2026-04-10 14:58:03 +02:00
|
|
|
using Godot;
|
|
|
|
|
using System;
|
|
|
|
|
using Chessistics.Engine.Model;
|
|
|
|
|
|
|
|
|
|
namespace Chessistics.Scripts.UI;
|
|
|
|
|
|
|
|
|
|
public partial class ControlBar : HBoxContainer
|
|
|
|
|
{
|
|
|
|
|
[Signal]
|
|
|
|
|
public delegate void PlayPressedEventHandler();
|
|
|
|
|
[Signal]
|
|
|
|
|
public delegate void PausePressedEventHandler();
|
|
|
|
|
[Signal]
|
|
|
|
|
public delegate void StepPressedEventHandler();
|
|
|
|
|
[Signal]
|
|
|
|
|
public delegate void StopPressedEventHandler();
|
|
|
|
|
[Signal]
|
|
|
|
|
public delegate void SpeedChangedEventHandler(float speed);
|
|
|
|
|
|
|
|
|
|
private Button _playButton = null!;
|
|
|
|
|
private Button _pauseButton = null!;
|
|
|
|
|
private Button _stepButton = null!;
|
|
|
|
|
private Button _stopButton = null!;
|
|
|
|
|
private OptionButton _speedSelect = null!;
|
|
|
|
|
private Label _turnLabel = null!;
|
|
|
|
|
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
private static readonly Color BtnBg = new("#2A2A2E");
|
|
|
|
|
private static readonly Color BtnHover = new("#3A3A40");
|
|
|
|
|
private static readonly Color BtnPressed = new("#1A1A1E");
|
|
|
|
|
private static readonly Color BtnDisabled = new("#1E1E20");
|
|
|
|
|
private static readonly Color BtnBorder = new("#444448");
|
|
|
|
|
|
2026-04-10 14:58:03 +02:00
|
|
|
public override void _Ready()
|
|
|
|
|
{
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
AddThemeConstantOverride("separation", 8);
|
|
|
|
|
|
|
|
|
|
_playButton = CreateStyledButton("PLAY");
|
2026-04-10 14:58:03 +02:00
|
|
|
_playButton.Pressed += () => EmitSignal(SignalName.PlayPressed);
|
|
|
|
|
AddChild(_playButton);
|
|
|
|
|
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
_pauseButton = CreateStyledButton("PAUSE");
|
2026-04-10 14:58:03 +02:00
|
|
|
_pauseButton.Pressed += () => EmitSignal(SignalName.PausePressed);
|
|
|
|
|
AddChild(_pauseButton);
|
|
|
|
|
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
_stepButton = CreateStyledButton("STEP");
|
2026-04-10 14:58:03 +02:00
|
|
|
_stepButton.Pressed += () => EmitSignal(SignalName.StepPressed);
|
|
|
|
|
AddChild(_stepButton);
|
|
|
|
|
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
_stopButton = CreateStyledButton("STOP");
|
2026-04-10 14:58:03 +02:00
|
|
|
_stopButton.Pressed += () => EmitSignal(SignalName.StopPressed);
|
|
|
|
|
AddChild(_stopButton);
|
|
|
|
|
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
// Spacer
|
|
|
|
|
AddChild(new Control { CustomMinimumSize = new Vector2(12, 0) });
|
|
|
|
|
|
|
|
|
|
_speedSelect = new OptionButton { CustomMinimumSize = new Vector2(60, 30) };
|
2026-04-10 14:58:03 +02:00
|
|
|
_speedSelect.AddItem("x1", 0);
|
|
|
|
|
_speedSelect.AddItem("x2", 1);
|
|
|
|
|
_speedSelect.AddItem("x4", 2);
|
|
|
|
|
_speedSelect.ItemSelected += OnSpeedSelected;
|
|
|
|
|
AddChild(_speedSelect);
|
|
|
|
|
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
// Spacer
|
|
|
|
|
AddChild(new Control { SizeFlagsHorizontal = SizeFlags.ExpandFill });
|
|
|
|
|
|
2026-04-10 14:58:03 +02:00
|
|
|
_turnLabel = new Label { Text = "Coup: --" };
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
_turnLabel.AddThemeFontSizeOverride("font_size", 13);
|
|
|
|
|
_turnLabel.AddThemeColorOverride("font_color", new Color("#999999"));
|
2026-04-10 14:58:03 +02:00
|
|
|
AddChild(_turnLabel);
|
|
|
|
|
|
|
|
|
|
UpdateForPhase(SimPhase.Edit);
|
|
|
|
|
}
|
|
|
|
|
|
Juice pass: procedural SFX, particles, polished visuals
Sound (SfxManager.cs):
- Procedural audio synthesis via AudioStreamWav — no external files
- Distinct tones for place, produce, transfer, deliver, move, destroy, victory
- Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes
Pieces (PieceView.cs):
- Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna
- Drop shadow under each piece for depth
- 3-stop radial gradient (bright center → main → dark rim)
- Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing)
- Cargo indicator pulses gently when carrying
Trajectories (TrajectView.cs):
- Arrowhead at endpoint showing movement direction
- Antialiased lines with piece-matched colors
Cells (CellView.cs):
- Warmer palette: parchment/walnut board, deep forest production, aged gold demand
- Production flash uses warm golden glow instead of white
- Subtle inner shadow for visual depth
Animations (EventAnimator.cs):
- Production: golden particles burst from production cells
- Transfer: cargo slides with 2-particle trail + back-out whip easing
- Destruction: pieces shrink + spin + red particle explosion
- Victory: 40 confetti particles rain across the screen
- All phases trigger appropriate SFX
UI polish:
- ControlBar: styled buttons with rounded corners, disabled states
- MetricsOverlay: fade-in + scale animation, sequential metric reveals
- ObjectivePanel: animated progress bars, styled fills, green flash on completion
- Main: fade-in/out transitions between level select and gameplay
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
|
|
|
private static Button CreateStyledButton(string text)
|
|
|
|
|
{
|
|
|
|
|
var btn = new Button
|
|
|
|
|
{
|
|
|
|
|
Text = text,
|
|
|
|
|
CustomMinimumSize = new Vector2(70, 30)
|
|
|
|
|
};
|
|
|
|
|
btn.AddThemeFontSizeOverride("font_size", 11);
|
|
|
|
|
|
|
|
|
|
var normal = MakeStyle(BtnBg);
|
|
|
|
|
var hover = MakeStyle(BtnHover);
|
|
|
|
|
var pressed = MakeStyle(BtnPressed);
|
|
|
|
|
var disabled = MakeStyle(BtnDisabled);
|
|
|
|
|
disabled.BorderColor = new Color("#2A2A2E");
|
|
|
|
|
|
|
|
|
|
btn.AddThemeStyleboxOverride("normal", normal);
|
|
|
|
|
btn.AddThemeStyleboxOverride("hover", hover);
|
|
|
|
|
btn.AddThemeStyleboxOverride("pressed", pressed);
|
|
|
|
|
btn.AddThemeStyleboxOverride("disabled", disabled);
|
|
|
|
|
btn.AddThemeColorOverride("font_disabled_color", new Color("#555555"));
|
|
|
|
|
|
|
|
|
|
return btn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static StyleBoxFlat MakeStyle(Color bg)
|
|
|
|
|
{
|
|
|
|
|
return new StyleBoxFlat
|
|
|
|
|
{
|
|
|
|
|
BgColor = bg,
|
|
|
|
|
BorderColor = BtnBorder,
|
|
|
|
|
BorderWidthBottom = 1, BorderWidthTop = 1,
|
|
|
|
|
BorderWidthLeft = 1, BorderWidthRight = 1,
|
|
|
|
|
CornerRadiusTopLeft = 4, CornerRadiusTopRight = 4,
|
|
|
|
|
CornerRadiusBottomLeft = 4, CornerRadiusBottomRight = 4,
|
|
|
|
|
ContentMarginLeft = 10, ContentMarginRight = 10,
|
|
|
|
|
ContentMarginTop = 4, ContentMarginBottom = 4
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 14:58:03 +02:00
|
|
|
private void OnSpeedSelected(long index)
|
|
|
|
|
{
|
|
|
|
|
float speed = index switch
|
|
|
|
|
{
|
|
|
|
|
0 => 1.0f,
|
|
|
|
|
1 => 0.5f,
|
|
|
|
|
2 => 0.25f,
|
|
|
|
|
_ => 1.0f
|
|
|
|
|
};
|
|
|
|
|
EmitSignal(SignalName.SpeedChanged, speed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateForPhase(SimPhase phase)
|
|
|
|
|
{
|
|
|
|
|
_playButton.Disabled = phase != SimPhase.Edit && phase != SimPhase.Paused;
|
|
|
|
|
_pauseButton.Disabled = phase != SimPhase.Running;
|
|
|
|
|
_stepButton.Disabled = phase == SimPhase.Running || phase == SimPhase.Victory || phase == SimPhase.Defeat;
|
|
|
|
|
_stopButton.Disabled = phase == SimPhase.Edit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateTurn(int turn)
|
|
|
|
|
{
|
|
|
|
|
_turnLabel.Text = $"Coup: {turn}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ResetTurn()
|
|
|
|
|
{
|
|
|
|
|
_turnLabel.Text = "Coup: --";
|
|
|
|
|
}
|
|
|
|
|
}
|