Skip to content

Commit 38179fb

Browse files
joye-ramonexrSimpAI
authored andcommitted
Допилил советы при загрузке. Настройка почти как в ЗП, только рендом в движке.
Так же, в можно указать максимальное число советов в <loading_tip number_of_tips=123>
1 parent e4b7b14 commit 38179fb

File tree

9 files changed

+40
-9
lines changed

9 files changed

+40
-9
lines changed

ogsr_engine/xrGame/GamePersistent.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,11 @@ void CGamePersistent::LoadTitle(const char* str)
727727
Discord.Update(tittle);
728728
}
729729

730+
void CGamePersistent::SetTip()
731+
{
732+
pApp->LoadTitleInt();
733+
}
734+
730735
bool CGamePersistent::CanBePaused() { return (g_pGamePersistent->GameType() == GAME_SINGLE); }
731736

732737
bool CGamePersistent::OnKeyboardPress(int dik)

ogsr_engine/xrGame/GamePersistent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class CGamePersistent : public IGame_Persistent, public IEventReceiver
8080
virtual void OnRenderPPUI_main();
8181
virtual void OnRenderPPUI_PP();
8282
virtual void LoadTitle(const char* title_name);
83+
virtual void SetTip();
8384

8485
virtual bool CanBePaused();
8586
bool OnKeyboardPress(int dik);

ogsr_engine/xrGame/alife_update_manager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ void CALifeUpdateManager::load(LPCSTR game_name, bool no_assert, bool new_only)
252252
Msg("* Loading alife simulator is successfully completed (%7.3f Mb)", float(Memory.mem_usage() - memory_usage) / 1048576.0);
253253
#endif
254254
g_pGamePersistent->LoadTitle("st_server_connecting");
255+
g_pGamePersistent->SetTip();
255256
}
256257

257258
void CALifeUpdateManager::reload(LPCSTR section)

ogsr_engine/xrGame/ui/UILoadingScreen.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
#include "UIHelper.h"
1414
#include "xrUIXmlParser.h"
1515
#include "UIXmlInit.h"
16+
#include "string_table.h"
1617

1718
UILoadingScreen::UILoadingScreen()
18-
: loadingProgress(nullptr), loadingProgressPercent(nullptr), loadingLogo(nullptr), loadingStage(nullptr), loadingHeader(nullptr), loadingTipNumber(nullptr), loadingTip(nullptr)
19+
: loadingProgress(nullptr), loadingProgressPercent(nullptr), loadingLogo(nullptr), loadingStage(nullptr), loadingHeader(nullptr), loadingTipNumber(nullptr), loadingTip(nullptr), maxTip(100)
1920
{
2021
UILoadingScreen::Initialize();
2122
}
@@ -44,9 +45,13 @@ void UILoadingScreen::Initialize()
4445
loadingLogo = UIHelper::CreateStatic(uiXml, "loading_logo", this, false);
4546
loadingProgressPercent = UIHelper::CreateStatic(uiXml, "loading_progress_percent", this, false);
4647
loadingStage = UIHelper::CreateStatic(uiXml, "loading_stage", this, false);
48+
4749
loadingHeader = UIHelper::CreateStatic(uiXml, "loading_header", this, false);
50+
4851
loadingTipNumber = UIHelper::CreateStatic(uiXml, "loading_tip_number", this, false);
4952
loadingTip = UIHelper::CreateStatic(uiXml, "loading_tip", this, false);
53+
54+
maxTip = uiXml.ReadAttribInt("loading_tip", 0, "number_of_tips", maxTip);
5055
}
5156

5257
void UILoadingScreen::Update(const int stagesCompleted, const int stagesTotal)
@@ -120,13 +125,29 @@ void UILoadingScreen::SetStageTitle(const char* title)
120125
loadingStage->SetText(title);
121126
}
122127

