Skip to content

Commit b39957d

Browse files
committed
UI Styles: check current style path and default path when searching xml
1 parent c3ced77 commit b39957d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+99
-72
lines changed

src/xrGame/EliteDetector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void CUIArtefactDetectorElite::construct(CEliteDetector* p)
7979
{
8080
m_parent = p;
8181
CUIXml uiXml;
82-
uiXml.Load(CONFIG_PATH, UI_PATH, "ui_detector_artefact.xml");
82+
uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_detector_artefact.xml");
8383

8484
CUIXmlInit xml_init;
8585
string512 buff;

src/xrGame/MainMenu.cpp

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <shellapi.h>
2929
#pragma comment(lib, "shell32.lib")
3030

31+
#include <tbb/parallel_for_each.h>
32+
3133
#include "Common/object_broker.h"
3234

3335
#include "account_manager.h"
@@ -150,16 +152,43 @@ CMainMenu::~CMainMenu()
150152
void CMainMenu::ReadTextureInfo()
151153
{
152154
string_path buf;
153-
FS_FileSet fset;
154-
FS.file_list(fset, "$game_config$", FS_ListFiles, strconcat(sizeof(buf), buf, UI_PATH, "\\", "textures_descr\\*.xml"));
155-
for (const auto& file : fset)
155+
FS_FileSet files;
156+
157+
const auto UpdateFileSet = [&](pcstr path)
156158
{
157-
string_path fn1, fn2, fn3;
158-
_splitpath(file.name.c_str(), fn1, fn2, fn3, 0);
159-
xr_strcat(fn3, ".xml");
159+
FS.file_list(files, "$game_config$", FS_ListFiles,
160+
strconcat(sizeof(buf), buf, path, "\\", "textures_descr\\*.xml")
161+
);
162+
};
160163

161-
CUITextureMaster::ParseShTexInfo(fn3);
162-
}
164+
const auto ParseFileSet = [&]()
165+
{
166+
/*
167+
* Original CoP textures_descr
168+
* loading time:
169+
* Single-threaded ~80 ms
170+
* Multi-threaded ~40 ms
171+
* Just a bit of speedup
172+
*/
173+
tbb::parallel_for_each(files, [](const FS_File& file)
174+
{
175+
string_path path, name;
176+
_splitpath(file.name.c_str(), nullptr, path, name, nullptr);
177+
xr_strcat(name, ".xml");
178+
path[xr_strlen(path) - 1] = '\0'; // cut the latest '\\'
179+
180+
CUITextureMaster::ParseShTexInfo(path, name);
181+
});
182+
};
183+
184+
UpdateFileSet(UI_PATH_DEFAULT);
185+
ParseFileSet();
186+
187+
if (0 == xr_strcmp(UI_PATH, UI_PATH_DEFAULT))
188+
return;
189+
190+
UpdateFileSet(UI_PATH);
191+
ParseFileSet();
163192
}
164193

165194
void CMainMenu::Activate(bool bActivate)

src/xrGame/Missile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void create_force_progress()
3232
{
3333
VERIFY(!g_MissileForceShape);
3434
CUIXml uiXml;
35-
uiXml.Load(CONFIG_PATH, UI_PATH, "grenade.xml");
35+
uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "grenade.xml");
3636

3737
CUIXmlInit xml_init;
3838
g_MissileForceShape = new CUIProgressShape();

src/xrGame/ScriptXMLInit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void _attach_child(CUIWindow* _child, CUIWindow* _parent)
3737
_parent->AttachChild(_child);
3838
}
3939

40-
void CScriptXmlInit::ParseFile(LPCSTR xml_file) { m_xml.Load(CONFIG_PATH, UI_PATH, xml_file); }
40+
void CScriptXmlInit::ParseFile(LPCSTR xml_file) { m_xml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, xml_file); }
4141
void CScriptXmlInit::InitWindow(LPCSTR path, int index, CUIWindow* pWnd)
4242
{
4343
CUIXmlInit::InitWindow(m_xml, path, index, pWnd);

src/xrGame/UIAchivementsIndicator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CUIAchivementIndicator::CUIAchivementIndicator()
1111
m_achivement_log = new CUIGameLog();
1212
AttachChild(m_achivement_log);
1313
CUIXml tmp_xml;
14-
tmp_xml.Load(CONFIG_PATH, UI_PATH, "ui_mp_achivements.xml");
14+
tmp_xml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_mp_achivements.xml");
1515
CUIXmlInit::InitWindow(tmp_xml, "mp_achivement_wnd", 0, this);
1616
CUIXmlInit::InitScrollView(tmp_xml, "mp_achivement_wnd:achivement_list", 0, m_achivement_log);
1717
}

