unify main scene for mobile
This commit is contained in:
parent
89518f6aa5
commit
7249e00a92
|
@ -41,7 +41,6 @@ _global_script_class_icons={
|
|||
config/name="Taqin"
|
||||
run/main_scene="res://src/Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
run/main_scene.mobile="res://src/MainMobile.tscn"
|
||||
|
||||
[autoload]
|
||||
|
||||
|
@ -50,12 +49,16 @@ Styles="*res://src/Styles.gd"
|
|||
[display]
|
||||
|
||||
window/size/resizable=false
|
||||
window/size/test_width=600
|
||||
window/size/test_height=1200
|
||||
window/dpi/allow_hidpi=true
|
||||
window/handheld/orientation="portrait"
|
||||
window/size/width.mobile=600
|
||||
window/size/height.mobile=1200
|
||||
window/stretch/mode.mobile="2d"
|
||||
window/stretch/aspect.mobile="expand"
|
||||
window/size/width.pc=1024
|
||||
window/size/height.pc=600
|
||||
|
||||
[filesystem]
|
||||
|
||||
|
|
15
src/Main.gd
15
src/Main.gd
|
@ -1,8 +1,10 @@
|
|||
extends Control
|
||||
|
||||
onready var taquin = $HSplitContainer/Taquin
|
||||
onready var container = $GridContainer
|
||||
onready var taquin = $GridContainer/Taquin
|
||||
|
||||
func _ready():
|
||||
layout_reflow()
|
||||
load_game()
|
||||
print("Starting state: ", taquin.current_state_name())
|
||||
|
||||
|
@ -11,6 +13,17 @@ func _notification(what):
|
|||
save_game()
|
||||
get_tree().quit() # default behavior
|
||||
|
||||
func layout_reflow():
|
||||
if container == null:
|
||||
return
|
||||
|
||||
if container.rect_size.x < container.rect_size.y:
|
||||
# portrait
|
||||
container.columns = 1
|
||||
else:
|
||||
# landscape
|
||||
container.columns = 2
|
||||
|
||||
# https://docs.godotengine.org/en/3.2/tutorials/io/saving_games.html
|
||||
func save_game():
|
||||
var save_game = File.new()
|
||||
|
|
|
@ -23,19 +23,21 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="."]
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 20.0
|
||||
margin_top = 20.0
|
||||
margin_right = -20.0
|
||||
margin_bottom = -20.0
|
||||
custom_constants/separation = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
columns = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Taquin" parent="HSplitContainer" groups=[
|
||||
[node name="Taquin" parent="GridContainer" groups=[
|
||||
"Persist",
|
||||
] instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
|
@ -43,36 +45,39 @@ anchor_bottom = 0.0
|
|||
margin_right = 540.0
|
||||
margin_bottom = 560.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer"]
|
||||
margin_left = 556.0
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="GridContainer"]
|
||||
margin_left = 548.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 560.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="New Game" parent="HSplitContainer/VBoxContainer" instance=ExtResource( 4 )]
|
||||
[node name="New Game" parent="GridContainer/VBoxContainer" instance=ExtResource( 4 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 206.0
|
||||
margin_right = 428.0
|
||||
margin_right = 436.0
|
||||
margin_bottom = 276.0
|
||||
rect_min_size = Vector2( 0, 70 )
|
||||
text = "New Game"
|
||||
|
||||
[node name="Hints" parent="HSplitContainer/VBoxContainer" instance=ExtResource( 4 )]
|
||||
[node name="Hints" parent="GridContainer/VBoxContainer" instance=ExtResource( 4 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 284.0
|
||||
margin_right = 428.0
|
||||
margin_right = 436.0
|
||||
margin_bottom = 354.0
|
||||
rect_min_size = Vector2( 0, 70 )
|
||||
text = "Hints"
|
||||
|
||||
[node name="NewGamePanel" parent="." instance=ExtResource( 3 )]
|
||||
visible = false
|
||||
rect_pivot_offset = Vector2( 4, 4 )
|
||||
[connection signal="state_changed" from="HSplitContainer/Taquin" to="." method="_on_Taquin_state_changed"]
|
||||
[connection signal="pressed" from="HSplitContainer/VBoxContainer/New Game" to="." method="_on_New_game_pressed"]
|
||||
[connection signal="button_down" from="HSplitContainer/VBoxContainer/Hints" to="HSplitContainer/Taquin" method="_on_Hints_button_down"]
|
||||
[connection signal="button_up" from="HSplitContainer/VBoxContainer/Hints" to="HSplitContainer/Taquin" method="_on_Hints_button_up"]
|
||||
[connection signal="state_changed" from="GridContainer/Taquin" to="." method="_on_Taquin_state_changed"]
|
||||
[connection signal="pressed" from="GridContainer/VBoxContainer/New Game" to="." method="_on_New_game_pressed"]
|
||||
[connection signal="button_down" from="GridContainer/VBoxContainer/Hints" to="GridContainer/Taquin" method="_on_Hints_button_down"]
|
||||
[connection signal="button_up" from="GridContainer/VBoxContainer/Hints" to="GridContainer/Taquin" method="_on_Hints_button_up"]
|
||||
[connection signal="about_to_show" from="NewGamePanel" to="." method="_on_NewGamePanel_about_to_show"]
|
||||
[connection signal="popup_hide" from="NewGamePanel" to="." method="_on_NewGamePanel_popup_hide"]
|
||||
[connection signal="start_triggered" from="NewGamePanel" to="HSplitContainer/Taquin" method="_on_NewGamePanel_start_triggered"]
|
||||
[connection signal="start_triggered" from="NewGamePanel" to="GridContainer/Taquin" method="_on_NewGamePanel_start_triggered"]
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://src/Main.gd" type="Script" id=1]
|
||||
[ext_resource path="res://src/Taquin.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://assets/taqin_theme.tres" type="Theme" id=3]
|
||||
|
||||
[node name="Main" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 3 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VSplitContainer" type="VSplitContainer" parent="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 20.0
|
||||
margin_top = 20.0
|
||||
margin_right = -20.0
|
||||
margin_bottom = -20.0
|
||||
split_offset = 200
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="Panel/VSplitContainer"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 540.0
|
||||
|
||||
[node name="Taquin" parent="Panel/VSplitContainer/CenterContainer" instance=ExtResource( 2 )]
|
||||
margin_left = 222.0
|
||||
margin_right = 762.0
|
||||
margin_bottom = 540.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/VSplitContainer"]
|
||||
margin_top = 552.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 632.0
|
||||
|
||||
[node name="Hints" type="Button" parent="Panel/VSplitContainer/VBoxContainer"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 80.0
|
||||
rect_min_size = Vector2( 0, 80 )
|
||||
text = "HINTS"
|
Loading…
Reference in a new issue