Added sound management in savegames and load games. (#337)
Fixes #300 Fix crash on loading game when the saved position was a float while teleport_pos command needs integers. Fix pause menu missing in simplemouse-ui, causing a crash when calling pause menu. Co-authored-by: StraToN <StraToN@users.noreply.github.com>
This commit is contained in:
@@ -87,4 +87,8 @@ func get_save_data() -> Dictionary:
|
||||
save_data["last_deg"] = wrapi(self.node._movable._get_angle() + 1, 0, 360)
|
||||
save_data["last_dir"] = self.node._movable.last_dir
|
||||
|
||||
if (self.global_id == "bg_music" or self.global_id == "bg_sound") \
|
||||
and self.node.get("state"):
|
||||
save_data["state"] = self.node.get("state")
|
||||
|
||||
return save_data
|
||||
|
||||
@@ -151,15 +151,22 @@ func load_game(id: int):
|
||||
if save_game.objects[object_global_id].has("global_transform"):
|
||||
load_statements.append(ESCCommand.new("teleport_pos %s %s %s" \
|
||||
% [object_global_id,
|
||||
save_game.objects[object_global_id] \
|
||||
["global_transform"].origin.x,
|
||||
save_game.objects[object_global_id] \
|
||||
["global_transform"].origin.y])
|
||||
int(save_game.objects[object_global_id] \
|
||||
["global_transform"].origin.x),
|
||||
int(save_game.objects[object_global_id] \
|
||||
["global_transform"].origin.y)]
|
||||
)
|
||||
)
|
||||
load_statements.append(ESCCommand.new("set_angle %s %s" \
|
||||
% [object_global_id,
|
||||
save_game.objects[object_global_id]["last_deg"]])
|
||||
)
|
||||
|
||||
if object_global_id == "bg_music" or object_global_id == "bg_sound":
|
||||
load_statements.append(ESCCommand.new("set_sound_state %s %s true" \
|
||||
% [object_global_id,
|
||||
save_game.objects[object_global_id]["state"]])
|
||||
)
|
||||
|
||||
load_event.statements = load_statements
|
||||
escoria.event_manager.queue_event(load_event)
|
||||
|
||||
@@ -51,3 +51,7 @@ func _ready():
|
||||
ESCObject.new(global_id, self),
|
||||
true
|
||||
)
|
||||
|
||||
# Set state to default when finished playing.
|
||||
func _on_sound_finished():
|
||||
state = "default"
|
||||
|
||||
@@ -15,3 +15,5 @@ __meta__ = {
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
bus = "SFX"
|
||||
|
||||
[connection signal="finished" from="AudioStreamPlayer" to="." method="_on_sound_finished"]
|
||||
|
||||
@@ -123,15 +123,32 @@ func open_inventory():
|
||||
func close_inventory():
|
||||
$ui/inventory_layer/inventory_ui/inventory_button.close_inventory()
|
||||
|
||||
|
||||
func mousewheel_action(direction: int):
|
||||
$ui/verbs_layer/verbs_menu.iterate_actions_cursor(direction)
|
||||
|
||||
|
||||
func hide_ui():
|
||||
$ui/inventory_layer/inventory_ui.hide()
|
||||
|
||||
|
||||
func show_ui():
|
||||
$ui/inventory_layer/inventory_ui.show()
|
||||
|
||||
|
||||
func _on_event_done(event_name: String):
|
||||
escoria.action_manager.clear_current_action()
|
||||
$ui/verbs_layer/verbs_menu.clear_tool_texture()
|
||||
|
||||
|
||||
func pause_game():
|
||||
if $ui/pause_menu.visible:
|
||||
$ui/pause_menu.hide()
|
||||
escoria.main.current_scene.game.get_node("camera").current = true
|
||||
escoria.main.current_scene.game.show_ui()
|
||||
escoria.main.current_scene.show()
|
||||
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()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.tscn" type="PackedScene" id=2]
|
||||
@@ -7,6 +7,7 @@
|
||||
[ext_resource path="res://addons/escoria-ui-simplemouse/game.gd" type="Script" id=5]
|
||||
[ext_resource path="res://addons/escoria-ui-simplemouse/tooltip/target_tooltip.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://game/ui/commons/room_select.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://game/ui/commons/pause_menu/pause_menu.tscn" type="PackedScene" id=8]
|
||||
|
||||
[node name="game" type="Node2D"]
|
||||
script = ExtResource( 5 )
|
||||
@@ -51,4 +52,7 @@ margin_top = 751.323
|
||||
margin_right = 138.51
|
||||
margin_bottom = 791.324
|
||||
|
||||
[node name="pause_menu" parent="ui" instance=ExtResource( 8 )]
|
||||
visible = false
|
||||
|
||||
[node name="camera" parent="." instance=ExtResource( 3 )]
|
||||
|
||||
@@ -407,6 +407,7 @@ Makes the `player` walk to the position `x`/`y`.
|
||||
|
||||
|
||||
|
||||
|
||||
## Dialogs
|
||||
|
||||
Dialogs are specified by writing `?` with optional parameters, followed by a list of dialog options starting with `-`. Use `!` to end the dialog.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,10 @@
|
||||
extends Control
|
||||
|
||||
|
||||
func _ready():
|
||||
hide()
|
||||
|
||||
|
||||
func _on_continue_pressed():
|
||||
escoria.main.current_scene.game.pause_game()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user