123-
void UILoadingScreen::SetStageTip(const char* header, const char* tipNumber, const char* tip)
128+
void UILoadingScreen::SetStageTip()
124129
{
125130
std::scoped_lock<decltype(loadingLock)> lock(loadingLock);
126131

127-
loadingHeader->SetText(header);
128-
loadingTipNumber->SetText(tipNumber);
129-
loadingTip->SetText(tip);
132+
u8 tip_num = Random.randI(1, maxTip);
133+
134+
string512 buff;
135+
136+
if (loadingHeader)
137+
{
138+
loadingHeader->SetText(CStringTable().translate("ls_header").c_str());
139+
}
140+
if (loadingTipNumber)
141+
{
142+
xr_sprintf(buff, "%s%d:", CStringTable().translate("ls_tip_number").c_str(), tip_num);
143+
shared_str tipNumber = buff;
144+
loadingTipNumber->SetText(tipNumber.c_str());
145+
}
146+
if (loadingTip)
147+
{
148+
xr_sprintf(buff, "ls_tip_%d", tip_num);
149+
loadingTip->SetText(CStringTable().translate(buff).c_str());
150+
}
130151
}
131152

132153
void UILoadingScreen::Show(bool status) { CUIWindow::Show(status); }

ogsr_engine/xrGame/ui/UILoadingScreen.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class UILoadingScreen : public ILoadingScreen, public CUIWindow
2626
CUIStatic* loadingTipNumber;
2727
CUIStatic* loadingTip;
2828

29+
u32 maxTip;
30+
2931
public:
3032
UILoadingScreen();
3133

@@ -40,5 +42,5 @@ class UILoadingScreen : public ILoadingScreen, public CUIWindow
4042

4143
void SetLevelLogo(const char* name) override;
4244
void SetStageTitle(const char* title) override;
43-
void SetStageTip(const char* header, const char* tipNumber, const char* tip) override;
45+
void SetStageTip() override;
4446
};

ogsr_engine/xr_3da/IGame_Persistent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class ENGINE_API IGame_Persistent : public DLL_Pure, public pureAppStart, public
9292
u32 GameType() { return m_game_params.m_e_game_type; };
9393
virtual void Statistics(CGameFont* F) = 0;
9494
virtual void LoadTitle(const char* title_name) = 0;
95+
virtual void SetTip() = 0;
9596

9697
virtual bool CanBePaused() { return true; }
9798
};

ogsr_engine/xr_3da/ILoadingScreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ class ILoadingScreen
2424

2525
virtual void SetLevelLogo(const char* name) = 0;
2626
virtual void SetStageTitle(const char* title) = 0;
27-
virtual void SetStageTip(const char* header, const char* tipNumber, const char* tip) = 0;
27+
virtual void SetStageTip() = 0;
2828
};

ogsr_engine/xr_3da/x_ray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ void CApplication::LoadForceFinish() { loadingScreen->ForceFinish(); }
604604

605605
void CApplication::SetLoadStageTitle(pcstr _ls_title) { loadingScreen->SetStageTitle(_ls_title); }
606606

607-
void CApplication::LoadTitleInt(LPCSTR str1, LPCSTR str2, LPCSTR str3) { loadingScreen->SetStageTip(str1, str2, str3); }
607+
void CApplication::LoadTitleInt() { loadingScreen->SetStageTip(); }
608608

609609
void CApplication::LoadStage()
610610
{

ogsr_engine/xr_3da/x_ray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ENGINE_API CApplication : public pureFrame, public IEventReceiver
3838
// Loading
3939
void LoadBegin();
4040
void LoadEnd();
41-
void LoadTitleInt(LPCSTR str1, LPCSTR str2, LPCSTR str3); // 100 советов по выживанию в Зоне
41+
void LoadTitleInt(); // 100 советов по выживанию в Зоне
4242
void LoadStage();
4343
void LoadDraw();
4444
void LoadForceFinish();

0 commit comments

Comments
 (0)