fn_onChar.sqf 982 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "defines.h"
  2. /*
  3. Author: Bryan "Tonic" Boardwine
  4. Description:
  5. When a character is entered it is validated and changes the
  6. correct slider it is associated with. I probably over-complicated
  7. this more then I had to but onChar behaves weird.
  8. PARAMS:
  9. 0: CONTROL
  10. 1: SCALAR (INT)
  11. 2: STRING (Case option)
  12. */
  13. private["_value","_varName","_maxRange"];
  14. params ["_control","_code","_slider"];
  15. disableSerialization;
  16. if(isNull _control) exitWith {}; //POOOOOP
  17. _maxRange = if(!isNil "tawvd_maxRange") then {tawvd_maxRange} else {20000};
  18. _value = parseNumber (ctrlText _control);
  19. if(_value > _maxRange OR _value < 100) exitwith {[] call TAWVD_fnc_openMenu;};
  20. _varName = switch (_slider) do {
  21. case "ground": {"tawvd_foot"};
  22. case "vehicle": {"tawvd_car"};
  23. case "air": {"tawvd_air"};
  24. case "object": {"tawvd_object"};
  25. case "drone": {"tawvd_drone"};
  26. default {"tawvd_foot"};
  27. };
  28. SVAR_MNS [_varName,_value];
  29. [] call TAWVD_fnc_updateViewDistance;
  30. [] call TAWVD_fnc_openMenu;