Added a new character and modified the way :setup and :ready events are run.
This commit is contained in:
114
game/ui/ui_9verbs/game.gd
Normal file
114
game/ui/ui_9verbs/game.gd
Normal file
@@ -0,0 +1,114 @@
|
||||
extends Node
|
||||
|
||||
"""
|
||||
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)
|
||||
|
||||
- element_focused(element_id : String)
|
||||
- element_unfocused()
|
||||
|
||||
- left_click_on_hotspot(hotspot_global_id : String, event : InputEvent)
|
||||
- right_click_on_hotspot(hotspot_global_id : String, event : InputEvent)
|
||||
- left_double_click_on_hotspot(hotspot_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)
|
||||
"""
|
||||
|
||||
signal element_focused(element_global_id)
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("switch_action_verb"):
|
||||
if event.button_index == BUTTON_WHEEL_UP:
|
||||
$ui/verbs_layer/verbs_menu.iterate_actions_cursor(-1)
|
||||
elif event.button_index == BUTTON_WHEEL_DOWN:
|
||||
$ui/verbs_layer/verbs_menu.iterate_actions_cursor(1)
|
||||
|
||||
## BACKGROUND ##
|
||||
|
||||
func left_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
|
||||
func right_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
|
||||
func left_double_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position, true])
|
||||
|
||||
|
||||
## ITEM/HOTSPOT FOCUS ##
|
||||
|
||||
func element_focused(element_id : String) -> void:
|
||||
#emit_signal("element_focused", element_id)
|
||||
# var target_obj = escoria.esc_runner.get_object(element_id)
|
||||
# if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null:
|
||||
# if target_obj is ESCItem or target_obj is ESCHotspot:
|
||||
# $ui/verbs_layer/verbs_menu.set_by_name(target_obj.default_action)
|
||||
pass
|
||||
|
||||
|
||||
func element_unfocused() -> void:
|
||||
#emit_signal("element_focused", "")
|
||||
#$ui/verbs_layer/verbs_menu.set_by_name("walk")
|
||||
pass
|
||||
|
||||
|
||||
## HOTSPOTS ##
|
||||
|
||||
func left_click_on_hotspot(hotspot_global_id : String, event : InputEvent) -> void:
|
||||
escoria.do("hotspot_left_click", [hotspot_global_id, event])
|
||||
|
||||
func right_click_on_hotspot(hotspot_global_id : String, event : InputEvent) -> void:
|
||||
escoria.do("hotspot_right_click", [hotspot_global_id, event])
|
||||
|
||||
func left_double_click_on_hotspot(hotspot_global_id : String, event : InputEvent) -> void:
|
||||
escoria.do("hotspot_left_click", [hotspot_global_id, event])
|
||||
|
||||
|
||||
## ITEMS ##
|
||||
|
||||
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:
|
||||
escoria.do("item_right_click", [item_global_id, event])
|
||||
|
||||
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:
|
||||
escoria.do("item_left_click", [inventory_item_global_id, event])
|
||||
if escoria.esc_runner.current_action == "use":
|
||||
var item = escoria.esc_runner.get_object(inventory_item_global_id)
|
||||
if item.texture:
|
||||
$ui/verbs_layer/verbs_menu.set_tool_texture(item.texture)
|
||||
elif item.inventory_item_scene_file.instance().texture_normal:
|
||||
$ui/verbs_layer/verbs_menu.set_tool_texture(item.inventory_item_scene_file.instance().texture_normal)
|
||||
|
||||
|
||||
func right_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void:
|
||||
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:
|
||||
pass
|
||||
|
||||
func inventory_item_focused(inventory_item_global_id : String) -> void:
|
||||
emit_signal("element_focused", inventory_item_global_id)
|
||||
|
||||
func inventory_item_unfocused() -> void:
|
||||
emit_signal("element_focused", "")
|
||||
|
||||
|
||||
func open_inventory():
|
||||
$ui/inventory_layer/inventory_ui/inventory_button.show_inventory()
|
||||
|
||||
|
||||
func close_inventory():
|
||||
$ui/inventory_layer/inventory_ui/inventory_button.close_inventory()
|
||||
@@ -1,15 +1,17 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/template_scenes/label/action_target_tooltip.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://game/ui/ui_9verbs/inventory_ui.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://game/ui/ui_9verbs/verbs_menu.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://game/ui/ui_9verbs/game.gd" type="Script" id=5]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=6]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.6, 0.6, 0.6, 0.5 )
|
||||
|
||||
[node name="game" type="Node"]
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="ui" type="CanvasLayer" parent="."]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/inventory/inventory_ui.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/items/all_items.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://game/items/ESCORIA_ALL_ITEMS.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://game/ui/ui_9verbs/inventory_ui_container.gd" type="Script" id=3]
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
"""
|
||||
This script is out of Escoria's scope. It controls the UI reaction to an
|
||||
UI event (eg right click) to change the cursor accordingly.
|
||||
"""
|
||||
|
||||
func _ready():
|
||||
for but in $actions.get_children():
|
||||
but.connect("pressed", self, "_on_action_selected", [but.name])
|
||||
|
||||
Reference in New Issue
Block a user