change counter and unit info texture handling

This commit is contained in:
Teatov 2024-10-13 17:31:33 +10:00
parent 8f510fd370
commit 21017f9854
22 changed files with 66 additions and 376 deletions

BIN
assets/textures/gui/honeydew_0.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/textures/gui/honeydew_1.png (Stored with Git LFS)

Binary file not shown.

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://du3uh5fhacn7v"
path="res://.godot/imported/honeydew_1.png-9e5c1d92468c4cc1db1501efee932d15.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/gui/honeydew_1.png"
dest_files=["res://.godot/imported/honeydew_1.png-9e5c1d92468c4cc1db1501efee932d15.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

BIN
assets/textures/gui/honeydew_2.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/textures/gui/honeydew_3.png (Stored with Git LFS)

Binary file not shown.

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://corv2uv8wurkf"
path="res://.godot/imported/honeydew_3.png-436a903c5a77aa591e16d4564ac3cfdb.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/gui/honeydew_3.png"
dest_files=["res://.godot/imported/honeydew_3.png-436a903c5a77aa591e16d4564ac3cfdb.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

BIN
assets/textures/gui/honeydew_4.png (Stored with Git LFS)

Binary file not shown.

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cyfxm1tt3wof7"
path="res://.godot/imported/honeydew_4.png-e9e50fa541076eac4b1d0c10f31e1c3c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/gui/honeydew_4.png"
dest_files=["res://.godot/imported/honeydew_4.png-e9e50fa541076eac4b1d0c10f31e1c3c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

BIN
assets/textures/gui/honeydew_5.png (Stored with Git LFS)

Binary file not shown.

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://do1fp3hnmrlcu"
path="res://.godot/imported/honeydew_5.png-a131a01d8257e3190ecb2ed321febc00.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/gui/honeydew_5.png"
dest_files=["res://.godot/imported/honeydew_5.png-a131a01d8257e3190ecb2ed321febc00.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

BIN
assets/textures/gui/honeydew_count.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://c3ed3wq0pq6mf"
path="res://.godot/imported/honeydew_0.png-7e460af95db38f7ccf71cfc3f3210122.ctex"
uid="uid://cbl67su2x66tp"
path="res://.godot/imported/honeydew_count.png-9508de9ae794e619ceb6a6e45fdb8048.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/gui/honeydew_0.png"
dest_files=["res://.godot/imported/honeydew_0.png-7e460af95db38f7ccf71cfc3f3210122.ctex"]
source_file="res://assets/textures/gui/honeydew_count.png"
dest_files=["res://.godot/imported/honeydew_count.png-9508de9ae794e619ceb6a6e45fdb8048.ctex"]
[params]

BIN
assets/textures/gui/pictograms.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/textures/gui/unit_state.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://b0bvmx8e8qc06"
path="res://.godot/imported/honeydew_2.png-f178ab830fa2d76ad851dac2505f7663.ctex"
uid="uid://3dcjgbpixtn1"
path="res://.godot/imported/unit_state.png-e5105ee48539a83148cc624fb2d8513d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/textures/gui/honeydew_2.png"
dest_files=["res://.godot/imported/honeydew_2.png-f178ab830fa2d76ad851dac2505f7663.ctex"]
source_file="res://assets/textures/gui/unit_state.png"
dest_files=["res://.godot/imported/unit_state.png-e5105ee48539a83148cc624fb2d8513d.ctex"]
[params]

View File

@ -52,7 +52,7 @@ offset_right = 232.0
offset_bottom = 55.0
[node name="AntBuyButton" type="TextureButton" parent="."]
modulate = Color(0.827451, 0.717647, 0.564706, 1)
self_modulate = Color(0.827451, 0.717647, 0.564706, 1)
layout_mode = 0
offset_left = 241.0
offset_top = 13.0

View File

@ -57,7 +57,7 @@ offset_bottom = 58.0
texture = SubResource("AtlasTexture_t7i0n")
[node name="BuyNitwitButton" type="TextureButton" parent="."]
modulate = Color(0.827451, 0.717647, 0.564706, 1)
self_modulate = Color(0.827451, 0.717647, 0.564706, 1)
layout_mode = 0
offset_left = 13.0
offset_top = 16.0
@ -92,7 +92,7 @@ offset_right = 220.0
offset_bottom = 71.0
[node name="BuyGathererButton" type="TextureButton" parent="."]
modulate = Color(0.827451, 0.717647, 0.564706, 1)
self_modulate = Color(0.827451, 0.717647, 0.564706, 1)
layout_mode = 0
offset_left = 15.0
offset_top = 77.0

View File

@ -1,9 +1,15 @@
[gd_scene load_steps=2 format=3 uid="uid://w3ydggdgvyqn"]
[gd_scene load_steps=4 format=3 uid="uid://w3ydggdgvyqn"]
[ext_resource type="Script" path="res://scripts/ui/honeydew_counter.gd" id="1_en213"]
[ext_resource type="Texture2D" uid="uid://cbl67su2x66tp" path="res://assets/textures/gui/honeydew_count.png" id="2_thytk"]
[sub_resource type="AtlasTexture" id="AtlasTexture_unwbl"]
atlas = ExtResource("2_thytk")
region = Rect2(0, 0, 128, 128)
[node name="HoneydewCounter" type="ReferenceRect"]
offset_right = 77.0
offset_bottom = 33.0
mouse_filter = 2
script = ExtResource("1_en213")
atlas = SubResource("AtlasTexture_unwbl")

View File

@ -52,7 +52,7 @@ grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxTexture_k576p")
[node name="QuitButton" type="TextureButton" parent="Panel"]
modulate = Color(0.843007, 0.282913, 0.299802, 1)
self_modulate = Color(0.843007, 0.282913, 0.299802, 1)
layout_mode = 0
offset_left = 38.0
offset_top = 24.0
@ -80,7 +80,7 @@ grow_vertical = 2
texture = SubResource("AtlasTexture_td4xc")
[node name="CancelButton" type="TextureButton" parent="Panel"]
modulate = Color(0.827451, 0.717647, 0.564706, 1)
self_modulate = Color(0.827451, 0.717647, 0.564706, 1)
layout_mode = 0
offset_left = 117.0
offset_top = -25.0

View File

@ -1,44 +1,16 @@
[gd_scene load_steps=13 format=3 uid="uid://dhtofjn8dnuw3"]
[gd_scene load_steps=6 format=3 uid="uid://dhtofjn8dnuw3"]
[ext_resource type="Texture2D" uid="uid://cc40vkh4nc6pk" path="res://assets/textures/gui/think_bubble.png" id="1_hsifm"]
[ext_resource type="Script" path="res://scripts/ui/unit_info.gd" id="2_b6c6l"]
[ext_resource type="Texture2D" uid="uid://slraulfmk8c0" path="res://assets/textures/gui/pictograms.png" id="6_vrqjx"]
[ext_resource type="Texture2D" uid="uid://3dcjgbpixtn1" path="res://assets/textures/gui/unit_state.png" id="3_tdly6"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_wrdqv"]
texture = ExtResource("1_hsifm")
modulate_color = Color(0.917647, 0.807843, 0.647059, 1)
[sub_resource type="AtlasTexture" id="AtlasTexture_7modd"]
atlas = ExtResource("6_vrqjx")
region = Rect2(404.555, 93.7849, 67.5499, 53.8488)
[sub_resource type="AtlasTexture" id="AtlasTexture_2jq3t"]
atlas = ExtResource("6_vrqjx")
region = Rect2(476.79, 88.6228, 77.4275, 53.8488)
[sub_resource type="AtlasTexture" id="AtlasTexture_beuyo"]
atlas = ExtResource("6_vrqjx")
region = Rect2(572.197, 83.8424, 60.0876, 64.636)
[sub_resource type="AtlasTexture" id="AtlasTexture_0t4ki"]
atlas = ExtResource("6_vrqjx")
region = Rect2(656.569, 88.7656, 91.2443, 48.374)
[sub_resource type="AtlasTexture" id="AtlasTexture_mcquw"]
atlas = ExtResource("6_vrqjx")
region = Rect2(758.514, 84.6555, 89.4846, 61.9183)
[sub_resource type="AtlasTexture" id="AtlasTexture_ndwb1"]
atlas = ExtResource("6_vrqjx")
region = Rect2(405.682, 154.985, 69.6633, 48.5967)
[sub_resource type="AtlasTexture" id="AtlasTexture_fh2cu"]
atlas = ExtResource("6_vrqjx")
region = Rect2(493.617, 151.821, 88.0582, 58.802)
[sub_resource type="AtlasTexture" id="AtlasTexture_q6lpn"]
atlas = ExtResource("6_vrqjx")
region = Rect2(605.33, 162.323, 47.3997, 44.5031)
[sub_resource type="AtlasTexture" id="AtlasTexture_fbih3"]
atlas = ExtResource("3_tdly6")
region = Rect2(0, 0, 108, 94)
[node name="UnitInfo" type="Panel"]
offset_right = 128.0
@ -50,122 +22,17 @@ mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxTexture_wrdqv")
script = ExtResource("2_b6c6l")
[node name="AntIdle" type="TextureRect" parent="."]
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -26.0
offset_top = -40.0
offset_right = 41.0
offset_bottom = 13.0
offset_left = -55.0
offset_top = -59.0
offset_right = 53.0
offset_bottom = 35.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_7modd")
[node name="AntMoving" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -39.0
offset_top = -41.0
offset_right = 38.0
offset_bottom = 12.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_2jq3t")
[node name="AntPickingUp" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -29.0
offset_top = -48.0
offset_right = 31.0
offset_bottom = 16.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_beuyo")
[node name="AntDepositing" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -47.0
offset_top = -37.0
offset_right = 44.0
offset_bottom = 11.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_0t4ki")
[node name="AntAwaiting" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -44.0
offset_top = -42.0
offset_right = 45.0
offset_bottom = 19.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_mcquw")
[node name="AphidIdle" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -32.0
offset_top = -37.0
offset_right = 37.0
offset_bottom = 11.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_ndwb1")
[node name="AphidPanic" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -43.0
offset_top = -41.0
offset_right = 45.0
offset_bottom = 17.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_fh2cu")
[node name="AphidEat" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -19.0
offset_top = -24.0
offset_right = 28.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_q6lpn")
texture = SubResource("AtlasTexture_fbih3")

View File

@ -6,21 +6,17 @@ const RANDOM_OFFSET: float = 5
const GAP: float = 1
const SPRITES_PER_RECT: int = 5
@export var atlas: AtlasTexture
var rects: Array[TextureRect] = []
var max_count: int = 0
var count_per_row: int = 0
var rect_size: float = RECT_SIZE
var counter_0 := preload("res://assets/textures/gui/honeydew_0.png")
var counter_1 := preload("res://assets/textures/gui/honeydew_1.png")
var counter_2 := preload("res://assets/textures/gui/honeydew_2.png")
var counter_3 := preload("res://assets/textures/gui/honeydew_3.png")
var counter_4 := preload("res://assets/textures/gui/honeydew_4.png")
var counter_5 := preload("res://assets/textures/gui/honeydew_5.png")
func _ready() -> void:
assert(atlas != null, "atlas missing!")
count_per_row = floor(size.x / (rect_size + GAP))
@ -52,29 +48,21 @@ func update_counter(new_count: int) -> void:
for i in range(rects.size()):
var rect := rects[i]
var amount := i * SPRITES_PER_RECT
var count: int = 0
if amount >= new_count:
rect.texture = counter_0
continue
rect.modulate = Color.WHITE
if amount < whole:
rect.texture = counter_5
continue
count = 0
elif amount < whole:
count = 5
else:
count = remainder
match remainder:
1:
rect.texture = counter_1
2:
rect.texture = counter_2
3:
rect.texture = counter_3
4:
rect.texture = counter_4
(rect.texture as AtlasTexture).region.position.x = count * atlas.region.size.x
func _create_rect(col: int, row: int) -> TextureRect:
var rect := TextureRect.new()
add_child(rect)
rect.texture = counter_5
rect.texture = atlas.duplicate()
rect.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
rect.position.x = (
col

View File

@ -13,37 +13,30 @@ enum InfoState {
APHID_EAT,
}
const ANIMATION_SPEED: float = 0.25
var unit: Unit
var state: InfoState = InfoState.NONE
var anim_time: float = 0
@onready var ant_idle: Control = $AntIdle
@onready var ant_moving: Control = $AntMoving
@onready var ant_picking_up: Control = $AntPickingUp
@onready var ant_depositing: Control = $AntDepositing
@onready var ant_awaiting: Control = $AntAwaiting
@onready var aphid_idle: Control = $AphidIdle
@onready var aphid_panic: Control = $AphidPanic
@onready var aphid_eat: Control = $AphidEat
@onready var texture_rect: TextureRect = $TextureRect
@onready var atlas: AtlasTexture = texture_rect.texture as AtlasTexture
func _ready() -> void:
assert(ant_idle != null, "ant_idle missing!")
assert(ant_moving != null, "ant_moving missing!")
assert(ant_picking_up != null, "ant_picking_up missing!")
assert(ant_depositing != null, "ant_depositing missing!")
assert(ant_awaiting != null, "ant_awaiting missing!")
assert(aphid_idle != null, "aphid_idle missing!")
assert(aphid_panic != null, "aphid_panic missing!")
assert(aphid_eat != null, "aphid_eat missing!")
assert(texture_rect != null, "texture_rect missing!")
assert(atlas != null, "atlas missing!")
super._ready()
func _process(delta: float) -> void:
super._process(delta)
if unit == null or not visible:
return
anim_time += delta
_get_state()
_set_image()
_handle_pictogram()
func open(who: Unit) -> void:
@ -59,28 +52,12 @@ func close() -> void:
super.close()
func _set_image() -> void:
for child: Control in get_children():
child.visible = false
match state:
InfoState.ANT_IDLE:
ant_idle.visible = true
InfoState.ANT_MOVING:
ant_moving.visible = true
InfoState.ANT_PICKING_UP:
ant_picking_up.visible = true
InfoState.ANT_DEPOSITING:
ant_depositing.visible = true
InfoState.ANT_AWAITING:
ant_awaiting.visible = true
InfoState.APHID_IDLE:
aphid_idle.visible = true
InfoState.APHID_PANIC:
aphid_panic.visible = true
InfoState.APHID_EAT:
aphid_eat.visible = true
func _handle_pictogram() -> void:
texture_rect.visible = state != InfoState.NONE
atlas.region.position.y = (state - 1) * atlas.region.size.y
atlas.region.position.x = floor(
wrapf(anim_time / ANIMATION_SPEED, 0, 4)
) * atlas.region.size.x
func _get_state() -> void:
if unit is Aphid: