2019-12-29 22:24:37 +00:00
|
|
|
|
extends ConfirmationDialog
|
|
|
|
|
|
2021-01-25 20:07:02 +00:00
|
|
|
|
|
|
|
|
|
class Template:
|
|
|
|
|
var resolution : Vector2
|
|
|
|
|
var name : String
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init(_resolution : Vector2, _name := "") -> void:
|
|
|
|
|
resolution = _resolution
|
|
|
|
|
name = _name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var aspect_ratio := 1.0
|
|
|
|
|
var templates := [
|
2021-02-05 11:05:08 +00:00
|
|
|
|
# Basic
|
2021-01-25 20:07:02 +00:00
|
|
|
|
Template.new(Vector2(16, 16)),
|
|
|
|
|
Template.new(Vector2(32, 32)),
|
|
|
|
|
Template.new(Vector2(64, 64)),
|
|
|
|
|
Template.new(Vector2(128, 128)),
|
2021-03-15 01:41:02 +00:00
|
|
|
|
|
2021-02-05 11:05:08 +00:00
|
|
|
|
# Nintendo
|
2021-01-25 20:07:02 +00:00
|
|
|
|
Template.new(Vector2(160, 144), "GB"),
|
|
|
|
|
Template.new(Vector2(240, 160), "GBA"),
|
|
|
|
|
Template.new(Vector2(256, 224), "NES (NTSC)"),
|
|
|
|
|
Template.new(Vector2(256, 240), "NES (PAL)"),
|
|
|
|
|
Template.new(Vector2(512, 448), "SNES (NTSC)"),
|
|
|
|
|
Template.new(Vector2(512, 480), "SNES (PAL)"),
|
2021-02-05 11:05:08 +00:00
|
|
|
|
Template.new(Vector2(646, 486), "N64 (NTSC)"),
|
|
|
|
|
Template.new(Vector2(786, 576), "N64 (PAL)"),
|
2021-03-15 01:41:02 +00:00
|
|
|
|
|
2021-02-05 11:05:08 +00:00
|
|
|
|
# Sega
|
|
|
|
|
Template.new(Vector2(256, 192), "SMS (NTSC)"),
|
|
|
|
|
Template.new(Vector2(256, 224), "SMS (PAL)"),
|
|
|
|
|
Template.new(Vector2(160, 144), "GG"),
|
|
|
|
|
Template.new(Vector2(320, 224), "MD (NTSC)"),
|
|
|
|
|
Template.new(Vector2(320, 240), "MD (PAL)"),
|
2021-03-15 01:41:02 +00:00
|
|
|
|
|
2021-02-05 11:05:08 +00:00
|
|
|
|
# NEC
|
|
|
|
|
Template.new(Vector2(256, 239), "PC Engine"), #256×224 to 512×242 (mostly 256×239)
|
2021-03-15 01:41:02 +00:00
|
|
|
|
|
2021-02-05 11:05:08 +00:00
|
|
|
|
# DOS
|
|
|
|
|
Template.new(Vector2(320, 200), "DOS EGA"),
|
|
|
|
|
Template.new(Vector2(320, 200), "DOS VGA"),
|
|
|
|
|
Template.new(Vector2(620, 480), "DOS SVGA"),
|
|
|
|
|
Template.new(Vector2(640, 200), "DOS CGA (2-Colour)"),
|
|
|
|
|
Template.new(Vector2(320, 200), "DOS CGA (4-Colour)"),
|
|
|
|
|
Template.new(Vector2(160, 240), "DOS CGA (Composite)"),
|
|
|
|
|
Template.new(Vector2(160, 240), "Tandy"),
|
2021-03-15 01:41:02 +00:00
|
|
|
|
|
2021-02-05 11:05:08 +00:00
|
|
|
|
# Commodore
|
|
|
|
|
Template.new(Vector2(320, 200), "Amiga OCS LowRes (NTSC)"),
|
|
|
|
|
Template.new(Vector2(320, 256), "Amiga OCS LowRes (PAL)"),
|
|
|
|
|
Template.new(Vector2(640, 200), "Amiga OCS HiRes (NTSC)"),
|
|
|
|
|
Template.new(Vector2(640, 256), "Amiga OCS HiRes (PAL)"),
|
|
|
|
|
Template.new(Vector2(1280, 200), "Amiga ECS Super-HiRes (NTSC)"),
|
|
|
|
|
Template.new(Vector2(1280, 256), "Amiga ECS SuperHiRes (PAL)"),
|
|
|
|
|
Template.new(Vector2(640, 480), "Amiga ECS Multiscan"),
|
|
|
|
|
Template.new(Vector2(320, 200), "C64"),
|
2021-03-15 01:41:02 +00:00
|
|
|
|
|
2021-02-05 11:05:08 +00:00
|
|
|
|
# Sinclair
|
|
|
|
|
Template.new(Vector2(256, 192), "ZX Spectrum"),
|
2021-01-25 20:07:02 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
onready var templates_options = find_node("TemplatesOptions")
|
|
|
|
|
onready var ratio_box = find_node("AspectRatioButton")
|
|
|
|
|
onready var width_value = find_node("WidthValue")
|
|
|
|
|
onready var height_value = find_node("HeightValue")
|
|
|
|
|
onready var portrait_button = find_node("PortraitButton")
|
|
|
|
|
onready var landscape_button = find_node("LandscapeButton")
|
|
|
|
|
onready var fill_color_node = find_node("FillColor")
|
2020-04-10 18:19:44 +00:00
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
|
2020-04-03 00:12:42 +00:00
|
|
|
|
func _ready() -> void:
|
2020-07-15 00:25:59 +00:00
|
|
|
|
width_value.value = Global.default_image_width
|
|
|
|
|
height_value.value = Global.default_image_height
|
2021-01-25 20:07:02 +00:00
|
|
|
|
aspect_ratio = width_value.value / height_value.value
|
2020-07-15 00:25:59 +00:00
|
|
|
|
fill_color_node.color = Global.default_fill_color
|
2020-05-06 17:24:22 +00:00
|
|
|
|
fill_color_node.get_picker().presets_visible = false
|
2020-07-15 00:25:59 +00:00
|
|
|
|
|
2021-01-25 20:07:02 +00:00
|
|
|
|
_create_option_list()
|
2020-04-11 02:36:51 +00:00
|
|
|
|
|
2020-04-10 18:19:44 +00:00
|
|
|
|
|
2021-01-25 20:07:02 +00:00
|
|
|
|
func _create_option_list() -> void:
|
|
|
|
|
var i := 1
|
|
|
|
|
for template in templates:
|
|
|
|
|
if template.name != "":
|
|
|
|
|
templates_options.add_item("{width}x{height} - {name}".format({"width":template.resolution.x, "height":template.resolution.y, "name":template.name}), i)
|
|
|
|
|
else:
|
|
|
|
|
templates_options.add_item("{width}x{height}".format({"width":template.resolution.x, "height":template.resolution.y}), i)
|
2020-05-01 17:47:10 +00:00
|
|
|
|
|
2021-01-25 20:07:02 +00:00
|
|
|
|
i += 1
|
2020-04-03 00:25:56 +00:00
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
|
2019-12-29 22:24:37 +00:00
|
|
|
|
func _on_CreateNewImage_confirmed() -> void:
|
2020-01-10 22:11:36 +00:00
|
|
|
|
var width : int = width_value.value
|
|
|
|
|
var height : int = height_value.value
|
|
|
|
|
var fill_color : Color = fill_color_node.color
|
2020-06-09 16:02:09 +00:00
|
|
|
|
Global.canvas.fill_color = fill_color
|
2020-06-05 01:30:50 +00:00
|
|
|
|
|
2020-06-09 15:44:08 +00:00
|
|
|
|
var frame : Frame = Global.canvas.new_empty_frame(false, true, Vector2(width, height))
|
2021-05-24 14:03:56 +00:00
|
|
|
|
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())
|
2020-06-05 15:54:11 +00:00
|
|
|
|
new_project.layers.append(Layer.new())
|
|
|
|
|
Global.projects.append(new_project)
|
2020-06-05 01:30:50 +00:00
|
|
|
|
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
|
2020-06-02 23:14:24 +00:00
|
|
|
|
Global.canvas.camera_zoom()
|
2019-12-29 22:24:37 +00:00
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
|
2021-01-25 20:07:02 +00:00
|
|
|
|
func _on_AspectRatioButton_toggled(_button_pressed : bool) -> void:
|
2020-04-03 00:12:42 +00:00
|
|
|
|
aspect_ratio = width_value.value / height_value.value
|
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
|
2020-04-03 00:12:42 +00:00
|
|
|
|
func _on_SizeValue_value_changed(value: float) -> void:
|
2021-01-25 20:07:02 +00:00
|
|
|
|
if ratio_box.pressed:
|
|
|
|
|
if width_value.value == value:
|
|
|
|
|
height_value.value = width_value.value / aspect_ratio
|
|
|
|
|
if height_value.value == value:
|
|
|
|
|
width_value.value = height_value.value * aspect_ratio
|
|
|
|
|
|
|
|
|
|
toggle_size_buttons()
|
2020-04-03 00:12:42 +00:00
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
|
2021-01-25 20:07:02 +00:00
|
|
|
|
func toggle_size_buttons() -> void:
|
|
|
|
|
portrait_button.disconnect("toggled", self, "_on_PortraitButton_toggled")
|
|
|
|
|
landscape_button.disconnect("toggled", self, "_on_LandscapeButton_toggled")
|
|
|
|
|
portrait_button.pressed = width_value.value < height_value.value
|
|
|
|
|
landscape_button.pressed = width_value.value > height_value.value
|
|
|
|
|
|
|
|
|
|
portrait_button.connect("toggled", self, "_on_PortraitButton_toggled")
|
|
|
|
|
landscape_button.connect("toggled", self, "_on_LandscapeButton_toggled")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_TemplatesOptions_item_selected(id : int) -> void:
|
2021-05-24 14:03:56 +00:00
|
|
|
|
#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
|
|
|
|
|
|
2021-01-25 20:07:02 +00:00
|
|
|
|
if id > 0:
|
|
|
|
|
width_value.value = templates[id - 1].resolution.x
|
|
|
|
|
height_value.value = templates[id - 1].resolution.y
|
2020-04-10 18:19:44 +00:00
|
|
|
|
else:
|
|
|
|
|
width_value.value = Global.default_image_width
|
|
|
|
|
height_value.value = Global.default_image_height
|
2021-05-24 14:03:56 +00:00
|
|
|
|
|
|
|
|
|
if temporary_release:
|
|
|
|
|
ratio_box.pressed = true
|
2020-04-11 02:36:51 +00:00
|
|
|
|
|
2021-01-25 20:07:02 +00:00
|
|
|
|
|
|
|
|
|
func _on_PortraitButton_toggled(button_pressed : bool) -> void:
|
|
|
|
|
if !button_pressed or height_value.value > width_value.value:
|
|
|
|
|
toggle_size_buttons()
|
|
|
|
|
return
|
|
|
|
|
switch_width_height()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_LandscapeButton_toggled(button_pressed : bool) -> void:
|
|
|
|
|
if !button_pressed or width_value.value > height_value.value:
|
|
|
|
|
toggle_size_buttons()
|
|
|
|
|
return
|
|
|
|
|
switch_width_height()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func switch_width_height() -> void:
|
|
|
|
|
width_value.disconnect("value_changed", self, "_on_SizeValue_value_changed")
|
|
|
|
|
height_value.disconnect("value_changed", self, "_on_SizeValue_value_changed")
|
|
|
|
|
|
|
|
|
|
var height = height_value.value
|
|
|
|
|
height_value.value = width_value.value
|
|
|
|
|
width_value.value = height
|
|
|
|
|
toggle_size_buttons()
|
|
|
|
|
|
|
|
|
|
width_value.connect("value_changed", self, "_on_SizeValue_value_changed")
|
|
|
|
|
height_value.connect("value_changed", self, "_on_SizeValue_value_changed")
|