Files
modbison/scripts/smoke_test_editor_controls_and_hat.gd
2026-09-21 18:25:52 +00:00

158 lines
6.4 KiB
GDScript

extends SceneTree
## Smoke test verifying:
## 1. Character editor has right_hand and right_foot options.
## 2. Water Buffalo Lodge Hat (hair_waterbuffalo_01) exists, resolves, and loads.
## 3. In world editor / build mode, controls_pill is hidden.
## 4. Main menu sound toggle is accessible when logged out and responds to 'M' key.
var passed := 0
var failed := 0
func _initialize() -> void:
_run()
func _check(desc: String, cond: bool) -> bool:
if cond:
print(" PASS: ", desc)
passed += 1
else:
printerr(" FAIL: ", desc)
failed += 1
return cond
func _run() -> void:
await process_frame
print("SMOKE: Starting Editor Controls, Water Buffalo Hat & Sound verification...")
# --- 1. Water Buffalo Hat & Character Editor Slots ---
var AvatarCatalogScript = preload("res://scripts/avatar/avatar_catalog.gd")
var catalog = AvatarCatalogScript.new()
var cat_err = catalog.load_catalog()
_check("Catalog loads successfully", cat_err == OK)
var hat = catalog.resolve("hair_waterbuffalo_01")
_check("hair_waterbuffalo_01 exists in catalog", not hat.is_empty())
_check("hair_waterbuffalo_01 slot is 'hair'", hat.get("slot", "") == "hair")
_check("hair_waterbuffalo_01 mount_bone is 'HeadTop'", hat.get("mount_bone", "") == "HeadTop")
_check("hair_waterbuffalo_01 display_name is 'Water Buffalo Lodge Hat'", hat.get("display_name", "") == "Water Buffalo Lodge Hat")
var AvatarCustomizationUIScript = preload("res://scripts/avatar/avatar_customization_ui.gd")
var ui = AvatarCustomizationUIScript.new()
root.add_child(ui)
await process_frame
await process_frame
var clothing_slots: Array = ui.CATEGORIES[1]["slots"]
_check("Clothing category contains 'right_hand'", clothing_slots.has("right_hand"))
_check("Clothing category contains 'right_foot'", clothing_slots.has("right_foot"))
ui._select_slot("right_hand")
await process_frame
var right_hand_btn = ui.find_child("Item_right_hand_glove_01", true, false)
_check("Item_right_hand_glove_01 exists in ItemList", right_hand_btn != null)
ui._select_slot("right_foot")
await process_frame
var right_foot_btn = ui.find_child("Item_right_foot_boot_01", true, false)
_check("Item_right_foot_boot_01 exists in ItemList", right_foot_btn != null)
ui._select_slot("hair")
await process_frame
var hat_btn = ui.find_child("Item_hair_waterbuffalo_01", true, false)
_check("Item_hair_waterbuffalo_01 exists in ItemList", hat_btn != null)
# Equip water buffalo hat
ui._on_equip_pressed("hair_waterbuffalo_01")
await process_frame
_check("Water Buffalo Hat equipped in loadout", ui.loadout.get_equipment("hair") == "hair_waterbuffalo_01")
ui.queue_free()
await process_frame
# --- 2. Main Menu Sound Controls & Keyboard 'M' ---
var audio_mgr = root.get_node_or_null("AudioManager")
_check("AudioManager autoload exists", audio_mgr != null)
if audio_mgr:
audio_mgr.set_sound_enabled(true, false)
var main_menu_scene = load("res://scenes/main_menu.tscn")
var menu = main_menu_scene.instantiate()
root.add_child(menu)
await process_frame
var sound_btn = menu.find_child("SoundButton", true, false) as Button
_check("SoundButton exists on MainMenu", sound_btn != null)
var auth_sound_btn = menu.find_child("AuthSoundButton", true, false) as Button
_check("AuthSoundButton exists in AuthButtonsRow", auth_sound_btn != null)
var panel_sound_btn = menu.find_child("PanelSoundButton", true, false) as Button
_check("PanelSoundButton exists in AuthPanel", panel_sound_btn != null)
_check("SoundButton text contains 'Sound: ON'", sound_btn != null and sound_btn.text.contains("Sound: ON"))
_check("AuthSoundButton text contains 'Sound: ON'", auth_sound_btn != null and auth_sound_btn.text.contains("Sound: ON"))
# Test 'M' key shortcut
var key_ev = InputEventKey.new()
key_ev.pressed = true
key_ev.keycode = KEY_M
menu._unhandled_input(key_ev)
await process_frame
_check("Pressing 'M' toggles sound OFF", audio_mgr != null and not audio_mgr.is_sound_enabled())
_check("SoundButton text updated to 'Sound: OFF'", sound_btn != null and sound_btn.text.contains("Sound: OFF"))
_check("AuthSoundButton text updated to 'Sound: OFF'", auth_sound_btn != null and auth_sound_btn.text.contains("Sound: OFF"))
# Toggle back ON with AuthSoundButton
if auth_sound_btn != null:
auth_sound_btn.emit_signal("pressed")
await process_frame
_check("AuthSoundButton click toggles sound ON", audio_mgr != null and audio_mgr.is_sound_enabled())
_check("SoundButton text restored to 'Sound: ON'", sound_btn != null and sound_btn.text.contains("Sound: ON"))
menu.queue_free()
await process_frame
# --- 3. World Editor Controls Banner Hiding ---
var game_scene = load("res://scenes/game.tscn")
_check("game.tscn loads successfully", game_scene != null)
if game_scene == null:
_finish()
return
var game = game_scene.instantiate()
root.add_child(game)
await process_frame
var pill = game.find_child("ControlsPill", true, false) as Control
var hud_layer = game.find_child("InGameHUD", true, false) as CanvasLayer
var hud_panel = game.find_child("HUDPanel", true, false) as Control
_check("ControlsPill exists in game HUD", pill != null)
_check("InGameHUD CanvasLayer exists", hud_layer != null)
_check("HUDPanel exists in game HUD", hud_panel != null)
_check("ControlsPill starts visible during regular play", pill != null and pill.visible)
_check("InGameHUD starts visible during regular play", hud_layer != null and hud_layer.visible)
_check("HUDPanel starts visible during regular play", hud_panel != null and hud_panel.visible)
# Open build mode
game._open_build_mode()
await process_frame
_check("ControlsPill is HIDDEN when in build mode", pill != null and not pill.visible)
_check("InGameHUD is HIDDEN when in build mode", hud_layer != null and not hud_layer.visible)
_check("HUDPanel is HIDDEN when in build mode", hud_panel != null and not hud_panel.visible)
# Close build mode
game._close_build_mode()
await process_frame
_check("ControlsPill is RESTORED when exiting build mode", pill != null and pill.visible)
_check("InGameHUD is RESTORED when exiting build mode", hud_layer != null and hud_layer.visible)
_check("HUDPanel is RESTORED when exiting build mode", hud_panel != null and hud_panel.visible)
game.queue_free()
await process_frame
print("\n=== SMOKE RESULT: %d/%d passed ===" % [passed, passed + failed])
quit(0 if failed == 0 else 1)
func _finish() -> void:
print("\n=== SMOKE RESULT: %d/%d passed ===" % [passed, passed + failed])
quit(0 if failed == 0 else 1)