Files
Dawn-Godot/scripts/UI/DebugMenu.gd
2025-05-25 08:42:17 -05:00

112 lines
3.0 KiB
GDScript

class_name DebugMenu extends VBoxContainer
func _ready() -> void:
show()
$MainMenu.connect("pressed", _on_MainMenu_pressed);
$OverworldOption/Overworld.connect("pressed", _on_Overworld_pressed);
$Quest.connect("pressed", _on_Quests_pressed);
$Inventory.connect("pressed", _on_Inventory_pressed);
$Event.connect("pressed", _on_Event_pressed);
$Cutscene.connect("pressed", _on_Custscene_pressed);
$Cooking.connect("pressed", _on_Cooking_pressed);
$Battle.connect("pressed", _on_Battle_pressed);
$LanguageOption/LangDropdown.item_selected.connect(_on_LanguageSelected)
$LanguageOption/RegDropdown.item_selected.connect(_on_RegionSelected)
# Overworld List
var i:int = 0;
for map in OVERWORLD.MAPS.keys():
$OverworldOption/MapDropdown.add_item(map, i);
i = i + 1;
# Language list
i = 0
for lang in LOCALE.LANGUAGE_MATCH.keys():
$LanguageOption/LangDropdown.add_item(lang, i);
if LOCALE.LANGUAGE_MATCH[lang] == LOCALE.language:
$LanguageOption/LangDropdown.selected = i
i = i + 1;
# Region list
i = 0
for reg in LOCALE.REGION_MATCH.keys():
$LanguageOption/RegDropdown.add_item(reg, i);
if LOCALE.REGION_MATCH[reg] == LOCALE.region:
$LanguageOption/RegDropdown.selected = i
i = i + 1;
func _exit_tree() -> void:
$MainMenu.disconnect("pressed", _on_MainMenu_pressed);
$OverworldOption/Overworld.disconnect("pressed", _on_Overworld_pressed);
$Quest.disconnect("pressed", _on_Quests_pressed);
$Cutscene.disconnect("pressed", _on_Custscene_pressed);
$Cooking.disconnect("pressed", _on_Cooking_pressed);
$Battle.disconnect("pressed", _on_Battle_pressed);
func _process(delta: float) -> void:
if Input.is_action_just_pressed("debug"):
print("Debug key pressed")
if isOpen():
close()
else:
open()
func _on_MainMenu_pressed():
SCENE_MANAGER.setScene("MainMenu");
close()
func _on_Overworld_pressed():
var keys:Array[String] = OVERWORLD.MAPS.keys()
OVERWORLD.setMap(keys[$OverworldOption/MapDropdown.selected])
SCENE_MANAGER.setScene("Overworld");
close()
func _on_Quests_pressed():
close()
if UI.QUEST_MENU.isOpen():
UI.QUEST_MENU.close()
else:
UI.QUEST_MENU.open()
func _on_Custscene_pressed():
print("Cutscene pressed")
func _on_Cooking_pressed():
print("Cooking pressed")
func _on_Battle_pressed():
print("Battle pressed")
func _on_Event_pressed():
close()
if UI.EVENT_FLAG_MENU.isOpen():
UI.EVENT_FLAG_MENU.close()
else:
UI.EVENT_FLAG_MENU.open()
func _on_Inventory_pressed():
close()
if UI.INVENTORY_MENU.isOpen():
UI.INVENTORY_MENU.close()
else:
UI.INVENTORY_MENU.open()
func _on_LanguageSelected(index:int) -> void:
var lang:String = $LanguageOption/LangDropdown.get_item_text(index)
LOCALE.setLocale(LOCALE.LANGUAGE_MATCH[lang], LOCALE.region)
func _on_RegionSelected(index:int) -> void:
var reg:String = $LanguageOption/RegDropdown.get_item_text(index)
LOCALE.setLocale(LOCALE.language, LOCALE.REGION_MATCH[reg])
func open() -> void:
show()
func close() -> void:
hide()
func isOpen() -> bool:
return visible