Ga naar hoofdinhoud

Menus

Pause menu, settings, en andere menu interfaces.

Pause Menu

┌─────────────────────────────────────────┐
│ │
│ PAUZE │
│ │
│ ┌───────────────────┐ │
│ │ Doorgaan │ │
│ └───────────────────┘ │
│ ┌───────────────────┐ │
│ │ Instellingen │ │
│ └───────────────────┘ │
│ ┌───────────────────┐ │
│ │ Opslaan │ │
│ └───────────────────┘ │
│ ┌───────────────────┐ │
│ │ Hoofdmenu │ │
│ └───────────────────┘ │
│ │
└─────────────────────────────────────────┘

Scene Structuur

PauseMenu (Control)
├── Dimmer (ColorRect) # Semi-transparent background
├── Panel (NinePatchRect)
│ └── VBoxContainer
│ ├── Title (Label)
│ ├── ResumeButton
│ ├── SettingsButton
│ ├── SaveButton
│ └── MainMenuButton
└── SettingsPanel (hidden by default)

Script

# pause_menu.gd
extends Control

@onready var settings_panel: Control = $SettingsPanel

var is_paused: bool = false

func _input(event: InputEvent) -> void:
if event.is_action_pressed("pause"):
toggle_pause()

func toggle_pause() -> void:
is_paused = !is_paused
visible = is_paused
get_tree().paused = is_paused

func _on_resume_pressed() -> void:
toggle_pause()

func _on_settings_pressed() -> void:
settings_panel.visible = true

func _on_save_pressed() -> void:
GameState.save_game()
_show_notification("Spel opgeslagen!")

func _on_main_menu_pressed() -> void:
get_tree().paused = false
get_tree().change_scene_to_file("res://scenes/main_menu.tscn")

Settings Menu

┌─────────────────────────────────────────────────────────────────┐
│ INSTELLINGEN [X] │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Audio │
│ ───── │
│ Muziek Volume: [════════●═══════════] 70% │
│ Geluidseffecten: [═══════════●════════] 85% │
│ │
│ Weergave │
│ ───────── │
│ Fullscreen: [✓] │
│ Schermschudden: [✓] │
│ │
│ Toegankelijkheid │
│ ──────────────── │
│ Tekstgrootte: [Klein] [Normaal] [Groot] │
│ Hoog Contrast: [ ] │
│ │
│ [Opslaan] [Annuleren] │
└─────────────────────────────────────────────────────────────────┘

Settings Data

# settings.gd
class_name Settings extends Resource

@export var music_volume: float = 0.7
@export var sfx_volume: float = 0.85
@export var fullscreen: bool = false
@export var screen_shake: bool = true
@export var text_size: int = 1 # 0=small, 1=normal, 2=large
@export var high_contrast: bool = false

const SAVE_PATH = "user://settings.tres"

static func load_settings() -> Settings:
if ResourceLoader.exists(SAVE_PATH):
return load(SAVE_PATH)
return Settings.new()

func save() -> void:
ResourceSaver.save(self, SAVE_PATH)

Settings Panel Script

# settings_panel.gd
extends Control

@onready var music_slider: HSlider = $VBox/Audio/MusicSlider
@onready var sfx_slider: HSlider = $VBox/Audio/SFXSlider
@onready var fullscreen_check: CheckBox = $VBox/Display/FullscreenCheck

var settings: Settings

func _ready() -> void:
settings = Settings.load_settings()
_apply_settings()
_update_ui()

func _update_ui() -> void:
music_slider.value = settings.music_volume
sfx_slider.value = settings.sfx_volume
fullscreen_check.button_pressed = settings.fullscreen

func _apply_settings() -> void:
AudioServer.set_bus_volume_db(
AudioServer.get_bus_index("Music"),
linear_to_db(settings.music_volume)
)
AudioServer.set_bus_volume_db(
AudioServer.get_bus_index("SFX"),
linear_to_db(settings.sfx_volume)
)

if settings.fullscreen:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)

func _on_save_pressed() -> void:
settings.music_volume = music_slider.value
settings.sfx_volume = sfx_slider.value
settings.fullscreen = fullscreen_check.button_pressed
settings.save()
_apply_settings()
hide()

Quest Log Menu

┌─────────────────────────────────────────────────────────────────┐
│ QUEST LOG [X] │
├─────────────────────────────────────────────────────────────────┤
│ [Actief] [Voltooid] │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ★ Dagelijkse Oogst [Tracking]│
│ ──────────────────────────────────────────── │
│ Oogst 5 gewassen │
│ Voortgang: ████████░░ 4/5 │
│ Reward: 10 eikels, 15 XP │
│ │
│ ○ Help Oma Wilma │
│ ──────────────────────────────────────────── │
│ Breng 3 eieren naar Oma Wilma │
│ Voortgang: ██░░░░░░░░ 1/3 │
│ │
└─────────────────────────────────────────────────────────────────┘

Script

# quest_log.gd
extends Control

@onready var quest_list: VBoxContainer = $Panel/QuestList
@onready var active_tab: Button = $Panel/Tabs/ActiveTab
@onready var completed_tab: Button = $Panel/Tabs/CompletedTab

const QUEST_ENTRY = preload("res://scenes/ui/quest_entry.tscn")

var showing_active: bool = true

func _ready() -> void:
active_tab.pressed.connect(func(): _show_quests(true))
completed_tab.pressed.connect(func(): _show_quests(false))
_show_quests(true)

func _show_quests(active: bool) -> void:
showing_active = active
active_tab.button_pressed = active
completed_tab.button_pressed = not active

# Clear list
for child in quest_list.get_children():
child.queue_free()

# Get quests
var quests = quest_manager.get_player_quests()
for quest in quests:
if active and quest.status == "active":
_add_quest_entry(quest)
elif not active and quest.status == "completed":
_add_quest_entry(quest)

func _add_quest_entry(quest: Dictionary) -> void:
var entry = QUEST_ENTRY.instantiate()
entry.setup(quest)
quest_list.add_child(entry)

Map Menu

# world_map.gd
extends Control

@onready var map_image: TextureRect = $MapImage
@onready var player_marker: TextureRect = $PlayerMarker
@onready var location_markers: Node2D = $LocationMarkers

var discovered_locations: Array = []

func _ready() -> void:
_load_discovered_locations()
_update_markers()
_update_player_position()

func _update_player_position() -> void:
var world_pos = GameState.get_saved_position()
var map_pos = _world_to_map(world_pos)
player_marker.position = map_pos

func _on_location_clicked(location_id: String) -> void:
if _can_fast_travel(location_id):
_fast_travel_to(location_id)
else:
_show_location_info(location_id)

func _can_fast_travel(location_id: String) -> bool:
return discovered_locations.has(location_id)

Confirmation Dialog

# confirm_dialog.gd
extends Control

signal confirmed
signal cancelled

@onready var title_label: Label = $Panel/Title
@onready var message_label: Label = $Panel/Message

var _on_confirm_callback: Callable

func show_confirmation(title: String, message: String, on_confirm: Callable) -> void:
title_label.text = title
message_label.text = message
_on_confirm_callback = on_confirm
visible = true

func _on_confirm_pressed() -> void:
if _on_confirm_callback.is_valid():
_on_confirm_callback.call()
visible = false
confirmed.emit()

func _on_cancel_pressed() -> void:
visible = false
cancelled.emit()

Volgende