loopier / animatron-godot3

Yet another implementation of Animatron, but in Godot
GNU General Public License v3.0
17 stars 1 forks source link

Implement config system #12

Closed loopier closed 2 years ago

loopier commented 2 years ago

The config system can be built with OSC messages that are called at startup. Things that it should handle (extend as needed in this thread?):

totalgee commented 2 years ago

The config system can be built with OSC messages that are called at startup.

What do you mean "can be built with OSC messages"? Wouldn't this be a "config file" that would be read from disk at startup? Can you give an example (commands) of what you mean?

You mean something like /config/animpath dir? What would that do, save the config to disk for subsequent runs, or only affect the current state?

loopier commented 2 years ago

You mean something like /config/animpath dir?

yes. Having a bunch of config OSC messages to config stuff in the app. Saving these in a file as we do custom /defs it's like a config file. The app just needs to call this "script" at startup. Does it make sense?

This allow for runtime configuration, and avoids having to setup a dedicated parsing system just for the config (with JSON or INI or whatever). We have one parsing system to rule them all.

totalgee commented 2 years ago

Yes, makes sense, thanks. Would it always save the current settings on exit, or only explicitly when you call a save settings command?

loopier commented 2 years ago

not sure. Automatic saving has the danger of accidentally overwriting files.

Another question might be what config file does it load by default? The last one used?

loopier commented 2 years ago

A first implementation in 1147cdd0729ad8d0b3d39d21a93af16a4782e81a saves config files as regular /defs in res://config/.

The workflow is the same as with custom commands, so the config file has to be loaded AND executed.

An example config file named config.osc:

def /config
    /window/screen 1
    /window/fullscreen

would be used with

n.sendMsg("/load/config", "config.osc");
n.sendMsg("/config");
loopier commented 2 years ago

Is it possible/desirable to read OSC commands directly from a file without putting them in a def?

/window/screen 1
/window/fullscreen

as opposed to

def /config
    /window/screen 1
    /window/fullscreen
totalgee commented 2 years ago

I added some fixes to your work on this, so now it basically works:

I don't know if having to define a /config message is the best way, but it's fine for now. In fact, with the current approach, we don't really need a $Config.loadConfig() (/load/config) method (and associated OSC command), since it's basically identical to $OscInterface.loadDefsFile() (/load/defs). On startup, for loading the default config file, we could just call $CustomCommands.loadCommandFile() and then run /config.

loopier commented 2 years ago

You're right, I could've just remapped with OSC. Let's remove it.

totalgee commented 2 years ago

I added a new config option to allow you to restrict OSC messages from non-localhost clients: