1 #ifndef _ui_services__hpp__included__
2 #define _ui_services__hpp__included__
11 /*********************************************************************************************************************
14 - All functions here are safe to call from another thread.
15 - If function takes onerror parameter, that function is asynchronous.
16 - The onerror handler is called from arbitrary thread.
17 *********************************************************************************************************************/
19 class emulator_instance
;
20 class dumper_factory_base
;
21 namespace keyboard
{ class modifier_set
; }
22 namespace keyboard
{ class key_key
; }
24 struct project_author_info
26 //True if this is a project, false if not. Ignored when saving.
28 //Lua scripts. Ignored when saving if not in project context.
29 std::list
<std::string
> luascripts
;
30 //Autorun new lua scripts. Ignored when saving if not in project context, always loaded as false.
32 //Authors. First of each pair is full name, second is nickname.
33 std::list
<std::pair
<std::string
, std::string
>> authors
;
36 //Project Directory. Ignored if not in project context.
37 std::string directory
;
38 //Project name. Ignored if not in project context.
39 std::string projectname
;
44 struct dumper_information_1
46 //The factory for this dumper.
47 dumper_factory_base
* factory
;
48 //Name of this dumper.
50 //Is this dumper active?
54 //Modes available (first is internal name, second is human-readable one).
55 std::map
<std::string
, std::string
> modes
;
58 struct dumper_information
60 std::map
<std::string
, dumper_information_1
> dumpers
;
64 * Fill branch name map.
66 void UI_get_branch_map(emulator_instance
& instance
, uint64_t& cur
, std::map
<uint64_t, std::string
>& namemap
,
67 std::map
<uint64_t, std::set
<uint64_t>>& childmap
);
69 * Arrange current project to be flushed.
71 void UI_call_flush(emulator_instance
& instance
, std::function
<void(std::exception
&)> onerror
);
73 * Arrage branch to be created.
75 void UI_create_branch(emulator_instance
& instance
, uint64_t id
, const std::string
& name
,
76 std::function
<void(std::exception
&)> onerror
);
78 * Arrage branch to be renamed.
80 void UI_rename_branch(emulator_instance
& instance
, uint64_t id
, const std::string
& name
,
81 std::function
<void(std::exception
&)> onerror
);
83 * Arrage branch to be reparented.
85 void UI_reparent_branch(emulator_instance
& instance
, uint64_t id
, uint64_t pid
,
86 std::function
<void(std::exception
&)> onerror
);
88 * Arrage branch to be deleted.
90 void UI_delete_branch(emulator_instance
& instance
, uint64_t id
, std::function
<void(std::exception
&)> onerror
);
92 * Arrage branch to be switched.
94 void UI_switch_branch(emulator_instance
& instance
, uint64_t id
, std::function
<void(std::exception
&)> onerror
);
96 * Load project author info.
98 project_author_info
UI_load_author_info(emulator_instance
& instance
);
100 * Save project author info.
102 void UI_save_author_info(emulator_instance
& instance
, project_author_info
& info
);
104 * Get available dumpers.
106 dumper_information
UI_get_dumpers(emulator_instance
& instance
);
110 void UI_start_dump(emulator_instance
& inst
, dumper_factory_base
& factory
, const std::string
& mode
,
111 const std::string
& prefix
);
115 void UI_end_dump(emulator_instance
& inst
, dumper_factory_base
& factory
);
117 * Send a keypress event.
119 void UI_do_keypress(emulator_instance
& inst
, const keyboard::modifier_set
& mods
, keyboard::key_key
& key
,
122 * Is there a valid movie?
124 bool UI_has_movie(emulator_instance
& inst
);
126 * Save a movie into buffer.
128 void UI_save_movie(emulator_instance
& inst
, std::ostringstream
& buffer
);
130 * Look up (platform,game) pair.
132 std::pair
<std::string
, std::string
> UI_lookup_platform_and_game(emulator_instance
& inst
);
134 * Get otherpath of current project.
136 std::string
UI_get_project_otherpath(emulator_instance
& inst
);
138 * Get moviepath of current project.
140 std::string
UI_get_project_moviepath(emulator_instance
& inst
);
142 * Is in project context?
144 bool UI_in_project_context(emulator_instance
& inst
);