zen-mod / ZEN

Zeus enhancement mod for Arma 3
https://zen-mod.github.io/ZEN
GNU General Public License v3.0
108 stars 47 forks source link

Custom Dialog - SLIDER:RADIUS does not save last selection data when "Radius Center" is changed #664

Closed Crowdedlight closed 2 years ago

Crowdedlight commented 2 years ago

Arma 3 Version: 2.08 (stable) CBA Version: 3.15.6.211004 (stable) ZEN Version: 1.12.1 (stable)

Mods:

- CBA_A3
- ZEN

Description: When using the custom dialog framework with SLIDER:RADIUS and a position ("Radius Center") that is based on where the module is used, it always resets to default values, instead of using last saved values. However it seems that if you give a static position, or no position, then it correctly uses the last saved options. You can test this by giving it position [0,0,0] then change sliders to a value. If you execute that code again but change position to [0,0,1] it will reset to default values.

I suspect the function responsible to detect if the dialog is "identical" to a known dialog, to get last used values, also includes the position argument in detection.

Expected behavior: I expect the framework to save the last selected options, even if the position argument of SLIDER:RADIUS changes. As most modules will be executed on different positions each time based on where zeus click. I assume the SLIDER:RADIUS was made to be able to easily display a radius indicator of area-of-effect. It does not make sense that this would also make all options reset to default every time its used.

Steps to reproduce: Add the steps needed to reproduce the issue.

  1. run this in execute code module, with local execution
    private _pos = ASLtoAGL (_this#0); 
    [ 
    "Select Firesupport Type and Area",  
    [ 
    ["SLIDER:RADIUS","Radius",[0,5000,20,0, _pos, [1, 0, 0, 0.7]],false], 
    ["SLIDER","slider2",[0,30,5,1],false] 
    ], 
    _onConfirm, 
    {}, 
    _this 
    ] call zen_dialog_fnc_create;
  2. Set slider value other than default
  3. Run the same again in execute code, the values are now back to default.

Where did the issue occur? Experienced in: Dedicated / Self-Hosted Multiplayer / Editor (Multiplayer)

Additional information: Provide any additional information that will help us solve this issue.

RPT log file: https://gist.github.com/Crowdedlight/0865e5d6aab501f7029faf17f9a6c39f

neilzar commented 2 years ago

I'm afraid this is a side effect of the ID we create. Any change in any of those values, whether that be the _pos variable or the _onConfirm variable, will change the ID. You can add a 6th argument to the function call to create a custom save ID, which should solve your problem. I see it is not documented on the website, but if you pass a string after _this in your example it should save properly.

Crowdedlight commented 2 years ago

Ah perfect. Didn't know the custom id was an option. That works. Thanks for the quick reply!