diff --git a/Prefabs/Dialogs/CreateNewImage.tscn b/Prefabs/Dialogs/CreateNewImage.tscn index b2fac11bf..7fb1bba8f 100644 --- a/Prefabs/Dialogs/CreateNewImage.tscn +++ b/Prefabs/Dialogs/CreateNewImage.tscn @@ -3,6 +3,7 @@ [ext_resource path="res://Scripts/Dialogs/CreateNewImage.gd" type="Script" id=1] [node name="CreateNewImage" type="ConfirmationDialog"] +visible = true margin_right = 205.0 margin_bottom = 200.0 rect_min_size = Vector2( 250, 200 ) @@ -47,10 +48,11 @@ text = "Templates:" [node name="TemplatesOptions" type="OptionButton" parent="VBoxContainer/OptionsContainer"] margin_left = 114.0 -margin_right = 188.0 +margin_right = 189.0 margin_bottom = 20.0 toggle_mode = false -items = [ "Default", null, false, 0, null, "16x16", null, false, 1, null, "32x32", null, false, 2, null, "64x64", null, false, 3, null, "128x128", null, false, 4, null ] +text = "Default" +items = [ "Default", null, false, 0, null ] selected = 0 [node name="RatioLabel" type="Label" parent="VBoxContainer/OptionsContainer"] @@ -62,7 +64,7 @@ text = "Lock aspect ratio:" [node name="RatioCheckBox" type="CheckBox" parent="VBoxContainer/OptionsContainer"] margin_left = 114.0 margin_top = 24.0 -margin_right = 188.0 +margin_right = 189.0 margin_bottom = 48.0 __meta__ = { "_edit_use_anchors_": false @@ -77,7 +79,7 @@ text = "Width:" [node name="WidthValue" type="SpinBox" parent="VBoxContainer/OptionsContainer"] margin_left = 114.0 margin_top = 52.0 -margin_right = 188.0 +margin_right = 189.0 margin_bottom = 76.0 mouse_default_cursor_shape = 2 min_value = 1.0 @@ -94,7 +96,7 @@ text = "Height:" [node name="HeightValue" type="SpinBox" parent="VBoxContainer/OptionsContainer"] margin_left = 114.0 margin_top = 80.0 -margin_right = 188.0 +margin_right = 189.0 margin_bottom = 104.0 mouse_default_cursor_shape = 2 min_value = 1.0 @@ -111,7 +113,7 @@ text = "Fill with color:" [node name="FillColor" type="ColorPickerButton" parent="VBoxContainer/OptionsContainer"] margin_left = 114.0 margin_top = 108.0 -margin_right = 188.0 +margin_right = 189.0 margin_bottom = 128.0 rect_min_size = Vector2( 64, 20 ) color = Color( 0, 0, 0, 0 ) diff --git a/Scripts/Dialogs/CreateNewImage.gd b/Scripts/Dialogs/CreateNewImage.gd index 083496a3a..ef26b4b36 100644 --- a/Scripts/Dialogs/CreateNewImage.gd +++ b/Scripts/Dialogs/CreateNewImage.gd @@ -6,6 +6,8 @@ onready var width_value = $VBoxContainer/OptionsContainer/WidthValue onready var height_value = $VBoxContainer/OptionsContainer/HeightValue onready var fill_color_node = $VBoxContainer/OptionsContainer/FillColor +onready var size_value = Vector2() + #Template Id identifier enum Templates { TDefault = 0, @@ -13,18 +15,55 @@ enum Templates { T32 = 2, T64 = 3, T128 = 4, + GB = 5, + GBA = 6, + NES_NTSC = 7, + NES_PAL = 8, + SNES_NTSC = 9, + SNES_PAL = 10 } #Template actual value, without Default because we get it from Global -enum TValues { - T16 = 16, - T32 = 32, - T64 = 64, - T128 = 128, +var TResolutions = { + Templates.T16: Vector2(16,16), + Templates.T32: Vector2(32,32), + Templates.T64: Vector2(64,64), + Templates.T128: Vector2(128,128), + + Templates.GB: Vector2(160,144), + Templates.GBA: Vector2(240,160), + Templates.NES_NTSC: Vector2(256,224), + Templates.NES_PAL: Vector2(256,240), + Templates.SNES_NTSC: Vector2(512,448), + Templates.SNES_PAL: Vector2(512,480), } +var TStrings ={ + Templates.T16: "", + Templates.T32: "", + Templates.T64: "", + Templates.T128: "", + + Templates.GB: "GB", + Templates.GBA: "GBA", + Templates.NES_NTSC: "NES (NTSC)", + Templates.NES_PAL: "NES (PAL)", + Templates.SNES_NTSC: "SNES (NTSC)", + Templates.SNES_PAL: "SNES (PAL)" + } + func _ready() -> void: ratio_box.connect("pressed", self, "_on_RatioCheckBox_toggled", [ratio_box.pressed]) templates_options.connect("item_selected", self, "_on_TemplatesOptions_item_selected") + + _CreateOptionList() + +func _CreateOptionList(): + for i in Templates.values(): + if i > 0: + if TStrings[i] != "": + templates_options.add_item("{width}x{height} - {name}".format({"width":TResolutions[i].x, "height":TResolutions[i].y, "name":TStrings[i]}), i) + else: + templates_options.add_item("{width}x{height}".format({"width":TResolutions[i].x, "height":TResolutions[i].y}), i) func _on_CreateNewImage_confirmed() -> void: var width : int = width_value.value @@ -78,19 +117,11 @@ func _on_SizeValue_value_changed(value: float) -> void: width_value.value = height_value.value * aspect_ratio func _on_TemplatesOptions_item_selected(id: int) -> void: - match id: - Templates.TDefault: - width_value.value = Global.default_image_width - height_value.value = Global.default_image_height - Templates.T16: - width_value.value = TValues.T16 - height_value.value = TValues.T16 - Templates.T32: - width_value.value = TValues.T32 - height_value.value = TValues.T32 - Templates.T64: - width_value.value = TValues.T64 - height_value.value = TValues.T64 - Templates.T128: - width_value.value = TValues.T128 - height_value.value = TValues.T128 + if id != Templates.TDefault: + size_value = TResolutions[id] + else: + width_value.value = Global.default_image_width + height_value.value = Global.default_image_height + + width_value.value = size_value.x + height_value.value = size_value.y