godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.15k stars 96 forks source link

"Select Frames" window should remember previous settings #7021

Open idbrii opened 1 year ago

idbrii commented 1 year ago

Describe the project you are working on

side scrolling platformer

Describe the problem or limitation you are having in your project

I have a sprite sheet with many animations in it: idle, walk, run, etc. To setup SpriteFrames, I need to create several animations and for each one, use "add frames from a file" to open the Select Frames window, set the sprite sheet slice settings (Horizontal/Vertical count, Separation, etc), select my frames, Add Frames.

The Select Frames window always opens with settings for 4x4 sprites on a sheet and 1:1 zoom.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It would really expedite this process if I only had to configure the sprite sheet slice settings once. Either:

The latter seems like excessive complexity when I could save my completed SpriteFrames as a resource, so I think saving the last settings would be enough.

Many games have multiple characters with the same pixel dimensions, so I suggest that the Size, Separation, and Offset values as well as Zoom level are the ones that are saved. These are most likely to be the same across several sprite sheets.

That would allow you to import multiple spritesheets and have a better starting point instead of always 4x4 sprites on a sheet. And when you have lots of tiny pixel art spritesheets, the zoom level will be large enough to actually see the art.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Every time you enter this window, it uses the same Size, Separation, Offset, Zoom settings as the last time you clicked "Add Frames" instead of using a single set of defaults:

image

These settings are saved to the .godot folder or only saved in memory. They are not part of the project.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I'm not sure how you could do this in script. A tool script that creates the SpriteFrames for you?

Is there a reason why this should be core and not an add-on in the asset library?

The "Select Frames" window is core already, so enhancements would need to be core too.

idbrii commented 1 year ago

For further clarity, these are the animframe instructions from the artist. The numbers are 0-indexed frames into the spritesheet.

DashRight: 8 DashLeft: 9 Item: 10 Sleep: 32,33,34,35 attack: 40 fishing: 28,29 fishingPull: 30 hurt: 41 controllingDrone / playing game: 20,21,20,22,23,22 Digging: 16,17,17,17,18,19 run: 4,4,7,6,5,5,6,7 idle: 0,1,2,1 swim: 12,13,14,13 jump: 4 fall: 11 LookingAtMap: 31 die: 36,37,38,39 rest: 43, push: 40, blowback: 41, boomerang (weapon): 19 ladder: 44,45,46,45 ReservedForFX (Dash, shake): 42

The process of setting up all of these anims was so laborious, that I imported all of them into a single animation, saved the SpriteFrames as a beard_character_anim.tres, yanked the frames out of the tres, and fed them into a python script to generate animations:

frames = [
    # Paste frames from beard_character_anim.tres here
]

anim = '''{{
"frames": [
{animframes}
],
"loop": true,
"name": &"{name}",
"speed": 5.0
}},'''

txt = ""
def create_anim(name, frame_list):
    f = []
    for i in frame_list:
        f.append(frames[i])
    f_str = "\n".join(f)
    return anim.format(name = name, animframes = f_str)

txt += create_anim("dash_right", [8])
txt += create_anim("dash_left", [9])
txt += create_anim("item", [10])
txt += create_anim("sleep", [32,33,34,35])
txt += create_anim("attack", [40])
txt += create_anim("fishing", [28,29])
txt += create_anim("fishing_pull", [30])
txt += create_anim("hurt", [41])
txt += create_anim("pda", [20,21,20,22,23,22])
txt += create_anim("digging", [16,17,17,17,18,19])
txt += create_anim("run", [4,4,7,6,5,5,6,7])
txt += create_anim("idle", [0,1,2,1])
txt += create_anim("swim", [12,13,14,13])
txt += create_anim("jump", [4])
txt += create_anim("fall", [11])
txt += create_anim("looking_at_map", [31])
txt += create_anim("die", [36,37,38,39])
txt += create_anim("rest", [43,])
txt += create_anim("push", [40,])
txt += create_anim("blowback", [41,])
txt += create_anim("boomerang", [19])
txt += create_anim("ladder", [44,45,46,45])
txt += create_anim("reserved_for_fx (Dash, shake)", [42])

# In beard_character_anim.tres there's a section like this:
# [resource]
# animations = [
#   Paste this output here
# ]
print(txt)

I'm glad I scripted it because I noticed there were edge bleed artifacts and had to make adjustments to the Separation value which would have meant manually redoing the whole thing.

I'm not sure how common these repeated frames are.

From a "I got an art pack" experience, the animation import process could be greatly improved. A wizard that let you select frames, and then input anim names and lists of indexes would have greatly simplified this case, but I guess that could be an addon.

idbrii commented 1 year ago

Updated proposal to include zoom level to avoid seeing a tiny image every time you Select Frames on a pixel art project: image

AThousandShips commented 1 year ago

This can easily be done by storing it as meta data like some other editor details aready have, I've worked with this plugin before so I'll take a look when I have time to implement this

Question: should it store the most recent properties (when relevant, such as tile size) as the default, or should it be a setting?

It should at least store the specific settings for each input file

idbrii commented 1 year ago

Are you thinking of something like a SlicedImage resource that stores the slicing information for a spritesheet?

That would be very helpful. But also, when working on a pixel art project with multiple spritesheets, many will use the same item dimensions even if the png dimensions are different. So once I select 24x24px and 5x zoom, I'd be nice if that applied to all my spritesheets in that project. I guess it could be a project setting, but it doesn't feel like something that needs to be edited from the Project Settings panel.

AThousandShips commented 1 year ago

Don't think this warrants adding a whole new format, instead just handling the metadata, or at minimum store the last setting if applicable

AThousandShips commented 1 year ago

Got some basic functionality going but will have to tweak with the specifics more, starting with focus on saving the state and not saving the specific state for each file though that would be desirable, it involves more meta data knowledge than I'm currently knowledgeable of

nonunknown commented 1 year ago

It should at least store the specific settings for each input file

with the PR I've made recent settings is remembered, but I think I can improve it more, to always remember for each texture! I think with that will be neat, but for now its ok, basic stuff's done!