Skip to content

Support using undeclared media resources by file name #181

@andrigamerita

Description

@andrigamerita

Hi! I'm trying Monogatari a bit, and one possible quality-of-life feature I found missing would be the ability to use media resources (character sprites, backgrounds, music, videos, etc...) without having to declare them first with their associated file path.

Calls to show/hide and play/stop commands for those elements currently only allow for the IDs of resources declared in script.js (and CSS properties when applicable), which can be a bit limiting and tedious when there are many assets, given how each file must be manually specified, and so the configuration must be always kept manually in sync with the actual file system.
Other engines like Ren'Py make this optional, allowing for the file path to be specified directly each time a file needs to be used (even without extension in some cases; for example, characters).

So, what I'm suggesting is either one of the following be implemented:

  • Add specialized syntax in all show/hide and play/stop commands for explicitly using a resource by its file name (relative to the various assets directories), as opposed to CSS or IDs; this could be something like a special prefix symbol (eg. @name.png, show character y @happy.png) or some wrapping symbols (eg. "name.mp4" or <name.jpg>, show scene <sea.jpg>), depending on what makes more sense.
  • A fallback (which is a bit dirty, but it's a possible second option in case the first is for some reason bad) such that, when the game tries to read a resource string as a resource ID and doesn't find a corresponding object in the declarations table, and it hasn't tried to read the string as CSS, it assumes the string is a direct file path and tries loading that, instead of failing immediately like it does now.

After deciding on either one of the options, an additional quality-of-life feature would be that of making specifying the file extension optional. When a file name that features no extension is specified in some action of the script, the engine guesses a possibile file extension based on some common defaults for types (eg. MP4 for videos, PNG for sprites, MP3 for music, ...), possibly overridable by developers via the JSON configuration.

What I'm requesting is actually already partially implemented for image elements (still kinda limited, since what the engine does is infer if the user has specified a file path or a resource ID just based on if a dot is present), so I would guess the absence for all other media elements is just a forgotten detail, and not a design decision, and so I think this could be a good addition.
The only issue I can think of with this approach is that, when writing a game with media called always this way, instead of all declared, preloading would be impossible without doing some fancy script parsing before the start of the game... but this could still be implemented in the future if considered valuable, and developers who want preloading can still go with the classic approach. If it isn't a problem for images, I guess it's not a problem in general.

Let me know what you think of this, and if there's something you would do different!
I would like this feature for my own use, so I probably will end up coding it myself, seeing how you don't have much time and there aren't other active mantainers; but, since I would obviously like to contribute back to the project with a pull request in that case, I figure it's good to ask for your opinion as owner of the project before doing anything, so that I can come up with a solution that is good for you too.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions