1 #ifndef _project__hpp__included__
2 #define _project__hpp__included__
8 #include "library/json.hpp"
9 #include "core/controller.hpp"
10 #include "core/rom.hpp"
12 class voice_commentary
;
14 class controller_state
;
25 struct project_branch_info
33 //Information about project.
36 //Internal ID of the project.
38 //Name of the project.
43 std::string roms
[ROM_SLOT_COUNT
];
45 std::string last_save
;
46 //Directory for save/load dialogs.
47 std::string directory
;
48 //Prefix for save/load dialogs.
50 //List of Lua scripts to run at startup.
51 std::list
<std::string
> luascripts
;
53 std::map
<std::string
, std::string
> watches
;
55 std::map
<std::string
, JSON::node
> macros
;
57 std::map
<uint64_t, project_branch_info
> branches
;
58 uint64_t active_branch
;
60 //Filename this was loaded from.
64 std::map
<std::string
, std::string
> settings
;
65 std::string coreversion
;
67 std::string projectid
;
68 std::string romimg_sha256
[ROM_SLOT_COUNT
];
69 std::string romxml_sha256
[ROM_SLOT_COUNT
];
70 std::string namehint
[ROM_SLOT_COUNT
];
71 std::vector
<std::pair
<std::string
, std::string
>> authors
;
72 std::map
<std::string
, std::vector
<char>> movie_sram
;
73 std::vector
<char> anchor_savestate
;
74 int64_t movie_rtc_second
;
75 int64_t movie_rtc_subsecond
;
77 * Obtain parent of branch.
79 * Parameter bid: The branch ID.
80 * Returns: The parent branch ID.
81 * Throws std::runtime_error: Invalid branch ID.
83 * Note: bid 0 is root. Calling this on root always gives 0.
85 uint64_t get_parent_branch(uint64_t bid
);
87 * Get current branch id.
89 * Returns: The branch id.
91 uint64_t get_current_branch() { return active_branch
; }
95 * Parameter bid: The branch id.
96 * Throws std::runtime_error: Invalid branch ID.
98 void set_current_branch(uint64_t bid
);
100 * Get name of branch.
102 * Parameter bid: The branch id.
103 * Throws std::runtime_error: Invalid branch ID.
104 * Note: The name of ROOT branch is always empty string.
106 const std::string
& get_branch_name(uint64_t bid
);
108 * Set name of branch.
110 * Parameter bid: The branch id.
111 * Parameter name: The new name
112 * Throws std::runtime_error: Invalid branch ID.
113 * Note: The name of ROOT branch can't be changed.
115 void set_branch_name(uint64_t bid
, const std::string
& name
);
117 * Set parent branch of branch.
119 * Parameter bid: The branch id.
120 * Parameter pbid: The new parent branch id.
121 * Throws std::runtime_error: Invalid branch ID, or cyclic dependency.
122 * Note: The parent of ROOT branch can't be set.
124 void set_parent_branch(uint64_t bid
, uint64_t pbid
);
126 * Enumerate child branches of specified branch.
128 * Parameter bid: The branch id.
129 * Returns: The set of chilid branch IDs.
130 * Throws std::runtime_error: Invalid branch ID.
132 std::set
<uint64_t> branch_children(uint64_t bid
);
134 * Create a new branch.
136 * Parameter pbid: Parent of the new branch.
137 * Parameter name: Name of new branch.
138 * Returns: Id of new branch.
139 * Throws std::runtime_error: Invalid branch ID.
141 uint64_t create_branch(uint64_t pbid
, const std::string
& name
);
145 * Parameter bid: The branch id.
146 * Throws std::runtime_error: Invalid branch ID or branch has children.
148 void delete_branch(uint64_t bid
);
150 * Get name of current branch as string.
152 std::string
get_branch_string();
154 * Flush the project to disk.
158 void write(std::ostream
& s
);
164 project_state(voice_commentary
& _commentary
, memwatch_set
& _mwatch
, command::group
& _command
,
165 controller_state
& _controls
, settingvar::cache
& _setcache
);
168 * Get currently active project.
170 * Returns: The currently active project or NULL if none.
174 * Change currently active project. This reloads Lua VM, ROM and savestate.
176 * Parameter p: The new currently active project, or NULL to switch out of any project.
177 * Parameter current: If true, do not reload ROM, movie nor state.
179 bool set(project_info
* p
, bool current
= false);
181 * Enumerate all known projects.
183 * Returns: Map from IDs of projects to project names.
185 std::map
<std::string
, std::string
> enumerate();
187 * Load a given project.
189 * Parameter id: The ID of project to load.
190 * Returns: The project information.
192 project_info
& load(const std::string
& id
);
194 * Get project movie path.
196 * Returns: The movie path.
198 std::string
moviepath();
200 * Get project other path.
202 * Returns: The other path.
204 std::string
otherpath();
206 * Get project savestate extension.
208 * Returns: The savestate extension.
210 std::string
savestate_ext();
212 * Copy watches to project
214 void copy_watches(project_info
& p
);
216 * Copy macros to project.
218 void copy_macros(project_info
& p
, controller_state
& s
);
220 project_info
* active_project
;
221 voice_commentary
& commentary
;
222 memwatch_set
& mwatch
;
223 command::group
& command
;
224 controller_state
& controls
;
225 settingvar::cache
& setcache
;