Feature - Implemented Update HP/MP Usage GUI when preferences change

adeyke

Member
If you use the CLI or a script to update hpAutoRecovery and such, this doesn't change what's displayed in the GUI. It would be nice if that automatically showed the new values.
 

Bale

Minion
I agree that this would be very nice. It troubles me a bit at the beginning of every ascension when my newLife resets those settings for level 1.

The settings he refers to as "hpAutoRecovery and such" are:
  • hpAutoRecovery
  • hpAutoRecoveryTarget
  • mpAutoRecovery
  • mpAutoRecoveryTarget
  • manaBurningThreshold
  • manaBurningTrigger
 

Crowther

Active member
This confused me for the longest time. I believe even when mafia resets them on ascension, the display is not updated.
 

fronobulax

Developer
Staff member
Remind me and I will look at this. But I think this is a long standing issue. In the spirit of remembering things that did not happen, I think the issue is that there is no listener attached to that panel and so no trivial way to update. No one wanted to implement a listener way back then.
 

Bale

Minion
As I recall, that is what Veracity said the last time it came up. Unfortunately it seems to have been on the defunct bug tracker because nothing comes up when I search for it.
 

fronobulax

Developer
Staff member
As I recall, that is what Veracity said the last time it came up. Unfortunately it seems to have been on the defunct bug tracker because nothing comes up when I search for it.

Thanks. It's nice to remember things correctly. I'm looking at it now.
 

fronobulax

Developer
Staff member
I have code that has worked for me. I will run with it tomorrow and then commit if I still think it works.

For those playing along at home there already was a registry for preference change listeners. So on paper this was a simple as registering new listeners and then having them respond by updating the GUI. The problem is that the registry only keeps a weak reference to the listeners. My first implementation was to create a listener class but it turned out that they were being garbage collected. As a software archeologist I'd say the registry has an undocumented convention that it expects the GUI object to also be the listener. Thus when the GUI object itself is no longer needed the listeners will unregister themselves. I won't question why this was done, but in 2016 it is probably not what any team I have supported would have adopted as an implementation standard.

The HP/MP Restore tab should now be updated whenever the following change:
hpAutoRecovery
hpAutoRecoveryTarget
mpAutoRecovery
mpAutoRecoveryTarget
manaBurningThreshold
manaBurningTrigger
 

fronobulax

Developer
Staff member
r17182

It worked for me, but many are the times when I have been wrong. Part of my delay is that the recovery values are floats with absolute value bounded by one. set hpAutoRecoveryTarget= 75 is not going to do what I had initially hoped :)
 
Top