1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-19 01:29:49 +00:00

Set project name (#490)

* Set project name. Also fixed a bug

Added ability to set project name also fixed a bug that "if the aspect ratio button is pressed and a template of different width and height were selected, then the button also applied on them e.g a template of (but it shouldn't)"
Example: write 1 in width, 2 in height, enable aspect ratio, and then try to change template... a template of 256x240 will give 120x240

* Add files via upload

* Adjust save name to project name

* Add files via upload
This commit is contained in:
Variable 2021-05-24 19:03:56 +05:00 committed by GitHub
parent 62dc608eea
commit 0257adb97b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 17 deletions

View file

@ -99,7 +99,13 @@ func _on_CreateNewImage_confirmed() -> void:
Global.canvas.fill_color = fill_color Global.canvas.fill_color = fill_color
var frame : Frame = Global.canvas.new_empty_frame(false, true, Vector2(width, height)) var frame : Frame = Global.canvas.new_empty_frame(false, true, Vector2(width, height))
var new_project := Project.new([frame], tr("untitled"), Vector2(width, height).floor()) var new_project : Project
var proj_name :String = $VBoxContainer/ProjectName/NameInput.text
if proj_name.is_valid_filename():
new_project = Project.new([frame], tr(proj_name), Vector2(width, height).floor())
else:
# an empty field or non valid name...
new_project = Project.new([frame], tr("untitled"), Vector2(width, height).floor())
new_project.layers.append(Layer.new()) new_project.layers.append(Layer.new())
Global.projects.append(new_project) Global.projects.append(new_project)
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1 Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
@ -131,12 +137,21 @@ func toggle_size_buttons() -> void:
func _on_TemplatesOptions_item_selected(id : int) -> void: func _on_TemplatesOptions_item_selected(id : int) -> void:
#if a template is chosen while "ratio button" is pressed then temporarily release it
var temporary_release = false
if ratio_box.pressed:
ratio_box.pressed = false
temporary_release = true
if id > 0: if id > 0:
width_value.value = templates[id - 1].resolution.x width_value.value = templates[id - 1].resolution.x
height_value.value = templates[id - 1].resolution.y height_value.value = templates[id - 1].resolution.y
else: else:
width_value.value = Global.default_image_width width_value.value = Global.default_image_width
height_value.value = Global.default_image_height height_value.value = Global.default_image_height
if temporary_release:
ratio_box.pressed = true
func _on_PortraitButton_toggled(button_pressed : bool) -> void: func _on_PortraitButton_toggled(button_pressed : bool) -> void:

View file

@ -8,9 +8,9 @@
[ext_resource path="res://assets/graphics/dark_themes/misc/lock_aspect_guides.png" type="Texture" id=6] [ext_resource path="res://assets/graphics/dark_themes/misc/lock_aspect_guides.png" type="Texture" id=6]
[node name="CreateNewImage" type="ConfirmationDialog"] [node name="CreateNewImage" type="ConfirmationDialog"]
margin_right = 300.0 margin_right = 375.0
margin_bottom = 200.0 margin_bottom = 222.0
rect_min_size = Vector2( 375, 200 ) rect_min_size = Vector2( 375, 222 )
window_title = "New..." window_title = "New..."
resizable = true resizable = true
script = ExtResource( 1 ) script = ExtResource( 1 )
@ -22,26 +22,46 @@ __meta__ = {
margin_left = 8.0 margin_left = 8.0
margin_top = 8.0 margin_top = 8.0
margin_right = 367.0 margin_right = 367.0
margin_bottom = 164.0 margin_bottom = 186.0
size_flags_horizontal = 0 size_flags_horizontal = 0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="ImageSize" type="Label" parent="VBoxContainer"] [node name="ProjectName" type="HBoxContainer" parent="VBoxContainer"]
margin_right = 359.0 margin_right = 359.0
margin_bottom = 14.0 margin_bottom = 24.0
[node name="NameLabel" type="Label" parent="VBoxContainer/ProjectName"]
margin_top = 5.0
margin_right = 100.0
margin_bottom = 19.0
rect_min_size = Vector2( 100, 0 )
text = "Project Name:"
[node name="NameInput" type="LineEdit" parent="VBoxContainer/ProjectName"]
margin_left = 104.0
margin_right = 359.0
margin_bottom = 24.0
mouse_default_cursor_shape = 2
size_flags_horizontal = 3
placeholder_text = "Enter name... (Default \"untitled\")"
[node name="ImageSize" type="Label" parent="VBoxContainer"]
margin_top = 28.0
margin_right = 359.0
margin_bottom = 42.0
text = "Image Size" text = "Image Size"
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"] [node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
margin_top = 18.0 margin_top = 46.0
margin_right = 359.0 margin_right = 359.0
margin_bottom = 22.0 margin_bottom = 50.0
[node name="TemplatesContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="TemplatesContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 26.0 margin_top = 54.0
margin_right = 359.0 margin_right = 359.0
margin_bottom = 46.0 margin_bottom = 74.0
[node name="TemplatesLabel" type="Label" parent="VBoxContainer/TemplatesContainer"] [node name="TemplatesLabel" type="Label" parent="VBoxContainer/TemplatesContainer"]
margin_top = 3.0 margin_top = 3.0
@ -62,9 +82,9 @@ items = [ "Default", null, false, 0, null ]
selected = 0 selected = 0
[node name="SizeContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="SizeContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 50.0 margin_top = 78.0
margin_right = 359.0 margin_right = 359.0
margin_bottom = 102.0 margin_bottom = 130.0
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/SizeContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/SizeContainer"]
margin_right = 346.0 margin_right = 346.0
@ -141,9 +161,9 @@ __meta__ = {
} }
[node name="SizeButtonsContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="SizeButtonsContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 106.0 margin_top = 134.0
margin_right = 359.0 margin_right = 359.0
margin_bottom = 126.0 margin_bottom = 154.0
[node name="PortraitButton" type="Button" parent="VBoxContainer/SizeButtonsContainer"] [node name="PortraitButton" type="Button" parent="VBoxContainer/SizeButtonsContainer"]
margin_right = 20.0 margin_right = 20.0
@ -193,9 +213,9 @@ __meta__ = {
} }
[node name="FillColorContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="FillColorContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 130.0 margin_top = 158.0
margin_right = 359.0 margin_right = 359.0
margin_bottom = 150.0 margin_bottom = 178.0
[node name="FillColorLabel" type="Label" parent="VBoxContainer/FillColorContainer"] [node name="FillColorLabel" type="Label" parent="VBoxContainer/FillColorContainer"]
margin_top = 3.0 margin_top = 3.0

View file

@ -259,8 +259,10 @@ func save_project_file() -> void:
if path == "": if path == "":
if OS.get_name() == "HTML5": if OS.get_name() == "HTML5":
Global.save_sprites_html5_dialog.popup_centered() Global.save_sprites_html5_dialog.popup_centered()
Global.save_sprites_html5_dialog.get_node("FileNameContainer/FileNameLineEdit").text = Global.current_project.name
else: else:
Global.save_sprites_dialog.popup_centered() Global.save_sprites_dialog.popup_centered()
Global.save_sprites_dialog.current_file = Global.current_project.name
Global.dialog_open(true) Global.dialog_open(true)
else: else:
Global.control._on_SaveSprite_file_selected(path) Global.control._on_SaveSprite_file_selected(path)
@ -270,8 +272,10 @@ func save_project_file_as() -> void:
Global.control.is_quitting_on_save = false Global.control.is_quitting_on_save = false
if OS.get_name() == "HTML5": if OS.get_name() == "HTML5":
Global.save_sprites_html5_dialog.popup_centered() Global.save_sprites_html5_dialog.popup_centered()
Global.save_sprites_html5_dialog.get_node("FileNameContainer/FileNameLineEdit").text = Global.current_project.name
else: else:
Global.save_sprites_dialog.popup_centered() Global.save_sprites_dialog.popup_centered()
Global.save_sprites_dialog.current_file = Global.current_project.name
Global.dialog_open(true) Global.dialog_open(true)