TazGraph Project v0.1.0
Loading...
Searching...
No Matches
DataManager.h
1#pragma once
2
3#include <map>
4#include <memory>
5#include <string>
6#include <filesystem>
7
8#include <imguiComboAutoselect/imgui_combo_autoselect.h>
9
10namespace fs = std::filesystem;
11
13public:
14 // Gets the single instance of CameraManager (singleton)
15 static DataManager& getInstance() {
16 static DataManager instance; // Guaranteed to be destroyed. Instantiated on first use.
17 return instance;
18 }
19
20 DataManager() {}
21
22 ImGui::ComboAutoSelectData data;
23 ImGui::ComboAutoSelectData pathData;
24
25 std::string mapToLoad;
26
27 std::vector<std::string> fileNames;
28 std::vector<std::string> pollingFileNames;
29 std::vector<std::string> pathsFileNames;
30 std::string pathLoading;
31
32 bool filesLoaded = false;
33
34 bool saving = false;
35 bool startingNew = false;
36 bool loading = false;
37 bool loadingPath = false;
38 bool goingBack = false;
39
40 void setPathLoading(bool loading)
41 {
42 loadingPath = loading;
43 }
44
45 bool isSaving() {
46 return saving;
47 }
48
49 void setNewMap(bool m_startingNew)
50 {
51 startingNew = m_startingNew;
52 }
53
54 void setLoading(bool m_loading)
55 {
56 loading = m_loading;
57 }
58
59 bool isStartingNew()
60 {
61 return startingNew;
62 }
63
64 bool isLoading()
65 {
66 return loading;
67 }
68
69 bool isLoadingPath()
70 {
71 return loadingPath;
72 }
73
74 bool isGoingBack()
75 {
76 return goingBack;
77 }
78
79 std::string getPathLoading() {
80 return pathLoading;
81 }
82
83 void SetGoingBack(bool m_goingBack) {
84 goingBack = m_goingBack;
85 }
86
87 void updateFileNamesInAssets() {
88 fileNames.clear();
89 const std::string path = "assets/Maps"; // Directory path
90 for (const auto& entry : fs::directory_iterator(path)) {
91 if (entry.is_regular_file()) {
92 fileNames.push_back(entry.path().filename().string()); // Add file name to vector
93 }
94 }
95 }
96
97 void updatePollingFileNamesInAssets() {
98 pollingFileNames.clear();
99 const std::string path = "assets/Maps/Polling"; // Directory path
100 for (const auto& entry : fs::directory_iterator(path)) {
101 if (entry.is_regular_file()) {
102 pollingFileNames.push_back(entry.path().filename().string()); // Add file name to vector
103 }
104 }
105 }
106
107 void updatePathFileNamesInAssets() {
108 pathsFileNames.clear();
109 const std::string path = "assets/Paths"; // Directory path
110 for (const auto& entry : fs::directory_iterator(path)) {
111 if (entry.is_regular_file()) {
112 pathsFileNames.push_back(entry.path().filename().string()); // Add file name to vector
113 }
114 }
115 pathsFileNames.push_back(">Reset");
116 }
117
118 void ReloadAccessibleFiles() {
119 if (!filesLoaded) {
120 updateFileNamesInAssets();
121 updatePollingFileNamesInAssets();
122 updatePathFileNamesInAssets();
123
124 filesLoaded = true; // Set to true so we don't reload unnecessarily
125 }
126 }
127};
Definition DataManager.h:12