From efb761a14c40e79bd7812c6341f45059120fb19c Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 21 Jan 2015 22:52:39 +0100 Subject: [PATCH] vector settings --- addons/vector/RscInGameUI.hpp | 306 +++++++++--------- addons/vector/XEH_preInit.sqf | 3 + .../vector/functions/fnc_adjustBrightness.sqf | 28 ++ addons/vector/functions/fnc_nextMode.sqf | 44 +++ addons/vector/functions/fnc_onKeyDown.sqf | 16 +- addons/vector/functions/fnc_onKeyHold.sqf | 93 ++++-- addons/vector/functions/fnc_showP1.sqf | 2 + addons/vector/functions/fnc_showText.sqf | 2 +- 8 files changed, 311 insertions(+), 183 deletions(-) create mode 100644 addons/vector/functions/fnc_adjustBrightness.sqf create mode 100644 addons/vector/functions/fnc_nextMode.sqf diff --git a/addons/vector/RscInGameUI.hpp b/addons/vector/RscInGameUI.hpp index dea9d98419..9be7f1ea1c 100644 --- a/addons/vector/RscInGameUI.hpp +++ b/addons/vector/RscInGameUI.hpp @@ -4,162 +4,162 @@ class RscPicture; //class ScrollBar; class RscControlsGroup { - class VScrollbar;//: ScrollBar {}; - class HScrollbar;//: ScrollBar {}; + class VScrollbar;//: ScrollBar {}; + class HScrollbar;//: ScrollBar {}; }; class RscInGameUI { - class RscUnitInfo; - class ACE_RscOptics_vector: RscUnitInfo { - onLoad = "[""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable ['ACE_dlgVector', _this select 0];"; - onUnload = "[""onUnload"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; - idd = 300; - controls[] = {"CA_Distance","CA_Heading","CA_OpticsPitch","CA_Elev","CA_OpticsZoom","CA_VisionMode","ACE_ScriptedDisplayControlsGroup"}; + class RscUnitInfo; + class ACE_RscOptics_vector: RscUnitInfo { + onLoad = "[""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable ['ACE_dlgVector', _this select 0];"; + onUnload = "[""onUnload"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; + idd = 300; + controls[] = {"CA_Distance","CA_Heading","CA_OpticsPitch","CA_Elev","CA_OpticsZoom","CA_VisionMode","ACE_ScriptedDisplayControlsGroup"}; - class CA_Distance: RscText { - idc = 151; // distance - w = 0; - h = 0; + class CA_Distance: RscText { + idc = 151; // distance + w = 0; + h = 0; + }; + + class CA_Heading: RscText { + idc = 156; // azimuth + w = 0; + h = 0; + }; + + class CA_OpticsPitch: RscText { + idc = 182; // inclination + w = 0; + h = 0; + }; + + class CA_Elev: RscText { + idc = 175; // inclination, more accurate + w = 0; + h = 0; + }; + + class CA_OpticsZoom: RscText { + idc = 180; // some kind of zoom + w = 0; + h = 0; + }; + + class CA_VisionMode: RscText { + idc = 179; // ??? + w = 0; + h = 0; + }; + + class ACE_ScriptedDisplayControlsGroup: RscControlsGroup { + idc = 170; + x = "SafezoneX"; + y = "SafezoneY"; + w = "SafezoneW"; + h = "SafezoneH"; + + class VScrollbar: VScrollbar { + width = 0; + }; + + class HScrollbar: HScrollbar { + height = 0; + }; + + class controls { + class Center: RscPicture { + idc = 1301; + text = ""; + colorText[] = {1,0,0,0.5}; + x = 0.488 * safezoneW /*+ safezoneX*/; + y = 0.4783 * safezoneH /*+ safezoneY*/; + w = 0.4 / 16 * safezoneW; + h = 0.4 / 9 * safezoneH; + }; + + class Crosshair: Center { + idc = 1302; + x = 0.4848 * safezoneW /*+ safezoneX*/; + y = 0.4732 * safezoneH /*+ safezoneY*/; + w = 0.5 / 16 * safezoneW; + h = 0.5 / 9 * safezoneH; + }; + + class Digit0: Center { + idc = 1310; + x = (0.54 + 0 * 0.02) * safezoneW /*+ safezoneX*/; + y = 0.54 * safezoneH /*+ safezoneY*/; + w = 0.5 / 16 * safezoneW; + h = 0.5 / 9 * safezoneH; + }; + + class Digit1: Digit0 { + idc = 1311; + x = (0.54 + 1 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class Digit2: Digit0 { + idc = 1312; + x = (0.54 + 2 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class Digit3: Digit0 { + idc = 1313; + x = (0.54 + 3 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class Digit4: Digit0 { + idc = 1314; + x = (0.54 + 4 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class Digit5: Digit0 { + idc = 1315; + x = (0.35 + 0 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class Digit6: Digit0 { + idc = 1316; + x = (0.35 + 1 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class Digit7: Digit0 { + idc = 1317; + x = (0.35 + 2 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class Digit8: Digit0 { + idc = 1318; + x = (0.35 + 3 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class Digit9: Digit0 { + idc = 1319; + x = (0.35 + 4 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class DigitE1: Digit0 { + idc = 1321; + x = (0.39 + 0 * 0.02) * safezoneW /*+ safezoneX*/; + y = 0.42 * safezoneH /*+ safezoneY*/; + }; + + class DigitE2: DigitE1 { + idc = 1322; + x = (0.39 + 1 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class DigitE3: DigitE1 { + idc = 1323; + x = (0.39 + 2 * 0.02) * safezoneW /*+ safezoneX*/; + }; + + class DigitE4: DigitE1 { + idc = 1324; + x = (0.39 + 3 * 0.02) * safezoneW /*+ safezoneX*/; + }; + }; + }; }; - - class CA_Heading: RscText { - idc = 156; // azimuth - w = 0; - h = 0; - }; - - class CA_OpticsPitch: RscText { - idc = 182; // inclination - w = 0; - h = 0; - }; - - class CA_Elev: RscText { - idc = 175; // inclination, more accurate - w = 0; - h = 0; - }; - - class CA_OpticsZoom: RscText { - idc = 180; // some kind of zoom - w = 0; - h = 0; - }; - - class CA_VisionMode: RscText { - idc = 179; // ??? - w = 0; - h = 0; - }; - - class ACE_ScriptedDisplayControlsGroup: RscControlsGroup { - idc = 170; - x = "SafezoneX"; - y = "SafezoneY"; - w = "SafezoneW"; - h = "SafezoneH"; - - class VScrollbar: VScrollbar { - width = 0; - }; - - class HScrollbar: HScrollbar { - height = 0; - }; - - class controls { - class Center: RscPicture { - idc = 1301; - text = ""; - colorText[] = {1,0,0,0.5}; - x = 0.488 * safezoneW /*+ safezoneX*/; - y = 0.4783 * safezoneH /*+ safezoneY*/; - w = 0.4 / 16 * safezoneW; - h = 0.4 / 9 * safezoneH; - }; - - class Crosshair: Center { - idc = 1302; - x = 0.4848 * safezoneW /*+ safezoneX*/; - y = 0.4732 * safezoneH /*+ safezoneY*/; - w = 0.5 / 16 * safezoneW; - h = 0.5 / 9 * safezoneH; - }; - - class Digit0: Center { - idc = 1310; - x = (0.54 + 0 * 0.02) * safezoneW /*+ safezoneX*/; - y = 0.54 * safezoneH /*+ safezoneY*/; - w = 0.5 / 16 * safezoneW; - h = 0.5 / 9 * safezoneH; - }; - - class Digit1: Digit0 { - idc = 1311; - x = (0.54 + 1 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class Digit2: Digit0 { - idc = 1312; - x = (0.54 + 2 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class Digit3: Digit0 { - idc = 1313; - x = (0.54 + 3 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class Digit4: Digit0 { - idc = 1314; - x = (0.54 + 4 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class Digit5: Digit0 { - idc = 1315; - x = (0.35 + 0 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class Digit6: Digit0 { - idc = 1316; - x = (0.35 + 1 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class Digit7: Digit0 { - idc = 1317; - x = (0.35 + 2 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class Digit8: Digit0 { - idc = 1318; - x = (0.35 + 3 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class Digit9: Digit0 { - idc = 1319; - x = (0.35 + 4 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class DigitE1: Digit0 { - idc = 1321; - x = (0.39 + 0 * 0.02) * safezoneW /*+ safezoneX*/; - y = 0.42 * safezoneH /*+ safezoneY*/; - }; - - class DigitE2: DigitE1 { - idc = 1322; - x = (0.39 + 1 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class DigitE3: DigitE1 { - idc = 1323; - x = (0.39 + 2 * 0.02) * safezoneW /*+ safezoneX*/; - }; - - class DigitE4: DigitE1 { - idc = 1324; - x = (0.39 + 3 * 0.02) * safezoneW /*+ safezoneX*/; - }; - }; - }; - }; }; diff --git a/addons/vector/XEH_preInit.sqf b/addons/vector/XEH_preInit.sqf index a8f9f41826..3e91e24282 100644 --- a/addons/vector/XEH_preInit.sqf +++ b/addons/vector/XEH_preInit.sqf @@ -25,6 +25,8 @@ PREP(showRelativeDistance); PREP(showRelativeHeightLength); PREP(showFallOfShort); PREP(showText); +PREP(nextMode); +PREP(adjustBrightness); GVAR(holdKeyHandler) = -1; GVAR(isKeyDownAzimuth) = false; @@ -33,3 +35,4 @@ GVAR(keyDownTimeAzimuth) = -1; GVAR(keyDownTimeDistance) = -1; GVAR(useMil) = false; GVAR(useFeet) = false; +GVAR(modeReticle) = 0; diff --git a/addons/vector/functions/fnc_adjustBrightness.sqf b/addons/vector/functions/fnc_adjustBrightness.sqf new file mode 100644 index 0000000000..8832329796 --- /dev/null +++ b/addons/vector/functions/fnc_adjustBrightness.sqf @@ -0,0 +1,28 @@ +// by commy2 +#include "script_component.hpp" + +private "_dlgVector"; + +disableSerialization; +_dlgVector = GETUVAR(ACE_dlgVector,displayNull); + +private "_color"; + +_color = [[1,0,0,0.5], [1,0,0,1]] select (_this select 0); + +(_dlgVector displayCtrl 1301) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1302) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1310) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1311) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1312) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1313) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1314) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1315) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1316) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1317) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1318) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1319) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1321) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1322) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1323) ctrlSetTextColor _color; +(_dlgVector displayCtrl 1324) ctrlSetTextColor _color; diff --git a/addons/vector/functions/fnc_nextMode.sqf b/addons/vector/functions/fnc_nextMode.sqf new file mode 100644 index 0000000000..53054e85e6 --- /dev/null +++ b/addons/vector/functions/fnc_nextMode.sqf @@ -0,0 +1,44 @@ +// by commy2 +#include "script_component.hpp" + +switch (_this select 0) do { + case ("settings"): { + switch (GVAR(configTemp)) do { + case ([false, false]): { + GVAR(configTemp) = [false, true]; + }; + case ([false, true]): { + GVAR(configTemp) = [true, true]; + }; + case ([true, true]): { + GVAR(configTemp) = [true, false]; + }; + case ([true, false]): { + GVAR(configTemp) = [false, false]; + }; + }; + + [["meter", "feet"] select (GVAR(configTemp) select 0)] call FUNC(showText); + [["deg", "mil" ] select (GVAR(configTemp) select 1)] call FUNC(showText); + }; + + case ("config"): { + GVAR(configTemp) = GVAR(configTemp) + 1; + if (GVAR(configTemp) > 2) then {GVAR(configTemp) = 0}; + + switch (GVAR(configTemp)) do { + case (0): { + ["eret"] call FUNC(showText); + ["off"] call FUNC(showText); + }; + case (1): { + ["eret"] call FUNC(showText); + ["on"] call FUNC(showText); + }; + case (2): { + ["nigt"] call FUNC(showText); + ["on"] call FUNC(showText); + }; + }; + }; +}; diff --git a/addons/vector/functions/fnc_onKeyDown.sqf b/addons/vector/functions/fnc_onKeyDown.sqf index 22c29121a0..197ea1e3ae 100644 --- a/addons/vector/functions/fnc_onKeyDown.sqf +++ b/addons/vector/functions/fnc_onKeyDown.sqf @@ -20,10 +20,11 @@ _fnc_setPFH = { switch (_this select 0) do { case ("azimuth"): { + GVAR(keyDownTabCountDistance) = 0; // handle input in option menu if (GVAR(currentMode) == "settings") exitWith { - if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith {}; + if (diag_tickTime < GVAR(keyDownTimeMenu) + 1) exitWith {}; if (diag_tickTime < GVAR(keyDownTimeAzimuth) + 0.5) then { GVAR(keyDownTabCountAzimuth) = (GETGVAR(keyDownTabCountAzimuth,0)) + 1; @@ -32,14 +33,12 @@ switch (_this select 0) do { }; GVAR(keyDownTimeAzimuth) = diag_tickTime; - - systemChat str GVAR(keyDownTabCountAzimuth);// }; if (GVAR(currentMode) == "config") exitWith { if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith {}; - systemChat "azi in config"; + ["config"] call FUNC(nextMode); }; // prevent additinal modifier input if advanced mode it set, spaghetti @@ -63,6 +62,7 @@ switch (_this select 0) do { GVAR(keyDownTimeMenu) = diag_tickTime; GVAR(keyDownTimeAzimuth) = diag_tickTime; GVAR(keyDownTabCountAzimuth) = 0; + GVAR(configTemp) = [GVAR(useFeet), GVAR(useMil)]; ["settings"] call FUNC(showText); "settings" call _fnc_setPFH; }; @@ -90,9 +90,9 @@ switch (_this select 0) do { }; case ("distance"): { + GVAR(keyDownTabCountAzimuth) = 0; // handle input in option menu - if (GVAR(currentMode) == "config") exitWith { if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith {}; @@ -103,14 +103,12 @@ switch (_this select 0) do { }; GVAR(keyDownTimeDistance) = diag_tickTime; - - systemChat str GVAR(keyDownTabCountDistance);// }; if (GVAR(currentMode) == "settings") exitWith { if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith {}; - systemChat "dis in settings" + ["settings"] call FUNC(nextMode); }; // prevent additinal modifier input if advanced mode it set, spaghetti @@ -139,7 +137,7 @@ switch (_this select 0) do { GVAR(keyDownTimeMenu) = diag_tickTime; GVAR(keyDownTimeDistance) = diag_tickTime; GVAR(keyDownTabCountDistance) = 0; - GVAR(configTemp) = [GVAR(useFeet), GVAR(useMil)]; + GVAR(configTemp) = GVAR(modeReticle); ["config"] call FUNC(showText); "config" call _fnc_setPFH; }; diff --git a/addons/vector/functions/fnc_onKeyHold.sqf b/addons/vector/functions/fnc_onKeyHold.sqf index 9cb5d25f12..17c5d3c4b1 100644 --- a/addons/vector/functions/fnc_onKeyHold.sqf +++ b/addons/vector/functions/fnc_onKeyHold.sqf @@ -222,15 +222,35 @@ switch (_this select 0) do { }; case ("settings"): { - if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith { + if (diag_tickTime < GVAR(keyDownTimeMenu) + 1) exitWith { GVAR(keyDownTimeAzimuth) = diag_tickTime; }; - /*[["meter", "feet"] select GVAR(useFeet)] call FUNC(showText); - [["deg", "mil" ] select GVAR(useMil)] call FUNC(showText);*/ + [["meter", "feet"] select (GVAR(configTemp) select 0)] call FUNC(showText); + [["deg", "mil" ] select (GVAR(configTemp) select 1)] call FUNC(showText); - if (GVAR(keyDownTabCountAzimuth) > 0 && {diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5}) exitWith { - systemChat "abort"; + if (GVAR(keyDownTabCountAzimuth) >= 5) exitWith { + GVAR(useFeet) = GVAR(configTemp) select 0; + GVAR(useMil) = GVAR(configTemp) select 1; + + ["clear_left"] call FUNC(showText); + ["clear_right"] call FUNC(showText); + ["stor"] call FUNC(showText); + + [_this select 1] call CBA_fnc_removePerFrameHandler; + + GVAR(currentMode) = ""; + + if (GVAR(holdKeyHandler) > -1) then { + GVAR(holdKeyHandler) = -1; + }; + }; + + if (GVAR(keyDownTabCountAzimuth) > 0 && {diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5}) exitWith { + + ["clear_left"] call FUNC(showText); + ["clear_right"] call FUNC(showText); + ["old_settings"] call FUNC(showText); [_this select 1] call CBA_fnc_removePerFrameHandler; @@ -240,26 +260,62 @@ switch (_this select 0) do { GVAR(holdKeyHandler) = -1; }; }; - //show current mode }; case ("config"): { - if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith { + if (diag_tickTime < GVAR(keyDownTimeMenu) + 1) exitWith { GVAR(keyDownTimeDistance) = diag_tickTime; }; - [["meter", "feet"] select (GVAR(configTemp) select 0)] call FUNC(showText); - [["deg", "mil" ] select (GVAR(configTemp) select 0)] call FUNC(showText); - - if (GVAR(keyDownTabCountDistance) > 0 && {diag_tickTime > GVAR(keyDownTimeDistance) + 0.5}) exitWith { - if (GVAR(keyDownTabCountDistance) >= 5) exitWith { - GVAR(useFeet) = GVAR(configTemp) select 0; - GVAR(useMil) = GVAR(configTemp) select 1; - - systemChat "set"; + switch (GVAR(configTemp)) do { + case (0): { + ["eret"] call FUNC(showText); + ["off"] call FUNC(showText); }; + case (1): { + ["eret"] call FUNC(showText); + ["on"] call FUNC(showText); + }; + case (2): { + ["nigt"] call FUNC(showText); + ["on"] call FUNC(showText); + }; + }; - systemChat "abort"; + if (GVAR(keyDownTabCountDistance) >= 5) exitWith { + GVAR(modeReticle) = GVAR(configTemp); + + ["clear_left"] call FUNC(showText); + ["clear_right"] call FUNC(showText); + ["stor"] call FUNC(showText); + + // set new config settings + switch (GVAR(configTemp)) do { + case (0): { + [false] call FUNC(adjustBrightness); + }; + case (1): { + [false] call FUNC(adjustBrightness); + }; + case (2): { + [true] call FUNC(adjustBrightness); + }; + }; + + [_this select 1] call CBA_fnc_removePerFrameHandler; + + GVAR(currentMode) = ""; + + if (GVAR(holdKeyHandler) > -1) then { + GVAR(holdKeyHandler) = -1; + }; + }; + + if (GVAR(keyDownTabCountDistance) > 0 && {diag_tickTime > GVAR(keyDownTimeDistance) + 0.5}) exitWith { + + ["clear_left"] call FUNC(showText); + ["clear_right"] call FUNC(showText); + ["old_config"] call FUNC(showText); [_this select 1] call CBA_fnc_removePerFrameHandler; @@ -269,9 +325,6 @@ switch (_this select 0) do { GVAR(holdKeyHandler) = -1; }; }; - //show current mode }; }; - -//systemChat str (_this select 0); diff --git a/addons/vector/functions/fnc_showP1.sqf b/addons/vector/functions/fnc_showP1.sqf index 54cbd203f4..6d7baf7412 100644 --- a/addons/vector/functions/fnc_showP1.sqf +++ b/addons/vector/functions/fnc_showP1.sqf @@ -16,8 +16,10 @@ if (_this select 0) then { (_dlgVector displayCtrl 1321) ctrlSetText QUOTE(PATHTOF(rsc\vector_1.paa)); (_dlgVector displayCtrl 1322) ctrlSetText QUOTE(PATHTOF(rsc\vector_minus.paa)); (_dlgVector displayCtrl 1323) ctrlSetText QUOTE(PATHTOF(rsc\vector_p.paa)); + (_dlgVector displayCtrl 1324) ctrlSetText ""; } else { (_dlgVector displayCtrl 1321) ctrlSetText ""; (_dlgVector displayCtrl 1322) ctrlSetText ""; (_dlgVector displayCtrl 1323) ctrlSetText ""; + (_dlgVector displayCtrl 1324) ctrlSetText ""; }; diff --git a/addons/vector/functions/fnc_showText.sqf b/addons/vector/functions/fnc_showText.sqf index 08fdb7fd96..33e1c4766f 100644 --- a/addons/vector/functions/fnc_showText.sqf +++ b/addons/vector/functions/fnc_showText.sqf @@ -33,7 +33,7 @@ switch (_this select 0) do { (_dlgVector displayCtrl 1314) ctrlSetText ""; }; - case ("night"): { + case ("nigt"): { (_dlgVector displayCtrl 1315) ctrlSetText ""; (_dlgVector displayCtrl 1316) ctrlSetText QUOTE(PATHTOF(rsc\vector_n.paa)); (_dlgVector displayCtrl 1317) ctrlSetText QUOTE(PATHTOF(rsc\vector_i.paa));