1#include "Menu/MainMenu.h"
3#include "imgui/imgui.h"
5#include "Utils/Utils.h"
6#include "Misc/AppStyles.h"
7#include "Misc/ExportManager.h"
8#include "Data/ApplicationState.h"
11static void ShowWindowMenuItem(
const char *title,
bool *val)
13 ImGui::Checkbox(title, val);
27void MainMenu::ShowMainMenu()
29 if (ImGui::BeginMainMenuBar())
31 if (ImGui::BeginMenu(
"File"))
37 if (ImGui::BeginMenu(
"Options"))
43 if (ImGui::BeginMenu(
"Windows"))
49 if (ImGui::BeginMenu(
"Help"))
55 ImGui::EndMainMenuBar();
59void MainMenu::ShowFileMenu()
61 if (ImGui::MenuItem(
"Open"))
63 appState->serailizer->LoadFile(ShowOpenFileDialog(
"*.terr3d"));
66 if (ImGui::MenuItem(
"Save"))
68 appState->serailizer->LoadFile(ShowSaveFileDialog(
"*.terr3d"));
71 if (ImGui::MenuItem(
"Install Module"))
78 switch (appState->mode)
80 case ApplicationMode::TERRAIN:
81 modelToExport = appState->models.coreTerrain;
84 case ApplicationMode::CUSTOM_BASE:
85 modelToExport = appState->models.customBase;
89 modelToExport = appState->models.coreTerrain;
93 if (ImGui::BeginMenu(
"Export Mesh As"))
95 if (ImGui::MenuItem(
"Wavefont OBJ"))
97 ExportModelAssimp(modelToExport,
"obj", ShowSaveFileDialog(
".obj\0"),
"obj");
100 if (ImGui::MenuItem(
"FBX"))
102 ExportModelAssimp(modelToExport,
"fbx", ShowSaveFileDialog(
".fbx\0"),
"fbx");
105 if (ImGui::MenuItem(
"GLTF v2"))
107 ExportModelAssimp(modelToExport,
"gltf2", ShowSaveFileDialog(
".gltf\0"),
"gltf");
110 if (ImGui::MenuItem(
"GLB v2"))
112 ExportModelAssimp(modelToExport,
"glb2", ShowSaveFileDialog(
".glb\0"),
"glb");
115 if (ImGui::MenuItem(
"JSON"))
117 ExportModelAssimp(modelToExport,
"json", ShowSaveFileDialog(
".json\0"));
120 if (ImGui::MenuItem(
"STL"))
122 ExportModelAssimp(modelToExport,
"stl", ShowSaveFileDialog(
".stl\0"));
125 if (ImGui::MenuItem(
"PLY"))
127 ExportModelAssimp(modelToExport,
"ply", ShowSaveFileDialog(
".ply\0"));
130 if (ImGui::MenuItem(
"Collada"))
132 ExportModelAssimp(modelToExport,
"collada", ShowSaveFileDialog(
".dae\0"),
"dae");
138 if (ImGui::MenuItem(
"Close"))
140 appState->globals.currentOpenFilePath =
"";
143 if (ImGui::MenuItem(
"Pack Project"))
145 appState->serailizer->PackProject(ShowSaveFileDialog(
"*.terr3dpack"));
148 if (ImGui::MenuItem(
"Load Packed Project"))
150 appState->serailizer->LoadPackedProject(ShowOpenFileDialog(
"*.terr3dpack"));
153 if (ImGui::MenuItem(
"Load Auto Saved Project"))
155 appState->serailizer->LoadFile(GetExecutableDir() + PATH_SEPARATOR
"Data" PATH_SEPARATOR
"cache" PATH_SEPARATOR
"autosave" PATH_SEPARATOR
"autosave.terr3d");
158 if (ImGui::MenuItem(
"Exit"))
164void MainMenu::ShowOptionsMenu()
166 if (ImGui::MenuItem(
"Toggle System Console"))
168 ToggleSystemConsole();
171 if (ImGui::MenuItem(
"Associate (.terr3d) File Type"))
176 if (ImGui::MenuItem(
"Copy Version Hash"))
178 char *output =
new char[MD5File(GetExecutablePath()).ToString().size() + 1];
179 strcpy(output, MD5File(GetExecutablePath()).ToString().c_str());
180 const size_t len = strlen(output) + 1;
182 HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
183 memcpy(GlobalLock(hMem), output, len);
187 SetClipboardData(CF_TEXT, hMem);
191 std::cout <<
"Version Hash : " << output << std::endl;
195 if (ImGui::BeginMenu(
"Themes"))
197 if (ImGui::MenuItem(
"Default"))
202 if(ImGui::MenuItem(
"Maya Theme"))
207 if (ImGui::MenuItem(
"Black & White"))
212 if (ImGui::MenuItem(
"Cool Dark"))
217 if (ImGui::MenuItem(
"Light Orange"))
219 LoadLightOrngeStyle();
222 if (ImGui::MenuItem(
"Load Theme From File"))
224 LoadThemeFromFile(openfilename());
231void MainMenu::ShowWindowsMenu()
233 ShowWindowMenuItem(
"Statistics", &appState->windows.statsWindow);
234 ShowWindowMenuItem(
"Theme Editor", &appState->windows.styleEditor);
235 ShowWindowMenuItem(
"Foliage Manager", &appState->windows.foliageManager);
236 ShowWindowMenuItem(
"Texture Baker", &appState->windows.textureBaker);
237 ShowWindowMenuItem(
"Texture Store", &appState->windows.textureStore);
238 ShowWindowMenuItem(
"Sea Settings", &appState->windows.seaEditor);
239 ShowWindowMenuItem(
"Light Settings", &appState->windows.lightControls);
240 ShowWindowMenuItem(
"Camera Settings", &appState->windows.cameraControls);
241 ShowWindowMenuItem(
"Mesh Generators Settings", &appState->meshGenerator->windowStat);
242 ShowWindowMenuItem(
"Sky Settings", &appState->windows.skySettings);
243 ShowWindowMenuItem(
"Shading", &appState->windows.shadingManager);
244 ShowWindowMenuItem(
"Filters Manager", &appState->windows.filtersManager);
245 ShowWindowMenuItem(
"Module Manager", &appState->windows.modulesManager);
246 ShowWindowMenuItem(
"Supporters", &appState->windows.supportersTribute);
247 ShowWindowMenuItem(
"Open Source Liscenses", &appState->windows.osLisc);
250void MainMenu::ShowHelpMenu()
252 if (ImGui::MenuItem(
"Tutorial"))
254 OpenURL(
"https://www.youtube.com/playlist?list=PLl3xhxX__M4A74aaTj8fvqApu7vo3cOiZ");
257 if (ImGui::MenuItem(
"Social Handle"))
259 OpenURL(
"https://twitter.com/jaysmito101");
262 if (ImGui::MenuItem(
"Discord Server"))
264 OpenURL(
"https://discord.gg/AcgRafSfyB");
267 if (ImGui::MenuItem(
"GitHub Page"))
269 OpenURL(
"https://github.com/Jaysmito101/TerraForge3D");
272 if (ImGui::MenuItem(
"Documentation"))
274 OpenURL(
"https://github.com/Jaysmito101/TerraForge3D/wiki");
277 if (ImGui::MenuItem(
"Open Source Liscenses"))
279 appState->windows.osLisc = !appState->windows.osLisc;