TerraForge3D  2.3.1
3D Terrain And Landscape Generator
OSLiscences.cpp
1#include "Misc/OSLiscences.h"
2
3#include "imgui.h"
4
5#include <string>
6#include <vector>
7#include <iostream>
8#include <filesystem>
9
10#include "Utils/Utils.h"
11#include "Data/ApplicationState.h"
12
13namespace fs = std::filesystem;
14
15OSLiscences::~OSLiscences()
16{
17 osls.clear();
18}
19
20OSLiscences::OSLiscences(ApplicationState *as)
21{
22 appState = as;
23 std::string path = appState->constants.liscensesDir;
24
25 for (const auto &entry : fs::directory_iterator(path))
26 {
27 std::string path{ entry.path().u8string() };
28 std::string name{ entry.path().filename().u8string()};
29 bool tmp = false;
30 name = name.substr(0, name.size() - 3);
31 osls.push_back(std::make_pair(name, ReadShaderSourceFile(path, &tmp)));
32 }
33}
34
35void OSLiscences::ShowLisc(std::string &name, std::string &content, int id)
36{
37 bool state = ImGui::CollapsingHeader(("##LiscItem" + std::to_string(id)).c_str());
38 ImGui::SameLine();
39 ImGui::Text(name.c_str());
40
41 if (state)
42 {
43 ImGui::Text(content.c_str());
44 }
45}
46
47
48void OSLiscences::ShowSettings(bool *pOpen)
49{
50 ImGui::Begin("Open Source LICENSES", pOpen);
51 int id = 0;
52
53 for (auto &item : osls)
54 {
55 ShowLisc(item.first, item.second, id++);
56 }
57
58 ImGui::End();
59}