mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Add a project properties dialog
Allows users to change project name and add custom user data. I was not sure where to put this, so I put it under the Edit menu. It might be a good idea to add a new "Project" menu in the future, and perhaps Scale Image, Resize Canvas and Crop to Content/Selection could be placed there, as they always affect the entire project.
This commit is contained in:
parent
c5c421bd28
commit
596c174c92
|
@ -1878,6 +1878,9 @@ msgstr ""
|
|||
msgid "Properties"
|
||||
msgstr ""
|
||||
|
||||
msgid "Project properties"
|
||||
msgstr ""
|
||||
|
||||
msgid "Frame properties"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -841,6 +841,10 @@ cancel_reference_transform={
|
|||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
project_properties={
|
||||
"deadzone": 0.5,
|
||||
"events": []
|
||||
}
|
||||
|
||||
[input_devices]
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ enum MeasurementMode { NONE, MOVE }
|
|||
## Enumeration of items present in the File Menu.
|
||||
enum FileMenu { NEW, OPEN, OPEN_LAST_PROJECT, RECENT, SAVE, SAVE_AS, EXPORT, EXPORT_AS, QUIT }
|
||||
## Enumeration of items present in the Edit Menu.
|
||||
enum EditMenu { UNDO, REDO, COPY, CUT, PASTE, PASTE_IN_PLACE, DELETE, NEW_BRUSH, PREFERENCES }
|
||||
enum EditMenu {
|
||||
UNDO, REDO, COPY, CUT, PASTE, PASTE_IN_PLACE, DELETE, NEW_BRUSH, PROJECT_PROPERTIES, PREFERENCES
|
||||
}
|
||||
## Enumeration of items present in the View Menu.
|
||||
enum ViewMenu {
|
||||
TILE_MODE,
|
||||
|
@ -717,6 +719,7 @@ func _initialize_keychain() -> void:
|
|||
"paste_in_place": Keychain.InputAction.new("", "Edit menu", true),
|
||||
"delete": Keychain.InputAction.new("", "Edit menu", true),
|
||||
"new_brush": Keychain.InputAction.new("", "Edit menu", true),
|
||||
&"project_properties": Keychain.InputAction.new("", "Edit menu", true),
|
||||
"preferences": Keychain.InputAction.new("", "Edit menu", true),
|
||||
"scale_image": Keychain.InputAction.new("", "Image menu", true),
|
||||
"crop_to_selection": Keychain.InputAction.new("", "Image menu", true),
|
||||
|
|
|
@ -50,6 +50,7 @@ var reference_images: Array[ReferenceImage] = []
|
|||
var reference_index: int = -1 # The currently selected index ReferenceImage
|
||||
var vanishing_points := [] ## Array of Vanishing Points
|
||||
var fps := 6.0
|
||||
var user_data := "" ## User defined data, set in the project properties.
|
||||
|
||||
var x_symmetry_point: float
|
||||
var y_symmetry_point: float
|
||||
|
@ -268,6 +269,7 @@ func serialize() -> Dictionary:
|
|||
"export_file_name": file_name,
|
||||
"export_file_format": file_format,
|
||||
"fps": fps,
|
||||
"user_data": user_data,
|
||||
"metadata": metadata
|
||||
}
|
||||
|
||||
|
@ -384,12 +386,10 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
|
|||
x_symmetry_axis.points[point].y = floorf(y_symmetry_point / 2 + 1)
|
||||
for point in y_symmetry_axis.points.size():
|
||||
y_symmetry_axis.points[point].x = floorf(x_symmetry_point / 2 + 1)
|
||||
if dict.has("export_file_name"):
|
||||
file_name = dict.export_file_name
|
||||
if dict.has("export_file_format"):
|
||||
file_format = dict.export_file_format
|
||||
if dict.has("fps"):
|
||||
fps = dict.fps
|
||||
file_name = dict.get("export_file_name", file_name)
|
||||
file_format = dict.get("export_file_format", file_name)
|
||||
fps = dict.get("fps", file_name)
|
||||
user_data = dict.get("user_data", user_data)
|
||||
_deserialize_metadata(self, dict)
|
||||
order_layers()
|
||||
|
||||
|
|
24
src/UI/Dialogs/ProjectProperties.gd
Normal file
24
src/UI/Dialogs/ProjectProperties.gd
Normal file
|
@ -0,0 +1,24 @@
|
|||
extends AcceptDialog
|
||||
|
||||
@onready var size_value_label := $GridContainer/SizeValueLabel as Label
|
||||
@onready var frames_value_label := $GridContainer/FramesValueLabel as Label
|
||||
@onready var layers_value_label := $GridContainer/LayersValueLabel as Label
|
||||
@onready var name_line_edit := $GridContainer/NameLineEdit as LineEdit
|
||||
@onready var user_data_text_edit := $GridContainer/UserDataTextEdit as TextEdit
|
||||
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
Global.dialog_open(visible)
|
||||
size_value_label.text = str(Global.current_project.size)
|
||||
frames_value_label.text = str(Global.current_project.frames.size())
|
||||
layers_value_label.text = str(Global.current_project.layers.size())
|
||||
name_line_edit.text = Global.current_project.name
|
||||
user_data_text_edit.text = Global.current_project.user_data
|
||||
|
||||
|
||||
func _on_name_line_edit_text_changed(new_text: String) -> void:
|
||||
Global.current_project.name = new_text
|
||||
|
||||
|
||||
func _on_user_data_text_edit_text_changed() -> void:
|
||||
Global.current_project.user_data = user_data_text_edit.text
|
70
src/UI/Dialogs/ProjectProperties.tscn
Normal file
70
src/UI/Dialogs/ProjectProperties.tscn
Normal file
|
@ -0,0 +1,70 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://dnjcs2l1ri38n"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/UI/Dialogs/ProjectProperties.gd" id="1_0n4uc"]
|
||||
|
||||
[node name="ProjectProperties" type="AcceptDialog"]
|
||||
title = "Project properties"
|
||||
size = Vector2i(197, 235)
|
||||
exclusive = false
|
||||
popup_window = true
|
||||
script = ExtResource("1_0n4uc")
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
offset_left = 8.0
|
||||
offset_top = 8.0
|
||||
offset_right = 189.0
|
||||
offset_bottom = 186.0
|
||||
columns = 2
|
||||
|
||||
[node name="SizeLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Size:"
|
||||
|
||||
[node name="SizeValueLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "64x64"
|
||||
|
||||
[node name="FramesLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Frames:"
|
||||
|
||||
[node name="FramesValueLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "64x64"
|
||||
|
||||
[node name="LayersLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Layers:"
|
||||
|
||||
[node name="LayersValueLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "64x64"
|
||||
|
||||
[node name="NameLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Name:"
|
||||
|
||||
[node name="NameLineEdit" type="LineEdit" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="UserDataLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
text = "User data:"
|
||||
|
||||
[node name="UserDataTextEdit" type="TextEdit" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
scroll_fit_content_height = true
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||
[connection signal="text_changed" from="GridContainer/NameLineEdit" to="." method="_on_name_line_edit_text_changed"]
|
||||
[connection signal="text_changed" from="GridContainer/UserDataTextEdit" to="." method="_on_user_data_text_edit_text_changed"]
|
|
@ -15,6 +15,7 @@ var zen_mode := false
|
|||
|
||||
# Dialogs
|
||||
var new_image_dialog := Dialog.new("res://src/UI/Dialogs/CreateNewImage.tscn")
|
||||
var project_properties_dialog := Dialog.new("res://src/UI/Dialogs/ProjectProperties.tscn")
|
||||
var preferences_dialog := Dialog.new("res://src/Preferences/PreferencesDialog.tscn")
|
||||
var offset_image_dialog := Dialog.new("res://src/UI/Dialogs/ImageEffects/OffsetImage.tscn")
|
||||
var scale_image_dialog := Dialog.new("res://src/UI/Dialogs/ImageEffects/ScaleImage.tscn")
|
||||
|
@ -171,6 +172,7 @@ func _setup_edit_menu() -> void:
|
|||
"Paste in Place": "paste_in_place",
|
||||
"Delete": "delete",
|
||||
"New Brush": "new_brush",
|
||||
"Project properties": "project_properties",
|
||||
"Preferences": "preferences"
|
||||
}
|
||||
var i := 0
|
||||
|
@ -528,6 +530,8 @@ func edit_menu_id_pressed(id: int) -> void:
|
|||
Global.canvas.selection.delete()
|
||||
Global.EditMenu.NEW_BRUSH:
|
||||
Global.canvas.selection.new_brush()
|
||||
Global.EditMenu.PROJECT_PROPERTIES:
|
||||
project_properties_dialog.popup()
|
||||
Global.EditMenu.PREFERENCES:
|
||||
preferences_dialog.popup()
|
||||
_:
|
||||
|
|
Loading…
Reference in a new issue