iw4x-client/src/Components/Modules/StartupMessages.cpp

47 lines
1.6 KiB
C++
Raw Normal View History

2022-02-27 07:53:44 -05:00
#include <STDInclude.hpp>
namespace Components
{
int StartupMessages::TotalMessages = -1;
std::list<std::string> StartupMessages::MessageList;
StartupMessages::StartupMessages()
{
Dvar::OnInit([]()
{
Dvar::Register<const char*>("ui_startupMessage", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, "");
Dvar::Register<const char*>("ui_startupMessageTitle", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, "");
Dvar::Register<const char*>("ui_startupNextButtonText", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, "");
});
UIScript::Add("nextStartupMessage", [](UIScript::Token)
{
if (!StartupMessages::MessageList.size()) return;
if (StartupMessages::TotalMessages < 1)
{
StartupMessages::TotalMessages = StartupMessages::MessageList.size();
}
2022-01-10 10:28:37 -05:00
const auto& message = StartupMessages::MessageList.front();
Game::Dvar_SetStringByName("ui_startupMessage", message.data());
Game::Dvar_SetStringByName("ui_startupMessageTitle", Utils::String::VA("Messages (%d/%d)", StartupMessages::TotalMessages - StartupMessages::MessageList.size(), StartupMessages::TotalMessages));
Game::Dvar_SetStringByName("ui_startupNextButtonText", StartupMessages::MessageList.size() ? "Next" : "Close");
2022-02-07 07:28:17 -05:00
Game::Cbuf_AddText(0, "openmenu startup_messages\n");
2022-01-10 10:28:37 -05:00
StartupMessages::MessageList.pop_front();
});
}
2022-01-10 10:28:37 -05:00
StartupMessages::~StartupMessages()
{
StartupMessages::MessageList.clear();
}
2018-12-17 08:29:18 -05:00
void StartupMessages::AddMessage(const std::string& message)
{
StartupMessages::MessageList.push_back(message);
}
}