Forráskód Böngészése

Fix jammer UI, works now, rename icons and move to ui folder

m3ales 4 éve
szülő
commit
f184eab980

+ 0 - 2
addons - Copy/RD501_Main/functions/jammer/fnc_addJammerLocal.sqf

@@ -1,8 +1,6 @@
 params["_jammer", "_radius", "_strength"];
 if(isDedicated || !hasInterface) exitWith { };
-systemChat "Adding Jammer Local";
 if(player getVariable ["rd501_jammers_pfh", -1] == -1) exitWith {
-	systemChat "Adding Client Per Frame Handler";
 	private _handler = [{
 			_this call rd501_fnc_jammersPFH;
 		}, 0.5, [player]] call CBA_fnc_addPerFrameHandler;

+ 3 - 4
addons - Copy/RD501_Main/functions/jammer/fnc_jammersPFH.sqf

@@ -6,13 +6,13 @@ _args params["_player"];
 *		["bis_o1", 1000, 400]
 *	];
 */
-if(!alive _player) exitWith { systemChat format["Player dead for %1", _handle] };
+if(!alive _player) exitWith { diag_log format["Player dead for %1", _handle] };
 
 _jammers = missionNamespace getVariable ["rd501_jammers",[]];
 
 // Exit if jammer list is empty, remove PFH and rely on someone else calling it via jammer placement
 if(count _jammers == 0) exitWith {
-	systemChat "Exiting Client PFH";
+	diag_log "Exiting Client PFH";
 	[_handle] call CBA_fnc_removePerFrameHandler;
 	_player setVariable ["rd501_jammers_pfh", -1];
 	_player setVariable ["tf_receivingDistanceMultiplicator", 1];
@@ -44,5 +44,4 @@ private _interference = 1;
 
 // Set interference locally
 _player setVariable ["tf_receivingDistanceMultiplicator", _interference];
-// _player setVariable ["tf_transmittingDistanceMultiplicator", _interference]; // Unused by TFAR 0.9.7
-systemChat format["Interference: %1", _interference];
+// _player setVariable ["tf_transmittingDistanceMultiplicator", _interference]; // Unused by TFAR 0.9.7

+ 1 - 1
addons - Copy/RD501_Main/functions/jammer/fnc_jammersServerPFH.sqf

@@ -4,7 +4,7 @@ if(!isServer) exitWith {
 	[_handle] call CBA_fnc_removePerFrameHandler;
 };
 
-diag_log "Server PFH";
+diag_log "Server PFH Tick";
 private _jammers = missionNamespace getVariable ["rd501_jammers",[]];
  
 {

+ 19 - 0
addons - Copy/RD501_Zeus/XEH_PREP.sqf

@@ -0,0 +1,19 @@
+// PREP Macros
+// Basically this is just a way to have short hand produce
+// "RD501_Zeus\functions\fnc_moduleJammerSettings.sqf","rd501_zeus_fnc_moduleJammerSettings"] call CBA_fnc_compileFunction;
+// from
+// PREP(moduleJammerSettings);
+// Why?
+// Need to register functions somehow, normal arma config based is slow since it reads from disc, cba is cached in memory.
+// So we use CBA functions, macros are just a nice thing to have for ensuring convention.
+// So just add your stuff to PREP(name) where your file is in functions, and is called fnc_name.sqf
+// NOTE: this adds a zeus prefix to the function call (rd501_zeus_fnc vs rd501_fnc)
+#define PREP_CONCAT(a,b) a##b
+#define PREP_CONCAT_3(a,b,c) PREP_CONCAT(PREP_CONCAT(a,b),c)
+#define PREP_PATH PREP_CONCAT_3(RD501_Zeus,\,functions)
+#define PREP_QUOTE(quoted) #quoted
+#define PREP(func)\
+[PREP_QUOTE(PREP_CONCAT_3(PREP_PATH,\,PREP_CONCAT_3(fnc_,func,.sqf))),PREP_QUOTE(PREP_CONCAT(rd501_zeus_fnc_,func))] call CBA_fnc_compileFunction
+
+PREP(moduleJammerSettings);
+PREP(ui_jammerSettings);

+ 1 - 0
addons - Copy/RD501_Zeus/XEH_preInit.sqf

@@ -0,0 +1 @@
+#include "XEH_PREP.sqf"

+ 38 - 9
addons - Copy/RD501_Zeus/config.cpp

@@ -1,7 +1,4 @@
 #include "../RD501_main/config_macros.hpp"
-
-
-
 class CfgPatches
 {
 	class macro_patch_name(zeus)
@@ -16,16 +13,39 @@ class CfgPatches
 			macro_new_ordnance(AV7_Cluster),
 			macro_new_ordnance(ModuleSquadShield),
 			macro_new_ordnance(ModuleDioxis),
-			macro_new_ordnance(ModuleShadow)
+			macro_new_ordnance(ModuleShadow),
+			rd501_moduleJammerSettings
 		};
 		weapons[] = {};
 	};
 };
