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 PanelManager;
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 // Panel Control
87 // ============================================================================
88
94 static std::string OpenPanel(const std::string& card_id);
95
101 static std::string ClosePanel(const std::string& card_id);
102
108 static std::string TogglePanel(const std::string& card_id);
109
114 static std::string GetVisiblePanels();
115
120 static std::string GetAvailablePanels();
121
127 static std::string GetPanelsInCategory(const std::string& category);
128
133 static std::string ShowAllPanels();
134
139 static std::string HideAllPanels();
140
146 static std::string ShowAllPanelsInCategory(const std::string& category);
147
153 static std::string HideAllPanelsInCategory(const std::string& category);
154
160 static std::string ShowOnlyPanel(const std::string& card_id);
161
162 // ============================================================================
163 // Layout Control
164 // ============================================================================
165
171 static std::string SetPanelLayout(const std::string& layout_name);
172
177 static std::string GetAvailableLayouts();
178
184 static std::string SaveCurrentLayout(const std::string& layout_name);
185
186 // ============================================================================
187 // Menu/UI Actions
188 // ============================================================================
189
195 static std::string TriggerMenuAction(const std::string& action_path);
196
201 static std::string GetAvailableMenuActions();
202
203 // ============================================================================
204 // Session Control
205 // ============================================================================
206
211 static std::string GetSessionInfo();
212
217 static std::string CreateSession();
218
224 static std::string SwitchSession(int session_index);
225
226 // ============================================================================
227 // ROM Control
228 // ============================================================================
229
234 static std::string GetRomStatus();
235
242 static std::string ReadRomBytes(int address, int count);
243
250 static std::string WriteRomBytes(int address, const std::string& bytes_json);
251
256 static std::string SaveRom();
257
258 // ============================================================================
259 // Editor State APIs (for LLM agents and automation)
260 // ============================================================================
261
266 static std::string GetEditorSnapshot();
267
272 static std::string GetCurrentDungeonRoom();
273
278 static std::string GetCurrentOverworldMap();
279
284 static std::string GetEditorSelection();
285
286 // ============================================================================
287 // Read-only Data APIs
288 // ============================================================================
289
295 static std::string GetRoomTileData(int room_id);
296
302 static std::string GetRoomObjects(int room_id);
303
309 static std::string GetRoomProperties(int room_id);
310
316 static std::string GetMapTileData(int map_id);
317
323 static std::string GetMapEntities(int map_id);
324
330 static std::string GetMapProperties(int map_id);
331
338 static std::string GetPaletteData(const std::string& group_name, int palette_id);
339
344 static std::string ListPaletteGroups();
345
353 static std::string LoadFont(const std::string& name, const std::string& data, float size);
354
355 // ============================================================================
356 // GUI Automation APIs (for LLM agents)
357 // ============================================================================
358
363 static std::string GetUIElementTree();
364
370 static std::string GetUIElementBounds(const std::string& element_id);
371
377 static std::string SetSelection(const std::string& ids_json);
378
379 // ============================================================================
380 // Platform Info API
381 // ============================================================================
382
396 static std::string GetPlatformInfo();
397
398 // ============================================================================
399 // Agent API (for AI/LLM agent integration)
400 // ============================================================================
401
406 static bool AgentIsReady();
407
413 static std::string AgentSendMessage(const std::string& message);
414
419 static std::string AgentGetChatHistory();
420
425 static std::string AgentGetConfig();
426
432 static std::string AgentSetConfig(const std::string& config_json);
433
438 static std::string AgentGetProviders();
439
444 static std::string AgentGetProposals();
445
451 static std::string AgentAcceptProposal(const std::string& proposal_id);
452
458 static std::string AgentRejectProposal(const std::string& proposal_id);
459
465 static std::string AgentGetProposalDetails(const std::string& proposal_id);
466
471 static std::string AgentOpenSidebar();
472
477 static std::string AgentCloseSidebar();
478
479 private:
480 static editor::EditorManager* editor_manager_;
481 static bool initialized_;
482
483 // Helper to get card registry
484 static editor::PanelManager* GetPanelRegistry();
485
486 // Helper to convert EditorType to string
487 static std::string EditorTypeToString(int type);
488
489 // Helper to convert string to EditorType
490 static int StringToEditorType(const std::string& name);
491};
492
493} // namespace platform
494} // namespace app
495} // namespace yaze
496
497#else // !__EMSCRIPTEN__
498
499// Stub for non-WASM builds
500namespace yaze {
501namespace editor {
502class EditorManager;
503}
504
505namespace app {
506namespace platform {
507
509 public:
511 static bool IsReady() { return false; }
512 static void SetupJavaScriptBindings() {}
513 static std::string SwitchEditor(const std::string&) { return "{}"; }
514 static std::string GetCurrentEditor() { return "{}"; }
515 static std::string GetAvailableEditors() { return "[]"; }
516 static std::string OpenPanel(const std::string&) { return "{}"; }
517 static std::string ClosePanel(const std::string&) { return "{}"; }
518 static std::string TogglePanel(const std::string&) { return "{}"; }
519 static std::string GetVisiblePanels() { return "[]"; }
520 static std::string GetAvailablePanels() { return "[]"; }
521 static std::string GetPanelsInCategory(const std::string&) { return "[]"; }
522 static std::string ShowAllPanels() { return "{}"; }
523 static std::string HideAllPanels() { return "{}"; }
524 static std::string ShowAllPanelsInCategory(const std::string&) { return "{}"; }
525 static std::string HideAllPanelsInCategory(const std::string&) { return "{}"; }
526 static std::string ShowOnlyPanel(const std::string&) { return "{}"; }
527 static std::string SetPanelLayout(const std::string&) { return "{}"; }
528 static std::string GetAvailableLayouts() { return "[]"; }
529 static std::string SaveCurrentLayout(const std::string&) { return "{}"; }
530 static std::string TriggerMenuAction(const std::string&) { return "{}"; }
531 static std::string GetAvailableMenuActions() { return "[]"; }
532 static std::string GetSessionInfo() { return "{}"; }
533 static std::string CreateSession() { return "{}"; }
534 static std::string SwitchSession(int) { return "{}"; }
535 static std::string GetRomStatus() { return "{}"; }
536 static std::string ReadRomBytes(int, int) { return "{}"; }
537 static std::string WriteRomBytes(int, const std::string&) { return "{}"; }
538 static std::string SaveRom() { return "{}"; }
539 // Editor State APIs
540 static std::string GetEditorSnapshot() { return "{}"; }
541 static std::string GetCurrentDungeonRoom() { return "{}"; }
542 static std::string GetCurrentOverworldMap() { return "{}"; }
543 static std::string GetEditorSelection() { return "{}"; }
544 // Read-only Data APIs
545 static std::string GetRoomTileData(int) { return "{}"; }
546 static std::string GetRoomObjects(int) { return "[]"; }
547 static std::string GetRoomProperties(int) { return "{}"; }
548 static std::string GetMapTileData(int) { return "{}"; }
549 static std::string GetMapEntities(int) { return "{}"; }
550 static std::string GetMapProperties(int) { return "{}"; }
551 static std::string GetPaletteData(const std::string&, int) { return "{}"; }
552 static std::string ListPaletteGroups() { return "[]"; }
553 // GUI Automation APIs
554 static std::string GetUIElementTree() { return "{}"; }
555 static std::string GetUIElementBounds(const std::string&) { return "{}"; }
556 static std::string SetSelection(const std::string&) { return "{}"; }
557 // Platform Info API
558 static std::string GetPlatformInfo() { return "{}"; }
559 // Agent API
560 static bool AgentIsReady() { return false; }
561 static std::string AgentSendMessage(const std::string&) { return "{}"; }
562 static std::string AgentGetChatHistory() { return "[]"; }
563 static std::string AgentGetConfig() { return "{}"; }
564 static std::string AgentSetConfig(const std::string&) { return "{}"; }
565 static std::string AgentGetProviders() { return "[]"; }
566 static std::string AgentGetProposals() { return "[]"; }
567 static std::string AgentAcceptProposal(const std::string&) { return "{}"; }
568 static std::string AgentRejectProposal(const std::string&) { return "{}"; }
569 static std::string AgentGetProposalDetails(const std::string&) { return "{}"; }
570 static std::string AgentOpenSidebar() { return "{}"; }
571 static std::string AgentCloseSidebar() { return "{}"; }
572};
573
574} // namespace platform
575} // namespace app
576} // namespace yaze
577
578#endif // __EMSCRIPTEN__
579
580#endif // YAZE_APP_PLATFORM_WASM_CONTROL_API_H_
static std::string SaveCurrentLayout(const std::string &)
static std::string GetAvailableMenuActions()
static std::string ShowAllPanelsInCategory(const std::string &)
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 HideAllPanelsInCategory(const std::string &)
static std::string GetMapEntities(int)
static std::string AgentAcceptProposal(const std::string &)
static std::string ShowOnlyPanel(const std::string &)
static std::string ReadRomBytes(int, int)
static std::string ClosePanel(const std::string &)
static std::string OpenPanel(const std::string &)
static void Initialize(editor::EditorManager *)
static std::string GetCurrentOverworldMap()
static std::string GetRoomObjects(int)
static std::string GetMapTileData(int)
static std::string SetPanelLayout(const std::string &)
static std::string GetPanelsInCategory(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 &)
static std::string GetRoomTileData(int)
static std::string GetPaletteData(const std::string &, int)
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 AgentSendMessage(const std::string &)
The EditorManager controls the main editor window and manages the various editor classes.
absl::Status LoadFont(const FontConfig &font_config)