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 std::function<void(absl::StatusOr<test::ScreenshotArtifact>)> callback;
38 };
39
40 bool IsActive() const { return active_; }
41 absl::Status OnEntry(std::string filename = "");
42 void OnInput();
43 absl::Status OnLoad();
44 void DoRender() const;
45 void OnExit();
46
47 // Defer a screenshot capture to the next render frame (thread-safe)
48 void RequestScreenshot(const ScreenshotRequest& request);
49
50 // Set startup editor and cards from command-line flags
51 void SetStartupEditor(const std::string& editor_name,
52 const std::string& cards);
53
54 // Window visibility control (for service mode)
55 void ShowWindow() {
57 window_backend_->ShowWindow();
58 }
59 void HideWindow() {
61 window_backend_->HideWindow();
62 }
63
64 auto window() -> SDL_Window* {
65 return window_backend_ ? window_backend_->GetNativeWindow() : nullptr;
66 }
67 void set_active(bool active) { active_ = active; }
68 auto active() const { return active_; }
73 auto renderer() -> gfx::IRenderer* { return renderer_.get(); }
74
75 // Test-friendly accessors for GUI testing with ImGuiTestEngine
77
78 // Window backend accessor
80
81 // Dependency-injection seam for focused controller event tests.
83 std::unique_ptr<platform::IWindowBackend> window_backend) {
85 }
86
87 // Load a ROM file and initialize all editors for testing
88 // This performs the full initialization flow including LoadAssets()
89 absl::Status LoadRomForTesting(const std::string& rom_path);
90
91#ifdef YAZE_WITH_GRPC
92 void SetCanvasAutomationService(CanvasAutomationServiceImpl* service) {
93 editor_manager_.SetCanvasAutomationService(service);
94 }
95#endif
96
97 private:
98 friend int ::main(int argc, char** argv);
99
100 bool active_ = false;
101 std::unique_ptr<platform::IWindowBackend> window_backend_;
103 std::unique_ptr<gfx::IRenderer> renderer_;
104
105 // Thread-safe screenshot queue
106 mutable std::mutex screenshot_mutex_;
107 mutable std::queue<ScreenshotRequest> screenshot_requests_;
108
109 void ProcessScreenshotRequests() const;
110};
111
112} // namespace yaze
113
114#endif // YAZE_APP_CORE_CONTROLLER_H
Main controller for the application.
Definition controller.h:33
platform::IWindowBackend * window_backend()
Definition controller.h:79
auto window() -> SDL_Window *
Definition controller.h:64
editor::EditorManager * editor_manager()
Definition controller.h:76
std::queue< ScreenshotRequest > screenshot_requests_
Definition controller.h:107
auto overworld() -> yaze::zelda3::Overworld *
Definition controller.h:69
auto renderer() -> gfx::IRenderer *
Definition controller.h:73
editor::EditorManager editor_manager_
Definition controller.h:102
absl::Status LoadRomForTesting(const std::string &rom_path)
absl::Status OnEntry(std::string filename="")
Definition controller.cc:37
auto GetCurrentRom() -> Rom *
Definition controller.h:72
void SetStartupEditor(const std::string &editor_name, const std::string &cards)
auto active() const
Definition controller.h:68
std::unique_ptr< platform::IWindowBackend > window_backend_
Definition controller.h:101
void ProcessScreenshotRequests() const
bool IsActive() const
Definition controller.h:40
absl::Status OnLoad()
void SetWindowBackendForTesting(std::unique_ptr< platform::IWindowBackend > window_backend)
Definition controller.h:82
void DoRender() const
void RequestScreenshot(const ScreenshotRequest &request)
std::unique_ptr< gfx::IRenderer > renderer_
Definition controller.h:103
std::mutex screenshot_mutex_
Definition controller.h:106
void set_active(bool active)
Definition controller.h:67
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:37