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
207 static std::string ToggleMenuBar();
208
209 // ============================================================================
210 // Session Control
211 // ============================================================================
212
217 static std::string GetSessionInfo();
218
223 static std::string CreateSession();
224
230 static std::string SwitchSession(int session_index);
231
232 // ============================================================================
233 // ROM Control
234 // ============================================================================
235
240 static std::string GetRomStatus();
241
248 static std::string ReadRomBytes(int address, int count);
249
256 static std::string WriteRomBytes(int address, const std::string& bytes_json);
257
262 static std::string SaveRom();
263
264 // ============================================================================
265 // Editor State APIs (for LLM agents and automation)
266 // ============================================================================
267
272 static std::string GetEditorSnapshot();
273
278 static std::string GetCurrentDungeonRoom();
279
284 static std::string GetCurrentOverworldMap();
285
290 static std::string GetEditorSelection();
291
292 // ============================================================================
293 // Read-only Data APIs
294 // ============================================================================
295
301 static std::string GetRoomTileData(int room_id);
302
308 static std::string GetRoomObjects(int room_id);
309
315 static std::string GetRoomProperties(int room_id);
316
322 static std::string GetMapTileData(int map_id);
323
329 static std::string GetMapEntities(int map_id);
330
336 static std::string GetMapProperties(int map_id);
337
344 static std::string GetPaletteData(const std::string& group_name, int palette_id);
345
350 static std::string ListPaletteGroups();
351
359 static std::string LoadFont(const std::string& name, const std::string& data, float size);
360
361 // ============================================================================
362 // GUI Automation APIs (for LLM agents)
363 // ============================================================================
364
369 static std::string GetUIElementTree();
370
376 static std::string GetUIElementBounds(const std::string& element_id);
377
383 static std::string SetSelection(const std::string& ids_json);
384
385 // ============================================================================
386 // Platform Info API
387 // ============================================================================
388
402 static std::string GetPlatformInfo();
403
404 // ============================================================================
405 // Agent API (for AI/LLM agent integration)
406 // ============================================================================
407
412 static bool AgentIsReady();
413
419 static std::string AgentSendMessage(const std::string& message);
420
425 static std::string AgentGetChatHistory();
426
431 static std::string AgentGetConfig();
432
438 static std::string AgentSetConfig(const std::string& config_json);
439
444 static std::string AgentGetProviders();
445
450 static std::string AgentGetProposals();
451
457 static std::string AgentAcceptProposal(const std::string& proposal_id);
458
464 static std::string AgentRejectProposal(const std::string& proposal_id);
465
471 static std::string AgentGetProposalDetails(const std::string& proposal_id);
472
477 static std::string AgentOpenSidebar();
478
483 static std::string AgentCloseSidebar();
484
485 private:
486 static editor::EditorManager* editor_manager_;
487 static bool initialized_;
488
489 // Helper to get card registry
490 static editor::PanelManager* GetPanelRegistry();
491
492 // Helper to convert EditorType to string
493 static std::string EditorTypeToString(int type);
494
495 // Helper to convert string to EditorType
496 static int StringToEditorType(const std::string& name);
497};
498
499} // namespace platform
500} // namespace app
501} // namespace yaze
502
503#else // !__EMSCRIPTEN__
504
505// Stub for non-WASM builds
506namespace yaze {
507namespace editor {
508class EditorManager;
509}
510
511namespace app {
512namespace platform {
513
515 public:
517 static bool IsReady() { return false; }
518 static void SetupJavaScriptBindings() {}
519 static std::string SwitchEditor(const std::string&) { return "{}"; }
520 static std::string GetCurrentEditor() { return "{}"; }
521 static std::string GetAvailableEditors() { return "[]"; }
522 static std::string OpenPanel(const std::string&) { return "{}"; }
523 static std::string ClosePanel(const std::string&) { return "{}"; }
524 static std::string TogglePanel(const std::string&) { return "{}"; }
525 static std::string GetVisiblePanels() { return "[]"; }
526 static std::string GetAvailablePanels() { return "[]"; }
527 static std::string GetPanelsInCategory(const std::string&) { return "[]"; }
528 static std::string ShowAllPanels() { return "{}"; }
529 static std::string HideAllPanels() { return "{}"; }
530 static std::string ShowAllPanelsInCategory(const std::string&) { return "{}"; }
531 static std::string HideAllPanelsInCategory(const std::string&) { return "{}"; }
532 static std::string ShowOnlyPanel(const std::string&) { return "{}"; }
533 static std::string SetPanelLayout(const std::string&) { return "{}"; }
534 static std::string GetAvailableLayouts() { return "[]"; }
535 static std::string SaveCurrentLayout(const std::string&) { return "{}"; }
536 static std::string TriggerMenuAction(const std::string&) { return "{}"; }
537 static std::string GetAvailableMenuActions() { return "[]"; }
538 static std::string ToggleMenuBar() { return "{}"; }
539 static std::string GetSessionInfo() { return "{}"; }
540 static std::string CreateSession() { return "{}"; }
541 static std::string SwitchSession(int) { return "{}"; }
542 static std::string GetRomStatus() { return "{}"; }
543 static std::string ReadRomBytes(int, int) { return "{}"; }
544 static std::string WriteRomBytes(int, const std::string&) { return "{}"; }
545 static std::string SaveRom() { return "{}"; }
546 // Editor State APIs
547 static std::string GetEditorSnapshot() { return "{}"; }
548 static std::string GetCurrentDungeonRoom() { return "{}"; }
549 static std::string GetCurrentOverworldMap() { return "{}"; }
550 static std::string GetEditorSelection() { return "{}"; }
551 // Read-only Data APIs
552 static std::string GetRoomTileData(int) { return "{}"; }
553 static std::string GetRoomObjects(int) { return "[]"; }
554 static std::string GetRoomProperties(int) { return "{}"; }
555 static std::string GetMapTileData(int) { return "{}"; }
556 static std::string GetMapEntities(int) { return "{}"; }
557 static std::string GetMapProperties(int) { return "{}"; }
558 static std::string GetPaletteData(const std::string&, int) { return "{}"; }
559 static std::string ListPaletteGroups() { return "[]"; }
560 // GUI Automation APIs
561 static std::string GetUIElementTree() { return "{}"; }
562 static std::string GetUIElementBounds(const std::string&) { return "{}"; }
563 static std::string SetSelection(const std::string&) { return "{}"; }
564 // Platform Info API
565 static std::string GetPlatformInfo() { return "{}"; }
566 // Agent API
567 static bool AgentIsReady() { return false; }
568 static std::string AgentSendMessage(const std::string&) { return "{}"; }
569 static std::string AgentGetChatHistory() { return "[]"; }
570 static std::string AgentGetConfig() { return "{}"; }
571 static std::string AgentSetConfig(const std::string&) { return "{}"; }
572 static std::string AgentGetProviders() { return "[]"; }
573 static std::string AgentGetProposals() { return "[]"; }
574 static std::string AgentAcceptProposal(const std::string&) { return "{}"; }
575 static std::string AgentRejectProposal(const std::string&) { return "{}"; }
576 static std::string AgentGetProposalDetails(const std::string&) { return "{}"; }
577 static std::string AgentOpenSidebar() { return "{}"; }
578 static std::string AgentCloseSidebar() { return "{}"; }
579};
580
581} // namespace platform
582} // namespace app
583} // namespace yaze
584
585#endif // __EMSCRIPTEN__
586
587#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)