Skip to content

ImportGraphics, ImportGraphicsAdvanced: trim texture pages items, credit ImportGraphicsWithParameters' creator#2083

Merged
colinator27 merged 2 commits intoUnderminersTeam:masterfrom
CST1229:importgraphics-trim
Apr 5, 2025
Merged

ImportGraphics, ImportGraphicsAdvanced: trim texture pages items, credit ImportGraphicsWithParameters' creator#2083
colinator27 merged 2 commits intoUnderminersTeam:masterfrom
CST1229:importgraphics-trim

Conversation

@CST1229
Copy link
Copy Markdown
Contributor

@CST1229 CST1229 commented Mar 29, 2025

Description

ImportGraphics.csx and ImportGraphicsAdvanced.csx now trims the textures of imported sprites (and adjusts the appropriate page item properties), which saves on texture page space, matches GameMaker's behavior better and fixes importing proprtional sprite fonts. The margin left/right/top/bottom properties are also now somewhat properly calculated (they are properly calculated for new sprites, but for existing ones they are only ever grown and never shrinked).

I also changed the header comments in ImportGraphicsAdvanced to credit the actual creator of the original ImportGraphicsWithParameters, @DonavinDraws. Maybe mention him too (alongside me) when the ImportGraphicsAdvanced script is mentioned on the next release's changelog.
I found him by looking for the earliest time ImportGraphicsWithParameters.csx was sent in the PTD with B&H Discord server (a Pizza Tower server), and I also DMed him to confirm it:
image
(this DM was posted with permission from him, by the way)

Output example with a few random sprites

Old:

New:

Caveats

Something happened to the indentation in ImportGraphicsAdvanced, not sure how that happened (probably through Visual Studio doing some autoformatting). The diff is more readable if you turn on the ignore whitespace option.

I also didn't test much.

Notes

Coincidentally, Donavin himself was also developing ImportGraphicsWithParameters further (which I was completely unaware of; it's also in the PTD with B&H server), re-incorparating my ImportGraphicsWithParametersPlus changes back into his and adding an independent implementation of texture trimming before me. However it was before the texture refactor so it isn't really useful here. I just thought it was interesting.

CST1229 added 2 commits March 29, 2025 15:31
This makes imported sprite fonts not break, as well as saving on texture page space.
@github-actions
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@colinator27 colinator27 left a comment

Choose a reason for hiding this comment

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

Seems to work great! As an additional note, I'll probably be adding some texture packing (and related) utilities to the library proper as part of the project system. Hopefully should consolidate a lot of the duplicated code across these two scripts, and others.

@colinator27 colinator27 merged commit 101ae07 into UnderminersTeam:master Apr 5, 2025
5 checks passed
@CST1229 CST1229 deleted the importgraphics-trim branch April 10, 2025 14:05
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