2017-01-30 21:57:31 -05:00
|
|
|
#include "STDInclude.hpp"
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
2017-02-06 15:46:57 -05:00
|
|
|
int StartupMessages::TotalMessages = -1;
|
|
|
|
std::list<std::string> StartupMessages::MessageList;
|
2017-01-30 21:57:31 -05:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2017-02-06 15:46:57 -05:00
|
|
|
if (!StartupMessages::MessageList.size()) return;
|
2017-01-30 21:57:31 -05:00
|
|
|
|
2017-02-06 15:46:57 -05:00
|
|
|
if (StartupMessages::TotalMessages < 1)
|
2017-01-30 21:57:31 -05:00
|
|
|
{
|
2017-02-06 15:46:57 -05:00
|
|
|
StartupMessages::TotalMessages = StartupMessages::MessageList.size();
|
2017-01-30 21:57:31 -05:00
|
|
|
}
|
|
|
|
|
2017-02-06 15:46:57 -05:00
|
|
|
std::string message = StartupMessages::MessageList.front();
|
|
|
|
StartupMessages::MessageList.pop_front();
|
2017-01-30 21:57:31 -05:00
|
|
|
|
|
|
|
Game::Dvar_SetStringByName("ui_startupMessage", message.data());
|
2017-02-06 15:46:57 -05:00
|
|
|
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");
|
2017-01-30 21:57:31 -05:00
|
|
|
Game::Cbuf_AddText(0, "openmenu startup_messages");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartupMessages::AddMessage(std::string message)
|
|
|
|
{
|
2017-02-06 15:46:57 -05:00
|
|
|
StartupMessages::MessageList.push_back(message);
|
2017-01-30 21:57:31 -05:00
|
|
|
}
|
2017-06-14 06:06:04 -04:00
|
|
|
}
|