diff --git a/src/config.cpp b/src/config.cpp index 418737b..a59cdcb 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -137,6 +137,75 @@ void config::Sound::dump_as_v1_0_0(toml::table& tbl) { }); } +void config::Windows::load_from_v1_0_0_table(const toml::table& tbl) { + if (not tbl["windows"].is_table()) { + return; + } + const auto windows_table = tbl["windows"].ref(); + if (auto val = windows_table["show_playfield"].value()) { + show_playfield = *val; + } + if (auto val = windows_table["show_file_properties"].value()) { + show_file_properties = *val; + } + if (auto val = windows_table["show_status"].value()) { + show_status = *val; + } + if (auto val = windows_table["show_playback_status"].value()) { + show_playback_status = *val; + } + if (auto val = windows_table["show_timeline"].value()) { + show_timeline = *val; + } + if (auto val = windows_table["show_chart_list"].value()) { + show_chart_list = *val; + } + if (auto val = windows_table["show_linear_view"].value()) { + show_linear_view = *val; + } + if (auto val = windows_table["show_sound_settings"].value()) { + show_sound_settings = *val; + } + if (auto val = windows_table["show_editor_settings"].value()) { + show_editor_settings = *val; + } + if (auto val = windows_table["show_history"].value()) { + show_history = *val; + } + if (auto val = windows_table["show_new_chart_dialog"].value()) { + show_new_chart_dialog = *val; + } + if (auto val = windows_table["show_chart_properties"].value()) { + show_chart_properties = *val; + } + if (auto val = windows_table["show_sync_menu"].value()) { + show_sync_menu = *val; + } + if (auto val = windows_table["show_bpm_change_menu"].value()) { + show_bpm_change_menu = *val; + } +} + +void config::Windows::dump_as_v1_0_0(toml::table& tbl) { + tbl.insert_or_assign("windows", toml::table{ + {"show_playfield", show_playfield}, + {"show_file_properties", show_file_properties}, + {"show_status", show_status}, + {"show_playback_status", show_playback_status}, + {"show_timeline", show_timeline}, + {"show_chart_list", show_chart_list}, + {"show_linear_view", show_linear_view}, + {"show_sound_settings", show_sound_settings}, + {"show_editor_settings", show_editor_settings}, + {"show_history", show_history}, + {"show_new_chart_dialog", show_new_chart_dialog}, + {"show_chart_properties", show_chart_properties}, + {"show_sync_menu", show_sync_menu}, + {"show_bpm_change_menu", show_bpm_change_menu} + }); +} + + config::Config::Config(const std::filesystem::path& settings) : config_path(settings / "config.toml") { @@ -175,6 +244,7 @@ toml::table config::Config::dump_as_v1_0_0() { linear_view.dump_as_v1_0_0(tbl); editor.dump_as_v1_0_0(tbl); sound.dump_as_v1_0_0(tbl); + windows.dump_as_v1_0_0(tbl); return tbl; } @@ -195,4 +265,5 @@ void config::Config::load_from_v1_0_0_table(const toml::table& tbl) { linear_view.load_from_v1_0_0_table(tbl); editor.load_from_v1_0_0_table(tbl); sound.load_from_v1_0_0_table(tbl); + windows.load_from_v1_0_0_table(tbl); } \ No newline at end of file diff --git a/src/config.hpp b/src/config.hpp index b777ae1..f785951 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -56,6 +56,26 @@ namespace config { void dump_as_v1_0_0(toml::table& tbl); }; + struct Windows { + bool show_playfield = true; + bool show_file_properties = false; + bool show_status = false; + bool show_playback_status = true; + bool show_timeline = true; + bool show_chart_list = false; + bool show_linear_view = false; + bool show_sound_settings = false; + bool show_editor_settings = false; + bool show_history = false; + bool show_new_chart_dialog = false; + bool show_chart_properties = false; + bool show_sync_menu = false; + bool show_bpm_change_menu = false; + + void load_from_v1_0_0_table(const toml::table& tbl); + void dump_as_v1_0_0(toml::table& tbl); + }; + /* RAII-style class that holds settings we wish to save on disk and saves them upon being destroyed */ class Config { @@ -69,6 +89,7 @@ namespace config { LinearView linear_view; Editor editor; Sound sound; + Windows windows; private: void load_from_v1_0_0_table(const toml::table& tbl); diff --git a/src/editor_state.cpp b/src/editor_state.cpp index f120d1a..5d4af4c 100644 --- a/src/editor_state.cpp +++ b/src/editor_state.cpp @@ -52,6 +52,20 @@ EditorState::EditorState(const std::filesystem::path& assets_, config::Config& c beat_ticks(std::make_shared(nullptr, assets_, 1.f)), playfield(assets_), linear_view(LinearView{assets_, config_}), + show_playfield(config_.windows.show_playfield), + show_file_properties(config_.windows.show_file_properties), + show_status(config_.windows.show_status), + show_playback_status(config_.windows.show_playback_status), + show_timeline(config_.windows.show_timeline), + show_chart_list(config_.windows.show_chart_list), + show_linear_view(config_.windows.show_linear_view), + show_sound_settings(config_.windows.show_sound_settings), + show_editor_settings(config_.windows.show_editor_settings), + show_history(config_.windows.show_history), + show_new_chart_dialog(config_.windows.show_new_chart_dialog), + show_chart_properties(config_.windows.show_chart_properties), + show_sync_menu(config_.windows.show_sync_menu), + show_bpm_change_menu(config_.windows.show_bpm_change_menu), applicable_timing(song.timing), assets(assets_) { @@ -73,6 +87,20 @@ EditorState::EditorState( beat_ticks(std::make_shared(nullptr, assets_, 1.f)), playfield(assets_), linear_view(LinearView{assets_, config_}), + show_playfield(config_.windows.show_playfield), + show_file_properties(config_.windows.show_file_properties), + show_status(config_.windows.show_status), + show_playback_status(config_.windows.show_playback_status), + show_timeline(config_.windows.show_timeline), + show_chart_list(config_.windows.show_chart_list), + show_linear_view(config_.windows.show_linear_view), + show_sound_settings(config_.windows.show_sound_settings), + show_editor_settings(config_.windows.show_editor_settings), + show_history(config_.windows.show_history), + show_new_chart_dialog(config_.windows.show_new_chart_dialog), + show_chart_properties(config_.windows.show_chart_properties), + show_sync_menu(config_.windows.show_sync_menu), + show_bpm_change_menu(config_.windows.show_bpm_change_menu), applicable_timing(song.timing), assets(assets_) { @@ -435,7 +463,7 @@ Fraction EditorState::get_snap_step() const { }; void EditorState::display_playfield(const Markers::marker_type& opt_marker, Judgement markerEndingState) { - ImGui::SetNextWindowSize(ImVec2(400, 400), ImGuiCond_Once); + ImGui::SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver); ImGui::SetNextWindowSizeConstraints( ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), @@ -1004,7 +1032,7 @@ void EditorState::display_chart_list() { }; void EditorState::display_linear_view() { - ImGui::SetNextWindowSize(ImVec2(304, 500), ImGuiCond_Once); + ImGui::SetNextWindowSize(ImVec2(304, 500), ImGuiCond_FirstUseEver); ImGui::SetNextWindowSizeConstraints(ImVec2(304, 304), ImVec2(FLT_MAX, FLT_MAX)); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(2, 2)); diff --git a/src/editor_state.hpp b/src/editor_state.hpp index 208d818..9a4bac9 100644 --- a/src/editor_state.hpp +++ b/src/editor_state.hpp @@ -142,43 +142,43 @@ public: sf::Time time_at(Fraction beat) const; Fraction get_snap_step() const; - bool show_playfield = true; + bool& show_playfield; void display_playfield(const Markers::marker_type& marker, Judgement markerEndingState); - bool show_file_properties = false; + bool& show_file_properties; void display_file_properties(); - bool show_status = false; + bool& show_status; void display_status(); - bool show_playback_status = true; + bool& show_playback_status; void display_playback_status(); - bool show_timeline = true; + bool& show_timeline; void display_timeline(); - bool show_chart_list = false; + bool& show_chart_list; void display_chart_list(); - bool show_linear_view = false; + bool& show_linear_view; void display_linear_view(); - bool show_sound_settings = false; + bool& show_sound_settings; void display_sound_settings(); - bool show_editor_settings = false; + bool& show_editor_settings; void display_editor_settings(); - bool show_history = false; + bool& show_history; void display_history(); - bool show_new_chart_dialog = false; - bool show_chart_properties = false; + bool& show_new_chart_dialog; + bool& show_chart_properties; - bool show_sync_menu = false; + bool& show_sync_menu; void display_sync_menu(); - bool show_bpm_change_menu = false; + bool& show_bpm_change_menu; void display_bpm_change_menu(); enum class SaveOutcome {