From ddd8cb8b6a13a664dcbf67af4ce0ef70ce2865f0 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 6 Feb 2017 21:46:57 +0100 Subject: [PATCH] [StartupMessages] Adapt code to coding guidelines --- src/Components/Modules/StartupMessages.cpp | 21 ++++++++++----------- src/Components/Modules/StartupMessages.hpp | 4 ++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Components/Modules/StartupMessages.cpp b/src/Components/Modules/StartupMessages.cpp index a5911898..3ef8ecff 100644 --- a/src/Components/Modules/StartupMessages.cpp +++ b/src/Components/Modules/StartupMessages.cpp @@ -2,9 +2,8 @@ namespace Components { - std::list startupMessages; - - int totalMessages = -1; + int StartupMessages::TotalMessages = -1; + std::list StartupMessages::MessageList; StartupMessages::StartupMessages() { @@ -17,26 +16,26 @@ namespace Components UIScript::Add("nextStartupMessage", [](UIScript::Token) { - if (!startupMessages.size()) return; + if (!StartupMessages::MessageList.size()) return; - if (totalMessages < 1) + if (StartupMessages::TotalMessages < 1) { - totalMessages = startupMessages.size(); + StartupMessages::TotalMessages = StartupMessages::MessageList.size(); } - std::string message = startupMessages.front(); - startupMessages.pop_front(); + std::string message = StartupMessages::MessageList.front(); + StartupMessages::MessageList.pop_front(); Game::Dvar_SetStringByName("ui_startupMessage", message.data()); - Game::Dvar_SetStringByName("ui_startupMessageTitle", Utils::String::VA("Messages (%d/%d)", totalMessages - startupMessages.size(), totalMessages)); - Game::Dvar_SetStringByName("ui_startupNextButtonText", startupMessages.size() ? "Next" : "Close"); + 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"); Game::Cbuf_AddText(0, "openmenu startup_messages"); }); } void StartupMessages::AddMessage(std::string message) { - startupMessages.push_back(message); + StartupMessages::MessageList.push_back(message); } } \ No newline at end of file diff --git a/src/Components/Modules/StartupMessages.hpp b/src/Components/Modules/StartupMessages.hpp index b20380af..61eeac13 100644 --- a/src/Components/Modules/StartupMessages.hpp +++ b/src/Components/Modules/StartupMessages.hpp @@ -12,5 +12,9 @@ namespace Components #endif static void AddMessage(std::string message); + + private: + static int TotalMessages = -1; + static std::list MessageList; }; }