diff --git a/assets/ASSET_REGISTRY.md b/assets/ASSET_REGISTRY.md index a742714..f93d2c2 100644 --- a/assets/ASSET_REGISTRY.md +++ b/assets/ASSET_REGISTRY.md @@ -17,3 +17,26 @@ All binary art below is an unmodified 32×32 PNG copied from the local **Dungeon | `assets/audio/dungeon_exploration.wav` | generated specifically for this project | Dungeon Crawler World project | original project asset | procedural synthesis, 2026-10-08 | | `assets/audio/dungeon_combat.wav` | generated specifically for this project | Dungeon Crawler World project | original project asset | procedural synthesis, 2026-10-08 | | `assets/audio/dungeon_danger.wav` | generated specifically for this project | Dungeon Crawler World project | original project asset | procedural synthesis, 2026-10-08 | + +## Dark fantasy UI kit — Task 1 + +Reusable UI components copied from the local prototype kit documented by the portable pack identifier `DungeonCrawlerWorld_UI_Assets/README.md`. Only transparent reusable components were imported, plus the two explicitly requested captures (`portrait_roger.png`, `illustration_equipement.png`). Import presets keep UI textures uncompressed, without mipmaps, and do not scale/recolor them with editor settings for pixel-stable UI rendering. + +| Imported path | Local source | Author / pack | License | Modification / intended use | +|---|---|---|---|---| +| `assets/ui/dark_fantasy/bouton_normal_180x48.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/bouton_normal_180x48.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; normal button state | +| `assets/ui/dark_fantasy/bouton_survol_180x48.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/bouton_survol_180x48.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; hover/focus/pressed button state | +| `assets/ui/dark_fantasy/case_inventaire_72x72.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/case_inventaire_72x72.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; inventory slot frame | +| `assets/ui/dark_fantasy/header_800x54.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/header_800x54.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; ornamental header bar | +| `assets/ui/dark_fantasy/jauge_focus_pleine.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/jauge_focus_pleine.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; full focus gauge texture for TextureProgressBar | +| `assets/ui/dark_fantasy/jauge_vie_pleine.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/jauge_vie_pleine.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; full health gauge texture for TextureProgressBar | +| `assets/ui/dark_fantasy/jauge_xp_pleine.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/jauge_xp_pleine.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; full XP gauge texture for TextureProgressBar | +| `assets/ui/dark_fantasy/panel_320x200.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/panel_320x200.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; fixed-size charcoal/gold panel | +| `assets/ui/dark_fantasy/panel_440x270.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/panel_440x270.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; fixed-size charcoal/gold panel | +| `assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/panel_64x64_nine_patch_source.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; NinePatchRect/StyleBoxTexture source, 10 px margins | +| `assets/ui/dark_fantasy/touche_clavier_vide.png` | `DungeonCrawlerWorld_UI_Assets/composants_transparents/touche_clavier_vide.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; keyboard shortcut keycap | +| `assets/ui/dark_fantasy/portrait_roger.png` | `DungeonCrawlerWorld_UI_Assets/captures/portrait_roger.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; Roger portrait TextureRect | +| `assets/ui/dark_fantasy/illustration_equipement.png` | `DungeonCrawlerWorld_UI_Assets/captures/illustration_equipement.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; equipment illustration TextureRect | +| `assets/ui/dark_fantasy/dungeon_ui_background.png` | `DungeonCrawlerWorld_UI_Assets/captures/c4dc05cf-9f60-4620-a0af-f067852ba23b.png` | DungeonCrawlerWorld prototype UI kit | project prototype asset | none; reusable HUD background capture, tracked under portable pack identifier rather than an absolute workstation path | +| `assets/ui/dark_fantasy/dark_fantasy_theme.tres` | authored in project from imported UI kit colors/textures | Dungeon Crawler World project | original project asset | Godot Theme: parchment text, gold accents, charcoal panels, ornamental textured borders, focused/hover button states, 16–22 px readable defaults | +| `assets/ui/dark_fantasy/gold_coin.svg` | authored in project | Dungeon Crawler World project | original project asset | simple original SVG; readable round gold currency icon for HUD/GoldIcon | diff --git a/assets/ui/dark_fantasy/bouton_normal_180x48.png b/assets/ui/dark_fantasy/bouton_normal_180x48.png new file mode 100644 index 0000000..be17008 Binary files /dev/null and b/assets/ui/dark_fantasy/bouton_normal_180x48.png differ diff --git a/assets/ui/dark_fantasy/bouton_normal_180x48.png.import b/assets/ui/dark_fantasy/bouton_normal_180x48.png.import new file mode 100644 index 0000000..57522c5 --- /dev/null +++ b/assets/ui/dark_fantasy/bouton_normal_180x48.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cow1oh3o0fbus" +path="res://.godot/imported/bouton_normal_180x48.png-d9711fa595a0c3013705906e1b96edfc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/bouton_normal_180x48.png" +dest_files=["res://.godot/imported/bouton_normal_180x48.png-d9711fa595a0c3013705906e1b96edfc.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/bouton_survol_180x48.png b/assets/ui/dark_fantasy/bouton_survol_180x48.png new file mode 100644 index 0000000..193c8ec Binary files /dev/null and b/assets/ui/dark_fantasy/bouton_survol_180x48.png differ diff --git a/assets/ui/dark_fantasy/bouton_survol_180x48.png.import b/assets/ui/dark_fantasy/bouton_survol_180x48.png.import new file mode 100644 index 0000000..9aecc62 --- /dev/null +++ b/assets/ui/dark_fantasy/bouton_survol_180x48.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dnlfu6bkuvwp8" +path="res://.godot/imported/bouton_survol_180x48.png-941a16c6df0968e7cf184cf2a49ee3c5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/bouton_survol_180x48.png" +dest_files=["res://.godot/imported/bouton_survol_180x48.png-941a16c6df0968e7cf184cf2a49ee3c5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/case_inventaire_72x72.png b/assets/ui/dark_fantasy/case_inventaire_72x72.png new file mode 100644 index 0000000..f24ccac Binary files /dev/null and b/assets/ui/dark_fantasy/case_inventaire_72x72.png differ diff --git a/assets/ui/dark_fantasy/case_inventaire_72x72.png.import b/assets/ui/dark_fantasy/case_inventaire_72x72.png.import new file mode 100644 index 0000000..67f97e6 --- /dev/null +++ b/assets/ui/dark_fantasy/case_inventaire_72x72.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bu7xvj53seokx" +path="res://.godot/imported/case_inventaire_72x72.png-b4d759bb61ed8ed9e36f821cdf01969d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/case_inventaire_72x72.png" +dest_files=["res://.godot/imported/case_inventaire_72x72.png-b4d759bb61ed8ed9e36f821cdf01969d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/dark_fantasy_theme.tres b/assets/ui/dark_fantasy/dark_fantasy_theme.tres new file mode 100644 index 0000000..37c210b --- /dev/null +++ b/assets/ui/dark_fantasy/dark_fantasy_theme.tres @@ -0,0 +1,118 @@ +[gd_resource type="Theme" load_steps=8 format=3] + +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png" id="1_panel64"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/bouton_normal_180x48.png" id="2_btn_normal"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/bouton_survol_180x48.png" id="3_btn_hover"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/case_inventaire_72x72.png" id="4_inventory"] + +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_panel"] +texture = ExtResource("1_panel64") +texture_margin_left = 10.0 +texture_margin_top = 10.0 +texture_margin_right = 10.0 +texture_margin_bottom = 10.0 +content_margin_left = 14.0 +content_margin_top = 12.0 +content_margin_right = 14.0 +content_margin_bottom = 12.0 +modulate_color = Color(0.95, 0.88, 0.68, 1) + +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_button_normal"] +texture = ExtResource("2_btn_normal") +texture_margin_left = 14.0 +texture_margin_top = 12.0 +texture_margin_right = 14.0 +texture_margin_bottom = 12.0 +content_margin_left = 18.0 +content_margin_top = 8.0 +content_margin_right = 18.0 +content_margin_bottom = 8.0 + +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_button_hover"] +texture = ExtResource("3_btn_hover") +texture_margin_left = 14.0 +texture_margin_top = 12.0 +texture_margin_right = 14.0 +texture_margin_bottom = 12.0 +content_margin_left = 18.0 +content_margin_top = 8.0 +content_margin_right = 18.0 +content_margin_bottom = 8.0 +modulate_color = Color(1.0, 0.88, 0.48, 1) + +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_inventory_slot"] +texture = ExtResource("4_inventory") +texture_margin_left = 8.0 +texture_margin_top = 8.0 +texture_margin_right = 8.0 +texture_margin_bottom = 8.0 +content_margin_left = 8.0 +content_margin_top = 8.0 +content_margin_right = 8.0 +content_margin_bottom = 8.0 + +[resource] +default_base_scale = 1.0 +default_font_size = 18 +Button/colors/font_color = Color(0.82, 0.72, 0.45, 1) +Button/colors/font_disabled_color = Color(0.36, 0.32, 0.25, 1) +Button/colors/font_focus_color = Color(1, 0.87, 0.42, 1) +Button/colors/font_hover_color = Color(1, 0.86, 0.36, 1) +Button/colors/font_hover_pressed_color = Color(0.95, 0.78, 0.28, 1) +Button/colors/font_outline_color = Color(0.05, 0.04, 0.03, 1) +Button/colors/font_pressed_color = Color(0.93, 0.76, 0.24, 1) +Button/constants/h_separation = 6 +Button/constants/outline_size = 2 +Button/font_sizes/font_size = 18 +Button/styles/disabled = SubResource("StyleBoxTexture_button_normal") +Button/styles/focus = SubResource("StyleBoxTexture_button_hover") +Button/styles/hover = SubResource("StyleBoxTexture_button_hover") +Button/styles/normal = SubResource("StyleBoxTexture_button_normal") +Button/styles/pressed = SubResource("StyleBoxTexture_button_hover") +CheckButton/colors/font_color = Color(0.82, 0.72, 0.45, 1) +CheckButton/colors/font_hover_color = Color(1, 0.86, 0.36, 1) +CheckButton/font_sizes/font_size = 18 +Label/colors/font_color = Color(0.86, 0.78, 0.58, 1) +Label/colors/font_outline_color = Color(0.04, 0.03, 0.025, 1) +Label/constants/line_spacing = 3 +Label/constants/outline_size = 1 +Label/font_sizes/font_size = 18 +LineEdit/colors/caret_color = Color(0.95, 0.78, 0.28, 1) +LineEdit/colors/font_color = Color(0.86, 0.78, 0.58, 1) +LineEdit/colors/font_placeholder_color = Color(0.58, 0.49, 0.34, 1) +LineEdit/font_sizes/font_size = 18 +LineEdit/styles/focus = SubResource("StyleBoxTexture_panel") +LineEdit/styles/normal = SubResource("StyleBoxTexture_panel") +MarginContainer/constants/margin_bottom = 12 +MarginContainer/constants/margin_left = 14 +MarginContainer/constants/margin_right = 14 +MarginContainer/constants/margin_top = 12 +NinePatchRect/colors/modulate_color = Color(1, 1, 1, 1) +Panel/styles/panel = SubResource("StyleBoxTexture_panel") +PanelContainer/styles/panel = SubResource("StyleBoxTexture_panel") +ProgressBar/colors/font_color = Color(0.86, 0.78, 0.58, 1) +ProgressBar/font_sizes/font_size = 16 +ProgressBar/styles/background = SubResource("StyleBoxTexture_panel") +RichTextLabel/colors/default_color = Color(0.86, 0.78, 0.58, 1) +RichTextLabel/colors/font_outline_color = Color(0.04, 0.03, 0.025, 1) +RichTextLabel/constants/line_separation = 3 +RichTextLabel/constants/outline_size = 1 +RichTextLabel/font_sizes/bold_font_size = 18 +RichTextLabel/font_sizes/bold_italics_font_size = 18 +RichTextLabel/font_sizes/italics_font_size = 18 +RichTextLabel/font_sizes/mono_font_size = 16 +RichTextLabel/font_sizes/normal_font_size = 18 +TabContainer/colors/font_selected_color = Color(1, 0.86, 0.36, 1) +TabContainer/colors/font_unselected_color = Color(0.82, 0.72, 0.45, 1) +TabContainer/font_sizes/font_size = 18 +TextureButton/styles/focus = SubResource("StyleBoxTexture_button_hover") +Tree/colors/font_color = Color(0.86, 0.78, 0.58, 1) +Tree/colors/guide_color = Color(0.45, 0.36, 0.16, 1) +Tree/colors/relationship_line_color = Color(0.45, 0.36, 0.16, 1) +Tree/font_sizes/font_size = 18 +Tree/styles/focus = SubResource("StyleBoxTexture_panel") +Tree/styles/panel = SubResource("StyleBoxTexture_panel") +VBoxContainer/constants/separation = 8 +Window/colors/title_color = Color(1, 0.86, 0.36, 1) +Window/font_sizes/title_font_size = 22 +Window/styles/embedded_border = SubResource("StyleBoxTexture_panel") diff --git a/assets/ui/dark_fantasy/dungeon_ui_background.png b/assets/ui/dark_fantasy/dungeon_ui_background.png new file mode 100644 index 0000000..2b8737a Binary files /dev/null and b/assets/ui/dark_fantasy/dungeon_ui_background.png differ diff --git a/assets/ui/dark_fantasy/gold_coin.svg b/assets/ui/dark_fantasy/gold_coin.svg new file mode 100644 index 0000000..b2ccba0 --- /dev/null +++ b/assets/ui/dark_fantasy/gold_coin.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/ui/dark_fantasy/header_800x54.png b/assets/ui/dark_fantasy/header_800x54.png new file mode 100644 index 0000000..c773157 Binary files /dev/null and b/assets/ui/dark_fantasy/header_800x54.png differ diff --git a/assets/ui/dark_fantasy/header_800x54.png.import b/assets/ui/dark_fantasy/header_800x54.png.import new file mode 100644 index 0000000..5569130 --- /dev/null +++ b/assets/ui/dark_fantasy/header_800x54.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cn1ylkt1gdri3" +path="res://.godot/imported/header_800x54.png-8168d4b03d78332ce9be36d6efc70292.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/header_800x54.png" +dest_files=["res://.godot/imported/header_800x54.png-8168d4b03d78332ce9be36d6efc70292.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/illustration_equipement.png b/assets/ui/dark_fantasy/illustration_equipement.png new file mode 100644 index 0000000..3afdc03 Binary files /dev/null and b/assets/ui/dark_fantasy/illustration_equipement.png differ diff --git a/assets/ui/dark_fantasy/illustration_equipement.png.import b/assets/ui/dark_fantasy/illustration_equipement.png.import new file mode 100644 index 0000000..cc1e843 --- /dev/null +++ b/assets/ui/dark_fantasy/illustration_equipement.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c7xpnu2ug8a87" +path="res://.godot/imported/illustration_equipement.png-17faa12e99d3eb7822899599360d7b06.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/illustration_equipement.png" +dest_files=["res://.godot/imported/illustration_equipement.png-17faa12e99d3eb7822899599360d7b06.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/jauge_focus_pleine.png b/assets/ui/dark_fantasy/jauge_focus_pleine.png new file mode 100644 index 0000000..5a437f7 Binary files /dev/null and b/assets/ui/dark_fantasy/jauge_focus_pleine.png differ diff --git a/assets/ui/dark_fantasy/jauge_focus_pleine.png.import b/assets/ui/dark_fantasy/jauge_focus_pleine.png.import new file mode 100644 index 0000000..2fdca52 --- /dev/null +++ b/assets/ui/dark_fantasy/jauge_focus_pleine.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://lihl4mwt6wbt" +path="res://.godot/imported/jauge_focus_pleine.png-64bf27c84c8e05cfa86bf7d4297e8997.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/jauge_focus_pleine.png" +dest_files=["res://.godot/imported/jauge_focus_pleine.png-64bf27c84c8e05cfa86bf7d4297e8997.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/jauge_vie_pleine.png b/assets/ui/dark_fantasy/jauge_vie_pleine.png new file mode 100644 index 0000000..fac0fde Binary files /dev/null and b/assets/ui/dark_fantasy/jauge_vie_pleine.png differ diff --git a/assets/ui/dark_fantasy/jauge_vie_pleine.png.import b/assets/ui/dark_fantasy/jauge_vie_pleine.png.import new file mode 100644 index 0000000..0581d4b --- /dev/null +++ b/assets/ui/dark_fantasy/jauge_vie_pleine.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c0t0ocoverbbr" +path="res://.godot/imported/jauge_vie_pleine.png-75bd04bf86b6c769a3e43d7f6534489d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/jauge_vie_pleine.png" +dest_files=["res://.godot/imported/jauge_vie_pleine.png-75bd04bf86b6c769a3e43d7f6534489d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/jauge_xp_pleine.png b/assets/ui/dark_fantasy/jauge_xp_pleine.png new file mode 100644 index 0000000..b902fc3 Binary files /dev/null and b/assets/ui/dark_fantasy/jauge_xp_pleine.png differ diff --git a/assets/ui/dark_fantasy/jauge_xp_pleine.png.import b/assets/ui/dark_fantasy/jauge_xp_pleine.png.import new file mode 100644 index 0000000..f7bd250 --- /dev/null +++ b/assets/ui/dark_fantasy/jauge_xp_pleine.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dn58tylg6os7w" +path="res://.godot/imported/jauge_xp_pleine.png-45d8a1b9a97caa1a7551aef5f69de77e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/jauge_xp_pleine.png" +dest_files=["res://.godot/imported/jauge_xp_pleine.png-45d8a1b9a97caa1a7551aef5f69de77e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/panel_320x200.png b/assets/ui/dark_fantasy/panel_320x200.png new file mode 100644 index 0000000..82b9fc6 Binary files /dev/null and b/assets/ui/dark_fantasy/panel_320x200.png differ diff --git a/assets/ui/dark_fantasy/panel_320x200.png.import b/assets/ui/dark_fantasy/panel_320x200.png.import new file mode 100644 index 0000000..cfded6a --- /dev/null +++ b/assets/ui/dark_fantasy/panel_320x200.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://nbehix2ncwl3" +path="res://.godot/imported/panel_320x200.png-745adcaa92ccb293fc90dc8ce6d3dbe5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/panel_320x200.png" +dest_files=["res://.godot/imported/panel_320x200.png-745adcaa92ccb293fc90dc8ce6d3dbe5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/panel_440x270.png b/assets/ui/dark_fantasy/panel_440x270.png new file mode 100644 index 0000000..11ccc64 Binary files /dev/null and b/assets/ui/dark_fantasy/panel_440x270.png differ diff --git a/assets/ui/dark_fantasy/panel_440x270.png.import b/assets/ui/dark_fantasy/panel_440x270.png.import new file mode 100644 index 0000000..33a70d0 --- /dev/null +++ b/assets/ui/dark_fantasy/panel_440x270.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://do1kj76r5rihi" +path="res://.godot/imported/panel_440x270.png-d711f8145df187c64091a8248e4dcbc1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/panel_440x270.png" +dest_files=["res://.godot/imported/panel_440x270.png-d711f8145df187c64091a8248e4dcbc1.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png b/assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png new file mode 100644 index 0000000..98f0279 Binary files /dev/null and b/assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png differ diff --git a/assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png.import b/assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png.import new file mode 100644 index 0000000..030c865 --- /dev/null +++ b/assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cf2866mb1kemu" +path="res://.godot/imported/panel_64x64_nine_patch_source.png-7ff7dcd49b8e306dc38177a411da730c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png" +dest_files=["res://.godot/imported/panel_64x64_nine_patch_source.png-7ff7dcd49b8e306dc38177a411da730c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/portrait_roger.png b/assets/ui/dark_fantasy/portrait_roger.png new file mode 100644 index 0000000..97e1990 Binary files /dev/null and b/assets/ui/dark_fantasy/portrait_roger.png differ diff --git a/assets/ui/dark_fantasy/portrait_roger.png.import b/assets/ui/dark_fantasy/portrait_roger.png.import new file mode 100644 index 0000000..d02731d --- /dev/null +++ b/assets/ui/dark_fantasy/portrait_roger.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b3t2nmqk1h6sy" +path="res://.godot/imported/portrait_roger.png-74551b7844d393bf5ec8920cc556e9c7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/portrait_roger.png" +dest_files=["res://.godot/imported/portrait_roger.png-74551b7844d393bf5ec8920cc556e9c7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/ui/dark_fantasy/touche_clavier_vide.png b/assets/ui/dark_fantasy/touche_clavier_vide.png new file mode 100644 index 0000000..6f406ee Binary files /dev/null and b/assets/ui/dark_fantasy/touche_clavier_vide.png differ diff --git a/assets/ui/dark_fantasy/touche_clavier_vide.png.import b/assets/ui/dark_fantasy/touche_clavier_vide.png.import new file mode 100644 index 0000000..875bfc7 --- /dev/null +++ b/assets/ui/dark_fantasy/touche_clavier_vide.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c6l1uyqyf1b3h" +path="res://.godot/imported/touche_clavier_vide.png-6931d919c221b025b4da175cc93a8397.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ui/dark_fantasy/touche_clavier_vide.png" +dest_files=["res://.godot/imported/touche_clavier_vide.png-6931d919c221b025b4da175cc93a8397.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index 2147165..00adf27 100644 --- a/project.godot +++ b/project.godot @@ -75,7 +75,7 @@ move_southwest={ } move_southeast={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194441,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } wait={ @@ -121,7 +121,7 @@ crafting={ } character={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":80,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } quest={ diff --git a/scenes/Game.tscn b/scenes/Game.tscn index 083adc3..e2ec479 100644 --- a/scenes/Game.tscn +++ b/scenes/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=24 format=3] +[gd_scene load_steps=26 format=3] [ext_resource type="Script" path="res://scripts/game/game.gd" id="1_game"] [ext_resource type="Script" path="res://scripts/presentation/map_renderer.gd" id="2_map"] @@ -36,43 +36,46 @@ [ext_resource type="PackedScene" path="res://scenes/ui/OptionsPanel.tscn" id="29_options"] [ext_resource type="PackedScene" path="res://scenes/ui/HelpPanel.tscn" id="30_help"] -[sub_resource type="StyleBoxFlat" id="StyleBox_hud_panel"] -bg_color = Color(0.035, 0.055, 0.09, 0.9) -border_width_left = 2 -border_width_top = 2 -border_width_right = 2 -border_width_bottom = 2 -border_color = Color(0.25, 0.48, 0.62, 0.9) -corner_radius_top_left = 6 -corner_radius_top_right = 6 -corner_radius_bottom_right = 6 -corner_radius_bottom_left = 6 -content_margin_left = 12.0 -content_margin_top = 8.0 -content_margin_right = 12.0 -content_margin_bottom = 8.0 +[ext_resource type="Theme" path="res://assets/ui/dark_fantasy/dark_fantasy_theme.tres" id="36_hud_theme"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/portrait_roger.png" id="38_hud_portrait"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png" id="37_hud_panel"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/dungeon_ui_background.png" id="38_hud_background"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/jauge_vie_pleine.png" id="40_hud_health"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/jauge_focus_pleine.png" id="41_hud_focus"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/jauge_xp_pleine.png" id="42_hud_xp"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/gold_coin.svg" id="43_hud_gold_coin"] + +[sub_resource type="StyleBoxTexture" id="StyleBox_hud_panel"] +texture = ExtResource("37_hud_panel") +texture_margin_left = 10.0 +texture_margin_top = 10.0 +texture_margin_right = 10.0 +texture_margin_bottom = 10.0 +modulate_color = Color(0.32, 0.29, 0.23, 0.88) [sub_resource type="StyleBoxFlat" id="StyleBox_xp_background"] -bg_color = Color(0.025, 0.055, 0.075, 1) +bg_color = Color(0.025, 0.02, 0.014, 1) border_width_left = 1 border_width_top = 1 border_width_right = 1 border_width_bottom = 1 -border_color = Color(0.35, 0.48, 0.62, 1) +border_color = Color(0.55, 0.40, 0.16, 1) corner_radius_top_left = 4 corner_radius_top_right = 4 corner_radius_bottom_right = 4 corner_radius_bottom_left = 4 [sub_resource type="StyleBoxFlat" id="StyleBox_xp_fill"] -bg_color = Color(0.35, 0.72, 1, 1) +bg_color = Color(0.78, 0.58, 0.2, 1) corner_radius_top_left = 3 corner_radius_top_right = 3 corner_radius_bottom_right = 3 corner_radius_bottom_left = 3 +[sub_resource type="StyleBoxEmpty" id="StyleBox_legacy_transparent"] + [sub_resource type="StyleBoxFlat" id="StyleBox_prompt_panel"] -bg_color = Color(0.08, 0.12, 0.16, 0.94) +bg_color = Color(0.10, 0.075, 0.042, 0.98) border_width_left = 2 border_width_top = 2 border_width_right = 2 @@ -83,6 +86,60 @@ corner_radius_top_right = 6 corner_radius_bottom_right = 6 corner_radius_bottom_left = 6 + +[sub_resource type="StyleBoxFlat" id="StyleBox_opaque_outside_artboard"] +bg_color = Color(0.012, 0.018, 0.028, 1) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.19, 0.15, 0.09, 1) + +[sub_resource type="StyleBoxTexture" id="StyleBox_play_area_mask"] +texture = ExtResource("38_hud_background") +modulate_color = Color(0.55, 0.55, 0.55, 1) + +[sub_resource type="StyleBoxTexture" id="StyleBox_section"] +texture = ExtResource("37_hud_panel") +texture_margin_left = 10.0 +texture_margin_top = 10.0 +texture_margin_right = 10.0 +texture_margin_bottom = 10.0 +modulate_color = Color(0.27, 0.24, 0.19, 0.9) + +[sub_resource type="StyleBoxFlat" id="StyleBox_play_frame"] +bg_color = Color(0.008, 0.012, 0.018, 0.0) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(0.67, 0.48, 0.19, 0.95) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 + +[sub_resource type="StyleBoxTexture" id="StyleBox_health_fill"] +texture = ExtResource("40_hud_health") +texture_margin_left = 4.0 +texture_margin_top = 4.0 +texture_margin_right = 4.0 +texture_margin_bottom = 4.0 + +[sub_resource type="StyleBoxTexture" id="StyleBox_focus_fill"] +texture = ExtResource("41_hud_focus") +texture_margin_left = 4.0 +texture_margin_top = 4.0 +texture_margin_right = 4.0 +texture_margin_bottom = 4.0 + +[sub_resource type="StyleBoxTexture" id="StyleBox_xp_fill_dark_fantasy"] +texture = ExtResource("42_hud_xp") +texture_margin_left = 4.0 +texture_margin_top = 4.0 +texture_margin_right = 4.0 +texture_margin_bottom = 4.0 + [node name="Game" type="Node2D"] script = ExtResource("1_game") @@ -175,142 +232,321 @@ script = ExtResource("4_hud") [node name="HelpPanel" parent="HUD" instance=ExtResource("30_help")] [node name="AchievementToast" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -360.0 -offset_top = 18.0 -offset_right = 360.0 -offset_bottom = 48.0 -grow_horizontal = 2 +layout_mode = 0 theme_override_colors/font_color = Color(1, 0.82, 0.42, 1) theme_override_font_sizes/font_size = 18 horizontal_alignment = 1 +vertical_alignment = 1 +visible = false [node name="TitleLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -360.0 -offset_top = 48.0 -offset_right = 360.0 -offset_bottom = 74.0 -grow_horizontal = 2 -theme_override_colors/font_color = Color(0.75, 0.94, 0.55, 1) +layout_mode = 0 +theme_override_colors/font_color = Color(0.95, 0.79, 0.36, 1) +theme_override_font_sizes/font_size = 22 +horizontal_alignment = 1 +vertical_alignment = 1 +text = "Étage 0" + +[node name="TitleNotificationLabel" type="Label" parent="HUD"] +layout_mode = 0 +visible = false +theme_override_colors/font_color = Color(1, 0.88, 0.52, 1) +theme_override_colors/font_outline_color = Color(0.06, 0.035, 0.015, 1) +theme_override_constants/outline_size = 3 +theme_override_font_sizes/font_size = 20 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="TitleNotificationTimer" type="Timer" parent="HUD"] +wait_time = 5.0 +one_shot = true + +[node name="AchievementToastTimer" type="Timer" parent="HUD"] +wait_time = 5.0 +one_shot = true + +[node name="HeaderValuesLabel" type="Label" parent="HUD" groups=["hud_header_values"]] +layout_mode = 0 +theme_override_colors/font_color = Color(0.86, 0.78, 0.58, 1) theme_override_font_sizes/font_size = 16 horizontal_alignment = 1 +vertical_alignment = 1 +text = "" +visible = false [node name="ResponsiveLayout" type="Control" parent="HUD"] layout_mode = 3 +z_index = -1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 +theme = ExtResource("36_hud_theme") + +[node name="DarkBackdrop" type="Control" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 + +[node name="Artboard" type="Control" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 + +[node name="LetterboxTop" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_opaque_outside_artboard") + +[node name="LetterboxBottom" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_opaque_outside_artboard") + +[node name="PillarboxLeft" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_opaque_outside_artboard") + +[node name="PillarboxRight" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_opaque_outside_artboard") + +[node name="PlayAreaMaskTop" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_play_area_mask") + +[node name="PlayAreaMaskLeft" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_play_area_mask") + +[node name="PlayAreaMaskRight" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_play_area_mask") + +[node name="PlayAreaMaskBottom" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_play_area_mask") + +[node name="TopBar" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_hud_panel") + +[node name="LeftRail" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_hud_panel") + +[node name="CharacterSection" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_section") + +[node name="ObjectivesSection" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_section") + +[node name="StatusSection" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_section") + +[node name="CharacterSectionTitle" type="Label" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.96, 0.84, 0.48, 1) +theme_override_colors/font_outline_color = Color(0.06, 0.035, 0.015, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.85) +theme_override_constants/outline_size = 3 +theme_override_constants/shadow_offset_x = 1 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 22 +text = "PERSONNAGE" +vertical_alignment = 1 + +[node name="ObjectivesSectionTitle" type="Label" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.96, 0.9, 0.7, 1) +theme_override_colors/font_outline_color = Color(0.06, 0.035, 0.015, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.85) +theme_override_constants/outline_size = 2 +theme_override_constants/shadow_offset_x = 1 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 16 +text = "OBJECTIFS" +vertical_alignment = 1 + +[node name="StatusSectionTitle" type="Label" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.96, 0.9, 0.7, 1) +theme_override_colors/font_outline_color = Color(0.06, 0.035, 0.015, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.85) +theme_override_constants/outline_size = 2 +theme_override_constants/shadow_offset_x = 1 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 16 +text = "ÉTAT" +vertical_alignment = 1 + +[node name="PlayAreaFrame" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +show_behind_parent = true +theme_override_styles/panel = SubResource("StyleBox_play_frame") + +[node name="RightRail" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_hud_panel") + +[node name="JournalSection" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_section") + +[node name="MapSection" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_section") + +[node name="JournalSectionTitle" type="Label" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.96, 0.84, 0.48, 1) +theme_override_colors/font_outline_color = Color(0.06, 0.035, 0.015, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.85) +theme_override_constants/outline_size = 3 +theme_override_constants/shadow_offset_x = 1 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 22 +text = "JOURNAL" +vertical_alignment = 1 + +[node name="MapSectionTitle" type="Label" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.96, 0.9, 0.7, 1) +theme_override_colors/font_outline_color = Color(0.06, 0.035, 0.015, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.85) +theme_override_constants/outline_size = 2 +theme_override_constants/shadow_offset_x = 1 +theme_override_constants/shadow_offset_y = 2 +theme_override_font_sizes/font_size = 16 +text = "CARTE" +vertical_alignment = 1 + +[node name="CommandBar" type="Panel" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_hud_panel") [node name="StatsPanel" type="PanelContainer" parent="HUD/ResponsiveLayout"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 12.0 -offset_top = 12.0 -offset_right = 298.0 -offset_bottom = 250.0 -grow_horizontal = 0 -grow_vertical = 0 -theme_override_styles/panel = SubResource("StyleBox_hud_panel") +layout_mode = 0 +mouse_filter = 2 +show_behind_parent = true +theme_override_styles/panel = SubResource("StyleBox_legacy_transparent") [node name="LogPanel" type="PanelContainer" parent="HUD/ResponsiveLayout"] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -256.0 -offset_top = 12.0 -offset_right = -12.0 -offset_bottom = 170.0 -grow_horizontal = 0 -grow_vertical = 0 -theme_override_styles/panel = SubResource("StyleBox_hud_panel") +layout_mode = 0 +mouse_filter = 2 +show_behind_parent = true +theme_override_styles/panel = SubResource("StyleBox_legacy_transparent") [node name="PromptPanel" type="PanelContainer" parent="HUD/ResponsiveLayout"] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -280.0 -offset_top = -90.0 -offset_right = 280.0 -offset_bottom = -52.0 -grow_horizontal = 2 -grow_vertical = 0 -theme_override_styles/panel = SubResource("StyleBox_prompt_panel") +layout_mode = 0 +mouse_filter = 2 [node name="HelpPanel" type="PanelContainer" parent="HUD/ResponsiveLayout"] -layout_mode = 1 -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 12.0 -offset_top = -42.0 -offset_right = -12.0 -offset_bottom = -12.0 -grow_horizontal = 2 -grow_vertical = 0 -theme_override_styles/panel = SubResource("StyleBox_hud_panel") +layout_mode = 0 +mouse_filter = 2 -[node name="PlayerHealthLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 26.0 -offset_right = 286.0 -offset_bottom = 46.0 -grow_horizontal = 0 -grow_vertical = 0 -theme_override_colors/font_color = Color(1, 1, 1, 1) +[node name="QuickSlotStrip" type="PanelContainer" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 + +[node name="QuickSlotHint" type="Label" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.86, 0.78, 0.58, 1) +theme_override_font_sizes/font_size = 16 +text = "1 Arme • 2 Sort • 3 Soin • I Sac" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="PortraitIllustration" type="TextureRect" parent="HUD/ResponsiveLayout"] +layout_mode = 0 +mouse_filter = 2 +texture = ExtResource("38_hud_portrait") +expand_mode = 1 +stretch_mode = 5 + +[node name="CharacterNameLabel" type="Label" parent="HUD/ResponsiveLayout" groups=["hud_character_values"]] +layout_mode = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.96, 0.84, 0.48, 1) +theme_override_font_sizes/font_size = 21 +text = "" +visible = false +vertical_alignment = 1 + +[node name="CharacterLevelLabel" type="Label" parent="HUD/ResponsiveLayout" groups=["hud_character_values"]] +layout_mode = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.8, 0.76, 0.62, 1) +theme_override_font_sizes/font_size = 16 +text = "Niveau 1" +vertical_alignment = 1 + +[node name="PlayerHealthLabel" type="Label" parent="HUD" groups=["hud_character_values"]] +layout_mode = 0 +theme_override_colors/font_color = Color(1, 0.78, 0.68, 1) theme_override_font_sizes/font_size = 18 +text = "PV du joueur : 12/12" +vertical_alignment = 1 -[node name="PlayerFocusLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 47.0 -offset_right = 286.0 -offset_bottom = 73.0 -grow_horizontal = 0 -grow_vertical = 0 +[node name="HealthBar" type="ProgressBar" parent="HUD"] +layout_mode = 0 +mouse_filter = 2 +max_value = 12.0 +value = 12.0 +show_percentage = false +theme_override_styles/background = SubResource("StyleBox_xp_background") +theme_override_styles/fill = SubResource("StyleBox_health_fill") + +[node name="PlayerFocusLabel" type="Label" parent="HUD" groups=["hud_character_values"]] +layout_mode = 0 theme_override_colors/font_color = Color(0.7, 0.8, 1, 1) theme_override_font_sizes/font_size = 18 +text = "Focus : 3/3" +vertical_alignment = 1 + +[node name="FocusBar" type="ProgressBar" parent="HUD"] +layout_mode = 0 +mouse_filter = 2 +max_value = 3.0 +value = 3.0 +show_percentage = false +theme_override_styles/background = SubResource("StyleBox_xp_background") +theme_override_styles/fill = SubResource("StyleBox_focus_fill") [node name="ExperienceBar" type="ProgressBar" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 74.0 -offset_right = 286.0 -offset_bottom = 94.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 mouse_filter = 2 theme_override_styles/background = SubResource("StyleBox_xp_background") -theme_override_styles/fill = SubResource("StyleBox_xp_fill") +theme_override_styles/fill = SubResource("StyleBox_xp_fill_dark_fantasy") show_percentage = false [node name="ExperienceLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 30.0 -offset_top = 74.0 -offset_right = 282.0 -offset_bottom = 94.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 mouse_filter = 2 theme_override_colors/font_color = Color(0.92, 0.97, 1, 1) theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9) @@ -321,130 +557,100 @@ text = "Niveau 1 — XP 0/100" horizontal_alignment = 1 vertical_alignment = 1 +[node name="CharacterStatusLabel" type="Label" parent="HUD" groups=["hud_character_values"]] +layout_mode = 0 +theme_override_colors/font_color = Color(0.75, 0.9, 0.72, 1) +theme_override_font_sizes/font_size = 15 +text = "" +visible = false +autowrap_mode = 2 +vertical_alignment = 1 + +[node name="GoldIcon" type="TextureRect" parent="HUD"] +layout_mode = 0 +mouse_filter = 2 +texture = ExtResource("43_hud_gold_coin") +expand_mode = 1 +stretch_mode = 5 + [node name="GoldLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 96.0 -offset_right = 286.0 -offset_bottom = 122.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 theme_override_colors/font_color = Color(1, 0.84, 0.35, 1) theme_override_font_sizes/font_size = 18 -text = "Or: 0" +text = "0" +vertical_alignment = 1 [node name="QuestTrackerLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 123.0 -offset_right = 286.0 -offset_bottom = 143.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 theme_override_colors/font_color = Color(0.65, 1, 0.72, 1) theme_override_font_sizes/font_size = 14 text = "Quêtes : aucune" +autowrap_mode = 2 +vertical_alignment = 1 [node name="SpellLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 144.0 -offset_right = 286.0 -offset_bottom = 164.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 +text = "" +visible = false theme_override_colors/font_color = Color(0.82, 0.7, 1, 1) theme_override_font_sizes/font_size = 14 +vertical_alignment = 1 [node name="EnemyHealthLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 165.0 -offset_right = 286.0 -offset_bottom = 191.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 +text = "" +visible = false theme_override_colors/font_color = Color(1, 0.8, 0.7, 1) -theme_override_font_sizes/font_size = 18 +theme_override_font_sizes/font_size = 16 +vertical_alignment = 1 [node name="CombatSummaryLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 192.0 -offset_right = 286.0 -offset_bottom = 215.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 +text = "" +visible = false theme_override_colors/font_color = Color(1, 0.9, 0.5, 1) -theme_override_font_sizes/font_size = 16 +theme_override_font_sizes/font_size = 15 +autowrap_mode = 2 +vertical_alignment = 1 [node name="DeadlineLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 0 -offset_left = 26.0 -offset_top = 216.0 -offset_right = 286.0 -offset_bottom = 246.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 +text = "" +visible = false theme_override_colors/font_color = Color(1, 0.76, 0.4, 1) theme_override_font_sizes/font_size = 14 autowrap_mode = 2 -clip_text = true +vertical_alignment = 1 [node name="EventLog" type="RichTextLabel" parent="HUD"] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -244.0 -offset_top = 22.0 -offset_right = -24.0 -offset_bottom = 158.0 -grow_horizontal = 0 -grow_vertical = 0 +layout_mode = 0 +mouse_filter = 2 bbcode_enabled = false fit_content = false theme_override_colors/default_color = Color(1, 1, 0.8, 1) theme_override_font_sizes/normal_font_size = 14 -[node name="ContextPromptLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -266.0 -offset_top = -85.0 -offset_right = 266.0 -offset_bottom = -57.0 -grow_horizontal = 2 -grow_vertical = 0 +[node name="ActionHintLabel" type="Label" parent="HUD/ResponsiveLayout/PromptPanel" groups=["hud_command_hints"]] +layout_mode = 0 +mouse_filter = 2 theme_override_colors/font_color = Color(1, 0.92, 0.63, 1) theme_override_font_sizes/font_size = 16 +text = "F : Distance • X : Magie • K : Familier" +horizontal_alignment = 1 +vertical_alignment = 0 + +[node name="ContextPromptLabel" type="Label" parent="HUD" groups=["hud_command_hints"]] +layout_mode = 0 +theme_override_colors/font_color = Color(0.82, 0.9, 1, 1) +theme_override_font_sizes/font_size = 13 horizontal_alignment = 1 vertical_alignment = 1 -[node name="HelpLabel" type="Label" parent="HUD"] -layout_mode = 1 -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 28.0 -offset_top = -37.0 -offset_right = -28.0 -offset_bottom = -17.0 -grow_horizontal = 2 -grow_vertical = 0 +[node name="HelpLabel" type="Label" parent="HUD" groups=["hud_command_hints"]] +layout_mode = 0 theme_override_colors/font_color = Color(0.82, 0.9, 1, 1) theme_override_font_sizes/font_size = 14 -text = "Déplacer : ZQSD / Flèches (nord-est : pavé num. 9) • Interagir : Espace ou E • Distance : F • Familier : K • Sauvegarder : V / Ctrl+S • Aide : F1" +text = "Déplacer ZQSD • Interagir Espace • Inventaire I • Sauvegarde V • Aide F1" +clip_text = false horizontal_alignment = 1 vertical_alignment = 1 diff --git a/scenes/ui/CharacterPanel.tscn b/scenes/ui/CharacterPanel.tscn index fdd05f8..6cfc960 100644 --- a/scenes/ui/CharacterPanel.tscn +++ b/scenes/ui/CharacterPanel.tscn @@ -1,18 +1,15 @@ -[gd_scene load_steps=3 format=3] +[gd_scene load_steps=4 format=3] [ext_resource type="Script" path="res://scripts/presentation/character_panel.gd" id="1_character"] +[ext_resource type="Texture2D" path="res://assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png" id="2_panel"] -[sub_resource type="StyleBoxFlat" id="StyleBox_character_panel"] -bg_color = Color(0.035, 0.055, 0.09, 0.97) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 3 -border_color = Color(0.66, 0.82, 0.42, 0.95) -corner_radius_top_left = 8 -corner_radius_top_right = 8 -corner_radius_bottom_right = 8 -corner_radius_bottom_left = 8 +[sub_resource type="StyleBoxTexture" id="StyleBox_character_panel"] +texture = ExtResource("2_panel") +texture_margin_left = 10.0 +texture_margin_top = 10.0 +texture_margin_right = 10.0 +texture_margin_bottom = 10.0 +modulate_color = Color(0.22, 0.2, 0.16, 0.98) [node name="CharacterPanel" type="PanelContainer"] visible = false @@ -22,10 +19,10 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -220.0 -offset_top = -170.0 -offset_right = 220.0 -offset_bottom = 170.0 +offset_left = -360.0 +offset_top = -320.0 +offset_right = 360.0 +offset_bottom = 320.0 grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBox_character_panel") @@ -36,13 +33,15 @@ layout_mode = 1 anchors_preset = 10 anchor_left = 0.5 anchor_right = 0.5 -offset_left = -185.0 -offset_top = 18.0 -offset_right = 185.0 -offset_bottom = 46.0 +offset_left = -310.0 +offset_top = 22.0 +offset_right = 310.0 +offset_bottom = 54.0 grow_horizontal = 2 -theme_override_colors/font_color = Color(0.75, 0.94, 0.55, 1) -theme_override_font_sizes/font_size = 21 +theme_override_colors/font_color = Color(1, 0.88, 0.52, 1) +theme_override_colors/font_outline_color = Color(0.08, 0.045, 0.015, 1) +theme_override_constants/outline_size = 3 +theme_override_font_sizes/font_size = 24 horizontal_alignment = 1 [node name="Body" type="RichTextLabel" parent="."] @@ -50,11 +49,11 @@ layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = 30.0 -offset_top = 62.0 -offset_right = -30.0 -offset_bottom = -24.0 +offset_left = 42.0 +offset_top = 76.0 +offset_right = -42.0 +offset_bottom = -30.0 grow_horizontal = 2 grow_vertical = 2 -theme_override_colors/default_color = Color(0.92, 0.95, 1, 1) -theme_override_font_sizes/normal_font_size = 17 +theme_override_colors/default_color = Color(0.95, 0.93, 0.8, 1) +theme_override_font_sizes/normal_font_size = 18 diff --git a/scenes/ui/Minimap.tscn b/scenes/ui/Minimap.tscn index c07b3f4..d533504 100644 --- a/scenes/ui/Minimap.tscn +++ b/scenes/ui/Minimap.tscn @@ -3,27 +3,23 @@ [ext_resource type="Script" path="res://scripts/presentation/minimap.gd" id="1_minimap"] [sub_resource type="StyleBoxFlat" id="StyleBox_minimap"] -bg_color = Color(0.025, 0.045, 0.085, 0.94) -border_width_left = 2 -border_width_top = 2 -border_width_right = 2 -border_width_bottom = 2 -border_color = Color(0.45, 0.75, 0.9, 0.9) -corner_radius_top_left = 6 -corner_radius_top_right = 6 -corner_radius_bottom_right = 6 -corner_radius_bottom_left = 6 +bg_color = Color(0.045, 0.035, 0.025, 0.96) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(0.67, 0.48, 0.19, 0.95) +corner_radius_top_left = 8 +corner_radius_top_right = 8 +corner_radius_bottom_right = 8 +corner_radius_bottom_left = 8 +shadow_color = Color(0, 0, 0, 0.55) +shadow_size = 5 [node name="Minimap" type="Control"] layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -188.0 -offset_top = 184.0 -offset_right = -20.0 -offset_bottom = 352.0 -grow_horizontal = 0 +offset_right = 280.0 +offset_bottom = 300.0 mouse_filter = 2 script = ExtResource("1_minimap") @@ -43,13 +39,28 @@ layout_mode = 1 anchors_preset = 10 anchor_left = 0.5 anchor_right = 0.5 -offset_left = -70.0 -offset_top = 4.0 -offset_right = 70.0 -offset_bottom = 20.0 +offset_left = -120.0 +offset_top = 7.0 +offset_right = 120.0 +offset_bottom = 29.0 grow_horizontal = 2 -theme_override_colors/font_color = Color(0.78, 0.94, 1, 1) -theme_override_font_sizes/font_size = 12 -text = "CARTE — Tab" +theme_override_colors/font_color = Color(0.86, 0.78, 0.58, 1) +theme_override_font_sizes/font_size = 13 +text = "CARTE — TAB" horizontal_alignment = 1 +vertical_alignment = 1 mouse_filter = 2 + +[node name="MapRegion" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 14.0 +offset_top = 40.0 +offset_right = -14.0 +offset_bottom = -14.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +clip_contents = true diff --git a/scripts/check-visual-capture.py b/scripts/check-visual-capture.py index f3815db..1b0e6f2 100755 --- a/scripts/check-visual-capture.py +++ b/scripts/check-visual-capture.py @@ -13,11 +13,16 @@ import sys import zlib from pathlib import Path -WIDTH = 1920 -HEIGHT = 1080 -# Central dungeon measurement region, proportionally equivalent to the former -# 16:9 reference crop while excluding the anchored HUD panels. -VIEWPORT = (384, 60, 1536, 1017) +REFERENCE_WIDTH = 1920 +REFERENCE_HEIGHT = 1080 +EXPECTED_DIMENSIONS = { + "visual-check.png": (REFERENCE_WIDTH, REFERENCE_HEIGHT), + "visual-check-exit.png": (REFERENCE_WIDTH, REFERENCE_HEIGHT), + "visual-check-compact.png": (1280, 720), +} +# The unmasked PlayAreaFrame in the reference 1920×1080 artboard. +# This is scaled for the real 720p capture. +PLAY_AREA_REFERENCE = (498, 125, 1422, 955) UNKNOWN = (1, 2, 5) # Captured explored tiles are texture modulated, so classify their blue-black # pixels by palette range rather than expecting one flat overlay color. @@ -70,8 +75,14 @@ def read_png(path: Path) -> tuple[int, int, list[bytes]]: if header is None or not saw_iend or offset != len(data): fail("incomplete PNG") width, height, depth, color_type, compression, filtering, interlace = header - if (width, height) != (WIDTH, HEIGHT): - fail(f"expected {WIDTH}x{HEIGHT} PNG, got {width}x{height}") + expected_dimensions = EXPECTED_DIMENSIONS.get(path.name) + if expected_dimensions is None: + fail(f"unsupported visual capture name: {path.name}") + if (width, height) != expected_dimensions: + fail( + f"expected {expected_dimensions[0]}x{expected_dimensions[1]} PNG, " + f"got {width}x{height}" + ) if depth != 8 or color_type not in (2, 6): fail("visual capture must be an 8-bit RGB or RGBA PNG") if (compression, filtering, interlace) != (0, 0, 0): @@ -154,18 +165,28 @@ def is_visible(pixel: tuple[int, int, int]) -> bool: def is_explored(pixel: tuple[int, int, int]) -> bool: - # Tile texture remains visible under a blue-black fog overlay. This is the - # dominant fog-modulated floor texel; keeping the detector exact avoids HUD - # colors and visible terrain satisfying it. - return pixel == (19, 29, 39) + # Texture-preserving explored terrain is rendered under a blue-black fog + # overlay. GPU blend rounding and the authored floor texture produce a + # palette rather than one portable exact RGB value; accept only its dark, + # blue-shifted range so HUD chrome and visible brown terrain cannot match. + red, green, blue = pixel + return 4 <= red <= 14 and 7 <= green <= 22 and 16 <= blue <= 32 and blue >= green + 4 and green >= red + 3 + + +def viewport_for(width: int, height: int) -> tuple[int, int, int, int]: + scale_x = width / REFERENCE_WIDTH + scale_y = height / REFERENCE_HEIGHT + return tuple(round(coordinate * (scale_x if index % 2 == 0 else scale_y)) for index, coordinate in enumerate(PLAY_AREA_REFERENCE)) def measure(path: Path) -> None: + width, height = EXPECTED_DIMENSIONS[path.name] observed = list(pixels(path)) + viewport = viewport_for(width, height) dungeon_pixels = [ - observed[y * WIDTH + x] - for y in range(VIEWPORT[1], VIEWPORT[3]) - for x in range(VIEWPORT[0], VIEWPORT[2]) + observed[y * width + x] + for y in range(viewport[1], viewport[3]) + for x in range(viewport[0], viewport[2]) ] non_black = sum(pixel != (0, 0, 0) for pixel in dungeon_pixels) unknown_pixels = [pixel for pixel in dungeon_pixels if pixel == UNKNOWN] diff --git a/scripts/game/game.gd b/scripts/game/game.gd index 8375593..46dce62 100644 --- a/scripts/game/game.gd +++ b/scripts/game/game.gd @@ -92,7 +92,9 @@ const QuestStateType = preload("res://scripts/domain/narrative/quest_state.gd") @onready var options_panel: OptionsPanel = $HUD/OptionsPanel @onready var help_panel: HelpPanel = $HUD/HelpPanel @onready var achievement_toast: Label = $HUD/AchievementToast -@onready var title_label: Label = $HUD/TitleLabel +@onready var achievement_toast_timer: Timer = $HUD/AchievementToastTimer +@onready var title_notification_label: Label = $HUD/TitleNotificationLabel +@onready var title_notification_timer: Timer = $HUD/TitleNotificationTimer @onready var companion_view: ActorView = $World/Companion @onready var party_views: Node2D = $World/Party const FACTION_WAR_MIN_FLOOR := 9 @@ -132,6 +134,7 @@ var active_dialogue_npc: Dictionary = {} var active_event_index := -1 var _turn_start_player_hit_points := -1 var _turn_start_companion_hit_points := -1 +var _title_notifications_enabled := false func configure_new_run(settings: RunSettings, player_name: String) -> void: pending_run_settings = settings @@ -158,6 +161,9 @@ func _ready() -> void: race_class_choice_panel.race_confirmed.connect(_choose_floor_three_race) race_class_choice_panel.class_confirmed.connect(_choose_floor_three_class) death_panel.navigation_requested.connect(func(action: StringName) -> void: death_navigation_requested.emit(action)) + title_notification_timer.timeout.connect(_hide_title_notification) + achievement_toast_timer.timeout.connect(_hide_achievement_toast) + _title_notifications_enabled = true map_renderer.set_map(game_state.map) _sync_map_renderer_visibility() _sync_minimap() @@ -302,6 +308,8 @@ func _get_capture_mode() -> String: var arguments := OS.get_cmdline_user_args() if "--capture-exit" in arguments: return "exit" + if "--visual-check-compact" in arguments: + return "compact" if "--capture" in arguments: return "initial" return "" @@ -309,16 +317,29 @@ func _get_capture_mode() -> String: func _capture_visual_check(capture_mode: String) -> void: if capture_mode == "exit": _prepare_exit_capture_state() + _refresh_capture_hud() + # Camera2D applies its scroll during the frame cycle. Force it before the + # deterministic capture so the world is framed around the capture state. + camera.force_update_scroll() await get_tree().process_frame await get_tree().process_frame await RenderingServer.frame_post_draw - var filename := "visual-check-exit.png" if capture_mode == "exit" else "visual-check.png" + var filename := "visual-check.png" + if capture_mode == "exit": + filename = "visual-check-exit.png" + elif capture_mode == "compact": + filename = "visual-check-compact.png" var capture_path := ProjectSettings.globalize_path("res://artifacts/" + filename) DirAccess.make_dir_recursive_absolute(capture_path.get_base_dir()) var image := get_viewport().get_texture().get_image() var result := image.save_png(capture_path) get_tree().quit(0 if result == OK else 1) +func _refresh_capture_hud() -> void: + # Capture startup appends game_started after the normal first HUD refresh. + # Refresh only on the capture path so production rendering remains untouched. + hud.refresh(game_state, run_state.recent_events(run_state.log.size()), run_state) + func _prepare_exit_capture_state() -> void: # Preserve the entrance exploration, then frame the authored surface exit. # This exercises visible, explored, and unknown rendering without depending @@ -326,9 +347,15 @@ func _prepare_exit_capture_state() -> void: game_state.map.set_cell(Vector2i(36, 7), GridMapStateType.CellKind.FLOOR) game_state.player.cell = game_state.floor_state.exit game_state.update_exploration() + # Keep a nearby floor tile as remembered terrain. The entrance is outside + # the exit camera crop, so it cannot prove the explored-fog render contract. + var remembered_cell := game_state.floor_state.exit + Vector2i(-2, 0) + game_state.explored_cells[remembered_cell] = true + game_state.visible_cells.erase(remembered_cell) _sync_map_renderer_visibility() _sync_minimap() player_view.refresh() + _configure_camera() _sync_camera_to_player() func _input(event: InputEvent) -> void: @@ -995,7 +1022,7 @@ func _toggle_character_panel() -> Array[GameEvent]: _close_character_panel(false) return _record_ranged_event(&"character_panel_closed", &"", {}, "Character panel closed.") _sync_dialogue_player_progression() - character_panel.present(dialogue_player, game_state.player.progression) + character_panel.present(dialogue_player, game_state.player.progression, run_state.player_name, _current_title()) return _record_ranged_event(&"character_panel_opened", &"", {"level": game_state.player.progression.level}, "Character panel opened.") func _spend_character_attribute(key: StringName) -> void: @@ -1259,9 +1286,9 @@ func _record_narrative_event(kind: StringName, event_id: StringName, payload: Di func _process_ground_pickup() -> Array[TurnResult]: var pickup := run_state.inventory.pick_up_ground_item(game_state.floor_state, game_state.player.cell) - var item: ItemInstance = pickup.item + var item: ItemInstance = pickup.get("item", null) var result: TurnResult - if bool(pickup.accepted): + if bool(pickup.get("accepted", false)) and item != null: result = TurnResult.new( game_state.player.id, &"item_picked_up", @@ -1270,9 +1297,14 @@ func _process_ground_pickup() -> Array[TurnResult]: &"", 0, "Picked up %s x%d." % [item.definition.name, item.quantity], - {"item_id": item.definition.id, "instance_id": item.instance_id, "quantity": item.quantity, "stack_merged_into": pickup.stack_merged_into} + {"item_id": item.definition.id, "instance_id": item.instance_id, "quantity": item.quantity, "stack_merged_into": pickup.get("stack_merged_into", &"")} ) else: + var reason := StringName(pickup.get("reason", &"no_ground_item")) + var payload := {"reason": reason} + if item != null: + payload.merge({"item_id": item.definition.id, "instance_id": item.instance_id, "quantity": item.quantity}, true) + var message := "Rien à ramasser." if reason == &"no_ground_item" else "Inventaire plein." if reason == &"capacity" else "Ramassage impossible." result = TurnResult.new( game_state.player.id, &"pickup_refused", @@ -1280,8 +1312,8 @@ func _process_ground_pickup() -> Array[TurnResult]: game_state.player.cell, &"", 0, - "Inventory is full.", - {"reason": pickup.reason} + message, + payload ) _resolve_player_action([result], false) return [result] @@ -1792,6 +1824,8 @@ func _observe_achievements(events: Array[GameEvent]) -> void: var achievement_id := StringName(definition.get("id", "")) var message := "Succès débloqué : %s" % String(definition.get("name", achievement_id)) achievement_toast.text = message + achievement_toast.visible = true + achievement_toast_timer.start() run_state.log.insert(insertion_index, GameEventType.new( event.turn, event.floor, @@ -1861,13 +1895,31 @@ func _current_title() -> Dictionary: return title_engine.refresh(_title_context()) if title_engine != null else {} func _refresh_title() -> void: - var title := _current_title() - if title.is_empty(): - run_state.current_title_id = &"" - title_label.text = "" + if run_state == null: return - run_state.current_title_id = StringName(title.get("id", "")) - title_label.text = "Titre : %s" % String(title.get("name", title.get("id", ""))) + var title := _current_title() + var previous_title_id := run_state.current_title_id + var current_title_id := StringName(title.get("id", "")) + run_state.current_title_id = current_title_id + if title.is_empty(): + # A title loss is not an announcement; it must also clear a still-visible + # notification from the prior title. + _hide_title_notification() + return + # Boot and load establish the state silently. Only a real later transition + # deserves the temporary overlay; the permanent top bar belongs to GameHud. + if _title_notifications_enabled and current_title_id != previous_title_id: + title_notification_label.text = String(title.get("name", current_title_id)) + title_notification_label.visible = true + title_notification_timer.start() + +func _hide_title_notification() -> void: + title_notification_label.visible = false + title_notification_label.text = "" + +func _hide_achievement_toast() -> void: + achievement_toast.visible = false + achievement_toast.text = "" func _append_level_up_events(events: Array[GameEvent]) -> void: var levels_gained := 0 @@ -1980,10 +2032,18 @@ func _create_initial_state() -> GameState: func _configure_camera() -> void: var map_size := game_state.map.size * TILE_SIZE - camera.limit_left = $World.position.x - camera.limit_top = $World.position.y - camera.limit_right = $World.position.x + map_size.x - camera.limit_bottom = $World.position.y + map_size.y + # Camera2D clamps against its full engine viewport, while opaque HUD masks + # expose only PlayAreaFrame. Extend each map edge by the difference between + # those half-extents so actors at a map edge remain inside the framed area + # instead of being pinned against its border. + var frame := hud.get_node_or_null("ResponsiveLayout/PlayAreaFrame") as Control + var viewport_half := get_viewport().get_visible_rect().size / camera.zoom * 0.5 + var frame_half := frame.get_global_rect().size / camera.zoom * 0.5 if frame != null else viewport_half + var limit_padding := viewport_half - frame_half + camera.limit_left = floori($World.position.x - limit_padding.x) + camera.limit_top = floori($World.position.y - limit_padding.y) + camera.limit_right = ceili($World.position.x + map_size.x + limit_padding.x) + camera.limit_bottom = ceili($World.position.y + map_size.y + limit_padding.y) _sync_camera_to_player() func _sync_camera_to_player() -> void: diff --git a/scripts/presentation/character_panel.gd b/scripts/presentation/character_panel.gd index 92656f5..2963a02 100644 --- a/scripts/presentation/character_panel.gd +++ b/scripts/presentation/character_panel.gd @@ -3,16 +3,26 @@ extends PanelContainer const SkillTreeType = preload("res://scripts/domain/progression/skill_tree.gd") +const ATTRIBUTE_LABELS := { + &"str_": "Force", &"agi": "Agilité", &"end": "Endurance", &"per": "Perception", + &"int_": "Intelligence", &"wil": "Volonté", &"cha": "Charisme", &"luc": "Chance", +} +const FEATURED_SKILLS := {&"melee": "Corps à corps", &"ranged": "Distance", &"dodge": "Esquive"} + @onready var title: Label = $Title @onready var body: RichTextLabel = $Body var _player: PlayerState var _experience: Experience var _skill_tree: SkillTree +var _player_name := "Sans-Nom" +var _title_definition: Dictionary = {} -func present(player: PlayerState, experience: Experience) -> void: +func present(player: PlayerState, experience: Experience, player_name: String = "Sans-Nom", title_definition: Dictionary = {}) -> void: _player = player _experience = experience + _player_name = player_name + _title_definition = title_definition.duplicate(true) _skill_tree = SkillTreeType.new(experience, player.attributes, player.skills) visible = true refresh() @@ -22,6 +32,7 @@ func dismiss() -> void: _player = null _experience = null _skill_tree = null + _title_definition.clear() func spend_attribute(key: StringName) -> Dictionary: if _skill_tree == null: @@ -42,13 +53,26 @@ func spend_skill(key: StringName) -> Dictionary: func refresh() -> void: if _player == null or _experience == null: return - title.text = "Character" - body.text = "Level %d — XP %d/%d\nAttribute points: %d\nSkill points: %d\n\n[A] Strength: %d\n[S] Melee: %d\n\nA / S Allocate Esc Close" % [ - _experience.level, - _experience.total_xp, - _experience.next_level_xp(), - _experience.attribute_points, - _experience.skill_points, - _player.attributes.get_attribute(&"str_"), - _player.effective_skill(&"melee"), + var title_name := String(_title_definition.get("name", "Sans titre")) + var flavor := String(_title_definition.get("flavor", "Aucune légende n’est encore écrite.")) + title.text = "FICHE DE PERSONNAGE" + var lines := [ + "Nom : %s" % _player_name, + "Titre : %s" % title_name, + flavor, + "", + "Niveau %d — XP %d/%d" % [_experience.level, _experience.total_xp, _experience.next_level_xp()], + "Points d’attribut : %d" % _experience.attribute_points, + "Points de compétence : %d" % _experience.skill_points, + "", + "Caractéristiques :", ] + for key: StringName in ATTRIBUTE_LABELS: + lines.append("%s : %d" % [ATTRIBUTE_LABELS[key], _player.attributes.get_attribute(key)]) + lines.append("") + lines.append("Compétences principales :") + for key: StringName in FEATURED_SKILLS: + lines.append("%s : %d" % [FEATURED_SKILLS[key], _player.effective_skill(key)]) + lines.append("") + lines.append("A / S Allouer (Force / Corps à corps) Échap Fermer") + body.text = "\n".join(lines) diff --git a/scripts/presentation/event_presenter.gd b/scripts/presentation/event_presenter.gd index d3d6073..b7a8e8d 100644 --- a/scripts/presentation/event_presenter.gd +++ b/scripts/presentation/event_presenter.gd @@ -57,7 +57,7 @@ func map_event(event: GameEvent) -> PresentationEvent: return PresentationEventType.new(event, &"door", event.message, DoorChestFeedback.DOOR_COLOR) &"chest_opened": return PresentationEventType.new(event, &"chest", event.message, DoorChestFeedback.CHEST_COLOR) - &"loot_dropped", &"loot_taken", &"item_picked_up": + &"loot_dropped", &"loot_taken", &"item_picked_up", &"pickup_refused": return PresentationEventType.new(event, &"loot", event.message, LootFeedback.LOOT_COLOR) &"trap_triggered", &"trap_discovered", &"trap_disarmed", &"trap_disarm_failed", &"trap_status_applied": return PresentationEventType.new(event, &"trap", event.message, LootFeedback.TRAP_COLOR) diff --git a/scripts/presentation/hud.gd b/scripts/presentation/hud.gd index d215de9..1e81fe1 100644 --- a/scripts/presentation/hud.gd +++ b/scripts/presentation/hud.gd @@ -11,52 +11,581 @@ const TRAP_PROMPT := "Espace — Désamorcer le piège" const SHRINE_PROMPT := "Espace — Prier au sanctuaire" const QUEST_BOARD_PROMPT := "Espace — Lire le tableau des quêtes" +const REFERENCE_VIEWPORT := Vector2(1920.0, 1080.0) +const MIN_LAYOUT_SCALE := 0.66 +const MIN_FONT_SCALE := 0.66 +const STATUS_EFFECT_NAMES := { + &"poison": "Empoisonnement", + &"bleeding": "Saignement", + &"burning": "Brûlure", + &"sepsis": "Septicémie", + &"stunned": "Étourdi", + &"feared": "Effrayé", + &"confused": "Confus", + &"wounded": "Blessé", + &"fatigued": "Fatigué", + &"strengthened": "Renforcé", + &"regenerating": "Régénération", +} + @onready var player_health_label: Label = $PlayerHealthLabel @onready var player_focus_label: Label = $PlayerFocusLabel +@onready var health_bar: ProgressBar = $HealthBar +@onready var focus_bar: ProgressBar = $FocusBar @onready var experience_bar: ProgressBar = $ExperienceBar @onready var experience_label: Label = $ExperienceLabel @onready var spell_label: Label = $SpellLabel @onready var deadline_label: Label = $DeadlineLabel +@onready var gold_icon: TextureRect = $GoldIcon @onready var gold_label: Label = $GoldLabel @onready var quest_tracker_label: Label = $QuestTrackerLabel @onready var enemy_health_label: Label = $EnemyHealthLabel @onready var combat_summary_label: Label = $CombatSummaryLabel +@onready var character_status_label: Label = $CharacterStatusLabel +@onready var character_name_label: Label = $ResponsiveLayout/CharacterNameLabel +@onready var character_level_label: Label = $ResponsiveLayout/CharacterLevelLabel +@onready var header_values_label: Label = $HeaderValuesLabel +@onready var title_label: Label = $TitleLabel @onready var event_log: RichTextLabel = $EventLog @onready var log_panel: PanelContainer = $ResponsiveLayout/LogPanel @onready var context_prompt_label: Label = $ContextPromptLabel +@onready var action_hint_label: Label = $ResponsiveLayout/PromptPanel/ActionHintLabel +@onready var responsive_layout: Control = $ResponsiveLayout + +const HIDDEN_JOURNAL_KINDS: Array[StringName] = [&"moved", &"enemy_moved", &"companion_moved", &"party_moved", &"episode_published"] + var combat_summary := "" var log_expanded := false +var _state: GameState +var _run_state: RunState +var _viewport_size := REFERENCE_VIEWPORT + +func _ready() -> void: + get_viewport().size_changed.connect(_on_viewport_size_changed) + apply_viewport_layout(get_viewport().get_visible_rect().size) + +func _on_viewport_size_changed() -> void: + apply_viewport_layout(get_viewport().get_visible_rect().size) + +## Lays the shell out from a 1920×1080 artboard while retaining readable controls +## down to 1280×720. It is public so embedded game views can request a relayout. +func apply_viewport_layout(viewport_size: Vector2) -> void: + if viewport_size.x <= 0.0 or viewport_size.y <= 0.0: + return + _viewport_size = viewport_size + var scale := maxf(MIN_LAYOUT_SCALE, minf(viewport_size.x / REFERENCE_VIEWPORT.x, viewport_size.y / REFERENCE_VIEWPORT.y)) + # Do not let the minimum readable layout escape a viewport smaller than 1280×720. + if viewport_size.x < 1280.0 or viewport_size.y < 720.0: + scale = minf(viewport_size.x / REFERENCE_VIEWPORT.x, viewport_size.y / REFERENCE_VIEWPORT.y) + var artboard_size := REFERENCE_VIEWPORT * scale + var origin := (viewport_size - artboard_size) * 0.5 + + # The shell is one centered 1920×1080 artboard. Camera2D intentionally keeps + # its engine viewport: these opaque masks, not a coupled camera viewport, are + # the visual boundary of the playable world. + _set_rect($ResponsiveLayout/DarkBackdrop, Vector2.ZERO, viewport_size) + _set_rect($ResponsiveLayout/Artboard, origin, artboard_size) + _set_rect($ResponsiveLayout/LetterboxTop, Vector2.ZERO, Vector2(viewport_size.x, origin.y)) + _set_rect($ResponsiveLayout/LetterboxBottom, Vector2(0.0, origin.y + artboard_size.y), Vector2(viewport_size.x, origin.y)) + _set_rect($ResponsiveLayout/PillarboxLeft, Vector2(0.0, origin.y), Vector2(origin.x, artboard_size.y)) + _set_rect($ResponsiveLayout/PillarboxRight, Vector2(origin.x + artboard_size.x, origin.y), Vector2(origin.x, artboard_size.y)) + + # Reference composition: 16px artboard margins, 24%% rails, and a 48%% central + # frame whose centre is the viewport centre. The slightly taller centre keeps + # the camera focal point stable between top and command bars. + _set_rect($ResponsiveLayout/TopBar, origin + Vector2(16, 12) * scale, Vector2(1888, 76) * scale) + _set_rect($ResponsiveLayout/LeftRail, origin + Vector2(16, 98) * scale, Vector2(460, 842) * scale) + _set_rect($ResponsiveLayout/PlayAreaFrame, origin + Vector2(498, 125) * scale, Vector2(924, 830) * scale) + _set_rect($ResponsiveLayout/RightRail, origin + Vector2(1444, 98) * scale, Vector2(460, 842) * scale) + _set_rect($ResponsiveLayout/CommandBar, origin + Vector2(16, 956) * scale, Vector2(1888, 108) * scale) + + # These four panels are deliberately before all chrome in the scene tree. + # Together they cover exactly the artboard outside PlayAreaFrame, hiding the + # full engine viewport while leaving the framed centre unmasked. + _set_rect($ResponsiveLayout/PlayAreaMaskTop, origin, Vector2(1920, 125) * scale) + _set_rect($ResponsiveLayout/PlayAreaMaskLeft, origin + Vector2(0, 125) * scale, Vector2(498, 830) * scale) + _set_rect($ResponsiveLayout/PlayAreaMaskRight, origin + Vector2(1422, 125) * scale, Vector2(498, 830) * scale) + _set_rect($ResponsiveLayout/PlayAreaMaskBottom, origin + Vector2(0, 955) * scale, Vector2(1920, 125) * scale) + + # Named rail sections establish the visible content hierarchy. The legacy + # panel paths remain as transparent compatibility hosts for existing callers. + _set_rect($ResponsiveLayout/CharacterSection, origin + Vector2(28, 110) * scale, Vector2(436, 300) * scale) + _set_rect($ResponsiveLayout/ObjectivesSection, origin + Vector2(28, 422) * scale, Vector2(436, 156) * scale) + _set_rect($ResponsiveLayout/StatusSection, origin + Vector2(28, 602) * scale, Vector2(436, 326) * scale) + _set_rect($ResponsiveLayout/JournalSection, origin + Vector2(1456, 110) * scale, Vector2(436, 404) * scale) + _set_rect($ResponsiveLayout/MapSection, origin + Vector2(1456, 526) * scale, Vector2(436, 402) * scale) + _set_rect($ResponsiveLayout/StatsPanel, origin + Vector2(28, 110) * scale, Vector2(436, 300) * scale) + _set_rect($ResponsiveLayout/LogPanel, origin + Vector2(1456, 110) * scale, Vector2(436, 404) * scale) + _set_rect($ResponsiveLayout/PromptPanel, origin + Vector2(490, 968) * scale, Vector2(610, 84) * scale) + _set_rect($ResponsiveLayout/HelpPanel, origin + Vector2(1120, 968) * scale, Vector2(772, 84) * scale) + _set_rect($ResponsiveLayout/QuickSlotStrip, origin + Vector2(28, 968) * scale, Vector2(442, 84) * scale) + + # Every title has a deliberate 18px inset: it stays clear of the nine-patch border. + _set_rect($ResponsiveLayout/CharacterSectionTitle, origin + Vector2(44, 128) * scale, Vector2(400, 28) * scale) + _set_rect($ResponsiveLayout/ObjectivesSectionTitle, origin + Vector2(44, 440) * scale, Vector2(400, 24) * scale) + _set_rect($ResponsiveLayout/StatusSectionTitle, origin + Vector2(44, 620) * scale, Vector2(400, 24) * scale) + _set_rect($ResponsiveLayout/JournalSectionTitle, origin + Vector2(1472, 128) * scale, Vector2(400, 28) * scale) + _set_rect($ResponsiveLayout/MapSectionTitle, origin + Vector2(1472, 544) * scale, Vector2(400, 24) * scale) + _set_rect($ResponsiveLayout/QuickSlotHint, origin + Vector2(38, 980) * scale, Vector2(420, 60) * scale) + + _set_rect($AchievementToast, origin + Vector2(1450, 48) * scale, Vector2(420, 25) * scale) + _set_rect($TitleLabel, origin + Vector2(675, 24) * scale, Vector2(570, 34) * scale) + _set_rect($TitleNotificationLabel, origin + Vector2(650, 52) * scale, Vector2(620, 26) * scale) + _set_rect($HeaderValuesLabel, origin + Vector2(480, 51) * scale, Vector2(960, 26) * scale) + # Identity leads the character card. The portrait stays at the mockup's 140px + # width and the source aspect ratio (127:140); vital gauges form a clear column. + _set_rect($ResponsiveLayout/PortraitIllustration, origin + Vector2(44, 160) * scale, Vector2(140, 154.33) * scale) + # Character identity is the section title. The legacy name label remains hidden. + _set_rect($ResponsiveLayout/CharacterNameLabel, origin + Vector2(202, 154) * scale, Vector2(226, 30) * scale) + _set_rect($ResponsiveLayout/CharacterLevelLabel, origin + Vector2(202, 164) * scale, Vector2(226, 22) * scale) + _set_rect($PlayerHealthLabel, origin + Vector2(202, 194) * scale, Vector2(226, 22) * scale) + _set_rect($HealthBar, origin + Vector2(202, 218) * scale, Vector2(226, 18) * scale) + _set_rect($PlayerFocusLabel, origin + Vector2(202, 242) * scale, Vector2(226, 22) * scale) + _set_rect($FocusBar, origin + Vector2(202, 266) * scale, Vector2(226, 18) * scale) + _set_rect($ExperienceBar, origin + Vector2(44, 306) * scale, Vector2(384, 22) * scale) + _set_rect($ExperienceLabel, origin + Vector2(48, 306) * scale, Vector2(376, 22) * scale) + _set_rect($GoldIcon, origin + Vector2(44, 366) * scale, Vector2(24, 24) * scale) + _set_rect($GoldLabel, origin + Vector2(76, 366) * scale, Vector2(120, 24) * scale) + + _set_rect($QuestTrackerLabel, origin + Vector2(52, 482) * scale, Vector2(376, 92) * scale) + + _layout_status_slots(origin, scale) + + _set_rect($EventLog, origin + Vector2(1476, 164) * scale, Vector2(396, 330) * scale) + _set_rect($ContextPromptLabel, origin + Vector2(506, 1008) * scale, Vector2(578, 30) * scale) + _set_rect($HelpLabel, origin + Vector2(1132, 980) * scale, Vector2(742, 58) * scale) + var minimap := get_node_or_null("Minimap") as Control + if minimap != null: + minimap.call("_layout_in_hud") + _apply_text_scale(scale) + if log_expanded: + _layout_expanded_log(origin, scale) + +func _set_rect(control: Control, position: Vector2, control_size: Vector2) -> void: + control.position = position + control.size = control_size + +func _layout_status_slots(origin: Vector2, scale: float) -> void: + # StatusSection ends at y=928. At reference, slots follow the authored + # 664/780/824px composition. At compact scale labels retain enough physical + # height to wrap all effects, so the bounded stack is bottom-aligned instead. + var x := origin.x + 44.0 * scale + var width := 386.0 * scale + var character_y := origin.y + 664.0 * scale + var character_height := 100.0 * scale + var target_height := 24.0 * scale + var deadline_height := 60.0 * scale + var gap := 18.0 * scale + if scale < 1.0: + # These are physical compact-layout heights (not artboard-scaled): the + # multi-effect row needs its full wrapped minimum while all rows remain + # inside StatusSection at 1280×720 with a visible 12px gap. + character_height = 97.0 + target_height = 23.0 + deadline_height = 28.0 + gap = 12.0 + # Keep the StatusSection title clear while remaining above its lower edge. + character_y = maxf(origin.y + 662.0 * scale, origin.y + 928.0 * scale - character_height - target_height - deadline_height - 2.0 * gap) + var target_y := character_y + character_height + gap + var deadline_y := target_y + target_height + gap + _set_rect($CharacterStatusLabel, Vector2(x, character_y), Vector2(width, character_height)) + _set_rect($EnemyHealthLabel, Vector2(x, target_y), Vector2(width, target_height)) + _set_rect($DeadlineLabel, Vector2(x, deadline_y), Vector2(width, deadline_height)) + # Dormant labels share a hidden lower slot. _refresh_status_section clears + # and hides them before showing actionable information. + var dormant_y := origin.y + 896.0 * scale + _set_rect($SpellLabel, Vector2(x, dormant_y), Vector2(width, 20.0 * scale)) + _set_rect($CombatSummaryLabel, Vector2(x, dormant_y), Vector2(width, 20.0 * scale)) + +func _apply_text_scale(layout_scale: float) -> void: + var font_scale := clampf(layout_scale, MIN_FONT_SCALE, 1.0) + for control: Control in [ + $AchievementToast, + $TitleLabel, + $TitleNotificationLabel, + $HeaderValuesLabel, + $ResponsiveLayout/QuickSlotHint, + $PlayerHealthLabel, + $PlayerFocusLabel, + $ExperienceLabel, + $CharacterStatusLabel, + $ResponsiveLayout/CharacterNameLabel, + $ResponsiveLayout/CharacterLevelLabel, + $GoldLabel, + $QuestTrackerLabel, + $SpellLabel, + $EnemyHealthLabel, + $CombatSummaryLabel, + $DeadlineLabel, + action_hint_label, + $ContextPromptLabel, + $HelpLabel, + ]: + var base_size: int = control.get_meta(&"base_font_size", 0) + if base_size == 0: + base_size = control.get_theme_font_size(&"font_size") + control.set_meta(&"base_font_size", base_size) + control.add_theme_font_size_override(&"font_size", roundi(base_size * font_scale)) + + # RichTextLabel does not use Label's font_size theme key. Keep the journal + # independently readable at 720p without changing the rest of the HUD scale. + var event_log_base_size: int = event_log.get_meta(&"base_normal_font_size", 0) + if event_log_base_size == 0: + event_log_base_size = event_log.get_theme_font_size(&"normal_font_size") + event_log.set_meta(&"base_normal_font_size", event_log_base_size) + event_log.add_theme_font_size_override(&"normal_font_size", max(12, roundi(event_log_base_size * font_scale))) + +func _layout_expanded_log(origin: Vector2, scale: float) -> void: + # Explicit expansion may temporarily consume the MapSection, never the world. + _set_rect(log_panel, origin + Vector2(1456, 110) * scale, Vector2(436, 818) * scale) + _set_rect(event_log, origin + Vector2(1476, 154) * scale, Vector2(396, 750) * scale) func toggle_log() -> void: log_expanded = not log_expanded - log_panel.offset_bottom = 480.0 if log_expanded else 170.0 - event_log.offset_bottom = 468.0 if log_expanded else 158.0 -var _state: GameState -var _run_state: RunState + apply_viewport_layout(_viewport_size) func refresh(state: GameState, events: Array[GameEvent] = [], run_state: RunState = null) -> void: _state = state if run_state != null: _run_state = run_state - player_health_label.text = "Player HP: %d/%d" % [state.player.hit_points, state.player.max_hit_points] - player_focus_label.text = "Focus: %d/%d" % [state.player.focus, state.player.max_focus] + player_health_label.text = "PV : %d/%d" % [state.player.hit_points, state.player.max_hit_points] + player_focus_label.text = "Focus : %d/%d" % [state.player.focus, state.player.max_focus] + _refresh_live_gauge(health_bar, state.player.hit_points, state.player.max_hit_points) + _refresh_live_gauge(focus_bar, state.player.focus, state.player.max_focus) _refresh_experience(state.player.progression) - if state.enemies.has(&"goblin"): - var goblin: ActorState = state.enemies[&"goblin"] - enemy_health_label.text = "Goblin HP: %d/%d" % [goblin.hit_points, goblin.max_hit_points] - combat_summary = "Target: Goblin HP: %d/%d" % [goblin.hit_points, goblin.max_hit_points] - else: - enemy_health_label.text = "No active target" - combat_summary = "No active target" - combat_summary_label.text = combat_summary - deadline_label.text = _deadline_status() - gold_label.text = "Or: %d" % (_run_state.gold if _run_state != null else 0) + _refresh_header_values() + title_label.text = "Étage %d" % state.floor_state.floor_number + var player_name := _run_state.player_name if _run_state != null else "Sans-Nom" + $ResponsiveLayout/CharacterSectionTitle.text = player_name + character_name_label.text = "" + character_name_label.visible = false + character_level_label.text = "Niveau %d" % state.player.progression.level + _refresh_status_section(state) + gold_label.text = str(_run_state.gold if _run_state != null else 0) quest_tracker_label.text = _quest_tracker() + action_hint_label.text = "F : Distance • X : Magie • K : Familier" context_prompt_label.text = get_context_prompt() # The supplied RunState journal events are the only source for journal text. event_log.clear() for event in events: - event_log.append_text(event.message + "\n") + if _should_show_in_journal(event): + event_log.append_text(_localized_event_message(event) + "\n") + +func _refresh_status_section(state: GameState) -> void: + for label: Label in [character_status_label, spell_label, enemy_health_label, combat_summary_label, deadline_label]: + label.text = "" + label.visible = false + combat_summary = "" + + var effects: Array[String] = [] + for effect: StatusEffect in state.player.status_effects: + var name := String(STATUS_EFFECT_NAMES.get(effect.key, String(effect.key).capitalize())) + if state.player.status_effects.size() <= 3: + effects.append("%s (%d tours)" % [name, effect.duration]) + else: + effects.append("%s %d" % [name, effect.duration]) + if not effects.is_empty(): + # Compact separators preserve every effect and duration in the fixed slot. + var prefix := "Effets : " if effects.size() <= 3 else "Effets (%d) : " % effects.size() + character_status_label.text = prefix + (", ".join(effects) if effects.size() <= 3 else " • ".join(effects)) + character_status_label.visible = true + + var target := _active_target(state) + if target != null: + combat_summary = "%s — PV : %d/%d" % [_target_name(target), target.hit_points, target.max_hit_points] + enemy_health_label.text = combat_summary + enemy_health_label.visible = true + + var deadline_status := _deadline_status() + if not deadline_status.is_empty(): + deadline_label.text = deadline_status + deadline_label.visible = true + +func _active_target(state: GameState) -> ActorState: + var candidates: Array[ActorState] = [] + for enemy: ActorState in state.enemies.values(): + if enemy.is_alive() and bool(state.visible_cells.get(enemy.cell, false)): + candidates.append(enemy) + if candidates.is_empty(): + return null + candidates.sort_custom(func(left: ActorState, right: ActorState) -> bool: + var left_distance := state.player.cell.distance_squared_to(left.cell) + var right_distance := state.player.cell.distance_squared_to(right.cell) + if left_distance != right_distance: + return left_distance < right_distance + return String(left.id) < String(right.id) + ) + return candidates[0] + +func _target_name(target: ActorState) -> String: + if target.id == &"goblin" or target.content_id == &"goblin": + return "Gobelin" + if _run_state != null and _run_state.content_catalog != null: + var definition := _run_state.content_catalog.get_enemy(target.content_id) + if not definition.is_empty(): + return String(definition.get("name", "Ennemi")) + # Never expose an actor/content identifier as player-facing HUD text. + return "Ennemi" + +func _should_show_in_journal(event: GameEvent) -> bool: + return event.kind not in HIDDEN_JOURNAL_KINDS + +## Converts only the structured events the HUD owns into French. Domain messages +## remain untouched and provide the presentation fallback for every other kind. +func _localized_event_message(event: GameEvent) -> String: + var actor := _localized_actor(event.actor_id) + var target := _localized_actor(event.target_id) + var damage := int(event.payload.get("damage", 0)) + var attack_method := String(event.payload.get("attack_method", "attaque")) + match event.kind: + &"game_started": + return "%s commence une nouvelle aventure." % String(event.payload.get("player_name", "Sans-Nom")) + &"moved": + var destination: Variant = event.payload.get("to_cell", event.cell) + return "Vous vous déplacez vers %s." % destination + &"enemy_moved": + return "%s se déplace." % _sentence_case(actor) + &"blocked": + return "Votre chemin est bloqué." + &"melee": + return "Vous frappez %s avec %s et lui infligez %d dégâts." % [target, attack_method, damage] + &"enemy_melee": + return "%s vous frappe avec %s et vous inflige %d dégâts." % [_sentence_case(actor), attack_method, damage] + &"enemy_defeated": + return "%s est vaincu." % _sentence_case(actor) + &"attack_started": + return "Vous attaquez %s avec %s." % [target, attack_method] if event.actor_id == &"player" else "%s attaque %s avec %s." % [_sentence_case(actor), target, attack_method] + &"attack_hit": + return "Vous touchez %s." % target if event.actor_id == &"player" else "%s touche %s." % [_sentence_case(actor), target] + &"damage_dealt": + var damage_target := _with_preposition("à", target) + return "Vous infligez %d dégâts %s." % [damage, damage_target] if event.actor_id == &"player" else "%s inflige %d dégâts %s." % [_sentence_case(actor), damage, damage_target] + &"actor_died": + return "Vous succombez." if event.actor_id == &"player" else "%s succombe." % _sentence_case(actor) + &"xp_granted": + return "Vous gagnez %d points d’expérience." % int(event.payload.get("xp", 0)) + &"loot_dropped": + return _localized_loot_dropped(event.payload) + &"loot_taken": + return _localized_loot_taken(event.payload) + &"item_picked_up": + var picked_item := _localized_item_quantity(event.payload) + return "Ramassé : %s." % picked_item if not picked_item.is_empty() else "Ramassage impossible." + &"pickup_refused": + return _localized_pickup_refused(event.payload) + &"companion_intercepted": + return "Votre familier intercepte l’attaque %s." % _with_preposition("de", actor) + &"companion_died": + return "Votre familier tombe, mais votre aventure continue." + &"companion_moved": + return "Votre familier vous suit." + &"episode_published": + return "Épisode %d publié." % int(event.payload.get("number", 0)) + &"ranged": + return "Vous tirez sur %s avec %s et infligez %d dégâts." % [target, _localized_weapon(event.payload), damage] + &"cast": + return "Vous lancez %s sur %s et infligez %d dégâts." % [_localized_spell(event.payload), target, damage] + &"ranged_attack_started": + return "Vous préparez un tir avec %s sur %s." % [_localized_weapon(event.payload), target] + &"projectile_fired": + return "Vous tirez avec %s sur %s." % [_localized_weapon(event.payload), target] + &"ranged_attack_hit": + return "Votre tir atteint %s." % target + &"invalid_ranged_target": + return "Tir impossible : %s." % _localized_failure_reason(event.payload.get("reason", "")) + &"spell_targeting_started": + return "Choisissez la cible de votre sort." + &"spell_targeting_cancelled": + return "Ciblage du sort annulé." + &"invalid_spell_target": + return "Sort impossible : %s." % _localized_failure_reason(event.payload.get("reason", "")) + &"spell_cast_started": + return "Vous lancez %s sur %s." % [_localized_spell(event.payload), target] + &"spell_damage_dealt": + return "%s inflige %d dégâts %s." % [_sentence_case(_localized_spell(event.payload)), damage, _with_preposition("à", target)] + &"spell_effect_applied": + return "%s applique l’état %s %s." % [_sentence_case(_localized_spell(event.payload)), _localized_status(event.payload.get("status", "")), _with_preposition("à", target)] + _: + return event.message + +func _localized_loot_dropped(payload: Dictionary) -> String: + # Enemy items remain on the ground, while gold is credited to RunState at + # death. Keep both destinations explicit instead of presenting all rewards as + # ground loot. + var dropped_items := _localized_items(payload.get("items", [])) + var gold := int(payload.get("gold", 0)) + if not dropped_items.is_empty() and gold > 0: + return "Butin — au sol : %s ; or récupéré : %d." % [", ".join(dropped_items), gold] + if not dropped_items.is_empty(): + return "Butin au sol : %s." % ", ".join(dropped_items) + if gold > 0: + return "Or récupéré : %d." % gold + return "Aucun butin." + +func _localized_items(items: Array) -> PackedStringArray: + var parts := PackedStringArray() + for item_data: Variant in items: + if item_data is Dictionary: + var item := _localized_item_quantity(item_data) + if not item.is_empty(): + parts.append(item) + return parts + +func _localized_loot_taken(payload: Dictionary) -> String: + var rewards := _localized_reward_parts(payload) + var refused := _localized_refused_items(payload.get("refused_items", [])) + if rewards.is_empty() and refused.is_empty(): + return "Aucun butin ramassé." + var message := "Butin récupéré" + if not rewards.is_empty(): + message += " : %s" % ", ".join(rewards) + if not refused.is_empty(): + message += "%s%s" % [" ; " if not rewards.is_empty() else " : ", ", ".join(refused)] + return message + "." + +func _localized_pickup_refused(payload: Dictionary) -> String: + var reason := StringName(payload.get("reason", "")) + if reason == &"no_ground_item": + return "Rien à ramasser." + var item := _localized_item_quantity(payload) + if reason == &"capacity" or reason == &"inventory_full": + return "Inventaire plein : %s non ramassé." % item if not item.is_empty() else "Inventaire plein." + return "Ramassage impossible." + +func _localized_reward_parts(payload: Dictionary) -> PackedStringArray: + var parts := _localized_items(payload.get("items", [])) + var gold := int(payload.get("gold", 0)) + if gold > 0: + parts.append("%d or" % gold) + var ammunition := int(payload.get("ammunition", 0)) + if ammunition > 0: + parts.append("%d munitions récupérées" % ammunition) + return parts + +func _localized_refused_items(items: Array) -> PackedStringArray: + var parts := PackedStringArray() + for item_data: Variant in items: + if item_data is Dictionary: + var item := _localized_item_quantity(item_data) + if not item.is_empty(): + parts.append("%s non ramassé (inventaire plein)" % item) + return parts + +func _localized_item_quantity(item_data: Dictionary) -> String: + var item_id := StringName(item_data.get("item_id", "")) + if item_id.is_empty(): + return "" + var quantity := int(item_data.get("quantity", 1)) + if quantity <= 0: + return "" + return "%s x%d" % [_localized_item_name(item_id), quantity] + +func _localized_item_name(item_id: StringName) -> String: + if _run_state != null and _run_state.content_catalog != null: + var item := _run_state.content_catalog.get_item(item_id) + if not item.is_empty(): + return String(item.get("name", item_id)) + return String(item_id).replace("_", " ") + +func _localized_weapon(payload: Dictionary) -> String: + var weapon_id := StringName(payload.get("weapon_id", "")) + if _run_state != null and _run_state.content_catalog != null and not weapon_id.is_empty(): + var weapon := _run_state.content_catalog.get_item(weapon_id) + if not weapon.is_empty(): + return String(weapon.get("name", weapon_id)) + return "votre arme à distance" + +func _localized_spell(payload: Dictionary) -> String: + var spell_name := String(payload.get("spell_name", "")) + if not spell_name.is_empty(): + return spell_name + var spell_id := StringName(payload.get("spell_id", "")) + if _run_state != null and _run_state.content_catalog != null and not spell_id.is_empty(): + var spell := _run_state.content_catalog.get_spell(spell_id) + if not spell.is_empty(): + return String(spell.get("name", spell_id)) + return "votre sort" + +func _localized_failure_reason(reason: Variant) -> String: + match StringName(reason): + &"cooldown": return "le sort est en recharge" + &"insufficient_focus": return "Focus insuffisant" + &"out_of_range": return "la cible est hors de portée" + &"line_of_sight_blocked": return "la ligne de vue est bloquée" + &"no_ammunition": return "vous n’avez plus de munitions" + &"no_ranged_weapon": return "aucune arme à distance n’est équipée" + &"invalid_target": return "cible invalide" + &"no_valid_spell_target": return "aucune cible valide pour ce sort" + _: return "action impossible" + +func _localized_status(status: Variant) -> String: + match StringName(status): + &"poison": return "empoisonnement" + &"burning": return "brûlure" + &"bleeding": return "saignement" + &"feared": return "peur" + &"stunned": return "étourdissement" + &"wounded": return "blessure" + _: return "effet" + +func _sentence_case(text: String) -> String: + return text.left(1).to_upper() + text.substr(1) + +func _with_preposition(preposition: String, actor: String) -> String: + if actor.begins_with("le "): + return "%s %s" % ["au" if preposition == "à" else "du", actor.trim_prefix("le ")] + if actor.begins_with("les "): + return "%s %s" % ["aux" if preposition == "à" else "des", actor.trim_prefix("les ")] + return "%s %s" % [preposition, actor] + +func _localized_actor(actor_id: StringName) -> String: + match actor_id: + &"player": + return "vous" + &"companion": + return "votre familier" + &"goblin": + return "le gobelin" + &"": + return "l’adversaire" + var content_id := actor_id + if _state != null and _state.enemies.has(actor_id): + var enemy: ActorState = _state.enemies[actor_id] + content_id = enemy.content_id + else: + content_id = _content_id_from_generated_actor(actor_id) + if _run_state != null and _run_state.content_catalog != null: + var enemy_definition := _run_state.content_catalog.get_enemy(content_id) + if not enemy_definition.is_empty(): + return _with_definite_article(String(enemy_definition.get("name", "adversaire"))) + return "l’adversaire" + +func _content_id_from_generated_actor(actor_id: StringName) -> StringName: + var id := String(actor_id) + var suffix_start := id.rfind("_") + if suffix_start >= 0 and id.substr(suffix_start + 1).is_valid_int(): + return StringName(id.left(suffix_start)) + return actor_id + +func _with_definite_article(name: String) -> String: + var normalized := name.strip_edges() + if normalized.is_empty(): + return "l’adversaire" + var lower := normalized.to_lower() + if lower.begins_with("le ") or lower.begins_with("la ") or lower.begins_with("les ") or lower.begins_with("l’") or lower.begins_with("l'"): + return normalized + return "l’%s" % normalized if lower.begins_with("a") or lower.begins_with("e") or lower.begins_with("i") or lower.begins_with("o") or lower.begins_with("u") or lower.begins_with("h") else "le %s" % lower + +func _refresh_live_gauge(gauge: ProgressBar, current: int, maximum: int) -> void: + gauge.min_value = 0 + gauge.max_value = max(1, maximum) + gauge.value = clampi(current, 0, maximum) + +func _refresh_header_values() -> void: + # Kept solely as a stable node path for older UI integrations. The floor is + # now the single permanent top-bar value and is refreshed above. + header_values_label.text = "" + header_values_label.visible = false func _refresh_experience(experience: Experience) -> void: var current_level_start := experience.xp_for_level(experience.level) @@ -99,27 +628,20 @@ func get_context_prompt() -> String: func _quest_tracker() -> String: if _run_state == null or not "quest_manager" in _run_state or _run_state.quest_manager == null: - return "Quêtes : aucune" + return "◆ Objectif : aucune quête active" var active: Array[QuestState] = _run_state.quest_manager.active_states() if active.is_empty(): - return "Quêtes : aucune active" + return "◆ Objectif : aucune quête active" var state := active[0] var definition := _run_state.quest_manager.catalog.get_quest(state.quest_id) for objective: Dictionary in definition.get("objectives", []): var objective_id := StringName(objective.get("id", "")) if state.objectives.get(objective_id, 0) < int(objective.get("count", 1)): - return "%s — %s (%d/%d)" % [String(definition.get("title", state.quest_id)), String(objective.get("description", objective_id)), state.objectives.get(objective_id, 0), int(objective.get("count", 1))] - return "%s — terminée" % String(definition.get("title", state.quest_id)) + return "◆ %s — %s (%d/%d)" % [String(definition.get("title", state.quest_id)), String(objective.get("description", objective_id)), state.objectives.get(objective_id, 0), int(objective.get("count", 1))] + return "◆ %s — terminée" % String(definition.get("title", state.quest_id)) func _deadline_status() -> String: - if _run_state == null: + if _run_state == null or _run_state.current_floor <= 0: return "" - if _run_state.current_floor == 0: - return "Surface — aucun effondrement" var deadline := _run_state.current_floor_deadline() - var status := "Étage %d — %d jour(s) avant l’effondrement" % [_run_state.current_floor, deadline.remaining_days()] - if deadline.collapsing: - return status + " — EFFONDREMENT" - if deadline.can_descend(): - return status + " — escaliers ouverts" - return status + " — escaliers dans %d jour(s)" % deadline.days_until_stairs_open() + return "Effondrement du niveau dans %d jours" % deadline.remaining_days() diff --git a/scripts/presentation/loot_feedback.gd b/scripts/presentation/loot_feedback.gd index c55c4c4..1dda68e 100644 --- a/scripts/presentation/loot_feedback.gd +++ b/scripts/presentation/loot_feedback.gd @@ -21,15 +21,17 @@ func get_last_feedback_state() -> Dictionary: func begin(event: GameEvent, presentation_kind: StringName) -> void: var color := _color_for(presentation_kind) + var feedback_label := label_for_event(event, presentation_kind) _last_feedback_state = { "kind": presentation_kind, "duration_ms": EFFECT_DURATION_MS, "color": color, + "label": feedback_label, } if _test_mode: return var label := Label.new() - label.text = _label_for(event, presentation_kind) + label.text = feedback_label label.modulate = color label.position = Vector2(390, 80) label.z_index = 20 @@ -47,9 +49,20 @@ func _color_for(presentation_kind: StringName) -> Color: &"quest": return QUEST_COLOR _: return LOOT_COLOR -func _label_for(event: GameEvent, presentation_kind: StringName) -> String: +func label_for_event(event: GameEvent, presentation_kind: StringName) -> String: + if presentation_kind == &"loot": + match event.kind: + &"loot_dropped": return "✦ BUTIN AU SOL" + &"item_picked_up": return "✦ OBJET RAMASSÉ" + &"loot_taken": return "✦ BUTIN RÉCUPÉRÉ" + &"pickup_refused": + var reason := StringName(event.payload.get("reason", "")) + if reason == &"no_ground_item": + return "! RIEN À RAMASSER" + if reason == &"capacity" or reason == &"inventory_full": + return "! INVENTAIRE PLEIN" + return "! RAMASSAGE IMPOSSIBLE" match presentation_kind: - &"loot": return "✦ BUTIN AU SOL" &"trap": return "! TRAP" &"quest": return "✦ QUEST UPDATED" _: return event.message diff --git a/scripts/presentation/menu/main_menu.gd b/scripts/presentation/menu/main_menu.gd index d3dc9e7..7210801 100644 --- a/scripts/presentation/menu/main_menu.gd +++ b/scripts/presentation/menu/main_menu.gd @@ -33,7 +33,7 @@ func _ready() -> void: func _get_capture_mode() -> bool: var arguments := OS.get_cmdline_user_args() - return "--capture" in arguments or "--capture-exit" in arguments + return "--capture" in arguments or "--capture-exit" in arguments or "--visual-check-compact" in arguments func _show_character_creation() -> void: menu.visible = false diff --git a/scripts/presentation/minimap.gd b/scripts/presentation/minimap.gd index ddf7678..83ccd0e 100644 --- a/scripts/presentation/minimap.gd +++ b/scripts/presentation/minimap.gd @@ -2,12 +2,17 @@ class_name Minimap extends Control const CROP_RADIUS := 6 -const CELL_SIZE := 12.0 -const UNKNOWN_COLOR := Color(0.025, 0.04, 0.09, 0.94) -const EXPLORED_COLOR := Color(0.18, 0.32, 0.48, 0.96) -const VISIBLE_COLOR := Color(0.72, 0.84, 0.9, 1.0) -const PLAYER_COLOR := Color(1.0, 0.92, 0.32, 1.0) -const THREAT_COLOR := Color(0.95, 0.42, 0.18, 1.0) +const UNKNOWN_COLOR := Color(0.035, 0.03, 0.025, 0.96) +const EXPLORED_COLOR := Color(0.24, 0.29, 0.25, 0.98) +const VISIBLE_COLOR := Color(0.72, 0.66, 0.51, 1.0) +const PLAYER_COLOR := Color(0.96, 0.78, 0.3, 1.0) +const THREAT_COLOR := Color(0.84, 0.22, 0.14, 1.0) +const COMPACT_SIZE := Vector2(396.0, 340.0) +const EXPANDED_SIZE := Vector2(520.0, 560.0) +const COMPACT_RAIL_INSET := 14.0 +const EXPANDED_FRAME_INSET := 28.0 + +@onready var map_region: Control = $MapRegion var expanded := false var _crop_radius := CROP_RADIUS @@ -17,6 +22,17 @@ var _visible_cells: Dictionary[Vector2i, bool] = {} var _explored_cells: Dictionary[Vector2i, bool] = {} var _threat_cells: Dictionary[Vector2i, bool] = {} +func _ready() -> void: + resized.connect(queue_redraw) + map_region.resized.connect(queue_redraw) + get_viewport().size_changed.connect(_on_viewport_size_changed) + call_deferred("_layout_in_hud") + +func _on_viewport_size_changed() -> void: + # GameHud updates the rail rectangles from the same signal; defer until those + # rectangles have received their new responsive dimensions. + call_deferred("_layout_in_hud") + func set_state(map: GridMapState, player_cell: Vector2i, visible_cells: Dictionary[Vector2i, bool], explored_cells: Dictionary[Vector2i, bool], threat_cells: Dictionary[Vector2i, bool]) -> void: _map = map _player_cell = player_cell @@ -49,28 +65,61 @@ func get_cell_visibility_state(cell: Vector2i) -> StringName: func get_threat_marker_cells() -> Dictionary[Vector2i, bool]: var threats: Dictionary[Vector2i, bool] = {} + var displayed := get_displayed_cells() for cell in _threat_cells: - if _visible_cells.has(cell) and get_displayed_cells().has(cell): + if _visible_cells.has(cell) and displayed.has(cell): threats[cell] = true return threats +## Returns the local rectangle exclusively available to map cells and markers. +func get_drawable_map_rect() -> Rect2: + if not is_instance_valid(map_region): + return Rect2() + var region_size := map_region.size + var square_side := minf(region_size.x, region_size.y) + return Rect2(map_region.position + (region_size - Vector2.ONE * square_side) * 0.5, Vector2.ONE * square_side) + func toggle_expanded() -> void: expanded = not expanded _crop_radius = CROP_RADIUS * 2 if expanded else CROP_RADIUS - set_anchors_and_offsets_preset(Control.PRESET_CENTER_TOP if expanded else Control.PRESET_TOP_RIGHT) - size = Vector2(312, 312) if expanded else Vector2(168, 168) - position = Vector2(484, 72) if expanded else Vector2(-188, 184) + _layout_in_hud() queue_redraw() +func _layout_in_hud() -> void: + if not is_inside_tree(): + return + var layout := get_node_or_null("../ResponsiveLayout") as Control + if layout == null: + return + var host := layout.get_node_or_null("PlayAreaFrame" if expanded else "MapSection") as Control + if host == null: + return + var requested_size := EXPANDED_SIZE if expanded else COMPACT_SIZE + var inset := EXPANDED_FRAME_INSET if expanded else COMPACT_RAIL_INSET + var available_size := host.size - Vector2.ONE * inset * 2.0 + if not expanded: + # The section heading occupies its own clear line above the map. + available_size.y -= 28.0 + var panel_size := Vector2(minf(requested_size.x, available_size.x), minf(requested_size.y, available_size.y)) + size = panel_size + if expanded: + position = host.position + (host.size - panel_size) * 0.5 + else: + position = host.position + Vector2((host.size.x - panel_size.x) * 0.5, 42.0) + func _draw() -> void: if _map == null: return + var drawable_rect := get_drawable_map_rect() + if drawable_rect.size.x <= 0.0 or drawable_rect.size.y <= 0.0: + return var displayed := get_displayed_cells() + var threat_cells := get_threat_marker_cells() var cells_across := _crop_radius * 2 + 1 - var draw_cell_size := size.x / float(cells_across) + var draw_cell_size := drawable_rect.size.x / float(cells_across) for cell in displayed: - var local := cell - _player_cell + Vector2i(cells_across / 2, cells_across / 2) - var rect := Rect2(Vector2(local) * draw_cell_size, Vector2.ONE * (draw_cell_size - 1.0)) + var local := cell - _player_cell + Vector2i(_crop_radius, _crop_radius) + var rect := Rect2(drawable_rect.position + Vector2(local) * draw_cell_size, Vector2.ONE * (draw_cell_size - 1.0)) var color := UNKNOWN_COLOR if get_cell_visibility_state(cell) == &"visible": color = VISIBLE_COLOR @@ -79,5 +128,5 @@ func _draw() -> void: draw_rect(rect, color) if cell == _player_cell: draw_circle(rect.get_center(), draw_cell_size * 0.28, PLAYER_COLOR) - elif get_threat_marker_cells().has(cell): + elif threat_cells.has(cell): draw_circle(rect.get_center(), draw_cell_size * 0.25, THREAT_COLOR) diff --git a/scripts/run-visual-check.sh b/scripts/run-visual-check.sh index 3a0f1b4..830a81e 100755 --- a/scripts/run-visual-check.sh +++ b/scripts/run-visual-check.sh @@ -18,7 +18,8 @@ mkdir -p artifacts log_path="artifacts/visual-check.log" initial_capture_path="artifacts/visual-check.png" exit_capture_path="artifacts/visual-check-exit.png" -rm -f "$initial_capture_path" "$exit_capture_path" +compact_capture_path="artifacts/visual-check-compact.png" +rm -f "$initial_capture_path" "$exit_capture_path" "$compact_capture_path" : > "$log_path" runner=() @@ -34,8 +35,9 @@ fi run_capture() { local label="$1" local capture_argument="$2" + shift 2 set +e - timeout --foreground 20s "${runner[@]}" "$GODOT_BIN" --path . -- --"$capture_argument" >>"$log_path" 2>&1 + timeout --foreground 20s "${runner[@]}" "$GODOT_BIN" --path . "$@" -- --"$capture_argument" >>"$log_path" 2>&1 local status=$? set -e if (( status != 0 )); then @@ -46,6 +48,10 @@ run_capture() { run_capture "initial" "capture" run_capture "exit" "capture-exit" +# This is a real 1280×720 window capture, not a unit-level HUD relayout call. +# The fixed window size makes the compact artboard and PNG reproducible under +# Xvfb as well as an interactive DISPLAY. +run_capture "compact" "visual-check-compact" --windowed --resolution 1280x720 # Godot's SCRIPT ERROR / Parse Error diagnostics are actionable application # failures. Do not treat unrelated backend diagnostics (for example the # expected xkbcommon Compose warnings emitted by some Snap/Xvfb setups) as an @@ -65,3 +71,4 @@ measure_capture() { measure_capture "$initial_capture_path" measure_capture "$exit_capture_path" +measure_capture "$compact_capture_path" diff --git a/tests/e2e/test_achievement_reward_e2e.gd b/tests/e2e/test_achievement_reward_e2e.gd index 5fb07d5..acaef0f 100644 --- a/tests/e2e/test_achievement_reward_e2e.gd +++ b/tests/e2e/test_achievement_reward_e2e.gd @@ -36,7 +36,24 @@ func test_real_hit_unlocks_reward_toast_journal_claim_and_title_refresh() -> voi assert_string_contains((game.get_node("HUD/AchievementToast") as Label).text, "Premier coup") assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"achievement_unlocked")) assert_eq(game.get_run_state().current_title_id, &"striker") - assert_string_contains((game.get_node("HUD/TitleLabel") as Label).text, "Frappeur") + var permanent_title := game.get_node_or_null("HUD/TitleLabel") as Label + var notification := game.get_node_or_null("HUD/TitleNotificationLabel") as Label + var notification_timer := game.get_node_or_null("HUD/TitleNotificationTimer") as Timer + assert_not_null(permanent_title) + assert_not_null(notification, "HUD requires a separate temporary TitleNotificationLabel") + assert_not_null(notification_timer, "HUD requires TitleNotificationTimer") + if permanent_title != null: + assert_eq(permanent_title.text, "Étage 0", "The permanent TopBar title remains the current floor") + if notification == null or notification_timer == null: + return + assert_true(notification.visible, "A newly earned title needs a temporary notification") + assert_eq(notification.text, "Frappeur") + assert_true(notification_timer.one_shot) + assert_eq(notification_timer.wait_time, 5.0) + # The real five-second expiry is intentionally verified by the dedicated + # transition test below, rather than manually emitting this timer's signal. + if permanent_title != null: + assert_eq(permanent_title.text, "Étage 0") await _dispatch_key(KEY_L) assert_true(panel.visible) @@ -45,6 +62,56 @@ func test_real_hit_unlocks_reward_toast_journal_claim_and_title_refresh() -> voi assert_true(game.get_run_state().recent_events(3).any(func(event: GameEvent) -> bool: return event.kind == &"achievement_reward_claimed")) assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Récompense reçue") +func test_title_notification_only_announces_real_transitions_and_expires_after_its_timer() -> void: + var permanent_title := game.get_node_or_null("HUD/TitleLabel") as Label + var notification := game.get_node_or_null("HUD/TitleNotificationLabel") as Label + var notification_timer := game.get_node_or_null("HUD/TitleNotificationTimer") as Timer + assert_not_null(permanent_title) + assert_not_null(notification) + assert_not_null(notification_timer) + if permanent_title == null or notification == null or notification_timer == null: + return + + assert_false(notification.visible, "Initialization must not announce the established title") + assert_eq(notification.text, "") + assert_eq(permanent_title.text, "Étage 0") + + game._refresh_title() + assert_false(notification.visible, "Refreshing the same current title stays silent") + assert_eq(permanent_title.text, "Étage 0") + + game.title_engine = TitleEngineType.new([]) + game._refresh_title() + assert_false(notification.visible, "Losing a title or receiving no title stays silent") + assert_eq(notification.text, "") + assert_eq(permanent_title.text, "Étage 0") + + game.title_engine = TitleEngineType.new([ + {"id": "renewed", "name": "Renouveau", "rank": 1, "conditions": []}, + ]) + game._refresh_title() + assert_true(notification.visible, "A real title transition needs a temporary notification") + assert_eq(notification.text, "Renouveau") + assert_true(notification_timer.time_left > 0.0) + assert_eq(permanent_title.text, "Étage 0") + + game.title_engine = TitleEngineType.new([]) + game._refresh_title() + assert_false(notification.visible, "A title loss clears an in-flight notification") + assert_eq(notification.text, "") + assert_eq(permanent_title.text, "Étage 0") + + game.title_engine = TitleEngineType.new([ + {"id": "renewed", "name": "Renouveau", "rank": 1, "conditions": []}, + ]) + game._refresh_title() + assert_true(notification.visible, "Regaining a title is a real transition") + await notification_timer.timeout + await get_tree().process_frame + assert_false(notification.visible, "The actual five-second timer hides the notification") + assert_eq(notification.text, "") + assert_eq(permanent_title.text, "Étage 0") + func _dispatch_key(keycode: Key) -> void: Input.parse_input_event(_key_event(keycode, true)) await get_tree().process_frame diff --git a/tests/e2e/test_attributes_current_game_nonregression_e2e.gd b/tests/e2e/test_attributes_current_game_nonregression_e2e.gd index c848c8f..462b396 100644 --- a/tests/e2e/test_attributes_current_game_nonregression_e2e.gd +++ b/tests/e2e/test_attributes_current_game_nonregression_e2e.gd @@ -15,5 +15,5 @@ func test_current_game_event_and_hud_remain_available_with_attributes_domain_loa var hud := game.get_node("HUD") as GameHud assert_eq(state.enemies[&"goblin"].hit_points, 3) assert_true(game.get_run_state().recent_events(2).any(func(event: GameEvent) -> bool: return event.kind == &"melee")) - assert_true(hud.player_health_label.text.contains("Player HP:")) - assert_true(hud.event_log.get_parsed_text().contains("You strike the goblin")) + assert_eq(hud.player_health_label.text, "PV : %d/%d" % [state.player.hit_points, state.player.max_hit_points]) + assert_true(hud.event_log.get_parsed_text().contains("Vous frappez le gobelin")) diff --git a/tests/e2e/test_audience_episode_e2e.gd b/tests/e2e/test_audience_episode_e2e.gd index de2b350..1c67e31 100644 --- a/tests/e2e/test_audience_episode_e2e.gd +++ b/tests/e2e/test_audience_episode_e2e.gd @@ -21,9 +21,21 @@ func test_real_actions_build_audience_unlock_sponsor_publish_episode_and_open_pa assert_gte(game.audience_state.spectacle_score(), 1) assert_eq(game.audience_state.followers(), 50) assert_eq(game.audience_state.unlocked_sponsors(), [&"first_sponsor"]) + var run_state := game.get_run_state() + var episode_events := run_state.recent_events(run_state.log.size()).filter(func(event: GameEvent) -> bool: return event.kind == &"episode_published") assert_eq(game.recap_log.episodes().size(), 1) - assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"sponsor_unlocked")) - assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"episode_published")) + assert_true(run_state.recent_events(run_state.log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"sponsor_unlocked")) + assert_eq(episode_events.size(), 1, "RunState must retain the published episode event") + var episode := game.recap_log.episodes()[0] + assert_eq(int(episode.get("number", 0)), 1) + assert_eq(int(episode.get("turn", 0)), run_state.current_turn) + assert_gte(int(episode.get("spectacle", 0)), 1) + assert_eq(int(episode.get("followers", 0)), 50) + assert_eq(episode.get("sponsors", []), [&"first_sponsor"]) + + var event_log := game.get_node("HUD/EventLog") as RichTextLabel + assert_eq(event_log.get_parsed_text().find("Épisode 1 publié"), -1) + assert_eq(event_log.get_parsed_text().find(episode_events[0].message), -1) await _dispatch_key(KEY_U) var audience_panel := game.get_node("HUD/AudiencePanel") as PanelContainer diff --git a/tests/e2e/test_combat_hud_e2e.gd b/tests/e2e/test_combat_hud_e2e.gd index 368bc32..99719d9 100644 --- a/tests/e2e/test_combat_hud_e2e.gd +++ b/tests/e2e/test_combat_hud_e2e.gd @@ -14,7 +14,8 @@ func test_configured_input_event_uses_the_same_action_path_as_submit_test_action var input_event := _key_event(KEY_DOWN) game._unhandled_input(input_event) assert_eq(state.player.cell, Vector2i(4, 8)) - assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "You move to (4, 8).") + assert_eq(game.get_run_state().recent_events(1)[0].kind, &"moved") + assert_eq(game.get_node("HUD/EventLog").get_parsed_text(), "") var submitted_game := GameScene.instantiate() as Game add_child_autofree(submitted_game) @@ -32,20 +33,22 @@ func test_real_game_scene_completes_adjacent_bump_combat_and_defeat_route() -> v game._sync_enemy_views() var hud := game.get_node("HUD") as GameHud hud.refresh(state, [], game.get_run_state()) - assert_eq(hud.combat_summary, "Target: Goblin HP: 6/6") + assert_eq(hud.combat_summary, "Gobelin — PV : 6/6") var first_melee := game.submit_test_action(Vector2i.RIGHT) assert_eq(first_melee[0].kind, &"melee") assert_eq(first_melee[1].kind, &"enemy_melee") assert_eq(state.player.cell, Vector2i(4, 7)) assert_eq(enemy.cell, Vector2i(5, 7)) - assert_string_contains(hud.event_log.get_parsed_text(), "with mains nues") + assert_string_contains(hud.event_log.get_parsed_text(), "Vous frappez le gobelin avec mains nues") + assert_eq(hud.event_log.get_parsed_text().find("You"), -1) var lethal_melee := game.submit_test_action(Vector2i.RIGHT) assert_eq(lethal_melee[0].kind, &"melee") assert_eq(lethal_melee[1].kind, &"enemy_defeated") assert_false(state.enemies.has(&"goblin")) - assert_eq(hud.combat_summary, "No active target") + assert_eq(hud.combat_summary, "") + assert_false((hud.get_node("EnemyHealthLabel") as Label).visible) func _key_event(keycode: Key) -> InputEventKey: var event := InputEventKey.new() diff --git a/tests/e2e/test_display_camera_grid_e2e.gd b/tests/e2e/test_display_camera_grid_e2e.gd index 7b7659c..180b126 100644 --- a/tests/e2e/test_display_camera_grid_e2e.gd +++ b/tests/e2e/test_display_camera_grid_e2e.gd @@ -30,3 +30,24 @@ func test_real_game_keyboard_movement_keeps_actor_in_cell_and_updates_camera_wit assert_eq(camera.position, game.get_node("World").position + Vector2(state.player.cell * Game.TILE_SIZE)) assert_eq(hud.layer, 1) assert_eq(game.get_node("HUD/PlayerHealthLabel").get_global_rect().position, hud_screen_position) + +func test_surface_exit_camera_keeps_the_player_inside_the_play_area_frame() -> void: + var state := game.get_game_state() + var camera := game.get_node("Camera2D") as Camera2D + var world := game.get_node("World") as Node2D + var player := game.get_node("World/Player") as ActorView + var play_area := game.get_node("HUD/ResponsiveLayout/PlayAreaFrame") as Control + state.player.cell = state.floor_state.exit + player.refresh() + game._configure_camera() + camera.force_update_scroll() + await get_tree().process_frame + + var player_screen_rect := Rect2( + (player.global_position - camera.get_screen_center_position()) * camera.zoom + get_viewport().get_visible_rect().size * 0.5, + Vector2(Game.TILE_SIZE) * camera.zoom + ) + assert_true(play_area.get_global_rect().encloses(player_screen_rect), "the exit player must stay within the unmasked PlayAreaFrame") + assert_gte(player_screen_rect.position.x - play_area.get_global_rect().position.x, 64.0, "the exit player needs a readable left margin") + assert_gte(play_area.get_global_rect().end.x - player_screen_rect.end.x, 64.0, "the exit player needs a readable right margin") + assert_eq(camera.position, world.position + Vector2(state.player.cell * Game.TILE_SIZE)) diff --git a/tests/e2e/test_enemy_ai_e2e.gd b/tests/e2e/test_enemy_ai_e2e.gd index 50d786c..afc2d14 100644 --- a/tests/e2e/test_enemy_ai_e2e.gd +++ b/tests/e2e/test_enemy_ai_e2e.gd @@ -58,4 +58,4 @@ func test_real_game_enemy_detects_approaches_attacks_and_dies_with_feedback() -> assert_false(state.enemies.has(&"goblin")) await get_tree().create_timer(1.2).timeout assert_eq(game.get_node("World/Enemies").get_child_count(), 0) - assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "defeated") + assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "Le gobelin est vaincu.") diff --git a/tests/e2e/test_level_up_e2e.gd b/tests/e2e/test_level_up_e2e.gd index 6091fe4..911a94c 100644 --- a/tests/e2e/test_level_up_e2e.gd +++ b/tests/e2e/test_level_up_e2e.gd @@ -30,10 +30,26 @@ func test_real_character_input_opens_panel_and_allocates_level_up_points_without assert_eq(xp_bar.max_value, 200.0) assert_eq(xp_label.text, "Niveau 2 — XP 0/200") - await _dispatch_key(KEY_P) var panel := game.get_node("HUD/CharacterPanel") as PanelContainer - assert_true(panel.visible) - assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Level 2") + game.get_run_state().player_name = "Dame Ysabel" + await _dispatch_key(KEY_P) + assert_false(panel.visible, "P must no longer open the character sheet") + await _dispatch_key(KEY_C) + assert_true(panel.visible, "The physical C key opens the character sheet") + var sheet_text := (panel.get_node("Body") as RichTextLabel).get_parsed_text() + assert_string_contains(sheet_text, "Nom : Dame Ysabel") + assert_string_contains(sheet_text, "Titre : Bleu du Donjon") + assert_string_contains(sheet_text, "Vous n'avez encore rien prouve.") + assert_string_contains(sheet_text, "Niveau 2") + assert_string_contains(sheet_text, "XP") + assert_string_contains(sheet_text, "Points d’attribut") + assert_string_contains(sheet_text, "Points de compétence") + for attribute_name: String in ["Force", "Agilité", "Endurance", "Perception", "Intelligence", "Volonté", "Charisme", "Chance"]: + assert_string_contains(sheet_text, attribute_name, "The sheet must list %s" % attribute_name) + for skill_name: String in ["Compétences principales", "Corps à corps", "Distance", "Esquive"]: + assert_string_contains(sheet_text, skill_name, "The sheet must list %s" % skill_name) + assert_string_contains(sheet_text, "A / S") + assert_string_contains(sheet_text, "Échap") await _dispatch_key(KEY_A) assert_eq(state.player.progression.attribute_points, 0) assert_eq(game.get_dialogue_player().attributes.get_attribute(&"str_"), 5) diff --git a/tests/e2e/test_melee_feedback_e2e.gd b/tests/e2e/test_melee_feedback_e2e.gd index 0e679ea..4d900cf 100644 --- a/tests/e2e/test_melee_feedback_e2e.gd +++ b/tests/e2e/test_melee_feedback_e2e.gd @@ -19,22 +19,37 @@ func test_real_game_resolves_damage_and_death_before_a3_feedback_and_journals_st observed.append(event) ) + var gold_before_kill := game.get_run_state().gold game.submit_test_action(Vector2i.RIGHT) assert_false(state.enemies.has(&"goblin")) # domain result is synchronous var recent := game.get_run_state().recent_events(8).filter(func(event: GameEvent) -> bool: return event.kind in [&"attack_started", &"attack_hit", &"damage_dealt", &"actor_died", &"xp_granted", &"loot_dropped"]) assert_eq(recent.map(func(event: GameEvent) -> StringName: return event.kind), [&"attack_started", &"attack_hit", &"damage_dealt", &"actor_died", &"xp_granted", &"loot_dropped"]) assert_eq(recent[2].payload.damage, 3) - assert_true(state.floor_state.ground_items.has(enemy.cell)) - if state.floor_state.ground_items.has(enemy.cell): - assert_false(state.floor_state.ground_items[enemy.cell].is_empty()) - assert_true(state.floor_state.ground_items[enemy.cell][0] is ItemInstance) var loot_event: GameEvent = recent.filter(func(event: GameEvent) -> bool: return event.kind == &"loot_dropped")[0] assert_true(loot_event.payload.has("items")) assert_true(loot_event.payload.has("gold")) + # Each item announced by the kill is an actual ItemInstance at the corpse, + # whereas gold bypasses the ground and is immediately added to RunState. + assert_true(state.floor_state.ground_items.has(enemy.cell)) + var ground_items: Array = state.floor_state.ground_items.get(enemy.cell, []) + for item_data: Dictionary in loot_event.payload.items: + var matching_items := ground_items.filter(func(item: Variant) -> bool: + return item is ItemInstance and item.definition.id == StringName(item_data.item_id) and item.quantity == int(item_data.quantity) + ) + assert_false(matching_items.is_empty(), "Loot payload item must exist as an ItemInstance on the ground") + assert_eq(game.get_run_state().gold, gold_before_kill + int(loot_event.payload.gold), "Enemy gold must be collected immediately") + assert_eq(int(loot_event.payload.gold), 26) + await _wait_for_feedback(observed) assert_eq(observed.map(func(event: GameEvent) -> StringName: return event.kind), [&"attack_started", &"attack_hit", &"damage_dealt", &"actor_died", &"xp_granted", &"loot_dropped"]) - assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "defeated") + # This is the live journal produced by the normal combat flow. Do not manually + # refresh it: achievement observation must not erase the player's loot detail. + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var journal_text := hud.event_log.get_parsed_text() + assert_string_contains(journal_text, "Butin — au sol : Bandage x1 ; or récupéré : 26.") + assert_eq(journal_text.find("consumable_bandage"), -1) func _wait_for_feedback(observed: Array[GameEvent]) -> void: var deadline := Time.get_ticks_msec() + 2500 diff --git a/tests/e2e/test_pet_companion_e2e.gd b/tests/e2e/test_pet_companion_e2e.gd index f116dff..2e95c32 100644 --- a/tests/e2e/test_pet_companion_e2e.gd +++ b/tests/e2e/test_pet_companion_e2e.gd @@ -71,7 +71,7 @@ func test_live_enemy_attack_is_intercepted_in_support_and_companion_death_leaves assert_eq(state.player.hit_points, state.player.max_hit_points) assert_false(companion.is_alive()) assert_not_null(game.get_node_or_null("World/Companion")) - assert_string_contains((game.get_node("HUD/EventLog") as RichTextLabel).get_parsed_text(), "companion") + assert_string_contains((game.get_node("HUD/EventLog") as RichTextLabel).get_parsed_text(), "Votre familier tombe") func _dispatch_key(keycode: Key) -> void: Input.parse_input_event(_key_event(keycode, true)) diff --git a/tests/e2e/test_pickup_inventory_e2e.gd b/tests/e2e/test_pickup_inventory_e2e.gd index 2e68d35..8cfb95e 100644 --- a/tests/e2e/test_pickup_inventory_e2e.gd +++ b/tests/e2e/test_pickup_inventory_e2e.gd @@ -33,6 +33,11 @@ func test_real_interact_picks_visible_ground_item_then_inventory_action_opens_li assert_eq(pickup.kind, &"item_picked_up") assert_eq(pickup.payload.item_id, &"consumable_bandage") assert_eq(pickup.payload.quantity, 2) + # Assert the journal the player sees after the real interaction; no manual + # refresh may mask a later observer (such as achievements) overwriting it. + var hud := game.get_node("HUD") as GameHud + await get_tree().process_frame + assert_string_contains(hud.event_log.get_parsed_text(), "Ramassé : Bandage x2.") await _dispatch_key(KEY_I) @@ -42,6 +47,52 @@ func test_real_interact_picks_visible_ground_item_then_inventory_action_opens_li assert_string_contains(entries.get_parsed_text(), "Bandage x2") assert_eq(game.get_run_state().recent_events(1)[0].kind, &"inventory_opened") +func test_direct_ground_pickup_refuses_an_empty_injected_ground_item_list_without_item_fields() -> void: + var state := game.get_game_state() + state.floor_state.ground_items[state.player.cell] = [] + + var results := game._process_ground_pickup() + + assert_eq(results.size(), 1) + assert_eq(results[0].kind, &"pickup_refused") + assert_eq(results[0].payload.reason, &"no_ground_item") + assert_false(results[0].payload.has("item_id")) + assert_false(results[0].payload.has("instance_id")) + assert_false(results[0].payload.has("quantity")) + assert_eq(results[0].message, "Rien à ramasser.") + var refusal := game.get_run_state().recent_events(1)[0] + assert_eq(refusal.kind, &"pickup_refused") + assert_eq(refusal.payload.reason, &"no_ground_item") + assert_false(refusal.payload.has("item_id")) + var hud := game.get_node("HUD") as GameHud + assert_string_contains(hud.event_log.get_parsed_text(), "Rien à ramasser.") + +func test_real_interact_refuses_non_stackable_ground_item_when_inventory_is_full() -> void: + var state := game.get_game_state() + var inventory := game.get_run_state().inventory + var definition := ItemDefinitionType.from_catalog(game.spell_catalog, &"weapon_hunting_knife") + var ground_item := ItemInstanceType.new(definition, 1, &"e2e-refused-hunting-knife") + inventory.capacity = 0 + var inventory_before := inventory.items.duplicate() + state.floor_state.ground_items[state.player.cell] = [ground_item] + game._sync_map_renderer_visibility() + await get_tree().process_frame + + await _dispatch_key(KEY_E) + + var refusal := game.get_run_state().recent_events(1)[0] + assert_eq(refusal.kind, &"pickup_refused") + assert_eq(refusal.payload.item_id, &"weapon_hunting_knife") + assert_eq(refusal.payload.instance_id, &"e2e-refused-hunting-knife") + assert_eq(refusal.payload.quantity, 1) + assert_eq(refusal.payload.reason, &"capacity") + assert_eq(inventory.items, inventory_before) + assert_true(state.floor_state.ground_items.has(state.player.cell)) + assert_eq(state.floor_state.ground_items[state.player.cell][0], ground_item) + var hud := game.get_node("HUD") as GameHud + await get_tree().process_frame + assert_string_contains(hud.event_log.get_parsed_text(), "Inventaire plein : Couteau de chasse x1 non ramassé.") + func _dispatch_key(keycode: Key) -> void: Input.parse_input_event(_key_event(keycode, true)) await get_tree().process_frame diff --git a/tests/e2e/test_run_event_journal_e2e.gd b/tests/e2e/test_run_event_journal_e2e.gd index 2121ff6..97e0939 100644 --- a/tests/e2e/test_run_event_journal_e2e.gd +++ b/tests/e2e/test_run_event_journal_e2e.gd @@ -13,19 +13,14 @@ func test_real_input_event_records_one_action_turn_and_hud_renders_its_run_state var run := game.get_run_state() var events := run.recent_events(2) var event_log := game.get_node("HUD/EventLog") as RichTextLabel - var expected_hud_text := "" - for event in events: - expected_hud_text += event.message + "\n" - # One input resolves movement plus an enemy response. They are one player action, - # so their journal events share action turn 1 and are present exactly once. + # so their RunState events share action turn 1 and are present exactly once. assert_eq(events.size(), 2) assert_eq(events.map(func(event: GameEvent) -> StringName: return event.kind), [&"moved", &"enemy_moved"]) assert_eq(events.map(func(event: GameEvent) -> int: return event.turn), [1, 1]) assert_eq(run.current_turn, 1) - assert_eq(event_log.get_parsed_text(), expected_hud_text) - assert_string_contains(event_log.get_parsed_text(), events[0].message) - assert_string_contains(event_log.get_parsed_text(), events[1].message) + # The HUD filters movement-only batches without mutating the RunState journal. + assert_eq(event_log.get_parsed_text(), "") func _key_event(keycode: Key) -> InputEventKey: var event := InputEventKey.new() diff --git a/tests/e2e/test_shop_rest_e2e.gd b/tests/e2e/test_shop_rest_e2e.gd index 468aaa7..d104b7e 100644 --- a/tests/e2e/test_shop_rest_e2e.gd +++ b/tests/e2e/test_shop_rest_e2e.gd @@ -20,7 +20,7 @@ func test_real_merchant_interaction_opens_shop_and_purchase_updates_inventory_an game.get_run_state().gold = 100 var no_events: Array[GameEvent] = [] game.get_node("HUD").refresh(state, no_events, game.get_run_state()) - assert_eq((game.get_node("HUD/GoldLabel") as Label).text, "Or: 100") + assert_eq((game.get_node("HUD/GoldLabel") as Label).text, "100") await _dispatch_key(KEY_E) var dialogue_entries := game.get_node("HUD/DialoguePanel/Layout/Entries") as RichTextLabel diff --git a/tests/e2e/test_temporary_playtest_chests_e2e.gd b/tests/e2e/test_temporary_playtest_chests_e2e.gd index 6d57e12..2fec437 100644 --- a/tests/e2e/test_temporary_playtest_chests_e2e.gd +++ b/tests/e2e/test_temporary_playtest_chests_e2e.gd @@ -51,9 +51,17 @@ func test_temporary_rewards_grant_ammunition_and_teach_the_offensive_spell_throu var spell_reward := _reward_with_item(state.floor_state.chests, &"misc_grimoire_ombre") game.pending_loot = ranged_reward.duplicate(true) + var ammunition_before := state.player.ammunition + var awarded_ammunition := int(ranged_reward.get("ammunition", 0)) + assert_gt(awarded_ammunition, 0) + assert_eq(awarded_ammunition, 20) game._take_all_loot() - assert_eq(state.player.ammunition, 20) + assert_eq(state.player.ammunition, ammunition_before + 20) assert_true(game.get_run_state().inventory.items.any(func(item: ItemInstance) -> bool: return item.definition.id == &"weapon_hand_crossbow")) + var loot_event := game.get_run_state().recent_events(1)[0] + assert_eq(loot_event.kind, &"loot_taken") + assert_eq(loot_event.payload.ammunition, 20) + assert_string_contains((game.get_node("HUD/EventLog") as RichTextLabel).get_parsed_text(), "20 munitions récupérées") game.pending_loot = spell_reward.duplicate(true) game._take_all_loot() diff --git a/tests/e2e/test_visual_capture_state_e2e.gd b/tests/e2e/test_visual_capture_state_e2e.gd new file mode 100644 index 0000000..652b350 --- /dev/null +++ b/tests/e2e/test_visual_capture_state_e2e.gd @@ -0,0 +1,25 @@ +extends GutTest + +const GameScene = preload("res://scenes/Game.tscn") +const RunSettingsType = preload("res://scripts/domain/run/run_settings.gd") + +func test_capture_preparation_refreshes_the_real_name_and_started_journal() -> void: + var game := GameScene.instantiate() as Game + game.configure_new_run(RunSettingsType.new("visual-check", &"crawler", false, false), "Visual Check") + add_child_autofree(game) + await get_tree().process_frame + + var hud := game.get_node_or_null("HUD") as GameHud + var character_title := game.get_node_or_null("HUD/ResponsiveLayout/CharacterSectionTitle") as Label + var event_log := game.get_node_or_null("HUD/EventLog") as RichTextLabel + assert_not_null(hud) + assert_not_null(character_title) + assert_not_null(event_log) + if hud == null or character_title == null or event_log == null: + return + assert_eq(character_title.text, "Visual Check") + assert_eq(event_log.get_parsed_text(), "", "Startup initially refreshes before game_started is appended") + + game._refresh_capture_hud() + assert_eq(character_title.text, "Visual Check") + assert_string_contains(event_log.get_parsed_text(), "Visual Check commence une nouvelle aventure.") diff --git a/tests/e2e/test_visual_capture_state_e2e.gd.uid b/tests/e2e/test_visual_capture_state_e2e.gd.uid new file mode 100644 index 0000000..2d47cda --- /dev/null +++ b/tests/e2e/test_visual_capture_state_e2e.gd.uid @@ -0,0 +1 @@ +uid://d00r2dqs4yi56 diff --git a/tests/e2e/test_visual_readability_e2e.gd b/tests/e2e/test_visual_readability_e2e.gd index 226498e..4dd1346 100644 --- a/tests/e2e/test_visual_readability_e2e.gd +++ b/tests/e2e/test_visual_readability_e2e.gd @@ -8,17 +8,128 @@ func before_each() -> void: add_child_autofree(game) await get_tree().process_frame -func test_real_game_scene_exposes_readable_fov_zoom_and_compact_hud() -> void: - var renderer := game.get_node("World/MapRenderer") as MapRenderer - var camera := game.get_node("Camera2D") as Camera2D - var hud := game.get_node("HUD") as GameHud - var results := game.submit_test_action(Vector2i.DOWN) - var central_play_area := Rect2(300, 120, 680, 480) +func test_real_game_scene_exposes_readable_fov_zoom_and_framed_center_viewport() -> void: + var renderer := game.get_node_or_null("World/MapRenderer") as MapRenderer + var camera := game.get_node_or_null("Camera2D") as Camera2D + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(renderer, "Game scene requires World/MapRenderer") + assert_not_null(camera, "Game scene requires Camera2D") + assert_not_null(hud, "Game scene requires HUD") + if renderer == null or camera == null or hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + _assert_legacy_panel_paths(layout) + + var top_bar := layout.get_node_or_null("TopBar") as Control + var left_rail := layout.get_node_or_null("LeftRail") as Control + var play_area_frame := layout.get_node_or_null("PlayAreaFrame") as Control + var right_rail := layout.get_node_or_null("RightRail") as Control + var command_bar := layout.get_node_or_null("CommandBar") as Control + assert_not_null(top_bar, "ResponsiveLayout requires a TopBar") + assert_not_null(left_rail, "ResponsiveLayout requires a LeftRail") + assert_not_null(play_area_frame, "ResponsiveLayout requires a PlayAreaFrame") + assert_not_null(right_rail, "ResponsiveLayout requires a RightRail") + assert_not_null(command_bar, "ResponsiveLayout requires a CommandBar") + if top_bar == null or left_rail == null or play_area_frame == null or right_rail == null or command_bar == null: + return + + var results := game.submit_test_action(Vector2i.DOWN) + assert_gte(results.size(), 1, "the real game action must produce a result") + if results.is_empty(): + return assert_eq(results[0].kind, &"moved") assert_eq(camera.zoom, Vector2(2.0, 2.0)) assert_eq(renderer.get_cell_render_color(Vector2i(4, 12)), Color.WHITE) assert_eq(renderer.get_cell_render_color(Vector2i(29, 19)), renderer.UNKNOWN_COLOR) - for panel_name in [&"StatsPanel", &"LogPanel", &"PromptPanel", &"HelpPanel"]: - var panel := hud.get_node("ResponsiveLayout/" + String(panel_name)) as PanelContainer - assert_false(panel.get_global_rect().intersects(central_play_area), "%s obscures the central play area" % panel_name) + _assert_play_area_is_centered_and_inside_effective_viewport(play_area_frame) + var play_rect := play_area_frame.get_global_rect() + for region: Control in [top_bar, left_rail, right_rail, command_bar]: + assert_false(region.get_global_rect().intersects(play_rect), "%s obscures the framed center viewport" % region.name) + +func test_live_scene_has_an_unmasked_central_camera_view_and_named_non_overlapping_rail_sections() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + var camera := game.get_node_or_null("Camera2D") as Camera2D + assert_not_null(hud, "Game scene requires HUD") + assert_not_null(camera, "Game scene requires Camera2D") + if hud == null or camera == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + var artboard := layout.get_node_or_null("Artboard") as Control + var play_area := layout.get_node_or_null("PlayAreaFrame") as Control + assert_not_null(artboard, "ResponsiveLayout requires Artboard") + assert_not_null(play_area, "ResponsiveLayout requires PlayAreaFrame") + if artboard == null or play_area == null: + return + + # Camera2D retains Godot's single viewport. The observable opaque HUD masks + # establish the real play boundary while its focal centre stays centred there. + assert_lte(play_area.get_global_rect().get_center().distance_to(get_viewport().get_visible_rect().get_center()), 2.0) + _assert_live_named_sections(layout, "LeftRail", ["CharacterSection", "ObjectivesSection", "StatusSection"]) + _assert_live_named_sections(layout, "RightRail", ["JournalSection", "MapSection"]) + _assert_live_play_area_masks(layout, artboard.get_global_rect(), play_area.get_global_rect()) + +func _assert_live_named_sections(layout: Control, rail_name: String, names: Array[String]) -> void: + var rail := layout.get_node_or_null(rail_name) as Control + assert_not_null(rail, "ResponsiveLayout requires %s" % rail_name) + if rail == null: + return + var sections: Array[Control] = [] + for section_name in names: + var section := layout.get_node_or_null(section_name) as Control + assert_not_null(section, "%s must expose a named %s section" % [rail_name, section_name]) + if section == null: + continue + assert_true(section.visible, "%s must be visible in the real game scene" % section_name) + assert_true(rail.get_global_rect().encloses(section.get_global_rect()), "%s must stay inside %s" % [section_name, rail_name]) + sections.append(section) + for index in sections.size(): + for other_index in range(index + 1, sections.size()): + assert_false(sections[index].get_global_rect().intersects(sections[other_index].get_global_rect()), "%s overlaps %s" % [sections[index].name, sections[other_index].name]) + +func _assert_live_play_area_masks(layout: Control, artboard_rect: Rect2, play_rect: Rect2) -> void: + var expected_masks := { + "PlayAreaMaskTop": Rect2(artboard_rect.position, Vector2(artboard_rect.size.x, play_rect.position.y - artboard_rect.position.y)), + "PlayAreaMaskLeft": Rect2(Vector2(artboard_rect.position.x, play_rect.position.y), Vector2(play_rect.position.x - artboard_rect.position.x, play_rect.size.y)), + "PlayAreaMaskRight": Rect2(Vector2(play_rect.end.x, play_rect.position.y), Vector2(artboard_rect.end.x - play_rect.end.x, play_rect.size.y)), + "PlayAreaMaskBottom": Rect2(Vector2(artboard_rect.position.x, play_rect.end.y), Vector2(artboard_rect.size.x, artboard_rect.end.y - play_rect.end.y)), + } + for mask_name: String in expected_masks: + var mask := layout.get_node_or_null(mask_name) as Panel + assert_not_null(mask, "Real-game HUD requires %s" % mask_name) + if mask == null: + continue + assert_eq(mask.get_global_rect(), expected_masks[mask_name], "%s must exactly cover its artboard band outside PlayAreaFrame" % mask_name) + assert_false(mask.get_global_rect().intersects(play_rect), "%s must leave the PlayAreaFrame interior visible" % mask_name) + var style := mask.get_theme_stylebox(&"panel") + assert_true(style is StyleBoxTexture, "%s requires the textured dungeon background style" % mask_name) + if style is StyleBoxTexture: + var texture_style := style as StyleBoxTexture + assert_not_null(texture_style.texture, "%s requires a visible dungeon background texture" % mask_name) + assert_eq(texture_style.modulate_color.a, 1.0, "%s must remain fully opaque" % mask_name) + +func _assert_legacy_panel_paths(layout: Control) -> void: + assert_not_null(layout.get_node_or_null("StatsPanel") as PanelContainer, "HUD must preserve ResponsiveLayout/StatsPanel") + assert_not_null(layout.get_node_or_null("LogPanel") as PanelContainer, "HUD must preserve ResponsiveLayout/LogPanel because GameHud uses that path") + assert_not_null(layout.get_node_or_null("PromptPanel") as PanelContainer, "HUD must preserve ResponsiveLayout/PromptPanel") + assert_not_null(layout.get_node_or_null("HelpPanel") as PanelContainer, "HUD must preserve ResponsiveLayout/HelpPanel") + +func _assert_play_area_is_centered_and_inside_effective_viewport(play_area_frame: Control) -> void: + var viewport_rect := get_viewport().get_visible_rect() + var expected_viewport := Vector2(Game.REFERENCE_VIEWPORT) + var play_rect := play_area_frame.get_global_rect() + assert_eq(viewport_rect.size, expected_viewport, "HUD layout is evaluated in the effective 1920x1080 viewport") + assert_gte(play_rect.position.x, viewport_rect.position.x, "PlayAreaFrame must stay inside the viewport on the left") + assert_gte(play_rect.position.y, viewport_rect.position.y, "PlayAreaFrame must stay inside the viewport at the top") + assert_lte(play_rect.end.x, viewport_rect.end.x, "PlayAreaFrame must stay inside the viewport on the right") + assert_lte(play_rect.end.y, viewport_rect.end.y, "PlayAreaFrame must stay inside the viewport at the bottom") + assert_gte(play_rect.size.x, viewport_rect.size.x * 0.40, "PlayAreaFrame must have meaningful viewport width") + assert_gte(play_rect.size.y, viewport_rect.size.y * 0.40, "PlayAreaFrame must have meaningful viewport height") + assert_gte(play_rect.get_area(), viewport_rect.get_area() * 0.25, "PlayAreaFrame must occupy a meaningful part of the viewport") + assert_lte(play_rect.get_center().distance_to(viewport_rect.get_center()), 2.0, "PlayAreaFrame must be centered in the effective viewport") diff --git a/tests/scripts/test_godot_import_runners.sh b/tests/scripts/test_godot_import_runners.sh index e2e7ba8..7cb28b3 100755 --- a/tests/scripts/test_godot_import_runners.sh +++ b/tests/scripts/test_godot_import_runners.sh @@ -17,9 +17,11 @@ if [[ " $* " == *" --import "* ]]; then printf '%s\n' "fake import output" >&2 exit "${FAKE_IMPORT_STATUS:-0}" fi -if [[ " $* " == *" --capture "* || " $* " == *" --capture-exit "* ]]; then +if [[ " $* " == *" --capture "* || " $* " == *" --capture-exit "* || " $* " == *" --visual-check-compact "* ]]; then if [[ " $* " == *" --capture-exit "* ]]; then capture_name="visual-check-exit.png" + elif [[ " $* " == *" --visual-check-compact "* ]]; then + capture_name="visual-check-compact.png" else capture_name="visual-check.png" fi @@ -30,10 +32,13 @@ import sys import zlib os.makedirs("artifacts", exist_ok=True) -width, height = 1920, 1080 +compact = sys.argv[1] == "visual-check-compact.png" +width, height = (1280, 720) if compact else (1920, 1080) unknown = (1, 2, 5) visible = (176, 176, 176) -explored = (19, 29, 39) +# Match the blue-black explored tile palette accepted by the real capture +# validator; do not model it as a single renderer-specific RGB tuple. +explored = (9, 14, 23) def pixel_for_x(x): if x < width // 3: return unknown @@ -72,6 +77,18 @@ assert_import_precedes_run() { } } +visual_log="$tmp_dir/run-visual-check.sh.log" +FAKE_GODOT_LOG="$visual_log" GODOT_BIN="$fake_godot" DISPLAY=:99 "$project_dir/scripts/run-visual-check.sh" +compact_run="$(grep -- '--visual-check-compact' "$visual_log")" +[[ "$compact_run" == *"--windowed"* && "$compact_run" == *"--resolution 1280x720"* ]] || { + echo "run-visual-check.sh did not request a real 1280x720 compact window" >&2 + exit 1 +} +[[ -s "$project_dir/artifacts/visual-check-compact.png" ]] || { + echo "run-visual-check.sh did not produce a compact capture" >&2 + exit 1 +} + assert_import_precedes_run test-unit.sh assert_import_precedes_run test-e2e.sh assert_import_precedes_run run-visual-check.sh diff --git a/tests/unit/test_action_router.gd b/tests/unit/test_action_router.gd index ced7ba8..22fef66 100644 --- a/tests/unit/test_action_router.gd +++ b/tests/unit/test_action_router.gd @@ -30,6 +30,16 @@ func test_f_starts_ranged_targeting_and_ctrl_s_or_v_requests_a_manual_save() -> assert_eq(router.action_from_input(_action_event(&"ranged")).kind, &"ranged") assert_eq(router.action_from_input(_action_event(&"save")).kind, &"save") +func test_character_opens_with_physical_c_while_p_is_free_and_southeast_uses_keypad_3() -> void: + var character_c := _key_event(KEY_C) + var legacy_character_p := _key_event(KEY_P) + var southeast_keypad_3 := _key_event(KEY_KP_3) + + assert_true(InputMap.action_has_event(&"character", character_c), "C is the physical character-sheet binding") + assert_false(InputMap.action_has_event(&"character", legacy_character_p), "P must no longer open the character sheet") + assert_true(InputMap.action_has_event(&"move_southeast", southeast_keypad_3), "South-east is bound to keypad 3") + assert_false(InputMap.action_has_event(&"move_southeast", character_c), "C must no longer move south-east") + func test_action_from_input_maps_the_complete_command_vocabulary() -> void: var router := ActionRouter.new(null) var expected := { diff --git a/tests/unit/test_combat_presentation.gd b/tests/unit/test_combat_presentation.gd index 720568e..ee4dad6 100644 --- a/tests/unit/test_combat_presentation.gd +++ b/tests/unit/test_combat_presentation.gd @@ -19,19 +19,40 @@ func test_combat_routes_damage_feedback_and_exposes_current_target_summary() -> var enemy_view := game.get_node("World/Enemies/Goblin") as ActorView hud.refresh(state, [], game.get_run_state()) - assert_eq(hud.combat_summary, "Target: Goblin HP: 6/6") + assert_eq(hud.combat_summary, "Gobelin — PV : 6/6") + assert_true((hud.get_node("EnemyHealthLabel") as Label).visible) + assert_eq((hud.get_node("EnemyHealthLabel") as Label).text, "Gobelin — PV : 6/6") + for label_name: String in ["CharacterStatusLabel", "SpellLabel", "CombatSummaryLabel", "DeadlineLabel"]: + var label := hud.get_node(label_name) as Label + assert_false(label.visible, "%s must stay hidden while only the target is actionable" % label_name) + assert_eq(label.text, "") game.submit_test_action(Vector2i.RIGHT) await _wait_for_feedback() assert_eq(player_view.last_damage, 2) - assert_eq(hud.combat_summary, "Target: Goblin HP: 6/6") + assert_string_contains(hud.combat_summary, "Gobelin") + assert_string_contains(hud.combat_summary, "PV") + assert_eq(hud.combat_summary.find("Target"), -1) + assert_eq(hud.combat_summary.find("HP"), -1) game.submit_test_action(Vector2i.RIGHT) await _wait_for_feedback() game.submit_test_action(Vector2i.RIGHT) await _wait_for_feedback() assert_false(is_instance_valid(enemy_view)) - assert_eq(hud.combat_summary, "No active target") - assert_string_contains(hud.event_log.get_parsed_text(), "with mains nues") + assert_eq(hud.combat_summary, "") + assert_eq((hud.get_node("EnemyHealthLabel") as Label).text, "") + assert_false((hud.get_node("EnemyHealthLabel") as Label).visible) + assert_eq(_visible_text_occurrences(hud, "Aucune cible active"), 0, "The no-target state must never expose a no-target placeholder") + assert_eq(_visible_text_occurrences(hud, "No active target"), 0, "The no-target state must never expose the English fallback") + assert_string_contains(hud.event_log.get_parsed_text(), "Vous frappez le gobelin avec mains nues") + +func _visible_text_occurrences(hud: GameHud, needle: String) -> int: + var occurrences := 0 + for node in hud.find_children("*", "Label", true, false): + var label := node as Label + if label != null and label.visible and label.text == needle: + occurrences += 1 + return occurrences func _wait_for_feedback() -> void: await get_tree().create_timer(0.32).timeout diff --git a/tests/unit/test_display_layout.gd b/tests/unit/test_display_layout.gd index 8c9f46a..e38b5a2 100644 --- a/tests/unit/test_display_layout.gd +++ b/tests/unit/test_display_layout.gd @@ -58,25 +58,105 @@ func test_map_renderer_returns_the_contract_cell_rectangle() -> void: assert_eq(renderer.get_cell_rect(Vector2i(2, 3)), Rect2(64, 96, 32, 32)) -func test_camera_tracks_player_after_a_valid_action_and_uses_map_limits() -> void: +func test_minimap_root_is_enclosed_by_the_right_rail_at_reference_viewport() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var minimap := game.get_node("HUD/Minimap") as Minimap + var right_rail := game.get_node("HUD/ResponsiveLayout/RightRail") as Control + + assert_true(right_rail.get_global_rect().encloses(minimap.get_global_rect())) + +func test_camera_tracks_player_and_expands_limits_for_the_real_play_area() -> void: var game := GameScene.instantiate() as Game add_child_autofree(game) await get_tree().process_frame var camera := game.get_node("Camera2D") as Camera2D var state := game.get_game_state() + var play_area := game.get_node("HUD/ResponsiveLayout/PlayAreaFrame") as Control + var viewport_half := get_viewport().get_visible_rect().size / camera.zoom * 0.5 + var play_area_half := play_area.get_global_rect().size / camera.zoom * 0.5 + var limit_padding := viewport_half - play_area_half + var world := game.get_node("World") as Node2D + var map_size := Vector2(state.map.size * GameType.TILE_SIZE) - assert_eq(camera.position, Vector2(state.player.cell * GameType.TILE_SIZE) + game.get_node("World").position) + assert_eq(camera.position, Vector2(state.player.cell * GameType.TILE_SIZE) + world.position) assert_eq(camera.zoom, Vector2(2.0, 2.0)) assert_eq(GameType.TILE_SIZE, Vector2i(32, 32)) assert_eq(MapRendererType.TILE_SIZE, Vector2i(32, 32)) - assert_eq(camera.limit_left, 32) - assert_eq(camera.limit_top, 48) - assert_eq(camera.limit_right, 1376) - assert_eq(camera.limit_bottom, 560) + assert_eq(camera.limit_left, floori(world.position.x - limit_padding.x)) + assert_eq(camera.limit_top, floori(world.position.y - limit_padding.y)) + assert_eq(camera.limit_right, ceili(world.position.x + map_size.x + limit_padding.x)) + assert_eq(camera.limit_bottom, ceili(world.position.y + map_size.y + limit_padding.y)) game.submit_test_action(Vector2i.DOWN) - assert_eq(camera.position, Vector2(state.player.cell * GameType.TILE_SIZE) + game.get_node("World").position) + assert_eq(camera.position, Vector2(state.player.cell * GameType.TILE_SIZE) + world.position) + +func test_play_area_has_four_opaque_masks_that_cover_only_the_artboard_outside_the_frame() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout at %s" % viewport_size) + if layout == null: + return + var artboard := layout.get_node_or_null("Artboard") as Control + var play_area := layout.get_node_or_null("PlayAreaFrame") as Control + assert_not_null(artboard, "ResponsiveLayout requires Artboard at %s" % viewport_size) + assert_not_null(play_area, "ResponsiveLayout requires PlayAreaFrame at %s" % viewport_size) + if artboard == null or play_area == null: + return + + var artboard_rect := artboard.get_global_rect() + var play_rect := play_area.get_global_rect() + var expected_masks := { + "PlayAreaMaskTop": Rect2(artboard_rect.position, Vector2(artboard_rect.size.x, play_rect.position.y - artboard_rect.position.y)), + "PlayAreaMaskLeft": Rect2(Vector2(artboard_rect.position.x, play_rect.position.y), Vector2(play_rect.position.x - artboard_rect.position.x, play_rect.size.y)), + "PlayAreaMaskRight": Rect2(Vector2(play_rect.end.x, play_rect.position.y), Vector2(artboard_rect.end.x - play_rect.end.x, play_rect.size.y)), + "PlayAreaMaskBottom": Rect2(Vector2(artboard_rect.position.x, play_rect.end.y), Vector2(artboard_rect.size.x, artboard_rect.end.y - play_rect.end.y)), + } + for mask_name: String in expected_masks: + var mask := layout.get_node_or_null(mask_name) as Panel + assert_not_null(mask, "ResponsiveLayout requires %s at %s" % [mask_name, viewport_size]) + if mask == null: + continue + assert_true(mask.visible, "%s must be visible at %s" % [mask_name, viewport_size]) + assert_eq(mask.get_global_rect(), expected_masks[mask_name], "%s must exactly cover its outside-PlayAreaFrame band at %s" % [mask_name, viewport_size]) + assert_false(mask.get_global_rect().intersects(play_rect), "%s must not mask the PlayAreaFrame interior at %s" % [mask_name, viewport_size]) + var style := mask.get_theme_stylebox(&"panel") + assert_true(style is StyleBoxTexture, "%s requires the textured dungeon background style" % mask_name) + if style is StyleBoxTexture: + var texture_style := style as StyleBoxTexture + assert_not_null(texture_style.texture, "%s requires a visible dungeon background texture" % mask_name) + assert_eq(texture_style.modulate_color.a, 1.0, "%s must remain fully opaque" % mask_name) + +func test_camera_focal_center_aligns_with_the_unmasked_central_play_area() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node_or_null("HUD") as GameHud + var play_area := game.get_node_or_null("HUD/ResponsiveLayout/PlayAreaFrame") as Control + assert_not_null(hud, "Game scene requires HUD") + assert_not_null(play_area, "HUD requires ResponsiveLayout/PlayAreaFrame") + if hud == null or play_area == null: + return + + # Camera2D has one engine viewport; HUD masks define the actual visible world. + assert_lte(play_area.get_global_rect().get_center().distance_to(get_viewport().get_visible_rect().get_center()), 2.0) + for mask_name: String in ["PlayAreaMaskTop", "PlayAreaMaskLeft", "PlayAreaMaskRight", "PlayAreaMaskBottom"]: + var mask := hud.get_node_or_null("ResponsiveLayout/" + mask_name) as Panel + assert_not_null(mask, "HUD exposes the observable %s boundary" % mask_name) + if mask != null: + assert_false(mask.get_global_rect().intersects(play_area.get_global_rect())) func test_camera_limits_are_recomputed_when_entering_a_larger_generated_floor() -> void: var game := GameScene.instantiate() as Game @@ -84,14 +164,19 @@ func test_camera_limits_are_recomputed_when_entering_a_larger_generated_floor() await get_tree().process_frame var camera := game.get_node("Camera2D") as Camera2D var world := game.get_node("World") as Node2D + var play_area := game.get_node("HUD/ResponsiveLayout/PlayAreaFrame") as Control var state := game.get_game_state() state.player.cell = state.floor_state.exit game.submit_test_interact() + var viewport_half := get_viewport().get_visible_rect().size / camera.zoom * 0.5 + var play_area_half := play_area.get_global_rect().size / camera.zoom * 0.5 + var limit_padding := viewport_half - play_area_half + var map_size := Vector2(state.map.size * GameType.TILE_SIZE) assert_eq(game.get_run_state().current_floor, 1) - assert_eq(camera.limit_left, int(world.position.x)) - assert_eq(camera.limit_top, int(world.position.y)) - assert_eq(camera.limit_right, int(world.position.x) + state.map.size.x * GameType.TILE_SIZE.x) - assert_eq(camera.limit_bottom, int(world.position.y) + state.map.size.y * GameType.TILE_SIZE.y) + assert_eq(camera.limit_left, floori(world.position.x - limit_padding.x)) + assert_eq(camera.limit_top, floori(world.position.y - limit_padding.y)) + assert_eq(camera.limit_right, ceili(world.position.x + map_size.x + limit_padding.x)) + assert_eq(camera.limit_bottom, ceili(world.position.y + map_size.y + limit_padding.y)) assert_eq(camera.position, world.position + Vector2(state.player.cell * GameType.TILE_SIZE)) diff --git a/tests/unit/test_event_presenter.gd b/tests/unit/test_event_presenter.gd index fe6383c..3da6818 100644 --- a/tests/unit/test_event_presenter.gd +++ b/tests/unit/test_event_presenter.gd @@ -120,6 +120,7 @@ func test_major_domain_event_kinds_each_map_to_one_named_presentation_event() -> &"door_opened": &"door", &"chest_opened": &"chest", &"loot_taken": &"loot", + &"pickup_refused": &"loot", &"trap_triggered": &"trap", &"spell_cast_started": &"spell", &"quest_started": &"quest", diff --git a/tests/unit/test_hud_event_journal.gd b/tests/unit/test_hud_event_journal.gd index f7adb78..f516cb9 100644 --- a/tests/unit/test_hud_event_journal.gd +++ b/tests/unit/test_hud_event_journal.gd @@ -10,7 +10,9 @@ func test_hud_replaces_its_log_with_the_supplied_journal_events() -> void: var hud := game.get_node("HUD") as GameHud var state := game.get_game_state() - hud.refresh(state, [GameEvent.new(1, 0, &"moved", {}, "obsolete transient message")]) - hud.refresh(state, [GameEvent.new(2, 0, &"blocked", {}, "authoritative journal message")]) + hud.refresh(state, [ + GameEvent.new(1, 0, &"moved", {}, "obsolete transient message"), + GameEvent.new(2, 0, &"blocked", {}, "authoritative journal message"), + ]) - assert_eq(hud.event_log.get_parsed_text(), "authoritative journal message\n") + assert_eq(hud.event_log.get_parsed_text(), "Votre chemin est bloqué.\n") diff --git a/tests/unit/test_hud_journal_localization.gd b/tests/unit/test_hud_journal_localization.gd new file mode 100644 index 0000000..f21878f --- /dev/null +++ b/tests/unit/test_hud_journal_localization.gd @@ -0,0 +1,216 @@ +extends GutTest + +const GameScene = preload("res://scenes/Game.tscn") +const GameEvent = preload("res://scripts/domain/run/game_event.gd") + +func test_hud_localizes_current_structured_journal_events_without_using_the_english_source_message() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var events: Array[GameEvent] = [ + GameEvent.new(1, 0, &"game_started", {"player_name": "Ariane"}, "Ariane begins a new run."), + # Production events carry their destination as `to_cell`, not the legacy `to` key. + GameEvent.new(2, 0, &"moved", {"to_cell": Vector2i(6, 8)}, "You move to (6, 8).", &"player"), + GameEvent.new(3, 0, &"enemy_moved", {"to_cell": Vector2i(5, 8)}, "The goblin moves.", &"goblin", &"player"), + GameEvent.new(4, 0, &"blocked", {"to_cell": Vector2i(5, 7)}, "Your way is blocked.", &"player"), + GameEvent.new(5, 0, &"melee", {"damage": 3, "attack_method": "épée courte"}, "You strike the goblin with a short sword for 3.", &"player", &"goblin"), + GameEvent.new(6, 0, &"enemy_melee", {"damage": 2, "attack_method": "griffes"}, "The goblin hits you with claws for 2.", &"goblin", &"player"), + GameEvent.new(7, 0, &"enemy_defeated", {}, "The goblin is defeated.", &"goblin", &"player"), + GameEvent.new(8, 0, &"attack_started", {"attack_method": "épée courte"}, "You attack.", &"player", &"goblin"), + GameEvent.new(9, 0, &"attack_hit", {}, "You hit.", &"player", &"goblin"), + GameEvent.new(10, 0, &"damage_dealt", {"damage": 3}, "You deal 3 damage.", &"player", &"goblin"), + GameEvent.new(11, 0, &"actor_died", {}, "The goblin is defeated.", &"goblin", &"player"), + GameEvent.new(12, 0, &"xp_granted", {"xp": 12}, "You gain experience.", &"player", &"goblin"), + GameEvent.new(13, 0, &"loot_dropped", {"items": [{"item_id": &"consumable_bandage", "quantity": 2}, {"item_id": &"weapon_hunting_knife", "quantity": 1}], "gold": 12, "empty": false}, "Loot dropped.", &"goblin", &"player"), + GameEvent.new(14, 0, &"companion_intercepted", {}, "Your companion intercepts the attack.", &"goblin", &"companion"), + GameEvent.new(15, 0, &"companion_died", {}, "Your companion falls, but your run continues.", &"companion", &"player"), + GameEvent.new(16, 0, &"companion_moved", {}, "Your companion follows.", &"companion", &"player"), + GameEvent.new(17, 0, &"party_moved", {}, "The party moves.", &"player"), + GameEvent.new(18, 0, &"episode_published", {"number": 7}, "Episode 7 published."), + ] + + hud.refresh(state, events, game.get_run_state()) + + var journal_text := hud.event_log.get_parsed_text() + for expected: String in [ + "Ariane commence une nouvelle aventure.", + "Votre chemin est bloqué.", + "Vous frappez le gobelin avec épée courte et lui infligez 3 dégâts.", + "Le gobelin vous frappe avec griffes et vous inflige 2 dégâts.", + "Le gobelin est vaincu.", + "Vous attaquez le gobelin avec épée courte.", + "Vous touchez le gobelin.", + "Vous infligez 3 dégâts au gobelin.", + "Le gobelin succombe.", + "Vous gagnez 12 points d’expérience.", + "Butin — au sol : Bandage x2, Couteau de chasse x1 ; or récupéré : 12.", + "Votre familier intercepte l’attaque du gobelin.", + "Votre familier tombe, mais votre aventure continue.", + ]: + assert_string_contains(journal_text, expected) + for hidden_event: String in ["You move to (6, 8).", "The goblin moves.", "Your companion follows.", "The party moves.", "Vous vous déplacez vers (6, 8).", "Le gobelin se déplace.", "Votre familier vous suit.", "Épisode 7 publié.", "Episode 7 published."]: + assert_eq(journal_text.find(hidden_event), -1, "GameHud must omit movement and episode publication events from the journal even when they provide source messages") + for english_source: String in ["Ariane begins a new run.", "Your way is blocked.", "You strike the goblin with a short sword for 3.", "The goblin hits you with claws for 2.", "The goblin is defeated.", "You attack.", "You hit.", "You deal 3 damage.", "You gain experience.", "Loot dropped.", "Your companion intercepts the attack.", "Your companion falls, but your run continues."]: + assert_eq(journal_text.find(english_source), -1, "GameHud must localize %s from structured event data, not reuse its source message" % english_source) + for technical_id: String in ["consumable_bandage", "weapon_hunting_knife"]: + assert_eq(journal_text.find(technical_id), -1, "GameHud must resolve %s through the content catalog" % technical_id) + + +func test_hud_hides_movement_and_episode_publication_in_a_mixed_batch() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var events: Array[GameEvent] = [ + GameEvent.new(1, 0, &"moved", {"to_cell": Vector2i(5, 7)}, "You move.", &"player"), + GameEvent.new(1, 0, &"enemy_moved", {}, "The goblin moves.", &"goblin", &"player"), + GameEvent.new(1, 0, &"companion_moved", {}, "Your companion follows.", &"companion", &"player"), + GameEvent.new(1, 0, &"party_moved", {}, "The party moves.", &"player"), + GameEvent.new(1, 0, &"episode_published", {"number": 1}, "Episode 1 published."), + GameEvent.new(1, 0, &"blocked", {}, "Your way is blocked.", &"player"), + GameEvent.new(1, 0, &"loot_dropped", {"items": [], "gold": 4}, "Loot dropped.", &"goblin", &"player"), + GameEvent.new(1, 0, &"melee", {"damage": 3, "attack_method": "épée courte"}, "You strike.", &"player", &"goblin"), + ] + + hud.refresh(state, events, game.get_run_state()) + + assert_eq(hud.event_log.get_parsed_text(), "Votre chemin est bloqué.\nOr récupéré : 4.\nVous frappez le gobelin avec épée courte et lui infligez 3 dégâts.\n") + +func test_hud_distinguishes_dropped_enemy_items_from_immediately_collected_gold() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var cases: Array[Dictionary] = [ + {"payload": {"items": [{"item_id": &"consumable_bandage", "quantity": 1}], "gold": 26}, "expected": "Butin — au sol : Bandage x1 ; or récupéré : 26."}, + {"payload": {"items": [{"item_id": &"consumable_bandage", "quantity": 2}], "gold": 0}, "expected": "Butin au sol : Bandage x2."}, + {"payload": {"items": [], "gold": 8}, "expected": "Or récupéré : 8."}, + {"payload": {"items": [], "gold": 0, "empty": true}, "expected": "Aucun butin."}, + ] + for test_case: Dictionary in cases: + hud.refresh(state, [GameEvent.new(1, 0, &"loot_dropped", test_case.payload, "Loot dropped.", &"goblin", &"player")], game.get_run_state()) + assert_eq(hud.event_log.get_parsed_text(), "%s\n" % test_case.expected) + +func test_hud_describes_pickup_and_loot_take_outcomes_in_french() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var events: Array[GameEvent] = [ + GameEvent.new(1, 0, &"item_picked_up", {"item_id": &"consumable_bandage", "quantity": 2}, "Picked up consumable_bandage x2.", &"player"), + GameEvent.new(2, 0, &"pickup_refused", {"item_id": &"consumable_bandage", "quantity": 2, "reason": "inventory_full"}, "Inventory is full.", &"player"), + GameEvent.new(3, 0, &"pickup_refused", {"reason": "no_ground_item"}, "Nothing to pick up.", &"player"), + GameEvent.new(4, 0, &"loot_taken", {"items": [{"item_id": &"consumable_bandage", "quantity": 1}], "gold": 4, "ammunition": 3, "refused_items": [{"item_id": &"weapon_hunting_knife", "quantity": 1, "reason": "inventory_full"}]}, "Loot taken.", &"player"), + ] + + hud.refresh(state, events, game.get_run_state()) + + var journal_text := hud.event_log.get_parsed_text() + assert_string_contains(journal_text, "Ramassé : Bandage x2.") + assert_string_contains(journal_text, "Inventaire plein") + assert_string_contains(journal_text, "Rien à ramasser.") + assert_string_contains(journal_text, "Butin récupéré : Bandage x1, 4 or, 3 munitions récupérées") + assert_string_contains(journal_text, "Couteau de chasse x1 non ramassé (inventaire plein)") + for technical_id: String in ["consumable_bandage", "weapon_hunting_knife"]: + assert_eq(journal_text.find(technical_id), -1, "GameHud must never expose known item IDs") + +func test_hud_localizes_generated_enemy_ids_from_live_state_and_catalog_after_removal() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var generated_id := &"enemy_scavenger_07" + state.enemies[generated_id] = ActorState.new(generated_id, Vector2i(5, 8), 22, 5, &"enemy_scavenger") + + # Movement events are deliberately not journal entries, including generated enemies. + hud.refresh(state, [GameEvent.new(1, 0, &"enemy_moved", {}, "The scavenger moves.", generated_id, &"player")], game.get_run_state()) + assert_eq(hud.event_log.get_parsed_text(), "") + + state.enemies.erase(generated_id) + hud.refresh(state, [GameEvent.new(2, 0, &"enemy_melee", {"damage": 2, "attack_method": "griffes"}, "The scavenger hits you.", generated_id, &"player")], game.get_run_state()) + var removed_text := hud.event_log.get_parsed_text() + assert_string_contains(removed_text, "Le pillard efflanque vous frappe avec griffes et vous inflige 2 dégâts.") + assert_eq(removed_text.find("enemy_scavenger_07"), -1) + assert_eq(removed_text.find("_"), -1) + +func test_hud_omits_items_with_invalid_quantities() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + + assert_eq(hud._localized_item_quantity({"item_id": &"weapon_hunting_knife", "quantity": 0}), "") + assert_eq(hud._localized_item_quantity({"item_id": &"weapon_hunting_knife", "quantity": -2}), "") + +func test_hud_localizes_active_ranged_and_spell_events_without_english_domain_messages() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var target_id := &"enemy_scavenger_07" + state.enemies[target_id] = ActorState.new(target_id, Vector2i(5, 8), 22, 5, &"enemy_scavenger") + var cases: Array[Dictionary] = [ + {"kind": &"ranged", "payload": {"weapon_id": "weapon_hunting_bow", "damage": 4}, "expected": "Vous tirez sur le pillard efflanque"}, + {"kind": &"cast", "payload": {"spell_name": "Épines empoisonnées", "damage": 3}, "expected": "Vous lancez Épines empoisonnées"}, + {"kind": &"ranged_attack_started", "payload": {"weapon_id": "weapon_hunting_bow"}, "expected": "Vous préparez un tir"}, + {"kind": &"projectile_fired", "payload": {"weapon_id": "weapon_hunting_bow"}, "expected": "Vous tirez avec Arc de chasse"}, + {"kind": &"ranged_attack_hit", "payload": {}, "expected": "Votre tir atteint"}, + {"kind": &"invalid_ranged_target", "payload": {"reason": "no_ammunition"}, "expected": "plus de munitions"}, + {"kind": &"spell_targeting_started", "payload": {"spell_name": "Épines empoisonnées"}, "expected": "Choisissez la cible"}, + {"kind": &"spell_targeting_cancelled", "payload": {}, "expected": "Ciblage du sort annulé"}, + {"kind": &"invalid_spell_target", "payload": {"reason": "insufficient_focus"}, "expected": "Focus insuffisant"}, + {"kind": &"spell_cast_started", "payload": {"spell_name": "Épines empoisonnées"}, "expected": "Vous lancez Épines empoisonnées"}, + {"kind": &"spell_damage_dealt", "payload": {"spell_name": "Épines empoisonnées", "damage": 3}, "expected": "inflige 3 dégâts"}, + {"kind": &"spell_effect_applied", "payload": {"spell_name": "Épines empoisonnées", "status": "poison"}, "expected": "empoisonnement"}, + ] + for test_case: Dictionary in cases: + var source := "English source for %s." % String(test_case.kind) + var event := GameEvent.new(1, 0, test_case.kind, test_case.payload, source, &"player", target_id) + hud.refresh(state, [event], game.get_run_state()) + var journal_text := hud.event_log.get_parsed_text() + assert_string_contains(journal_text, String(test_case.expected), "French presentation expected for %s" % test_case.kind) + assert_eq(journal_text.find(source), -1, "HUD must not reuse English source for %s" % test_case.kind) + + for reason_case: Dictionary in [ + {"reason": "cooldown", "expected": "recharge"}, + {"reason": "insufficient_focus", "expected": "Focus insuffisant"}, + {"reason": "out_of_range", "expected": "hors de portée"}, + {"reason": "line_of_sight_blocked", "expected": "ligne de vue"}, + {"reason": "no_ammunition", "expected": "plus de munitions"}, + {"reason": "no_ranged_weapon", "expected": "arme à distance"}, + {"reason": "invalid_target", "expected": "cible invalide"}, + {"reason": "no_valid_spell_target", "expected": "aucune cible valide"}, + ]: + var event := GameEvent.new(1, 0, &"invalid_spell_target", {"reason": reason_case.reason}, "English invalid reason.", &"player", target_id) + hud.refresh(state, [event], game.get_run_state()) + assert_string_contains(hud.event_log.get_parsed_text(), String(reason_case.expected), "French reason expected for %s" % reason_case.reason) + +func test_hud_uses_french_spacing_for_focus_and_gold_labels() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + game.get_run_state().gold = 42 + hud.refresh(state, [], game.get_run_state()) + assert_eq(hud.player_focus_label.text, "Focus : %d/%d" % [state.player.focus, state.player.max_focus]) + assert_eq(hud.gold_label.text, "42") + +func test_hud_keeps_the_domain_message_for_unknown_journal_event_kinds() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var source_message := "An unknown event remains readable." + + hud.refresh(state, [GameEvent.new(1, 0, &"unknown_event", {}, source_message)], game.get_run_state()) + + assert_string_contains(hud.event_log.get_parsed_text(), source_message) diff --git a/tests/unit/test_hud_journal_localization.gd.uid b/tests/unit/test_hud_journal_localization.gd.uid new file mode 100644 index 0000000..d5058ad --- /dev/null +++ b/tests/unit/test_hud_journal_localization.gd.uid @@ -0,0 +1 @@ +uid://dx236r7u7q2nn diff --git a/tests/unit/test_hud_layout.gd b/tests/unit/test_hud_layout.gd index 43edeba..5c8d80c 100644 --- a/tests/unit/test_hud_layout.gd +++ b/tests/unit/test_hud_layout.gd @@ -1,6 +1,10 @@ extends GutTest const GameScene = preload("res://scenes/Game.tscn") +const StatusEffectType = preload("res://scripts/domain/combat/status_effect.gd") +const HEADER_VALUES_GROUP := &"hud_header_values" +const CHARACTER_VALUES_GROUP := &"hud_character_values" +const COMMAND_HINTS_GROUP := &"hud_command_hints" var game: Game func before_each() -> void: @@ -12,18 +16,27 @@ func test_help_band_displays_the_exact_control_labels() -> void: var help_label := game.get_node_or_null("HUD/HelpLabel") as Label assert_not_null(help_label) - assert_string_contains(help_label.text, "Déplacer : ZQSD / Flèches") - assert_string_contains(help_label.text, "nord-est : pavé num. 9") - assert_string_contains(help_label.text, "Interagir : Espace ou E") + if help_label == null: + return + assert_string_contains(help_label.text, "Déplacer") + assert_string_contains(help_label.text, "Interagir") + assert_string_contains(help_label.text, "Inventaire") + assert_string_contains(help_label.text, "Sauvegarde") + assert_string_contains(help_label.text, "Aide") func test_xp_bar_shows_progress_inside_the_current_level_and_refreshes_after_xp_gain() -> void: - var hud := game.get_node("HUD") as GameHud + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return var state := game.get_game_state() var xp_bar := hud.get_node_or_null("ExperienceBar") as ProgressBar var xp_label := hud.get_node_or_null("ExperienceLabel") as Label assert_not_null(xp_bar) assert_not_null(xp_label) + if xp_bar == null or xp_label == null: + return assert_eq(xp_bar.min_value, 0.0) assert_eq(xp_bar.max_value, 100.0) assert_eq(xp_bar.value, 0.0) @@ -36,73 +49,994 @@ func test_xp_bar_shows_progress_inside_the_current_level_and_refreshes_after_xp_ assert_eq(xp_bar.value, 25.0) assert_eq(xp_label.text, "Niveau 2 — XP 25/200") -func test_hud_uses_viewport_anchored_panels_with_distinct_stats_and_log_zones() -> void: - var hud := game.get_node("HUD") as GameHud +func test_hud_preserves_legacy_responsive_panel_paths() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return var layout := hud.get_node_or_null("ResponsiveLayout") as Control - var stats_panel := hud.get_node_or_null("ResponsiveLayout/StatsPanel") as PanelContainer - var log_panel := hud.get_node_or_null("ResponsiveLayout/LogPanel") as PanelContainer - var player_health := hud.get_node("PlayerHealthLabel") as Label - var enemy_health := hud.get_node("EnemyHealthLabel") as Label - var event_log := hud.get_node("EventLog") as RichTextLabel + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + + var stats_panel := layout.get_node_or_null("StatsPanel") as PanelContainer + var log_panel := layout.get_node_or_null("LogPanel") as PanelContainer + var prompt_panel := layout.get_node_or_null("PromptPanel") as PanelContainer + var help_panel := layout.get_node_or_null("HelpPanel") as PanelContainer + assert_not_null(stats_panel, "HUD must preserve ResponsiveLayout/StatsPanel") + assert_not_null(log_panel, "HUD must preserve ResponsiveLayout/LogPanel because GameHud uses that path") + assert_not_null(prompt_panel, "HUD must preserve ResponsiveLayout/PromptPanel") + assert_not_null(help_panel, "HUD must preserve ResponsiveLayout/HelpPanel") + if stats_panel == null or log_panel == null or prompt_panel == null or help_panel == null: + return + + var player_health := hud.get_node_or_null("PlayerHealthLabel") as Control + var event_log := hud.get_node_or_null("EventLog") as Control + var prompt := hud.get_node_or_null("ContextPromptLabel") as Control + var help := hud.get_node_or_null("HelpLabel") as Control + assert_not_null(player_health, "StatsPanel requires the existing health control") + assert_not_null(event_log, "LogPanel requires the existing event log") + assert_not_null(prompt, "PromptPanel requires the existing context prompt") + assert_not_null(help, "HelpPanel requires the existing help label") + if player_health == null or event_log == null or prompt == null or help == null: + return + assert_true(stats_panel.get_global_rect().encloses(player_health.get_global_rect())) + assert_true(log_panel.get_global_rect().encloses(event_log.get_global_rect())) + _assert_legacy_panel_is_transparent_and_behind(stats_panel) + _assert_legacy_panel_is_transparent_and_behind(log_panel) + assert_true(prompt_panel.get_global_rect().encloses(prompt.get_global_rect())) + assert_true(help_panel.get_global_rect().encloses(help.get_global_rect())) + +func test_hud_defines_a_full_frame_shell_with_a_significant_centered_play_area() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + + var top_bar := layout.get_node_or_null("TopBar") as Control + var left_rail := layout.get_node_or_null("LeftRail") as Control + var play_area_frame := layout.get_node_or_null("PlayAreaFrame") as Control + var right_rail := layout.get_node_or_null("RightRail") as Control + var command_bar := layout.get_node_or_null("CommandBar") as Control + assert_not_null(top_bar, "ResponsiveLayout requires a TopBar") + assert_not_null(left_rail, "ResponsiveLayout requires a LeftRail") + assert_not_null(play_area_frame, "ResponsiveLayout requires a PlayAreaFrame") + assert_not_null(right_rail, "ResponsiveLayout requires a RightRail") + assert_not_null(command_bar, "ResponsiveLayout requires a CommandBar") + if top_bar == null or left_rail == null or play_area_frame == null or right_rail == null or command_bar == null: + return - assert_not_null(layout) assert_eq(layout.anchor_right, 1.0) assert_eq(layout.anchor_bottom, 1.0) - assert_not_null(stats_panel) - assert_not_null(log_panel) - assert_true(stats_panel.get_global_rect().encloses(player_health.get_global_rect())) - assert_true(stats_panel.get_global_rect().encloses(enemy_health.get_global_rect())) - assert_true(log_panel.get_global_rect().encloses(event_log.get_global_rect())) - assert_false(stats_panel.get_global_rect().intersects(log_panel.get_global_rect())) - var visible_stats: Array[Control] = [ - hud.get_node("PlayerHealthLabel"), - hud.get_node("PlayerFocusLabel"), - hud.get_node("ExperienceBar"), - hud.get_node("GoldLabel"), - hud.get_node("QuestTrackerLabel"), - hud.get_node("SpellLabel"), - hud.get_node("EnemyHealthLabel"), - hud.get_node("CombatSummaryLabel"), - hud.get_node("DeadlineLabel"), - ] - for first_index in range(visible_stats.size()): - for second_index in range(first_index + 1, visible_stats.size()): - assert_false( - visible_stats[first_index].get_global_rect().intersects(visible_stats[second_index].get_global_rect()), - "%s and %s must not overlap" % [visible_stats[first_index].name, visible_stats[second_index].name] - ) + _assert_play_area_is_centered_and_inside_effective_viewport(play_area_frame) + var play_rect := play_area_frame.get_global_rect() + assert_false(left_rail.get_global_rect().intersects(play_rect), "LeftRail must not cover the framed play area") + assert_false(right_rail.get_global_rect().intersects(play_rect), "RightRail must not cover the framed play area") + assert_false(top_bar.get_global_rect().intersects(play_rect), "TopBar must not cover the framed play area") + assert_false(command_bar.get_global_rect().intersects(play_rect), "CommandBar must not cover the framed play area") + assert_false(left_rail.get_global_rect().intersects(right_rail.get_global_rect()), "the two rails must be distinct") + assert_false(top_bar.get_global_rect().intersects(command_bar.get_global_rect()), "the top and command bars must be distinct") + +func test_live_hud_content_is_enclosed_by_its_intended_shell_region() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + var top_bar := layout.get_node_or_null("TopBar") as Control + var left_rail := layout.get_node_or_null("LeftRail") as Control + var right_rail := layout.get_node_or_null("RightRail") as Control + var command_bar := layout.get_node_or_null("CommandBar") as Control + assert_not_null(top_bar, "ResponsiveLayout requires a TopBar") + assert_not_null(left_rail, "ResponsiveLayout requires a LeftRail") + assert_not_null(right_rail, "ResponsiveLayout requires a RightRail") + assert_not_null(command_bar, "ResponsiveLayout requires a CommandBar") + if top_bar == null or left_rail == null or right_rail == null or command_bar == null: + return + + _assert_controls_enclosed(top_bar, [ + hud.get_node_or_null("AchievementToast") as Control, + hud.get_node_or_null("TitleLabel") as Control, + ] + _controls_in_group(hud, HEADER_VALUES_GROUP), "TopBar") + _assert_controls_enclosed(left_rail, [ + hud.get_node_or_null("PlayerHealthLabel") as Control, + hud.get_node_or_null("PlayerFocusLabel") as Control, + hud.get_node_or_null("ExperienceBar") as Control, + hud.get_node_or_null("ExperienceLabel") as Control, + hud.get_node_or_null("GoldLabel") as Control, + hud.get_node_or_null("QuestTrackerLabel") as Control, + hud.get_node_or_null("SpellLabel") as Control, + hud.get_node_or_null("EnemyHealthLabel") as Control, + hud.get_node_or_null("CombatSummaryLabel") as Control, + hud.get_node_or_null("DeadlineLabel") as Control, + ] + _controls_in_group(hud, CHARACTER_VALUES_GROUP), "LeftRail") + _assert_controls_enclosed(right_rail, [hud.get_node_or_null("EventLog") as Control], "RightRail") + _assert_controls_enclosed(command_bar, _controls_in_group(hud, COMMAND_HINTS_GROUP), "CommandBar") + +func test_dynamic_hud_groups_refresh_live_character_and_command_values_without_a_redundant_header() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + var left_rail := layout.get_node_or_null("LeftRail") as Control + var command_bar := layout.get_node_or_null("CommandBar") as Control + var header_values := hud.get_node_or_null("HeaderValuesLabel") as Label + assert_not_null(left_rail) + assert_not_null(command_bar) + assert_not_null(header_values, "Legacy HeaderValuesLabel remains an explicitly hidden empty compatibility control") + if left_rail == null or command_bar == null or header_values == null: + return -func test_long_deadline_text_wraps_and_stays_inside_the_stats_panel() -> void: - var hud := game.get_node("HUD") as GameHud var state := game.get_game_state() var run := game.get_run_state() - run.current_floor = 1 - run.ensure_floor_deadline(1) + run.player_name = "Dame Ysabel" + state.player.hit_points = state.player.max_hit_points - 1 + state.player.cell = state.floor_state.entrance hud.refresh(state, [], run) + + var character_values := _labels_in_group(hud, CHARACTER_VALUES_GROUP) + var command_hints := _labels_in_group(hud, COMMAND_HINTS_GROUP) + assert_gte(character_values.size(), 1, "LeftRail exposes dynamic character values through the hud_character_values group") + assert_gte(command_hints.size(), 1, "CommandBar exposes dynamic hints through the hud_command_hints group") + assert_false(header_values.visible, "HeaderValuesLabel must not duplicate top-bar information") + assert_eq(header_values.text, "", "HeaderValuesLabel must be empty when hidden") + if character_values.is_empty() or command_hints.is_empty(): + return + assert_string_contains(_combined_label_text(character_values), str(state.player.hit_points)) + _assert_controls_enclosed(left_rail, character_values, "LeftRail") + + state.player.cell = Vector2i(35, 7) + hud.refresh(state, [], run) + assert_string_contains(_combined_label_text(command_hints), hud.get_context_prompt()) + assert_string_contains(_combined_label_text(command_hints), "Ouvrir la porte") + _assert_controls_enclosed(command_bar, command_hints, "CommandBar") + +func test_compact_1280_layout_keeps_the_hidden_legacy_header_out_of_the_top_bar_content() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + hud.apply_viewport_layout(Vector2(1280, 720)) + var header := hud.get_node_or_null("HeaderValuesLabel") as Label + assert_not_null(header, "HUD retains HeaderValuesLabel as a compatibility node") + if header == null: + return + assert_false(header.visible, "The compact TopBar must not revive the removed header values") + assert_eq(header.text, "") + +func test_compact_1280_layout_contains_live_hud_regions_without_covering_the_play_area() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + hud.apply_viewport_layout(Vector2(1280, 720)) await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var minimap := hud.get_node_or_null("Minimap") as Minimap + assert_not_null(layout, "HUD requires ResponsiveLayout") + assert_not_null(minimap, "HUD requires its live minimap") + if layout == null or minimap == null: + return + var top_bar := layout.get_node_or_null("TopBar") as Control + var left_rail := layout.get_node_or_null("LeftRail") as Control + var play_area := layout.get_node_or_null("PlayAreaFrame") as Control + var right_rail := layout.get_node_or_null("RightRail") as Control + var command_bar := layout.get_node_or_null("CommandBar") as Control + var stats_panel := layout.get_node_or_null("StatsPanel") as Control + var log_panel := layout.get_node_or_null("LogPanel") as Control + var prompt_panel := layout.get_node_or_null("PromptPanel") as Control + var help_panel := layout.get_node_or_null("HelpPanel") as Control + var quick_slots := layout.get_node_or_null("QuickSlotStrip") as Control + assert_not_null(top_bar) + assert_not_null(left_rail) + assert_not_null(play_area) + assert_not_null(right_rail) + assert_not_null(command_bar) + assert_not_null(stats_panel) + assert_not_null(log_panel) + assert_not_null(prompt_panel) + assert_not_null(help_panel) + assert_not_null(quick_slots) + if top_bar == null or left_rail == null or play_area == null or right_rail == null or command_bar == null or stats_panel == null or log_panel == null or prompt_panel == null or help_panel == null or quick_slots == null: + return - var stats_panel := hud.get_node("ResponsiveLayout/StatsPanel") as PanelContainer - var deadline := hud.get_node("DeadlineLabel") as Label - assert_true(stats_panel.get_global_rect().encloses(deadline.get_global_rect())) - assert_lte(deadline.get_minimum_size().x, deadline.size.x) - assert_gt(deadline.size.y, deadline.get_line_height()) + _assert_controls_enclosed(top_bar, [ + hud.get_node_or_null("AchievementToast") as Control, + hud.get_node_or_null("TitleLabel") as Control, + hud.get_node_or_null("HeaderValuesLabel") as Control, + ], "compact TopBar") + _assert_controls_enclosed(left_rail, [ + stats_panel, + hud.get_node_or_null("PlayerHealthLabel") as Control, + hud.get_node_or_null("HealthBar") as Control, + hud.get_node_or_null("PlayerFocusLabel") as Control, + hud.get_node_or_null("FocusBar") as Control, + hud.get_node_or_null("ExperienceBar") as Control, + hud.get_node_or_null("ExperienceLabel") as Control, + hud.get_node_or_null("CharacterStatusLabel") as Control, + hud.get_node_or_null("GoldLabel") as Control, + hud.get_node_or_null("QuestTrackerLabel") as Control, + hud.get_node_or_null("SpellLabel") as Control, + hud.get_node_or_null("EnemyHealthLabel") as Control, + hud.get_node_or_null("CombatSummaryLabel") as Control, + hud.get_node_or_null("DeadlineLabel") as Control, + ], "compact LeftRail") + _assert_controls_enclosed(right_rail, [ + log_panel, + hud.get_node_or_null("EventLog") as Control, + minimap, + ], "compact RightRail") + _assert_controls_enclosed(command_bar, [prompt_panel, help_panel, quick_slots, + hud.get_node_or_null("ContextPromptLabel") as Control, + hud.get_node_or_null("HelpLabel") as Control, + layout.get_node_or_null("QuickSlotHint") as Control, + ], "compact CommandBar") -func test_compact_hud_leaves_a_dominant_unobstructed_central_play_area() -> void: - var hud := game.get_node("HUD") as GameHud - var stats_panel := hud.get_node("ResponsiveLayout/StatsPanel") as PanelContainer - var log_panel := hud.get_node("ResponsiveLayout/LogPanel") as PanelContainer - var prompt_panel := hud.get_node("ResponsiveLayout/PromptPanel") as PanelContainer - var help_panel := hud.get_node("ResponsiveLayout/HelpPanel") as PanelContainer - var panels: Array[PanelContainer] = [stats_panel, log_panel, prompt_panel, help_panel] - var occupied_area := 0.0 - var central_play_area := Rect2( - Game.REFERENCE_VIEWPORT.x * 0.25, - Game.REFERENCE_VIEWPORT.y * 0.17, - Game.REFERENCE_VIEWPORT.x * 0.5, - Game.REFERENCE_VIEWPORT.y * 0.66 - ) - for panel in panels: - var panel_rect: Rect2 = panel.get_global_rect() - occupied_area += panel_rect.get_area() - assert_false(panel_rect.intersects(central_play_area), "%s obscures the central play area" % panel.name) - assert_lte(occupied_area, float(Game.REFERENCE_VIEWPORT.x * Game.REFERENCE_VIEWPORT.y) * 0.18) + for shell: Control in [top_bar, left_rail, right_rail, command_bar]: + assert_false(shell.get_global_rect().intersects(play_area.get_global_rect()), "%s must not cover the compact PlayAreaFrame" % shell.name) + assert_false(minimap.get_global_rect().intersects(play_area.get_global_rect()), "The compact minimap must remain off the PlayAreaFrame") + + for label: Label in [ + hud.get_node_or_null("HeaderValuesLabel") as Label, + hud.get_node_or_null("PlayerHealthLabel") as Label, + hud.get_node_or_null("PlayerFocusLabel") as Label, + hud.get_node_or_null("ExperienceLabel") as Label, + hud.get_node_or_null("ContextPromptLabel") as Label, + hud.get_node_or_null("HelpLabel") as Label, + ]: + assert_not_null(label) + if label != null: + assert_gte(label.get_theme_font_size(&"font_size"), 9, "%s must keep a readable compact font" % label.name) + var journal := hud.get_node_or_null("EventLog") as RichTextLabel + var journal_title := layout.get_node_or_null("JournalSectionTitle") as Label + var character_title := layout.get_node_or_null("CharacterSectionTitle") as Label + assert_not_null(journal) + assert_not_null(journal_title) + assert_not_null(character_title) + if journal != null: + var journal_font_size := journal.get_theme_font_size(&"normal_font_size") + assert_gte(journal_font_size, 12, "The compact journal must retain a 12px normal font") + assert_gte(journal.size.y / journal_font_size, 12.0, "The compact journal must retain at least twelve lines of visible space") + if journal_title != null: + assert_gte(journal_title.get_theme_font_size(&"font_size"), 14, "The compact journal title must remain readable") + if character_title != null: + assert_gte(character_title.get_theme_font_size(&"font_size"), 14, "The compact character title must remain readable") + +func test_non_sixteen_by_nine_viewports_center_the_artboard_and_mask_every_outside_band() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + for viewport_size: Vector2 in [Vector2(1024, 768), Vector2(2560, 1080)]: + hud.apply_viewport_layout(viewport_size) + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var artboard := layout.get_node_or_null("Artboard") as Control if layout != null else null + assert_not_null(artboard, "ResponsiveLayout requires its centered 16:9 Artboard") + if layout == null or artboard == null: + return + var scale := minf(viewport_size.x / GameHud.REFERENCE_VIEWPORT.x, viewport_size.y / GameHud.REFERENCE_VIEWPORT.y) + var expected_size := GameHud.REFERENCE_VIEWPORT * scale + var expected_origin := (viewport_size - expected_size) * 0.5 + assert_eq(artboard.position, expected_origin, "The artboard must be centered at %s" % viewport_size) + assert_eq(artboard.size, expected_size, "The artboard must preserve a 16:9 size at %s" % viewport_size) + + var artboard_rect := artboard.get_global_rect() + for shell_name: String in ["TopBar", "LeftRail", "PlayAreaFrame", "RightRail", "CommandBar"]: + var shell := layout.get_node_or_null(shell_name) as Control + assert_not_null(shell) + if shell != null: + assert_true(artboard_rect.encloses(shell.get_global_rect()), "%s must remain inside the 16:9 artboard" % shell_name) + + for band_name: String in ["LetterboxTop", "LetterboxBottom", "PillarboxLeft", "PillarboxRight"]: + var band := layout.get_node_or_null(band_name) as Panel + assert_not_null(band, "ResponsiveLayout requires %s" % band_name) + if band != null and band.size.x > 0.0 and band.size.y > 0.0: + var style := band.get_theme_stylebox(&"panel") as StyleBoxFlat + assert_not_null(style, "%s needs an explicit opaque panel style" % band_name) + if style != null: + assert_eq(style.bg_color.a, 1.0, "%s must be opaque so the world cannot show through" % band_name) + assert_false(band.get_global_rect().intersects(artboard_rect), "%s must cover only the outside band" % band_name) + + var top := layout.get_node_or_null("LetterboxTop") as Control + var bottom := layout.get_node_or_null("LetterboxBottom") as Control + var left := layout.get_node_or_null("PillarboxLeft") as Control + var right := layout.get_node_or_null("PillarboxRight") as Control + if viewport_size == Vector2(1024, 768): + assert_eq(top.size, Vector2(1024, 96), "1024x768 needs a fully covered top letterbox") + assert_eq(bottom.size, Vector2(1024, 96), "1024x768 needs a fully covered bottom letterbox") + assert_eq(left.size.x, 0.0) + assert_eq(right.size.x, 0.0) + else: + assert_eq(left.size, Vector2(320, 1080), "ultrawide needs a fully covered left pillarbox") + assert_eq(right.size, Vector2(320, 1080), "ultrawide needs a fully covered right pillarbox") + assert_eq(top.size.y, 0.0) + assert_eq(bottom.size.y, 0.0) + +func test_status_section_only_shows_actionable_information_without_a_floor_zero_placeholder() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var state := game.get_game_state() + var run := game.get_run_state() + state.enemies.clear() + run.current_floor = 0 + hud.refresh(state, [], run) + var status := hud.get_node_or_null("ResponsiveLayout/StatusSection") as Control + var status_title := hud.get_node_or_null("ResponsiveLayout/StatusSectionTitle") as Label + assert_not_null(status) + assert_not_null(status_title) + if status_title != null: + assert_true(status_title.visible) + assert_eq(status_title.text, "ÉTAT") + for label_name: String in ["CharacterStatusLabel", "EnemyHealthLabel", "CombatSummaryLabel", "SpellLabel", "DeadlineLabel"]: + var label := hud.get_node_or_null(label_name) as Label + assert_not_null(label, "HUD requires %s" % label_name) + if label != null: + assert_eq(label.text, "", "%s must be cleared in the neutral state" % label_name) + assert_false(label.visible, "%s must be hidden in the neutral state" % label_name) + assert_eq(hud.combat_summary, "") + assert_eq(_visible_text_occurrences(hud, "Aucune cible active"), 0) + assert_eq(_visible_text_occurrences(hud, "prêt à explorer"), 0) + +func test_status_section_formats_active_player_effects_in_french() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var state := game.get_game_state() + state.enemies.clear() + state.player.apply_status(StatusEffectType.new(&"poison", 3)) + state.player.apply_status(StatusEffectType.new(&"strengthened", 2)) + hud.refresh(state, [], game.get_run_state()) + var effects := hud.get_node_or_null("CharacterStatusLabel") as Label + assert_not_null(effects) + if effects == null: + return + assert_true(effects.visible) + assert_eq(effects.text, "Effets : Empoisonnement (3 tours), Renforcé (2 tours)") + assert_eq(effects.text.findn("prêt à explorer"), -1) + +func test_generated_visible_target_uses_catalog_name_and_never_reveals_hidden_enemies() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var state := game.get_game_state() + state.enemies.clear() + state.visible_cells.clear() + var nearest_visible := ActorState.new(&"enemy_scavenger_07", state.player.cell + Vector2i.RIGHT, 22, 5, &"enemy_scavenger") + var farther_visible := ActorState.new(&"enemy_scavenger_08", state.player.cell + Vector2i(3, 0), 22, 5, &"enemy_scavenger") + farther_visible.take_damage(5) + var nearer_hidden := ActorState.new(&"enemy_scavenger_hidden", state.player.cell + Vector2i.DOWN, 22, 5, &"enemy_scavenger") + state.enemies[nearest_visible.id] = nearest_visible + state.enemies[farther_visible.id] = farther_visible + state.enemies[nearer_hidden.id] = nearer_hidden + state.visible_cells[nearest_visible.cell] = true + state.visible_cells[farther_visible.cell] = true + hud.refresh(state, [], game.get_run_state()) + var target_label := hud.get_node_or_null("EnemyHealthLabel") as Label + assert_not_null(target_label) + if target_label == null: + return + assert_true(target_label.visible) + assert_eq(target_label.text, "Pillard efflanque — PV : 22/22") + assert_eq(target_label.text.find("enemy_scavenger_07"), -1, "HUD must never expose a technical actor id") + + state.visible_cells.erase(nearest_visible.cell) + hud.refresh(state, [], game.get_run_state()) + assert_true(target_label.visible) + assert_eq(target_label.text, "Pillard efflanque — PV : 17/22", "The next nearest visible living target must be selected") + + farther_visible.take_damage(farther_visible.hit_points) + hud.refresh(state, [], game.get_run_state()) + assert_false(target_label.visible, "A living enemy outside FOV must not be revealed") + assert_eq(target_label.text, "") + assert_eq(hud.combat_summary, "") + +func test_visible_status_labels_are_contained_separated_and_non_overlapping_at_reference_and_compact_sizes() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var state := game.get_game_state() + var run := game.get_run_state() + state.enemies.clear() + state.visible_cells.clear() + var target := ActorState.new(&"enemy_scavenger_07", state.player.cell + Vector2i.RIGHT, 22, 5, &"enemy_scavenger") + state.enemies[target.id] = target + state.visible_cells[target.cell] = true + for effect_key: StringName in StatusEffectType.DEFINITIONS.keys(): + state.player.apply_status(StatusEffectType.new(effect_key)) + run.current_floor = 1 + run.ensure_floor_deadline(1).turns_remaining = 15 * FloorDeadline.TURNS_PER_DAY + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + hud.refresh(state, [], run) + await get_tree().process_frame + var status := hud.get_node_or_null("ResponsiveLayout/StatusSection") as Control + var effects := hud.get_node_or_null("CharacterStatusLabel") as Label + var target_label := hud.get_node_or_null("EnemyHealthLabel") as Label + var deadline := hud.get_node_or_null("DeadlineLabel") as Label + assert_not_null(status) + assert_not_null(effects) + assert_not_null(target_label) + assert_not_null(deadline) + if status == null or effects == null or target_label == null or deadline == null: + continue + assert_true(effects.visible) + assert_true(target_label.visible) + assert_true(deadline.visible) + assert_string_contains(effects.text, "Empoisonnement") + assert_string_contains(effects.text, "Régénération") + for effect: StatusEffect in state.player.status_effects: + assert_string_contains(effects.text, str(effect.duration), "Every active effect duration must remain represented") + assert_lte(effects.get_minimum_size().x, effects.size.x, "Effects text must fit its assigned width at %s" % viewport_size) + assert_lte(effects.get_minimum_size().y, effects.size.y, "Effects text must fit its assigned height at %s" % viewport_size) + var visible_labels := _visible_status_labels(hud) + assert_eq(visible_labels.size(), 3, "The configured state must expose exactly effects, target, and deadline") + for label: Label in visible_labels: + assert_true(status.get_global_rect().encloses(label.get_global_rect()), "%s must stay inside StatusSection at %s" % [label.name, viewport_size]) + for index in visible_labels.size(): + for other_index in range(index + 1, visible_labels.size()): + var first := visible_labels[index].get_global_rect() + var second := visible_labels[other_index].get_global_rect() + assert_false(first.intersects(second), "%s must not overlap %s at %s" % [visible_labels[index].name, visible_labels[other_index].name, viewport_size]) + var upper := first if first.position.y <= second.position.y else second + var lower := second if upper == first else first + assert_gte(lower.position.y - upper.end.y, 12.0, "Visible status labels need at least 12px vertical separation at %s" % viewport_size) + +func test_deadline_label_is_hidden_on_floor_zero_and_uses_only_the_live_collapse_countdown_afterward() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var state := game.get_game_state() + var run := game.get_run_state() + var deadline := hud.get_node_or_null("DeadlineLabel") as Label + assert_not_null(deadline, "HUD requires DeadlineLabel") + if deadline == null: + return + + run.current_floor = 0 + hud.refresh(state, [], run) + assert_eq(deadline.text, "", "Floor zero has no collapse deadline") + assert_false(deadline.visible, "Floor zero must not show an empty deadline slot") + + run.current_floor = 1 + var floor_deadline := run.ensure_floor_deadline(1) + floor_deadline.turns_remaining = 15 * floor_deadline.TURNS_PER_DAY + hud.refresh(state, [], run) + assert_true(deadline.visible) + assert_eq(deadline.text, "Effondrement du niveau dans 15 jours") + assert_eq(deadline.text.findn("escalier"), -1, "DeadlineLabel must not mention stairs") + assert_eq(deadline.text.findn("Étage"), -1, "DeadlineLabel must not repeat the floor") + + floor_deadline.rest() + hud.refresh(state, [], run) + assert_eq(deadline.text, "Effondrement du niveau dans 14 jours", "The displayed count must follow the live deadline") + +func test_event_log_and_log_panel_never_intersect_the_hud_minimap_at_reference_and_compact_sizes() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var event_log := hud.get_node_or_null("EventLog") as Control + var minimap := hud.get_node_or_null("Minimap") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout at %s" % viewport_size) + assert_not_null(event_log, "HUD requires EventLog at %s" % viewport_size) + assert_not_null(minimap, "HUD requires Minimap at %s" % viewport_size) + if layout == null or event_log == null or minimap == null: + return + var log_panel := layout.get_node_or_null("LogPanel") as Control + assert_not_null(log_panel, "HUD requires ResponsiveLayout/LogPanel at %s" % viewport_size) + if log_panel == null: + return + + assert_false(event_log.get_global_rect().intersects(minimap.get_global_rect()), "EventLog must not intersect HUD/Minimap at %s" % viewport_size) + assert_false(log_panel.get_global_rect().intersects(minimap.get_global_rect()), "LogPanel must not intersect HUD/Minimap at %s" % viewport_size) + +func test_artboard_rails_and_center_follow_the_mockup_width_proportions() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout at %s" % viewport_size) + if layout == null: + return + var artboard := layout.get_node_or_null("Artboard") as Control + var left_rail := layout.get_node_or_null("LeftRail") as Control + var play_area := layout.get_node_or_null("PlayAreaFrame") as Control + var right_rail := layout.get_node_or_null("RightRail") as Control + assert_not_null(artboard, "ResponsiveLayout requires Artboard at %s" % viewport_size) + assert_not_null(left_rail, "ResponsiveLayout requires LeftRail at %s" % viewport_size) + assert_not_null(play_area, "ResponsiveLayout requires PlayAreaFrame at %s" % viewport_size) + assert_not_null(right_rail, "ResponsiveLayout requires RightRail at %s" % viewport_size) + if artboard == null or left_rail == null or play_area == null or right_rail == null: + return + + var left_ratio := left_rail.size.x / artboard.size.x + var center_ratio := play_area.size.x / artboard.size.x + var right_ratio := right_rail.size.x / artboard.size.x + assert_gte(left_ratio, 0.22, "LeftRail must use at least 22%% of the artboard width at %s" % viewport_size) + assert_lte(left_ratio, 0.26, "LeftRail must use at most 26%% of the artboard width at %s" % viewport_size) + assert_gte(center_ratio, 0.48, "PlayAreaFrame must use at least 48%% of the artboard width at %s" % viewport_size) + assert_lte(center_ratio, 0.56, "PlayAreaFrame must use at most 56%% of the artboard width at %s" % viewport_size) + assert_gte(right_ratio, 0.22, "RightRail must use at least 22%% of the artboard width at %s" % viewport_size) + assert_lte(right_ratio, 0.26, "RightRail must use at most 26%% of the artboard width at %s" % viewport_size) + +func test_named_left_and_right_rail_sections_are_visible_enclosed_and_non_overlapping() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + + _assert_named_non_overlapping_sections(layout, "LeftRail", ["CharacterSection", "ObjectivesSection", "StatusSection"]) + _assert_named_non_overlapping_sections(layout, "RightRail", ["JournalSection", "MapSection"]) + +func _assert_legacy_panel_is_transparent_and_behind(panel: PanelContainer) -> void: + assert_true(panel.has_theme_stylebox_override(&"panel"), "%s requires an explicit local panel style rather than an inherited theme style" % panel.name) + var style := panel.get_theme_stylebox(&"panel") + assert_not_null(style, "%s requires an explicit local transparent panel style" % panel.name) + assert_true(style is StyleBoxEmpty or (style is StyleBoxFlat and (style as StyleBoxFlat).bg_color.a == 0.0), "%s must not repaint over section headings" % panel.name) + assert_true(panel.show_behind_parent, "%s must draw behind its parent and section titles" % panel.name) + +func _assert_named_non_overlapping_sections(layout: Control, rail_name: String, section_names: Array[String]) -> void: + var rail := layout.get_node_or_null(rail_name) as Control + assert_not_null(rail, "ResponsiveLayout requires %s" % rail_name) + if rail == null: + return + var sections: Array[Control] = [] + for section_name in section_names: + var section := layout.get_node_or_null(section_name) as Control + assert_not_null(section, "%s requires a visible %s" % [rail_name, section_name]) + if section == null: + continue + assert_true(section.visible, "%s must be visible" % section_name) + assert_true(rail.get_global_rect().encloses(section.get_global_rect()), "%s must be enclosed by %s" % [section_name, rail_name]) + sections.append(section) + for index in sections.size(): + for other_index in range(index + 1, sections.size()): + assert_false(sections[index].get_global_rect().intersects(sections[other_index].get_global_rect()), "%s must not overlap %s" % [sections[index].name, sections[other_index].name]) + +func test_character_section_title_shows_the_real_run_name_without_a_redundant_name_label() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var character_section := layout.get_node_or_null("CharacterSection") as Control if layout != null else null + var section_title := layout.get_node_or_null("CharacterSectionTitle") as Label if layout != null else null + var name_label := layout.get_node_or_null("CharacterNameLabel") as Label if layout != null else null + var level_label := layout.get_node_or_null("CharacterLevelLabel") as Label if layout != null else null + assert_not_null(layout, "HUD requires ResponsiveLayout") + assert_not_null(character_section, "ResponsiveLayout requires CharacterSection") + assert_not_null(section_title, "CharacterSection requires CharacterSectionTitle") + assert_not_null(level_label, "CharacterSection requires CharacterLevelLabel") + if layout == null or character_section == null or section_title == null or level_label == null: + return + + var state := game.get_game_state() + var run := game.get_run_state() + run.player_name = "Dame Ysabel" + state.player.progression.set_total_xp(125) + hud.refresh(state, [], run) + + assert_true(section_title.visible) + assert_eq(section_title.text, run.player_name, "The card heading is the run's real name, not PERSONNAGE") + assert_ne(section_title.text, "PERSONNAGE") + assert_true(name_label == null or not name_label.visible, "CharacterNameLabel must be absent or invisible because the title already names the run") + if name_label != null: + assert_eq(name_label.text, "", "The hidden duplicate must not retain a second visible identity") + assert_true(level_label.visible) + assert_true(character_section.get_global_rect().encloses(section_title.get_global_rect())) + assert_true(character_section.get_global_rect().encloses(level_label.get_global_rect())) + assert_string_contains(level_label.text, str(state.player.progression.level)) + +func test_character_portrait_uses_mockup_width_and_preserves_its_aspect_ratio_at_reference_size() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + hud.apply_viewport_layout(Vector2(1920, 1080)) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var character_section := layout.get_node_or_null("CharacterSection") as Control if layout != null else null + var portrait := layout.get_node_or_null("PortraitIllustration") as TextureRect if layout != null else null + assert_not_null(character_section, "ResponsiveLayout requires CharacterSection") + assert_not_null(portrait, "CharacterSection requires PortraitIllustration") + if character_section == null or portrait == null: + return + assert_true(portrait.visible, "PortraitIllustration must be visible") + assert_gte(portrait.size.x / character_section.size.x, 0.28, "Portrait must use at least 28%% of CharacterSection width") + assert_lte(portrait.size.x / character_section.size.x, 0.38, "Portrait must use at most 38%% of CharacterSection width") + var texture := portrait.texture as Texture2D + assert_not_null(texture, "PortraitIllustration requires a portrait texture") + if texture != null: + assert_almost_eq(portrait.size.x / portrait.size.y, texture.get_width() as float / texture.get_height() as float, 0.01, "PortraitIllustration must preserve the portrait aspect ratio") + +func test_section_titles_are_visible_contained_and_readable_at_reference_size() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + hud.apply_viewport_layout(Vector2(1920, 1080)) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + var section_names := ["CharacterSection", "ObjectivesSection", "StatusSection", "JournalSection", "MapSection"] + var title_names := ["CharacterSectionTitle", "ObjectivesSectionTitle", "StatusSectionTitle", "JournalSectionTitle", "MapSectionTitle"] + for index in section_names.size(): + var section := layout.get_node_or_null(section_names[index]) as Control + var title := layout.get_node_or_null(title_names[index]) as Label + assert_not_null(section, "ResponsiveLayout requires %s" % section_names[index]) + assert_not_null(title, "ResponsiveLayout requires %s" % title_names[index]) + if section == null or title == null: + continue + assert_true(title.visible, "%s must be visible" % title_names[index]) + assert_true(section.get_global_rect().encloses(title.get_global_rect()), "%s must contain %s" % [section_names[index], title_names[index]]) + assert_gte(title.get_theme_font_size(&"font_size"), 16, "%s must use at least a 16px font at 1920x1080" % title_names[index]) + +func test_top_bar_defaults_to_a_single_floor_title_without_legacy_values_or_notifications() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + hud.apply_viewport_layout(Vector2(1920, 1080)) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var top_bar := layout.get_node_or_null("TopBar") as Control if layout != null else null + var title := hud.get_node_or_null("TitleLabel") as Label + var header_values := hud.get_node_or_null("HeaderValuesLabel") as Label + var achievement_toast := hud.get_node_or_null("AchievementToast") as Label + var title_notification := hud.get_node_or_null("TitleNotificationLabel") as Label + assert_not_null(top_bar, "ResponsiveLayout requires TopBar") + assert_not_null(title, "TopBar requires TitleLabel") + assert_not_null(header_values, "Legacy HeaderValuesLabel must be explicitly hidden") + assert_not_null(achievement_toast, "HUD retains AchievementToast") + assert_not_null(title_notification, "HUD requires a separate temporary TitleNotificationLabel") + if top_bar == null or title == null or header_values == null or achievement_toast == null or title_notification == null: + return + assert_true(title.visible, "TitleLabel is the sole default visible TopBar value") + assert_eq(title.text, "Étage 0") + assert_false(header_values.visible) + assert_eq(header_values.text, "") + assert_false(achievement_toast.visible) + assert_false(title_notification.visible) + assert_true(top_bar.get_global_rect().encloses(title.get_global_rect())) + assert_gte(title.get_theme_font_size(&"font_size"), 20) + +func test_command_bar_subzones_are_distinct_and_contain_their_text() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + hud.apply_viewport_layout(Vector2(1920, 1080)) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var command_bar := layout.get_node_or_null("CommandBar") as Control if layout != null else null + assert_not_null(command_bar, "ResponsiveLayout requires CommandBar") + if layout == null or command_bar == null: + return + var quick_slots := layout.get_node_or_null("QuickSlotStrip") as Control + var prompt_panel := layout.get_node_or_null("PromptPanel") as Control + var help_panel := layout.get_node_or_null("HelpPanel") as Control + var quick_text := layout.get_node_or_null("QuickSlotHint") as Control + var prompt_text := hud.get_node_or_null("ContextPromptLabel") as Control + var help_text := hud.get_node_or_null("HelpLabel") as Control + for zone: Control in [quick_slots, prompt_panel, help_panel]: + assert_not_null(zone, "CommandBar requires its three text sub-zones") + if zone != null: + assert_true(zone.visible, "%s must be visible" % zone.name) + assert_true(command_bar.get_global_rect().encloses(zone.get_global_rect()), "%s must be contained by CommandBar" % zone.name) + for index in 3: + for other_index in range(index + 1, 3): + var zones: Array[Control] = [quick_slots, prompt_panel, help_panel] + if zones[index] != null and zones[other_index] != null: + assert_false(zones[index].get_global_rect().intersects(zones[other_index].get_global_rect()), "%s must not overlap %s" % [zones[index].name, zones[other_index].name]) + assert_not_null(quick_text, "QuickSlotStrip requires QuickSlotHint") + assert_not_null(prompt_text, "PromptPanel requires ContextPromptLabel") + assert_not_null(help_text, "HelpPanel requires HelpLabel") + for text_control: Control in [quick_text, prompt_text, help_text]: + if text_control != null: + assert_true(text_control.visible, "%s text must be visible" % text_control.name) + if quick_slots != null and quick_text != null: + assert_true(quick_slots.get_global_rect().encloses(quick_text.get_global_rect()), "QuickSlotStrip must contain its text") + if prompt_panel != null and prompt_text != null: + assert_true(prompt_panel.get_global_rect().encloses(prompt_text.get_global_rect()), "PromptPanel must contain its text") + if help_panel != null and help_text != null: + assert_true(help_panel.get_global_rect().encloses(help_text.get_global_rect()), "HelpPanel must contain its text") + +func _visible_status_labels(hud: GameHud) -> Array[Label]: + var labels: Array[Label] = [] + for label_name: String in ["CharacterStatusLabel", "SpellLabel", "EnemyHealthLabel", "CombatSummaryLabel", "DeadlineLabel"]: + var label := hud.get_node_or_null(label_name) as Label + if label != null and label.visible: + labels.append(label) + return labels + +func _visible_text_occurrences(hud: GameHud, needle: String) -> int: + var occurrences := 0 + for node in hud.find_children("*", "Label", true, false): + var label := node as Label + if label != null and label.visible and label.text.contains(needle): + occurrences += 1 + return occurrences + +func _assert_play_area_is_centered_and_inside_effective_viewport(play_area_frame: Control) -> void: + var viewport_rect := get_viewport().get_visible_rect() + var expected_viewport := Vector2(Game.REFERENCE_VIEWPORT) + var play_rect := play_area_frame.get_global_rect() + assert_eq(viewport_rect.size, expected_viewport, "HUD layout is evaluated in the effective 1920x1080 viewport") + assert_gte(play_rect.position.x, viewport_rect.position.x, "PlayAreaFrame must stay inside the viewport on the left") + assert_gte(play_rect.position.y, viewport_rect.position.y, "PlayAreaFrame must stay inside the viewport at the top") + assert_lte(play_rect.end.x, viewport_rect.end.x, "PlayAreaFrame must stay inside the viewport on the right") + assert_lte(play_rect.end.y, viewport_rect.end.y, "PlayAreaFrame must stay inside the viewport at the bottom") + assert_gte(play_rect.size.x, viewport_rect.size.x * 0.40, "PlayAreaFrame must have meaningful viewport width") + assert_gte(play_rect.size.y, viewport_rect.size.y * 0.40, "PlayAreaFrame must have meaningful viewport height") + assert_gte(play_rect.get_area(), viewport_rect.get_area() * 0.25, "PlayAreaFrame must occupy a meaningful part of the viewport") + assert_lte(play_rect.get_center().distance_to(viewport_rect.get_center()), 2.0, "PlayAreaFrame must be centered in the effective viewport") + +func _assert_controls_enclosed(region: Control, controls: Array, region_name: String) -> void: + for live_control: Control in controls: + assert_not_null(live_control, "%s must retain its live HUD control" % region_name) + if live_control != null: + assert_true(region.get_global_rect().encloses(live_control.get_global_rect()), "%s must enclose %s" % [region_name, live_control.get_path()]) + +func _controls_in_group(hud: GameHud, group_name: StringName) -> Array[Control]: + var controls: Array[Control] = [] + for node in get_tree().get_nodes_in_group(group_name): + if node is Control and hud.is_ancestor_of(node): + controls.append(node as Control) + return controls + +func _labels_in_group(hud: GameHud, group_name: StringName) -> Array[Label]: + var labels: Array[Label] = [] + for node in _controls_in_group(hud, group_name): + if node is Label: + labels.append(node as Label) + return labels + +func _combined_label_text(labels: Array[Label]) -> String: + var text := "" + for label in labels: + text += label.text + "\n" + return text + +func test_hud_shell_frames_use_the_dark_fantasy_nine_patch_texture() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + + for frame_name: String in [ + "TopBar", "LeftRail", "RightRail", "CommandBar", + "CharacterSection", "ObjectivesSection", "StatusSection", "JournalSection", "MapSection", + ]: + var frame := layout.get_node_or_null(frame_name) as Panel + assert_not_null(frame, "ResponsiveLayout requires %s" % frame_name) + if frame == null: + continue + var style := frame.get_theme_stylebox(&"panel") + assert_true(style is StyleBoxTexture, "%s must use StyleBoxTexture rather than StyleBoxFlat" % frame_name) + var texture_style := style as StyleBoxTexture + if texture_style != null: + assert_true(_texture_uses_path(texture_style.texture, "res://assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png"), "%s must use panel_64x64_nine_patch_source.png" % frame_name) + +func test_play_area_masks_use_the_dungeon_background_texture() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + + const DUNGEON_BACKGROUND := "res://assets/ui/dark_fantasy/dungeon_ui_background.png" + assert_file_exists(DUNGEON_BACKGROUND) + for mask_name: String in ["PlayAreaMaskTop", "PlayAreaMaskLeft", "PlayAreaMaskRight", "PlayAreaMaskBottom"]: + var mask := layout.get_node_or_null(mask_name) as Panel + assert_not_null(mask, "ResponsiveLayout requires %s" % mask_name) + if mask == null: + continue + var style := mask.get_theme_stylebox(&"panel") + assert_true(style is StyleBoxTexture, "%s must use a StyleBoxTexture/AtlasTexture dungeon background" % mask_name) + var texture_style := style as StyleBoxTexture + if texture_style != null: + assert_true(_texture_uses_path(texture_style.texture, DUNGEON_BACKGROUND), "%s must use the new dungeon_ui_background.png asset" % mask_name) + +func test_decorative_equipment_and_header_art_are_absent_or_hidden() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + for decorative_name: String in ["EquipmentIllustration", "HeaderOrnament"]: + var decorative := layout.get_node_or_null(decorative_name) as Control + assert_true(decorative == null or not decorative.visible, "%s must be absent or invisible rather than adding decorative visual noise" % decorative_name) + +func test_objectives_and_status_keep_separate_titles_and_content_at_reference_and_compact_sizes() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var objectives := layout.get_node_or_null("ObjectivesSection") as Control if layout != null else null + var status := layout.get_node_or_null("StatusSection") as Control if layout != null else null + var objectives_title := layout.get_node_or_null("ObjectivesSectionTitle") as Label if layout != null else null + var status_title := layout.get_node_or_null("StatusSectionTitle") as Label if layout != null else null + var quest_content := hud.get_node_or_null("QuestTrackerLabel") as Control + var status_content := hud.get_node_or_null("CharacterStatusLabel") as Control + assert_not_null(objectives, "ObjectivesSection is required at %s" % viewport_size) + assert_not_null(status, "StatusSection is required at %s" % viewport_size) + assert_not_null(objectives_title) + assert_not_null(status_title) + assert_not_null(quest_content) + assert_not_null(status_content) + if objectives == null or status == null or objectives_title == null or status_title == null or quest_content == null or status_content == null: + continue + assert_true(status.get_global_rect().encloses(status_content.get_global_rect()), "CharacterStatusLabel belongs inside StatusSection at %s" % viewport_size) + assert_true(objectives.get_global_rect().encloses(objectives_title.get_global_rect())) + assert_true(objectives.get_global_rect().encloses(quest_content.get_global_rect())) + assert_true(status.get_global_rect().encloses(status_title.get_global_rect())) + assert_false(status_content.get_global_rect().intersects(objectives.get_global_rect()), "CharacterStatusLabel must not touch ObjectivesSection at %s" % viewport_size) + assert_false(objectives_title.get_global_rect().intersects(quest_content.get_global_rect()), "Objectives title and content must be distinct at %s" % viewport_size) + assert_false(status_title.get_global_rect().intersects(status_content.get_global_rect()), "Status title and content must be distinct at %s" % viewport_size) + assert_false(objectives.get_global_rect().intersects(status.get_global_rect()), "Objectives and status frames must remain separate at %s" % viewport_size) + if viewport_size == Vector2(1920, 1080): + assert_gte(status.get_global_rect().position.y - objectives.get_global_rect().end.y, 24.0) + assert_gte(status_title.get_global_rect().position.y - status.get_global_rect().position.y, 14.0) + +func test_player_health_and_gold_use_the_final_compact_character_section_contract() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var state := game.get_game_state() + var run := game.get_run_state() + run.gold = 15 + hud.refresh(state, [], run) + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var character_section := layout.get_node_or_null("CharacterSection") as Control if layout != null else null + var health := hud.get_node_or_null("PlayerHealthLabel") as Label + var gold_icon := hud.get_node_or_null("GoldIcon") as TextureRect + var gold_label := hud.get_node_or_null("GoldLabel") as Label + assert_not_null(character_section) + assert_not_null(health) + assert_not_null(gold_icon, "CharacterSection requires GoldIcon") + assert_not_null(gold_label) + if character_section == null or health == null or gold_icon == null or gold_label == null: + return + assert_eq(health.text, "PV : %d/%d" % [state.player.hit_points, state.player.max_hit_points]) + assert_true(gold_icon.visible) + assert_not_null(gold_icon.texture) + if gold_icon.texture != null: + assert_true(_texture_has_gold_coin_path(gold_icon.texture), "GoldIcon must use the gold_coin SVG or PNG asset") + assert_eq(gold_label.text, "15", "GoldLabel contains the numeric value only") + assert_true(character_section.get_global_rect().encloses(gold_icon.get_global_rect())) + assert_true(character_section.get_global_rect().encloses(gold_label.get_global_rect())) + var currency_bottom := maxf(gold_icon.get_global_rect().end.y, gold_label.get_global_rect().end.y) + assert_gte(character_section.get_global_rect().end.y - currency_bottom, 16.0, "The currency icon/value union needs a >=16px bottom margin") + +func test_character_and_journal_titles_use_the_final_large_outlined_light_style() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + hud.apply_viewport_layout(Vector2(1920, 1080)) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout) + if layout == null: + return + for specification: Dictionary in [ + {"section": "CharacterSection", "title": "CharacterSectionTitle"}, + {"section": "JournalSection", "title": "JournalSectionTitle"}, + ]: + var section := layout.get_node_or_null(String(specification.section)) as Control + var title := layout.get_node_or_null(String(specification.title)) as Label + assert_not_null(section) + assert_not_null(title, "ResponsiveLayout requires %s" % specification.title) + if section == null or title == null: + continue + assert_gte(title.get_theme_font_size(&"font_size"), 20, "%s needs a >=20px font at 1920x1080" % title.name) + assert_gte(title.get_theme_constant(&"outline_size"), 3, "%s needs a >=3px contour" % title.name) + var font_color := title.get_theme_color(&"font_color") + assert_gte(font_color.r, 0.95, "%s must use an explicit gold/yellow red channel" % title.name) + assert_gte(font_color.g, 0.70, "%s must use an explicit gold/yellow green channel" % title.name) + assert_lte(font_color.g, 0.90, "%s must use an explicit gold/yellow green channel" % title.name) + assert_lte(font_color.b, 0.55, "%s must use an explicit gold/yellow blue channel" % title.name) + assert_eq(font_color.a, 1.0, "%s must be fully opaque" % title.name) + assert_gte(title.get_global_rect().position.y - section.get_global_rect().position.y, 16.0, "%s needs a >=16px vertical inset" % title.name) + +func test_command_bar_keeps_all_three_zones_readable_at_reference_and_compact_sizes() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var command_bar := layout.get_node_or_null("CommandBar") as Control if layout != null else null + var quick_slots := layout.get_node_or_null("QuickSlotStrip") as Control if layout != null else null + var prompt_panel := layout.get_node_or_null("PromptPanel") as Control if layout != null else null + var help_panel := layout.get_node_or_null("HelpPanel") as Control if layout != null else null + var quick_hint := layout.get_node_or_null("QuickSlotHint") as Label if layout != null else null + var prompt := layout.get_node_or_null("PromptPanel/ActionHintLabel") as Label if layout != null else null + var help := hud.get_node_or_null("HelpLabel") as Label + assert_not_null(command_bar, "CommandBar is required at %s" % viewport_size) + assert_not_null(quick_slots) + assert_not_null(prompt_panel) + assert_not_null(help_panel) + assert_not_null(quick_hint) + assert_not_null(prompt) + assert_not_null(help) + if command_bar == null or quick_slots == null or prompt_panel == null or help_panel == null or quick_hint == null or prompt == null or help == null: + continue + for zone: Control in [quick_slots, prompt_panel, help_panel]: + assert_true(command_bar.get_global_rect().encloses(zone.get_global_rect()), "%s must remain contained at %s" % [zone.name, viewport_size]) + for index in 3: + var zones: Array[Control] = [quick_slots, prompt_panel, help_panel] + for other_index in range(index + 1, 3): + assert_false(zones[index].get_global_rect().intersects(zones[other_index].get_global_rect()), "%s and %s must not overlap at %s" % [zones[index].name, zones[other_index].name, viewport_size]) + assert_true(quick_slots.get_global_rect().encloses(quick_hint.get_global_rect())) + assert_true(prompt_panel.get_global_rect().encloses(prompt.get_global_rect())) + assert_true(help_panel.get_global_rect().encloses(help.get_global_rect())) + assert_false(help.clip_text, "HelpLabel must not be truncated at %s" % viewport_size) + assert_lte(help.get_minimum_size().x, help.size.x, "The right help zone must fit its complete label at %s" % viewport_size) + assert_eq(prompt.text, "F : Distance • X : Magie • K : Familier", "The center zone must contain exactly the three requested command notions") + +func _texture_has_gold_coin_path(texture: Texture2D) -> bool: + return _texture_uses_path(texture, "res://assets/ui/dark_fantasy/gold_coin.svg") or _texture_uses_path(texture, "res://assets/ui/dark_fantasy/gold_coin.png") + +func _texture_uses_path(texture: Texture2D, expected_path: String) -> bool: + if texture == null: + return false + if texture.resource_path == expected_path: + return true + if texture is AtlasTexture: + var atlas_texture := texture as AtlasTexture + return atlas_texture.atlas != null and atlas_texture.atlas.resource_path == expected_path + return false diff --git a/tests/unit/test_loot_feedback.gd b/tests/unit/test_loot_feedback.gd new file mode 100644 index 0000000..7b1b3bf --- /dev/null +++ b/tests/unit/test_loot_feedback.gd @@ -0,0 +1,27 @@ +extends GutTest + +const LootFeedback = preload("res://scripts/presentation/loot_feedback.gd") +const GameEvent = preload("res://scripts/domain/run/game_event.gd") + +func test_label_for_event_distinguishes_each_loot_outcome() -> void: + var feedback := LootFeedback.new() + add_child_autofree(feedback) + var cases: Array[Dictionary] = [ + {"event": GameEvent.new(1, 0, &"loot_dropped"), "expected": "✦ BUTIN AU SOL"}, + {"event": GameEvent.new(1, 0, &"item_picked_up"), "expected": "✦ OBJET RAMASSÉ"}, + {"event": GameEvent.new(1, 0, &"loot_taken"), "expected": "✦ BUTIN RÉCUPÉRÉ"}, + {"event": GameEvent.new(1, 0, &"pickup_refused", {"reason": &"capacity"}), "expected": "! INVENTAIRE PLEIN"}, + {"event": GameEvent.new(1, 0, &"pickup_refused", {"reason": &"inventory_full"}), "expected": "! INVENTAIRE PLEIN"}, + {"event": GameEvent.new(1, 0, &"pickup_refused", {"reason": &"no_ground_item"}), "expected": "! RIEN À RAMASSER"}, + ] + + for test_case: Dictionary in cases: + assert_eq(feedback.label_for_event(test_case.event, &"loot"), test_case.expected) + +func test_begin_records_label_in_test_mode() -> void: + var feedback := LootFeedback.new() + add_child_autofree(feedback) + feedback.set_test_mode_for_testing(true) + feedback.begin(GameEvent.new(1, 0, &"item_picked_up"), &"loot") + + assert_eq(feedback.get_last_feedback_state().label, "✦ OBJET RAMASSÉ") diff --git a/tests/unit/test_loot_feedback.gd.uid b/tests/unit/test_loot_feedback.gd.uid new file mode 100644 index 0000000..b16bfcb --- /dev/null +++ b/tests/unit/test_loot_feedback.gd.uid @@ -0,0 +1 @@ +uid://5uw6cqftw4sw diff --git a/tests/unit/test_minimap.gd b/tests/unit/test_minimap.gd index 6a9e361..174df98 100644 --- a/tests/unit/test_minimap.gd +++ b/tests/unit/test_minimap.gd @@ -9,6 +9,31 @@ func before_each() -> void: add_child_autofree(game) await get_tree().process_frame +func test_minimap_lives_in_right_rail_and_draws_only_in_its_inner_map_region() -> void: + var minimap := game.get_node_or_null("HUD/Minimap") as Minimap + var layout := game.get_node("HUD/ResponsiveLayout") as Control + var right_rail := layout.get_node("RightRail") as Control + var play_frame := layout.get_node("PlayAreaFrame") as Control + var map_region := minimap.get_node("MapRegion") as Control + var caption := minimap.get_node("Caption") as Label + + assert_not_null(minimap) + assert_true(right_rail.get_global_rect().encloses(minimap.get_global_rect())) + assert_true(map_region.get_rect().encloses(minimap.get_drawable_map_rect())) + assert_false(caption.get_rect().intersects(minimap.get_drawable_map_rect())) + assert_lt(minimap.get_drawable_map_rect().size.x, minimap.size.x) + + minimap.toggle_expanded() + await get_tree().process_frame + assert_true(minimap.expanded) + assert_true(play_frame.get_global_rect().encloses(minimap.get_global_rect())) + assert_true(map_region.get_rect().encloses(minimap.get_drawable_map_rect())) + + minimap.toggle_expanded() + await get_tree().process_frame + assert_false(minimap.expanded) + assert_true(right_rail.get_global_rect().encloses(minimap.get_global_rect())) + func test_minimap_crops_to_player_camera_fov_and_never_reveals_hidden_threats() -> void: var minimap := game.get_node_or_null("HUD/Minimap") as Minimap var state := game.get_game_state()