yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
emulator_runtime_policy.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SYSTEM_EMULATOR_RUNTIME_POLICY_H_
2#define YAZE_APP_EDITOR_SYSTEM_EMULATOR_RUNTIME_POLICY_H_
3
4#include <string>
5#include <vector>
6
7namespace yaze::editor {
8
9// When emulator panels are hidden, only advance SNES/audio if the user opted
10// into background keep-alive. MusicPlayer drives its own frames when needed.
11inline bool ShouldTickEmulatorWhenHidden(bool keep_running_in_background) {
12 return keep_running_in_background;
13}
14
15// Startup category policy:
16// - Honor the last-active category, including Emulator (user left it open).
17// - Never default to Emulator when no saved category is available.
18inline std::string PreferStartupCategory(
19 const std::string& saved_category,
20 const std::vector<std::string>& available_categories) {
21 auto category_available = [&](const std::string& cat) {
22 if (available_categories.empty()) {
23 return true;
24 }
25 for (const auto& candidate : available_categories) {
26 if (candidate == cat) {
27 return true;
28 }
29 }
30 return false;
31 };
32
33 if (!saved_category.empty() && category_available(saved_category)) {
34 return saved_category;
35 }
36
37 for (const auto& cat : available_categories) {
38 if (cat != "Emulator") {
39 return cat;
40 }
41 }
42 return {};
43}
44
45} // namespace yaze::editor
46
47#endif // YAZE_APP_EDITOR_SYSTEM_EMULATOR_RUNTIME_POLICY_H_
Editors are the view controllers for the application.
std::string PreferStartupCategory(const std::string &saved_category, const std::vector< std::string > &available_categories)
bool ShouldTickEmulatorWhenHidden(bool keep_running_in_background)