Godot 4.6 exploration game with player movement, step-rotation camera rig, and POI interaction system (explore/rest/close menu). main.tscn is a test scene with placeholder props; debug/ holds unwired terrain prototypes (voxel river, procedural island mesh, cross-shaped hub
69 lines
1.9 KiB
GDScript
Executable File
69 lines
1.9 KiB
GDScript
Executable File
extends CanvasLayer
|
|
|
|
@onready var panel = $Panel
|
|
@onready var title_label = $Panel/TitleLabel
|
|
@onready var message_label = $Panel/MessageLabel
|
|
@onready var option_container = $Panel/OptionContainer
|
|
@onready var hint_label = $Panel/HintLabel
|
|
|
|
var current_options: Array = []
|
|
var selected_index: int = 0
|
|
var mode: String = "menu" # "menu" oder "text"
|
|
|
|
func _ready() -> void:
|
|
panel.visible = false
|
|
|
|
func show_menu(title: String, options: Array) -> void:
|
|
mode = "menu"
|
|
panel.visible = true
|
|
title_label.text = title
|
|
message_label.text = ""
|
|
hint_label.text = "[ESC/B] Beenden"
|
|
current_options = options
|
|
selected_index = 0
|
|
_rebuild_options()
|
|
|
|
func show_text(text: String) -> void:
|
|
mode = "text"
|
|
message_label.text = text
|
|
hint_label.text = "[F/A] Weiter [ESC/B] Beenden"
|
|
_clear_options()
|
|
|
|
func hide_menu() -> void:
|
|
panel.visible = false
|
|
current_options = []
|
|
|
|
func _rebuild_options() -> void:
|
|
_clear_options()
|
|
for i in current_options.size():
|
|
var btn = Button.new()
|
|
btn.text = current_options[i]["label"]
|
|
btn.focus_mode = Control.FOCUS_ALL
|
|
option_container.add_child(btn)
|
|
var action = current_options[i]["action"]
|
|
btn.pressed.connect(_on_option_pressed.bind(action))
|
|
# Ersten Button fokussieren
|
|
if option_container.get_child_count() > 0:
|
|
option_container.get_child(0).grab_focus()
|
|
|
|
func _clear_options() -> void:
|
|
for child in option_container.get_children():
|
|
child.queue_free()
|
|
|
|
func _on_option_pressed(action: String) -> void:
|
|
# Unterscheiden ob wir im Erkunden-Submenu sind
|
|
if action in ["track_follow", "track_leave"]:
|
|
InteractionManager.handle_explore(action)
|
|
else:
|
|
InteractionManager.handle_selection(action)
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if not panel.visible:
|
|
return
|
|
if Input.is_action_just_pressed("cancel"):
|
|
InteractionManager.close()
|
|
# Im Text-Mode mit F/A weiterklicken
|
|
if mode == "text" and Input.is_action_just_pressed("interact"):
|
|
# Zurück zum Hauptmenü
|
|
InteractionManager.open_poi(InteractionManager.current_poi)
|