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