Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ HandlerGUI="*res://src/autoload/HandlerGUI.gd"
window/size/viewport_width=720
window/size/viewport_height=1280
window/energy_saving/keep_screen_on=false
window/handheld/orientation=1
window/handheld/orientation=6
mouse_cursor/tooltip_position_offset=Vector2(0, 10)

[editor_plugins]
Expand Down
23 changes: 23 additions & 0 deletions src/autoload/Configs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,32 @@ signal tab_removed
signal tab_selected(index: int)
@warning_ignore("unused_signal")
signal layout_changed
@warning_ignore("unused_signal")
signal orientation_changed

var current_sdk: int = -1

enum orientation {PORTRAIT, LANDSCAPE}
var current_orientation := orientation.PORTRAIT

func _ready() -> void:
get_tree().root.size_changed.connect(check_orientation)

func check_orientation():
var width = DisplayServer.window_get_size().x
var height = DisplayServer.window_get_size().y

var new_orientation: orientation
if width > height:
new_orientation = orientation.LANDSCAPE
else:
new_orientation = orientation.PORTRAIT

if new_orientation != current_orientation:
current_orientation = new_orientation
orientation_changed.emit()


const savedata_path = "user://savedata.tres"
var savedata: SaveData:
set(new_value):
Expand Down
10 changes: 10 additions & 0 deletions src/autoload/HandlerGUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ const DonateMenuScene = preload("res://src/ui_parts/donate_menu.tscn")
const UpdateMenuScene = preload("res://src/ui_parts/update_menu.tscn")
const ExportMenuScene = preload("res://src/ui_parts/export_menu.tscn")
const ShortcutPanelScene = preload("res://src/ui_parts/shortcut_panel.tscn")
const TabsPanel = preload("res://src/ui_parts/tabs_panel.tscn")

# Menus should be added with add_menu() and removed by being freed.
# To add them as modals that don't hide the previous one, use add_dialog().
var menu_stack: Array[ColorRect]
var popup_stack: Array[Control]

var shortcut_panel: PanelContainer
var tabs_panel: PanelContainer

func _enter_tree() -> void:
var window := get_window()
Expand All @@ -33,6 +35,14 @@ func _ready() -> void:

shortcut_panel = ShortcutPanelScene.instantiate()
get_tree().root.add_child(shortcut_panel)

tabs_panel = TabsPanel.instantiate()
var overlay_ref := ColorRect.new()
overlay_ref.color = Color(0, 0, 0, 0.4)
overlay_ref.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
overlay_ref.hide()
get_tree().root.add_child.call_deferred(overlay_ref)
overlay_ref.add_child(tabs_panel)

func _notification(what: int) -> void:
if what == NOTIFICATION_WM_ABOUT:
Expand Down
12 changes: 6 additions & 6 deletions src/config_classes/SaveData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func validate() -> void:
_active_tab_index = _active_tab_index # Run the setter.

# End of the method, would need to be rewritten if more things need validation.
for location in [LayoutLocation.TOP_LEFT, LayoutLocation.BOTTOM_LEFT]:
for location in [LayoutLocation.SIDE_PANEL_TOP, LayoutLocation.SIDE_PANEL_BOTTOM]:
if _layout.has(location) and not _layout[location].is_empty():
return
_layout = {
LayoutLocation.TOP_LEFT: [Utils.LayoutPart.INSPECTOR, Utils.LayoutPart.CODE_EDITOR]
LayoutLocation.SIDE_PANEL_TOP: [Utils.LayoutPart.INSPECTOR, Utils.LayoutPart.CODE_EDITOR]
}


Expand Down Expand Up @@ -755,7 +755,7 @@ func move_tab(old_idx: int, new_idx: int) -> void:
Configs.tabs_changed.emit()


enum LayoutLocation {NONE, EXCLUDED, TOP_LEFT, BOTTOM_LEFT}
enum LayoutLocation { NONE, EXCLUDED, SIDE_PANEL_TOP, SIDE_PANEL_BOTTOM }

@export var _layout: Dictionary[LayoutLocation, Array]: # Array[Utils.LayoutPart]
set(new_value):
Expand Down Expand Up @@ -840,14 +840,14 @@ func get_layout_part_index(part: Utils.LayoutPart) -> int:
main_splitter_offset = new_value
emit_changed()

@export var top_vertical_splitter_offset := -240:
@export var side_panel_splitter_offset := -240:
set(new_value):
# Validation
if is_nan(new_value):
new_value = 0
# Main part
if top_vertical_splitter_offset != new_value:
top_vertical_splitter_offset = new_value
if side_panel_splitter_offset != new_value:
side_panel_splitter_offset = new_value
emit_changed()


Expand Down
23 changes: 8 additions & 15 deletions src/ui_parts/display.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extends VBoxContainer

const NumberEdit = preload("res://src/ui_widgets/number_edit.gd")
const TabsPanel = preload("res://src/ui_parts/tabs_panel.tscn")

