YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

Provide a command-line tool to modify GM project structure #5661

Open Alphish opened 6 months ago

Alphish commented 6 months ago

Is your feature request related to a problem?

Sometimes, we'd like to perform project structure modifications automatically. A common use-case would be re-importing sprites that have been changed externally, possibly by another process that exported them from another editor. Another scenario would be auto-generating code.

I've used Inkscape CLI to automatically export images and it has been a huge help in my process. I imagine a similar tool for managing GM projects would likewise allow lots of useful automations.

Describe the solution you'd like

Provide a tool that can modify a GameMaker project through a command line interface.

The command could take format like: gmproject MyProject.yyp add sprite spr_AutoSprite "AutoSprite.png" --origin=8,8 or maybe instead some JSON would be passed like: gmproject MyProject.yyp "[{ "command": "AddSprite", "name": "spr_AutoSprite", "path": "AutoSprite.png", "origin": { "x": 8, "y": 8 ]"

The point is to make those commands possible to reasonably write as a human, and reasonably generate by a tool; as long as this applies, I'm not too picky about the exact format.

Considering exposing all IDE functionality to the command-line interface would likely be time-consuming, the functionality might be added gradually, possibly going by the most demanded pull requests. I'd suggest focusing on sprite operations first, as I've found them to be most time-consuming to import, especially when working with an artist who would make dozens of these.

Describe alternatives you've considered

Figuring out the YYP project structure and trying to replicate basic operations myself. That's an option too, but project format is prone to change, and as a reverse-engineered solution the underlying abstraction for project management can clash with format changes or new project-related functionalities. On the other hand, YYG might already have some abstraction for project management, with core management operations exposed as a consistent API and any implementation details changing under the hood.

Additional context

We talked about sprite importing process and how graphic editors CLI can be useful to streamline the process, and then an idea of having similar CLI for GM project management was brought up as well.

thennothinghappened commented 6 months ago

Here's my quick stab at imagining what such a CLI could look like :)

$ gmcli project init "SomeProject" --path=./
Project "./SomeProject.yyp":
- Created new project "SomeProject" at ./

$ gmcli sprite add sSomeSprite --strip="SomeSpriteStrip.png" --strip_count=5 --origin=8,8 --group="Sprites/Something" --fps=30
Project "./SomeProject.yyp":
- New sprite "Sprites/Something/sSomeSprite", 16x16, 5 subimages, 30 FPS.

$ gmcli sprite list --tree
Project "./SomeProject.yyp":
|->"Sprites"
|  |->"Something"
|  |  |->"sSomeSprite"

$ gmcli sprite info sSomeSprite
Project "./SomeProject.yyp":

Group: "Sprites/Something/"
Type: Sprite
Size: 16x16
FPS: 30
Subimages: 5

$ gmcli sprite info sSomeSprite --references
Project "./SomeProject.yyp":

Group: "Sprites/Something/"
Type: Sprite
Size: 16x16
FPS: 30
Subimages: 5

Referenced By:
No current references.

$ gmcli sprite info sSomeSprite --quiet --group
Sprites/Something/

$ gmcli sprite info sSomeSprite --json
{"project": "./SomeProject.yyp", "group": "Sprites/Something/", "type": "GMSprite", "name": "sSomeSprite", "fps": 30, "width": 16, "height": 16, "subimages": 5}

$ gmcli project info
Project "./SomeProject.yyp":

Name: SomeProject
Project Start Date: 27 April 2024 8:31 AM
Project Use Time: 0 Days 0 Hours 56 Minutes 14 Seconds
YY Format: 2.0

$ gmcli options list
Project "./SomeProject.yyp":

GenerateMipmaps: false
EnableSourceControl: false
AcceptSpineLicense: false
CollisionCompatibilityMode: false
ArrayCopyOnWrite: false

$ gmcli options set ArrayCopyOnWrite true
Project "./SomeProject.yyp":
- Set "ArrayCopyOnWrite" to true

$ gmcli ide list
Installed IDEs:
- beta
- stable

Downloadable IDEs:
- lts

$ gmcli ide info beta
IDE "beta":

Location: "C:\Program Files\GameMaker-Beta"
Version: 2024.400.0.549

Checking IDE release feed...
IDE is up to date.

$ gmcli ide install lts --path="C:\Program Files\GameMaker-LTS"
Installing IDE "lts" v2022.0.2.51

Downloading...
(10.2mb/s) [####################] 100%

Unpacking...
Done!

$ gmcli ide --type=stable
Project "./SomeProject.yyp":
Opening Stable IDE.