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

Merge pull request #118 from Gaarco/master

Add preference options for the Image: default width, default height, default fill color and their translation strings
This commit is contained in:
Manolis Papadeas 2020-01-11 00:21:35 +02:00 committed by GitHub
commit 8b4c42a576
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 284 additions and 28 deletions

View file

@ -72,4 +72,5 @@ margin_right = 139.0
margin_bottom = 57.0
rect_min_size = Vector2( 64, 20 )
color = Color( 0, 0, 0, 0 )
[connection signal="about_to_show" from="." to="." method="_on_CreateNewImage_about_to_show"]
[connection signal="confirmed" from="." to="." method="_on_CreateNewImage_confirmed"]

View file

@ -37,12 +37,13 @@ size_flags_horizontal = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/ScrollContainer"]
margin_right = 205.0
margin_bottom = 282.0
margin_bottom = 554.0
size_flags_horizontal = 3
[node name="Languages" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
editor/display_folded = true
margin_right = 205.0
margin_bottom = 282.0
margin_bottom = 310.0
[node name="Language Options" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
margin_right = 205.0
@ -88,46 +89,46 @@ mouse_default_cursor_shape = 2
text = "Français [fr]"
[node name="Italian" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
margin_top = 144.0
margin_right = 205.0
margin_bottom = 168.0
mouse_default_cursor_shape = 2
text = "Italian [it]"
[node name="Polish" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
margin_top = 172.0
margin_right = 205.0
margin_bottom = 196.0
mouse_default_cursor_shape = 2
text = "Polski [pl]"
text = "Italian [it]"
[node name="Brazilian Portuguese" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
[node name="Polish" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
margin_top = 200.0
margin_right = 205.0
margin_bottom = 224.0
mouse_default_cursor_shape = 2
text = "Português Brasileiro [pt_BR]"
text = "Polski [pl]"
[node name="Russian" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
[node name="Brazilian Portuguese" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
margin_top = 228.0
margin_right = 205.0
margin_bottom = 252.0
mouse_default_cursor_shape = 2
text = "Português Brasileiro [pt_BR]"
[node name="Russian" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
margin_top = 256.0
margin_right = 205.0
margin_bottom = 280.0
mouse_default_cursor_shape = 2
text = "Русский [ru]"
[node name="Traditional Chinese" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Languages"]
margin_top = 256.0
margin_top = 284.0
margin_right = 205.0
margin_bottom = 282.0
margin_bottom = 310.0
mouse_default_cursor_shape = 2
custom_fonts/font = ExtResource( 3 )
text = "繁體中文 [zh_TW]"
[node name="Themes" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
visible = false
margin_top = 286.0
editor/display_folded = true
margin_top = 314.0
margin_right = 205.0
margin_bottom = 454.0
margin_bottom = 482.0
[node name="Theme Options" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Themes"]
margin_right = 205.0
@ -171,21 +172,20 @@ mouse_default_cursor_shape = 2
text = "Light"
[node name="Grid&Guides" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
visible = false
margin_top = 458.0
margin_top = 486.0
margin_right = 205.0
margin_bottom = 576.0
margin_bottom = 618.0
[node name="GridOptionsLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides"]
margin_right = 205.0
margin_bottom = 14.0
margin_bottom = 28.0
rect_min_size = Vector2( 0, 28 )
text = "Grid options"
[node name="GridOptions" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides"]
margin_top = 18.0
margin_top = 32.0
margin_right = 205.0
margin_bottom = 118.0
margin_bottom = 132.0
custom_constants/vseparation = 4
custom_constants/hseparation = 4
columns = 2
@ -247,6 +247,69 @@ margin_right = 156.0
margin_bottom = 100.0
rect_min_size = Vector2( 64, 20 )
color = Color( 0.63, 0.13, 0.94, 1 )
[node name="Image" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
margin_top = 486.0
margin_right = 205.0
margin_bottom = 618.0
[node name="ImageOptionsLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image"]
margin_right = 205.0
margin_bottom = 28.0
rect_min_size = Vector2( 0, 28 )
text = "Image Options"
[node name="ImageOptions" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image"]
margin_top = 32.0
margin_right = 205.0
margin_bottom = 132.0
custom_constants/vseparation = 4
custom_constants/hseparation = 4
columns = 2
[node name="DefaultWidthLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions"]
margin_top = 5.0
margin_right = 92.0
margin_bottom = 19.0
text = "Default Width:"
[node name="ImageDefaultWidth" type="SpinBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions"]
margin_left = 82.0
margin_right = 156.0
margin_bottom = 24.0
min_value = 1.0
max_value = 16384.0
value = 32.0
suffix = "px"
[node name="DefaultHeightLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions"]
margin_top = 5.0
margin_right = 96.0
margin_bottom = 19.0
text = "Default Height:"
[node name="ImageDefaultHeight" type="SpinBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions"]
margin_left = 82.0
margin_right = 156.0
margin_bottom = 24.0
min_value = 1.0
max_value = 16384.0
value = 32.0
suffix = "px"
[node name="DefaultFillColorLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions"]
margin_top = 5.0
margin_right = 96.0
margin_bottom = 19.0
text = "Default Fill Color:"
[node name="DefaultFillColor" type="ColorPickerButton" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions"]
margin_left = 82.0
margin_top = 56.0
margin_right = 156.0
margin_bottom = 76.0
rect_min_size = Vector2( 64, 20 )
color = Color( 0, 0, 0, 0 )
[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="item_selected" from="HSplitContainer/Tree" to="." method="_on_Tree_item_selected"]
@ -254,3 +317,6 @@ color = Color( 0.63, 0.13, 0.94, 1 )
[connection signal="value_changed" from="HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridHeightValue" to="." method="_on_GridHeightValue_value_changed"]
[connection signal="color_changed" from="HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridColor" to="." method="_on_GridColor_color_changed"]
[connection signal="color_changed" from="HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GuideColor" to="." method="_on_GuideColor_color_changed"]
[connection signal="value_changed" from="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/ImageDefaultWidth" to="." method="_on_ImageDefaultWidth_value_changed"]
[connection signal="value_changed" from="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/ImageDefaultHeight" to="." method="_on_ImageDefaultHeight_value_changed"]
[connection signal="color_changed" from="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/DefaultFillColor" to="." method="_on_DefaultBackground_color_changed"]

View file

@ -5,6 +5,7 @@ var layers := []
var current_layer_index := 0
var location := Vector2.ZERO
var size := Vector2(64, 64)
var fill_color := Color(0, 0, 0, 0)
var frame := 0 setget frame_changed
var frame_button : VBoxContainer
var frame_texture_rect : TextureRect
@ -32,7 +33,17 @@ func _ready() -> void:
# The sprite itself
if layers.empty():
var sprite := Image.new()
if Global.is_default_image:
if Global.config_cache.has_section_key("preferences", "default_width"):
size.x = Global.config_cache.get_value("preferences", "default_width")
if Global.config_cache.has_section_key("preferences", "default_height"):
size.y = Global.config_cache.get_value("preferences", "default_height")
if Global.config_cache.has_section_key("preferences", "default_fill_color"):
fill_color = Global.config_cache.get_value("preferences", "default_fill_color")
Global.is_default_image = !Global.is_default_image
sprite.create(size.x, size.y, false, Image.FORMAT_RGBA8)
sprite.fill(fill_color)
sprite.lock()
var tex := ImageTexture.new()

View file

@ -1,9 +1,13 @@
extends ConfirmationDialog
onready var width_value = $VBoxContainer/OptionsContainer/WidthValue
onready var height_value = $VBoxContainer/OptionsContainer/HeightValue
onready var fill_color_node = $VBoxContainer/OptionsContainer/FillColor
func _on_CreateNewImage_confirmed() -> void:
var width : int = $VBoxContainer/OptionsContainer/WidthValue.value
var height : int = $VBoxContainer/OptionsContainer/HeightValue.value
var fill_color : Color = $VBoxContainer/OptionsContainer/FillColor.color
var width : int = width_value.value
var height : int = height_value.value
var fill_color : Color = fill_color_node.color
Global.control.clear_canvases()
Global.canvas = load("res://Prefabs/Canvas.tscn").instance()
Global.canvas.size = Vector2(width, height).floor()
@ -15,3 +19,8 @@ func _on_CreateNewImage_confirmed() -> void:
Global.canvas.layers[0][0].fill(fill_color)
Global.canvas.layers[0][0].lock()
Global.canvas.update_texture(0)
func _on_CreateNewImage_about_to_show() -> void:
width_value.value = Global.default_image_width
height_value.value = Global.default_image_height
fill_color_node.color = Global.default_fill_color

View file

@ -5,6 +5,11 @@ onready var right_side : VBoxContainer = $HSplitContainer/ScrollContainer/VBoxCo
onready var languages = $HSplitContainer/ScrollContainer/VBoxContainer/Languages
onready var themes = $HSplitContainer/ScrollContainer/VBoxContainer/Themes
onready var grid_guides = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides"
onready var image = $HSplitContainer/ScrollContainer/VBoxContainer/Image
onready var default_width_value = $HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/ImageDefaultWidth
onready var default_height_value = $HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/ImageDefaultHeight
onready var default_fill_color = $HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions/DefaultFillColor
onready var grid_width_value = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridWidthValue"
onready var grid_height_value = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridHeightValue"
@ -28,7 +33,6 @@ func _ready() -> void:
change_theme(0)
themes.get_child(1).pressed = true
# Set default values for Grid & Guide options
if Global.config_cache.has_section_key("preferences", "grid_size"):
var grid_size = Global.config_cache.get_value("preferences", "grid_size")
@ -49,11 +53,28 @@ func _ready() -> void:
guide.default_color = Global.guide_color
guide_color.color = Global.guide_color
# Set default values for Image
if Global.config_cache.has_section_key("preferences", "default_width"):
var default_width = Global.config_cache.get_value("preferences", "default_width")
Global.default_image_width = int(default_width)
default_width_value.value = Global.default_image_width
if Global.config_cache.has_section_key("preferences", "default_height"):
var default_height = Global.config_cache.get_value("preferences", "default_height")
Global.default_image_height = int(default_height)
default_height_value.value = Global.default_image_height
if Global.config_cache.has_section_key("preferences", "default_fill_color"):
var fill_color = Global.config_cache.get_value("preferences", "default_fill_color")
Global.default_fill_color = fill_color
default_fill_color.color = Global.default_fill_color
func _on_PreferencesDialog_about_to_show() -> void:
var root := tree.create_item()
var language_button := tree.create_item(root)
var theme_button := tree.create_item(root)
var grid_button := tree.create_item(root)
var image_button := tree.create_item(root)
language_button.set_text(0, " " + tr("Language"))
# We use metadata to avoid being affected by translations
@ -63,6 +84,8 @@ func _on_PreferencesDialog_about_to_show() -> void:
theme_button.set_metadata(0, "Themes")
grid_button.set_text(0, " " + tr("Guides & Grid"))
grid_button.set_metadata(0, "Guides & Grid")
image_button.set_text(0, " " + tr("Image"))
image_button.set_metadata(0, "Image")
func _on_PreferencesDialog_popup_hide() -> void:
@ -78,6 +101,8 @@ func _on_Tree_item_selected() -> void:
themes.visible = true
elif "Guides & Grid" in selected:
grid_guides.visible = true
elif "Image" in selected:
image.visible = true
func _on_Language_pressed(button : Button) -> void:
var index := 0
@ -222,3 +247,19 @@ func _on_GuideColor_color_changed(color : Color) -> void:
guide.default_color = color
Global.config_cache.set_value("preferences", "guide_color", color)
Global.config_cache.save("user://cache.ini")
func _on_ImageDefaultWidth_value_changed(value: float) -> void:
Global.default_image_width = value
Global.config_cache.set_value("preferences", "default_width", value)
Global.config_cache.save("user://cache.ini")
func _on_ImageDefaultHeight_value_changed(value: float) -> void:
Global.default_image_height = value
Global.config_cache.set_value("preferences", "default_height", value)
Global.config_cache.save("user://cache.ini")
func _on_DefaultBackground_color_changed(color: Color) -> void:
Global.default_fill_color = color
Global.config_cache.set_value("preferences", "default_fill_color", color)
Global.config_cache.save("user://cache.ini")

View file

@ -24,6 +24,14 @@ var image_clipboard : Image
# warning-ignore:unused_class_variable
var theme_type := "Dark"
# warning-ignore:unused_class_variable
var is_default_image := true
# warning-ignore:unused_class_variable
var default_image_width := 32
# warning-ignore:unused_class_variable
var default_image_height := 32
# warning-ignore:unused_class_variable
var default_fill_color := Color(0, 0, 0, 0)
# warning-ignore:unused_class_variable
var grid_width := 1
# warning-ignore:unused_class_variable
var grid_height := 1

View file

@ -654,3 +654,15 @@ msgstr ""
msgid "Take this spot!"
msgstr ""
msgid "Image Options"
msgstr ""
msgid "Default Width:"
msgstr ""
msgid "Default Height:"
msgstr ""
msgid "Default Fill Color:"
msgstr ""

View file

@ -739,3 +739,15 @@ msgstr ""
#~ "Geteilter Bildschirm\n"
#~ "\n"
#~ "Verstecke zweite Leinwand"
msgid "Image Options"
msgstr ""
msgid "Default Width:"
msgstr ""
msgid "Default Height:"
msgstr ""
msgid "Default Fill Color:"
msgstr ""

View file

@ -736,3 +736,15 @@ msgstr "Πάρτε αυτή τη θέση!"
#~ "Διπλή οθόνη\n"
#~ "\n"
#~ "Απόκρυψη δεύτερου καμβάf"
msgid "Image Options"
msgstr "Επιλογές εικόνας"
msgid "Default Width:"
msgstr "Προεπιλεγμένο πλάτος:"
msgid "Default Height:"
msgstr "Προεπιλεγμένο ύψος:"
msgid "Default Fill Color:"
msgstr "Προεπιλεγμένο γέμισμα με χρώμα:"

View file

@ -727,3 +727,15 @@ msgstr "Take this spot!"
#~ "Split screen\n"
#~ "\n"
#~ "Hide second canvas"
msgid "Image Options"
msgstr "Image Options"
msgid "Default Width:"
msgstr "Default Width:"
msgid "Default Height:"
msgstr "Default Height:"
msgid "Default Fill Color:"
msgstr "Default Fill Color:"

View file

@ -754,3 +754,15 @@ msgstr ""
#~ "Écran partagé\n"
#~ "\n"
#~ "Cacher le second canevas"
msgid "Image Options"
msgstr ""
msgid "Default Width:"
msgstr ""
msgid "Default Height:"
msgstr ""
msgid "Default Fill Color:"
msgstr ""

View file

@ -734,3 +734,15 @@ msgstr "Prendi questo posto!"
#~ "Dividi lo schermo\n"
#~ "\n"
#~ "Nascondi il secondo canvas"
msgid "Image Options"
msgstr "Opzioni dell'immagine:"
msgid "Default Width:"
msgstr "Larghezza default:"
msgid "Default Height:"
msgstr "Altezza default:"
msgid "Default Fill Color:"
msgstr "Riempimento default:"

View file

@ -743,3 +743,15 @@ msgstr ""
#~ "Podzielenie ekranu\n"
#~ "\n"
#~ "Ukrywa drugie płótno"
msgid "Image Options"
msgstr ""
msgid "Default Width:"
msgstr ""
msgid "Default Height:"
msgstr ""
msgid "Default Fill Color:"
msgstr ""

View file

@ -720,3 +720,15 @@ msgstr "Não mostrar de novo"
msgid "Take this spot!"
msgstr "Peque este lugar!"
msgid "Image Options"
msgstr ""
msgid "Default Width:"
msgstr ""
msgid "Default Height:"
msgstr ""
msgid "Default Fill Color:"
msgstr ""

View file

@ -742,3 +742,15 @@ msgstr ""
#~ "Разделить экран\n"
#~ "\n"
#~ "Скрыть второй холст"
msgid "Image Options"
msgstr ""
msgid "Default Width:"
msgstr ""
msgid "Default Height:"
msgstr ""
msgid "Default Fill Color:"
msgstr ""

View file

@ -729,3 +729,15 @@ msgstr ""
#~ "分裂畫面\n"
#~ "\n"
#~ "顯示一張畫布"
msgid "Image Options"
msgstr ""
msgid "Default Width:"
msgstr ""
msgid "Default Height:"
msgstr ""
msgid "Default Fill Color:"
msgstr ""