weapon display
This commit is contained in:
parent
553f8ea77a
commit
8fadd143c3
26 changed files with 491 additions and 46 deletions
26
gui/weapon_display/horizontal_indicator.tscn
Normal file
26
gui/weapon_display/horizontal_indicator.tscn
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://iw76qt0vo57b"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bft3coi8fq4tr" path="res://gui/weapon_display/weapon_display_indicator.gd" id="1_amsli"]
|
||||
[ext_resource type="Texture2D" uid="uid://dnxw4x3cmu7io" path="res://icon.svg" id="2_qss44"]
|
||||
|
||||
[node name="VerticalIndicator" type="HBoxContainer" groups=["weapon_indicator"]]
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
offset_right = 64.0
|
||||
offset_bottom = 64.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_amsli")
|
||||
|
||||
[node name="Texture" type="TextureRect" parent="."]
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("2_qss44")
|
||||
expand_mode = 4
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Mark" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
26
gui/weapon_display/vertical_indicator.tscn
Normal file
26
gui/weapon_display/vertical_indicator.tscn
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://opxpjjslpoc3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bft3coi8fq4tr" path="res://gui/weapon_display/weapon_display_indicator.gd" id="1_unomd"]
|
||||
[ext_resource type="Texture2D" uid="uid://dnxw4x3cmu7io" path="res://icon.svg" id="2_gnxu7"]
|
||||
|
||||
[node name="VerticalIndicator" type="VBoxContainer" groups=["weapon_indicator"]]
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
offset_right = 64.0
|
||||
offset_bottom = 64.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_unomd")
|
||||
|
||||
[node name="Texture" type="TextureRect" parent="."]
|
||||
self_modulate = Color(0.76, 0.76, 0.76, 1)
|
||||
custom_minimum_size = Vector2(64, 64)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("2_gnxu7")
|
||||
expand_mode = 2
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Mark" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
13
gui/weapon_display/weapon_display.gd
Normal file
13
gui/weapon_display/weapon_display.gd
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
extends Control
|
||||
|
||||
|
||||
func on_slots_changed(current_slot: StringName, slots_data: Dictionary[StringName,StringName]):
|
||||
for indicator in get_tree().get_nodes_in_group("weapon_indicator"):
|
||||
var slot_accessed_data = slots_data[indicator.lookup_slot]
|
||||
if slot_accessed_data == "":
|
||||
indicator.hide()
|
||||
continue
|
||||
indicator.show()
|
||||
var weapon = Registry.weapons[slot_accessed_data]
|
||||
indicator.set_weapon(weapon)
|
||||
indicator.set_current(current_slot == indicator.lookup_slot)
|
||||
1
gui/weapon_display/weapon_display.gd.uid
Normal file
1
gui/weapon_display/weapon_display.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bdjp20eo2uw0d
|
||||
80
gui/weapon_display/weapon_display.tscn
Normal file
80
gui/weapon_display/weapon_display.tscn
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bqdcjq12tbh0s"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://opxpjjslpoc3" path="res://gui/weapon_display/vertical_indicator.tscn" id="1_bwhua"]
|
||||
[ext_resource type="Script" uid="uid://bdjp20eo2uw0d" path="res://gui/weapon_display/weapon_display.gd" id="1_nv6sv"]
|
||||
[ext_resource type="PackedScene" uid="uid://iw76qt0vo57b" path="res://gui/weapon_display/horizontal_indicator.tscn" id="2_hf8mm"]
|
||||
|
||||
[node name="WeaponDisplay" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_nv6sv")
|
||||
|
||||
[node name="AbilityContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.27265626
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.72734374
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
alignment = 1
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="FirstAbility" parent="AbilityContainer" instance=ExtResource("1_bwhua")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
lookup_slot = &"ability_first"
|
||||
lookup_action = &"plr_active_first"
|
||||
|
||||
[node name="SecondAbility" parent="AbilityContainer" instance=ExtResource("1_bwhua")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
lookup_slot = &"ability_second"
|
||||
lookup_action = &"plr_active_second"
|
||||
|
||||
[node name="ThirdAbility" parent="AbilityContainer" instance=ExtResource("1_bwhua")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
lookup_slot = &"ability_third"
|
||||
lookup_action = &"plr_active_third"
|
||||
|
||||
[node name="WeaponContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.9359375
|
||||
anchor_top = 0.5138889
|
||||
anchor_right = 0.9898437
|
||||
anchor_bottom = 0.88611114
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Primary" parent="WeaponContainer" instance=ExtResource("2_hf8mm")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
lookup_slot = &"primary"
|
||||
lookup_action = &"plr_primary"
|
||||
|
||||
[node name="Secondary" parent="WeaponContainer" instance=ExtResource("2_hf8mm")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
lookup_slot = &"secondary"
|
||||
lookup_action = &"plr_secondary"
|
||||
|
||||
[node name="Knife" parent="WeaponContainer" instance=ExtResource("2_hf8mm")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
lookup_slot = &"knife"
|
||||
lookup_action = &"plr_knife"
|
||||
|
||||
[node name="Bomb" parent="WeaponContainer" instance=ExtResource("2_hf8mm")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
lookup_slot = &"bomb"
|
||||
lookup_action = &"plr_bomb"
|
||||
18
gui/weapon_display/weapon_display_indicator.gd
Normal file
18
gui/weapon_display/weapon_display_indicator.gd
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
extends Container
|
||||
|
||||
const CURRENT_COLOR = Color("ffffff")
|
||||
const NOT_CURRENT_COLOR = Color("d4d4d4")
|
||||
|
||||
@onready var texture: TextureRect = $Texture
|
||||
@onready var button_mark: Label = $Mark
|
||||
@export var lookup_slot: StringName
|
||||
@export var lookup_action: StringName
|
||||
|
||||
func _ready():
|
||||
button_mark.text = InputMap.get_action_description(lookup_action).left(1)
|
||||
|
||||
func set_weapon(resource: WeaponResource):
|
||||
texture.texture = resource.preview
|
||||
|
||||
func set_current(current):
|
||||
texture.self_modulate = CURRENT_COLOR if current else NOT_CURRENT_COLOR
|
||||
1
gui/weapon_display/weapon_display_indicator.gd.uid
Normal file
1
gui/weapon_display/weapon_display_indicator.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bft3coi8fq4tr
|
||||
Loading…
Add table
Add a link
Reference in a new issue