More UI stuff, fancy number display (needs work)
This commit is contained in:
BIN
assets/ui/SO008B.BMP
Normal file
BIN
assets/ui/SO008B.BMP
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 MiB |
40
assets/ui/SO008B.BMP.import
Normal file
40
assets/ui/SO008B.BMP.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cavpqnd0qqoou"
|
||||
path="res://.godot/imported/SO008B.BMP-57a2d92123e6b32a5ec6367855ebadf6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/ui/SO008B.BMP"
|
||||
dest_files=["res://.godot/imported/SO008B.BMP-57a2d92123e6b32a5ec6367855ebadf6.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
|
||||
27
prefabs/StylizedNumberDisplay.tscn
Normal file
27
prefabs/StylizedNumberDisplay.tscn
Normal file
@@ -0,0 +1,27 @@
|
||||
[gd_scene format=3 uid="uid://bc5a7tb0my6n5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://biud4ob4h0rrs" path="res://scripts/ui/stylized_number_display.gd" id="1_s5s2y"]
|
||||
[ext_resource type="Texture2D" uid="uid://cavpqnd0qqoou" path="res://assets/ui/SO008B.BMP" id="2_b1oqg"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_b1oqg"]
|
||||
atlas = ExtResource("2_b1oqg")
|
||||
region = Rect2(546, 839, 272, 39)
|
||||
|
||||
[node name="StylizedNumberDisplay" type="Control" unique_id=702997768]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_s5s2y")
|
||||
sprite_sheet = SubResource("AtlasTexture_b1oqg")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=2089310026]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
@@ -2,12 +2,37 @@
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dx26d6py3n8xi" path="res://resources/main_ui_theme.tres" id="1_2ro41"]
|
||||
[ext_resource type="Script" uid="uid://w2wh6gtv3u2l" path="res://scripts/battle/combat_ui.gd" id="2_ui_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://cavpqnd0qqoou" path="res://assets/ui/SO008B.BMP" id="3_hadma"]
|
||||
[ext_resource type="Texture2D" uid="uid://cau61m1755dkn" path="res://assets/ui/SO008A.BMP" id="3_tfn3h"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc5a7tb0my6n5" path="res://prefabs/StylizedNumberDisplay.tscn" id="5_55shj"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hadma"]
|
||||
atlas = ExtResource("3_tfn3h")
|
||||
region = Rect2(0, 0, 800, 600)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_55shj"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(393, 280, 168, 77)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gqe5k"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(141, 0, 513, 169)
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_hadma"]
|
||||
blend_mode = 1
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3wejr"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(614, 711, 137, 26)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uh1k2"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(614, 737, 55, 20)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yayqj"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(546, 839, 272, 39)
|
||||
|
||||
[node name="BattleViewUI" type="CanvasLayer" unique_id=1093388037]
|
||||
script = ExtResource("2_ui_script")
|
||||
|
||||
@@ -20,16 +45,52 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="Overlay" type="Control" parent="UIBase" unique_id=114439631]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Background" type="TextureRect" parent="UIBase/Overlay" unique_id=1726665864]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("AtlasTexture_hadma")
|
||||
|
||||
[node name="HoverInfo" type="TextureRect" parent="UIBase/Overlay" unique_id=1180275113]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
texture = SubResource("AtlasTexture_55shj")
|
||||
|
||||
[node name="Bars" type="TextureRect" parent="UIBase/Overlay" unique_id=780801800]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -513.0
|
||||
offset_bottom = 169.0
|
||||
grow_horizontal = 0
|
||||
texture = SubResource("AtlasTexture_gqe5k")
|
||||
|
||||
[node name="UnitPanel" type="PanelContainer" parent="UIBase" unique_id=2000000001]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 8.0
|
||||
offset_left = -200.0
|
||||
offset_top = -70.0
|
||||
offset_right = 208.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
theme = ExtResource("1_2ro41")
|
||||
|
||||
@@ -189,11 +250,69 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Cancel"
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="UIBase" unique_id=1726665864]
|
||||
[node name="UnitPanel2" type="Control" parent="UIBase" unique_id=1823763147]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -241.0
|
||||
offset_top = -194.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="UIBase/UnitPanel2" unique_id=1655913738]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("AtlasTexture_hadma")
|
||||
|
||||
[node name="Level" type="Control" parent="UIBase/UnitPanel2/VBoxContainer" unique_id=1602621942]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="UIBase/UnitPanel2/VBoxContainer/Level" unique_id=691752297]
|
||||
material = SubResource("CanvasItemMaterial_hadma")
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -137.0
|
||||
offset_top = -13.0
|
||||
offset_bottom = 13.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
texture = SubResource("AtlasTexture_3wejr")
|
||||
|
||||
[node name="Items" type="HBoxContainer" parent="UIBase/UnitPanel2/VBoxContainer/Level" unique_id=828992814]
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -241.0
|
||||
offset_top = -10.0
|
||||
offset_bottom = 10.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Spacer" type="Control" parent="UIBase/UnitPanel2/VBoxContainer/Level/Items" unique_id=1068603879]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="TextureRect" parent="UIBase/UnitPanel2/VBoxContainer/Level/Items" unique_id=1299333906]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
texture = SubResource("AtlasTexture_uh1k2")
|
||||
|
||||
[node name="StylizedNumberDisplay" parent="UIBase/UnitPanel2/VBoxContainer/Level/Items" unique_id=702997768 instance=ExtResource("5_55shj")]
|
||||
layout_mode = 2
|
||||
sprite_sheet = SubResource("AtlasTexture_yayqj")
|
||||
number_sprite_width = 27
|
||||
number_sprite_height = 36
|
||||
value = 12
|
||||
|
||||
@@ -25,7 +25,7 @@ func _on_unit_unit_allegiance_changed(_unit: Unit, allegiance: UnitAllegiance) -
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fhs1y"]
|
||||
shader = ExtResource("3_fhs1y")
|
||||
shader_parameter/key_color = Color(0, 1, 0, 1)
|
||||
shader_parameter/threshold = 0.750000035625
|
||||
shader_parameter/threshold = 0.010000000475
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fhs1y"]
|
||||
atlas = ExtResource("3_on614")
|
||||
|
||||
@@ -38,5 +38,6 @@ debug_toggle={
|
||||
|
||||
[rendering]
|
||||
|
||||
textures/canvas_textures/default_texture_filter=0
|
||||
rendering_device/driver.windows="d3d12"
|
||||
renderer/rendering_method="mobile"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
[ext_resource type="Shader" uid="uid://dakre5usldk6r" path="res://shaders/masked_palette_swap.gdshader" id="1_nd71p"]
|
||||
[ext_resource type="Texture2D" uid="uid://b8td6sv5re6r8" path="res://assets/sprites/grey_castle_spritesheet_mask.bmp" id="2_7ddre"]
|
||||
[ext_resource type="Texture2D" uid="uid://b20mhn7ca5xyo" path="res://assets/sprites/aux_terrain.BMP" id="5_qjeyg"]
|
||||
[ext_resource type="Script" uid="uid://csdcbi2gtwrly" path="res://scripts/battle/camera_controller.gd" id="6_wtsjf"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc5a7tb0my6n5" path="res://prefabs/StylizedNumberDisplay.tscn" id="7_rnaij"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_qjeyg"]
|
||||
texture = ExtResource("1_7ddre")
|
||||
@@ -66,3 +68,19 @@ texture = SubResource("AtlasTexture_j8ivh")
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="." unique_id=1517711877]
|
||||
texture = SubResource("AtlasTexture_3qnke")
|
||||
|
||||
[node name="CameraController" type="Camera2D" parent="." unique_id=1277373781]
|
||||
script = ExtResource("6_wtsjf")
|
||||
metadata/_custom_type_script = "uid://csdcbi2gtwrly"
|
||||
|
||||
[node name="StylizedNumberDisplay" parent="." unique_id=702997768 instance=ExtResource("7_rnaij")]
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_right = 50.0
|
||||
offset_bottom = 50.0
|
||||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
number_sprite_width = 27
|
||||
number_sprite_height = 36
|
||||
value = 1234567890
|
||||
|
||||
@@ -8,6 +8,7 @@ var scene_registry: Array = [
|
||||
{ "name": "Battle Test", "path": "res://scenes/views/battle_view.tscn" },
|
||||
{ "name": "Main Menu", "path": "res://scenes/views/main_menu_view.tscn" },
|
||||
{ "name": "Dialogue Test", "path": "res://scenes/dialogue_scene.tscn" },
|
||||
{ "name": "Test Scene", "path": "res://scenes/test_scene.tscn" },
|
||||
]
|
||||
|
||||
var commands: Array[ConsoleCommand] = []
|
||||
|
||||
44
scripts/ui/stylized_number_display.gd
Normal file
44
scripts/ui/stylized_number_display.gd
Normal file
@@ -0,0 +1,44 @@
|
||||
class_name StylizedNumberDisplay extends Control
|
||||
|
||||
@export var sprite_sheet: AtlasTexture
|
||||
@export var number_sprite_width: int
|
||||
@export var number_sprite_height: int
|
||||
@export var value: int = 0:
|
||||
set(v):
|
||||
value = v
|
||||
if is_node_ready():
|
||||
_refresh()
|
||||
|
||||
@onready var _container: HBoxContainer = %HBoxContainer
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_refresh()
|
||||
|
||||
|
||||
func _get_minimum_size() -> Vector2:
|
||||
var digit_count := str(absi(value)).length()
|
||||
var spacing: int = _container.get_theme_constant("separation") if is_node_ready() else 0
|
||||
var total_width: int = digit_count * number_sprite_width + maxi(digit_count - 1, 0) * spacing
|
||||
return Vector2(total_width, number_sprite_height)
|
||||
|
||||
|
||||
func _refresh() -> void:
|
||||
for child in _container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
var digits := str(absi(value))
|
||||
for i in digits.length():
|
||||
var digit := digits[i].to_int()
|
||||
var atlas_tex := AtlasTexture.new()
|
||||
atlas_tex.atlas = sprite_sheet.atlas
|
||||
atlas_tex.region = Rect2(
|
||||
sprite_sheet.region.position.x + digit * number_sprite_width,
|
||||
sprite_sheet.region.position.y,
|
||||
number_sprite_width,
|
||||
number_sprite_height,
|
||||
)
|
||||
var tex_rect := TextureRect.new()
|
||||
tex_rect.texture = atlas_tex
|
||||
_container.add_child(tex_rect)
|
||||
update_minimum_size()
|
||||
1
scripts/ui/stylized_number_display.gd.uid
Normal file
1
scripts/ui/stylized_number_display.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://biud4ob4h0rrs
|
||||
Reference in New Issue
Block a user