yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
wasm_control_api.h
Go to the documentation of this file.
1#ifndef YAZE_APP_PLATFORM_WASM_CONTROL_API_H_
2#define YAZE_APP_PLATFORM_WASM_CONTROL_API_H_
3
4#ifdef __EMSCRIPTEN__
5
6#include <functional>
7#include <string>
8#include <vector>
9
10#include "absl/status/status.h"
11
12namespace yaze {
13
14// Forward declarations
15class Rom;
16
17namespace editor {
18class EditorManager;
19class WorkspaceWindowManager;
20} // namespace editor
21
22namespace app {
23namespace platform {
24
43class WasmControlApi {
44 public:
49 static void Initialize(editor::EditorManager* editor_manager);
50
55 static bool IsReady();
56
60 static void SetupJavaScriptBindings();
61
62 // ============================================================================
63 // Editor Control
64 // ============================================================================
65
71 static std::string SwitchEditor(const std::string& editor_name);
72
77 static std::string GetCurrentEditor();
78
83 static std::string GetAvailableEditors();
84
85 // ============================================================================
86 // Window Control
87 // ============================================================================
88
94 static std::string OpenWindow(const std::string& card_id);
95 static std::string OpenPanel(const std::string& card_id);
96
102 static std::string CloseWindow(const std::string& card_id);
103 static std::string ClosePanel(const std::string& card_id);
104
110 static std::string ToggleWindow(const std::string& card_id);
111 static std::string TogglePanel(const std::string& card_id);
112
117 static std::string GetVisibleWindows();
118 static std::string GetVisiblePanels();
119
124 static std::string GetAvailableWindows();
125 static std::string GetAvailablePanels();
126
132 static std::string GetWindowsInCategory(const std::string& category);
133 static std::string GetPanelsInCategory(const std::string& category);
134
139 static std::string ShowAllWindows();
140 static std::string ShowAllPanels();
141
146 static std::string HideAllWindows();
147 static std::string HideAllPanels();
148
154 static std::string ShowAllWindowsInCategory(const std::string& category);
155
161 static std::string HideAllWindowsInCategory(const std::string& category);
162
168 static std::string ShowOnlyWindow(const std::string& card_id);
169
170 // ============================================================================
171 // Layout Control
172 // ============================================================================
173
179 static std::string SetPanelLayout(const std::string& layout_name);
180
185 static std::string GetAvailableLayouts();
186
192 static std::string SaveCurrentLayout(const std::string& layout_name);
193
194 // ============================================================================
195 // Menu/UI Actions
196 // ============================================================================
197
203 static std::string TriggerMenuAction(const std::string& action_path);
204
209 static std::string GetAvailableMenuActions();
210
215 static std::string ToggleMenuBar();
216
217 // ============================================================================
218 // Session Control
219 // ============================================================================
220
225 static std::string GetSessionInfo();
226
231 static std::string CreateSession();
232
238 static std::string SwitchSession(int session_index);
239
240 // ============================================================================
241 // ROM Control
242 // ============================================================================
243
248 static std::string GetRomStatus();
249
256 static std::string ReadRomBytes(int address, int count);
257
264 static std::string WriteRomBytes(int address, const std::string& bytes_json);
265
270 static std::string SaveRom();
271
272 // ============================================================================
273 // Editor State APIs (for LLM agents and automation)
274 // ============================================================================
275
280 static std::string GetEditorSnapshot();
281
286 static std::string GetCurrentDungeonRoom();
287
292 static std::string GetCurrentOverworldMap();
293
298 static std::string GetEditorSelection();
299
300 // ============================================================================
301 // Read-only Data APIs
302 // ============================================================================
303
309 static std::string GetRoomTileData(int room_id);
310
316 static std::string GetRoomObjects(int room_id);
317
323 static std::string GetRoomProperties(int room_id);
324
330 static std::string GetMapTileData(int map_id);
331
337 static std::string GetMapEntities(int map_id);
338
344 static std::string GetMapProperties(int map_id);
345
352 static std::string GetPaletteData(const std::string& group_name, int palette_id);
353
358 static std::string ListPaletteGroups();
359
367 static std::string LoadFont(const std::string& name, const std::string& data, float size);
368
369 // ============================================================================
370 // GUI Automation APIs (for LLM agents)
371 // ============================================================================
372
377 static std::string GetUIElementTree();
378
384 static std::string GetUIElementBounds(const std::string& element_id);
385
391 static std::string SetSelection(const std::string& ids_json);
392
393 // ============================================================================
394 // Platform Info API
395 // ============================================================================
396
410 static std::string GetPlatformInfo();
411
412 // ============================================================================
413 // Agent API (for AI/LLM agent integration)
414 // ============================================================================
415
420 static bool AgentIsReady();
421
427 static std::string AgentSendMessage(const std::string& message);
428
433 static std::string AgentGetChatHistory();
434
439 static std::string AgentGetConfig();
440
446 static std::string AgentSetConfig(const std::string& config_json);
447
452 static std::string AgentGetProviders();
453
458 static std::string AgentGetProposals();
459
465 static std::string AgentAcceptProposal(const std::string& proposal_id);
466
472 static std::string AgentRejectProposal(const std::string& proposal_id);
473
479 static std::string AgentGetProposalDetails(const std::string& proposal_id);
480
485 static std::string AgentOpenSidebar();
486
491 static std::string AgentCloseSidebar();
492
493 private:
494 static editor::EditorManager* editor_manager_;
495 static bool initialized_;
496
497 // Helper to get the workspace window manager
498 static editor::WorkspaceWindowManager* GetWindowManager();
499
500 // Helper to convert EditorType to string
501 static std::string EditorTypeToString(int type);
502
503 // Helper to convert string to EditorType
504 static int StringToEditorType(const std::string& name);
505};
506
507} // namespace platform
508} // namespace app
509} // namespace yaze
510
511#else // !__EMSCRIPTEN__
512
513// Stub for non-WASM builds
514namespace yaze {
515namespace editor {
516class EditorManager;
517}
518
519namespace app {
520namespace platform {
521
523 public:
525 static bool IsReady() { return false; }
526 static void SetupJavaScriptBindings() {}
527 static std::string SwitchEditor(const std::string&) { return "{}"; }
528 static std::string GetCurrentEditor() { return "{}"; }
529 static std::string GetAvailableEditors() { return "[]"; }
530 static std::string OpenWindow(const std::string&) { return "{}"; }
531 static std::string OpenPanel(const std::string& card_id) {
532 return OpenWindow(card_id);
533 }
534 static std::string CloseWindow(const std::string&) { return "{}"; }
535 static std::string ClosePanel(const std::string& card_id) {
536 return CloseWindow(card_id);
537 }
538 static std::string ToggleWindow(const std::string&) { return "{}"; }
539 static std::string TogglePanel(const std::string& card_id) {
540 return ToggleWindow(card_id);
541 }
542 static std::string GetVisibleWindows() { return "[]"; }
543 static std::string GetVisiblePanels() { return GetVisibleWindows(); }
544 static std::string GetAvailableWindows() { return "[]"; }
545 static std::string GetAvailablePanels() { return GetAvailableWindows(); }
546 static std::string GetWindowsInCategory(const std::string&) { return "[]"; }
547 static std::string GetPanelsInCategory(const std::string& category) {
548 return GetWindowsInCategory(category);
549 }
550 static std::string ShowAllWindows() { return "{}"; }
551 static std::string ShowAllPanels() { return ShowAllWindows(); }
552 static std::string HideAllWindows() { return "{}"; }
553 static std::string HideAllPanels() { return HideAllWindows(); }
554 static std::string ShowAllWindowsInCategory(const std::string&) { return "{}"; }
555 static std::string HideAllWindowsInCategory(const std::string&) { return "{}"; }
556 static std::string ShowOnlyWindow(const std::string&) { return "{}"; }
557 static std::string SetPanelLayout(const std::string&) { return "{}"; }
558 static std::string GetAvailableLayouts() { return "[]"; }
559 static std::string SaveCurrentLayout(const std::string&) { return "{}"; }
560 static std::string TriggerMenuAction(const std::string&) { return "{}"; }
561 static std::string GetAvailableMenuActions() { return "[]"; }
562 static std::string ToggleMenuBar() { return "{}"; }
563 static std::string GetSessionInfo() { return "{}"; }
564 static std::string CreateSession() { return "{}"; }
565 static std::string SwitchSession(int) { return "{}"; }
566 static std::string GetRomStatus() { return "{}"; }
567 static std::string ReadRomBytes(int, int) { return "{}"; }
568 static std::string WriteRomBytes(int, const std::string&) { return "{}"; }
569 static std::string SaveRom() { return "{}"; }
570 // Editor State APIs
571 static std::string GetEditorSnapshot() { return "{}"; }
572 static std::string GetCurrentDungeonRoom() { return "{}"; }
573 static std::string GetCurrentOverworldMap() { return "{}"; }
574 static std::string GetEditorSelection() { return "{}"; }
575 // Read-only Data APIs
576 static std::string GetRoomTileData(int) { return "{}"; }
577 static std::string GetRoomObjects(int) { return "[]"; }
578 static std::string GetRoomProperties(int) { return "{}"; }
579 static std::string GetMapTileData(int) { return "{}"; }
580 static std::string GetMapEntities(int) { return "{}"; }
581 static std::string GetMapProperties(int) { return "{}"; }
582 static std::string GetPaletteData(const std::string&, int) { return "{}"; }
583 static std::string ListPaletteGroups() { return "[]"; }
584 // GUI Automation APIs
585 static std::string GetUIElementTree() { return "{}"; }
586 static std::string GetUIElementBounds(const std::string&) { return "{}"; }
587 static std::string SetSelection(const std::string&) { return "{}"; }
588 // Platform Info API
589 static std::string GetPlatformInfo() { return "{}"; }
590 // Agent API
591 static bool AgentIsReady() { return false; }
592 static std::string AgentSendMessage(const std::string&) { return "{}"; }
593 static std::string AgentGetChatHistory() { return "[]"; }
594 static std::string AgentGetConfig() { return "{}"; }
595 static std::string AgentSetConfig(const std::string&) { return "{}"; }
596 static std::string AgentGetProviders() { return "[]"; }
597 static std::string AgentGetProposals() { return "[]"; }
598 static std::string AgentAcceptProposal(const std::string&) { return "{}"; }
599 static std::string AgentRejectProposal(const std::string&) { return "{}"; }
600 static std::string AgentGetProposalDetails(const std::string&) { return "{}"; }
601 static std::string AgentOpenSidebar() { return "{}"; }
602 static std::string AgentCloseSidebar() { return "{}"; }
603};
604
605} // namespace platform
606} // namespace app
607} // namespace yaze
608
609#endif // __EMSCRIPTEN__
610
611#endif // YAZE_APP_PLATFORM_WASM_CONTROL_API_H_
static std::string SaveCurrentLayout(const std::string &)
static std::string GetAvailableMenuActions()
static std::string TriggerMenuAction(const std::string &)
static std::string SwitchEditor(const std::string &)
static std::string SwitchSession(int)
static std::string GetMapProperties(int)
static std::string ShowOnlyWindow(const std::string &)
static std::string GetPanelsInCategory(const std::string &category)
static std::string ClosePanel(const std::string &card_id)
static std::string HideAllWindowsInCategory(const std::string &)
static std::string GetMapEntities(int)
static std::string AgentAcceptProposal(const std::string &)
static std::string ReadRomBytes(int, int)
static std::string ShowAllWindowsInCategory(const std::string &)
static void Initialize(editor::EditorManager *)
static std::string GetCurrentOverworldMap()
static std::string GetRoomObjects(int)
static std::string ToggleWindow(const std::string &)
static std::string CloseWindow(const std::string &)
static std::string OpenPanel(const std::string &card_id)
static std::string GetMapTileData(int)
static std::string SetPanelLayout(const std::string &)
static std::string AgentSetConfig(const std::string &)
static std::string SetSelection(const std::string &)
static std::string WriteRomBytes(int, const std::string &)
static std::string TogglePanel(const std::string &card_id)
static std::string GetRoomTileData(int)
static std::string GetPaletteData(const std::string &, int)
static std::string GetWindowsInCategory(const std::string &)
static std::string GetRoomProperties(int)
static std::string AgentGetProposalDetails(const std::string &)
static std::string GetUIElementBounds(const std::string &)
static std::string AgentRejectProposal(const std::string &)
static std::string OpenWindow(const std::string &)
static std::string AgentSendMessage(const std::string &)
The EditorManager controls the main editor window and manages the various editor classes.
absl::Status LoadFont(const FontConfig &font_config)