Setup basic GUI and scanner selection
This commit is contained in:
parent
ee46a240c2
commit
5f8052f0a3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
/android/
|
||||
addons/
|
||||
17
Game.tscn
17
Game.tscn
@ -1,15 +1,14 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://d3srnfkpx01we"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_vr3vq"]
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_8n51p"]
|
||||
gradient = SubResource("Gradient_vr3vq")
|
||||
[ext_resource type="PackedScene" uid="uid://d3hul8b7hlmj7" path="res://scenes/Map.tscn" id="1_nnb57"]
|
||||
[ext_resource type="PackedScene" uid="uid://dha8pa1les53a" path="res://scenes/Gui.tscn" id="2_d5c8m"]
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
|
||||
[node name="Souris" type="Node2D" parent="."]
|
||||
[node name="Map" parent="." instance=ExtResource("1_nnb57")]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Souris"]
|
||||
scale = Vector2(0.0859375, 23)
|
||||
texture = SubResource("GradientTexture1D_8n51p")
|
||||
[node name="Interface" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Gui" parent="Interface" instance=ExtResource("2_d5c8m")]
|
||||
|
||||
[connection signal="scanner_selected" from="Interface/Gui" to="Map" method="_on_gui_scanner_selected"]
|
||||
|
||||
8
assets/gradients/Fertility.tres
Normal file
8
assets/gradients/Fertility.tres
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_resource type="GradientTexture1D" load_steps=2 format=3 uid="uid://be2uusaqcpcpd"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_pafyk"]
|
||||
offsets = PackedFloat32Array(0, 0.22549, 0.51634, 0.813725, 1)
|
||||
colors = PackedColorArray(0.66677, 0.166288, 0, 1, 0.41, 0.328, 0, 1, 0.0321677, 2.76752e-07, 0.262162, 1, 0, 0.592306, 0, 1, 0, 0.964706, 0.580392, 1)
|
||||
|
||||
[resource]
|
||||
gradient = SubResource("Gradient_pafyk")
|
||||
29
objects/gui/Scanner_modes.tscn
Normal file
29
objects/gui/Scanner_modes.tscn
Normal file
@ -0,0 +1,29 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://0so4tpnkk8t2"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/gui/scanner_modes.gd" id="1_synac"]
|
||||
|
||||
[node name="ScannerModes" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 0
|
||||
script = ExtResource("1_synac")
|
||||
|
||||
[node name="Scanner Select" type="OptionButton" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -60.5
|
||||
offset_right = 60.5
|
||||
offset_bottom = 40.0
|
||||
grow_horizontal = 2
|
||||
selected = 0
|
||||
item_count = 3
|
||||
popup/item_0/text = "No Scanner"
|
||||
popup/item_1/text = "Water"
|
||||
popup/item_1/id = 1
|
||||
popup/item_2/text = "Fertility"
|
||||
popup/item_2/id = 2
|
||||
|
||||
[connection signal="item_selected" from="Scanner Select" to="." method="_on_scanner_select_item_selected"]
|
||||
69
objects/gui/Seed_card.tscn
Normal file
69
objects/gui/Seed_card.tscn
Normal file
@ -0,0 +1,69 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://iaf4md4cbwqh"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_lissx"]
|
||||
offsets = PackedFloat32Array(1)
|
||||
colors = PackedColorArray(0.125911, 0.125911, 0.125911, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_aglhv"]
|
||||
gradient = SubResource("Gradient_lissx")
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_kiud1"]
|
||||
|
||||
[node name="SeedCard" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="Card" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -100.0
|
||||
offset_top = -181.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Card"]
|
||||
layout_mode = 2
|
||||
texture = SubResource("GradientTexture1D_aglhv")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Card"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Card/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Nom" type="Label" parent="Card/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Chène"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Image" type="TextureRect" parent="Card/MarginContainer/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(0, 80)
|
||||
layout_mode = 2
|
||||
texture = SubResource("NoiseTexture2D_kiud1")
|
||||
expand_mode = 3
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Besoins" type="Label" parent="Card/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Besoins"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Apports" type="Label" parent="Card/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Apports
|
||||
"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
72
objects/gui/Seed_queue.tscn
Normal file
72
objects/gui/Seed_queue.tscn
Normal file
@ -0,0 +1,72 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bm8nlb7kmaa6k"]
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_reedq"]
|
||||
|
||||
[node name="SeedQueue" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="NextSeed" type="TextureRect" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(80, 80)
|
||||
layout_mode = 2
|
||||
texture = SubResource("NoiseTexture2D_reedq")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="Queue" type="HBoxContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
alignment = 2
|
||||
|
||||
[node name="Seed1" type="TextureRect" parent="HBoxContainer/Queue"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = SubResource("NoiseTexture2D_reedq")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="Seed2" type="TextureRect" parent="HBoxContainer/Queue"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = SubResource("NoiseTexture2D_reedq")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="Seed3" type="TextureRect" parent="HBoxContainer/Queue"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = SubResource("NoiseTexture2D_reedq")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="Seed4" type="TextureRect" parent="HBoxContainer/Queue"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = SubResource("NoiseTexture2D_reedq")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="Seed5" type="TextureRect" parent="HBoxContainer/Queue"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = SubResource("NoiseTexture2D_reedq")
|
||||
expand_mode = 2
|
||||
38
scenes/Gui.tscn
Normal file
38
scenes/Gui.tscn
Normal file
@ -0,0 +1,38 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dha8pa1les53a"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/gui.gd" id="1_6gq27"]
|
||||
[ext_resource type="PackedScene" uid="uid://bm8nlb7kmaa6k" path="res://objects/gui/Seed_queue.tscn" id="1_lh8u1"]
|
||||
[ext_resource type="PackedScene" uid="uid://iaf4md4cbwqh" path="res://objects/gui/Seed_card.tscn" id="2_bt3vo"]
|
||||
[ext_resource type="PackedScene" uid="uid://0so4tpnkk8t2" path="res://objects/gui/Scanner_modes.tscn" id="3_bsm7r"]
|
||||
|
||||
[node name="Gui" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_6gq27")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="SeedQueue" parent="MarginContainer" instance=ExtResource("1_lh8u1")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SeedCard" parent="MarginContainer" instance=ExtResource("2_bt3vo")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ScannerModes" parent="MarginContainer" instance=ExtResource("3_bsm7r")]
|
||||
layout_mode = 2
|
||||
|
||||
[connection signal="scanner_selected" from="MarginContainer/ScannerModes" to="." method="_on_scanner_modes_scanner_selected"]
|
||||
@ -1,19 +1,18 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://6ferubyu2uy1"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://6ferubyu2uy1"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/scanners.gd" id="1_orxwo"]
|
||||
[ext_resource type="Shader" path="res://scripts/shaders/Scanner.gdshader" id="2_8t6wf"]
|
||||
[ext_resource type="Texture2D" uid="uid://be2uusaqcpcpd" path="res://assets/gradients/Fertility.tres" id="3_bt6q7"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_pafyk"]
|
||||
offsets = PackedFloat32Array(0, 0.22549, 0.51634, 0.813725, 1)
|
||||
colors = PackedColorArray(0.66677, 0.166288, 0, 1, 0.41, 0.328, 0, 1, 0, 0, 0, 1, 0, 0.592306, 0, 1, 0, 0.964706, 0.580392, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_mpkd3"]
|
||||
gradient = SubResource("Gradient_pafyk")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_yl6st"]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_05bn7"]
|
||||
shader = ExtResource("2_8t6wf")
|
||||
shader_parameter/dimension = 1
|
||||
shader_parameter/gradient = SubResource("GradientTexture1D_mpkd3")
|
||||
shader_parameter/gradient = ExtResource("3_bt6q7")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lpu5x"]
|
||||
shader = ExtResource("2_8t6wf")
|
||||
shader_parameter/dimension = 0
|
||||
shader_parameter/gradient = ExtResource("3_bt6q7")
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_sc8ss"]
|
||||
interpolation_mode = 1
|
||||
@ -25,6 +24,11 @@ gradient = SubResource("Gradient_sc8ss")
|
||||
fill_from = Vector2(0, 1)
|
||||
fill_to = Vector2(1, 1)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0lkln"]
|
||||
shader = ExtResource("2_8t6wf")
|
||||
shader_parameter/dimension = 2
|
||||
shader_parameter/gradient = ExtResource("3_bt6q7")
|
||||
|
||||
[node name="Scanners" type="Node2D"]
|
||||
script = ExtResource("1_orxwo")
|
||||
|
||||
@ -34,11 +38,17 @@ centered = false
|
||||
|
||||
[node name="Fertility" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
material = SubResource("ShaderMaterial_yl6st")
|
||||
material = SubResource("ShaderMaterial_05bn7")
|
||||
centered = false
|
||||
|
||||
[node name="Water" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
material = SubResource("ShaderMaterial_yl6st")
|
||||
material = SubResource("ShaderMaterial_lpu5x")
|
||||
texture = SubResource("GradientTexture2D_a7oi7")
|
||||
centered = false
|
||||
|
||||
[node name="Presence" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
material = SubResource("ShaderMaterial_0lkln")
|
||||
texture = SubResource("GradientTexture2D_a7oi7")
|
||||
centered = false
|
||||
|
||||
7
scripts/gui.gd
Normal file
7
scripts/gui.gd
Normal file
@ -0,0 +1,7 @@
|
||||
class_name Gui
|
||||
extends Control
|
||||
|
||||
signal scanner_selected
|
||||
|
||||
func _on_scanner_modes_scanner_selected(type : Scanners.Type):
|
||||
emit_signal("scanner_selected", type)
|
||||
14
scripts/gui/scanner_modes.gd
Normal file
14
scripts/gui/scanner_modes.gd
Normal file
@ -0,0 +1,14 @@
|
||||
extends Control
|
||||
|
||||
signal scanner_selected
|
||||
|
||||
func _on_scanner_select_item_selected(index):
|
||||
var scannerType : Scanners.Type
|
||||
|
||||
match index:
|
||||
0: scannerType = Scanners.Type.NoScanner
|
||||
1: scannerType = Scanners.Type.Water
|
||||
2: scannerType = Scanners.Type.Fertility
|
||||
3: scannerType = Scanners.Type.Presence
|
||||
|
||||
emit_signal("scanner_selected", scannerType)
|
||||
@ -1,2 +1,6 @@
|
||||
class_name Map
|
||||
extends Node2D
|
||||
|
||||
|
||||
func _on_gui_scanner_selected(type : Scanners.Type):
|
||||
$Scanners.select_scanner(type)
|
||||
|
||||
@ -1,11 +1,20 @@
|
||||
class_name Scanners
|
||||
extends Node2D
|
||||
|
||||
func _ready():
|
||||
for sprite in [$Water, $Fertility, $Data]:
|
||||
sprite.texture = GameTerrain.get_texture()
|
||||
sprite.scale = Vector2(GameTerrain.MAP_RATIO,GameTerrain.MAP_RATIO,)
|
||||
enum Type {NoScanner, Water, Fertility, Presence, Combined}
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
func _ready():
|
||||
for sprite in [$Water, $Fertility, $Presence, $Data]:
|
||||
sprite.texture = GameTerrain.get_texture()
|
||||
sprite.scale = Vector2(GameTerrain.MAP_RATIO,GameTerrain.MAP_RATIO)
|
||||
sprite.visible = false
|
||||
|
||||
func select_scanner(type: Type):
|
||||
for sprite in [$Water, $Fertility, $Presence, $Data]:
|
||||
sprite.visible = false
|
||||
|
||||
match type:
|
||||
Type.Water: $Water.visible = true
|
||||
Type.Fertility: $Fertility.visible = true
|
||||
Type.Presence: $Presence.visible = true
|
||||
Type.Combined: $Data.visible = true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user