Skip to content

Commit

Permalink
Merge pull request #23 from Friends-of-Monika/feature/unsaved-warning
Browse files Browse the repository at this point in the history
Add warning on pressing 'close' if unsaved
  • Loading branch information
dreamscached committed Jul 16, 2023
2 parents a470441 + fa1ebb8 commit b98c9e9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions mod/screen.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ init 100 python in _fom_saysomething:
self.session = None
self.session_cursor = 0

# Flag to indicate that any changes were made to ask for confirmation
self.changed = False


## PICKER STATE MANAGEMENT FUNCTIONS ----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -388,6 +390,7 @@ init 100 python in _fom_saysomething:
self.text = text
self.on_text_change(text)

self.changed = True
return RETURN_RENDER

def _load_pose_cursors(self, pose_cursors):
Expand Down Expand Up @@ -435,6 +438,7 @@ init 100 python in _fom_saysomething:

# This is equivalent to using Return(RETURN_RENDER) action.
# https://lemmasoft.renai.us/forums/viewtopic.php?p=536626#p536626
self.changed = True
return RETURN_RENDER

def get_pose_label(self, key):
Expand Down Expand Up @@ -508,6 +512,7 @@ init 100 python in _fom_saysomething:
return

self._load_pose_cursors(cursors)
self.changed = True
return RETURN_RENDER

def copy_to_clipboard(self):
Expand Down Expand Up @@ -649,7 +654,6 @@ init 100 python in _fom_saysomething:
# visual track of current preset.)
self.preset_name = name
self.preset_cursor = name

return self._load_state(persistent._fom_saysomething_presets[name])

def delete_preset(self, name):
Expand Down Expand Up @@ -749,7 +753,7 @@ init 100 python in _fom_saysomething:

# NOTE: reset just text, not pose
self._reset_state(reset_pose=False, reset_text=True)

self.changed = True
return RETURN_RENDER

def edit_session_item(self):
Expand Down Expand Up @@ -861,6 +865,8 @@ init 100 python in _fom_saysomething:
"""

self.text = value
if len(self.text) > 0:
self.changed = True
renpy.restart_interaction()

def on_shift_enter_press(self, say):
Expand Down Expand Up @@ -911,6 +917,7 @@ init 100 python in _fom_saysomething:

if self.text.count("\n") < 2:
self.text += "\n"
self.changed = True
return RETURN_RENDER

def on_search_input_change(self, value):
Expand Down Expand Up @@ -1340,7 +1347,13 @@ screen fom_saysomething_picker(say=True):
textbutton (_("Close") if not picker.presets_menu else _("Back")):
xysize (118, None)
if not picker.presets_menu:
action Return(_fom_saysomething.RETURN_CLOSE)
if picker.changed:
action Show("fom_saysomething_confirm_modal",
message=_("You're going to lose any unsaved changes. Continue?"),
ok_action=Return(_fom_saysomething.RETURN_CLOSE),
no_action=None)
else:
action Return(_fom_saysomething.RETURN_CLOSE)
else:
# NOTE: DisableAllInputValues will re-focus on say text
# input (in the textbox) again.
Expand Down

0 comments on commit b98c9e9

Please sign in to comment.