From f187f690af666824fa3ff175c918e63e5164055f Mon Sep 17 00:00:00 2001 From: CactiChameleon9 <51231053+CactiChameleon9@users.noreply.github.com> Date: Tue, 22 Mar 2022 10:49:06 +0000 Subject: [PATCH] Redo some of the UI to be more flexible with further improvement --- src/assets/theme.theme | Bin 693 -> 816 bytes src/classes/Unit.gd | 4 ++- src/classes/Unit.tscn | 7 +++- src/nodes/UI/UnitPopup.tscn | 70 ++++++++++++++++++++++++++++++++---- 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/src/assets/theme.theme b/src/assets/theme.theme index 828099e9551f310162d75f57402791263265f9d9..39a68418249886f8698980d5aa62bc39819b05a7 100644 GIT binary patch literal 816 zcmV-01JC?YQ$s@n000005C8!42mk;W0{{RhwJ-f(^9OYp0Hz^rJrK_%9V#9G0MII{ zs;a8`r2+tB)DW^n-g$4ypEn^yl3nhAnEH1i?kS|eFX-i1fa-zd=yg97znD8zp8`(+ zSO8rBY-c6mgN=hNyVn)`zwr&>2E3z_ZT`pj)EZecjQ$t6#ID&*{|Ox0sqU$3*8dt` zN}1!!+a`m}o;LW{Hd(>B@_)$xlP|T?hyR_6{{sF@E=!O@yzjH|;gMi!$jvahkc1!J z#%5GP(&vB1f}SKNJKD$CNm41+yv?wgteB>s_cYR0Xg@A>Y96OxH~c7ggv}&&P2*%L zn`ZxaTy8%X8TgD!MMnkSfDz#uIwF3O;v7gEL&`I(h2rv-HG;@6bgfe3&S}kN?a8pM ziq}J|B6Rsr@~4!9ELR3jYwoM*xfpg=E399o(Lx?T>?juf7q+Z zG1Mkk`Ss>wB6|XHB55$$YhPYZ=!tfwU2?+R?1a_)i~1Ll_p$i}llhJ2(EpS3kj8ba zTm*b_ce6mr_q*zK71ZE+!~^01o18<;S61{MLJ9A!wJ5L)8cM~$Aw|>(gE7<=-SZ(W zh@33eb?Q%%K7^MDKCHf{?LmkS!Mc1=2SD#8e4x36IFAZ|LFzLigCgd2C1BOzO8|IX uO9sq+taBe1#hU0evM3 zM_b!sTx!HFF2Qc-WIV!N5Id%EE|p!f|1B=JpL-5`MwOzI*3L=72bpCp2mi!d)~Mz_ zlb#wM7`j%eac87vv-V`j)WpjnP7#Xy@A&FB>9cL^d>*)gO`~biSYydPr@hUx!Eu?B zYbuvqmKtxo&#Az;SP*q{n{tco9CD`kab0|f))tR z!cwpV7$C`GVb+*&km6MEIYUTDZ~}9?>4=gQ%uIU&*9=Yv8S4Ph%`;U=$9Lgx7pCuH zkRf6T(a0v~H1idd9zqDiufQKyx-fyH5I{i7t!(gvHh61JOW?%1*7YK^PF#VonHnWq zLQ4GH4))P4sG!Lc6iRg|`v8aDFW?N9SXQ*bD&jf-9dFtK$`mF}|3pzlkWv$n<;cYU bV~BKkT@?E3$yGj-)xvu=)dg-0Qd2`i-%d81 diff --git a/src/classes/Unit.gd b/src/classes/Unit.gd index f994104..31c5221 100644 --- a/src/classes/Unit.gd +++ b/src/classes/Unit.gd @@ -77,7 +77,9 @@ func move(movement : Vector2): if (potential_movement[2] == false): #not behind z_index = 100 - $UnitPopup.get_node("PopupMenu").popup() + yield(get_tree().create_timer(.3), "timeout") + var popup = $Canvas/UnitPopup + popup.popup(Rect2(position.x + 0, position.y - 110, popup.rect_size.x, popup.rect_size.x)) func attack(damage : int, points : int, pattern : PoolVector2Array): diff --git a/src/classes/Unit.tscn b/src/classes/Unit.tscn index 6ac1b96..dcc4c0f 100644 --- a/src/classes/Unit.tscn +++ b/src/classes/Unit.tscn @@ -120,6 +120,7 @@ texture = ExtResource( 2 ) position = Vector2( 2, -12 ) hframes = 4 vframes = 6 +frame = 12 [node name="AnimationPlayer" type="AnimationPlayer" parent="."] autoplay = "Idle" @@ -130,4 +131,8 @@ autoplay = "Idle" anims/Idle = SubResource( 5 ) "anims/Idle back" = SubResource( 6 ) -[node name="UnitPopup" parent="." instance=ExtResource( 3 )] +[node name="Canvas" type="CanvasLayer" parent="."] + +[node name="UnitPopup" parent="Canvas" instance=ExtResource( 3 )] +margin_right = 40.0 +margin_bottom = 88.0 diff --git a/src/nodes/UI/UnitPopup.tscn b/src/nodes/UI/UnitPopup.tscn index 97380b8..536172a 100644 --- a/src/nodes/UI/UnitPopup.tscn +++ b/src/nodes/UI/UnitPopup.tscn @@ -2,12 +2,68 @@ [ext_resource path="res://src/assets/theme.theme" type="Theme" id=1] -[node name="UnitPopup" type="Control"] -margin_right = 20.0 -margin_bottom = 20.0 +[node name="PopupMenu" type="PopupPanel"] +margin_right = 39.0 +margin_bottom = 97.0 theme = ExtResource( 1 ) -[node name="PopupMenu" type="PopupMenu" parent="."] -margin_right = 20.0 -margin_bottom = 20.0 -items = [ "Move 1", null, 0, false, false, 0, 0, null, "", false, "Move 2", null, 0, false, false, 1, 0, null, "", false, "Move 3", null, 0, false, false, 2, 0, null, "", false, "Move 4", null, 0, false, false, 3, 0, null, "", false, "Move 5", null, 0, false, false, 4, 0, null, "", false ] +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -16.0 +margin_top = -44.5 +margin_right = 16.0 +margin_bottom = 44.5 +alignment = 1 + +[node name="Label" type="Label" parent="VBoxContainer"] +margin_top = 4.0 +margin_right = 32.0 +margin_bottom = 12.0 +text = "Health" +align = 1 + +[node name="Label2" type="Label" parent="VBoxContainer"] +margin_top = 16.0 +margin_right = 32.0 +margin_bottom = 24.0 +text = "Damage" +align = 1 + +[node name="Move1" type="Button" parent="VBoxContainer"] +margin_top = 28.0 +margin_right = 32.0 +margin_bottom = 36.0 +text = "Move 1" + +[node name="Move2" type="Button" parent="VBoxContainer"] +margin_top = 40.0 +margin_right = 32.0 +margin_bottom = 48.0 +text = "Move 2" + +[node name="Move3" type="Button" parent="VBoxContainer"] +margin_top = 52.0 +margin_right = 32.0 +margin_bottom = 60.0 +text = "Move 3" + +[node name="Move4" type="Button" parent="VBoxContainer"] +margin_top = 64.0 +margin_right = 32.0 +margin_bottom = 72.0 +text = "Move 4" + +[node name="Move5" type="Button" parent="VBoxContainer"] +margin_top = 76.0 +margin_right = 32.0 +margin_bottom = 84.0 +text = "Move 5" + +[connection signal="button_down" from="VBoxContainer/Move1" to="." method="hide"] +[connection signal="button_down" from="VBoxContainer/Move2" to="." method="hide"] +[connection signal="button_down" from="VBoxContainer/Move3" to="." method="hide"] +[connection signal="button_down" from="VBoxContainer/Move4" to="." method="hide"] +[connection signal="button_down" from="VBoxContainer/Move5" to="." method="hide"]