dialogic-godot / dialogic

💬 Create Dialogs, Visual Novels, RPGs, and manage Characters with Godot to create your Game!
https://dialogic.pro
MIT License
3.42k stars 206 forks source link

History Subsystem #1219

Closed exelia-antonov closed 1 year ago

exelia-antonov commented 1 year ago

History subsystem. Built to be flexible so it can be used in various different ways. Has two different types of histories: a full history stack of all events, and a separate history of just all read text options. Full history is meant for multiple uses including data rollback, read text is more focused for VN/RPG type use, where it typically allows for styling the text a different color or allowing for a toggle to only skip already-read text (see #1100). before saving it into the full state, it will strip the actual Event object from the timeline

I copied it's files from the Glossary event, so some of them are currently still Glossary files. I'm using this draft to document things I need to implement:

Core necessary things:

A few other things will be tangentially made possible with this directly or with changes needed for making this enabled, so I'll link them as I go if I find them

The above is all the core functionality of the History subsystem itself. Then after I'll make an example History view, probably mimicing the way that Dialogic 1.x History looks for starters. But as it's own subsystem of just data, people will be able to use it and customize the actual visuals of the history however they want.

exelia-antonov commented 1 year ago

note to self: no explicit choice data needs to be saved, as the choices are built from the Text event before it, and it only calls handle_event() on whichever choice is selected. only the chosen choice will be in the history

Jowan-Spooner commented 1 year ago

I'm wondering if events should be able to implement a _execute_reverse() or _rollback() method where they get acess to some previous data? But I haven't looked into how you want to implement the rollback functionality.

Also is the history stack saved? Can it be loaded back in from different slots?

exelia-antonov commented 1 year ago

history stack is put in the state, yeah, in a stripped down form (which timeline it is, which line it is, that event type it is) at minimum. there will be options to save more data than that if they want it, instead of having to reload the timelines and grab the full events again, which could be useful in certain different uses of the timeline. in memory before that, itll also have the full event object

for actual rollback function, my thought had been just an actual event reversing functionality would just play the reverse timeline in order, one step at a time. there's a few spots where it would need to like reference back to the original timeline to rebuild while doing that, such as choices so it can rebuild the choice menu

exelia-antonov commented 1 year ago

Niche case note for idk how to fix it right now, whether it really needs to be, and can be addressed later: the bbcode for putting in a random word in a text block, theres not really a way to save that for the history

exelia-antonov commented 1 year ago

example History display created, and added to the Default scene. it's only on the Default theme, not the Special theme

oh that one wasn't in my checklists, gotta finish those still

exelia-antonov commented 1 year ago

noting here: since I had been planning on updating the Visual Novel template (since I'm using it for one of my projects myself), I'm going to have that as the example implementation for the usage of the text_read_history, as well as actually using the full_history for a rollback function, as both of those are like very limited use outside of VN's specifically

also, in line with more DDLC shenanigans, gonna make a custom event type that can put fake events in the History but don't show up elswhere. I'll attach it onto here as a zip, probly, until the new Dialogic website can be set up with the custom events gallery

exelia-antonov commented 1 year ago

decided to go with a signal in the History subsystem for the already read text event, history_text_already_read rather than going with another type added to Text itself. cleaner this way, instead of having to add another property on the Text event itself and having to update a bunch of functions with it. the History subsystem is handled before the event itself is, so the signal can make the display scene ready ahead of time to apply to whatever changes you want to use

exelia-antonov commented 1 year ago

ok there was some more options i wanted to add to history for more options for the full history saving, but I genuinely dont rememger them right now and cant find the notes I made about them. so I'm gonna just open this one up as ready now, and add those later when i fianlly remmber the other situations

coppolaemilio commented 1 year ago

image

I'm getting these errors when opening the regular test project for the first and second time using this branch, no idea why, just posting the screenshot here

coppolaemilio commented 1 year ago

That fixes the two first ones

coppolaemilio commented 1 year ago

That should be all the errors, I'll fix the merge issues now.

coppolaemilio commented 1 year ago

@thebardsrc I'm getting this error when trying to run a timeline with the first event being a text event with no character set:

image