diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-15 09:39:59 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-15 09:39:59 +0200 |
commit | 069071ad40850f2880367885a3100676f716030d (patch) | |
tree | 309e8d5a1e08187002ac71fd97c603269952f5cc | |
parent | f5fad353fa1afbbab81438ac73242821b06e5b61 (diff) | |
download | godot-hexgrid-069071ad40850f2880367885a3100676f716030d.zip godot-hexgrid-069071ad40850f2880367885a3100676f716030d.tar.gz |
redo app tree to support resizing
-rw-r--r-- | Main.gd | 10 | ||||
-rw-r--r-- | Main.tscn | 85 |
2 files changed, 55 insertions, 40 deletions
@@ -3,21 +3,21 @@ extends Node2D var drag_map : bool = false -onready var UI : CanvasLayer = $UI -onready var Map : Sprite = $ViewportContainer/Viewport/Map -onready var Camera : Camera2D = $ViewportContainer/Viewport/Camera +onready var UI : Control = $CanvasLayer/HBOX/UI +onready var Map : Sprite = $CanvasLayer/HBOX/ViewportContainer/Viewport/Map +onready var Camera : Camera2D = $CanvasLayer/HBOX/ViewportContainer/Viewport/Camera func _ready(): UI.get_node("rotate").connect("pressed", self, "on_rotate") UI.get_node("LOS").connect("pressed", self, "on_toggle") UI.get_node("Move").connect("pressed", self, "on_toggle") Map.connect("hex_touched", self, "on_hex_touched") - $ViewportContainer.connect("resized", self, "on_viewport_resized") + $CanvasLayer/HBOX/ViewportContainer.connect("resized", self, "on_viewport_resized") on_toggle() on_viewport_resized() func on_viewport_resized() -> void: - Camera.configure($ViewportContainer/Viewport.size, Map.center(), Map.texture_size()) + Camera.configure($CanvasLayer/HBOX/ViewportContainer/Viewport.size, Map.center(), Map.texture_size()) func on_rotate() -> void: Map.rotate_map() @@ -10,80 +10,95 @@ [node name="Main" type="Node2D"] script = ExtResource( 3 ) -[node name="UI" type="CanvasLayer" parent="."] +[node name="CanvasLayer" type="CanvasLayer" parent="."] -[node name="rotate" type="Button" parent="UI"] -margin_left = 19.0 -margin_top = 17.0 -margin_right = 101.0 -margin_bottom = 56.0 -text = "Rotate" +[node name="HBOX" type="HBoxContainer" parent="CanvasLayer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 __meta__ = { "_edit_use_anchors_": false } -[node name="Info" type="Label" parent="UI"] -margin_left = 2.0 -margin_top = 501.0 -margin_right = 131.0 -margin_bottom = 598.0 +[node name="UI" type="VBoxContainer" parent="CanvasLayer/HBOX"] +margin_right = 150.0 +margin_bottom = 600.0 +rect_min_size = Vector2( 150, 0 ) __meta__ = { "_edit_use_anchors_": false } -[node name="LOS" type="CheckBox" parent="UI"] -margin_left = 30.0 -margin_top = 90.0 -margin_right = 83.0 -margin_bottom = 114.0 +[node name="rotate" type="Button" parent="CanvasLayer/HBOX/UI"] +margin_right = 150.0 +margin_bottom = 20.0 +text = "Rotate" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="LOS" type="CheckBox" parent="CanvasLayer/HBOX/UI"] +margin_top = 24.0 +margin_right = 150.0 +margin_bottom = 48.0 pressed = true text = "LOS" __meta__ = { "_edit_use_anchors_": false } -[node name="Move" type="CheckBox" parent="UI"] -margin_left = 30.0 -margin_top = 140.0 -margin_right = 93.0 -margin_bottom = 164.0 +[node name="Move" type="CheckBox" parent="CanvasLayer/HBOX/UI"] +margin_top = 52.0 +margin_right = 150.0 +margin_bottom = 76.0 text = "Move" __meta__ = { "_edit_use_anchors_": false } -[node name="ViewportContainer" type="ViewportContainer" parent="."] -margin_left = 141.0 -margin_top = 19.0 -margin_right = 1004.0 -margin_bottom = 581.0 +[node name="Info" type="Label" parent="CanvasLayer/HBOX/UI"] +margin_top = 80.0 +margin_right = 150.0 +margin_bottom = 94.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ViewportContainer" type="ViewportContainer" parent="CanvasLayer/HBOX"] +margin_left = 154.0 +margin_right = 1024.0 +margin_bottom = 600.0 +rect_min_size = Vector2( 100, 100 ) mouse_filter = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 stretch = true __meta__ = { "_edit_use_anchors_": false } -[node name="Viewport" type="Viewport" parent="ViewportContainer"] -size = Vector2( 863, 562 ) +[node name="Viewport" type="Viewport" parent="CanvasLayer/HBOX/ViewportContainer"] +size = Vector2( 870, 600 ) handle_input_locally = false render_target_update_mode = 3 -[node name="Map" type="Sprite" parent="ViewportContainer/Viewport"] +[node name="Map" type="Sprite" parent="CanvasLayer/HBOX/ViewportContainer/Viewport"] script = ExtResource( 2 ) -[node name="Hexes" type="Node" parent="ViewportContainer/Viewport/Map"] +[node name="Hexes" type="Node" parent="CanvasLayer/HBOX/ViewportContainer/Viewport/Map"] -[node name="Target" type="Sprite" parent="ViewportContainer/Viewport/Map"] +[node name="Target" type="Sprite" parent="CanvasLayer/HBOX/ViewportContainer/Viewport/Map"] z_index = 1 texture = ExtResource( 6 ) -[node name="Tank" type="Sprite" parent="ViewportContainer/Viewport/Map"] +[node name="Tank" type="Sprite" parent="CanvasLayer/HBOX/ViewportContainer/Viewport/Map"] z_index = 1 texture = ExtResource( 7 ) -[node name="Los" type="Node2D" parent="ViewportContainer/Viewport/Map"] +[node name="Los" type="Node2D" parent="CanvasLayer/HBOX/ViewportContainer/Viewport/Map"] script = ExtResource( 4 ) -[node name="Camera" type="Camera2D" parent="ViewportContainer/Viewport"] +[node name="Camera" type="Camera2D" parent="CanvasLayer/HBOX/ViewportContainer/Viewport"] current = true script = ExtResource( 1 ) |