mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Save layout in the config file
This commit is contained in:
parent
743f5fa8d2
commit
6148004b45
@ -126,7 +126,7 @@ func _ready() -> void:
|
||||
# Set window title
|
||||
OS.set_window_title(ProjectSettings.get_setting("application/config/name")+" v"+ProjectSettings.get_setting("application/config/release"))
|
||||
|
||||
layout.load_panes()
|
||||
layout.load_panes(config_cache)
|
||||
library = layout.get_pane("Library")
|
||||
preview_2d = layout.get_pane("Preview2D")
|
||||
preview_3d = layout.get_pane("Preview3D")
|
||||
@ -593,6 +593,7 @@ func _exit_tree() -> void:
|
||||
config_cache.set_value("window", "maximized", OS.window_maximized || OS.window_fullscreen)
|
||||
config_cache.set_value("window", "position", OS.window_position)
|
||||
config_cache.set_value("window", "size", OS.window_size)
|
||||
layout.save_config(config_cache)
|
||||
config_cache.save("user://cache.ini")
|
||||
|
||||
func _notification(what : int) -> void:
|
||||
|
@ -14,18 +14,48 @@ const PANES = [
|
||||
|
||||
var panes = {}
|
||||
|
||||
func load_panes() -> void:
|
||||
func load_panes(config_cache) -> void:
|
||||
# Create panels
|
||||
for pane_pos in PANE_POSITIONS.keys():
|
||||
get_node(PANE_POSITIONS[pane_pos]).set_tabs_rearrange_group(1)
|
||||
for pane in PANES:
|
||||
var node = pane.scene.instance()
|
||||
node.name = pane.name
|
||||
var tab = get_node(PANE_POSITIONS[pane.position])
|
||||
tab.add_child(node)
|
||||
panes[pane.name] = node
|
||||
var tab = get_node(PANE_POSITIONS[pane.position])
|
||||
if config_cache.has_section_key("layout", pane.name+"_location"):
|
||||
tab = get_node(PANE_POSITIONS[config_cache.get_value("layout", pane.name+"_location")])
|
||||
if config_cache.has_section_key("layout", pane.name+"_hidden") && config_cache.get_value("layout", pane.name+"_hidden"):
|
||||
node.set_meta("parent_tab_container", tab)
|
||||
else:
|
||||
tab.add_child(node)
|
||||
# Split positions
|
||||
if config_cache.has_section_key("layout", "LeftVSplitOffset"):
|
||||
split_offset = config_cache.get_value("layout", "LeftVSplitOffset")
|
||||
if config_cache.has_section_key("layout", "LeftHSplitOffset"):
|
||||
$Left.split_offset = config_cache.get_value("layout", "LeftHSplitOffset")
|
||||
if config_cache.has_section_key("layout", "RightVSplitOffset"):
|
||||
$SplitRight.split_offset = config_cache.get_value("layout", "RightVSplitOffset")
|
||||
if config_cache.has_section_key("layout", "RightHSplitOffset"):
|
||||
$SplitRight/Right.split_offset = config_cache.get_value("layout", "RightHSplitOffset")
|
||||
update_panes()
|
||||
|
||||
func save_config(config_cache) -> void:
|
||||
for p in panes:
|
||||
var location = panes[p].get_parent()
|
||||
var hidden = false
|
||||
if location == null:
|
||||
hidden = true
|
||||
location = panes[p].get_meta("parent_tab_container")
|
||||
config_cache.set_value("layout", p+"_hidden", hidden)
|
||||
for l in PANE_POSITIONS.keys():
|
||||
if location == get_node(PANE_POSITIONS[l]):
|
||||
config_cache.set_value("layout", p+"_location", l)
|
||||
config_cache.set_value("layout", "LeftVSplitOffset", split_offset)
|
||||
config_cache.set_value("layout", "LeftHSplitOffset", $Left.split_offset)
|
||||
config_cache.set_value("layout", "RightVSplitOffset", $SplitRight.split_offset)
|
||||
config_cache.set_value("layout", "RightHSplitOffset", $SplitRight/Right.split_offset)
|
||||
|
||||
func get_pane(n) -> Control:
|
||||
return panes[n]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user