From 582f2298f25676ff9c1043a0f3d9527189bc6708 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 7 Dec 2019 19:01:34 +0100 Subject: [PATCH] Actionbars are now using built in control functionality for layout. Also Vsync is on now. --- game/project.godot | 1 - game/ui/actionbars/ActionBar.gd | 18 ------------------ game/ui/actionbars/ActionBar.tscn | 23 +++++++++++++---------- game/ui/actionbars/ActionBarEntry.tscn | 12 +++++------- game/ui/player_ui/player_ui.tscn | 6 ++++-- 5 files changed, 22 insertions(+), 38 deletions(-) diff --git a/game/project.godot b/game/project.godot index 1871a75d..fa0c0831 100644 --- a/game/project.godot +++ b/game/project.godot @@ -248,7 +248,6 @@ gdscript/warnings/integer_division=false [display] window/dpi/allow_hidpi=true -window/vsync/use_vsync=false window/handheld/orientation="sensor_landscape" window/stretch/mode="2d" window/stretch/aspect="expand" diff --git a/game/ui/actionbars/ActionBar.gd b/game/ui/actionbars/ActionBar.gd index 9d658142..f71581b8 100644 --- a/game/ui/actionbars/ActionBar.gd +++ b/game/ui/actionbars/ActionBar.gd @@ -8,28 +8,10 @@ export (PackedScene) var action_bar_entry_scene export (NodePath) var child_container_path var child_container -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" - -# Called when the node enters the scene tree for the first time. func _ready() -> void: child_container = get_node(child_container_path) -# pass # Replace with function body. - -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass func set_actionbar_entry(action_bar_entry : ActionBarEntry, player: Entity) -> void: - #rect_size = Vector2(action_bar_entry.size, (action_bar_entry.size) * action_bar_entry.slot_num) - #set_anchors_preset(Control.PRESET_BOTTOM_RIGHT, false) - #margin_left = action_bar_entry.action_bar_id * -(action_bar_entry.size + 5) - 10 - - margin_top = - ((action_bar_entry.size) * action_bar_entry.slot_num) - #margin_bottom = 0 - margin_right = -((action_bar_entry.action_bar_id - 1) * action_bar_entry.size) - margin_left = -((action_bar_entry.action_bar_id) * action_bar_entry.size) for i in range(action_bar_entry.slot_num): var b : ActionBarButtonEntry = action_bar_entry.get_button_for_slotid(i) diff --git a/game/ui/actionbars/ActionBar.tscn b/game/ui/actionbars/ActionBar.tscn index e7ebea09..3a2b8da8 100644 --- a/game/ui/actionbars/ActionBar.tscn +++ b/game/ui/actionbars/ActionBar.tscn @@ -3,14 +3,15 @@ [ext_resource path="res://ui/actionbars/ActionBarEntry.tscn" type="PackedScene" id=1] [ext_resource path="res://ui/actionbars/ActionBar.gd" type="Script" id=2] -[node name="ActionBar" type="Control"] +[node name="ActionBar" type="VBoxContainer"] anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = -63.0 -margin_top = -580.0 +margin_left = -40.0 +margin_top = -553.0 mouse_filter = 2 +custom_constants/separation = 0 script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false @@ -18,13 +19,15 @@ __meta__ = { action_bar_entry_scene = ExtResource( 1 ) child_container_path = NodePath("GridContainer") -[node name="GridContainer" type="GridContainer" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -mouse_filter = 2 +[node name="Control" type="Control" parent="."] +margin_right = 40.0 +margin_bottom = 553.0 size_flags_horizontal = 3 size_flags_vertical = 3 + +[node name="GridContainer" type="GridContainer" parent="."] +margin_top = 553.0 +margin_right = 40.0 +margin_bottom = 553.0 custom_constants/vseparation = 0 -__meta__ = { -"_edit_use_anchors_": false -} +custom_constants/hseparation = 0 diff --git a/game/ui/actionbars/ActionBarEntry.tscn b/game/ui/actionbars/ActionBarEntry.tscn index 8f457214..06aa5e9b 100644 --- a/game/ui/actionbars/ActionBarEntry.tscn +++ b/game/ui/actionbars/ActionBarEntry.tscn @@ -6,12 +6,10 @@ [ext_resource path="res://ui/theme/actionbar_dynamicfont.tres" type="DynamicFont" id=5] [node name="ActionBarEntry" type="TouchButton"] -margin_top = 1.0 -margin_right = 70.0 -margin_bottom = 71.0 +margin_right = 46.0 +margin_bottom = 46.0 +rect_min_size = Vector2( 46, 46 ) focus_mode = 0 -size_flags_horizontal = 3 -size_flags_vertical = 3 theme = ExtResource( 3 ) shortcut_in_tooltip = false action_mode = 0 @@ -43,8 +41,8 @@ __meta__ = { [node name="TextureRect" type="TextureRect" parent="MarginContainer"] margin_left = 2.0 margin_top = 2.0 -margin_right = 68.0 -margin_bottom = 68.0 +margin_right = 44.0 +margin_bottom = 44.0 mouse_filter = 2 size_flags_horizontal = 3 size_flags_vertical = 3 diff --git a/game/ui/player_ui/player_ui.tscn b/game/ui/player_ui/player_ui.tscn index d363d7b7..60391ff6 100644 --- a/game/ui/player_ui/player_ui.tscn +++ b/game/ui/player_ui/player_ui.tscn @@ -319,15 +319,17 @@ enabled_focus_mode = 0 keep_pressed_outside = true text = "M" -[node name="Actionbars" type="Control" parent="GUI"] +[node name="Actionbars" type="HBoxContainer" parent="GUI"] anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +custom_constants/separation = 0 +alignment = 2 script = ExtResource( 8 ) __meta__ = { -"_edit_lock_": true +"_edit_use_anchors_": false } actionbar_scene = ExtResource( 14 )