Add levels 4-6 to level selector, use grid layout

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Samuel Bouchet 2026-04-10 22:39:06 +02:00
parent 672b831fc1
commit 4afe20842e

View file

@ -12,7 +12,10 @@ public partial class LevelSelectScreen : Control
[ [
("Premier Convoi", "Acheminez du bois de la scierie au depot."), ("Premier Convoi", "Acheminez du bois de la scierie au depot."),
("Deux Clients", "Fournissez deux destinations depuis une seule scierie."), ("Deux Clients", "Fournissez deux destinations depuis une seule scierie."),
("Le Col", "Franchissez le mur et gerez deux types de cargaison.") ("Le Col", "Franchissez le mur et gerez deux types de cargaison."),
("Le Carrefour", "Deux productions, deux demandes, et un carrefour au centre."),
("Le Labyrinthe", "Un couloir etroit serpente a travers les murs."),
("Trois Royaumes", "Trois productions, trois demandes. Gerez un reseau complet.")
]; ];
public override void _Ready() public override void _Ready()
@ -66,27 +69,30 @@ public partial class LevelSelectScreen : Control
// Spacer // Spacer
outerVBox.AddChild(new Control { CustomMinimumSize = new Vector2(0, 48) }); outerVBox.AddChild(new Control { CustomMinimumSize = new Vector2(0, 48) });
// --- Level cards --- // --- Level cards in a scrollable grid ---
var cardRow = new HBoxContainer(); var scroll = new ScrollContainer
cardRow.Alignment = BoxContainer.AlignmentMode.Center; {
cardRow.AddThemeConstantOverride("separation", 28); SizeFlagsVertical = SizeFlags.ExpandFill,
cardRow.SizeFlagsVertical = SizeFlags.ExpandFill; HorizontalScrollMode = ScrollContainer.ScrollMode.Disabled
cardRow.MouseFilter = MouseFilterEnum.Ignore; };
var grid = new GridContainer
{
Columns = 3,
SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
MouseFilter = MouseFilterEnum.Ignore
};
grid.AddThemeConstantOverride("h_separation", 28);
grid.AddThemeConstantOverride("v_separation", 28);
for (int i = 0; i < _levels.Length; i++) for (int i = 0; i < _levels.Length; i++)
{ {
var (name, desc) = _levels[i]; var (name, desc) = _levels[i];
cardRow.AddChild(CreateLevelCard(i, name, desc)); grid.AddChild(CreateLevelCard(i, name, desc));
} }
outerVBox.AddChild(cardRow); scroll.AddChild(grid);
outerVBox.AddChild(scroll);
// Bottom spacer
outerVBox.AddChild(new Control
{
SizeFlagsVertical = SizeFlags.ExpandFill,
CustomMinimumSize = new Vector2(0, 40)
});
margin.AddChild(outerVBox); margin.AddChild(outerVBox);
AddChild(margin); AddChild(margin);