progresS
This commit is contained in:
28
MainGame.gd
28
MainGame.gd
@@ -1,11 +1,11 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
var cursors = [load("res://boot_icon.png"), load("res://eye_icon.png"), load("res://hand_icon.png"), load("res://speech_icon.png")]
|
||||
var cursor_index = 0
|
||||
var hourglass_cursor = load("res://hourglass_icon.png")
|
||||
var previous_cursor_index: int = 0
|
||||
var is_script_running: bool = false
|
||||
var is_cursor_locked: bool = false # When true, hourglass is shown and cursor can't be changed
|
||||
func get_scene() -> Scene:
|
||||
return $SceneViewport/background
|
||||
|
||||
@@ -51,12 +51,30 @@ func _process(delta):
|
||||
var s = get_scene().ego_scale(player)
|
||||
player.scale = Vector2(s, s)
|
||||
|
||||
# Update cursor if script state changed
|
||||
var script = $GameScript.current_script
|
||||
if script and not is_script_running:
|
||||
set_script_cursor()
|
||||
elif not script and is_script_running:
|
||||
restore_cursor()
|
||||
|
||||
func set_script_cursor() -> void:
|
||||
previous_cursor_index = ActionState.current_action
|
||||
is_script_running = true
|
||||
is_cursor_locked = true # Lock cursor to hourglass
|
||||
Input.set_custom_mouse_cursor(hourglass_cursor)
|
||||
|
||||
func restore_cursor() -> void:
|
||||
is_script_running = false
|
||||
is_cursor_locked = false # Unlock cursor
|
||||
Input.set_custom_mouse_cursor(cursors[previous_cursor_index])
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
$SceneViewport.push_input(event)
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_released("quit"):
|
||||
get_tree().quit()
|
||||
if event.is_action_released("right_click"):
|
||||
if event.is_action_released("right_click") and not is_cursor_locked:
|
||||
ActionState.current_action = (ActionState.current_action + 1) % 4
|
||||
Input.set_custom_mouse_cursor(cursors[ActionState.current_action])
|
||||
|
||||
Reference in New Issue
Block a user