yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
controller.h
Go to the documentation of this file.
1#ifndef YAZE_APP_CORE_CONTROLLER_H
2#define YAZE_APP_CORE_CONTROLLER_H
3
5
6#include <memory>
7#include <mutex>
8#include <queue>
9#include <utility>
10
11#include "absl/status/status.h"
15#include "rom/rom.h"
16
17int main(int argc, char** argv);
18
19namespace yaze {
20
21class CanvasAutomationServiceImpl;
22
23namespace test {
24struct ScreenshotArtifact;
25}
26
34 public:
36 std::string preferred_path;
37 bool reveal_to_user = false;
38 std::function<void(absl::StatusOr<test::ScreenshotArtifact>)> callback;
39 };
40
41 bool IsActive() const { return active_; }
42 absl::Status OnEntry(std::string filename = "");
43 void OnInput();
44 absl::Status OnLoad();
45 void DoRender() const;
46 void OnExit();
47
48 // Defer a screenshot capture to the next render frame (thread-safe)
49 void RequestScreenshot(const ScreenshotRequest& request);
50
51 // Set startup editor and cards from command-line flags
52 void SetStartupEditor(const std::string& editor_name,
53 const std::string& cards);
54
55 // Window visibility control (for service mode)
56 void ShowWindow() {
58 window_backend_->ShowWindow();
59 }
60 void HideWindow() {
62 window_backend_->HideWindow();
63 }
64
65 auto window() -> SDL_Window* {
66 return window_backend_ ? window_backend_->GetNativeWindow() : nullptr;
67 }
68 void set_active(bool active) { active_ = active; }
69 auto active() const { return active_; }
74 auto renderer() -> gfx::IRenderer* { return renderer_.get(); }
75
76 // Test-friendly accessors for GUI testing with ImGuiTestEngine
78
79 // Window backend accessor
81
82 // Dependency-injection seam for focused controller event tests.
84 std::unique_ptr<platform::IWindowBackend> window_backend) {
86 }
87
88 // Load a ROM file and initialize all editors for testing
89 // This performs the full initialization flow including LoadAssets()
90 absl::Status LoadRomForTesting(const std::string& rom_path);
91
92#ifdef YAZE_WITH_GRPC
93 void SetCanvasAutomationService(CanvasAutomationServiceImpl* service) {
94 editor_manager_.SetCanvasAutomationService(service);
95 }
96#endif
97
98 private:
99 friend int ::main(int argc, char** argv);
100
101 bool active_ = false;
102 std::unique_ptr<platform::IWindowBackend> window_backend_;
104 std::unique_ptr<gfx::IRenderer> renderer_;
105
106 // Thread-safe screenshot queue
107 mutable std::mutex screenshot_mutex_;
108 mutable std::queue<ScreenshotRequest> screenshot_requests_;
109
110 void ProcessScreenshotRequests() const;
111};
112
113} // namespace yaze
114
115#endif // YAZE_APP_CORE_CONTROLLER_H
Main controller for the application.
Definition controller.h:33
platform::IWindowBackend * window_backend()
Definition controller.h:80
auto window() -> SDL_Window *
Definition controller.h:65
editor::EditorManager * editor_manager()
Definition controller.h:77
std::queue< ScreenshotRequest > screenshot_requests_
Definition controller.h:108
auto overworld() -> yaze::zelda3::Overworld *
Definition controller.h:70
auto renderer() -> gfx::IRenderer *
Definition controller.h:74
editor::EditorManager editor_manager_
Definition controller.h:103
absl::Status LoadRomForTesting(const std::string &rom_path)
absl::Status OnEntry(std::string filename="")
Definition controller.cc:37
auto GetCurrentRom() -> Rom *
Definition controller.h:73
void SetStartupEditor(const std::string &editor_name, const std::string &cards)
auto active() const
Definition controller.h:69
std::unique_ptr< platform::IWindowBackend > window_backend_
Definition controller.h:102
void ProcessScreenshotRequests() const
bool IsActive() const
Definition controller.h:41
absl::Status OnLoad()
void SetWindowBackendForTesting(std::unique_ptr< platform::IWindowBackend > window_backend)
Definition controller.h:83
void DoRender() const
void RequestScreenshot(const ScreenshotRequest &request)
std::unique_ptr< gfx::IRenderer > renderer_
Definition controller.h:104
std::mutex screenshot_mutex_
Definition controller.h:107
void set_active(bool active)
Definition controller.h:68
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
The EditorManager controls the main editor window and manages the various editor classes.
Rom * GetCurrentRom() const override
yaze::zelda3::Overworld * overworld() const
Defines an abstract interface for all rendering operations.
Definition irenderer.h:60
Abstract window backend interface.
Definition iwindow.h:116
Represents the full Overworld data, light and dark world.
Definition overworld.h:389
int main(int argc, char **argv)
Definition emu.cc:43
SDL2/SDL3 compatibility layer.
std::function< void(absl::StatusOr< test::ScreenshotArtifact >)> callback
Definition controller.h:38