JujuAdams / Scribble

Efficient, internationalized, multi-effects text renderer for GameMaker
https://www.jujuadams.com/Scribble/
MIT License
321 stars 47 forks source link

Typist reset() doesn't re-calculate macros (and refresh from typist.get_text_element() doesn't exist) #448

Closed iflam closed 1 year ago

iflam commented 1 year ago

Hi! First of all, thanks for making Scribble. It's amazing!

I noticed that when I call typist.reset(), it resets without re-calculating macros. I also tried

element = typist.get_text_element();
element.refresh();

but this actually just crashed telling me that <>.refresh() isn't a function, so not entirely sure what's up with that.

For my case, I have a textbox that will have multiple "choice words" you can select, and during that selection phase I need to be able to update my macro'd words/fonts.

scribble_refresh_everything works to fix this issue, but that doesn't seem like the best solution in this case.

Maybe i'm just missing something?

Using 8.7 on runtime 22.11.1.75

Thank you!

JujuAdams commented 1 year ago

Bug here is that get_text_element() is returning a weak reference. If you use typist.get_text_element().ref this'll then work as expected.

...probably. Unless, of course, the text element has been cleared up then we've got a problem so you'll need to run weak_ref_alive() on what .get_text_element() returns.

At any rate, I will make a patch for .get_text_element() that returns the actual text element, or undefined if the reference is dead.

iflam commented 1 year ago

Ah, so after I posted this issue, I went and did some debugging into what your code does and I did indeed find references to the element.ref.refresh(), however that didn't work either.

...What I did find I can do is since I'm wrapping my text elements in scribble and then calling the .draw(,,typist), I found a way to reference that original which is the non-weak reference.

Still, would be a nice little help if the .get_text_element() did as you wrote above :)

Typist is a w e s o m e :D

JujuAdams commented 1 year ago

https://github.com/JujuAdams/Scribble/commit/b7e7f548ab5f101532b9efba395c982970999cfd