dialogic icon indicating copy to clipboard operation
dialogic copied to clipboard

Add way to let subsystems save on Dialogic.get_full_state()

Open Jowan-Spooner opened this issue 2 years ago • 3 comments

Maybe with a signal or by calling a method like save_full_state() on all subsystems that have it. This would allow the subsystems to easily save stuff to the full state before it is "exported" or saved by the save system.

Jowan-Spooner avatar Nov 07 '22 00:11 Jowan-Spooner

and to copy my notes here, what would need to be figured out is a way to hold for all of the subsystems to be ready once the save signal is emitted. something like this:

  1. when DGH is initialized, say 4 subsystems register to the signal that they want to be able to save
  2. saving is called
  3. signal is sent out for all the subsystems to report in, and the save routine pauses
  4. once all 4 subsystems have reported in that theyve written to the full state, then the full state is ready and it can be saved

while checking into the Signal documentation, was able to see that there is a get_connections() function, which returns an array. so that works for the getting the number of them count. now just need to figure out how to do the waiting for it to report back as ready part

a similar kind of Signal->Wait system also had come to mind as the solution for a couple other things people had requested, like being able to do custom text processing with #1112. now that i know that there's a way to see what's listening, ill loook around probably can find some good description of how to completely implement it

ii4y-studios avatar Nov 07 '22 00:11 ii4y-studios

Wouldn't it be possible to just call the method on every subsystem similar to this:

for subsystem in get_subsystems():
    if subsystem.has_method('save_full_state'):
        current_state_info = subsystem.save_full_state()

Jowan-Spooner avatar Nov 08 '22 13:11 Jowan-Spooner

that would be a way to do it for just the save function, but that wouldn't solve the other example of doing it in other places, like post-processing of the text to handle otehr custom BBcode and such, or for any future similar things we may want to add. would also mean that if they want to use the single save for everything, and have any other game data in the same save it would also have to register as a subsystem too

but i think I did figure out more of the signal -> wait idea as alternative:

  • queue handling signal to emit, that other functions
  • timer (for timing out and moving on just in case one of them takes too long)
  • go/nogo signal for the listeniers to return when they're ready

then a couple functions to do the handling. would then go like this :

  1. some function (save for example) calls the fucntion to start the system
  2. function notes how many listeners there are with get_connected(), and signal is emitted with the name of what's being called to start
  3. each of the functions listening for that signal receives it, does their thing, and then sends back the go/nogo signal that they're done
  4. once it receives the same mumber of go/nogo back as listeners, then it's ready to finish out its own work
  5. if the timeout is hit before listeners are all done, then its handled diffrently depending on the needs (aborting save, saving with the missing data, just sending the text to the text box as-is for a custom bbcode handling, etc)

idk would still need to experiment with it, but seems more flexible and multi-purpose this way. could even jsut be a bonus available Dialogic feature for some devs to use in their game where they might need something like that, and not have to write it themselves

ii4y-studios avatar Nov 17 '22 18:11 ii4y-studios