mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Move new_empty_frame() to Project.gd from Canvas.gd
This commit also changes the behavior of the fill color. The new cels now only get filled with the Project.fill_color if they are on the bottom layer.
This commit is contained in:
parent
4c60ef144f
commit
f70efe3076
|
@ -44,8 +44,8 @@ var icon_color_from: int = IconColorFrom.THEME
|
|||
var custom_icon_color := Color.gray
|
||||
var tool_button_size: int = ButtonSize.SMALL
|
||||
|
||||
var default_image_width := 64
|
||||
var default_image_height := 64
|
||||
var default_width := 64
|
||||
var default_height := 64
|
||||
var default_fill_color := Color(0, 0, 0, 0)
|
||||
var grid_type = GridTypes.CARTESIAN
|
||||
var grid_width := 2
|
||||
|
@ -179,20 +179,19 @@ func _ready() -> void:
|
|||
|
||||
panel_layout = config_cache.get_value("window", "panel_layout", PanelLayout.AUTO)
|
||||
|
||||
default_image_width = config_cache.get_value(
|
||||
"preferences", "default_image_width", default_image_width
|
||||
)
|
||||
default_image_height = config_cache.get_value(
|
||||
"preferences", "default_image_height", default_image_height
|
||||
)
|
||||
default_width = config_cache.get_value("preferences", "default_width", default_width)
|
||||
default_height = config_cache.get_value("preferences", "default_height", default_height)
|
||||
default_fill_color = config_cache.get_value(
|
||||
"preferences", "default_fill_color", default_fill_color
|
||||
)
|
||||
var proj_size := Vector2(default_image_width, default_image_height)
|
||||
var proj_size := Vector2(default_width, default_height)
|
||||
projects.append(Project.new([], tr("untitled"), proj_size))
|
||||
projects[0].layers.append(Layer.new())
|
||||
projects[0].fill_color = default_fill_color
|
||||
current_project = projects[0]
|
||||
current_project.layers.append(Layer.new())
|
||||
current_project.fill_color = default_fill_color
|
||||
var frame: Frame = current_project.new_empty_frame()
|
||||
current_project.frames.append(frame)
|
||||
|
||||
for node in get_tree().get_nodes_in_group("UIButtons"):
|
||||
var tooltip: String = node.hint_tooltip
|
||||
if !tooltip.empty() and node.shortcut:
|
||||
|
|
|
@ -101,6 +101,20 @@ func commit_redo() -> void:
|
|||
Global.control.redone = false
|
||||
|
||||
|
||||
func new_empty_frame() -> Frame:
|
||||
var frame := Frame.new()
|
||||
var bottom_layer := true
|
||||
for l in layers: # Create as many cels as there are layers
|
||||
var image := Image.new()
|
||||
image.create(size.x, size.y, false, Image.FORMAT_RGBA8)
|
||||
if bottom_layer:
|
||||
image.fill(fill_color)
|
||||
frame.cels.append(Cel.new(image, 1))
|
||||
bottom_layer = false
|
||||
|
||||
return frame
|
||||
|
||||
|
||||
func selection_bitmap_changed() -> void:
|
||||
var image := Image.new()
|
||||
var image_texture := ImageTexture.new()
|
||||
|
|
|
@ -70,18 +70,8 @@ var preferences = [
|
|||
"pressed",
|
||||
Global.enable_autosave
|
||||
],
|
||||
[
|
||||
"default_image_width",
|
||||
"Image/ImageOptions/ImageDefaultWidth",
|
||||
"value",
|
||||
Global.default_image_width
|
||||
],
|
||||
[
|
||||
"default_image_height",
|
||||
"Image/ImageOptions/ImageDefaultHeight",
|
||||
"value",
|
||||
Global.default_image_height
|
||||
],
|
||||
["default_width", "Image/ImageOptions/ImageDefaultWidth", "value", Global.default_width],
|
||||
["default_height", "Image/ImageOptions/ImageDefaultHeight", "value", Global.default_height],
|
||||
[
|
||||
"default_fill_color",
|
||||
"Image/ImageOptions/DefaultFillColor",
|
||||
|
|
|
@ -20,9 +20,6 @@ func _ready() -> void:
|
|||
$OnionPast.blue_red_color = Color.blue
|
||||
$OnionFuture.type = $OnionFuture.FUTURE
|
||||
$OnionFuture.blue_red_color = Color.red
|
||||
var project: Project = Global.current_project
|
||||
var frame: Frame = new_empty_frame(project.fill_color, project.size)
|
||||
project.frames.append(frame)
|
||||
yield(get_tree(), "idle_frame")
|
||||
camera_zoom()
|
||||
|
||||
|
@ -106,21 +103,6 @@ func camera_zoom() -> void:
|
|||
Global.transparent_checker.update_rect()
|
||||
|
||||
|
||||
func new_empty_frame(fill_color: Color, size: Vector2, single_layer := false) -> Frame:
|
||||
var frame := Frame.new()
|
||||
for l in Global.current_project.layers: # Create as many cels as there are layers
|
||||
# The sprite itself
|
||||
var sprite := Image.new()
|
||||
sprite.create(size.x, size.y, false, Image.FORMAT_RGBA8)
|
||||
sprite.fill(fill_color)
|
||||
frame.cels.append(Cel.new(sprite, 1))
|
||||
|
||||
if single_layer:
|
||||
break
|
||||
|
||||
return frame
|
||||
|
||||
|
||||
func update_texture(layer_i: int, frame_i := -1, project: Project = Global.current_project) -> void:
|
||||
if frame_i == -1:
|
||||
frame_i = project.current_frame
|
||||
|
|
|
@ -64,8 +64,8 @@ class Template:
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
width_value.value = Global.default_image_width
|
||||
height_value.value = Global.default_image_height
|
||||
width_value.value = Global.default_width
|
||||
height_value.value = Global.default_height
|
||||
aspect_ratio = width_value.value / height_value.value
|
||||
fill_color_node.color = Global.default_fill_color
|
||||
fill_color_node.get_picker().presets_visible = false
|
||||
|
@ -103,16 +103,15 @@ func _on_CreateNewImage_confirmed() -> void:
|
|||
var height: int = height_value.value
|
||||
var fill_color: Color = fill_color_node.color
|
||||
|
||||
var frame: Frame = Global.canvas.new_empty_frame(fill_color, Vector2(width, height), true)
|
||||
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())
|
||||
if !proj_name.is_valid_filename():
|
||||
proj_name = tr("untitled")
|
||||
|
||||
var new_project := Project.new([], proj_name, Vector2(width, height).floor())
|
||||
new_project.layers.append(Layer.new())
|
||||
new_project.fill_color = fill_color
|
||||
var frame: Frame = new_project.new_empty_frame()
|
||||
new_project.frames.append(frame)
|
||||
Global.projects.append(new_project)
|
||||
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
|
||||
Global.canvas.camera_zoom()
|
||||
|
@ -153,8 +152,8 @@ func _on_TemplatesOptions_item_selected(id: int) -> void:
|
|||
width_value.value = templates[id - 1].resolution.x
|
||||
height_value.value = templates[id - 1].resolution.y
|
||||
else:
|
||||
width_value.value = Global.default_image_width
|
||||
height_value.value = Global.default_image_height
|
||||
width_value.value = Global.default_width
|
||||
height_value.value = Global.default_height
|
||||
|
||||
if temporary_release:
|
||||
ratio_box.pressed = true
|
||||
|
|
|
@ -81,7 +81,7 @@ func cel_size_changed(value: int) -> void:
|
|||
|
||||
func add_frame() -> void:
|
||||
var project: Project = Global.current_project
|
||||
var frame: Frame = Global.canvas.new_empty_frame(project.fill_color, project.size)
|
||||
var frame: Frame = project.new_empty_frame()
|
||||
var new_frames: Array = project.frames.duplicate()
|
||||
var new_layers: Array = project.layers.duplicate()
|
||||
new_frames.insert(project.current_frame + 1, frame)
|
||||
|
|
Loading…
Reference in a new issue