Skip to content

Commit

Permalink
work on match UI
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitaiMazliah committed Dec 15, 2023
1 parent 32b2ef5 commit aba5fcd
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 73 deletions.
Binary file removed art/8-JujDgNyqVKNI2d5.png
Binary file not shown.
34 changes: 0 additions & 34 deletions art/8-JujDgNyqVKNI2d5.png.import

This file was deleted.

19 changes: 19 additions & 0 deletions prefabs/ui/agent_panel.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[gd_scene load_steps=3 format=3 uid="uid://c4ux05o5ugmaw"]

[ext_resource type="Script" path="res://scripts/UI/match/player_panel.gd" id="1_4i5iu"]
[ext_resource type="Texture2D" uid="uid://dhlgpfw72xdwl" path="res://art/Untitled_design-removebg-preview.png" id="2_y6c2m"]

[node name="PlayerPanel" type="Panel"]
custom_minimum_size = Vector2(150, 0)
script = ExtResource("1_4i5iu")

[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("2_y6c2m")
expand_mode = 1
stretch_mode = 5
70 changes: 70 additions & 0 deletions prefabs/ui/status_details.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[gd_scene load_steps=4 format=3 uid="uid://geywmdguejwv"]

[ext_resource type="Script" path="res://scripts/UI/match/status_details.gd" id="1_ynvy0"]
[ext_resource type="Theme" uid="uid://dx4axq65l727t" path="res://theme.tres" id="2_mhgh5"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dj5y3"]
bg_color = Color(0.133333, 0.301961, 0.423529, 1)
border_width_left = 3
border_width_top = 3
border_width_right = 3
border_width_bottom = 3
border_color = Color(0.690196, 0.768627, 0.886275, 1)
corner_radius_top_left = 10
corner_radius_top_right = 10
corner_radius_bottom_right = 10
corner_radius_bottom_left = 10

[node name="StatusDetails" type="Control"]
custom_minimum_size = Vector2(428, 100)
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_ynvy0")

[node name="ItemStatsPanel" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("2_mhgh5")
theme_override_styles/panel = SubResource("StyleBoxFlat_dj5y3")

[node name="MarginContainer" type="MarginContainer" parent="ItemStatsPanel"]
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 = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10

[node name="Control" type="Control" parent="ItemStatsPanel/MarginContainer"]
layout_mode = 2

[node name="StatusNameLabel" type="Label" parent="ItemStatsPanel/MarginContainer/Control"]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 33.0
grow_horizontal = 2
theme_override_font_sizes/font_size = 22
text = "name"
vertical_alignment = 1

[node name="StatusDescriptionLabel" type="Label" parent="ItemStatsPanel/MarginContainer/Control"]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -27.0
grow_horizontal = 2
grow_vertical = 0
theme_override_font_sizes/font_size = 18
text = "description"
vertical_alignment = 1
3 changes: 2 additions & 1 deletion resources/items/ice-staff.tres
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
[sub_resource type="Resource" id="Resource_ej7sp"]
script = ExtResource("2_vc4og")
change_percentage = -0.05
duration = 1
name = "Slowed"
description = "haha u r slowed"

[sub_resource type="Resource" id="Resource_jeerm"]
script = ExtResource("1_87cl2")
Expand Down
81 changes: 52 additions & 29 deletions scenes/node.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[gd_scene load_steps=23 format=3 uid="uid://cgff2q1lirw7t"]
[gd_scene load_steps=26 format=3 uid="uid://cgff2q1lirw7t"]

[ext_resource type="Script" path="res://scripts/UI/match_ui.gd" id="1_i1hxe"]
[ext_resource type="Resource" uid="uid://d0e5uorq1a1rt" path="res://resources/events/victory_event_channel.tres" id="2_fwcwo"]
[ext_resource type="Resource" uid="uid://ceg0y65hkm0a2" path="res://resources/events/defeat_event_channel.tres" id="3_bimw1"]
[ext_resource type="Resource" uid="uid://c1hpycii541ab" path="res://resources/events/load_main_menu_event_channel.tres" id="4_12k3b"]
[ext_resource type="Theme" uid="uid://dx4axq65l727t" path="res://theme.tres" id="5_wvhhm"]
[ext_resource type="PackedScene" uid="uid://bp22mksxi8dw0" path="res://prefabs/turn_queue.tscn" id="6_m7c8m"]
[ext_resource type="PackedScene" uid="uid://c4ux05o5ugmaw" path="res://prefabs/ui/agent_panel.tscn" id="6_rbyna"]
[ext_resource type="PackedScene" uid="uid://dd6skvb0tvmwh" path="res://prefabs/agents/player_agent.tscn" id="6_xu7ma"]
[ext_resource type="Script" path="res://scripts/UI/match/agent_details_panel.gd" id="8_y0ba1"]
[ext_resource type="PackedScene" uid="uid://vwth8qa6lmwn" path="res://prefabs/agents/ai_agent.tscn" id="9_0ka0l"]
[ext_resource type="PackedScene" uid="uid://geywmdguejwv" path="res://prefabs/ui/status_details.tscn" id="9_iq8yi"]
[ext_resource type="PhysicsMaterial" uid="uid://hlsflh436ngb" path="res://arena_wall_physics_material.tres" id="9_ub7xk"]

[sub_resource type="PlaneMesh" id="PlaneMesh_04reb"]
Expand Down Expand Up @@ -59,6 +62,7 @@ script = ExtResource("1_i1hxe")
victory_event_channel = ExtResource("2_fwcwo")
defeat_event_channel = ExtResource("3_bimw1")
load_main_menu_event_channel = ExtResource("4_12k3b")
agent_panel_prefab = ExtResource("6_rbyna")

[node name="MatchEndPanel" type="Panel" parent="MatchUI"]
visible = false
Expand Down Expand Up @@ -108,47 +112,66 @@ grow_vertical = 0
theme = ExtResource("5_wvhhm")
text = "Back"

[node name="Control" type="Control" parent="MatchUI"]
layout_mode = 3
anchors_preset = 0
[node name="ButtomPanel" type="Panel" parent="MatchUI"]
offset_top = 1130.0
offset_right = 720.0
offset_bottom = 1280.0
mouse_filter = 2

[node name="Panel" type="Panel" parent="MatchUI/Control"]
layout_mode = 0
offset_right = 100.0
offset_bottom = 100.0

[node name="Panel2" type="Panel" parent="MatchUI/Control"]
[node name="MarginContainer" type="MarginContainer" parent="MatchUI/ButtomPanel"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchors_preset = 15
anchor_right = 1.0
offset_left = -100.0
offset_bottom = 100.0
grow_horizontal = 0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5

[node name="AgentsContainer" type="HBoxContainer" parent="MatchUI/ButtomPanel/MarginContainer"]
layout_mode = 2
alignment = 1

[node name="AgentDetailsPanel" type="Panel" parent="MatchUI"]
visible = false
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -224.0
offset_top = -285.0
offset_right = 224.0
offset_bottom = 285.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("8_y0ba1")
status_details_prefab = ExtResource("9_iq8yi")

[node name="Panel3" type="Panel" parent="MatchUI/Control"]
[node name="MarginContainer" type="MarginContainer" parent="MatchUI/AgentDetailsPanel"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -100.0
offset_right = 100.0
grow_vertical = 0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10

[node name="Panel4" type="Panel" parent="MatchUI/Control"]
[node name="Control" type="Control" parent="MatchUI/AgentDetailsPanel/MarginContainer"]
layout_mode = 2

[node name="StatusesContainer" type="VBoxContainer" parent="MatchUI/AgentDetailsPanel/MarginContainer/Control"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -100.0
offset_top = -100.0
grow_horizontal = 0
grow_vertical = 0
grow_horizontal = 2
grow_vertical = 2

[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
offset_right = 720.0
Expand Down
23 changes: 23 additions & 0 deletions scripts/UI/match/agent_details_panel.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
extends Panel

class_name AgentDetailsPanel

@onready var statuses_container: Control = $MarginContainer/Control/StatusesContainer

@export var status_details_prefab: PackedScene

func _ready() -> void:
hide()

func set_agent(agent: Agent2D):
print("need to show details of ", agent.name)
for status: AgentStatus in agent.statuses:
var status_details = status_details_prefab.instantiate() as StatusDetailsUI
status_details.ready.connect(func (): status_details.set_agent_status(status))
statuses_container.add_child(status_details)
show()

func close():
for child: Node in statuses_container.get_children():
child.queue_free()
hide()
18 changes: 18 additions & 0 deletions scripts/UI/match/player_panel.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extends Panel

class_name AgentPanel

signal pressed
signal released

var agent: Agent2D

func set_agent(agent: Agent2D):
self.agent = agent

func _gui_input(event: InputEvent) -> void:
if event is InputEventScreenTouch:
if event.pressed:
pressed.emit()
else:
released.emit()
10 changes: 10 additions & 0 deletions scripts/UI/match/status_details.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends Control

class_name StatusDetailsUI

@onready var status_name_label: Label = $ItemStatsPanel/MarginContainer/Control/StatusNameLabel
@onready var status_description_label: Label = $ItemStatsPanel/MarginContainer/Control/StatusDescriptionLabel

func set_agent_status(agent_status: AgentStatus):
status_name_label.text = agent_status.name
status_description_label.text = agent_status.description
10 changes: 10 additions & 0 deletions scripts/UI/match_ui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ extends CanvasLayer

@onready var match_end_pabel: Panel = $MatchEndPanel
@onready var label: Label = $MatchEndPanel/Label
@onready var agents_container: Control = $ButtomPanel/MarginContainer/AgentsContainer
@onready var agent_details_panel: AgentDetailsPanel = $AgentDetailsPanel

@export var victory_event_channel: VoidEventChannel
@export var defeat_event_channel: VoidEventChannel
@export var load_main_menu_event_channel: VoidEventChannel
@export var agent_panel_prefab: PackedScene

func _ready():
victory_event_channel.event_raised.connect(_on_victory)
defeat_event_channel.event_raised.connect(_on_defeat)
match_end_pabel.hide()
var agents = get_tree().get_nodes_in_group("Agents")
for agent: Agent2D in agents:
var agent_panel = agent_panel_prefab.instantiate() as AgentPanel
agent_panel.set_agent(agent)
agent_panel.pressed.connect(func (): agent_details_panel.set_agent(agent))
agent_panel.released.connect(func (): agent_details_panel.close())
agents_container.add_child(agent_panel)

func _on_victory():
label.text = "Vicotory!!!"
Expand Down
12 changes: 3 additions & 9 deletions scripts/agents/statuses/agent_status.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ extends Resource

class_name AgentStatus

@export var duration: int
@export var name: String
@export_multiline var description: String

var _agent: Agent2D
var _left_duration: int

func on_turn_ended():
_left_duration -= 1
if (_left_duration <= 0):
on_status_ended(_agent)

func on_status_given(agent: Agent2D):
_agent = agent
_left_duration = duration

func on_status_ended(agent: Agent2D):
print(agent.name, " slowed status ended")
pass

0 comments on commit aba5fcd

Please sign in to comment.