Skip to content
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

Merged
merged 17 commits into from
Feb 7, 2021
Merged

"SpriteSheet as layer" and "Replace Frame" import options #453

merged 17 commits into from
Feb 7, 2021

Conversation

Variable-ind
Copy link
Contributor

@Variable-ind Variable-ind commented Feb 5, 2021

This will allow us to use "SpriteSheet as layer" and "Replace Frame" import options in pixelorama

Maintainer edit: This implements #448.

Refactored CreateNewImage dialog and added portrait & landscape butto…
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)
Copy link
Member

@OverloadedOrama OverloadedOrama left a 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 :)

Comment on lines 404 to 415
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))
Copy link
Member

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.

Copy link
Contributor Author

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)

Copy link
Member

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.

Copy link
Contributor Author

@Variable-ind Variable-ind Feb 6, 2021

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

Comment on lines 30 to 48
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")
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, fixed it

Copy link
Member

@OverloadedOrama OverloadedOrama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@OverloadedOrama OverloadedOrama merged commit f9c275d into Orama-Interactive:master Feb 7, 2021
@Variable-ind Variable-ind deleted the SpriteSheet_as_layer branch February 10, 2021 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants