mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Remember the window position and size across restarts
This commit is contained in:
parent
cfca689e3f
commit
89237ccbc4
@ -163,7 +163,7 @@ func update_spatial_material(m, file_prefix = null) -> void:
|
||||
if m is SpatialMaterial:
|
||||
# Make the material double-sided for better visiblity in the preview
|
||||
m.params_cull_mode = SpatialMaterial.CULL_DISABLED
|
||||
# Albedo
|
||||
# Albedo
|
||||
m.albedo_color = parameters.albedo_color
|
||||
m.albedo_texture = get_generated_texture("albedo", file_prefix)
|
||||
m.metallic = parameters.metallic
|
||||
|
@ -3,6 +3,8 @@ extends Panel
|
||||
|
||||
var recent_files = []
|
||||
|
||||
var config_cache : ConfigFile = ConfigFile.new()
|
||||
|
||||
var editor_interface = null
|
||||
var current_tab = null
|
||||
|
||||
@ -52,6 +54,20 @@ signal quit
|
||||
var is_mac = false
|
||||
|
||||
func _ready() -> void:
|
||||
# Restore the window position/size if values are present in the configuration cache
|
||||
config_cache.load("user://cache.ini")
|
||||
|
||||
if config_cache.has_section_key("window", "screen"):
|
||||
OS.current_screen = config_cache.get_value("window", "screen")
|
||||
if config_cache.has_section_key("window", "maximized"):
|
||||
OS.window_maximized = config_cache.get_value("window", "maximized")
|
||||
|
||||
if !OS.window_maximized:
|
||||
if config_cache.has_section_key("window", "position"):
|
||||
OS.window_position = config_cache.get_value("window", "position")
|
||||
if config_cache.has_section_key("window", "size"):
|
||||
OS.window_size = config_cache.get_value("window", "size")
|
||||
|
||||
if OS.get_name() == "OSX":
|
||||
is_mac = true
|
||||
|
||||
@ -479,3 +495,11 @@ func _on_Preview_show_background_preview(v) -> void:
|
||||
var bgpv = $VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview/Viewport
|
||||
bgpv.world = pv.find_world()
|
||||
$VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview.visible = v
|
||||
|
||||
func _exit_tree() -> void:
|
||||
# Save the window position and size to remember it when restarting the application
|
||||
config_cache.set_value("window", "screen", OS.current_screen)
|
||||
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)
|
||||
config_cache.save("user://cache.ini")
|
||||
|
Loading…
Reference in New Issue
Block a user