-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNavKit.cpp
More file actions
94 lines (88 loc) · 3.84 KB
/
NavKit.cpp
File metadata and controls
94 lines (88 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Copyright (c) 2025 Daniel Bierek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <SDL.h>
#include <cpptrace/from_current.hpp>
#include "../include/NavKit/module/Airg.h"
#include "../include/NavKit/module/Gui.h"
#include "../include/NavKit/module/InputHandler.h"
#include "../include/NavKit/module/Logger.h"
#include "../include/NavKit/module/Menu.h"
#include "../include/NavKit/module/Navp.h"
#include "../include/NavKit/module/SceneMesh.h"
#include "../include/NavKit/module/PersistedSettings.h"
#include "../include/NavKit/module/Renderer.h"
#include "../include/NavKit/module/SceneExtract.h"
#include "../include/NavKit/util/ErrorHandler.h"
#include "../include/NavKit/util/FileUtil.h"
#include "../include/NavKit/util/UpdateChecker.h"
#undef main
int SDL_main(const int argc, char** argv) {
CPPTRACE_TRY
{
std::thread logThread(Logger::logRunner);
logThread.detach();
PersistedSettings::getInstance().load();
Renderer& renderer = Renderer::getInstance();
if (!renderer.initWindowAndRenderer()) {
return -1;
}
renderer.initShaders();
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
UpdateChecker& updateChecker = UpdateChecker::getInstance();
updateChecker.startUpdateCheck();
SceneExtract& sceneExtract = SceneExtract::getInstance();
Navp& navp = Navp::getInstance();
SceneMesh& obj = SceneMesh::getInstance();
Airg& airg = Airg::getInstance();
InputHandler& inputHandler = InputHandler::getInstance();
Menu::updateMenuState();
Gui& gui = Gui::getInstance();
bool isRunning = true;
Logger::log(NK_INFO, "NavKit initialized.");
while (isRunning) {
if (inputHandler.handleInput() == InputHandler::QUIT) {
isRunning = false;
}
renderer.renderFrame();
inputHandler.hitTest();
gui.drawGui();
sceneExtract.finalizeExtractScene();
obj.finalizeSceneMeshBuild();
navp.finalizeBuild();
obj.finalizeLoad();
airg.finalizeSave();
obj.finalizeExtractResources();
renderer.finalizeFrame();
}
NFD_Quit();
renderer.closeWindow();
return 0;
}
CPPTRACE_CATCH(const std::exception& e) {
ErrorHandler::openErrorDialog("An unexpected error occurred: " + std::string(e.what()) + "\n\nStack Trace:\n" +
cpptrace::from_current_exception().to_string());
} catch (...) {
ErrorHandler::openErrorDialog("An unexpected error occurred:\n\nStack Trace: \n" +
cpptrace::from_current_exception().to_string());
}
return 0;
}