@onready var viewport: SubViewport = %Viewport
@onready var reference_texture: TextureRect = %Viewport/ReferenceTexture
Expand Down Expand Up @@ -38,14 +37,6 @@ func _ready() -> void:
update_theme()
update_snap_config()
get_window().window_input.connect(_update_input_debug)

tabs_panel = TabsPanel.instantiate()
var overlay_ref := ColorRect.new()
overlay_ref.color = Color(0, 0, 0, 0.4)
overlay_ref.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
overlay_ref.hide()
get_tree().root.add_child.call_deferred(overlay_ref)
overlay_ref.add_child(tabs_panel)

func update_translations() -> void:
%LeftMenu/Visuals.tooltip_text = Translator.translate("Visuals")
Expand All @@ -59,10 +50,12 @@ func update_theme() -> void:

var frame := StyleBoxFlat.new()
frame.draw_center = false
frame.border_width_top = 2
if Configs.current_orientation == Configs.orientation.PORTRAIT:
frame.border_width_top = 2
else:
frame.border_width_left = 2
frame.border_color = ThemeUtils.connected_button_border_color_pressed
frame.content_margin_left = 2.0
frame.content_margin_top = 2.0
frame.set_content_margin_all(2.0)
viewport_panel.add_theme_stylebox_override("panel", frame)

func update_snap_config() -> void:
Expand Down Expand Up @@ -174,7 +167,7 @@ func _update_input_debug(event: InputEvent) -> void:

func show_tabs_panel() -> void:
if should_refresh_tabs:
tabs_panel.refresh_tabs()
HandlerGUI.tabs_panel.refresh_tabs()
should_refresh_tabs = false
tabs_panel.get_parent().show()
tabs_panel.animate_in()
HandlerGUI.tabs_panel.get_parent().show()
HandlerGUI.tabs_panel.animate_in()
2 changes: 1 addition & 1 deletion src/ui_parts/display.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ unique_name_in_owner = true
disable_3d = true
handle_input_locally = false
gui_snap_controls_to_pixels = false
size = Vector2i(716, 1248)
size = Vector2i(720, 1249)
size_2d_override_stretch = true
render_target_update_mode = 4
script = ExtResource("9_4xrk7")
Expand Down
91 changes: 50 additions & 41 deletions src/ui_parts/editor_scene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ const ViewportScene = preload("res://src/ui_parts/display.tscn")

@onready var panel_container: PanelContainer = $PanelContainer

var main_splitter: SplitContainer


func _ready() -> void:
Configs.theme_changed.connect(update_theme)
Configs.layout_changed.connect(update_layout)
Configs.orientation_changed.connect(update_orientation)
update_layout()
update_theme()
var version = JavaClassWrapper.wrap("android.os.Build$VERSION")
if version: Configs.current_sdk = version.SDK_INT

func update_orientation():
if Configs.current_orientation == Configs.orientation.PORTRAIT:
main_splitter.vertical = true
else:
main_splitter.vertical = false

func update_theme() -> void:
var stylebox := StyleBoxFlat.new()
stylebox.bg_color = ThemeUtils.overlay_panel_inner_color
Expand All @@ -26,54 +36,53 @@ func update_layout() -> void:
for child in panel_container.get_children():
child.queue_free()

var top_left := Configs.savedata.get_layout_parts(SaveData.LayoutLocation.TOP_LEFT)
var bottom_left := Configs.savedata.get_layout_parts(SaveData.LayoutLocation.BOTTOM_LEFT)
var side_panel_top := Configs.savedata.get_layout_parts(SaveData.LayoutLocation.SIDE_PANEL_TOP)
var side_panel_bottom := Configs.savedata.get_layout_parts(SaveData.LayoutLocation.SIDE_PANEL_BOTTOM)

# Set up the horizontal splitter.
var main_splitter := VSplitContainer.new()
main_splitter.size_flags_horizontal = Control.SIZE_FILL
# Set up the main splitter.
main_splitter = SplitContainer.new()
main_splitter.vertical = true
main_splitter.dragger_visibility = SplitContainer.DRAGGER_HIDDEN_COLLAPSED
main_splitter.touch_dragger_enabled = true
main_splitter.split_offset = Configs.savedata.main_splitter_offset
main_splitter.dragged.connect(_on_main_splitter_dragged)
panel_container.add_child(main_splitter)

var top_margin_container := MarginContainer.new()
top_margin_container.custom_minimum_size.x = 350
top_margin_container.begin_bulk_theme_override()
top_margin_container.add_theme_constant_override("margin_top", 6)
top_margin_container.add_theme_constant_override("margin_bottom", 3)
top_margin_container.add_theme_constant_override("margin_left", 6)
top_margin_container.add_theme_constant_override("margin_right", 6)
top_margin_container.end_bulk_theme_override()
main_splitter.add_child(top_margin_container)
var side_panel_margin_container := MarginContainer.new()
side_panel_margin_container.begin_bulk_theme_override()
side_panel_margin_container.add_theme_constant_override("margin_top", 6)
side_panel_margin_container.add_theme_constant_override("margin_bottom", 3)
side_panel_margin_container.add_theme_constant_override("margin_left", 6)
side_panel_margin_container.add_theme_constant_override("margin_right", 6)
side_panel_margin_container.end_bulk_theme_override()
main_splitter.add_child(side_panel_margin_container)

