Clean up window-fileupload.cpp
[lsnes.git] / include / core / ui-services.hpp
blob8adae9551ac9b1c2a2567e34b08059eb4022380e
1 #ifndef _ui_services__hpp__included__
2 #define _ui_services__hpp__included__
4 #include <map>
5 #include <set>
6 #include <functional>
7 #include <list>
8 #include <string>
9 #include <sstream>
11 /*********************************************************************************************************************
12 UI services.
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.
27 bool is_project;
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.
31 bool autorunlua;
32 //Authors. First of each pair is full name, second is nickname.
33 std::list<std::pair<std::string, std::string>> authors;
34 //Name of the game.
35 std::string gamename;
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;
40 //Save prefix.
41 std::string prefix;
44 struct dumper_information_1
46 //The factory for this dumper.
47 dumper_factory_base* factory;
48 //Name of this dumper.
49 std::string name;
50 //Is this dumper active?
51 bool active;
52 //Modes available (first is internal name, second is human-readable one).
53 std::map<std::string, std::string> modes;
56 struct dumper_information
58 std::map<std::string, dumper_information_1> dumpers;
61 /**
62 * Fill branch name map.
64 void UI_get_branch_map(emulator_instance& instance, uint64_t& cur, std::map<uint64_t, std::string>& namemap,
65 std::map<uint64_t, std::set<uint64_t>>& childmap);
66 /**
67 * Arrange current project to be flushed.
69 void UI_call_flush(emulator_instance& instance, std::function<void(std::exception&)> onerror);
70 /**
71 * Arrage branch to be created.
73 void UI_create_branch(emulator_instance& instance, uint64_t id, const std::string& name,
74 std::function<void(std::exception&)> onerror);
75 /**
76 * Arrage branch to be renamed.
78 void UI_rename_branch(emulator_instance& instance, uint64_t id, const std::string& name,
79 std::function<void(std::exception&)> onerror);
80 /**
81 * Arrage branch to be reparented.
83 void UI_reparent_branch(emulator_instance& instance, uint64_t id, uint64_t pid,
84 std::function<void(std::exception&)> onerror);
85 /**
86 * Arrage branch to be deleted.
88 void UI_delete_branch(emulator_instance& instance, uint64_t id, std::function<void(std::exception&)> onerror);
89 /**
90 * Arrage branch to be switched.
92 void UI_switch_branch(emulator_instance& instance, uint64_t id, std::function<void(std::exception&)> onerror);
93 /**
94 * Load project author info.
96 project_author_info UI_load_author_info(emulator_instance& instance);
97 /**
98 * Save project author info.
100 void UI_save_author_info(emulator_instance& instance, project_author_info& info);
102 * Get available dumpers.
104 dumper_information UI_get_dumpers(emulator_instance& instance);
106 * Start dumping.
108 void UI_start_dump(emulator_instance& inst, dumper_factory_base& factory, const std::string& mode,
109 const std::string& prefix);
111 * End dumping.
113 void UI_end_dump(emulator_instance& inst, dumper_factory_base& factory);
115 * Send a keypress event.
117 void UI_do_keypress(emulator_instance& inst, const keyboard::modifier_set& mods, keyboard::key_key& key,
118 bool polarity);
120 * Is there a valid movie?
122 bool UI_has_movie(emulator_instance& inst);
124 * Save a movie into buffer.
126 void UI_save_movie(emulator_instance& inst, std::ostringstream& buffer);
128 * Look up (platform,game) pair.
130 std::pair<std::string, std::string> UI_lookup_platform_and_game(emulator_instance& inst);
132 #endif