+class CfgFactionClasses {
+    class Jammers {
+        displayName = "Jammers";
+        priority = 2;
+        side = 7;
+    };
+};
 class CfgVehicles
 {
+	class Module_F;
 	class ModuleOrdnance_F;
 	class ModuleChemlight_F;
-	
+    class rd501_moduleJammerSettings: Module_F  {
+		author = "RD501";
+        category = "Jammers";
+        function = "ace_common_dummy";
+        functionPriority = 1;
+        isGlobal = 1;
+        isTriggerActivated = 0;
+        scope = 1;
+        scopeCurator = 2;
+        curatorCanAttach = 1;
+        displayName = "Add Jammer";
+        curatorInfoType = "RD501_RscJammerSettings";
+		portrait = "RD501_Zeus\ui\jammer_icon.paa";
+    };
+
 	class macro_new_ordnance(ModuleSquadShield): ModuleChemlight_F
 	{
 		author = "RD501";
@@ -34,7 +54,7 @@ class CfgVehicles
 		scopeCurator = 2;
 		category = "Ordnance";
 		displayName = "Squad Shield";
-		portrait = "RD501_Zeus\icons\wide_kite_64.paa";
+		portrait = "RD501_Zeus\ui\wide_kite_64.paa";
 		ammo = "SW_SquadShield_ammoCARGA";
 		delete Arguments;
 	};
@@ -46,7 +66,7 @@ class CfgVehicles
 		scopeCurator = 2;
 		category = "Ordnance";
 		displayName = "Dioxis Cloud";
-		portrait = "RD501_Zeus\icons\biohazard_64.paa";
+		portrait = "RD501_Zeus\ui\biohazard_64.paa";
 		ammo = macro_new_ordnance_ammo(Dioxis_long)
 		delete Arguments;
 	};
@@ -58,7 +78,7 @@ class CfgVehicles
 		scopeCurator = 2;
 		category = "Ordnance";
 		displayName = "Shadow Virus";
-		portrait = "RD501_Zeus\icons\biohazard_64.paa";
+		portrait = "RD501_Zeus\ui\biohazard_64.paa";
 		ammo = macro_new_ordnance_ammo(Shadow_long)
 		delete Arguments;
 	};
@@ -211,4 +231,13 @@ class CfgAmmo
 		CraterWaterEffects = "ImpactEffectsWaterHE";
 		ExplosionEffects = "ProtonbombAmmoExplosion";
 	};
-};
+};
+class Extended_PreInit_EventHandlers
+{
+	class RD501_Zeus_PreInit
+	{
+		init="call compileFinal preprocessFileLineNumbers 'RD501_Zeus\XEH_preInit.sqf'";
+	};
+};
+
+#include "ui\RscAttributes.hpp"

+ 12 - 0
addons - Copy/RD501_Zeus/functions/fnc_moduleJammerSettings.sqf

@@ -0,0 +1,12 @@
+params ["_logic"];
+
+if (isNull _logic) exitWith {};
+private _jammerInit = _logic getVariable ["rd501_ui_jammerInit", [300,160]];
+_attach = attachedTo _logic;
+if(isNull _attach) then {
+	[_logic, _jammerInit select 0, _jammerInit select 1] call rd501_fnc_addJammer;
+}else
+{
+	[_attach, _jammerInit select 0, _jammerInit select 1] call rd501_fnc_addJammer;
+	deleteVehicle _logic;
+};

+ 56 - 0
addons - Copy/RD501_Zeus/functions/fnc_ui_jammerSettings.sqf

