Implement save and loading games (#8)
This commit is contained in:
@@ -4,26 +4,26 @@ extends ESCGame
|
||||
"""
|
||||
Implement methods to react to inputs.
|
||||
|
||||
- left_click_on_bg(position : Vector2)
|
||||
- right_click_on_bg(position : Vector2)
|
||||
- left_double_click_on_bg(position : Vector2)
|
||||
- left_click_on_bg(position: Vector2)
|
||||
- right_click_on_bg(position: Vector2)
|
||||
- left_double_click_on_bg(position: Vector2)
|
||||
|
||||
- element_focused(element_id : String)
|
||||
- element_focused(element_id: String)
|
||||
- element_unfocused()
|
||||
|
||||
- left_click_on_item(item_global_id : String, event : InputEvent)
|
||||
- right_click_on_item(item_global_id : String, event : InputEvent)
|
||||
- left_double_click_on_item(item_global_id : String, event : InputEvent)
|
||||
- left_click_on_item(item_global_id: String, event: InputEvent)
|
||||
- right_click_on_item(item_global_id: String, event: InputEvent)
|
||||
- left_double_click_on_item(item_global_id: String, event: InputEvent)
|
||||
|
||||
- left_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent)
|
||||
- right_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent)
|
||||
- left_double_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent)
|
||||
- inventory_item_focused(inventory_item_global_id : String)
|
||||
- left_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent)
|
||||
- right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent)
|
||||
- left_double_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent)
|
||||
- inventory_item_focused(inventory_item_global_id: String)
|
||||
- inventory_item_unfocused()
|
||||
- open_inventory()
|
||||
- close_inventory()
|
||||
|
||||
- mousewheel_action(direction : int)
|
||||
- mousewheel_action(direction: int)
|
||||
|
||||
- hide_ui()
|
||||
- show_ui()
|
||||
@@ -47,17 +47,17 @@ func _input(event):
|
||||
|
||||
## BACKGROUND ##
|
||||
|
||||
func left_click_on_bg(position : Vector2) -> void:
|
||||
func left_click_on_bg(position: Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
escoria.action_manager.clear_current_action()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
func right_click_on_bg(position : Vector2) -> void:
|
||||
func right_click_on_bg(position: Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
escoria.action_manager.clear_current_action()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
func left_double_click_on_bg(position : Vector2) -> void:
|
||||
func left_double_click_on_bg(position: Vector2) -> void:
|
||||
escoria.do("walk", ["player", position, true])
|
||||
escoria.action_manager.clear_current_action()
|
||||
verbs_menu.unselect_actions()
|
||||
@@ -65,7 +65,7 @@ func left_double_click_on_bg(position : Vector2) -> void:
|
||||
|
||||
## ITEM FOCUS ##
|
||||
|
||||
func element_focused(element_id : String) -> void:
|
||||
func element_focused(element_id: String) -> void:
|
||||
var target_obj = escoria.object_manager.get_object(element_id).node
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
@@ -80,30 +80,30 @@ func element_unfocused() -> void:
|
||||
|
||||
## ITEMS ##
|
||||
|
||||
func left_click_on_item(item_global_id : String, event : InputEvent) -> void:
|
||||
func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [item_global_id, event])
|
||||
|
||||
func right_click_on_item(item_global_id : String, event : InputEvent) -> void:
|
||||
func right_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.action_manager.set_current_action(verbs_menu.selected_action)
|
||||
escoria.do("item_right_click", [item_global_id, event])
|
||||
|
||||
func left_double_click_on_item(item_global_id : String, event : InputEvent) -> void:
|
||||
func left_double_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [item_global_id, event])
|
||||
|
||||
|
||||
## INVENTORY ##
|
||||
func left_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void:
|
||||
func left_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [inventory_item_global_id, event])
|
||||
|
||||
|
||||
func right_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void:
|
||||
func right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.action_manager.set_current_action(verbs_menu.selected_action)
|
||||
escoria.do("item_right_click", [inventory_item_global_id, event])
|
||||
|
||||
func left_double_click_on_inventory_item(_inventory_item_global_id : String, _event : InputEvent) -> void:
|
||||
func left_double_click_on_inventory_item(_inventory_item_global_id: String, _event: InputEvent) -> void:
|
||||
pass
|
||||
|
||||
func inventory_item_focused(inventory_item_global_id : String) -> void:
|
||||
func inventory_item_focused(inventory_item_global_id: String) -> void:
|
||||
var target_obj = escoria.object_manager.get_object(
|
||||
inventory_item_global_id
|
||||
).node
|
||||
@@ -128,13 +128,14 @@ func close_inventory():
|
||||
pass
|
||||
|
||||
|
||||
func mousewheel_action(_direction : int):
|
||||
func mousewheel_action(_direction: int):
|
||||
pass
|
||||
|
||||
|
||||
func hide_ui():
|
||||
$ui/panel_down.hide()
|
||||
verbs_menu.hide()
|
||||
$ui/panel_down/verbs_layer/room_select.hide()
|
||||
$ui/panel_down/inventory_layer/inventory_ui.hide()
|
||||
tooltip.hide()
|
||||
|
||||
@@ -142,6 +143,7 @@ func hide_ui():
|
||||
func show_ui():
|
||||
$ui/panel_down.show()
|
||||
verbs_menu.show()
|
||||
$ui/panel_down/verbs_layer/room_select.show()
|
||||
$ui/panel_down/inventory_layer/inventory_ui.show()
|
||||
tooltip.show()
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ This script is totally user-defined. It does exactly what the user wants the
|
||||
inventory to look like. It only requires 4 functions to be defined:
|
||||
- is_empty() -> bool
|
||||
- get_items() -> Array
|
||||
- add_item(inventory_item : ESCInventoryItem)
|
||||
- remove_item(inventory_item : ESCInventoryItem)
|
||||
- add_item(inventory_item: ESCInventoryItem)
|
||||
- remove_item(inventory_item: ESCInventoryItem)
|
||||
The user is free to implement these methods the way s-he likes.
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ func is_empty() -> bool:
|
||||
func get_items() -> Array:
|
||||
return current_nodes_in_container.keys()
|
||||
|
||||
func add_item(inventory_item : ESCInventoryItem):
|
||||
func add_item(inventory_item: ESCInventoryItem):
|
||||
var center_container = CenterContainer.new()
|
||||
center_container.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
center_container.connect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
@@ -28,7 +28,7 @@ func add_item(inventory_item : ESCInventoryItem):
|
||||
add_child(center_container)
|
||||
current_nodes_in_container[inventory_item] = center_container
|
||||
|
||||
func remove_item(inventory_item : ESCInventoryItem):
|
||||
func remove_item(inventory_item: ESCInventoryItem):
|
||||
var node_to_remove = current_nodes_in_container[inventory_item]
|
||||
current_nodes_in_container.erase(node_to_remove)
|
||||
node_to_remove.disconnect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
|
||||
@@ -13,7 +13,7 @@ func _ready():
|
||||
but.connect("pressed", self, "_on_action_selected", [but.name])
|
||||
but.toggle_mode = true
|
||||
|
||||
func _on_action_selected(action : String):
|
||||
func _on_action_selected(action: String):
|
||||
escoria.action_manager.set_current_action(action)
|
||||
|
||||
for but in get_children():
|
||||
@@ -23,7 +23,7 @@ func unselect_actions():
|
||||
for but in get_children():
|
||||
but.set_pressed(false)
|
||||
|
||||
func set_by_name(action_name : String):
|
||||
func set_by_name(action_name: String):
|
||||
selected_action = action_name
|
||||
for but in get_children():
|
||||
but.set_pressed(but.get_name() == action_name)
|
||||
|
||||
Reference in New Issue
Block a user