Skip to content

Commit

Permalink
Допилил советы при загрузке. Настройка почти как в ЗП, только рендом …
Browse files Browse the repository at this point in the history
…в движке.

Так же, в можно указать максимальное число советов в <loading_tip number_of_tips=123>
  • Loading branch information
joye-ramone authored and xrSimpodin committed Nov 8, 2022
1 parent e4b7b14 commit 38179fb
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 9 deletions.
5 changes: 5 additions & 0 deletions ogsr_engine/xrGame/GamePersistent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,11 @@ void CGamePersistent::LoadTitle(const char* str)
Discord.Update(tittle);
}

void CGamePersistent::SetTip()
{
pApp->LoadTitleInt();
}

bool CGamePersistent::CanBePaused() { return (g_pGamePersistent->GameType() == GAME_SINGLE); }

bool CGamePersistent::OnKeyboardPress(int dik)
Expand Down
1 change: 1 addition & 0 deletions ogsr_engine/xrGame/GamePersistent.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class CGamePersistent : public IGame_Persistent, public IEventReceiver
virtual void OnRenderPPUI_main();
virtual void OnRenderPPUI_PP();
virtual void LoadTitle(const char* title_name);
virtual void SetTip();

virtual bool CanBePaused();
bool OnKeyboardPress(int dik);
Expand Down
1 change: 1 addition & 0 deletions ogsr_engine/xrGame/alife_update_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void CALifeUpdateManager::load(LPCSTR game_name, bool no_assert, bool new_only)
Msg("* Loading alife simulator is successfully completed (%7.3f Mb)", float(Memory.mem_usage() - memory_usage) / 1048576.0);
#endif
g_pGamePersistent->LoadTitle("st_server_connecting");
g_pGamePersistent->SetTip();
}

void CALifeUpdateManager::reload(LPCSTR section)
Expand Down
31 changes: 26 additions & 5 deletions ogsr_engine/xrGame/ui/UILoadingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
#include "UIHelper.h"
#include "xrUIXmlParser.h"
#include "UIXmlInit.h"
#include "string_table.h"

UILoadingScreen::UILoadingScreen()
: loadingProgress(nullptr), loadingProgressPercent(nullptr), loadingLogo(nullptr), loadingStage(nullptr), loadingHeader(nullptr), loadingTipNumber(nullptr), loadingTip(nullptr)
: loadingProgress(nullptr), loadingProgressPercent(nullptr), loadingLogo(nullptr), loadingStage(nullptr), loadingHeader(nullptr), loadingTipNumber(nullptr), loadingTip(nullptr), maxTip(100)
{
UILoadingScreen::Initialize();
}
Expand Down Expand Up @@ -44,9 +45,13 @@ void UILoadingScreen::Initialize()
loadingLogo = UIHelper::CreateStatic(uiXml, "loading_logo", this, false);
loadingProgressPercent = UIHelper::CreateStatic(uiXml, "loading_progress_percent", this, false);
loadingStage = UIHelper::CreateStatic(uiXml, "loading_stage", this, false);

loadingHeader = UIHelper::CreateStatic(uiXml, "loading_header", this, false);

loadingTipNumber = UIHelper::CreateStatic(uiXml, "loading_tip_number", this, false);
loadingTip = UIHelper::CreateStatic(uiXml, "loading_tip", this, false);

maxTip = uiXml.ReadAttribInt("loading_tip", 0, "number_of_tips", maxTip);
}

void UILoadingScreen::Update(const int stagesCompleted, const int stagesTotal)
Expand Down Expand Up @@ -120,13 +125,29 @@ void UILoadingScreen::SetStageTitle(const char* title)
loadingStage->SetText(title);
}

void UILoadingScreen::SetStageTip(const char* header, const char* tipNumber, const char* tip)
void UILoadingScreen::SetStageTip()
{
std::scoped_lock<decltype(loadingLock)> lock(loadingLock);

loadingHeader->SetText(header);
loadingTipNumber->SetText(tipNumber);
loadingTip->SetText(tip);
u8 tip_num = Random.randI(1, maxTip);

string512 buff;

if (loadingHeader)
{
loadingHeader->SetText(CStringTable().translate("ls_header").c_str());
}
if (loadingTipNumber)
{
xr_sprintf(buff, "%s%d:", CStringTable().translate("ls_tip_number").c_str(), tip_num);
shared_str tipNumber = buff;
loadingTipNumber->SetText(tipNumber.c_str());
}
if (loadingTip)
{
xr_sprintf(buff, "ls_tip_%d", tip_num);
loadingTip->SetText(CStringTable().translate(buff).c_str());
}
}

void UILoadingScreen::Show(bool status) { CUIWindow::Show(status); }
Expand Down
4 changes: 3 additions & 1 deletion ogsr_engine/xrGame/ui/UILoadingScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class UILoadingScreen : public ILoadingScreen, public CUIWindow
CUIStatic* loadingTipNumber;
CUIStatic* loadingTip;

u32 maxTip;

public:
UILoadingScreen();

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

void SetLevelLogo(const char* name) override;
void SetStageTitle(const char* title) override;
void SetStageTip(const char* header, const char* tipNumber, const char* tip) override;
void SetStageTip() override;
};
1 change: 1 addition & 0 deletions ogsr_engine/xr_3da/IGame_Persistent.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ENGINE_API IGame_Persistent : public DLL_Pure, public pureAppStart, public
u32 GameType() { return m_game_params.m_e_game_type; };
virtual void Statistics(CGameFont* F) = 0;
virtual void LoadTitle(const char* title_name) = 0;
virtual void SetTip() = 0;

virtual bool CanBePaused() { return true; }
};
Expand Down
2 changes: 1 addition & 1 deletion ogsr_engine/xr_3da/ILoadingScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ class ILoadingScreen

virtual void SetLevelLogo(const char* name) = 0;
virtual void SetStageTitle(const char* title) = 0;
virtual void SetStageTip(const char* header, const char* tipNumber, const char* tip) = 0;
virtual void SetStageTip() = 0;
};
2 changes: 1 addition & 1 deletion ogsr_engine/xr_3da/x_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ void CApplication::LoadForceFinish() { loadingScreen->ForceFinish(); }

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

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

void CApplication::LoadStage()
{
Expand Down
2 changes: 1 addition & 1 deletion ogsr_engine/xr_3da/x_ray.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ENGINE_API CApplication : public pureFrame, public IEventReceiver
// Loading
void LoadBegin();
void LoadEnd();
void LoadTitleInt(LPCSTR str1, LPCSTR str2, LPCSTR str3); // 100 советов по выживанию в Зоне
void LoadTitleInt(); // 100 советов по выживанию в Зоне
void LoadStage();
void LoadDraw();
void LoadForceFinish();
Expand Down

0 comments on commit 38179fb

Please sign in to comment.