Connect bear-save, massage, farm paywall, cheese catapults, Dressler hijack, final boss phases, fat-stim UI, and scene fixes so the satire path plays through.
190 lines
6.6 KiB
GDScript
190 lines
6.6 KiB
GDScript
extends CanvasLayer
|
|
## Global UI: pause, inventory, shop, settings, toast, dialog, burger-cham.
|
|
|
|
@onready var pause_panel: PanelContainer = $PausePanel
|
|
@onready var dialog_panel: PanelContainer = $DialogPanel
|
|
@onready var dialog_label: Label = $DialogPanel/Margin/DialogLabel
|
|
@onready var toast_label: Label = $ToastLabel
|
|
@onready var burger_overlay: ColorRect = $BurgerOverlay
|
|
@onready var burger_label: Label = $BurgerOverlay/BurgerLabel
|
|
@onready var points_label: Label = $PausePanel/Margin/VBox/PointsLabel
|
|
@onready var inventory_list: ItemList = $PausePanel/Margin/VBox/InventoryList
|
|
@onready var sfx_slider: HSlider = $PausePanel/Margin/VBox/SfxSlider
|
|
@onready var music_slider: HSlider = $PausePanel/Margin/VBox/MusicSlider
|
|
@onready var lang_option: OptionButton = $PausePanel/Margin/VBox/LangOption
|
|
@onready var hp_label: Label = $HUD/HpLabel
|
|
@onready var fat_stim: ColorRect = $FatStim
|
|
@onready var fat_label: Label = $FatStim/FatLabel
|
|
|
|
var _dialog_timer: float = 0.0
|
|
var _fat_blink: float = 0.0
|
|
|
|
func _ready() -> void:
|
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
layer = 100
|
|
pause_panel.visible = false
|
|
dialog_panel.visible = false
|
|
burger_overlay.visible = false
|
|
toast_label.visible = false
|
|
_setup_lang_option()
|
|
_refresh_texts()
|
|
sfx_slider.value = Settings.sfx_volume
|
|
music_slider.value = 1.0
|
|
music_slider.editable = false
|
|
Achievements.unlocked.connect(_on_achievement)
|
|
AudioDirector.burger_cham_triggered.connect(_on_burger_cham)
|
|
Settings.settings_changed.connect(_refresh_texts)
|
|
Locale.locale_changed.connect(_refresh_texts)
|
|
Inventory.inventory_changed.connect(_refresh_inventory)
|
|
Shop.points_changed.connect(_refresh_points)
|
|
GameState.hp_changed.connect(_on_hp)
|
|
GameState.status_changed.connect(func(): _on_hp(GameState.hp, GameState.max_hp))
|
|
_on_hp(GameState.hp, GameState.max_hp)
|
|
_refresh_inventory()
|
|
_refresh_points(Shop.dressler_points)
|
|
|
|
func _process(delta: float) -> void:
|
|
if _dialog_timer > 0.0:
|
|
_dialog_timer -= delta
|
|
if _dialog_timer <= 0.0:
|
|
dialog_panel.visible = false
|
|
_update_fat_stim(delta)
|
|
|
|
func _update_fat_stim(delta: float) -> void:
|
|
if fat_stim == null:
|
|
return
|
|
var fat := GameState.is_fat()
|
|
fat_stim.visible = fat and GameState.current_scene_id not in ["title_screen", "death_screen", "intro_cutscene", "catscene"]
|
|
if fat:
|
|
_fat_blink += delta
|
|
fat_label.text = Locale.tr_key("dialog_tiramisu")
|
|
fat_stim.color = Color(0.05, 0.05, 0.08, 0.35 + 0.25 * abs(sin(_fat_blink * 3.0)))
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("pause_menu"):
|
|
toggle_pause()
|
|
get_viewport().set_input_as_handled()
|
|
|
|
func toggle_pause() -> void:
|
|
if GameState.current_scene_id in ["title_screen", "death_screen", "intro_cutscene", "catscene"]:
|
|
return
|
|
pause_panel.visible = not pause_panel.visible
|
|
get_tree().paused = pause_panel.visible
|
|
_sync_player_focus(not pause_panel.visible)
|
|
if pause_panel.visible:
|
|
_refresh_texts()
|
|
_refresh_inventory()
|
|
|
|
func _sync_player_focus(focused: bool) -> void:
|
|
for node in get_tree().get_nodes_in_group("player"):
|
|
if node.has_method("set_gameplay_focused"):
|
|
node.set_gameplay_focused(focused)
|
|
|
|
func show_dialog(text: String, duration: float = 3.5) -> void:
|
|
dialog_label.text = text
|
|
dialog_panel.visible = true
|
|
_dialog_timer = duration
|
|
|
|
func _setup_lang_option() -> void:
|
|
lang_option.clear()
|
|
lang_option.add_item("Deutsch", 0)
|
|
lang_option.add_item("English", 1)
|
|
lang_option.add_item("Bayerisch", 2)
|
|
match Settings.language:
|
|
"en":
|
|
lang_option.select(1)
|
|
"by":
|
|
lang_option.select(2)
|
|
_:
|
|
lang_option.select(0)
|
|
|
|
func _refresh_texts() -> void:
|
|
$PausePanel/Margin/VBox/TitleLabel.text = Locale.tr_key("menu_settings")
|
|
$PausePanel/Margin/VBox/ResumeButton.text = Locale.tr_key("menu_resume")
|
|
$PausePanel/Margin/VBox/ShopTitle.text = Locale.tr_key("menu_shop")
|
|
$PausePanel/Margin/VBox/BuyPointButton.text = Locale.tr_key("menu_buy_point")
|
|
$PausePanel/Margin/VBox/BuySunglassesButton.text = Locale.tr_key("shop_sunglasses")
|
|
$PausePanel/Margin/VBox/BuyTicketButton.text = Locale.tr_key("shop_ticket")
|
|
$PausePanel/Margin/VBox/BuyMilkButton.text = Locale.tr_key("shop_continue_joke")
|
|
$PausePanel/Margin/VBox/BuyTiramisuButton.text = Locale.tr_key("shop_next_level")
|
|
$PausePanel/Margin/VBox/SfxLabel.text = Locale.tr_key("menu_sfx")
|
|
$PausePanel/Margin/VBox/MusicLabel.text = Locale.tr_key("menu_music")
|
|
$PausePanel/Margin/VBox/LangLabel.text = Locale.tr_key("menu_language")
|
|
$PausePanel/Margin/VBox/InventoryLabel.text = Locale.tr_key("menu_inventory")
|
|
_refresh_points(Shop.dressler_points)
|
|
|
|
func _refresh_points(points: int) -> void:
|
|
points_label.text = Locale.tr_key("menu_points", [str(points)])
|
|
|
|
func _refresh_inventory() -> void:
|
|
inventory_list.clear()
|
|
var items := Inventory.get_all()
|
|
for id in items.keys():
|
|
var count: int = int(items[id])
|
|
var item_name: String = Locale.tr_key("item_" + str(id))
|
|
inventory_list.add_item("%s x%d" % [item_name, count])
|
|
inventory_list.set_item_metadata(inventory_list.item_count - 1, id)
|
|
|
|
func _on_hp(hp: int, max_hp: int) -> void:
|
|
var extra := ""
|
|
if GameState.is_fat():
|
|
extra += " | " + Locale.tr_key("status_fat", [str(int(GameState.fat_time_left))])
|
|
if GameState.is_shocked():
|
|
extra += " | " + Locale.tr_key("status_shock")
|
|
if GameState.is_glitched_slow():
|
|
extra += " | " + Locale.tr_key("status_glitch")
|
|
hp_label.text = "HP %d/%d%s" % [hp, max_hp, extra]
|
|
|
|
func _on_achievement(_id: String, title: String) -> void:
|
|
toast_label.text = Locale.tr_key("toast_achievement", [title])
|
|
toast_label.visible = true
|
|
await get_tree().create_timer(3.0).timeout
|
|
toast_label.visible = false
|
|
|
|
func _on_burger_cham() -> void:
|
|
burger_label.text = Locale.tr_key("burger_cham")
|
|
burger_overlay.visible = true
|
|
await get_tree().create_timer(2.5).timeout
|
|
burger_overlay.visible = false
|
|
|
|
func _on_resume_pressed() -> void:
|
|
pause_panel.visible = false
|
|
get_tree().paused = false
|
|
_sync_player_focus(true)
|
|
|
|
func _on_buy_point() -> void:
|
|
Shop.purchase("buy_point")
|
|
|
|
func _on_buy_sunglasses() -> void:
|
|
Shop.purchase("sunglasses")
|
|
|
|
func _on_buy_ticket() -> void:
|
|
Shop.purchase("death_ticket")
|
|
|
|
func _on_buy_milk() -> void:
|
|
Shop.purchase("continue_joke")
|
|
|
|
func _on_buy_tiramisu() -> void:
|
|
Shop.purchase("next_level")
|
|
|
|
func _on_sfx_changed(value: float) -> void:
|
|
Settings.set_sfx_volume(value)
|
|
|
|
func _on_music_changed(_value: float) -> void:
|
|
Settings.set_music_volume(1.0)
|
|
music_slider.value = 1.0
|
|
|
|
func _on_lang_selected(index: int) -> void:
|
|
match index:
|
|
1:
|
|
Settings.set_language("en")
|
|
2:
|
|
Settings.set_language("by")
|
|
_:
|
|
Settings.set_language("de")
|
|
|
|
func _on_inventory_activated(index: int) -> void:
|
|
var id: Variant = inventory_list.get_item_metadata(index)
|
|
if typeof(id) == TYPE_STRING:
|
|
Inventory.use_item(str(id))
|
|
_refresh_inventory()
|