2022-02-27 07:53:44 -05:00
|
|
|
#include <STDInclude.hpp>
|
2022-12-26 07:07:24 -05:00
|
|
|
#include "StartupMessages.hpp"
|
2017-01-30 21:57:31 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
2023-01-27 18:05:26 -05:00
|
|
|
Dvar::Var StartupMessages::UIStartupMessage;
|
|
|
|
Dvar::Var StartupMessages::UIStartupMessageTitle;
|
|
|
|
Dvar::Var StartupMessages::UIStartupNextButtonText;
|
|
|
|
|
2017-01-30 21:57:31 -05:00
|
|
|
StartupMessages::StartupMessages()
|
|
|
|
{
|
2023-01-27 18:05:26 -05:00
|
|
|
Events::OnDvarInit([]
|
2017-01-30 21:57:31 -05:00
|
|
|
{
|
2023-01-27 18:05:26 -05:00
|
|
|
UIStartupMessage = Dvar::Register<const char*>("ui_startupMessage", "", Game::DVAR_NONE, "");
|
|
|
|
UIStartupMessageTitle = Dvar::Register<const char*>("ui_startupMessageTitle", "", Game::DVAR_NONE, "");
|
|
|
|
UIStartupNextButtonText = Dvar::Register<const char*>("ui_startupNextButtonText", "", Game::DVAR_NONE, "");
|
|
|
|
});
|
2017-01-30 21:57:31 -05:00
|
|
|
|
2022-08-24 10:38:14 -04:00
|
|
|
UIScript::Add("nextStartupMessage", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
|
2017-01-30 21:57:31 -05:00
|
|
|
{
|
2023-01-27 18:05:26 -05:00
|
|
|
if (MessageList.empty()) return;
|
2017-01-30 21:57:31 -05:00
|
|
|
|
2023-01-27 18:05:26 -05:00
|
|
|
if (TotalMessages < 1)
|
2017-01-30 21:57:31 -05:00
|
|
|
{
|
2023-01-27 18:05:26 -05:00
|
|
|
TotalMessages = static_cast<int>(MessageList.size());
|
2017-01-30 21:57:31 -05:00
|
|
|
}
|
|
|
|
|
2023-01-27 18:05:26 -05:00
|
|
|
const auto& message = MessageList.front();
|
2017-01-30 21:57:31 -05:00
|
|
|
|
2023-01-27 18:05:26 -05:00
|
|
|
UIStartupMessage.set(message);
|
|
|
|
UIStartupMessageTitle.set(std::format("Messages ({}/{})", TotalMessages - MessageList.size(), TotalMessages));
|
|
|
|
UIStartupNextButtonText.set(MessageList.empty() ? "Close" : "Next");
|
2022-02-07 07:28:17 -05:00
|
|
|
Game::Cbuf_AddText(0, "openmenu startup_messages\n");
|
2022-01-10 10:28:37 -05:00
|
|
|
|
2023-01-27 18:05:26 -05:00
|
|
|
MessageList.pop_front();
|
2017-01-30 21:57:31 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-17 08:29:18 -05:00
|
|
|
void StartupMessages::AddMessage(const std::string& message)
|
2017-01-30 21:57:31 -05:00
|
|
|
{
|
2023-01-27 18:05:26 -05:00
|
|
|
MessageList.push_back(message);
|
2017-01-30 21:57:31 -05:00
|
|
|
}
|
2017-06-14 06:06:04 -04:00
|
|
|
}
|