Inital commit

This commit is contained in:
2022-08-04 13:35:22 +02:00
parent b8161a96ef
commit 7551ca0143
68 changed files with 77726 additions and 0 deletions

10
include/UCTGui.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
namespace uct {
namespace gui {
void Init();
void Render();
} // namespace gui
} // namespace uct

36
include/UCTSave.h Normal file
View File

@@ -0,0 +1,36 @@
#pragma once
#include <string>
#include <any>
#include <vector>
namespace uct {
namespace save {
constexpr static std::size_t TEMPLATE_BUFFER_SIZE = 65536;
constexpr static std::size_t SLOT_BUFFER_SIZE = 1024;
struct TemplateSlot {
std::string name;
std::string defaultValue;
char valueBuffer[SLOT_BUFFER_SIZE];
};
struct Template {
std::string name;
char templateRaw[TEMPLATE_BUFFER_SIZE];
std::vector<TemplateSlot> templateSlots;
};
struct UCTSave {
std::vector<Template> templates;
float fondDeCaisse;
};
void SaveConfig(const UCTSave& save);
UCTSave LoadConfig();
std::string GetConfigFilePath();
} // namespace save
} // namespace uct

33
include/UCTUtils.h Normal file
View File

@@ -0,0 +1,33 @@
#pragma once
#include <memory>
#include <string>
#include <stdexcept>
#include <vector>
namespace uct {
namespace save {
struct Template;
} // namespace save
namespace utils {
template<typename ... Args>
std::string format(const std::string& format, Args ... args)
{
int size_s = std::snprintf(nullptr, 0, format.c_str(), args ...) + 1; // Extra space for '\0'
if (size_s <= 0) { throw std::runtime_error("Error during formatting."); }
auto size = static_cast<size_t>(size_s);
std::unique_ptr<char[]> buf(new char[size]);
std::snprintf(buf.get(), size, format.c_str(), args ...);
return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside
}
std::string format(std::string format, const std::vector<std::string>& args);
std::string format(const save::Template& t);
} // namespace utils
} // namespace uct