- Timestamp:
- 08/20/11 19:17:53 (13 years ago)
- Location:
- ps/trunk
- Files:
-
- 5 added
- 11 edited
-
binaries/data/mods/public/art/textures/ui/pregame/backgrounds (added)
-
binaries/data/mods/public/art/textures/ui/pregame/backgrounds/hellenes1-1.png (added)
-
binaries/data/mods/public/art/textures/ui/pregame/backgrounds/hellenes1-2.png (added)
-
binaries/data/mods/public/art/textures/ui/pregame/backgrounds/hellenes1-3.png (added)
-
binaries/data/mods/public/art/textures/ui/pregame/backgrounds/textures.xml (added)
-
binaries/data/mods/public/gui/pregame/mainmenu.js (modified) (2 diffs)
-
binaries/data/mods/public/gui/pregame/mainmenu.xml (modified) (3 diffs)
-
binaries/data/mods/public/gui/pregame/sprites.xml (modified) (1 diff)
-
source/gui/CGUI.cpp (modified) (2 diffs)
-
source/gui/CGUISprite.h (modified) (3 diffs)
-
source/gui/GUIRenderer.cpp (modified) (5 diffs)
-
source/gui/IGUIObject.h (modified) (1 diff)
-
source/gui/scripting/JSInterface_IGUIObject.cpp (modified) (3 diffs)
-
source/gui/scripting/JSInterface_IGUIObject.h (modified) (1 diff)
-
source/ps/Overlay.cpp (modified) (1 diff)
-
source/ps/Overlay.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.js
r8925 r10042 8 8 9 9 userReportEnabledText = getGUIObjectByName("userReportEnabledText").caption; 10 } 11 12 var t0 = new Date; 13 function scrollBackgrounds() 14 { 15 var layer1 = getGUIObjectByName("backgroundLayer1"); 16 var layer2 = getGUIObjectByName("backgroundLayer2"); 17 var layer3 = getGUIObjectByName("backgroundLayer3"); 18 19 var screen = layer1.parent.getComputedSize(); 20 var h = screen.bottom - screen.top; // height of screen 21 var w = h*16/9; // width of background image 22 23 // Offset the layers by oscillating amounts 24 var t = (t0 - new Date) / 1000; 25 var speed = 1/10; 26 var off1 = 0.10 * w * (1+Math.cos(t*speed)); 27 var off2 = 0.18 * w * (1+Math.cos(t*speed)) - h*6/9; 28 var off3 = 0.20 * w * (1+Math.cos(t*speed)); 29 30 var left = screen.right - w * (1 + Math.ceil(screen.right / w)); 31 layer1.size = new GUISize(left + off1, screen.top, screen.right + off1, screen.bottom); 32 33 layer2.size = new GUISize(screen.right - h + off2, screen.top, screen.right + off2, screen.bottom); 34 layer3.size = new GUISize(screen.right - h + off3, screen.top, screen.right + off3, screen.bottom); 10 35 } 11 36 … … 56 81 function onTick() 57 82 { 83 scrollBackgrounds(); 84 58 85 if (Engine.IsUserReportEnabled()) 59 86 { -
ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.xml
r9949 r10042 14 14 <object type="image" sprite="bkFillBlack"/> 15 15 16 <object name="pg" 17 type="image" 18 sprite="pgBackground" 19 aspectratio="1.333333" 20 > 16 <object name="pg"> 17 18 <object name="backgroundLayer1" 19 type="image" 20 sprite="background-hellenes1-1" 21 /> 22 <object name="backgroundLayer2" 23 type="image" 24 sprite="background-hellenes1-2" 25 /> 26 <object name="backgroundLayer3" 27 type="image" 28 sprite="background-hellenes1-3" 29 /> 21 30 22 31 <action on="Tick"> … … 446 455 <object 447 456 name="userReportDisabled" 448 size="100%-30 0 300 100% 450"457 size="100%-304 100%-154 100%-4 100%-4" 449 458 type="image" 450 459 style="userReportPanel" … … 469 478 <object 470 479 name="userReportEnabled" 471 size="100%-304 300 100%-4 590"480 size="100%-304 100%-294 100%-4 100%-4" 472 481 type="image" 473 482 style="userReportPanel" -
ps/trunk/binaries/data/mods/public/gui/pregame/sprites.xml
r8925 r10042 3 3 <sprites> 4 4 5 <!-- 6 ========================================== 7 PREGAME GUI - TEXTURE SPRITES - BACKDROPS 8 ========================================== 9 --> 5 <sprite name="background-hellenes1-1"> 6 <image 7 texture="pregame/backgrounds/hellenes1-1.png" 8 fixed_h_aspect_ratio="1.777777" 9 round_coordinates="false" 10 /> 11 </sprite> 10 12 11 <sprite name="pgBackground"> 12 <image texture="pregame/shell/parchment/background.dds" 13 real_texture_placement="0 0 1024 768" 14 size="0 0 100% 100%" 13 <sprite name="background-hellenes1-2"> 14 <image 15 texture="pregame/backgrounds/hellenes1-2.png" 16 round_coordinates="false" 17 wrap_mode="clamp_to_edge" 18 /> 19 </sprite> 20 21 <sprite name="background-hellenes1-3"> 22 <image 23 texture="pregame/backgrounds/hellenes1-3.png" 24 round_coordinates="false" 25 wrap_mode="clamp_to_edge" 15 26 /> 16 27 </sprite> -
ps/trunk/source/gui/CGUI.cpp
r9852 r10042 1 /* Copyright (C) 201 0Wildfire Games.1 /* Copyright (C) 2011 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 1591 1591 } 1592 1592 else 1593 if (attr_name == "fixed_h_aspect_ratio") 1594 { 1595 float val; 1596 if (!GUI<float>::ParseString(attr_value, val)) 1597 LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); 1598 else image.m_FixedHAspectRatio = val; 1599 } 1600 else 1601 if (attr_name == "round_coordinates") 1602 { 1603 bool b; 1604 if (!GUI<bool>::ParseString(attr_value, b)) 1605 LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); 1606 else image.m_RoundCoordinates = b; 1607 } 1608 else 1609 if (attr_name == "wrap_mode") 1610 { 1611 if (attr_value == L"repeat") 1612 image.m_WrapMode = GL_REPEAT; 1613 else if (attr_value == L"mirrored_repeat") 1614 image.m_WrapMode = GL_MIRRORED_REPEAT; 1615 else if (attr_value == L"clamp_to_edge") 1616 image.m_WrapMode = GL_CLAMP_TO_EDGE; 1617 else if (attr_value == L"clamp_to_border") 1618 image.m_WrapMode = GL_CLAMP_TO_BORDER; 1619 else 1620 LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); 1621 } 1622 else 1593 1623 if (attr_name == "z_level") 1594 1624 { -
ps/trunk/source/gui/CGUISprite.h
r7813 r10042 1 /* Copyright (C) 20 09Wildfire Games.1 /* Copyright (C) 2011 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 78 78 struct SGUIImage 79 79 { 80 SGUIImage() : m_Effects(NULL), m_Border(false), m_DeltaZ(0.f) {} 80 SGUIImage() : 81 m_FixedHAspectRatio(0.f), m_RoundCoordinates(true), m_WrapMode(GL_REPEAT), 82 m_Effects(NULL), m_Border(false), m_DeltaZ(0.f) 83 { 84 } 81 85 82 86 // Filename of the texture … … 99 103 // Equal to CSize(0,0) for non-celled textures. 100 104 CSize m_CellSize; 105 106 /** 107 * If non-zero, then the image's width will be adjusted when rendering so that 108 * the width:height ratio equals this value. 109 */ 110 float m_FixedHAspectRatio; 111 112 /** 113 * If true, the image's coordinates will be rounded to integer pixels when 114 * rendering, to avoid blurry filtering. 115 */ 116 bool m_RoundCoordinates; 117 118 /** 119 * Texture wrapping mode (GL_REPEAT, GL_CLAMP_TO_BORDER, etc) 120 */ 121 GLint m_WrapMode; 101 122 102 123 // Visual effects (e.g. colour modulation) -
ps/trunk/source/gui/GUIRenderer.cpp
r9362 r10042 1 /* Copyright (C) 201 0Wildfire Games.1 /* Copyright (C) 2011 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * … … 453 453 454 454 Call.m_Vertices = ObjectSize; 455 // Round the vertex coordinates to integers, to avoid ugly filtering artifacts 456 Call.m_Vertices.left = (int)(Call.m_Vertices.left + 0.5f); 457 Call.m_Vertices.right = (int)(Call.m_Vertices.right + 0.5f); 458 Call.m_Vertices.top = (int)(Call.m_Vertices.top + 0.5f); 459 Call.m_Vertices.bottom = (int)(Call.m_Vertices.bottom + 0.5f); 455 if (cit->m_RoundCoordinates) 456 { 457 // Round the vertex coordinates to integers, to avoid ugly filtering artifacts 458 Call.m_Vertices.left = (int)(Call.m_Vertices.left + 0.5f); 459 Call.m_Vertices.right = (int)(Call.m_Vertices.right + 0.5f); 460 Call.m_Vertices.top = (int)(Call.m_Vertices.top + 0.5f); 461 Call.m_Vertices.bottom = (int)(Call.m_Vertices.bottom + 0.5f); 462 } 460 463 461 464 if (! cit->m_TextureName.empty()) 462 465 { 463 466 CTextureProperties textureProps(cit->m_TextureName); 467 textureProps.SetWrap(cit->m_WrapMode); 464 468 CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps); 465 469 texture->Prefetch(); … … 535 539 // Get the screen's position/size for the block 536 540 CRect BlockScreen = m_Image->m_TextureSize.GetClientArea(m_ObjectSize); 541 542 if (m_Image->m_FixedHAspectRatio) 543 BlockScreen.right = BlockScreen.left + BlockScreen.GetHeight() * m_Image->m_FixedHAspectRatio; 537 544 538 545 // Get the texture's position/size for the block: … … 594 601 glDisable(GL_BLEND); 595 602 603 // Set LOD bias so mipmapped textures are prettier 604 glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -1.f); 605 596 606 // Iterate through each DrawCall, and execute whatever drawing code is being called 597 607 for (DrawCalls::const_iterator cit = Calls.begin(); cit != Calls.end(); ++cit) … … 671 681 glDisable(GL_BLEND); 672 682 } 673 } 683 684 glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0.f); 685 } -
ps/trunk/source/gui/IGUIObject.h
r9862 r10042 148 148 friend JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsid id, jsval* vp); 149 149 friend JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsid id, JSBool strict, jsval* vp); 150 friend JSBool JSI_IGUIObject::getComputedSize(JSContext* cx, uintN argc, jsval* vp); 150 151 151 152 public: -
ps/trunk/source/gui/scripting/JSInterface_IGUIObject.cpp
r9852 r10042 50 50 { "focus", JSI_IGUIObject::focus, 0, 0 }, 51 51 { "blur", JSI_IGUIObject::blur, 0, 0 }, 52 { "getComputedSize", JSI_IGUIObject::getComputedSize, 0, 0 }, 52 53 { 0 } 53 54 }; … … 76 77 propName == "toString" || 77 78 propName == "focus" || 78 propName == "blur" 79 propName == "blur" || 80 propName == "getComputedSize" 79 81 ) 80 82 return JS_TRUE; … … 648 650 return JS_TRUE; 649 651 } 652 653 JSBool JSI_IGUIObject::getComputedSize(JSContext* cx, uintN argc, jsval* vp) 654 { 655 UNUSED2(argc); 656 657 IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL); 658 if (!e) 659 return JS_FALSE; 660 661 e->UpdateCachedSize(); 662 CRect size = e->m_CachedActualSize; 663 664 JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL); 665 try 666 { 667 g_ScriptingHost.SetObjectProperty_Double(obj, "left", size.left); 668 g_ScriptingHost.SetObjectProperty_Double(obj, "right", size.right); 669 g_ScriptingHost.SetObjectProperty_Double(obj, "top", size.top); 670 g_ScriptingHost.SetObjectProperty_Double(obj, "bottom", size.bottom); 671 } 672 catch (PSERROR_Scripting_ConversionFailed) 673 { 674 debug_warn(L"Error creating size object!"); 675 return JS_FALSE; 676 } 677 678 JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); 679 return JS_TRUE; 680 } -
ps/trunk/source/gui/scripting/JSInterface_IGUIObject.h
r9852 r10042 32 32 JSBool focus(JSContext* cx, uintN argc, jsval* vp); 33 33 JSBool blur(JSContext* cx, uintN argc, jsval* vp); 34 JSBool getComputedSize(JSContext* cx, uintN argc, jsval* vp); 34 35 void init(); 35 36 } -
ps/trunk/source/ps/Overlay.cpp
r7813 r10042 250 250 } 251 251 252 CPos CRect::TopRight() const 253 { 254 return CPos(right, top); 255 } 256 257 CPos CRect::BottomLeft() const 258 { 259 return CPos(left, bottom); 260 } 261 252 262 CPos CRect::BottomRight() const 253 263 { 254 return CPos(right, right);264 return CPos(right, bottom); 255 265 } 256 266 -
ps/trunk/source/ps/Overlay.h
r10017 r10042 121 121 122 122 /** 123 * Get Position equivalent to top/right corner 124 */ 125 CPos TopRight() const; 126 127 /** 128 * Get Position equivalent to bottom/left corner 129 */ 130 CPos BottomLeft() const; 131 132 /** 123 133 * Get Position equivalent to bottom/right corner 124 134 */
Note:
See TracChangeset
for help on using the changeset viewer.
