blurymind / YarnClassic

A tool for writing interactive dialogue in games!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Save (Ctrl-S) converts yarn dialogue structure into json and can't open it afterwards

AlekFy opened this issue · comments

I have a long dialogue in yarn structure
When I open it with the editor and make a change and then save it with Ctrl-S the file gets converted to json structure
The file name is still the same, but the size is 10kb heavier
If I try to open it with the editor afterwards, the file looks empty (no nodes visible on workspace)
If I save it again, the file is 0kb

But if I edit the original yarn file, save it with Ctrl-S but do not close the editor and then Save As Yarn -> the new file keeps the yarn structure and size, but the original one is getting converted

I wish the editor would save the file in a format it was written in, not json by default, all the more so given that the converted file can't be opened with editor to convert back :(

I have now checked and even if I save to GIST the file keeps converting to json :((
This problem goes back to at least ver 0.4.100

yikes, that sounds bad. Think its possible that you are hitting the localStorage limit of 5mb.

Can you zip a file that we can use to stress test yarn and attach it to this ticket. I will try to come up with a fix that handles running out of memory.
To be honest the localStorage is convenient for persistence, but using it to snapshot the entire file is maybe a bad idea

Sure, here it is:
thenest_story.zip
Thank you for looking into it! I really like working with the editor and not the new VS Code plugin :P

Thank you, I will try to fix the issue using your file. I suspect it may be something else now, seeing that the file size is not so big, but it is tbc

silly question, but are you using the massively outdated electron version or the much newer web version of the editor?

There is no way to Ctrl+S (save) in the web editor, because it does not work on the local file but an online copy. I only can Save As using the menu so it's not the same case. Also it's not available anymore (404) :(

i think it is possible to bring the ctrl+s same file writing to the progressive web app version too, it just needs some dev work

when a new file is opened or created on the filesystem, a file handle should be created and held in memory. That would allow yarn to continuously write to the same file without having to create a new one.
https://developer.chrome.com/docs/capabilities/web-apis/file-system-access

This has a limitation however. The file handle cannot be persisted when you refresh the page, close the tab or close the progressive web app.
Then it would ask you to make a file again.

The best way to use it at the moment is by creating a new github token and saving to and from gist files.

  • it backs your work in the cloud
  • the gist files can be anonymous so only you can see them
  • clicking on the save button saves them directly to the cloud without asking you again to create new ones
  • you can edit the same files from your desktop pc or your smartphone (via the progressive web app) - that is something that you cannot do with electron

The electron version was developed before this new file system api existed and it uses an api that only works on electron - using nodejs fs api instead.
I want to replace it with the new api that works the same way in browser and electron, but never had the time to do it

I have now addressed this in the PWA version of yarn via
c7694e2

you can also install and use it offline as a PWA.

If you now open a local file or save a file- Yarn will keep its handle and every time you click on the save icon (bottom left)
yarn will override the same file instead of downloading it as a new file

This will not be fixed on the electron version, which i am planning on phasing out. That version is many many commits behind. I recommend not using it

I have also assigned this to ctrl+s if you dont like the save button
5375d33

(Sorry for the delayed response) Thank you for those improvements, it helps a lot! I've made a PWA on my desktop, works really well if I set redraw delay to 0 I can't really feel the difference from the electron version. The gist approach seems the most convenient! Thank you blurymind!