simplify optics

This commit is contained in:
commy2 2015-04-03 19:25:28 +02:00
parent b0575bad21
commit 025c1ef63f
10 changed files with 76 additions and 111 deletions

View File

@ -7,11 +7,8 @@ GVAR(position) = [0,0,0];
#include "initKeybinds.sqf"
["infoDisplayChanged", {
private "_control";
_control = (_this select 0) displayCtrl 151;
if (!isNull _control && {_this select 1 == "Any"}) then {
uiNamespace setVariable ['ACE_dlgRangefinder', _this select 0];
_control ctrlSetTextColor [0, 0, 0, 0];
if (!isNull ((_this select 0) displayCtrl 1713151)) then {
uiNamespace setVariable ["ACE_dlgRangefinder", _this select 0];
((_this select 0) displayCtrl 151) ctrlSetTextColor [0,0,0,0];
};
}] call EFUNC(common,addEventHandler);

View File

@ -1,28 +1,44 @@
class RscOpticsValue;
class RscMapControl;
class RscText;
class RscTitles {
class ACE_Shortdot_Reticle {
idd = -1;
onLoad = "uiNamespace setVariable ['ACE_ctrlShortdotReticle', (_this select 0) displayCtrl 1];";
duration = 999999;
fadeIn = 0;
fadeOut = 0;
name = "ACE_Shortdot_Reticle";
class RscInGameUI {
class RscUnitInfo;
class RscWeaponZeroing: RscUnitInfo {
class CA_Zeroing;
};
class controlsBackground {
class Debug_RscElement: RscText {
idc = 1;
style = 48;
size = 1;
sizeEx = 0;
font = "TahomaB";
text = "";
x = 0;
y = 0;
w = 0;
h = 0;
};
class ACE_RscWeaponZeroing: RscWeaponZeroing {
controls[] = {"CA_Zeroing","CA_FOVMode","ACE_DrawReticleHelper","ACE_ScriptedReticle"};
class CA_Zeroing: CA_Zeroing {};
class CA_FOVMode: RscOpticsValue { // idea by Taosenai. Apparently this can be used via isNil check to determine wheter the scope or the kolimator is used
idc = 154;
style = 2;
colorText[] = {0,0,0,0};
x = 0;
y = 0;
w = 0;
h = 0;
};
class ACE_DrawReticleHelper: RscMapControl {
onDraw = QUOTE([ctrlParent (_this select 0)] call DFUNC(onDrawScope));
idc = -1;
w = 0;
h = 0;
};
class ACE_ScriptedReticle: RscText {
idc = 1713154;
style = 48;
size = 1;
sizeEx = 0;
text = QUOTE(PATHTOF(reticles\ace_shortdot_reticle_1.paa));
w = 0;
h = 0;
};
};
};

View File

@ -1,3 +1,4 @@
class CfgWeapons {
class ItemCore;
class InventoryOpticsItem_Base_F;
@ -6,6 +7,7 @@ class CfgWeapons {
class ItemInfo: InventoryOpticsItem_Base_F {
class OpticsModes {
class Snip;
class Iron;
};
};
};
@ -15,6 +17,8 @@ class CfgWeapons {
_generalMacro = "ACE_optic_DMS";
displayName = "LOCALIZE ACE DMS";
//descriptionShort = "$STR_A3_CFGWEAPONS_ACC_DMS1";
weaponInfoType = "ACE_RscWeaponZeroing";
class ItemInfo: ItemInfo {
modelOptics = QUOTE(PATHTOF(models\ace_shortdot_optics.p3d));
@ -26,6 +30,8 @@ class CfgWeapons {
discretefov[] = {};
modelOptics[] = {};
};
class Iron: Iron {};
};
};
};

View File

@ -1,13 +1,2 @@
// by commy2
#include "script_component.hpp"
// init RSC
([QGVAR(reticle)] call BIS_fnc_rscLayer) cutRsc ["ACE_Shortdot_Reticle", "PLAIN", 0, false];
GVAR(isUsingOptic) = false;
["cameraViewChanged", {_this call FUNC(handleCameraViewChanged)}] call EFUNC(common,addEventHandler);
GVAR(usedOptics) = [["","",{}],["","",{}],["","",{}]];
["playerInventoryChanged", {_this call FUNC(handlePlayerInventoryChanged)}] call EFUNC(common,addEventHandler);
addMissionEventHandler ["Draw3D", {call FUNC(onDraw3D)}];

View File

@ -2,9 +2,6 @@
ADDON = false;
PREP(drawShortdotScript);
PREP(handleCameraViewChanged);
PREP(handlePlayerInventoryChanged);
PREP(onDraw3D);
PREP(onDrawScope);
ADDON = true;

View File

@ -1,20 +0,0 @@
// by commy2
#include "script_component.hpp"
private ["_control", "_zoom"];
_control = _this select 0;
_zoom = _this select 1;
private ["_sizeX", "_sizeY"];
_sizeX = _zoom/4;
_sizeY = _sizeX*safezoneW/safezoneH;
_control ctrlSetPosition [
safezoneX+0.5*safezoneW-0.5*_sizeX,
safezoneY+0.5*safezoneH-0.5*_sizeY,
_sizeX,
_sizeY
];
_control ctrlCommit 0;

View File

@ -1,7 +0,0 @@
// by commy2
#include "script_component.hpp"
private "_cameraView";
_cameraView = _this select 1;
GVAR(isUsingOptic) = _cameraView == "GUNNER";

View File

@ -1,28 +0,0 @@
// by commy2
#include "script_component.hpp"
private "_usedOptics";
_usedOptics = if (isNull (_this select 0)) then {["","",""]} else { //@todo fix eh
[
_this select 1 select 9 select 2,
_this select 1 select 12 select 2,
_this select 1 select 15 select 2
]
};
// update onDraw functions
{
if (_x != GVAR(usedOptics) select _forEachIndex select 0) then {
private ["_opticsTexture", "_opticsScript"];
_opticsTexture = "";
_opticsScript = {};
if (_x != "") then { // @todo
_opticsTexture = QUOTE(PATHTOF(reticles\ace_shortdot_reticle_1.paa));
_opticsScript = FUNC(drawShortdotScript);
};
GVAR(usedOptics) set [_forEachIndex, [_x, _opticsTexture, _opticsScript]];
};
} forEach _usedOptics;

View File

@ -1,14 +0,0 @@
// by commy2
#include "script_component.hpp"
private "_control";
_control = uiNamespace getVariable ["ACE_ctrlShortdotReticle", controlNull];
if !(GVAR(isUsingOptic) || {currentWeapon ACE_player != primaryWeapon ACE_player}) exitWith {
_control ctrlShow false;
};
_control ctrlSetText (GVAR(usedOptics) select 0 select 1);
_control ctrlShow true;
[_control, call EFUNC(common,getZoom)] call (GVAR(usedOptics) select 0 select 2);

View File

@ -0,0 +1,29 @@
// by commy2
#include "script_component.hpp"
disableSerialization;
private ["_display", "_control"];
_display = _this select 0;
_control = _display displayCtrl 1713154;
if (!ctrlShown (_display displayCtrl 154)) exitWith {
_control ctrlShow false;
};
private ["_sizeX", "_sizeY"];
_sizeX = (call EFUNC(common,getZoom))/4;
_sizeY = _sizeX*safezoneW/safezoneH;
_control ctrlSetPosition [
safezoneX+0.5*safezoneW-0.5*_sizeX,
safezoneY+0.5*safezoneH-0.5*_sizeY,
_sizeX,
_sizeY
];
_control ctrlCommit 0;
_control ctrlShow true;