Ticket #2622: gui_moddability.2.diff

File gui_moddability.2.diff, 23.2 KB (added by sanderd17, 10 years ago)

Fixed whitespace, added recursion check, don't reload the same script twice, added comments and warnings

  • binaries/data/mods/public/gui/session/diplomacy_window.xml

     
     1<?xml version="1.0" encoding="utf-8"?>
     2
     3<objects>
     4    <object name="diplomacyDialogPanel"
     5        size="50%-300 50%-200 50%+300 50%+150"
     6        type="image"
     7        hidden="true"
     8        sprite="ModernDialog"
     9    >
     10        <object type="text" style="TitleText" size="50%-96 -16 50%+96 16">
     11            <translatableAttribute id="caption">Diplomacy</translatableAttribute>
     12        </object>
     13
     14        <object name="diplomacyHeader" size="32 32 100%-32 64">
     15            <object name="diplomacyHeaderName" size="0 0 150 100%" type="text" style="chatPanel" ghost="true">
     16                <translatableAttribute id="caption">Name</translatableAttribute>
     17            </object>
     18            <object name="diplomacyHeaderCiv" size="150 0 250 100%" type="text" style="chatPanel" ghost="true">
     19                <translatableAttribute id="caption">Civilization</translatableAttribute>
     20            </object>
     21            <object name="diplomacyHeaderTeam" size="250 0 300 100%" type="text" style="chatPanel" ghost="true">
     22                <translatableAttribute id="caption">Team</translatableAttribute>
     23            </object>
     24            <object name="diplomacyHeaderTheirs" size="300 0 360 100%" type="text" style="chatPanel" ghost="true">
     25                <translatableAttribute id="caption">Theirs</translatableAttribute>
     26            </object>
     27            <object name="diplomacyHeaderAlly" size="100%-180 0 100%-160 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
     28                <translatableAttribute id="caption">A</translatableAttribute>
     29                <translatableAttribute id="tooltip">Ally</translatableAttribute>
     30            </object>
     31            <object name="diplomacyHeaderNeutral" size="100%-160 0 100%-140 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
     32                <translatableAttribute id="caption">N</translatableAttribute>
     33                <translatableAttribute id="tooltip">Neutral</translatableAttribute>
     34            </object>
     35            <object name="diplomacyHeaderEnemy" size="100%-140 0 100%-120 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
     36                <translatableAttribute id="caption">E</translatableAttribute>
     37                <translatableAttribute id="tooltip">Enemy</translatableAttribute>
     38            </object>
     39            <object name="diplomacyHeaderTribute" size="100%-110 0 100% 100%" type="text" style="chatPanel">
     40                <translatableAttribute id="caption">Tribute</translatableAttribute>
     41            </object>
     42        </object>
     43        <object size="32 64 100%-32 384">
     44            <repeat count="16">
     45                <object name="diplomacyPlayer[n]" size="0 0 100% 20" type="image" hidden="false">
     46                    <object name="diplomacyPlayerName[n]" size="0 0 150 100%" type="text" style="chatPanel" ghost="true"/>
     47                    <object name="diplomacyPlayerCiv[n]" size="150 0 250 100%" type="text" style="chatPanel" ghost="true"/>
     48                    <object name="diplomacyPlayerTeam[n]" size="250 0 300 100%" type="text" style="chatPanel" ghost="true"/>
     49                    <object name="diplomacyPlayerTheirs[n]" size="300 0 360 100%" type="text" style="chatPanel" ghost="true"/>
     50
     51                    <!-- Diplomatic stance - selection -->
     52                    <object name="diplomacyPlayerAlly[n]" size="100%-180 0 100%-160 100%" type="button" style="StoneButton" hidden="true"/>
     53                    <object name="diplomacyPlayerNeutral[n]" size="100%-160 0 100%-140 100%" type="button" style="StoneButton" hidden="true"/>
     54                    <object name="diplomacyPlayerEnemy[n]" size="100%-140 0 100%-120 100%" type="button" style="StoneButton" hidden="true"/>
     55
     56                    <!-- Tribute -->
     57                    <object name="diplomacyPlayerTributeFood[n]" size="100%-110 0 100%-90 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
     58                        <object name="diplomacyPlayerTributeFoodImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/food.png" ghost="true"/>
     59                    </object>
     60                    <object name="diplomacyPlayerTributeWood[n]" size="100%-90 0 100%-70 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
     61                        <object name="diplomacyPlayerTributeWoodImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/wood.png" ghost="true"/>
     62                    </object>
     63                    <object name="diplomacyPlayerTributeStone[n]" size="100%-70 0 100%-50 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
     64                        <object name="diplomacyPlayerTributeStoneImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/stone.png" ghost="true"/>
     65                    </object>
     66                    <object name="diplomacyPlayerTributeMetal[n]" size="100%-50 0 100%-30 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
     67                        <object name="diplomacyPlayerTributeMetalImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/metal.png" ghost="true"/>
     68                    </object>
     69                </object>
     70            </repeat>
     71        </object>
     72
     73        <object size="50%-64 100%-50 50%+64 100%-22" type="button" style="StoneButton">
     74            <translatableAttribute id="caption">Close</translatableAttribute>
     75            <action on="Press">closeDiplomacy();</action>
     76        </object>
     77    </object>
     78</objects>
  • binaries/data/mods/public/gui/session/session.xml

    Property changes on: binaries/data/mods/public/gui/session/diplomacy_window.xml
    ___________________________________________________________________
    Added: svn:mime-type
    ## -0,0 +1 ##
    +text/xml
    \ No newline at end of property
    Added: svn:eol-style
    ## -0,0 +1 ##
    +native
    \ No newline at end of property
     
    88<script file="gui/common/music.js"/>
    99<script file="gui/common/timer.js"/>
    1010<script file="gui/common/colorFades.js"/>
    11 <script file="gui/session/session.js"/>
    12 <script file="gui/session/selection.js"/>
     11<!-- load the placement script befor all other session scripts -->
    1312<script file="gui/session/placement.js"/>
    14 <script file="gui/session/input.js"/>
    15 <script file="gui/session/menu.js"/>
    16 <script file="gui/session/selection_details.js"/>
    17 <script file="gui/session/unit_commands.js"/>
    18 <script file="gui/session/messages.js"/>
    19 <script file="gui/session/utility_functions.js"/>
     13<script directory="gui/session/"/>
    2014
    2115<object name="sn" hotkey="session.gui.toggle">
    2216    <action on="Tick">
     
    412406    <!-- ================================  ================================ -->
    413407    <!-- Diplomacy Window -->
    414408    <!-- ================================  ================================ -->
    415     <object name="diplomacyDialogPanel"
    416         size="50%-300 50%-200 50%+300 50%+150"
    417         type="image"
    418         hidden="true"
    419         sprite="ModernDialog"
    420     >
    421         <object type="text" style="TitleText" size="50%-96 -16 50%+96 16">
    422             <translatableAttribute id="caption">Diplomacy</translatableAttribute>
    423         </object>
     409    <object include="gui/session/diplomacy_window.xml" />
    424410
    425         <object name="diplomacyHeader" size="32 32 100%-32 64">
    426             <object name="diplomacyHeaderName" size="0 0 150 100%" type="text" style="chatPanel" ghost="true">
    427                 <translatableAttribute id="caption">Name</translatableAttribute>
    428             </object>
    429             <object name="diplomacyHeaderCiv" size="150 0 250 100%" type="text" style="chatPanel" ghost="true">
    430                 <translatableAttribute id="caption">Civilization</translatableAttribute>
    431             </object>
    432             <object name="diplomacyHeaderTeam" size="250 0 300 100%" type="text" style="chatPanel" ghost="true">
    433                 <translatableAttribute id="caption">Team</translatableAttribute>
    434             </object>
    435             <object name="diplomacyHeaderTheirs" size="300 0 360 100%" type="text" style="chatPanel" ghost="true">
    436                 <translatableAttribute id="caption">Theirs</translatableAttribute>
    437             </object>
    438             <object name="diplomacyHeaderAlly" size="100%-180 0 100%-160 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
    439                 <translatableAttribute id="caption">A</translatableAttribute>
    440                 <translatableAttribute id="tooltip">Ally</translatableAttribute>
    441             </object>
    442             <object name="diplomacyHeaderNeutral" size="100%-160 0 100%-140 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
    443                 <translatableAttribute id="caption">N</translatableAttribute>
    444                 <translatableAttribute id="tooltip">Neutral</translatableAttribute>
    445             </object>
    446             <object name="diplomacyHeaderEnemy" size="100%-140 0 100%-120 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
    447                 <translatableAttribute id="caption">E</translatableAttribute>
    448                 <translatableAttribute id="tooltip">Enemy</translatableAttribute>
    449             </object>
    450             <object name="diplomacyHeaderTribute" size="100%-110 0 100% 100%" type="text" style="chatPanel">
    451                 <translatableAttribute id="caption">Tribute</translatableAttribute>
    452             </object>
    453         </object>
    454 
    455         <object size="32 64 100%-32 384">
    456             <repeat count="16">
    457                 <object name="diplomacyPlayer[n]" size="0 0 100% 20" type="image" hidden="false">
    458                     <object name="diplomacyPlayerName[n]" size="0 0 150 100%" type="text" style="chatPanel" ghost="true"/>
    459                     <object name="diplomacyPlayerCiv[n]" size="150 0 250 100%" type="text" style="chatPanel" ghost="true"/>
    460                     <object name="diplomacyPlayerTeam[n]" size="250 0 300 100%" type="text" style="chatPanel" ghost="true"/>
    461                     <object name="diplomacyPlayerTheirs[n]" size="300 0 360 100%" type="text" style="chatPanel" ghost="true"/>
    462 
    463                     <!-- Diplomatic stance - selection -->
    464                     <object name="diplomacyPlayerAlly[n]" size="100%-180 0 100%-160 100%" type="button" style="StoneButton" hidden="true"/>
    465                     <object name="diplomacyPlayerNeutral[n]" size="100%-160 0 100%-140 100%" type="button" style="StoneButton" hidden="true"/>
    466                     <object name="diplomacyPlayerEnemy[n]" size="100%-140 0 100%-120 100%" type="button" style="StoneButton" hidden="true"/>
    467 
    468                     <!-- Tribute -->
    469                     <object name="diplomacyPlayerTributeFood[n]" size="100%-110 0 100%-90 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
    470                         <object name="diplomacyPlayerTributeFoodImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/food.png" ghost="true"/>
    471                     </object>
    472                     <object name="diplomacyPlayerTributeWood[n]" size="100%-90 0 100%-70 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
    473                         <object name="diplomacyPlayerTributeWoodImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/wood.png" ghost="true"/>
    474                     </object>
    475                     <object name="diplomacyPlayerTributeStone[n]" size="100%-70 0 100%-50 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
    476                         <object name="diplomacyPlayerTributeStoneImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/stone.png" ghost="true"/>
    477                     </object>
    478                     <object name="diplomacyPlayerTributeMetal[n]" size="100%-50 0 100%-30 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
    479                         <object name="diplomacyPlayerTributeMetalImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/metal.png" ghost="true"/>
    480                     </object>
    481                 </object>
    482             </repeat>
    483         </object>
    484 
    485         <object size="50%-64 100%-50 50%+64 100%-22" type="button" style="StoneButton">
    486             <translatableAttribute id="caption">Close</translatableAttribute>
    487             <action on="Press">closeDiplomacy();</action>
    488         </object>
    489     </object>
    490 
    491411    <!-- ================================  ================================ -->
    492412    <!-- Trade Window -->
    493413    <!-- ================================  ================================ -->
  • source/gui/CGUI.cpp

     
    6565extern int g_yres;
    6666
    6767const double SELECT_DBLCLICK_RATE = 0.5;
     68const u32 MAX_OBECT_DEPTH = 100; // Max number of nesting for GUI objects. Used to detect recursive inclusion
    6869
    6970InReaction CGUI::HandleEvent(const SDL_Event_* ev)
    7071{
     
    930931
    931932    // Check root element's (node) name so we know what kind of
    932933    //  data we'll be expecting
    933     CStr root_name (XeroFile.GetElementString(node.GetNodeName()));
     934    CStr root_name(XeroFile.GetElementString(node.GetNodeName()));
    934935
    935936    try
    936937    {
     
    993994            Xeromyces_ReadScript(child, pFile, Paths);
    994995        else
    995996            // Read in this whole object into the GUI
    996             Xeromyces_ReadObject(child, pFile, m_BaseObject, subst, Paths);
     997            Xeromyces_ReadObject(child, pFile, m_BaseObject, subst, Paths, 0);
    997998    }
    998999}
    9991000
     
    10361037
    10371038        // Read in this whole object into the GUI
    10381039
    1039         CStr name (pFile->GetElementString(child.GetNodeName()));
     1040        CStr name(pFile->GetElementString(child.GetNodeName()));
    10401041
    10411042        if (name == "scrollbar")
    10421043        {
     
    10641065    }
    10651066}
    10661067
    1067 void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths)
     1068void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth)
    10681069{
     1070    if (nesting_depth > MAX_OBECT_DEPTH)
     1071    {
     1072        LOGERROR(L"Too many nested GUI objects. Probably caused by a recursive include attribute. Abort rendering any deeper.");
     1073        return;
     1074    }
     1075
    10691076    ENSURE(pParent);
    10701077    int i;
    10711078
     
    11101117    ATTR(file);
    11111118    ATTR(id);
    11121119    ATTR(context);
     1120    ATTR(include);
    11131121
    11141122    //
    11151123    //  Read Style and set defaults
     
    11181126    //
    11191127    //  Always load default (if it's available) first!
    11201128    //
    1121     CStr argStyle (attributes.GetNamedItem(attr_style));
     1129    CStr argStyle(attributes.GetNamedItem(attr_style));
    11221130
    11231131    if (m_Styles.count("default") == 1)
    11241132        object->LoadStyle(*this, "default");
     
    11401148
    11411149    bool NameSet = false;
    11421150    bool ManuallySetZ = false; // if z has been manually set, this turn true
     1151    bool ExternalChildren = false;
    11431152
     1153    CStrW inclusionPath;
    11441154    CStr hotkeyTag;
    11451155
    11461156    // Now we can iterate all attributes and store
     
    11591169        // Also the name needs some special attention
    11601170        if (attr.Name == attr_name)
    11611171        {
    1162             CStr name (attr.Value);
     1172            CStr name(attr.Value);
    11631173
    11641174            // Apply the requested substitutions
    11651175            for (size_t j = 0; j < NameSubst.size(); ++j)
     
    11701180            continue;
    11711181        }
    11721182
     1183        if (attr.Name == attr_include)
     1184        {
     1185            ExternalChildren = true;
     1186            inclusionPath = attr.Value.FromUTF8();
     1187            continue;
     1188        }
     1189
    11731190        // Wire up the hotkey tag, if it has one
    11741191        if (attr.Name == attr_hotkey)
    11751192            hotkeyTag = attr.Value;
     
    11971214    if (! hotkeyTag.empty())
    11981215        m_HotkeyObjects[hotkeyTag].push_back(object);
    11991216
    1200     CStrW caption (Element.GetText().FromUTF8());
    1201     if (! caption.empty())
     1217    CStrW caption(Element.GetText().FromUTF8());
     1218    if (!caption.empty())
    12021219    {
    12031220        // Set the setting caption to this
    12041221        object->SetSetting("caption", caption, true);
     
    12111228    //  Read Children
    12121229    //
    12131230
    1214     // Iterate children
    12151231    XMBElementList children = Element.GetChildNodes();
     1232    CXeromyces XeroChildren;
     1233    if (ExternalChildren)
     1234    {
     1235        if (children.Count > 0)
     1236            LOGWARNING(L"GUI: Gui XML Object in has child nodes and an 'include' attribute (pointing to %ls). The child nodes will be ignored.", inclusionPath.c_str());
     1237        Paths.insert(inclusionPath);
    12161238
     1239        if (XeroChildren.Load(g_VFS, inclusionPath) == PSRETURN_OK)
     1240        {
     1241            XMBElement node = XeroChildren.GetRoot();
     1242
     1243            CStr root_name(XeroChildren.GetElementString(node.GetNodeName()));
     1244
     1245            if (root_name == "objects")
     1246                children = node.GetChildNodes();
     1247            else
     1248                LOGERROR(L"GUI: Error reading included XML: %ls, root element must have the name 'objects'.", inclusionPath.c_str());
     1249        }
     1250        else
     1251            LOGERROR(L"GUI: Error reading included XML: %ls", inclusionPath.c_str());
     1252
     1253        // set pFile to the new CXeromyces file, as it's only used to handle the children from now on
     1254        pFile = &XeroChildren;
     1255    }
     1256
     1257    // Iterate children
    12171258    for (i=0; i<children.Count; ++i)
    12181259    {
    12191260        // Get node
     
    12251266        if (element_name == elmt_object)
    12261267        {
    12271268            // Call this function on the child
    1228             Xeromyces_ReadObject(child, pFile, object, NameSubst, Paths);
     1269            Xeromyces_ReadObject(child, pFile, object, NameSubst, Paths, nesting_depth + 1);
    12291270        }
    12301271        else if (element_name == elmt_action)
    12311272        {
     
    12321273            // Scripted <action> element
    12331274
    12341275            // Check for a 'file' parameter
    1235             CStrW filename (child.GetAttributes().GetNamedItem(attr_file).FromUTF8());
     1276            CStrW filename(child.GetAttributes().GetNamedItem(attr_file).FromUTF8());
    12361277
    12371278            CStr code;
    12381279
    12391280            // If there is a file, open it and use it as the code
    1240             if (! filename.empty())
     1281            if (!filename.empty())
    12411282            {
    12421283                Paths.insert(filename);
    12431284                CVFSFile scriptfile;
     
    12801321        }
    12811322        else if (element_name == elmt_repeat)
    12821323        {
    1283             Xeromyces_ReadRepeat(child, pFile, object, Paths);
     1324            Xeromyces_ReadRepeat(child, pFile, object, Paths, nesting_depth);
    12841325        }
    12851326        else if (element_name == elmt_translatableAttribute)
    12861327        {
     
    13881429    }
    13891430}
    13901431
    1391 void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths)
     1432void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth)
    13921433{
    13931434    #define ELMT(x) int elmt_##x = pFile->GetElementID(#x)
    13941435    #define ATTR(x) int attr_##x = pFile->GetAttributeID(#x)
     
    14081449        {
    14091450            if (child.GetNodeName() == elmt_object)
    14101451            {
    1411                 Xeromyces_ReadObject(child, pFile, pParent, subst, Paths);
     1452                Xeromyces_ReadObject(child, pFile, pParent, subst, Paths, nesting_depth + 1);
    14121453            }
    14131454        }
    14141455    }
     
    14171458void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::unordered_set<VfsPath>& Paths)
    14181459{
    14191460    // Check for a 'file' parameter
    1420     CStrW file (Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("file") ).FromUTF8());
     1461    CStrW file(Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("file") ).FromUTF8());
    14211462
    14221463    // If there is a file specified, open and execute it
    1423     if (! file.empty())
     1464    if (!file.empty())
    14241465    {
    14251466        Paths.insert(file);
    14261467        try
     
    14331474        }
    14341475    }
    14351476
     1477    // If it has a directory attribute, read all JS files in that directory
     1478    CStrW directory(Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("directory") ).FromUTF8());
     1479    if (!directory.empty())
     1480    {
     1481        VfsPaths pathnames;
     1482        vfs::GetPathnames(g_VFS, directory, L"*.js", pathnames);
     1483        for (VfsPaths::iterator it = pathnames.begin(); it != pathnames.end(); ++it)
     1484        {
     1485            // only load new files (so when the insert succeeds)
     1486            if (Paths.insert(*it).second)
     1487            {
     1488                try
     1489                {
     1490                    m_ScriptInterface->LoadGlobalScriptFile(*it);
     1491                }
     1492                catch (PSERROR_Scripting& e)
     1493                {
     1494                    LOGERROR(L"GUI: Error executing script %ls: %hs", directory.c_str(), e.what());
     1495                }
     1496            }
     1497        }
     1498    }
     1499
    14361500    // Execute inline scripts
    14371501    try
    14381502    {
    1439         CStr code (Element.GetText());
    1440         if (! code.empty())
     1503        CStr code(Element.GetText());
     1504        if (!code.empty())
    14411505            m_ScriptInterface->LoadGlobalScript(L"Some XML file", code.FromUTF8());
    14421506    }
    14431507    catch (PSERROR_Scripting& e)
     
    14781542        // Get node
    14791543        XMBElement child = children.Item(i);
    14801544
    1481         CStr ElementName (pFile->GetElementString(child.GetNodeName()));
     1545        CStr ElementName(pFile->GetElementString(child.GetNodeName()));
    14821546
    14831547        if (ElementName == "image")
    14841548        {
     
    15061570    // different effects)
    15071571    if (effects)
    15081572        for (std::vector<SGUIImage*>::iterator it = Sprite->m_Images.begin(); it != Sprite->m_Images.end(); ++it)
    1509             if (! (*it)->m_Effects)
     1573            if (!(*it)->m_Effects)
    15101574                (*it)->m_Effects = new SGUIImageEffects(*effects); // do a copy just so it can be deleted correctly later
    15111575
    15121576    delete effects;
     
    15391603    for (int i=0; i<attributes.Count; ++i)
    15401604    {
    15411605        XMBAttribute attr = attributes.Item(i);
    1542         CStr attr_name (pFile->GetAttributeString(attr.Name));
    1543         CStrW attr_value (attr.Value.FromUTF8());
     1606        CStr attr_name(pFile->GetAttributeString(attr.Name));
     1607        CStrW attr_value(attr.Value.FromUTF8());
    15441608
    15451609        if (attr_name == "texture")
    15461610        {
     
    16491713    for (int i=0; i<children.Count; ++i)
    16501714    {
    16511715        XMBElement child = children.Item(i);
    1652         CStr ElementName (pFile->GetElementString(child.GetNodeName()));
     1716        CStr ElementName(pFile->GetElementString(child.GetNodeName()));
    16531717        if (ElementName == "effect")
    16541718        {
    16551719            if (Image->m_Effects)
     
    16811745    for (int i=0; i<attributes.Count; ++i)
    16821746    {
    16831747        XMBAttribute attr = attributes.Item(i);
    1684         CStr attr_name (pFile->GetAttributeString(attr.Name));
    1685         CStrW attr_value (attr.Value.FromUTF8());
     1748        CStr attr_name(pFile->GetAttributeString(attr.Name));
     1749        CStrW attr_value(attr.Value.FromUTF8());
    16861750
    16871751        if (attr_name == "add_color")
    16881752        {
     
    17171781    for (int i=0; i<attributes.Count; ++i)
    17181782    {
    17191783        XMBAttribute attr = attributes.Item(i);
    1720         CStr attr_name (pFile->GetAttributeString(attr.Name));
     1784        CStr attr_name(pFile->GetAttributeString(attr.Name));
    17211785
    17221786        // The "name" setting is actually the name of the style
    17231787        //  and not a new default
     
    17561820    {
    17571821        XMBAttribute attr = attributes.Item(i);
    17581822        CStr attr_name = pFile->GetAttributeString(attr.Name);
    1759         CStr attr_value (attr.Value);
     1823        CStr attr_value(attr.Value);
    17601824
    17611825        if (attr_value == "null")
    17621826            continue;
     
    18531917    for (int i=0; i<attributes.Count; ++i)
    18541918    {
    18551919        XMBAttribute attr = attributes.Item(i);
    1856         CStr attr_name (pFile->GetAttributeString(attr.Name));
    1857         CStr attr_value (attr.Value);
     1920        CStr attr_name(pFile->GetAttributeString(attr.Name));
     1921        CStr attr_value(attr.Value);
    18581922
    18591923        if (attr_value == "null")
    18601924            continue;
     
    19011965    for (int i=0; i<attributes.Count; ++i)
    19021966    {
    19031967        XMBAttribute attr = attributes.Item(i);
    1904         CStr attr_name (pFile->GetAttributeString(attr.Name));
    1905         CStr attr_value (attr.Value);
     1968        CStr attr_name(pFile->GetAttributeString(attr.Name));
     1969        CStr attr_value(attr.Value);
    19061970
    19071971        if (attr_name == "name")
    19081972        {
     
    19291993    CStr name = attributes.GetNamedItem(pFile->GetAttributeID("name"));
    19301994
    19311995    // Try parsing value
    1932     CStr value (Element.GetText());
    1933     if (! value.empty())
     1996    CStr value(Element.GetText());
     1997    if (!value.empty())
    19341998    {
    19351999        // Try setting color to value
    19362000        if (!color.ParseString(value))
  • source/gui/CGUI.h

     
    444444     *
    445445     * @see LoadXmlFile()
    446446     */
    447     void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths);
     447    void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth);
    448448
    449449    /**
    450450     * Reads in the element \<repeat\>, which repeats its child \<object\>s
     
    451451     * 'count' times, replacing the string "[n]" in its descendants' names
    452452     * with "[0]", "[1]", etc.
    453453     */
    454     void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths);
     454    void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth);
    455455
    456456    /**
    457457     * Reads in the element \<script\> (the XMBElement) and executes