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

72 lines
1.4 KiB
C++
Raw Normal View History

2017-02-04 12:42:12 -05:00
#include "STDInclude.hpp"
namespace Components
{
2017-02-04 15:52:49 -05:00
std::mutex Changelog::Mutex;
std::vector<std::string> Changelog::Lines;
2017-02-04 12:42:12 -05:00
2017-02-04 15:52:49 -05:00
void Changelog::LoadChangelog()
2017-02-04 12:42:12 -05:00
{
2017-02-04 15:52:49 -05:00
//if (!Changelog::Lines.empty())
// return;
2017-02-04 15:52:49 -05:00
std::lock_guard<std::mutex> _(Changelog::Mutex);
Changelog::Lines.clear();
std::string data = Utils::Cache::GetFile("/iw4/changelog.txt");
2017-02-04 12:42:12 -05:00
2017-02-04 15:52:49 -05:00
if (data.empty())
2017-02-04 12:42:12 -05:00
{
2017-02-04 15:52:49 -05:00
data = "^1Unable to get changelog.";
2017-02-04 12:42:12 -05:00
}
2017-02-04 15:52:49 -05:00
Changelog::Lines = Utils::String::Explode(data, '\n');
2017-02-04 12:42:12 -05:00
2017-02-04 15:52:49 -05:00
for (auto& line : Changelog::Lines)
{
2017-02-04 12:42:12 -05:00
Utils::String::Replace(line, "\r", "");
}
}
unsigned int Changelog::GetChangelogCount()
{
2017-02-04 15:52:49 -05:00
return Changelog::Lines.size();
2017-02-04 12:42:12 -05:00
}
// Omit column here
const char* Changelog::GetChangelogText(unsigned int item, int /*column*/)
{
2017-02-04 15:52:49 -05:00
std::lock_guard<std::mutex> _(Changelog::Mutex);
if (item < Changelog::Lines.size())
2017-02-04 12:42:12 -05:00
{
2017-02-04 15:52:49 -05:00
return Utils::String::VA("%s", Changelog::Lines[item].data());
2017-02-04 12:42:12 -05:00
}
return "";
}
2017-02-04 15:52:49 -05:00
void Changelog::SelectChangelog(unsigned int /*index*/)
{
// Don't do anything in here
}
2017-02-04 12:42:12 -05:00
Changelog::Changelog()
{
if (Dedicated::IsEnabled()) return;
2017-02-04 12:42:12 -05:00
// Changelog
2017-02-06 15:23:15 -05:00
UIFeeder::Add(62.0f, Changelog::GetChangelogCount, Changelog::GetChangelogText, Changelog::SelectChangelog);
#ifndef DISABLE_ANTICHEAT
2017-07-03 09:07:47 -04:00
Scheduler::OnFrameAsync(AntiCheat::QuickCodeScanner1);
#endif
2017-02-04 12:42:12 -05:00
}
2017-02-04 15:52:49 -05:00
Changelog::~Changelog()
{
{
std::lock_guard<std::mutex> _(Changelog::Mutex);
Changelog::Lines.clear();
}
}
2017-02-04 12:42:12 -05:00
}