wonky polygon ui rework
This commit is contained in:
parent
6bdc9617b2
commit
6c55d719ff
22 changed files with 165 additions and 117 deletions
31
src/ui/PlayerHud.cs
Normal file
31
src/ui/PlayerHud.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace Dancer;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class PlayerHud : Control
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Export] private Player Player { get; set; } = null!;
|
||||
|
||||
[Node] private Polygon2D HpBar { get; set; } = null!;
|
||||
[Node] private Polygon2D EnergyBar0 { get; set; } = null!;
|
||||
[Node] private Polygon2D EnergyBar1 { get; set; } = null!;
|
||||
|
||||
public void OnReady() => SetProcess(true);
|
||||
|
||||
public void OnProcess(double delta)
|
||||
{
|
||||
((ShaderMaterial)HpBar.Material).SetShaderParameter("ratios",
|
||||
stackalloc float[] { 0f, 0f, Player.Health / Player.MaxHealth, 0f });
|
||||
|
||||
var energy0Fill = Mathf.Clamp(Player.DashPoints - 0f, 0f, 1f);
|
||||
((ShaderMaterial)EnergyBar0.Material).SetShaderParameter("ratios",
|
||||
stackalloc float[] { 0f, 0f, energy0Fill, 0f });
|
||||
|
||||
var energy1Fill = Mathf.Clamp(Player.DashPoints - 1f, 0f, 1f);
|
||||
((ShaderMaterial)EnergyBar1.Material).SetShaderParameter("ratios",
|
||||
stackalloc float[] { 0f, 0f, energy1Fill, 0f });
|
||||
}
|
||||
}
|
||||
1
src/ui/PlayerHud.cs.uid
Normal file
1
src/ui/PlayerHud.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dsbiwhvdat5ul
|
||||
BIN
src/ui/energy_bar.aseprite
(Stored with Git LFS)
Normal file
BIN
src/ui/energy_bar.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
src/ui/energy_bar.png
(Stored with Git LFS)
Normal file
BIN
src/ui/energy_bar.png
(Stored with Git LFS)
Normal file
Binary file not shown.
40
src/ui/energy_bar.png.import
Normal file
40
src/ui/energy_bar.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dwiu5ej85fc3i"
|
||||
path="res://.godot/imported/energy_bar.png-02c88baf398c7dd6c09b262e160b55f4.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/ui/energy_bar.png"
|
||||
dest_files=["res://.godot/imported/energy_bar.png-02c88baf398c7dd6c09b262e160b55f4.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
|
||||
BIN
src/ui/hp_bar.aseprite
(Stored with Git LFS)
Normal file
BIN
src/ui/hp_bar.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
src/ui/hp_bar.png
(Stored with Git LFS)
Normal file
BIN
src/ui/hp_bar.png
(Stored with Git LFS)
Normal file
Binary file not shown.
40
src/ui/hp_bar.png.import
Normal file
40
src/ui/hp_bar.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c0kdbshy1ipbe"
|
||||
path="res://.godot/imported/hp_bar.png-dad149f5958edda274a5b787fdfb48fd.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/ui/hp_bar.png"
|
||||
dest_files=["res://.godot/imported/hp_bar.png-dad149f5958edda274a5b787fdfb48fd.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
|
||||
BIN
src/ui/player_hud.aseprite
(Stored with Git LFS)
Normal file
BIN
src/ui/player_hud.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
src/ui/player_hud.png
(Stored with Git LFS)
Normal file
BIN
src/ui/player_hud.png
(Stored with Git LFS)
Normal file
Binary file not shown.
40
src/ui/player_hud.png.import
Normal file
40
src/ui/player_hud.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b7xxxshusx3sm"
|
||||
path="res://.godot/imported/player_hud.png-9842985ced4432e20f5da32d9c77546a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/ui/player_hud.png"
|
||||
dest_files=["res://.godot/imported/player_hud.png-9842985ced4432e20f5da32d9c77546a.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
|
||||
73
src/ui/player_hud.tscn
Normal file
73
src/ui/player_hud.tscn
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
[gd_scene format=3 uid="uid://llohfwmma2hv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dsbiwhvdat5ul" path="res://src/ui/PlayerHud.cs" id="1_580w7"]
|
||||
[ext_resource type="Shader" uid="uid://b5o01h7x0g8e5" path="res://src/ui/wobbly.gdshader" id="2_580w7"]
|
||||
[ext_resource type="Shader" uid="uid://ddhhiokx3ekiu" path="res://src/ui/poly_bar.gdshader" id="3_gukev"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_580w7"]
|
||||
shader = ExtResource("2_580w7")
|
||||
shader_parameter/frequency = 0.125
|
||||
shader_parameter/amplitude = 1.83
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_uku0i"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("3_gukev")
|
||||
shader_parameter/ratios = PackedFloat32Array(0, 0, 0.765, 0)
|
||||
shader_parameter/empty_color = Color(0.12955844, 0.12955847, 0.12955844, 1)
|
||||
shader_parameter/colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1, 0.15294118, 0.827451, 0.79607844, 1, 0, 0, 0, 1)
|
||||
shader_parameter/frequency = 0.125
|
||||
shader_parameter/amplitude = 1.0
|
||||
|
||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_wcly6"]
|
||||
size = Vector2(32, 32)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_i7kvj"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("3_gukev")
|
||||
shader_parameter/ratios = PackedFloat32Array(0, 0, 0.765, 0)
|
||||
shader_parameter/empty_color = Color(0.12955844, 0.12955847, 0.12955844, 1)
|
||||
shader_parameter/colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1, 1, 0.43137255, 0.6862745, 1, 0, 0, 0, 1)
|
||||
shader_parameter/frequency = 0.125
|
||||
shader_parameter/amplitude = 1.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_1dykc"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("3_gukev")
|
||||
shader_parameter/ratios = PackedFloat32Array(0, 0, 0.765, 0)
|
||||
shader_parameter/empty_color = Color(0.12955844, 0.12955847, 0.12955844, 1)
|
||||
shader_parameter/colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1, 1, 0.43137255, 0.6862745, 1, 0, 0, 0, 1)
|
||||
shader_parameter/frequency = 0.125
|
||||
shader_parameter/amplitude = 1.0
|
||||
|
||||
[node name="PlayerHud" type="Control" unique_id=763981532]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_580w7")
|
||||
|
||||
[node name="Background" type="Polygon2D" parent="." unique_id=1500138878]
|
||||
material = SubResource("ShaderMaterial_580w7")
|
||||
color = Color(0, 0, 0, 1)
|
||||
polygon = PackedVector2Array(3, 2, 2, 25, 32, 32, 55, 18, 92, 21, 110, -1)
|
||||
|
||||
[node name="HpBar" type="Polygon2D" parent="." unique_id=676108210]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource("ShaderMaterial_uku0i")
|
||||
texture = SubResource("PlaceholderTexture2D_wcly6")
|
||||
polygon = PackedVector2Array(8, 6, 99, 3, 88, 15, 8, 13)
|
||||
uv = PackedVector2Array(0.18070698, 7.5369415, 31.720398, 1.6552172, 31.191221, 6.699565, 0.67256737, 9.95163)
|
||||
|
||||
[node name="EnergyBar0" type="Polygon2D" parent="." unique_id=800795938]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource("ShaderMaterial_i7kvj")
|
||||
texture = SubResource("PlaceholderTexture2D_wcly6")
|
||||
polygon = PackedVector2Array(8, 16, 24, 17, 19, 24, 6, 22)
|
||||
uv = PackedVector2Array(-0.058876038, 12.0672, 31.749325, -0.97031116, 28.649677, 17.21373, 1.6946745, 25.515366)
|
||||
|
||||
[node name="EnergyBar1" type="Polygon2D" parent="." unique_id=2035511932]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource("ShaderMaterial_1dykc")
|
||||
texture = SubResource("PlaceholderTexture2D_wcly6")
|
||||
polygon = PackedVector2Array(28, 18, 45, 19, 34, 27, 22, 25)
|
||||
uv = PackedVector2Array(1.3059769, 25.891489, 31.327286, -2.5226192, 27.199902, 30.23344, 3.7188683, 48.139774)
|
||||
27
src/ui/poly_bar.gdshader
Normal file
27
src/ui/poly_bar.gdshader
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
const int count = 4;
|
||||
|
||||
uniform float ratios[count];
|
||||
uniform vec3 empty_color : source_color;
|
||||
uniform vec3 colors[count] : source_color;
|
||||
|
||||
uniform float frequency = 1.0;
|
||||
uniform float amplitude = 1.0;
|
||||
|
||||
#include "res://src/shaders/vertex_fun.gdshaderinc"
|
||||
|
||||
void vertex() {
|
||||
VERTEX += wobble(VERTEX, frequency, amplitude);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec3 base_color = empty_color;
|
||||
for (int idx = 0; idx < count; idx++) {
|
||||
float ratio = ratios[idx];
|
||||
vec3 fill_color = colors[idx];
|
||||
if (ratio >= UV.x)
|
||||
base_color = fill_color;
|
||||
}
|
||||
COLOR = vec4(base_color, 1.0);
|
||||
}
|
||||
1
src/ui/poly_bar.gdshader.uid
Normal file
1
src/ui/poly_bar.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ddhhiokx3ekiu
|
||||
10
src/ui/wobbly.gdshader
Normal file
10
src/ui/wobbly.gdshader
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform float frequency = 1.0;
|
||||
uniform float amplitude = 1.0;
|
||||
|
||||
#include "res://src/shaders/vertex_fun.gdshaderinc"
|
||||
|
||||
void vertex() {
|
||||
VERTEX += wobble(VERTEX, frequency, amplitude);
|
||||
}
|
||||
1
src/ui/wobbly.gdshader.uid
Normal file
1
src/ui/wobbly.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b5o01h7x0g8e5
|
||||
Loading…
Add table
Add a link
Reference in a new issue