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
10#include "absl/status/status.h"
14#include "rom/rom.h"
15
16int main(int argc, char** argv);
17
18namespace yaze {
19
20class CanvasAutomationServiceImpl;
21
22namespace test {
23struct ScreenshotArtifact;
24}
25
33 public:
35 std::string preferred_path;
36 std::function<void(absl::StatusOr<test::ScreenshotArtifact>)> callback;
37 };
38
39 bool IsActive() const { return active_; }
40 absl::Status OnEntry(std::string filename = "");
41 void OnInput();
42 absl::Status OnLoad();
43 void DoRender() const;
44 void OnExit();
45
46 // Defer a screenshot capture to the next render frame (thread-safe)
47 void RequestScreenshot(const ScreenshotRequest& request);
48
49 // Set startup editor and cards from command-line flags
50 void SetStartupEditor(const std::string& editor_name,
51 const std::string& cards);
52
53 auto window() -> SDL_Window* {
54 return window_backend_ ? window_backend_->GetNativeWindow() : nullptr;
55 }
56 void set_active(bool active) { active_ = active; }
57 auto active() const { return active_; }
62 auto renderer() -> gfx::IRenderer* { return renderer_.get(); }
63
64 // Test-friendly accessors for GUI testing with ImGuiTestEngine
66
67 // Window backend accessor
69
70 // Load a ROM file and initialize all editors for testing
71 // This performs the full initialization flow including LoadAssets()
72 absl::Status LoadRomForTesting(const std::string& rom_path);
73
74#ifdef YAZE_WITH_GRPC
75 void SetCanvasAutomationService(CanvasAutomationServiceImpl* service) {
76 editor_manager_.SetCanvasAutomationService(service);
77 }
78#endif
79
80 private:
81 friend int ::main(int argc, char** argv);
82
83 bool active_ = false;
84 std::unique_ptr<platform::IWindowBackend> window_backend_;
86 std::unique_ptr<gfx::IRenderer> renderer_;
87
88 // Thread-safe screenshot queue
89 mutable std::mutex screenshot_mutex_;
90 mutable std::queue<ScreenshotRequest> screenshot_requests_;
91
92 void ProcessScreenshotRequests() const;
93};
94
95} // namespace yaze
96
97#endif // YAZE_APP_CORE_CONTROLLER_H
Main controller for the application.
Definition controller.h:32
platform::IWindowBackend * window_backend()
Definition controller.h:68
auto window() -> SDL_Window *
Definition controller.h:53
editor::EditorManager * editor_manager()
Definition controller.h:65
std::queue< ScreenshotRequest > screenshot_requests_
Definition controller.h:90
auto overworld() -> yaze::zelda3::Overworld *
Definition controller.h:58
auto renderer() -> gfx::IRenderer *
Definition controller.h:62
editor::EditorManager editor_manager_
Definition controller.h:85
absl::Status LoadRomForTesting(const std::string &rom_path)
absl::Status OnEntry(std::string filename="")
Definition controller.cc:26
auto GetCurrentRom() -> Rom *
Definition controller.h:61
void SetStartupEditor(const std::string &editor_name, const std::string &cards)
Definition controller.cc:73
auto active() const
Definition controller.h:57
std::unique_ptr< platform::IWindowBackend > window_backend_
Definition controller.h:84
void ProcessScreenshotRequests() const
bool IsActive() const
Definition controller.h:39
absl::Status OnLoad()
void DoRender() const
void RequestScreenshot(const ScreenshotRequest &request)
std::unique_ptr< gfx::IRenderer > renderer_
Definition controller.h:86
std::mutex screenshot_mutex_
Definition controller.h:89
void set_active(bool active)
Definition controller.h:56
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
The EditorManager controls the main editor window and manages the various editor classes.
auto overworld() const -> yaze::zelda3::Overworld *
auto GetCurrentRom() const -> Rom *
Defines an abstract interface for all rendering operations.
Definition irenderer.h:40
Abstract window backend interface.
Definition iwindow.h:114
Represents the full Overworld data, light and dark world.
Definition overworld.h:217
int main(int argc, char **argv)
Definition emu.cc:39
SDL2/SDL3 compatibility layer.
std::function< void(absl::StatusOr< test::ScreenshotArtifact >)> callback
Definition controller.h:36