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>
22#include "iapp.h"
24#include "config/ui/config_ui.h"
26#include "render/irenderer.h"
29#include "tables/itable_loader.h"
31#include "tables/table_data.h"
35#include "tables/vpsdb/vpsdb_catalog_table.h" // Added for VpsdbJsonLoader
36#include "sound/isound_manager.h"
38#include "iwindow_manager.h"
39#include "joystick_manager.h"
40#include "ui/playfield_overlay.h"
41#include "ui/imgui_manager.h"
42#include "dependency_factory.h"
43#include "iapp_callbacks.h"
44#include "ui/loading_progress.h"
45#include "ui/loading_screen.h"
46struct Mix_Chunk;
47
58class App : public IApp, public IAppCallbacks {
59public:
60 ISoundManager* getSoundManager() override; // Changed to ISoundManager*
68 App(const std::string& configPath, bool forceSoftwareRenderer = false);
69
75 ~App();
76
82 void run();
83
91 void reloadFont(bool isStandalone = false) override;
92
98 void reloadWindows() override;
99
105 void reloadAssetsAndRenderers() override;
106
112 void reloadTablesAndTitle() override;
113
119 void reloadOverlaySettings() override;
120
121private:
122 bool forceSoftwareRenderer_ = false;
123 std::string exeDir_;
124 std::string configPath_;
125 bool showConfig_ = false;
126 std::unique_ptr<TableOverrideEditor> overrideEditor_;
127 TableOverrideManager overrideManager_;
128 bool showEditor_ = false;
129 std::unique_ptr<vpsdb::VpsdbCatalog> vpsdbCatalog_;
130 std::unique_ptr<vpsdb::VpsdbJsonLoader> vpsdbJsonLoader_; // Added for JSON loading
131 bool showVpsdb_ = false;
132 size_t currentIndex_ = 0;
133 size_t lastTableIndex_;
134 std::unique_ptr<TTF_Font, void(*)(TTF_Font*)> font_;
135 std::unique_ptr<JoystickManager> joystickManager_;
136 std::unique_ptr<IWindowManager> windowManager_;
137 std::unique_ptr<ImGuiManager> imGuiManager_;
138 std::unique_ptr<ISoundManager> soundManager_;
139 std::unique_ptr<IKeybindProvider> keybindProvider_;
140 std::unique_ptr<IConfigService> configManager_;
141 std::unique_ptr<ConfigUI> configEditor_;
142 std::unique_ptr<IRenderer> renderer_;
143 std::unique_ptr<IAssetManager> assets_;
144 std::unique_ptr<IScreenshotManager> screenshotManager_;
145 std::unique_ptr<ITableLauncher> tableLauncher_;
146 std::unique_ptr<IInputManager> inputManager_;
147 std::unique_ptr<ITableLoader> tableLoader_;
148 std::unique_ptr<ITableCallbacks> tableCallbacks_;
149 std::vector<TableData> tables_;
150 std::unique_ptr<PlayfieldOverlay> playfieldOverlay_;
151 bool prevShowConfig_ = false;
152 std::atomic<bool> isLoadingTables_{false};
153 std::mutex tablesMutex_;
154 std::shared_ptr<LoadingProgress> loadingProgress_;
155 std::unique_ptr<LoadingScreen> loadingScreen_;
156 std::thread loadingThread_; // Added to store the loading thread
157 std::mutex loadingMutex_; // Added for synchronizing loading state
158 std::condition_variable loadingCV_; // Added to signal loading completion
159
167 std::string getExecutableDir();
168
176 bool isConfigValid();
177
183 void loadTables();
184
190 void loadFont();
191
197 void handleEvents();
198
204 void update();
205
211 void render();
212
218 void cleanup();
219
225 void initializeDependencies();
226
232 void loadTablesThreaded(size_t oldIndex = 0); // Helper for threaded loading
233};
234
235#endif // APP_H
Main application controller for ASAPCabinetFE.
Definition app.h:58
void reloadAssetsAndRenderers() override
Reloads assets and renderers.
Definition app.cpp:96
~App()
Destroys the App instance.
Definition app.cpp:40
void reloadOverlaySettings() override
Reloads overlay settings.
Definition app.cpp:126
void reloadWindows() override
Reloads window configurations.
Definition app.cpp:65
void reloadTablesAndTitle() override
Reloads table data and window title.
Definition app.cpp:107
void reloadFont(bool isStandalone=false) override
Reloads the font resource.
Definition app.cpp:71
void run()
Runs the main application loop.
Definition app.cpp:54
Interface for handling various application callbacks.
Definition iapp_callbacks.h:22
Definition iapp.h:11
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 a simple interface for modular app entry points.
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.