-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: warn user before losing progress on an unfinished practice (#277)
Co-authored-by: Nathan Lovato <[email protected]>
- Loading branch information
1 parent
4fb06ee
commit c3f4fbd
Showing
9 changed files
with
396 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Base class for lesson and practice pages. Provides an interface for navigation | ||
# in relation with NavigationManager. | ||
# | ||
# Defines required overridable functions for interaction with | ||
# NavigationManager.gd. | ||
# | ||
# Defaults to always accept being unlaoded unless overriden. | ||
class_name UINavigatablePage | ||
extends Control | ||
|
||
var _is_current_screen := false | ||
|
||
|
||
func _ready() -> void: | ||
NavigationManager.connect( | ||
"all_screens_unload_requested", self, "_on_all_screens_unload_requested" | ||
) | ||
|
||
|
||
func set_is_current_screen(value: bool) -> void: | ||
if _is_current_screen == value: | ||
return | ||
|
||
_is_current_screen = value | ||
|
||
if _is_current_screen: | ||
NavigationManager.connect( | ||
"last_screen_unload_requested", self, "_on_current_screen_unload_requested" | ||
) | ||
else: | ||
NavigationManager.disconnect( | ||
"last_screen_unload_requested", self, "_on_current_screen_unload_requested" | ||
) | ||
|
||
|
||
func _accept_unload() -> void: | ||
NavigationManager.confirm_unload() | ||
|
||
|
||
func _deny_unload() -> void: | ||
NavigationManager.deny_unload() | ||
|
||
|
||
# Overridde if unload requires waiting | ||
func _on_current_screen_unload_requested() -> void: | ||
_accept_unload() | ||
|
||
|
||
# Overridde if unload requires waiting | ||
func _on_all_screens_unload_requested() -> void: | ||
if _is_current_screen: | ||
_on_current_screen_unload_requested() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.