src/xrGame/UIGameAHunt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void CUIGameAHunt::Init(int stage)
2828
m_pTeamPanels->Init(TEAM_PANELS_AHUNT_XML_NAME, "team_panels_wnd");
2929

3030
CUIXml uiXml;
31-
uiXml.Load(CONFIG_PATH, UI_PATH, "ui_game_ahunt.xml");
31+
uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_game_ahunt.xml");
3232

3333
CUIXmlInit::InitWindow(uiXml, "global", 0, Window);
3434
CUIXmlInit::InitTextWnd(uiXml, "fraglimit", 0, m_pFragLimitIndicator);

src/xrGame/UIGameCTA.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void CUIGameCTA::Init(int stage)
6666
teamPanels->Init(TEAM_PANELS_XML_NAME, "team_panels_wnd");
6767

6868
CUIXml uiXml;
69-
uiXml.Load(CONFIG_PATH, UI_PATH, CTA_GAME_WND_XML);
69+
uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, CTA_GAME_WND_XML);
7070

7171
CUIXmlInit::InitWindow(uiXml, "global", 0, Window);
7272

@@ -761,7 +761,7 @@ void CUIGameCTA::SetVoteMessage(LPCSTR str)
761761
if (str)
762762
{
763763
CUIXml uiXml;
764-
uiXml.Load(CONFIG_PATH, UI_PATH, "ui_game_dm.xml");
764+
uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_game_dm.xml");
765765
m_voteStatusWnd = new UIVoteStatusWnd();
766766
m_voteStatusWnd->InitFromXML(uiXml);
767767
m_voteStatusWnd->Show(true);

src/xrGame/UIGameCustom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void CUIGameCustom::Load()
247247
return;
248248
R_ASSERT(!MsgConfig);
249249
MsgConfig = new CUIXml();
250-
MsgConfig->Load(CONFIG_PATH, UI_PATH, "ui_custom_msgs.xml");
250+
MsgConfig->Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_custom_msgs.xml");
251251
R_ASSERT(!ActorMenu);
252252
ActorMenu = new CUIActorMenu();
253253
R_ASSERT(!PdaMenu);

src/xrGame/UIGameDM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void CUIGameDM::Init(int stage)
8585
{ // unique
8686
m_pTeamPanels->Init(TEAM_PANELS_DM_XML_NAME, "team_panels_wnd");
8787
CUIXml uiXml;
88-
uiXml.Load(CONFIG_PATH, UI_PATH, "ui_game_dm.xml");
88+
uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_game_dm.xml");
8989
CUIXmlInit::InitWindow(uiXml, "global", 0, Window);
9090
m_pMoneyIndicator->InitFromXML(uiXml);
9191
m_pRankIndicator->InitFromXml(uiXml);
@@ -144,7 +144,7 @@ void CUIGameDM::SetVoteMessage(LPCSTR str)
144144
if (!m_voteStatusWnd)
145145
{
146146
CUIXml uiXml;
147-
uiXml.Load(CONFIG_PATH, UI_PATH, "ui_game_dm.xml");
147+
uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_game_dm.xml");
148148
m_voteStatusWnd = new UIVoteStatusWnd();
149149
m_voteStatusWnd->InitFromXML(uiXml);
150150
}

src/xrGame/UIGameTDM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void CUIGameTDM::Init(int stage)
4747
m_pTeamPanels->Init(TEAM_PANELS_TDM_XML_NAME, "team_panels_wnd");
4848

4949
CUIXml uiXml, xml2;
50-
uiXml.Load(CONFIG_PATH, UI_PATH, "ui_game_tdm.xml");
50+
uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "ui_game_tdm.xml");
5151

5252
CUIXmlInit::InitWindow(uiXml, "global", 0, Window);
5353
CUIXmlInit::InitStatic(uiXml, "team1_icon", 0, m_team1_icon);

0 commit comments

Comments
 (0)