Refactor welcome screen behavior in EditorManager to improve user control

- Updated the logic for displaying the welcome screen to only show it if it hasn't been manually closed by the user.
- Introduced a new flag to track whether the welcome screen was manually closed, enhancing user experience by preventing unwanted re-displays.
- Reset the welcome screen state when a ROM is loaded, ensuring a fresh start for the user.
- Minor adjustments to comments for clarity and maintainability.
This commit is contained in:
scawful
2025-09-27 10:55:47 -04:00
parent 9fc84c9a0c
commit 86067fc066
5 changed files with 567 additions and 101 deletions

View File

@@ -27,89 +27,8 @@ Color ParseColor(const std::string &color) {
}
return result;
}
absl::Status ParseThemeContents(const std::string &key,
const std::string &value, Theme &theme) {
try {
if (key == "MenuBarBg") {
theme.menu_bar_bg = ParseColor(value);
} else if (key == "TitleBgActive") {
theme.title_bg_active = ParseColor(value);
} else if (key == "TitleBgCollapsed") {
theme.title_bg_collapsed = ParseColor(value);
} else if (key == "Tab") {
theme.tab = ParseColor(value);
} else if (key == "TabHovered") {
theme.tab_hovered = ParseColor(value);
} else if (key == "TabActive") {
theme.tab_active = ParseColor(value);
}
} catch (const std::exception &e) {
return absl::InvalidArgumentError(e.what());
}
return absl::OkStatus();
}
} // namespace
absl::StatusOr<Theme> LoadTheme(const std::string &filename) {
std::string theme_contents;
try {
theme_contents = core::LoadFile(filename);
} catch (const std::exception &e) {
return absl::InternalError(e.what());
}
Theme theme;
std::istringstream theme_stream(theme_contents);
while (theme_stream.good()) {
std::string line;
std::getline(theme_stream, line);
if (line.empty()) {
continue;
}
std::istringstream line_stream(line);
std::string key;
std::string value;
std::getline(line_stream, key, '=');
std::getline(line_stream, value);
RETURN_IF_ERROR(ParseThemeContents(key, value, theme));
}
return theme;
}
absl::Status SaveTheme(const Theme &theme) {
std::ostringstream theme_stream;
theme_stream << theme.name << "Theme\n";
theme_stream << "MenuBarBg=#" << gui::ColorToHexString(theme.menu_bar_bg)
<< "\n";
theme_stream << "TitleBg=#" << gui::ColorToHexString(theme.title_bar_bg)
<< "\n";
theme_stream << "Header=#" << gui::ColorToHexString(theme.header) << "\n";
theme_stream << "HeaderHovered=#"
<< gui::ColorToHexString(theme.header_hovered) << "\n";
theme_stream << "HeaderActive=#" << gui::ColorToHexString(theme.header_active)
<< "\n";
theme_stream << "TitleBgActive=#"
<< gui::ColorToHexString(theme.title_bg_active) << "\n";
theme_stream << "TitleBgCollapsed=#"
<< gui::ColorToHexString(theme.title_bg_collapsed) << "\n";
theme_stream << "Tab=#" << gui::ColorToHexString(theme.tab) << "\n";
theme_stream << "TabHovered=#" << gui::ColorToHexString(theme.tab_hovered)
<< "\n";
theme_stream << "TabActive=#" << gui::ColorToHexString(theme.tab_active)
<< "\n";
theme_stream << "Button=#" << gui::ColorToHexString(theme.button) << "\n";
theme_stream << "ButtonHovered=#"
<< gui::ColorToHexString(theme.button_hovered) << "\n";
theme_stream << "ButtonActive=#" << gui::ColorToHexString(theme.button_active)
<< "\n";
// Save the theme to a file.
return absl::OkStatus();
}
void ApplyTheme(const Theme &theme) {
ImGuiStyle *style = &ImGui::GetStyle();
ImVec4 *colors = style->Colors;