-
-
Notifications
You must be signed in to change notification settings - Fork 473
Expand file tree
/
Copy pathResourceProject.gd
More file actions
31 lines (26 loc) · 1.17 KB
/
ResourceProject.gd
File metadata and controls
31 lines (26 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class_name ResourceProject
extends Project
## A class for easily editing individual project sub-resources like tiles, index maps, etc.
##
## The [ResourceProject] is basically a [Project], except that it doesn't get saved physically
## (as a .pxo file), instead, a [signal resource_updated] signal is emitted which can
## be used to update the resource in the [Project].[br]
## Emitted when the [ResourceProject] is saved.
@warning_ignore("unused_signal")
signal resource_updated(project: Project)
func _init(_frames: Array[Frame] = [], _name := tr("untitled"), _size := Vector2i(64, 64)) -> void:
super._init(_frames, _name + " (Virtual Resource)", _size)
## Returns the full image of the [Frame] at [param frame_idx] in resource project.
func get_frame_image(frame_idx: int) -> Image:
var frame_image := Image.create_empty(size.x, size.y, false, Image.FORMAT_RGBA8)
if frame_idx >= 0 and frame_idx < frames.size():
var frame := frames[frame_idx]
DrawingAlgos.blend_layers(frame_image, frame, Vector2i.ZERO, self)
else:
printerr(
(
"frame index: %s not found in ResourceProject, frames.size(): %s"
% [str(frame_idx), str(frames.size())]
)
)
return frame_image