summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-06-04 23:00:58 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-06-04 23:00:58 -0600
commit36abc689d783774ce4f2d7b5a1bb621d8684be45 (patch)
treea3dbed6069fbd8d9a588c7510ce581af3e847af0 /src/ui
parent9a2bcf02c2623c8f3e8f5e74e70b3c0333790484 (diff)
added more ui for after gameplay, generalized basic food
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/main_menu/scenes/MainMenu.tscn16
-rw-r--r--src/ui/stats_display/scenes/ProgressionLabel.tscn50
-rw-r--r--src/ui/stats_display/scenes/StatsDisplay.tscn52
-rw-r--r--src/ui/stats_display/scripts/progression_label.gd48
-rw-r--r--src/ui/stats_display/scripts/stats_display.gd80
-rw-r--r--src/ui/stats_display/sprites/sep_16x16.pngbin0 -> 88 bytes
-rw-r--r--src/ui/stats_display/sprites/sep_16x16.png.import35
-rw-r--r--src/ui/stats_display/sprites/sep_2x2.pngbin0 -> 81 bytes
-rw-r--r--src/ui/stats_display/sprites/sep_2x2.png.import35
-rw-r--r--src/ui/stats_display/sprites/sep_4x4.pngbin0 -> 82 bytes
-rw-r--r--src/ui/stats_display/sprites/sep_4x4.png.import35
-rw-r--r--src/ui/stats_display/sprites/sep_8x8.pngbin0 -> 85 bytes
-rw-r--r--src/ui/stats_display/sprites/sep_8x8.png.import35
13 files changed, 378 insertions, 8 deletions
diff --git a/src/ui/main_menu/scenes/MainMenu.tscn b/src/ui/main_menu/scenes/MainMenu.tscn
index 249885e..9bce7f0 100644
--- a/src/ui/main_menu/scenes/MainMenu.tscn
+++ b/src/ui/main_menu/scenes/MainMenu.tscn
@@ -21,31 +21,31 @@ margin_right = 320.0
margin_bottom = 180.0
[node name="VBox" type="VBoxContainer" parent="Center"]
-margin_left = 64.0
+margin_left = 100.0
margin_top = 28.0
-margin_right = 256.0
+margin_right = 220.0
margin_bottom = 152.0
custom_constants/separation = 16
[node name="Title" type="CenterContainer" parent="Center/VBox"]
-margin_right = 192.0
+margin_right = 120.0
margin_bottom = 52.0
[node name="Label" type="Label" parent="Center/VBox/Title"]
-margin_right = 192.0
+margin_right = 120.0
margin_bottom = 52.0
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_fonts/font = SubResource( 1 )
-text = "El Snake"
+text = "Snake"
[node name="Options" type="CenterContainer" parent="Center/VBox"]
margin_top = 68.0
-margin_right = 192.0
+margin_right = 120.0
margin_bottom = 124.0
[node name="VBox" type="VBoxContainer" parent="Center/VBox/Options"]
-margin_left = 56.0
-margin_right = 136.0
+margin_left = 20.0
+margin_right = 100.0
margin_bottom = 56.0
[node name="Start" parent="Center/VBox/Options/VBox" instance=ExtResource( 1 )]
diff --git a/src/ui/stats_display/scenes/ProgressionLabel.tscn b/src/ui/stats_display/scenes/ProgressionLabel.tscn
new file mode 100644
index 0000000..bc7aef8
--- /dev/null
+++ b/src/ui/stats_display/scenes/ProgressionLabel.tscn
@@ -0,0 +1,50 @@
+[gd_scene load_steps=5 format=2]
+
+[ext_resource path="res://ui/stats_display/sprites/sep_8x8.png" type="Texture" id=1]
+[ext_resource path="res://themes/Theme.tres" type="Theme" id=2]
+[ext_resource path="res://ui/stats_display/scripts/progression_label.gd" type="Script" id=3]
+[ext_resource path="res://ui/stats_display/sprites/sep_2x2.png" type="Texture" id=4]
+
+[node name="ProgressionLabel" type="MarginContainer"]
+theme = ExtResource( 2 )
+script = ExtResource( 3 )
+
+[node name="HBox" type="HBoxContainer" parent="."]
+margin_right = 74.0
+margin_bottom = 13.0
+custom_constants/separation = 0
+
+[node name="Center" type="CenterContainer" parent="HBox"]
+margin_right = 8.0
+margin_bottom = 13.0
+
+[node name="VBox" type="VBoxContainer" parent="HBox/Center"]
+margin_top = 1.0
+margin_right = 8.0
+margin_bottom = 11.0
+custom_constants/separation = 0
+
+[node name="Sep" type="TextureRect" parent="HBox/Center/VBox"]
+margin_right = 8.0
+margin_bottom = 2.0
+texture = ExtResource( 4 )
+
+[node name="TextureRect" type="TextureRect" parent="HBox/Center/VBox"]
+margin_top = 2.0
+margin_right = 8.0
+margin_bottom = 10.0
+texture = ExtResource( 1 )
+
+[node name="Prefix" type="Label" parent="HBox"]
+margin_left = 8.0
+margin_right = 44.0
+margin_bottom = 13.0
+custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
+text = "Prefix"
+
+[node name="Stats" type="Label" parent="HBox"]
+margin_left = 44.0
+margin_right = 74.0
+margin_bottom = 13.0
+custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
+text = "Stats"
diff --git a/src/ui/stats_display/scenes/StatsDisplay.tscn b/src/ui/stats_display/scenes/StatsDisplay.tscn
new file mode 100644
index 0000000..9b86a55
--- /dev/null
+++ b/src/ui/stats_display/scenes/StatsDisplay.tscn
@@ -0,0 +1,52 @@
+[gd_scene load_steps=5 format=2]
+
+[ext_resource path="res://fonts/MonogramExtended.tres" type="DynamicFont" id=1]
+[ext_resource path="res://themes/Theme.tres" type="Theme" id=2]
+[ext_resource path="res://ui/stats_display/scenes/ProgressionLabel.tscn" type="PackedScene" id=3]
+[ext_resource path="res://ui/stats_display/scripts/stats_display.gd" type="Script" id=4]
+
+[node name="StatsDisplay" type="MarginContainer"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+theme = ExtResource( 2 )
+script = ExtResource( 4 )
+PROGRESSION_LABEL = ExtResource( 3 )
+
+[node name="Center" type="CenterContainer" parent="."]
+margin_right = 320.0
+margin_bottom = 180.0
+
+[node name="HBox" type="HBoxContainer" parent="Center"]
+margin_left = 126.0
+margin_top = 82.0
+margin_right = 194.0
+margin_bottom = 98.0
+
+[node name="ProgressionPanel" type="PanelContainer" parent="Center/HBox"]
+margin_right = 68.0
+margin_bottom = 16.0
+
+[node name="VBox" type="VBoxContainer" parent="Center/HBox/ProgressionPanel"]
+margin_left = 1.0
+margin_top = 1.0
+margin_right = 67.0
+margin_bottom = 15.0
+custom_constants/separation = 0
+
+[node name="Label" type="Label" parent="Center/HBox/ProgressionPanel/VBox"]
+margin_right = 66.0
+margin_bottom = 13.0
+custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
+custom_fonts/font = ExtResource( 1 )
+text = "Progression"
+
+[node name="HSeparator" type="HSeparator" parent="Center/HBox/ProgressionPanel/VBox"]
+margin_top = 13.0
+margin_right = 66.0
+margin_bottom = 14.0
+
+[node name="VBox" type="VBoxContainer" parent="Center/HBox/ProgressionPanel/VBox"]
+margin_top = 14.0
+margin_right = 66.0
+margin_bottom = 14.0
+custom_constants/separation = 0
diff --git a/src/ui/stats_display/scripts/progression_label.gd b/src/ui/stats_display/scripts/progression_label.gd
new file mode 100644
index 0000000..d4a0da0
--- /dev/null
+++ b/src/ui/stats_display/scripts/progression_label.gd
@@ -0,0 +1,48 @@
+class_name ProgressionLabel
+extends MarginContainer
+
+enum Type {
+ BODY_SEGMENT,
+ EMPTY
+}
+
+export(int) var TYPE: int = Type.EMPTY
+export(String) var PREFIX: String
+export(float) var BEFORE_VALUE: float
+export(float) var AFTER_VALUE: float = -1.0
+
+onready var label_prefix: Label = $HBox/Prefix
+onready var label_stats: Label = $HBox/Stats
+onready var texture_rect: TextureRect = $HBox/Center/VBox/TextureRect
+
+
+var textures: Dictionary = {
+ Type.BODY_SEGMENT: preload("res://ui/hud/progress_bars/sprites/grow_progress_icon.png"),
+ Type.EMPTY: preload("res://ui/stats_display/sprites/sep_8x8.png")
+}
+
+var _fmt: String = "%s->%s"
+var _fmt_partial: String = "%s"
+var _fmt_prefix: String = " %s "
+
+
+func _ready() -> void:
+ set_properties(TYPE, PREFIX, BEFORE_VALUE, AFTER_VALUE)
+
+
+func set_properties(icon: int, prefix: String, before: float, after: float=-1.0) -> void:
+ texture_rect.texture = textures[icon]
+ if after == -1.0:
+ label_stats.text =_fmt_partial % before
+ else:
+ label_stats.text =_fmt % [before, after]
+ if after > before:
+ label_stats.add_color_override("font_color", Color.green)
+ elif after < before:
+ label_stats.add_color_override("font_color", Color.red)
+ if not prefix.empty():
+ label_prefix.text = _fmt_prefix % prefix
+ else:
+ label_prefix.text = " "
+ label_prefix.update()
+ label_stats.update()
diff --git a/src/ui/stats_display/scripts/stats_display.gd b/src/ui/stats_display/scripts/stats_display.gd
new file mode 100644
index 0000000..f1f77ef
--- /dev/null
+++ b/src/ui/stats_display/scripts/stats_display.gd
@@ -0,0 +1,80 @@
+extends MarginContainer
+
+export(PackedScene) var PROGRESSION_LABEL: PackedScene
+
+onready var label_parent: VBoxContainer = $Center/HBox/ProgressionPanel/VBox/VBox
+
+
+func _ready():
+ Event.connect("display_stats", self, "_on_display_stats")
+ visible = false
+
+
+func _on_display_stats(old_stats: Stats, new_stats: Stats, mut_stats: Array) -> void:
+ visible = true
+ var old_stats_dict: Dictionary = old_stats.get_stats()
+ var new_stats_dict: Dictionary = new_stats.get_stats()
+ var mut_stats_dict: Array = []
+ for i in mut_stats:
+ mut_stats_dict.append(i)
+ print(i)
+
+ var type: int
+ var prefix: String
+ var should_print: bool
+
+ for stat_name in old_stats_dict:
+ should_print = _should_print(stat_name, new_stats_dict)
+ if should_print:
+ type = _get_type(stat_name)
+ prefix = _get_prefix(stat_name)
+ var _temp_label: ProgressionLabel = PROGRESSION_LABEL.instance()
+ label_parent.add_child(_temp_label)
+ _temp_label.set_properties(type, prefix, old_stats_dict[stat_name], new_stats_dict[stat_name])
+
+
+func _get_type(stat_name: String) -> int:
+ var type: int
+ match stat_name:
+ "segments":
+ type = ProgressionLabel.Type.BODY_SEGMENT
+ _:
+ type = ProgressionLabel.Type.EMPTY
+ return type
+
+
+func _get_prefix(stat_name: String) -> String:
+ var prefix: String
+ match stat_name:
+ "points":
+ prefix = "points"
+ _:
+ prefix = ""
+ return prefix
+
+
+func _should_print(stat_name: String, stats: Dictionary) -> bool:
+ var to_print: Array = [
+ "points",
+ "segments",
+ ]
+ var to_print_check: Array = [
+ "dash_percentage",
+ "slow_percentage",
+ "jump_lenght"
+ ]
+ var checks: Dictionary = {
+ to_print_check[0]: stats["trait_dash"],
+ to_print_check[1]: stats["trait_slow"],
+ to_print_check[2]: stats["trait_jump"]
+ }
+
+ if to_print.has(stat_name):
+ return true
+ elif to_print_check.has(stat_name):
+ if checks[stat_name]:
+ return true
+ else:
+ return false
+ else:
+ return false
diff --git a/src/ui/stats_display/sprites/sep_16x16.png b/src/ui/stats_display/sprites/sep_16x16.png
new file mode 100644
index 0000000..5e4988e
--- /dev/null
+++ b/src/ui/stats_display/sprites/sep_16x16.png
Binary files differ
diff --git a/src/ui/stats_display/sprites/sep_16x16.png.import b/src/ui/stats_display/sprites/sep_16x16.png.import
new file mode 100644
index 0000000..af73be3
--- /dev/null
+++ b/src/ui/stats_display/sprites/sep_16x16.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/sep_16x16.png-07358072cc2f69acd36c02f177ac1acb.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/stats_display/sprites/sep_16x16.png"
+dest_files=[ "res://.import/sep_16x16.png-07358072cc2f69acd36c02f177ac1acb.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/stats_display/sprites/sep_2x2.png b/src/ui/stats_display/sprites/sep_2x2.png
new file mode 100644
index 0000000..e17fd41
--- /dev/null
+++ b/src/ui/stats_display/sprites/sep_2x2.png
Binary files differ
diff --git a/src/ui/stats_display/sprites/sep_2x2.png.import b/src/ui/stats_display/sprites/sep_2x2.png.import
new file mode 100644
index 0000000..db8cfc0
--- /dev/null
+++ b/src/ui/stats_display/sprites/sep_2x2.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/sep_2x2.png-723a79374f3362fd763c297ceaabe580.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/stats_display/sprites/sep_2x2.png"
+dest_files=[ "res://.import/sep_2x2.png-723a79374f3362fd763c297ceaabe580.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/stats_display/sprites/sep_4x4.png b/src/ui/stats_display/sprites/sep_4x4.png
new file mode 100644
index 0000000..f5a21ee
--- /dev/null
+++ b/src/ui/stats_display/sprites/sep_4x4.png
Binary files differ
diff --git a/src/ui/stats_display/sprites/sep_4x4.png.import b/src/ui/stats_display/sprites/sep_4x4.png.import
new file mode 100644
index 0000000..e46103f
--- /dev/null
+++ b/src/ui/stats_display/sprites/sep_4x4.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/sep_4x4.png-df075ccb421f59c1ef36d42098338d8f.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/stats_display/sprites/sep_4x4.png"
+dest_files=[ "res://.import/sep_4x4.png-df075ccb421f59c1ef36d42098338d8f.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/stats_display/sprites/sep_8x8.png b/src/ui/stats_display/sprites/sep_8x8.png
new file mode 100644
index 0000000..01220e2
--- /dev/null
+++ b/src/ui/stats_display/sprites/sep_8x8.png
Binary files differ
diff --git a/src/ui/stats_display/sprites/sep_8x8.png.import b/src/ui/stats_display/sprites/sep_8x8.png.import
new file mode 100644
index 0000000..6ca9f8a
--- /dev/null
+++ b/src/ui/stats_display/sprites/sep_8x8.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/sep_8x8.png-2d331c15ccc1e2264f4ae5995f2c0099.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/stats_display/sprites/sep_8x8.png"
+dest_files=[ "res://.import/sep_8x8.png-2d331c15ccc1e2264f4ae5995f2c0099.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0