2022-02-27 07:53:44 -05:00
|
|
|
#include <STDInclude.hpp>
|
2022-12-26 07:07:24 -05:00
|
|
|
#include "Changelog.hpp"
|
|
|
|
#include "UIFeeder.hpp"
|
2017-02-04 12:42:12 -05:00
|
|
|
|
|
|
|
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
|
|
|
{
|
2022-11-23 10:31:48 -05:00
|
|
|
std::lock_guard _(Mutex);
|
|
|
|
Lines.clear();
|
2017-02-04 13:07:02 -05:00
|
|
|
|
2022-11-23 10:31:48 -05:00
|
|
|
const auto data = Utils::Cache::GetFile("/develop/CHANGELOG.md");
|
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
|
|
|
{
|
2022-11-23 10:31:48 -05:00
|
|
|
Lines.emplace_back("^1Unable to get changelog.");
|
|
|
|
return;
|
2017-02-04 12:42:12 -05:00
|
|
|
}
|
|
|
|
|
2022-11-23 10:31:48 -05:00
|
|
|
auto buffer = Utils::String::Split(data, '\n');
|
|
|
|
for (auto& line : buffer)
|
2017-02-04 15:52:49 -05:00
|
|
|
{
|
2017-02-04 12:42:12 -05:00
|
|
|
Utils::String::Replace(line, "\r", "");
|
|
|
|
}
|
2022-11-23 10:31:48 -05:00
|
|
|
|
|
|
|
Lines = buffer;
|
2017-02-04 12:42:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int Changelog::GetChangelogCount()
|
|
|
|
{
|
2022-11-23 10:31:48 -05:00
|
|
|
return Lines.size();
|
2017-02-04 12:42:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Omit column here
|
2022-11-23 10:31:48 -05:00
|
|
|
const char* Changelog::GetChangelogText(unsigned int item, [[maybe_unused]] int column)
|
2017-02-04 12:42:12 -05:00
|
|
|
{
|
2022-11-23 10:31:48 -05:00
|
|
|
std::lock_guard _(Mutex);
|
|
|
|
if (item < Lines.size())
|
2017-02-04 12:42:12 -05:00
|
|
|
{
|
2022-12-11 12:54:24 -05:00
|
|
|
return Utils::String::Format("{}", Lines[item]);
|
2017-02-04 12:42:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2022-11-23 10:31:48 -05:00
|
|
|
void Changelog::SelectChangelog([[maybe_unused]] unsigned int index)
|
2017-02-04 15:52:49 -05:00
|
|
|
{
|
|
|
|
// Don't do anything in here
|
|
|
|
}
|
2017-02-04 12:42:12 -05:00
|
|
|
|
|
|
|
Changelog::Changelog()
|
|
|
|
{
|
2017-02-25 06:54:26 -05:00
|
|
|
if (Dedicated::IsEnabled()) return;
|
|
|
|
|
2017-02-04 12:42:12 -05:00
|
|
|
// Changelog
|
2022-12-26 07:07:24 -05:00
|
|
|
UIFeeder::Add(62.0f, GetChangelogCount, GetChangelogText, SelectChangelog);
|
2017-02-04 12:42:12 -05:00
|
|
|
}
|
|
|
|
}
|