generated from krampus/template-godot4
Added cool curve bar
This commit is contained in:
parent
9d6821962b
commit
1a622ff3b1
|
@ -3,15 +3,39 @@ class_name Arc extends Control
|
|||
|
||||
const BASE_POINTS := 64
|
||||
|
||||
@export var gap_angle := 0.1
|
||||
@export var width := 1.0
|
||||
@export var antialiased := true
|
||||
@export var color: Color
|
||||
@export_range(-360, 360, 0.001, "radians") var arc_start := 0.1:
|
||||
set(value):
|
||||
arc_start = value
|
||||
queue_redraw()
|
||||
@export_range(-360, 360, 0.001, "radians") var arc_end := TAU:
|
||||
set(value):
|
||||
arc_end = value
|
||||
queue_redraw()
|
||||
@export var width := 1.0:
|
||||
set(value):
|
||||
width = value
|
||||
queue_redraw()
|
||||
@export var antialiased := true:
|
||||
set(value):
|
||||
antialiased = value
|
||||
queue_redraw()
|
||||
@export var color: Color:
|
||||
set(value):
|
||||
color = value
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var radius: float = minf(size.x, size.y) / 2.0
|
||||
var point_count: int = int(BASE_POINTS * (TAU - gap_angle) / TAU)
|
||||
var width_buffer: float = floor(width / 2.0)
|
||||
var point_count: int = int(BASE_POINTS * (arc_end - arc_start) / TAU)
|
||||
draw_arc(
|
||||
Vector2(radius, radius), radius, gap_angle, TAU, point_count, color, width, antialiased
|
||||
Vector2(radius, radius),
|
||||
radius - width_buffer,
|
||||
arc_start,
|
||||
arc_end,
|
||||
point_count,
|
||||
color,
|
||||
width,
|
||||
antialiased
|
||||
)
|
||||
|
|
|
@ -68,7 +68,7 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
pivot_offset = Vector2(300, 300)
|
||||
script = ExtResource("2_vijl7")
|
||||
gap_angle = 0.6
|
||||
arc_start = 0.610865
|
||||
width = 36.0
|
||||
color = Color(0, 0, 0, 0.392157)
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
@tool
|
||||
class_name CurveBar extends Control
|
||||
## Swinging arc used to set the curve of a shot.
|
||||
|
||||
const PIVOT_SCALE := -PI / 4
|
||||
|
||||
@export var gradient: Gradient:
|
||||
set(value):
|
||||
if gradient_tex:
|
||||
gradient_tex.gradient = value
|
||||
gradient = value
|
||||
|
||||
@export var value: float:
|
||||
set(v):
|
||||
if pivot:
|
||||
pivot.rotation = v * PIVOT_SCALE
|
||||
get:
|
||||
return pivot.rotation / PIVOT_SCALE if pivot else 0
|
||||
|
||||
@onready var pivot: Control = %Pivot
|
||||
@onready var gradient_fill: TextureRect = %GradientFill
|
||||
@onready var gradient_tex: GradientTexture2D = gradient_fill.texture
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
gradient = gradient
|
|
@ -0,0 +1,103 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://mm02j126jo1h"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ui/shot_hud/curve_bar/curve_bar.gd" id="1_aqvdi"]
|
||||
[ext_resource type="Gradient" uid="uid://k7867gxaxx57" path="res://src/ui/shot_hud/curve_bar/one_sided_gradient.tres" id="2_f3fom"]
|
||||
[ext_resource type="Texture2D" uid="uid://du3vk5nnksohs" path="res://assets/sprites/particles/sparkle.png" id="3_2tv33"]
|
||||
[ext_resource type="Script" path="res://src/ui/decorations/arc.gd" id="4_s2bpl"]
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_o88ik"]
|
||||
gradient = ExtResource("2_f3fom")
|
||||
width = 128
|
||||
height = 128
|
||||
fill = 1
|
||||
fill_from = Vector2(0.5, 0.02)
|
||||
fill_to = Vector2(0.5, 0.37)
|
||||
metadata/_snap_enabled = true
|
||||
|
||||
[node name="CurveBar" 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_aqvdi")
|
||||
gradient = ExtResource("2_f3fom")
|
||||
|
||||
[node name="Reticle" type="TextureRect" parent="."]
|
||||
texture_filter = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("3_2tv33")
|
||||
|
||||
[node name="Pivot" type="Control" parent="Reticle"]
|
||||
unique_name_in_owner = true
|
||||
show_behind_parent = true
|
||||
texture_filter = 6
|
||||
custom_minimum_size = Vector2(600, 600)
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -300.0
|
||||
offset_top = -32.0
|
||||
offset_right = 300.0
|
||||
offset_bottom = 568.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
pivot_offset = Vector2(300, 300)
|
||||
|
||||
[node name="ArcBG" type="Control" parent="Reticle/Pivot"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("4_s2bpl")
|
||||
arc_start = -2.35619
|
||||
arc_end = -0.785398
|
||||
width = 32.0
|
||||
color = Color(0.0352941, 0.0784314, 0.160784, 0.784314)
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Reticle/Pivot"]
|
||||
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 = 3
|
||||
theme_override_constants/margin_top = 3
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_bottom = 3
|
||||
|
||||
[node name="ArcFill" type="Control" parent="Reticle/Pivot/MarginContainer"]
|
||||
clip_children = 1
|
||||
layout_mode = 2
|
||||
script = ExtResource("4_s2bpl")
|
||||
arc_start = -2.35619
|
||||
arc_end = -0.785398
|
||||
width = 26.0
|
||||
|
||||
[node name="GradientFill" type="TextureRect" parent="Reticle/Pivot/MarginContainer/ArcFill"]
|
||||
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
|
||||
texture = SubResource("GradientTexture2D_o88ik")
|
|
@ -0,0 +1,6 @@
|
|||
[gd_resource type="Gradient" format=3 uid="uid://k7867gxaxx57"]
|
||||
|
||||
[resource]
|
||||
interpolation_color_space = 2
|
||||
offsets = PackedFloat32Array(0, 0.25, 0.5, 0.75, 1)
|
||||
colors = PackedColorArray(1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0)
|
|
@ -0,0 +1,6 @@
|
|||
[gd_resource type="Gradient" format=3 uid="uid://3achrua4vnny"]
|
||||
|
||||
[resource]
|
||||
interpolation_color_space = 2
|
||||
offsets = PackedFloat32Array(0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1)
|
||||
colors = PackedColorArray(1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0)
|
|
@ -9,7 +9,7 @@ const LIFE_BAR_DAMAGE_RUMBLE_TIME := 0.2
|
|||
var player: WorldPlayer
|
||||
|
||||
@onready var power_bar: TextureProgressBar = %PowerBar
|
||||
@onready var curve_bar: ProgressBar = %CurveBar
|
||||
@onready var curve_bar: CurveBar = %CurveBar
|
||||
@onready var life_bar: TextureProgressBar = %LifeBar
|
||||
|
||||
@onready var club_selector: ClubSelector = %ClubSelector
|
||||
|
@ -111,8 +111,8 @@ func set_life_value(new_value: float) -> void:
|
|||
life_bar.value = new_value
|
||||
|
||||
|
||||
static func create(player: WorldPlayer) -> ShotHUD:
|
||||
static func create(_player: WorldPlayer) -> ShotHUD:
|
||||
var instance: ShotHUD = scene.instantiate()
|
||||
instance.player = player
|
||||
instance.player = _player
|
||||
|
||||
return instance
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=34 format=3 uid="uid://c4ifdiohng830"]
|
||||
[gd_scene load_steps=35 format=3 uid="uid://c4ifdiohng830"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ui/shot_hud/shot_hud.gd" id="1_x5b4c"]
|
||||
[ext_resource type="Shader" path="res://src/shaders/canvas_retro.gdshader" id="1_ybxxp"]
|
||||
|
@ -7,6 +7,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://b5812y3pmmgg5" path="res://assets/ui/gauge_patch.png" id="4_5kcpe"]
|
||||
[ext_resource type="Texture2D" uid="uid://76fjx2ukavqe" path="res://assets/ui/power_gauge_fill.png" id="5_3i1yq"]
|
||||
[ext_resource type="Texture2D" uid="uid://4a8tvjgwegv3" path="res://assets/ui/power_gauge_tab.png" id="6_sw48q"]
|
||||
[ext_resource type="PackedScene" uid="uid://mm02j126jo1h" path="res://src/ui/shot_hud/curve_bar/curve_bar.tscn" id="7_kqi7w"]
|
||||
[ext_resource type="PackedScene" uid="uid://b0yr0w0xv8cm5" path="res://src/ui/shot_hud/ball_selector/ball_selector.tscn" id="8_b2302"]
|
||||
[ext_resource type="FontFile" uid="uid://dsa0oh7c0h4pu" path="res://assets/fonts/Racing_Sans_One/RacingSansOne-Regular.ttf" id="8_bejx4"]
|
||||
[ext_resource type="Texture2D" uid="uid://tancoet1lih5" path="res://assets/ui/ball_icons/basic_icon.png" id="8_tt8i3"]
|
||||
|
@ -718,19 +719,9 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="CurveBar" type="ProgressBar" parent="ShotGauges/CurveGauge"]
|
||||
[node name="CurveBar" parent="ShotGauges/CurveGauge" instance=ExtResource("7_kqi7w")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -13.5
|
||||
offset_bottom = 13.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
min_value = -1.0
|
||||
max_value = 1.0
|
||||
|
||||
[node name="CurveAnimation" type="AnimationPlayer" parent="ShotGauges/CurveGauge"]
|
||||
unique_name_in_owner = true
|
||||
|
|
Loading…
Reference in New Issue