Implement save overwrite confirmation (#368)
* Implement save overwrite confirmation + fixed pause game not pausing game execution. * docs: Automatic update of API docs Co-authored-by: StraToN <StraToN@users.noreply.github.com>
This commit is contained in:
@@ -432,7 +432,7 @@ func set_angle(deg: int, immediate = true) -> void:
|
||||
|
||||
# Returns the angle that corresponds to the current direction of the object.
|
||||
func _get_angle() -> int:
|
||||
return parent.animations.dir_angles[last_dir].animation
|
||||
return parent.animations.dir_angles[last_dir].angle_start
|
||||
|
||||
|
||||
# Return the shortest way to turn from a direction to another. Returned way is
|
||||
|
||||
@@ -14,6 +14,10 @@ var events_queue: Array = []
|
||||
var scheduled_events: Array = []
|
||||
|
||||
|
||||
func _ready():
|
||||
self.pause_mode = Node.PAUSE_MODE_STOP
|
||||
|
||||
|
||||
# Handle the events queue and scheduled events
|
||||
func _process(delta: float) -> void:
|
||||
if events_queue.size() > 0:
|
||||
|
||||
@@ -40,7 +40,7 @@ func set_state(p_state: String, immediate: bool = false):
|
||||
if node.has_method("get_animation_player"):
|
||||
var animation_node: ESCAnimationPlayer = node.get_animation_player()
|
||||
|
||||
if animation_node:
|
||||
if animation_node.is_valid():
|
||||
animation_node.stop()
|
||||
var actual_animator
|
||||
if animation_node.has_animation(p_state):
|
||||
|
||||
@@ -137,3 +137,11 @@ func seek_end(name: String):
|
||||
# - name: Name of the animation played
|
||||
func _on_animation_finished(name: String):
|
||||
emit_signal("animation_finished", name)
|
||||
|
||||
|
||||
# Return true if the ESCAnimationPlayer node is valid, ie. it has a valid player
|
||||
# node.
|
||||
# **Returns: true if the ESCAnimationPlayer has a valid player node,
|
||||
# else false**
|
||||
func is_valid() -> bool:
|
||||
return _player_node != null and _player_node is Node
|
||||
|
||||
@@ -154,6 +154,7 @@ var _animation_player: ESCAnimationPlayer = null
|
||||
# Add the movable node, connect signals, detect child nodes
|
||||
# and register this item
|
||||
func _ready():
|
||||
self.pause_mode = Node.PAUSE_MODE_STOP
|
||||
|
||||
_detect_children()
|
||||
|
||||
@@ -214,7 +215,7 @@ func get_animation_player() -> Node:
|
||||
child is AnimationPlayer:
|
||||
player_node_path = child.get_path()
|
||||
if not has_node(player_node_path):
|
||||
escoria.logger.error(
|
||||
escoria.logger.warning(
|
||||
"Can not find node at path %s" % player_node_path
|
||||
)
|
||||
_animation_player = ESCAnimationPlayer.new(get_node(player_node_path))
|
||||
|
||||
@@ -169,6 +169,9 @@ func load_game(id: int):
|
||||
)
|
||||
|
||||
load_event.statements = load_statements
|
||||
|
||||
escoria.set_game_paused(false)
|
||||
|
||||
escoria.event_manager.queue_event(load_event)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
# The escoria main script
|
||||
extends Node
|
||||
|
||||
# Signal sent when pause menu has to be displayed
|
||||
signal request_pause_menu
|
||||
|
||||
|
||||
# Escoria version number
|
||||
const ESCORIA_VERSION = "0.1.0"
|
||||
|
||||
@@ -97,6 +101,7 @@ func _init():
|
||||
|
||||
# Load settings
|
||||
func _ready():
|
||||
inputs_manager.register_core()
|
||||
settings = ESCSaveSettings.new()
|
||||
settings = save_manager.load_settings()
|
||||
escoria._on_settings_loaded(escoria.settings)
|
||||
@@ -388,3 +393,25 @@ func _on_settings_loaded(p_settings: ESCSaveSettings) -> void:
|
||||
)
|
||||
TranslationServer.set_locale(settings.text_lang)
|
||||
|
||||
|
||||
# Input function to manage specific input keys
|
||||
func _input(event):
|
||||
if event.is_action_pressed("esc_show_debug_prompt"):
|
||||
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
|
||||
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
emit_signal("request_pause_menu")
|
||||
|
||||
if ProjectSettings.get_setting("escoria/ui/tooltip_follows_mouse"):
|
||||
if escoria.main.current_scene and escoria.main.current_scene.game:
|
||||
if event is InputEventMouseMotion:
|
||||
escoria.main.current_scene.game. \
|
||||
update_tooltip_following_mouse_position(event.position)
|
||||
|
||||
|
||||
# Pauses or unpause the game
|
||||
#
|
||||
# #### Parameters
|
||||
# - p_paused: if true, pauses the game. If false, unpauses the game.
|
||||
func set_game_paused(p_paused: bool):
|
||||
get_tree().paused = p_paused
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
[ext_resource path="res://addons/escoria-core/game/escoria.gd" type="Script" id=3]
|
||||
|
||||
[node name="escoria" type="Node"]
|
||||
pause_mode = 2
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="main" parent="." instance=ExtResource( 2 )]
|
||||
|
||||
@@ -18,7 +18,6 @@ enum {
|
||||
# The current input mode
|
||||
var input_mode = INPUT_ALL
|
||||
|
||||
|
||||
# A LIFO stack of hovered items
|
||||
var hover_stack: Array = []
|
||||
|
||||
@@ -26,6 +25,15 @@ var hover_stack: Array = []
|
||||
var hotspot_focused: String = ""
|
||||
|
||||
|
||||
# Register core signals (from escoria.gd)
|
||||
func register_core():
|
||||
escoria.connect(
|
||||
"request_pause_menu",
|
||||
self,
|
||||
"_on_pause_menu_requested"
|
||||
)
|
||||
|
||||
|
||||
# Connect the item signals to the local methods
|
||||
func register_inventory_item(item: Node):
|
||||
item.connect(
|
||||
@@ -86,24 +94,6 @@ func register_background(background: ESCBackground):
|
||||
)
|
||||
|
||||
|
||||
# Input event handler
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - event: Godot input event received
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("esc_show_debug_prompt"):
|
||||
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
|
||||
|
||||
if input_mode == INPUT_ALL and event.is_action_pressed("ui_cancel"):
|
||||
_on_pause_menu_requested()
|
||||
|
||||
if ProjectSettings.get_setting("escoria/ui/tooltip_follows_mouse"):
|
||||
if escoria.main.current_scene and escoria.main.current_scene.game:
|
||||
if event is InputEventMouseMotion:
|
||||
escoria.main.current_scene.game.update_tooltip_following_mouse_position(event.position)
|
||||
|
||||
|
||||
# The background was clicked with the LMB
|
||||
#
|
||||
# #### Parameters
|
||||
|
||||
@@ -166,8 +166,10 @@ func pause_game():
|
||||
escoria.main.current_scene.game.get_node("camera").current = true
|
||||
escoria.main.current_scene.game.show_ui()
|
||||
escoria.main.current_scene.show()
|
||||
escoria.set_game_paused(false)
|
||||
else:
|
||||
$ui/pause_menu.show()
|
||||
escoria.main.current_scene.game.get_node("camera").current = false
|
||||
escoria.main.current_scene.game.hide_ui()
|
||||
escoria.main.current_scene.hide()
|
||||
escoria.set_game_paused(true)
|
||||
|
||||
Reference in New Issue
Block a user