ASAPCabinetFE
 
Loading...
Searching...
No Matches
app.h
Go to the documentation of this file.
1
11#ifndef APP_H
12#define APP_H
13
14#include <memory>
15#include <string>
16#include <vector>
17#include <atomic>
18#include <mutex>
19#include <thread>
20#include <condition_variable>
21#include <SDL_events.h>
23#include "config/ui/config_ui.h"
25#include "render/irenderer.h"
28#include "tables/itable_loader.h"
30#include "tables/table_data.h"
34#include "tables/vpsdb/vpsdb_catalog_table.h" // Added for VpsdbJsonLoader
35#include "sound/isound_manager.h"
37#include "iwindow_manager.h"
38#include "joystick_manager.h"
39#include "ui/playfield_overlay.h"
40#include "ui/imgui_manager.h"
41#include "dependency_factory.h"
42#include "iapp_callbacks.h"
43#include "ui/loading_progress.h"
44#include "ui/loading_screen.h"
45struct Mix_Chunk;
46
57class App : public IAppCallbacks {
58public:
59 ISoundManager* getSoundManager() override; // Changed to ISoundManager*
67 App(const std::string& configPath);
68
74 ~App();
75
81 void run();
82
90 void reloadFont(bool isStandalone = false) override;
91
97 void reloadWindows() override;
98
104 void reloadAssetsAndRenderers() override;
105
111 void reloadTablesAndTitle() override;
112
118 void reloadOverlaySettings() override;
119
120private:
121 std::string exeDir_;
122 std::string configPath_;
123 bool showConfig_ = false;
124 std::unique_ptr<TableOverrideEditor> overrideEditor_;
125 TableOverrideManager overrideManager_;
126 bool showEditor_ = false;
127 std::unique_ptr<vpsdb::VpsdbCatalog> vpsdbCatalog_;
128 std::unique_ptr<vpsdb::VpsdbJsonLoader> vpsdbJsonLoader_; // Added for JSON loading
129 bool showVpsdb_ = false;
130 size_t currentIndex_ = 0;
131 size_t lastTableIndex_;
132 std::unique_ptr<TTF_Font, void(*)(TTF_Font*)> font_;
133 std::unique_ptr<JoystickManager> joystickManager_;
134 std::unique_ptr<IWindowManager> windowManager_;
135 std::unique_ptr<ImGuiManager> imGuiManager_;
136 std::unique_ptr<ISoundManager> soundManager_;
137 std::unique_ptr<IKeybindProvider> keybindProvider_;
138 std::unique_ptr<IConfigService> configManager_;
139 std::unique_ptr<ConfigUI> configEditor_;
140 std::unique_ptr<IRenderer> renderer_;
141 std::unique_ptr<IAssetManager> assets_;
142 std::unique_ptr<IScreenshotManager> screenshotManager_;
143 std::unique_ptr<ITableLauncher> tableLauncher_;
144 std::unique_ptr<IInputManager> inputManager_;
145 std::unique_ptr<ITableLoader> tableLoader_;
146 std::unique_ptr<ITableCallbacks> tableCallbacks_;
147 std::vector<TableData> tables_;
148 std::unique_ptr<PlayfieldOverlay> playfieldOverlay_;
149 bool prevShowConfig_ = false;
150 std::atomic<bool> isLoadingTables_{false};
151 std::mutex tablesMutex_;
152 std::shared_ptr<LoadingProgress> loadingProgress_;
153 std::unique_ptr<LoadingScreen> loadingScreen_;
154 std::thread loadingThread_; // Added to store the loading thread
155 std::mutex loadingMutex_; // Added for synchronizing loading state
156 std::condition_variable loadingCV_; // Added to signal loading completion
157
165 std::string getExecutableDir();
166
174 bool isConfigValid();
175
181 void loadTables();
182
188 void loadFont();
189
195 void handleEvents();
196
202 void update();
203
209 void render();
210
216 void cleanup();
217
223 void initializeDependencies();
224
230 void loadTablesThreaded(size_t oldIndex = 0); // Helper for threaded loading
231};
232
233#endif // APP_H
Main application controller for ASAPCabinetFE.
Definition app.h:57
void reloadAssetsAndRenderers() override
Reloads assets and renderers.
Definition app.cpp:85
~App()
Destroys the App instance.
Definition app.cpp:29
void reloadOverlaySettings() override
Reloads overlay settings.
Definition app.cpp:111
void reloadWindows() override
Reloads window configurations.
Definition app.cpp:54
void reloadTablesAndTitle() override
Reloads table data and window title.
Definition app.cpp:92
void reloadFont(bool isStandalone=false) override
Reloads the font resource.
Definition app.cpp:60
void run()
Runs the main application loop.
Definition app.cpp:43
Interface for handling various application callbacks.
Definition iapp_callbacks.h:22
Interface for managing sound operations.
Definition isound_manager.h:14
Definition table_override_manager.h:19
Defines the ConfigUI class for managing the ImGui-based configuration UI in ASAPCabinetFE.
Defines the DependencyFactory class for creating component instances in ASAPCabinetFE.
Defines the IAssetManager interface for managing assets in ASAPCabinetFE.
Defines the IConfigService interface for managing configuration in ASAPCabinetFE.
Defines the IInputManager interface for handling input events in ASAPCabinetFE.
Defines the IScreenshotManager interface for screenshot capture operations in ASAPCabinetFE.
Defines the ITableCallbacks interface for managing ASAP index files in ASAPCabinetFE.
Defines the ITableLauncher interface for launching VPX tables.
Defines the IWindowManager interface for managing SDL windows and renderers in ASAPCabinetFE.
Defines the JoystickManager class for handling SDL joysticks in ASAPCabinetFE.
Defines the LoadingProgress struct for tracking loading state in ASAPCabinetFE.
Defines the TableData struct for storing VPX table metadata and media paths.
Defines the TableOverrideEditor class for editing table overrides in ASAPCabinetFE.
Defines the TableOverrideManager class for handling per-table JSON overrides in ASAPCabinetFE.
Header for VpsdbCatalog class to display VPSDB pinball table metadata.