mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Open last edited project at startup or at will feature (#215)
* Created feature that will alllow user to open last edited project on Pixelorama startup or open last edited project at will. Co-authored-by: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com>
This commit is contained in:
parent
fef7627f73
commit
086679f1f0
17
Main.tscn
17
Main.tscn
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=57 format=2]
|
[gd_scene load_steps=59 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Themes & Styles/Dark Theme/Dark Theme.tres" type="Theme" id=1]
|
[ext_resource path="res://Themes & Styles/Dark Theme/Dark Theme.tres" type="Theme" id=1]
|
||||||
[ext_resource path="res://Scripts/Main.gd" type="Script" id=2]
|
[ext_resource path="res://Scripts/Main.gd" type="Script" id=2]
|
||||||
|
@ -45,6 +45,8 @@
|
||||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Tools/Zoom.png" type="Texture" id=43]
|
[ext_resource path="res://Assets/Graphics/Dark Themes/Tools/Zoom.png" type="Texture" id=43]
|
||||||
[ext_resource path="res://Prefabs/Dialogs/HSVDialog.tscn" type="PackedScene" id=44]
|
[ext_resource path="res://Prefabs/Dialogs/HSVDialog.tscn" type="PackedScene" id=44]
|
||||||
[ext_resource path="res://Scripts/TransparentChecker.gd" type="Script" id=45]
|
[ext_resource path="res://Scripts/TransparentChecker.gd" type="Script" id=45]
|
||||||
|
[ext_resource path="res://Prefabs/Dialogs/OpenLastProjectAlertDialog.tscn" type="PackedScene" id=46]
|
||||||
|
[ext_resource path="res://Prefabs/Dialogs/NoProjectEditedOrCreatedAlertDialog.tscn" type="PackedScene" id=47]
|
||||||
|
|
||||||
[sub_resource type="Shader" id=1]
|
[sub_resource type="Shader" id=1]
|
||||||
code = "shader_type canvas_item;
|
code = "shader_type canvas_item;
|
||||||
|
@ -1350,7 +1352,7 @@ columns = 5
|
||||||
[node name="OpenSprite" type="FileDialog" parent="."]
|
[node name="OpenSprite" type="FileDialog" parent="."]
|
||||||
margin_right = 515.0
|
margin_right = 515.0
|
||||||
margin_bottom = 348.0
|
margin_bottom = 348.0
|
||||||
window_title = "Open a File"
|
window_title = "Otwórz plik"
|
||||||
resizable = true
|
resizable = true
|
||||||
mode = 0
|
mode = 0
|
||||||
access = 2
|
access = 2
|
||||||
|
@ -1422,10 +1424,21 @@ dialog_text = "This is an error message!"
|
||||||
[node name="NewPaletteDialog" parent="." instance=ExtResource( 36 )]
|
[node name="NewPaletteDialog" parent="." instance=ExtResource( 36 )]
|
||||||
|
|
||||||
[node name="PaletteImportFileDialog" parent="." instance=ExtResource( 37 )]
|
[node name="PaletteImportFileDialog" parent="." instance=ExtResource( 37 )]
|
||||||
|
window_title = "Otwórz plik"
|
||||||
filters = PoolStringArray( "*.json ; JavaScript Object Notation", "*.gpl ; Gimp Palette Library", "*.png; Portable Network Graphics" )
|
filters = PoolStringArray( "*.json ; JavaScript Object Notation", "*.gpl ; Gimp Palette Library", "*.png; Portable Network Graphics" )
|
||||||
|
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||||
|
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||||
|
|
||||||
[node name="HSVDialog" parent="." instance=ExtResource( 44 )]
|
[node name="HSVDialog" parent="." instance=ExtResource( 44 )]
|
||||||
|
|
||||||
|
[node name="OpenLastProjectAlertDialog" parent="." instance=ExtResource( 46 )]
|
||||||
|
margin_right = 179.0
|
||||||
|
margin_bottom = 62.0
|
||||||
|
|
||||||
|
[node name="NoProjectEditedOrCreatedAlertDialog" parent="." instance=ExtResource( 47 )]
|
||||||
|
margin_bottom = 62.0
|
||||||
|
window_title = "Alarm!"
|
||||||
|
|
||||||
[node name="LeftCursor" type="Sprite" parent="."]
|
[node name="LeftCursor" type="Sprite" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
|
|
7
Prefabs/Dialogs/NoProjectEditedOrCreatedAlertDialog.tscn
Normal file
7
Prefabs/Dialogs/NoProjectEditedOrCreatedAlertDialog.tscn
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_scene format=2]
|
||||||
|
|
||||||
|
[node name="NoProjectEditedOrCreatedAlertDialog" type="AcceptDialog"]
|
||||||
|
dialog_text = "You haven't saved or opened any project in Pixelorama yet!"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
7
Prefabs/Dialogs/OpenLastProjectAlertDialog.tscn
Normal file
7
Prefabs/Dialogs/OpenLastProjectAlertDialog.tscn
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_scene format=2]
|
||||||
|
|
||||||
|
[node name="OpenLastProjectAlertDialog" type="AcceptDialog"]
|
||||||
|
margin_right = 209.0
|
||||||
|
margin_bottom = 58.0
|
||||||
|
window_title = "Alarm!"
|
||||||
|
dialog_text = "Cannot find last project file."
|
|
@ -49,30 +49,39 @@ size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/ScrollContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/ScrollContainer"]
|
||||||
margin_right = 308.0
|
margin_right = 308.0
|
||||||
margin_bottom = 1158.0
|
margin_bottom = 1186.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="General" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
[node name="General" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 88.0
|
margin_bottom = 116.0
|
||||||
|
|
||||||
[node name="SmoothZoom" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/General"]
|
[node name="OpenLastProject" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/General"]
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
|
hint_tooltip = "Opens last opened project on startup"
|
||||||
|
mouse_default_cursor_shape = 2
|
||||||
|
pressed = true
|
||||||
|
text = "Open last project on startup"
|
||||||
|
|
||||||
|
[node name="SmoothZoom" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/General"]
|
||||||
|
margin_top = 28.0
|
||||||
|
margin_right = 306.0
|
||||||
|
margin_bottom = 52.0
|
||||||
hint_tooltip = "Adds a smoother transition when zooming in or out"
|
hint_tooltip = "Adds a smoother transition when zooming in or out"
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
pressed = true
|
pressed = true
|
||||||
text = "Smooth Zoom"
|
text = "Smooth Zoom"
|
||||||
|
|
||||||
[node name="HSeparator2" type="HSeparator" parent="HSplitContainer/ScrollContainer/VBoxContainer/General"]
|
[node name="HSeparator2" type="HSeparator" parent="HSplitContainer/ScrollContainer/VBoxContainer/General"]
|
||||||
margin_top = 28.0
|
margin_top = 56.0
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 32.0
|
margin_bottom = 60.0
|
||||||
|
|
||||||
[node name="GridContainer" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/General"]
|
[node name="GridContainer" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/General"]
|
||||||
margin_top = 36.0
|
margin_top = 64.0
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 88.0
|
margin_bottom = 116.0
|
||||||
custom_constants/vseparation = 4
|
custom_constants/vseparation = 4
|
||||||
custom_constants/hseparation = 4
|
custom_constants/hseparation = 4
|
||||||
columns = 2
|
columns = 2
|
||||||
|
@ -137,9 +146,9 @@ items = [ "None", null, false, 0, null, "Affect Brush's Alpha", null, false, 1,
|
||||||
selected = 1
|
selected = 1
|
||||||
|
|
||||||
[node name="Languages" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
[node name="Languages" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||||
margin_top = 92.0
|
margin_top = 120.0
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 484.0
|
margin_bottom = 512.0
|
||||||
|
|
||||||
[node name="System Language" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
|
[node name="System Language" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
|
@ -243,9 +252,9 @@ custom_fonts/font = ExtResource( 3 )
|
||||||
text = "繁體中文 [zh_TW]"
|
text = "繁體中文 [zh_TW]"
|
||||||
|
|
||||||
[node name="Themes" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
[node name="Themes" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||||
margin_top = 488.0
|
margin_top = 516.0
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 624.0
|
margin_bottom = 652.0
|
||||||
|
|
||||||
[node name="Dark Theme" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Themes"]
|
[node name="Dark Theme" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Themes"]
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
|
@ -282,9 +291,9 @@ mouse_default_cursor_shape = 2
|
||||||
text = "Light"
|
text = "Light"
|
||||||
|
|
||||||
[node name="Canvas" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
[node name="Canvas" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||||
margin_top = 628.0
|
margin_top = 656.0
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 820.0
|
margin_bottom = 848.0
|
||||||
|
|
||||||
[node name="GuideOptions" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"]
|
[node name="GuideOptions" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"]
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
|
@ -456,9 +465,9 @@ mouse_default_cursor_shape = 2
|
||||||
color = Color( 1, 1, 1, 1 )
|
color = Color( 1, 1, 1, 1 )
|
||||||
|
|
||||||
[node name="Image" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
[node name="Image" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||||
margin_top = 824.0
|
margin_top = 852.0
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 900.0
|
margin_bottom = 928.0
|
||||||
|
|
||||||
[node name="ImageOptions" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image"]
|
[node name="ImageOptions" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image"]
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
|
@ -529,9 +538,9 @@ mouse_default_cursor_shape = 2
|
||||||
color = Color( 0, 0, 0, 0 )
|
color = Color( 0, 0, 0, 0 )
|
||||||
|
|
||||||
[node name="Shortcuts" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
[node name="Shortcuts" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||||
margin_top = 904.0
|
margin_top = 932.0
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
margin_bottom = 1158.0
|
margin_bottom = 1186.0
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts"]
|
||||||
margin_right = 306.0
|
margin_right = 306.0
|
||||||
|
@ -796,6 +805,7 @@ __meta__ = {
|
||||||
[connection signal="about_to_show" from="." to="." method="_on_PreferencesDialog_about_to_show"]
|
[connection signal="about_to_show" from="." to="." method="_on_PreferencesDialog_about_to_show"]
|
||||||
[connection signal="popup_hide" from="." to="." method="_on_PreferencesDialog_popup_hide"]
|
[connection signal="popup_hide" from="." to="." method="_on_PreferencesDialog_popup_hide"]
|
||||||
[connection signal="item_selected" from="HSplitContainer/Tree" to="." method="_on_Tree_item_selected"]
|
[connection signal="item_selected" from="HSplitContainer/Tree" to="." method="_on_Tree_item_selected"]
|
||||||
|
[connection signal="pressed" from="HSplitContainer/ScrollContainer/VBoxContainer/General/OpenLastProject" to="." method="_on_OpenLastProject_pressed"]
|
||||||
[connection signal="pressed" from="HSplitContainer/ScrollContainer/VBoxContainer/General/SmoothZoom" to="." method="_on_SmoothZoom_pressed"]
|
[connection signal="pressed" from="HSplitContainer/ScrollContainer/VBoxContainer/General/SmoothZoom" to="." method="_on_SmoothZoom_pressed"]
|
||||||
[connection signal="toggled" from="HSplitContainer/ScrollContainer/VBoxContainer/General/GridContainer/LeftIndicatorCheckbox" to="." method="_on_LeftIndicatorCheckbox_toggled"]
|
[connection signal="toggled" from="HSplitContainer/ScrollContainer/VBoxContainer/General/GridContainer/LeftIndicatorCheckbox" to="." method="_on_LeftIndicatorCheckbox_toggled"]
|
||||||
[connection signal="toggled" from="HSplitContainer/ScrollContainer/VBoxContainer/General/GridContainer/RightIndicatorCheckbox" to="." method="_on_RightIndicatorCheckbox_toggled"]
|
[connection signal="toggled" from="HSplitContainer/ScrollContainer/VBoxContainer/General/GridContainer/RightIndicatorCheckbox" to="." method="_on_RightIndicatorCheckbox_toggled"]
|
||||||
|
|
|
@ -314,7 +314,7 @@ func export_processed_images(ignore_overwrites : bool) -> void:
|
||||||
# Store settings for quick export and when the dialog is opened again
|
# Store settings for quick export and when the dialog is opened again
|
||||||
was_exported = true
|
was_exported = true
|
||||||
store_export_settings()
|
store_export_settings()
|
||||||
Global.file_menu.get_popup().set_item_text(5, tr("Export") + " %s" % (file_name + file_format_string(file_format)))
|
Global.file_menu.get_popup().set_item_text(6, tr("Export") + " %s" % (file_name + file_format_string(file_format)))
|
||||||
Global.notification_label("File(s) exported")
|
Global.notification_label("File(s) exported")
|
||||||
hide()
|
hide()
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ onready var canvas = $HSplitContainer/ScrollContainer/VBoxContainer/Canvas
|
||||||
onready var image = $HSplitContainer/ScrollContainer/VBoxContainer/Image
|
onready var image = $HSplitContainer/ScrollContainer/VBoxContainer/Image
|
||||||
onready var shortcuts = $HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts
|
onready var shortcuts = $HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts
|
||||||
|
|
||||||
|
onready var open_last_project_button = $HSplitContainer/ScrollContainer/VBoxContainer/General/OpenLastProject
|
||||||
onready var smooth_zoom_button = $HSplitContainer/ScrollContainer/VBoxContainer/General/SmoothZoom
|
onready var smooth_zoom_button = $HSplitContainer/ScrollContainer/VBoxContainer/General/SmoothZoom
|
||||||
onready var sensitivity_option = $HSplitContainer/ScrollContainer/VBoxContainer/General/PressureSentivity/PressureSensitivityOptionButton
|
onready var sensitivity_option = $HSplitContainer/ScrollContainer/VBoxContainer/General/PressureSentivity/PressureSensitivityOptionButton
|
||||||
onready var left_tool_icon = $HSplitContainer/ScrollContainer/VBoxContainer/General/GridContainer/LeftToolIconCheckbox
|
onready var left_tool_icon = $HSplitContainer/ScrollContainer/VBoxContainer/General/GridContainer/LeftToolIconCheckbox
|
||||||
|
@ -58,6 +59,9 @@ func _ready() -> void:
|
||||||
themes.get_child(0).pressed = true
|
themes.get_child(0).pressed = true
|
||||||
|
|
||||||
# Set default values for General options
|
# Set default values for General options
|
||||||
|
if Global.config_cache.has_section_key("preferences", "open_last_project"):
|
||||||
|
Global.open_last_project = Global.config_cache.get_value("preferences", "open_last_project")
|
||||||
|
open_last_project_button.pressed = Global.open_last_project
|
||||||
if Global.config_cache.has_section_key("preferences", "smooth_zoom"):
|
if Global.config_cache.has_section_key("preferences", "smooth_zoom"):
|
||||||
Global.smooth_zoom = Global.config_cache.get_value("preferences", "smooth_zoom")
|
Global.smooth_zoom = Global.config_cache.get_value("preferences", "smooth_zoom")
|
||||||
smooth_zoom_button.pressed = Global.smooth_zoom
|
smooth_zoom_button.pressed = Global.smooth_zoom
|
||||||
|
@ -508,3 +512,8 @@ func _on_ShortcutSelector_confirmed() -> void:
|
||||||
shortcuts.get_node("Shortcuts/" + action_being_edited).text = OS.get_scancode_string(new_input_event.get_scancode_with_modifiers())
|
shortcuts.get_node("Shortcuts/" + action_being_edited).text = OS.get_scancode_string(new_input_event.get_scancode_with_modifiers())
|
||||||
$Popups/ShortcutSelector.hide()
|
$Popups/ShortcutSelector.hide()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_OpenLastProject_pressed():
|
||||||
|
Global.open_last_project = !Global.open_last_project
|
||||||
|
Global.config_cache.set_value("preferences", "open_last_project", Global.open_last_project)
|
||||||
|
Global.config_cache.save("user://cache.ini")
|
||||||
|
|
|
@ -45,6 +45,7 @@ var can_draw := false
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var has_focus := false
|
var has_focus := false
|
||||||
var pressure_sensitivity_mode = Pressure_Sensitivity.NONE
|
var pressure_sensitivity_mode = Pressure_Sensitivity.NONE
|
||||||
|
var open_last_project := true
|
||||||
var smooth_zoom := true
|
var smooth_zoom := true
|
||||||
var cursor_image = preload("res://Assets/Graphics/Cursor.png")
|
var cursor_image = preload("res://Assets/Graphics/Cursor.png")
|
||||||
var left_cursor_tool_texture : ImageTexture
|
var left_cursor_tool_texture : ImageTexture
|
||||||
|
|
|
@ -42,6 +42,7 @@ func _ready() -> void:
|
||||||
var file_menu_items := {
|
var file_menu_items := {
|
||||||
"New..." : InputMap.get_action_list("new_file")[0].get_scancode_with_modifiers(),
|
"New..." : InputMap.get_action_list("new_file")[0].get_scancode_with_modifiers(),
|
||||||
"Open..." : InputMap.get_action_list("open_file")[0].get_scancode_with_modifiers(),
|
"Open..." : InputMap.get_action_list("open_file")[0].get_scancode_with_modifiers(),
|
||||||
|
'Open last project...' : 0,
|
||||||
"Save..." : InputMap.get_action_list("save_file")[0].get_scancode_with_modifiers(),
|
"Save..." : InputMap.get_action_list("save_file")[0].get_scancode_with_modifiers(),
|
||||||
"Save as..." : InputMap.get_action_list("save_file_as")[0].get_scancode_with_modifiers(),
|
"Save as..." : InputMap.get_action_list("save_file_as")[0].get_scancode_with_modifiers(),
|
||||||
"Import..." : InputMap.get_action_list("import_file")[0].get_scancode_with_modifiers(),
|
"Import..." : InputMap.get_action_list("import_file")[0].get_scancode_with_modifiers(),
|
||||||
|
@ -187,6 +188,12 @@ func _ready() -> void:
|
||||||
else:
|
else:
|
||||||
Global.can_draw = true
|
Global.can_draw = true
|
||||||
|
|
||||||
|
if not Global.config_cache.has_section_key("preferences", "open_last_project"):
|
||||||
|
Global.config_cache.set_value("preferences", "open_last_project", true)
|
||||||
|
if Global.config_cache.get_value("preferences", "open_last_project"):
|
||||||
|
Global.open_last_project = Global.config_cache.get_value("preferences", "open_last_project")
|
||||||
|
load_last_project()
|
||||||
|
|
||||||
func _input(event : InputEvent) -> void:
|
func _input(event : InputEvent) -> void:
|
||||||
Global.left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
|
Global.left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
|
||||||
Global.left_cursor.texture = Global.left_cursor_tool_texture
|
Global.left_cursor.texture = Global.left_cursor_tool_texture
|
||||||
|
@ -230,31 +237,37 @@ func file_menu_id_pressed(id : int) -> void:
|
||||||
$OpenSprite.popup_centered()
|
$OpenSprite.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
opensprite_file_selected = false
|
opensprite_file_selected = false
|
||||||
2: # Save
|
2: # Open last project
|
||||||
|
# Check if last project path is set and if yes then open
|
||||||
|
if Global.config_cache.has_section_key("preferences", "last_project_path"):
|
||||||
|
load_last_project()
|
||||||
|
else: # if not then warn user that he didn't edit any project yet
|
||||||
|
$NoProjectEditedOrCreatedAlertDialog.popup_centered()
|
||||||
|
3: # Save
|
||||||
is_quitting_on_save = false
|
is_quitting_on_save = false
|
||||||
if OpenSave.current_save_path == "":
|
if OpenSave.current_save_path == "":
|
||||||
$SaveSprite.popup_centered()
|
$SaveSprite.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
else:
|
else:
|
||||||
_on_SaveSprite_file_selected(OpenSave.current_save_path)
|
_on_SaveSprite_file_selected(OpenSave.current_save_path)
|
||||||
3: # Save as
|
4: # Save as
|
||||||
is_quitting_on_save = false
|
is_quitting_on_save = false
|
||||||
$SaveSprite.popup_centered()
|
$SaveSprite.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
4: # Import
|
5: # Import
|
||||||
$ImportSprites.popup_centered()
|
$ImportSprites.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
opensprite_file_selected = false
|
opensprite_file_selected = false
|
||||||
5: # Export
|
6: # Export
|
||||||
if $ExportDialog.was_exported == false:
|
if $ExportDialog.was_exported == false:
|
||||||
$ExportDialog.popup_centered()
|
$ExportDialog.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
else:
|
else:
|
||||||
$ExportDialog.external_export()
|
$ExportDialog.external_export()
|
||||||
6: # Export as
|
7: # Export as
|
||||||
$ExportDialog.popup_centered()
|
$ExportDialog.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
7: # Quit
|
8: # Quit
|
||||||
show_quit_dialog()
|
show_quit_dialog()
|
||||||
|
|
||||||
func edit_menu_id_pressed(id : int) -> void:
|
func edit_menu_id_pressed(id : int) -> void:
|
||||||
|
@ -405,6 +418,18 @@ func help_menu_id_pressed(id : int) -> void:
|
||||||
$AboutDialog.popup_centered()
|
$AboutDialog.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
|
|
||||||
|
func load_last_project():
|
||||||
|
# Check if any project was saved or opened last time
|
||||||
|
if Global.config_cache.has_section_key("preferences", "last_project_path"):
|
||||||
|
# Check if file still exists on disk
|
||||||
|
var file_path = Global.config_cache.get_value("preferences", "last_project_path")
|
||||||
|
var file_check := File.new()
|
||||||
|
if file_check.file_exists(file_path): # If yes then load the file
|
||||||
|
_on_OpenSprite_file_selected(file_path)
|
||||||
|
else:
|
||||||
|
# If file doesn't exist on disk then warn user about this
|
||||||
|
$OpenLastProjectAlertDialog.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
func _on_UnsavedCanvasDialog_confirmed() -> void:
|
func _on_UnsavedCanvasDialog_confirmed() -> void:
|
||||||
$CreateNewImage.popup_centered()
|
$CreateNewImage.popup_centered()
|
||||||
|
@ -414,20 +439,26 @@ func _on_OpenSprite_file_selected(path : String) -> void:
|
||||||
OpenSave.open_pxo_file(path)
|
OpenSave.open_pxo_file(path)
|
||||||
|
|
||||||
$SaveSprite.current_path = path
|
$SaveSprite.current_path = path
|
||||||
|
# Set last opened project path and save
|
||||||
|
Global.config_cache.set_value("preferences", "last_project_path", path)
|
||||||
|
Global.config_cache.save("user://cache.ini")
|
||||||
$ExportDialog.file_name = path.get_file().trim_suffix(".pxo")
|
$ExportDialog.file_name = path.get_file().trim_suffix(".pxo")
|
||||||
$ExportDialog.directory_path = path.get_base_dir()
|
$ExportDialog.directory_path = path.get_base_dir()
|
||||||
$ExportDialog.was_exported = false
|
$ExportDialog.was_exported = false
|
||||||
file_menu.set_item_text(2, tr("Save") + " %s" % path.get_file())
|
file_menu.set_item_text(3, tr("Save") + " %s" % path.get_file())
|
||||||
file_menu.set_item_text(5, tr("Export"))
|
file_menu.set_item_text(6, tr("Export"))
|
||||||
|
|
||||||
|
|
||||||
func _on_SaveSprite_file_selected(path : String) -> void:
|
func _on_SaveSprite_file_selected(path : String) -> void:
|
||||||
OpenSave.save_pxo_file(path)
|
OpenSave.save_pxo_file(path)
|
||||||
|
|
||||||
|
# Set last opened project path and save
|
||||||
|
Global.config_cache.set_value("preferences", "last_project_path", path)
|
||||||
|
Global.config_cache.save("user://cache.ini")
|
||||||
$ExportDialog.file_name = path.get_file().trim_suffix(".pxo")
|
$ExportDialog.file_name = path.get_file().trim_suffix(".pxo")
|
||||||
$ExportDialog.directory_path = path.get_base_dir()
|
$ExportDialog.directory_path = path.get_base_dir()
|
||||||
$ExportDialog.was_exported = false
|
$ExportDialog.was_exported = false
|
||||||
file_menu.set_item_text(2, tr("Save") + " %s" % path.get_file())
|
file_menu.set_item_text(3, tr("Save") + " %s" % path.get_file())
|
||||||
|
|
||||||
if is_quitting_on_save:
|
if is_quitting_on_save:
|
||||||
_on_QuitDialog_confirmed()
|
_on_QuitDialog_confirmed()
|
||||||
|
|
|
@ -1037,3 +1037,12 @@ msgstr ""
|
||||||
|
|
||||||
msgid "A tool assigned to the right mouse button"
|
msgid "A tool assigned to the right mouse button"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Cannot find last project file."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "You haven't saved or opened any project in Pixelorama yet!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Open last project..."
|
||||||
|
msgstr ""
|
||||||
|
|
Loading…
Reference in a new issue