@@ -0,0 +1,56 @@
+params ["_control"];
+
+private _display = ctrlParent _control;
+private _ctrlButtonOK = _display displayCtrl 1;
+private _logic = missionNamespace getVariable ["BIS_fnc_initCuratorAttributes_target",objNull];
+
+_control ctrlRemoveAllEventHandlers "setFocus";
+
+private _fnc_sliderMove = {
+    params ["_slider"];
+    private _idc = ctrlIDC _slider;
+    private _logic = missionNamespace getVariable["BIS_fnc_initCuratorAttributes_target",objNull];
+    if (isNull _logic) exitWith {};
+    private _jammerInit = _logic getVariable ["rd501_ui_jammerInit", [300,160]];
+    if(_idc == 58402) then {
+        // Radius
+        private _curVal = _jammerInit select 0;
+        _slider ctrlSetTooltip format ["%1%3 (default %2%3)", round(sliderPosition _slider), round(_curVal), " metres"];
+    };
+    if(_idc == 58403) then {
+        // Strength
+        private _curVal = _jammerInit select 1;
+        _slider ctrlSetTooltip format ["%1%3 (default %2%3)", round(sliderPosition _slider), round(_curVal), " MW"];
+    };
+};
+
+private _logic = missionNamespace getVariable["BIS_fnc_initCuratorAttributes_target",objNull];
+private _jammerInit = _logic getVariable ["rd501_ui_jammerInit", [300,160]];
+{
+    private _slider = _display displayCtrl _x;
+    _slider sliderSetRange [0, 2000];
+    _slider sliderSetSpeed [1,10];
+    _slider sliderSetPosition (_jammerInit select _forEachIndex);
+    _slider ctrlAddEventHandler ["SliderPosChanged", _fnc_sliderMove];
+    _slider call _fnc_sliderMove;
+} forEach [58402, 58403];
+
+private _fnc_onUnload = {
+    private _logic =  missionNamespace getVariable ["BIS_fnc_initCuratorAttributes_target",objNull];
+    if (isNull _logic) exitWith { };
+    deleteVehicle _logic;
+};
+
+private _fnc_onConfirm = {
+    params [["_ctrlButtonOK", controlNull, [controlNull]]];
+
+    private _display = ctrlparent _ctrlButtonOK;
+    if (isNull _display) exitWith { };
+    private _logic = missionNamespace getVariable["BIS_fnc_initCuratorAttributes_target",objNull];
+    if (isNull _logic) exitWith { };
+    private _jammerInit = _logic setVariable ["rd501_ui_jammerInit", [sliderPosition (_display displayCtrl 58402), sliderPosition (_display displayCtrl 58403)]];
+    [_logic] call rd501_zeus_fnc_moduleJammerSettings;
+};
+
+_display displayAddEventHandler ["unload", _fnc_onUnload];
+_ctrlButtonOK ctrlAddEventHandler ["buttonclick", _fnc_onConfirm];

+ 77 - 0
addons - Copy/RD501_Zeus/ui/RscAttributes.hpp

@@ -0,0 +1,77 @@
+class RscControlsGroup;
+class RscControlsGroupNoScrollbars;
+class RscText;
+class RscListbox;
+class RscCombo;
+class RscEdit;
+class RscXSliderH;
+class RscCheckBox;
+class RscActivePicture;
+class RscMapControl;
+class RscPicture;
+class ctrlToolbox;
+class RscButton;
+
+class RscDisplayAttributes {
+    class Controls {
+        class Background;
+        class Title;
+        class Content: RscControlsGroup {
+            class controls;
+        };
+        class ButtonOK;
+        class ButtonCancel;
+    };
+};
+
+class RD501_RscJammerSettings: RscDisplayAttributes {
+    onLoad = "['onLoad', _this, ""RD501_RscJammerSettings""] call ace_zeus_fnc_zeusAttributes";
+    onUnload = "['onUnload', _this, ""RD501_RscJammerSettings""] call ace_zeus_fnc_zeusAttributes";
+    class Controls: Controls {
+        class Background: Background {};
+        class Title: Title {};
+        class Content: Content {
+            class Controls {
+                class RD501_JammerSettings: RscControlsGroupNoScrollbars {
+                    onSetFocus = "_this call rd501_zeus_fnc_ui_jammerSettings";
+                    idc = 58401;
+                    x = 0;
+                    y = 0;
+                    w = (26 * (((safezoneW / safezoneH) min 1.2) / 40));
+                    h = (2 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
+                    class Controls {
+                        class Title1: RscText {
+                            idc = -1;
+                            text = "Jammer Range";
+                            toolTip = "Jammer's effective Radius";
+                            x = 0;
+                            y = 0;
+                            w = (10 * (((safezoneW / safezoneH) min 1.2) / 40));
+                            h = (1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
+                            colorBackground[] = {0,0,0,0.5};
+                        };
+                        class Jammer_Radius: RscXSliderH {
+                            idc = 58402;
+                            x = (10.1 * (((safezoneW / safezoneH) min 1.2) / 40));
+                            y = 0;
+                            w = (15.9 * (((safezoneW / safezoneH) min 1.2) / 40));
+                            h = (1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
+                        };
+                        class Title2: Title1 {
+                            idc = -1;
+                            text = "Jammer Strength";
+                            toolTip = "At what portion of the distance a SR radio will become useless at 50m. 160 will place it at 1/2 the radius. Handle with care.";
+                            y = (1.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
+                        };
+                        class Jammer_Strength: Jammer_Radius {
+                            idc = 58403;
+                            y = (1.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
+                        };
+                    };
+                };
+            };
+        };
+        class ButtonOK: ButtonOK {};
+        class ButtonCancel: ButtonCancel {};
+    };
+};

+ 0 - 0
addons - Copy/RD501_Zeus/icons/biohazard_64.paa → addons - Copy/RD501_Zeus/ui/biohazard_64.paa


BIN
addons - Copy/RD501_Zeus/ui/jammer_icon.paa


+ 0 - 0
addons - Copy/RD501_Zeus/icons/wide_kite_64.paa → addons - Copy/RD501_Zeus/ui/wide_kite_64.paa