mgkid3310 / AWESome

makes ARMA 3's flights more realistic (GPWS, wind effect, etc.)
Other
14 stars 6 forks source link

CBA Settings Default #35

Closed BrettMayson closed 5 years ago

BrettMayson commented 5 years ago

Describe the bug A default value is being stored in the profileNamespace for CBA settings. This is not needed since CBA stores the user settings already. Since saveProfileNamespace is not used, this code is already not doing anything.

For example,

private _defaultMode = profileNamespace getVariable ["orbis_gpws_personallDefault", "none"];
missionNamespace setVariable ["orbis_gpws_personallDefault", _defaultMode];
[
    "orbis_gpws_personallDefault",
    "LIST",
    ["Default GPWS Mode", "Activates default GPWS when boarding planes with GPWS turned off"],
    "AWESome GPWS",
    [["none", "b747", "f16", "rita"], ["No default setting", "B747", "Betty (F-16)", "Rita"], ["none", "b747", "f16", "rita"] find _defaultMode],
    nil,
    {
        missionNamespace setVariable ["orbis_gpws_personallDefault", _this];
        profileNamespace setVariable ["orbis_gpws_personallDefault", _this];
    }
] call CBA_Settings_fnc_init;

should just be

[
    "orbis_gpws_personallDefault",
    "LIST",
    ["Default GPWS Mode", "Activates default GPWS when boarding planes with GPWS turned off"],
    "AWESome GPWS",
    [["none", "b747", "f16", "rita"], ["No default setting", "B747", "Betty (F-16)", "Rita"], ["none", "b747", "f16", "rita"] find _defaultMode]
] call CBA_Settings_fnc_init;

CBA will automatically create the variable in the mission namespace

mgkid3310 commented 5 years ago

Good comment about saveProfileNamespace. Don't know why it's missing lol About the profile namespace, I just wanted to make sure it's saved, and moreover, use the same value when the option's name is changed for some reason. Sure the current code would cause some more work, but the difference shouldn't be noticeable.

mgkid3310 commented 5 years ago

40 solves this issue. Thanks to your suggestion, I had some time to look inside the CBA's code and decided to adapt settings init more effectively. You can feel free to close this comment after checking if what you intended has been applied.

BrettMayson commented 5 years ago

I mean, all the stuff you are doing with profileNamespace and missionNamespace is completely unnecessary. CBA handles all of it already, it saves the settings and the variables are already in missionNamespace.

private _enabled = profileNamespace getVariable ["orbis_aerodynamics_enabled", true];
missionNamespace setVariable ["orbis_aerodynamics_enabled", _enabled];
[
    "orbis_aerodynamics_enabled",
    "LIST",
    ["Advanced Aerodynamics", "Can enable or disable Advanced Aerodynamics"],
    "AWESome Aerodynamics",
    [[true, false], ["Enabled", "Disabled"], [1, 0] select _enabled],
    nil,
    {
        missionNamespace setVariable ["orbis_aerodynamics_enabled", _this];
        profileNamespace setVariable ["orbis_aerodynamics_enabled", _this];
        saveProfileNamespace;
    }
] call CBA_Settings_fnc_init;

can be simplified to

[
    "orbis_aerodynamics_enabled",
    "LIST",
    ["Advanced Aerodynamics", "Can enable or disable Advanced Aerodynamics"],
    "AWESome Aerodynamics",
    [[true, false], ["Enabled", "Disabled"], 0],
    nil
] call CBA_Settings_fnc_init;
mgkid3310 commented 5 years ago

Yeah, that's been done with #40 #41 #42 and #43

BrettMayson commented 5 years ago

Ah ok, I had viewed #37

jonpas commented 5 years ago

Sorry for revival, but I was browsing this repository and I have to comment on this:

Since saveProfileNamespace is not used, this code is already not doing anything.

Actually not true, it auto-saves on various loads, shut-down etc. :) Not saying it was the case here, but likely was anyways.