This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 10042 for ps


Ignore:
Timestamp:
08/20/11 19:17:53 (13 years ago)
Author:
philip
Message:

# New menu background image

Location:
ps/trunk
Files:
5 added
11 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.js

    r8925 r10042  
    88
    99    userReportEnabledText = getGUIObjectByName("userReportEnabledText").caption;
     10}
     11
     12var t0 = new Date;
     13function 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);
    1035}
    1136
     
    5681function onTick()
    5782{
     83    scrollBackgrounds();
     84
    5885    if (Engine.IsUserReportEnabled())
    5986    {
  • ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.xml

    r9949 r10042  
    1414    <object type="image" sprite="bkFillBlack"/>
    1515
    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        />
    2130
    2231        <action on="Tick">
     
    446455        <object
    447456            name="userReportDisabled"
    448             size="100%-300 300 100% 450"
     457            size="100%-304 100%-154 100%-4 100%-4"
    449458            type="image"
    450459            style="userReportPanel"
     
    469478        <object
    470479            name="userReportEnabled"
    471             size="100%-304 300 100%-4 590"
     480            size="100%-304 100%-294 100%-4 100%-4"
    472481            type="image"
    473482            style="userReportPanel"
  • ps/trunk/binaries/data/mods/public/gui/pregame/sprites.xml

    r8925 r10042  
    33<sprites>
    44
    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>
    1012
    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"
    1526            />
    1627        </sprite>
  • ps/trunk/source/gui/CGUI.cpp

    r9852 r10042  
    1 /* Copyright (C) 2010 Wildfire Games.
     1/* Copyright (C) 2011 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
     
    15911591        }
    15921592        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
    15931623        if (attr_name == "z_level")
    15941624        {
  • ps/trunk/source/gui/CGUISprite.h

    r7813 r10042  
    1 /* Copyright (C) 2009 Wildfire Games.
     1/* Copyright (C) 2011 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
     
    7878struct SGUIImage
    7979{
    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    }
    8185
    8286    // Filename of the texture
     
    99103    //  Equal to CSize(0,0) for non-celled textures.
    100104    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;
    101122
    102123    // Visual effects (e.g. colour modulation)
  • ps/trunk/source/gui/GUIRenderer.cpp

    r9362 r10042  
    1 /* Copyright (C) 2010 Wildfire Games.
     1/* Copyright (C) 2011 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
     
    453453
    454454        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        }
    460463
    461464        if (! cit->m_TextureName.empty())
    462465        {
    463466            CTextureProperties textureProps(cit->m_TextureName);
     467            textureProps.SetWrap(cit->m_WrapMode);
    464468            CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps);
    465469            texture->Prefetch();
     
    535539    // Get the screen's position/size for the block
    536540    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;
    537544
    538545    // Get the texture's position/size for the block:
     
    594601    glDisable(GL_BLEND);
    595602
     603    // Set LOD bias so mipmapped textures are prettier
     604    glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -1.f);
     605
    596606    // Iterate through each DrawCall, and execute whatever drawing code is being called
    597607    for (DrawCalls::const_iterator cit = Calls.begin(); cit != Calls.end(); ++cit)
     
    671681        glDisable(GL_BLEND);
    672682    }
    673 }
     683
     684    glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0.f);
     685}
  • ps/trunk/source/gui/IGUIObject.h

    r9862 r10042  
    148148    friend JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsid id, jsval* vp);
    149149    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);
    150151
    151152public:
  • ps/trunk/source/gui/scripting/JSInterface_IGUIObject.cpp

    r9852 r10042  
    5050    { "focus", JSI_IGUIObject::focus, 0, 0 },
    5151    { "blur", JSI_IGUIObject::blur, 0, 0 },
     52    { "getComputedSize", JSI_IGUIObject::getComputedSize, 0, 0 },
    5253    { 0 }
    5354};
     
    7677        propName == "toString"    ||
    7778        propName == "focus"       ||
    78         propName == "blur"
     79        propName == "blur"        ||
     80        propName == "getComputedSize"
    7981       )
    8082        return JS_TRUE;
     
    648650    return JS_TRUE;
    649651}
     652
     653JSBool 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  
    3232    JSBool focus(JSContext* cx, uintN argc, jsval* vp);
    3333    JSBool blur(JSContext* cx, uintN argc, jsval* vp);
     34    JSBool getComputedSize(JSContext* cx, uintN argc, jsval* vp);
    3435    void init();
    3536}
  • ps/trunk/source/ps/Overlay.cpp

    r7813 r10042  
    250250}
    251251
     252CPos CRect::TopRight() const
     253{
     254    return CPos(right, top);
     255}
     256
     257CPos CRect::BottomLeft() const
     258{
     259    return CPos(left, bottom);
     260}
     261
    252262CPos CRect::BottomRight() const
    253263{
    254     return CPos(right, right);
     264    return CPos(right, bottom);
    255265}
    256266
  • ps/trunk/source/ps/Overlay.h

    r10017 r10042  
    121121
    122122    /**
     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    /**
    123133     * Get Position equivalent to bottom/right corner
    124134     */
Note: See TracChangeset for help on using the changeset viewer.