diff --git a/CHANGELOG.md b/CHANGELOG.md index 41b35b6..51aa1ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Sound files in the assets have been renamed - The long note currently being created (by holding right click) is dropped when the mouse stops hovering over the playfield - The history window changed looks and now displays "current" and "saved" next to the correct history item +- Saving with `File > Save` or `Ctrl+S` now forces saving to isk even if no changes were made ## 🗿 Bugfixes 🗿 - Playfield diff --git a/src/editor_state.cpp b/src/editor_state.cpp index c0acf50..ccf6663 100644 --- a/src/editor_state.cpp +++ b/src/editor_state.cpp @@ -943,7 +943,7 @@ bool EditorState::needs_to_save() const { EditorState::UserWantsToSave EditorState::ask_if_user_wants_to_save() const { int response_code = tinyfd_messageBox( "Warning", - "Chart has unsaved changes, do you want to save ?", + "The currently open chart has unsaved changes, do you want to save ?", "yesnocancel", "warning", 1 @@ -972,15 +972,7 @@ EditorState::SaveOutcome EditorState::save_if_needed_and_user_wants_to() { } switch (ask_if_user_wants_to_save()) { case EditorState::UserWantsToSave::Yes: - { - const auto path = ask_for_save_path_if_needed(); - if (not path) { - return EditorState::SaveOutcome::UserCanceled; - } else { - save(*path); - return EditorState::SaveOutcome::UserSaved; - } - } + return save_asking_for_path(); case EditorState::UserWantsToSave::No: return EditorState::SaveOutcome::UserDeclindedSaving; default: @@ -992,13 +984,17 @@ EditorState::SaveOutcome EditorState::save_if_needed() { if (not needs_to_save()) { return EditorState::SaveOutcome::NoSavingNeeded; } else { - const auto path = ask_for_save_path_if_needed(); - if (not path) { - return EditorState::SaveOutcome::UserCanceled; - } else { - save(*path); - return EditorState::SaveOutcome::UserSaved; - } + return save_asking_for_path(); + } +}; + +EditorState::SaveOutcome EditorState::save_asking_for_path() { + const auto path = ask_for_save_path_if_needed(); + if (not path) { + return EditorState::SaveOutcome::UserCanceled; + } else { + save(*path); + return EditorState::SaveOutcome::UserSaved; } }; @@ -1367,12 +1363,12 @@ void EditorState::save(const std::filesystem::path& path) { history.mark_as_saved(); }; -void feis::save( +void feis::force_save( std::optional& ed, NotificationsQueue& nq ) { if (ed) { - if (ed->save_if_needed() == EditorState::SaveOutcome::UserSaved) { + if (ed->save_asking_for_path() == EditorState::SaveOutcome::UserSaved) { nq.push(std::make_shared("Saved file")); } } diff --git a/src/editor_state.hpp b/src/editor_state.hpp index b596efc..838bdd5 100644 --- a/src/editor_state.hpp +++ b/src/editor_state.hpp @@ -161,6 +161,8 @@ public: SaveOutcome save_if_needed(); + SaveOutcome save_asking_for_path(); + bool needs_to_save() const; enum class UserWantsToSave { @@ -240,7 +242,7 @@ private: }; namespace feis { - void save( + void force_save( std::optional& ed, NotificationsQueue& nq ); diff --git a/src/main.cpp b/src/main.cpp index 28130bb..ec1e325 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -348,7 +348,7 @@ int main() { break; case sf::Keyboard::S: if (event.key.control) { - feis::save(editor_state, notificationsQueue); + feis::force_save(editor_state, notificationsQueue); } break; case sf::Keyboard::V: @@ -502,7 +502,7 @@ int main() { } ImGui::Separator(); if (ImGui::MenuItem("Save", "Ctrl+S", false, editor_state.has_value())) { - feis::save(editor_state, notificationsQueue); + feis::force_save(editor_state, notificationsQueue); } if (ImGui::MenuItem("Save As", "", false, editor_state.has_value())) { if (editor_state) {