-
-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"SpriteSheet as layer" and "Replace Frame" import options #453
"SpriteSheet as layer" and "Replace Frame" import options #453
Conversation
Refactored CreateNewImage dialog and added portrait & landscape butto…
update master
New Crowdin updates (#400)
It was originally made to use primarily in "Spritesheet (new layer)" but it thought it could also be useful to put it there as an import option
Now we can add SpriteSheets in current project and Replace frames in current project
I added functions that would allow me to add SpriteSheet as new Layer. I also added an option for "Replace frame" (the function "open_image_at_frame()" is originally being used in "open_image_as_spritesheet_layer()" method but i decided to use it as an import option as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be working well. The only issue I found is that if you switch between Spritesheet (new tab) and Spritesheet (new layer), is that the preview lines are not being updated. If you switch between new tab and new layer and you have different numbers of frames, the blue lines that separate the image are not getting updated.
I also left some comments in the code :)
src/Autoload/OpenSave.gd
Outdated
var image_no :int = 0 | ||
for yy in range(vertical): | ||
for xx in range(horizontal): | ||
var cropped_image := Image.new() | ||
cropped_image = image.get_rect(Rect2(frame_width * xx, frame_height * yy, frame_width, frame_height)) | ||
image_no += 1 | ||
if (start_frame + (image_no - 1)) < Global.current_project.frames.size(): | ||
# if frames are already present then fill those first | ||
if image_no == 1: | ||
open_image_as_new_layer(cropped_image, file_name, start_frame + image_no - 1) | ||
else: | ||
open_image_at_frame(cropped_image, Global.current_project.layers.size() - 1, start_frame + (image_no - 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick note, it looks like it would be better if image_no += 1
was placed at the end of the for loop. That way we could avoid all the image_no - 1
and just put image_no
instead. if image_no == 1
would have to be changed to if image_no == 0
of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i placed it here so we would have if image_no == 1 (Since it's the 1st image and not the 0th image)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having image_no == 0 would make more sense since in programming we're used to refer to the first item (in arrays, usually) with the number zero. We would also avoid doing unnecessary subtraction operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, it should work now
src/UI/Dialogs/PreviewDialog.gd
Outdated
for i in ImageImportOptions.size(): | ||
if i == ImageImportOptions.NEW_TAB: | ||
import_options.add_item("New tab") | ||
if i == ImageImportOptions.SPRITESHEET_TAB: | ||
import_options.add_item("Spritesheet (new tab)") | ||
if i == ImageImportOptions.SPRITESHEET_LAYER: | ||
import_options.add_item("Spritesheet (new layer)") | ||
if i == ImageImportOptions.NEW_FRAME: | ||
import_options.add_item("New frame") | ||
if i == ImageImportOptions.REPLACE_FRAME: | ||
import_options.add_item("Replace Frame") | ||
if i == ImageImportOptions.NEW_LAYER: | ||
import_options.add_item("New layer") | ||
if i == ImageImportOptions.PALETTE: | ||
import_options.add_item("New palette") | ||
if i == ImageImportOptions.BRUSH: | ||
import_options.add_item("New brush") | ||
if i == ImageImportOptions.PATTERN: | ||
import_options.add_item("New pattern") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why did you add the items here with code instead of in the node inside PreviewScene.tscn? Anyway, if we are to keep them here, the for loop and the if statements are not needed, simply using add_item()
will add all the items in order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added them here because there is a known issue about the "OptionButton" in godot that if we can only add new options at the end. if we want to add an option at a selected position, we would have to remove all items and add them again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay, good thinking. We should keep them there then, but we should remove the for loop and the if statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, fixed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you!
This will allow us to use "SpriteSheet as layer" and "Replace Frame" import options in pixelorama
Maintainer edit: This implements #448.