Browse Source

:recycle: Use anchors to set up UI components

Margins are now more readable and it will ease a possibly responsive
design refactoring.
DricomDragon 2 years ago
parent
commit
984130c64b

+ 9 - 5
godot/component/ui/message_panel/MessagePanel.tscn

@@ -3,10 +3,14 @@
 [ext_resource path="res://component/ui/message_panel/MessagePanel.gd" type="Script" id=1]
 
 [node name="Panel" type="Panel"]
-margin_left = 100.0
-margin_top = 175.0
-margin_right = 300.0
-margin_bottom = 225.0
+anchor_left = 0.5
+anchor_top = 0.5
+anchor_right = 0.5
+anchor_bottom = 0.5
+margin_left = -100.0
+margin_top = -25.0
+margin_right = 100.0
+margin_bottom = 25.0
 script = ExtResource( 1 )
 __meta__ = {
 "_edit_use_anchors_": false
@@ -17,7 +21,7 @@ margin_left = -100.0
 margin_top = -175.0
 margin_right = 300.0
 margin_bottom = 225.0
-text = "Your message here"
+text = "Edit your message"
 align = 1
 valign = 1
 __meta__ = {

+ 5 - 3
godot/component/ui/number_panel/NumberPanel.tscn

@@ -3,8 +3,10 @@
 [ext_resource path="res://component/ui/number_panel/NumberPanel.gd" type="Script" id=1]
 
 [node name="Panel" type="Panel"]
-margin_right = 40.0
-margin_bottom = 30.0
+margin_left = -20.0
+margin_top = -15.0
+margin_right = 20.0
+margin_bottom = 15.0
 script = ExtResource( 1 )
 __meta__ = {
 "_edit_use_anchors_": false
@@ -13,7 +15,7 @@ __meta__ = {
 [node name="Label" type="Label" parent="."]
 margin_right = 40.0
 margin_bottom = 14.0
-text = "Title"
+text = "Counter"
 align = 1
 valign = 1
 __meta__ = {

+ 18 - 12
godot/main.tscn

@@ -14,8 +14,8 @@
 script = ExtResource( 8 )
 
 [node name="Background" type="Panel" parent="."]
-margin_right = 400.0
-margin_bottom = 400.0
+anchor_right = 1.0
+anchor_bottom = 1.0
 __meta__ = {
 "_edit_use_anchors_": false
 }
@@ -31,8 +31,8 @@ __meta__ = {
 [node name="DeadLine" parent="." instance=ExtResource( 7 )]
 
 [node name="UI" type="Control" parent="."]
-margin_right = 40.0
-margin_bottom = 40.0
+anchor_right = 1.0
+anchor_bottom = 1.0
 script = ExtResource( 5 )
 __meta__ = {
 "_edit_use_anchors_": false
@@ -46,28 +46,34 @@ message = "Game Over!"
 message = "Click to shoot a ball!"
 
 [node name="ScoreCounter" parent="UI" instance=ExtResource( 6 )]
-margin_left = 350.0
-margin_top = 360.0
-margin_right = 390.0
-margin_bottom = 390.0
+anchor_left = 1.0
+anchor_top = 1.0
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_left = -50.0
+margin_top = -40.0
+margin_right = -10.0
+margin_bottom = -10.0
 title = "Score"
 
 [node name="BallCounter" parent="UI" instance=ExtResource( 6 )]
+anchor_top = 1.0
+anchor_bottom = 1.0
 margin_left = 10.0
-margin_top = 360.0
+margin_top = -40.0
 margin_right = 50.0
-margin_bottom = 390.0
+margin_bottom = -10.0
 title = "Balls"
+[connection signal="start_new_game" from="." to="UI/ScoreCounter" method="reset_counter"]
 [connection signal="start_new_game" from="." to="Grid" method="_on_Game_start_new_game"]
 [connection signal="start_new_game" from="." to="Launcher" method="_on_Game_start_new_game"]
 [connection signal="start_new_game" from="." to="UI/GameOverPanel" method="hide"]
-[connection signal="start_new_game" from="." to="UI/ScoreCounter" method="reset_counter"]
 [connection signal="start_new_game" from="." to="UI/BallCounter" method="reset_counter"]
 [connection signal="gain_new_bullet" from="Launcher" to="UI/BallCounter" method="increase_counter"]
 [connection signal="get_firing" from="Launcher" to="UI" method="_on_Launcher_get_firing"]
 [connection signal="is_full" from="Launcher" to="Grid" method="_on_Launcher_is_full"]
-[connection signal="has_moved" from="Grid" to="Launcher" method="_on_Grid_has_moved"]
 [connection signal="has_moved" from="Grid" to="DeadLine" method="_on_Grid_has_moved"]
+[connection signal="has_moved" from="Grid" to="Launcher" method="_on_Grid_has_moved"]
 [connection signal="kace_broken" from="Grid" to="Launcher" method="_on_Grid_kace_broken"]
 [connection signal="kace_damaged" from="Grid" to="UI/ScoreCounter" method="increase_counter"]
 [connection signal="game_lost" from="DeadLine" to="Launcher" method="_on_DeadLine_game_lost"]