Files
mod_turn_battle_base/src/DeadgroundBehaviour.cs
cthangover 1018c90c25 Line endings: LF everywhere
.gitattributes forces LF (CRLF only for .bat/.cmd), core.autocrlf is off;
files that differed only by CRLF are normalized.
2026-10-21 13:29:57 +02:00

64 lines
2.4 KiB
C#

using Cthangover.Core.Audio;
using Cthangover.Core.Battle;
using Cthangover.Core.Mods;
using Cthangover.Core.Mods.Resolvers;
using Cthangover.Core.Scenes;
using Cthangover.Core.Settings;
using Cthangover.Mods.Interface.Base.Lists;
using Cthangover.Core.UI.Theming;
using Cthangover.Core.Utils;
using Godot;
namespace Cthangover.TurnBattle
{
/// <summary>
/// Defeat screen widget. Minimal compared to WingroundBehaviour —
/// only sets the deadground background texture (resolved from mods)
/// and offers a Main Menu button that clears BattleData and reloads
/// the menu scene. No loot, no EXP.
/// </summary>
public partial class DeadgroundBehaviour : TransitionWidget
{
/// <summary>
/// Clears battle data and switches to the main menu scene.
/// Bound to the "Main Menu" button on the defeat screen.
/// </summary>
public void ToMainMenuClick()
{
var sceneService = GetNode<GodotSceneService>("/root/GodotSceneService");
sceneService?.SwitchToMenu();
BattleRequest.Current = null;
}
/// <summary>
/// Plays the defeat sound, resolves the deadground background
/// texture from mods, and shows the transition widget.
/// </summary>
public override void Show()
{
CthangoverTheme.Apply(this);
CthangoverTheme.ApplyPrimary(GetNodeOrNull<Button>("Content/CenterPanel/MainMenuButton"));
GameLogger.Log("BATTLE", $"Deadground.Show() ENTER: Visible={Visible}, GodotVisible={base.Visible}", LogLevel.Debug);
var audioService = GetNodeOrNull<Node>("/root/AudioService") as IAudioService;
audioService?.PlaySound("battle/deadground", SoundType.UI);
var bg = GetNodeOrNull<TextureRect>("TransitionBg");
GameLogger.Log("BATTLE", $"Deadground.Show: TransitionBg={(bg != null ? "found" : "NULL")}, texture={(bg?.Texture != null ? "has" : "null")}", LogLevel.Error);
if (bg != null && bg.Texture == null)
{
var tex = Textures.Resolve("deadground");
GameLogger.Log("BATTLE", $"Deadground.Show: ResolveTexture('deadground') = {(tex != null ? "loaded" : "NULL")}", LogLevel.Error);
bg.Texture = tex;
}
base.Show();
GameLogger.Log("BATTLE", $"Deadground.Show() EXIT: Visible={Visible}, GodotVisible={base.Visible}", LogLevel.Debug);
}
}
}