2d scripted optics

This commit is contained in:
commy2 2015-04-03 12:33:12 +02:00
parent ba00a31523
commit 6d3ddfeb5e
19 changed files with 181 additions and 77 deletions

View File

@ -0,0 +1 @@
z\ace\addons\optics

View File

@ -0,0 +1,12 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

View File

@ -0,0 +1,31 @@
class RscText;
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 controlsBackground {
class Debug_RscElement: RscText {
idc = 1;
style = 48;
size = 1;
sizeEx = 0;
font = "TahomaB";
text = "";
x = 0;
y = 0;
w = 0;
h = 0;
};
};
};
};

View File

@ -0,0 +1,37 @@
class CfgWeapons {
class ItemCore;
class InventoryOpticsItem_Base_F;
class optic_DMS: ItemCore {
class ItemInfo: InventoryOpticsItem_Base_F {
class OpticsModes {
class Snip;
};
};
};
class ACE_optic_DMS: optic_DMS {
author = "$STR_ACE_Common_ACETeam";
_generalMacro = "ACE_optic_DMS";
displayName = "LOCALIZE ACE DMS";
//descriptionShort = "$STR_A3_CFGWEAPONS_ACC_DMS1";
class ItemInfo: ItemInfo {
modelOptics = QUOTE(PATHTOF(models\ace_shortdot_optics.p3d));
class OpticsModes: OpticsModes {
class Snip: Snip {
opticsZoomMin = 0.05;
opticsZoomMax = 0.3;
opticsZoomInit = 0.3;
discretefov[] = {};
modelOptics[] = {};
};
};
};
};
};
class SlotInfo;
class CowsSlot: SlotInfo {
compatibleItems[] += {"ACE_optic_DMS"};
};

View File

@ -0,0 +1,13 @@
// 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

@ -0,0 +1,9 @@
#include "script_component.hpp"
ADDON = false;
PREP(handleCameraViewChanged);
PREP(handlePlayerInventoryChanged);
PREP(onDraw3D);
ADDON = true;

19
addons/optics/config.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author[] = {""};
authorUrl = "";
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "CfgWeapons.hpp"
#include "CfgRscTitles.hpp"

View File

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

View File

@ -0,0 +1,30 @@
// 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 = "";
_opticsScript = {};
};
GVAR(usedOptics) set [_forEachIndex, [_x, _opticsTexture, _opticsScript]];
};
} forEach _usedOptics;
//(uiNamespace getVariable "ACE_ctrlShortdotReticle") ctrlSetText QUOTE(PATHTOF(reticles\ace_shortdot_reticle_1.paa));

View File

@ -1,6 +1,15 @@
// by commy2 // by commy2
#include "script_component.hpp" #include "script_component.hpp"
if (GVAR(showShortdot)) then {
private "_control"; private "_control";
_control = uiNamespace getVariable ["ACE_ctrlShortdotReticle", controlNull]; _control = uiNamespace getVariable ["ACE_ctrlShortdotReticle", controlNull];

View File

@ -0,0 +1 @@
#include "\z\ace\addons\optics\script_component.hpp"

View File

@ -0,0 +1,12 @@
#define COMPONENT optics
#include "\z\ace\addons\main\script_mod.hpp"
#ifdef DEBUG_ENABLED_OPTICS
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_ENABLED_OPTICS
#define DEBUG_SETTINGS DEBUG_ENABLED_OPTICS
#endif
#include "\z\ace\addons\main\script_macros.hpp"

View File

@ -40,29 +40,4 @@ class CfgWeapons {
}; };
}; };
}; };
class ACE_optic_DMS: optic_DMS {
author = "$STR_ACE_Common_ACETeam";
_generalMacro = "ACE_optic_DMS";
displayName = "LOCALIZE ACE DMR";
//descriptionShort = "$STR_A3_CFGWEAPONS_ACC_DMS1";
class ItemInfo: ItemInfo {
modelOptics = QUOTE(PATHTOF(ace_shortdot_optics.p3d));
class OpticsModes: OpticsModes {
class Snip: Snip {
opticsZoomMin = 0.05;
opticsZoomMax = 0.3;
opticsZoomInit = 0.3;
discretefov[] = {};
modelOptics[] = {};
};
};
};
};
};
class SlotInfo;
class CowsSlot: SlotInfo {
compatibleItems[] += {"ACE_optic_DMS"};
}; };

View File

@ -68,30 +68,6 @@ 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 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 RscInGameUI { class RscInGameUI {

View File

@ -92,30 +92,3 @@ if !(hasInterface) exitWith {};
}, },
{false}, {false},
[201, [false, true, false]], false] call cba_fnc_addKeybind; [201, [false, true, false]], false] call cba_fnc_addKeybind;
// init shortdot
GVAR(showShortdot) = false;
["playerInventoryChanged", {
if (_this select 1 isEqualTo []) exitWith {}; //@todo fix eh
private "_showShortdot";
_showShortdot = _this select 1 select 9 select 2 == "ACE_optic_DMS";
if (GVAR(showShortdot)) then {
if (!_showShortdot) then {
// hide control and turn onDraw handler off
(uiNamespace getVariable ["ACE_ctrlShortdotReticle", controlNull]) ctrlShow false;
GVAR(showShortdot) = false;
};
} else {
if (_showShortdot) then {
// create control and turn onDraw handler on
([QGVAR(reticle)] call BIS_fnc_rscLayer) cutRsc ["ACE_Shortdot_Reticle", "PLAIN", 0, false];
(uiNamespace getVariable "ACE_ctrlShortdotReticle") ctrlSetText QUOTE(PATHTOF(data\reticles\ace_shortdot_reticle_1.paa));
GVAR(showShortdot) = true;
};
};
}] call EFUNC(common,addEventHandler);
addMissionEventHandler ["Draw3D", {if (GVAR(showShortdot)) then {call FUNC(onDrawShortdot)};}];

View File

@ -7,7 +7,6 @@ PREP(canAdjustScope);
PREP(firedEH); PREP(firedEH);
PREP(getOptics); PREP(getOptics);
PREP(inventoryCheck); PREP(inventoryCheck);
PREP(onDrawShortdot);
PREP(showZeroing); PREP(showZeroing);
GVAR(fadeScript) = scriptNull; GVAR(fadeScript) = scriptNull;