mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2025-02-28 15:30:32 +01:00
Ctrl+S and File>Save now force-save
This commit is contained in:
parent
7926b43c53
commit
dac05abe03
@ -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
|
||||
|
@ -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<EditorState>& 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<TextNotification>("Saved file"));
|
||||
}
|
||||
}
|
||||
|
@ -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<EditorState>& ed,
|
||||
NotificationsQueue& nq
|
||||
);
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user