var bottom_margin_container := MarginContainer.new()
bottom_margin_container.add_theme_constant_override("margin_top", 3)
bottom_margin_container.add_child(create_layout_node(Utils.LayoutPart.VIEWPORT))
main_splitter.add_child(bottom_margin_container)
var main_view_margin_container := MarginContainer.new()
main_view_margin_container.add_theme_constant_override("margin_top", 3)
main_view_margin_container.add_child(create_layout_node(Utils.LayoutPart.VIEWPORT))
main_splitter.add_child(main_view_margin_container)

var left_vbox := VBoxContainer.new()
left_vbox.add_theme_constant_override("separation", 6)
top_margin_container.add_child(left_vbox)
var side_panel_vbox := VBoxContainer.new()
side_panel_vbox.add_theme_constant_override("separation", 6)
side_panel_margin_container.add_child(side_panel_vbox)

var global_actions := GlobalActionsScene.instantiate()
left_vbox.add_child(global_actions)
side_panel_vbox.add_child(global_actions)

if not top_left.is_empty() and not bottom_left.is_empty():
if not side_panel_top.is_empty() and not side_panel_bottom.is_empty():
# Layout parts both on top and on the bottom.
var top_vertical_split_container := VSplitContainer.new()
top_vertical_split_container.size_flags_vertical = Control.SIZE_EXPAND_FILL
top_vertical_split_container.dragger_visibility = SplitContainer.DRAGGER_HIDDEN_COLLAPSED
top_vertical_split_container.touch_dragger_enabled = true
top_vertical_split_container.split_offset = Configs.savedata.top_vertical_splitter_offset
top_vertical_split_container.dragged.connect(_on_top_vertical_splitter_dragged)
top_vertical_split_container.add_child(create_layout_node(top_left[0]))
top_vertical_split_container.add_child(create_layout_node(bottom_left[0]))
left_vbox.add_child(top_vertical_split_container)
elif top_left.size() == 2 or bottom_left.size() == 2:
var side_panel_split_container := VSplitContainer.new()
side_panel_split_container.size_flags_vertical = Control.SIZE_EXPAND_FILL
side_panel_split_container.dragger_visibility = SplitContainer.DRAGGER_HIDDEN_COLLAPSED
side_panel_split_container.touch_dragger_enabled = true
side_panel_split_container.split_offset = Configs.savedata.side_panel_splitter_offset
side_panel_split_container.dragged.connect(_on_side_panel_splitter_dragged)
side_panel_split_container.add_child(create_layout_node(side_panel_top[0]))
side_panel_split_container.add_child(create_layout_node(side_panel_bottom[0]))
side_panel_vbox.add_child(side_panel_split_container)
elif side_panel_top.size() == 2 or side_panel_bottom.size() == 2:
# Tabs for the different layout parts.
var layout_parts := top_left if bottom_left.is_empty() else bottom_left
var layout_parts := side_panel_top if side_panel_bottom.is_empty() else side_panel_bottom
var vbox := VBoxContainer.new()
vbox.size_flags_vertical = Control.SIZE_EXPAND_FILL
var buttons_hbox := HBoxContainer.new()
Expand Down Expand Up @@ -114,19 +123,19 @@ func update_layout() -> void:
if i == 0:
btn.button_pressed = true
layout_nodes[part].show()
left_vbox.add_child(vbox)
side_panel_vbox.add_child(vbox)
else:
# Layout parts disabled.
if not top_left.is_empty():
left_vbox.add_child(create_layout_node(top_left[0]))
elif not bottom_left.is_empty():
left_vbox.add_child(create_layout_node(bottom_left[0]))
if not side_panel_top.is_empty():
side_panel_vbox.add_child(create_layout_node(side_panel_top[0]))
elif not side_panel_bottom.is_empty():
side_panel_vbox.add_child(create_layout_node(side_panel_bottom[0]))

func _on_main_splitter_dragged(offset: int) -> void:
Configs.savedata.main_splitter_offset = offset

func _on_top_vertical_splitter_dragged(offset: int) -> void:
Configs.savedata.top_vertical_splitter_offset = offset
func _on_side_panel_splitter_dragged(offset: int) -> void:
Configs.savedata.side_panel_splitter_offset = offset


func create_layout_node(layout_part: Utils.LayoutPart) -> Node:
Expand Down
2 changes: 1 addition & 1 deletion src/ui_parts/inspector.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ theme_override_constants/h_separation = 4
icon = ExtResource("3_vo6hf")

[node name="ElementContainer" type="Control" parent="."]
custom_minimum_size = Vector2(0, 150)
custom_minimum_size = Vector2(340, 150)
layout_mode = 2
size_flags_vertical = 3
script = ExtResource("3_qeptj")
Expand Down
Loading
Loading