Global refactor

This commit is contained in:
Rendo 2025-12-09 11:53:52 +05:00
commit 0589ca4e23
180 changed files with 249 additions and 401 deletions

View file

@ -0,0 +1,15 @@
extends Button
@export var weapon: WeaponResource
func _ready() -> void:
icon = weapon.preview
text = str(weapon.cost)
func _pressed() -> void:
var player_data = Session.get_player_data()
if player_data["money"] >= weapon.cost:
var player: Player = Session.player_nodes[multiplayer.get_unique_id()]
player_data["money"] -= weapon.cost
player.get_node("WeaponSystem").add(weapon.weapon_system_scene.instantiate(),"ability_first")

View file

@ -0,0 +1 @@
uid://bq32y7eee1f63

View file

@ -0,0 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://b1ej6kmbjpm78"]
[ext_resource type="Texture2D" uid="uid://dnxw4x3cmu7io" path="res://icon.svg" id="1_apu4l"]
[ext_resource type="Script" uid="uid://bq32y7eee1f63" path="res://gui/buy_menu/buy_button/buy_button.gd" id="1_impj7"]
[node name="BuyButton" type="Button"]
anchors_preset = -1
anchor_right = 0.035
anchor_bottom = 0.075
offset_right = -4.799999
offset_bottom = -14.000004
text = "3600"
icon = ExtResource("1_apu4l")
icon_alignment = 1
vertical_icon_alignment = 0
expand_icon = true
script = ExtResource("1_impj7")

29
gui/buy_menu/buy_menu.gd Normal file
View file

@ -0,0 +1,29 @@
extends ColorRect
func _ready() -> void:
Session.round_state_changed.connect(on_round_state_changed)
func on_round_state_changed(state: int) -> void:
if state != Session.ROUND_STATES.BUY:
visible = false
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _input(event: InputEvent) -> void:
if event.is_action_pressed("plr_buy"):
if Session.round_state == Session.ROUND_STATES.BUY:
visible = not visible
else:
visible = false
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE

View file

@ -0,0 +1 @@
uid://dba17sgimp4j0

View file

@ -0,0 +1,45 @@
[gd_scene load_steps=5 format=3 uid="uid://j5lgbg8c0pq"]
[ext_resource type="PackedScene" uid="uid://b1ej6kmbjpm78" path="res://gui/buy_menu/buy_button/buy_button.tscn" id="1_8guql"]
[ext_resource type="Script" uid="uid://dba17sgimp4j0" path="res://gui/buy_menu/buy_menu.gd" id="1_ko0fn"]
[ext_resource type="Resource" uid="uid://b081hg7uxx1wu" path="res://weapons/molikman_molotov.tres" id="2_0gws3"]
[ext_resource type="Script" uid="uid://dk4diwvruvkch" path="res://gui/buy_menu/player_money_label.gd" id="2_ll0n6"]
[node name="BuyMenu" type="ColorRect"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.22745098)
script = ExtResource("1_ko0fn")
[node name="CenterContainer" type="CenterContainer" parent="."]
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="PanelContainer" type="PanelContainer" parent="CenterContainer"]
layout_mode = 2
[node name="AbilitiesContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
script = ExtResource("2_ll0n6")
[node name="WeaponsContainer" type="GridContainer" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
columns = 5
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
[node name="BuyButton" parent="CenterContainer/PanelContainer/AbilitiesContainer/HBoxContainer" instance=ExtResource("1_8guql")]
layout_mode = 2
weapon = ExtResource("2_0gws3")

View file

@ -0,0 +1,7 @@
extends Label
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
var data = Session.get_player_data()
if data.has("money"):
text = str(data["money"])

View file

@ -0,0 +1 @@
uid://dk4diwvruvkch