Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bwa3_comp_ace/CfgEventhandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
13 changes: 13 additions & 0 deletions bwa3_comp_ace/CfgMagazines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ class CfgMagazines {
ACE_isBelt = 1;
};

class 60Rnd_30mm_APFSDS_shells;
class BWA3_240Rnd_APFSDS_shells: 60Rnd_30mm_APFSDS_shells {
BWA3_MagazineRearmTime = 30;
};
class 140Rnd_30mm_MP_shells;
class BWA3_160Rnd_HE_shells: 140Rnd_30mm_MP_shells {
BWA3_MagazineRearmTime = 30;
};

class BWA3_160Rnd_ABM_shells: BWA3_160Rnd_HE_shells {
BWA3_MagazineRearmTime = 30;
};

class BWA3_DM31AT_Mag: CA_Magazine {
ACE_explosives_Placeable = 1;
useAction = 0;
Expand Down
22 changes: 22 additions & 0 deletions bwa3_comp_ace/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ class CfgVehicles {
class ACE_Actions: ACE_Actions {
class ACE_MainActions: ACE_MainActions {
position = "[0,-1.0,1.3]";
class BWA3_MagazineDialog {
displayName = "$STR_BWA3_Comp_Ace_ConfigureAmmoLoad";
selection = "";
position = "";
showDisabled = 0;
priority = 2;
distance = 4;
icon = "\A3\ui_f\data\igui\cfg\simpletasks\types\rearm_ca.paa";
condition = "[_target] call BWA3_fnc_canOpenMagazineDialog";
statement = "[_target,[0]] call BWA3_fnc_OpenMagazineDialog";
};
};

class BWA3_CamoNet_show {
Expand Down Expand Up @@ -160,6 +171,17 @@ class CfgVehicles {
class ACE_Actions: ACE_Actions {
class ACE_MainActions: ACE_MainActions {
position = "[0,-1.5,1.3]";
class BWA3_MagazineDialog {
displayName = "$STR_BWA3_Comp_Ace_ConfigureAmmoLoad";
selection = "";
position = "";
showDisabled = 0;
priority = 2;
distance = 4;
icon = "\A3\ui_f\data\igui\cfg\simpletasks\types\rearm_ca.paa";
condition = "[_target] call BWA3_fnc_canOpenMagazineDialog";
statement = "[_target,[0]] call BWA3_fnc_OpenMagazineDialog";
};
};

class BWA3_CamoNet_show {
Expand Down
3 changes: 3 additions & 0 deletions bwa3_comp_ace/XEH_PREP.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PREP(canOpenMagazineDialog);
PREP(OpenMagazineDialog);
PREP(loadMagazines);
21 changes: 21 additions & 0 deletions bwa3_comp_ace/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "script_component.h"

ADDON = false;

#include "XEH_PREP.sqf"

ADDON = true;

If (isNil "BWA3_MagazineDialogDistance") then {
BWA3_MagazineDialogDistance = 25;
};

[
"BWA3_MagazineDialogAllowed",
"CHECKBOX",
"STR_BWA3_Comp_Ace_ConfigureMagazinesLoadAllowed",
localize "STR_BWA3_FactionClassBundeswehrName",
true,
1
] call CBA_Settings_fnc_init;

4 changes: 3 additions & 1 deletion bwa3_comp_ace/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = 0.1;
requiredAddons[] = {BWA3_Common, BWA3_Eagle, BWA3_Weapons, BWA3_VehicleWeapons, BWA3_Explosives, BWA3_Units, BWA3_Puma, BWA3_Leopard2A6M, BWA3_Tiger};
requiredAddons[] = {BWA3_Common, BWA3_Eagle, BWA3_Weapons, BWA3_VehicleWeapons, BWA3_Explosives, BWA3_Units, BWA3_Puma, BWA3_Leopard2A6M, BWA3_Tiger, ace_interact_menu};
versionAr[] = {1,0,0};
};
};
Expand All @@ -16,3 +16,5 @@ class CfgPatches {
#include "CfgAmmo.hpp"
#include "CfgGlasses.hpp"
#include "CfgRecoils.hpp"
#include "CfgEventhandlers.hpp"
#include "dialog.hpp"
137 changes: 137 additions & 0 deletions bwa3_comp_ace/dialog.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
copied macros from: "\a3\ui_f\hpp\defineCommon.inc"
*/
#define GUI_GRID_WAbs ((safezoneW / safezoneH) min 1.2)
#define GUI_GRID_HAbs (GUI_GRID_WAbs / 1.2)
#define GUI_GRID_W (GUI_GRID_WAbs / 40)
#define GUI_GRID_H (GUI_GRID_HAbs / 25)
#define GUI_GRID_CENTER_X (safezoneX + (safezoneW - GUI_GRID_WAbs)/2)
#define GUI_GRID_CENTER_Y (safezoneY + (safezoneH - GUI_GRID_HAbs)/2)

/*extern*/ class RscText;
/*extern*/ class RscButtonMenu;

class BWA3_MagazineDialog {
idd = IDD_BWA3_MAGAZINEDIALOG;
name = "$STR_BWA3_Comp_Ace_MagazineDialog";
enableSimulation = 1;

class Controls {
class TextTitlebar: RscText {
idc = IDC_BWA3_MAGAZINEDIALOG_TITLE;
text = "$STR_BWA3_Comp_Ace_MagazineDialog";
x = GUI_GRID_CENTER_X + GUI_GRID_W * 8;
y = GUI_GRID_CENTER_Y;
w = GUI_GRID_W * 24;
h = GUI_GRID_H;
sizeEx = GUI_GRID_H;
colorBackground[] = {"(profileNamespace getVariable ['GUI_BCG_RGB_R', 0.13])","(profileNamespace getVariable ['GUI_BCG_RGB_G', 0.54])","(profileNamespace getVariable ['GUI_BCG_RGB_B', 0.21])",1};
};
class BackgroundDialog: RscText {
idc = IDC_BWA3_MAGAZINEDIALOG_BACK;
x = GUI_GRID_CENTER_X + GUI_GRID_W * 8;
y = GUI_GRID_CENTER_Y + GUI_GRID_H;
w = GUI_GRID_W * 24;
h = GUI_GRID_H * 15;
colorBackground[] = {0,0,0,0.5};
text = "";
};
class ButtonApply: RscButtonMenu {
idc = 1;
text = "$STR_ui_debug_but_apply";
x = GUI_GRID_CENTER_X + GUI_GRID_W * 24;
y = GUI_GRID_CENTER_Y + GUI_GRID_H * 16;
w = GUI_GRID_W * 8;
h = GUI_GRID_H;
};
class ButtonClose: ButtonApply {
idc = 2;
text = "$STR_disp_cancel";
x = GUI_GRID_CENTER_X + GUI_GRID_W * 16;
};
class ControlsTable {
idc = IDC_BWA3_MAGAZINEDIALOG_CONTROLSTABLE;
x = GUI_GRID_CENTER_X + GUI_GRID_W * 9;
y = GUI_GRID_CENTER_Y + GUI_GRID_H * 2;
w = GUI_GRID_W * 22;
h = GUI_GRID_H * 13;

type = 19;
style = 0x10;

lineSpacing = 0.1 * GUI_GRID_H;
rowHeight = 1.1 * GUI_GRID_H;
headerHeight = 1.2 * GUI_GRID_H;

firstIDC = IDC_BWA3_MAGAZINEDIALOG_CONTROLSTABLE_START;
lastIDC = IDC_BWA3_MAGAZINEDIALOG_CONTROLSTABLE_END;

selectedRowColorFrom[] = {0.7, 0.85, 1, 0.25};
selectedRowColorTo[] = {0.7, 0.85, 1, 0.5};
selectedRowAnimLength = 1.2;

class VScrollBar {
color[] = {1,1,1,0.6};
colorActive[] = {1,1,1,1};
colorDisabled[] = {1,1,1,0.3};
thumb = "\A3\ui_f\data\gui\cfg\scrollbar\thumb_ca.paa";
arrowEmpty = "\A3\ui_f\data\gui\cfg\scrollbar\arrowEmpty_ca.paa";
arrowFull = "\A3\ui_f\data\gui\cfg\scrollbar\arrowFull_ca.paa";
border = "\A3\ui_f\data\gui\cfg\scrollbar\border_ca.paa";
shadow = 0;
scrollSpeed = 0.06;
width = GUI_GRID_W * 0.8;
autoScrollEnabled = 0;
autoScrollDelay = 1;
autoScrollRewind = 1;
autoScrollSpeed = 1;
};
class HScrollBar: VScrollBar {
height = 0;
width = 0;
};
class HeaderTemplate {
class HeaderBackground {
controlBaseClassPath[] = {"RscText"};
columnX = 0;
columnW = GUI_GRID_W * 22;
controlOffsetY = 0;
};
class Column1 {
controlBaseClassPath[] = {"RscText"};
columnX = GUI_GRID_W * 3;
columnW = GUI_GRID_W * 16;
controlOffsetY = 0;
};
};
class RowTemplate {
class RowBackground {
controlBaseClassPath[] = {"RscText"};
columnX = 0;
columnW = GUI_GRID_W * 22;
controlOffsetY = 0;
};
class Column1 {
controlBaseClassPath[] = {"RscText"};
columnX = 0;
columnW = 7 * GUI_GRID_W;
controlOffsetY = 0;
};
class Column2 {
controlBaseClassPath[] = {"RscXSliderH"};
columnX = 8 * GUI_GRID_W;
columnW = 11 * GUI_GRID_W;
controlOffsetY = 0.3 * GUI_GRID_H;
controlH = 0.8 * GUI_GRID_H;
};
class Column3 {
controlBaseClassPath[] = {"RscEdit"};
columnX = 20 * GUI_GRID_W;
columnW = 2 * GUI_GRID_W;
controlOffsetY = 0.3 * GUI_GRID_H;
controlH = 1 * GUI_GRID_H;
};
};
};
};
};
7 changes: 7 additions & 0 deletions bwa3_comp_ace/functions/fn_canOpenMagazineDialog.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
params ["_target"];

private _vehicles = nearestObjects [_target, ["Air", "LandVehicle", "Slingload_base_F", "ReammoBox_F"], BWA3_MagazineDialogDistance];
private _filter = ["transportAmmo", "ace_rearm_defaultSupply"] select (["ace_rearm"] call ace_common_fnc_isModLoaded);
private _rearmVehicles = {(getNumber (configFile >> "CfgVehicles" >> typeOf _x >> _filter)) > 0} count _vehicles;

(_rearmVehicles > 0 && {[ace_player, _target] call ace_common_fnc_canInteractWith} && {missionNamespace getVariable ["BWA3_MagazineDialogAllowed", true]})
55 changes: 55 additions & 0 deletions bwa3_comp_ace/functions/fn_loadMagazines.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
params ["_vehicle", "_turret", ["_magazines", [], [[]]]];

If (_magazines isEqualTo []) exitWith {};

// magazine specific reloadTime
private _reloadTime = getNumber(configFile >> "CfgMagazines" >> ((_magazines select 0) select 0) >> "BWA3_MagazineRearmTime");
If (_reloadTime == 0) then {_reloadTime = 7;};

private _curMagazine = (_magazines select 0) select 0;
private _addMagazine = ({(_x select 0) isEqualTo _curMagazine} count ((magazinesAllTurrets _vehicle) select {((_x select 1) isEqualTo _turret) && ((_x select 2) > 0)})) < ((_magazines select 0) select 1);



[
_reloadTime,
[_vehicle, _turret, _magazines],
{
(_this select 0) params ["_vehicle", "_turret", "_magazines"];

(_magazines select 0) params ["_curMagazine", "_targetAmount"];

private _curAmount = {(_x select 0) isEqualTo _curMagazine} count ((magazinesAllTurrets _vehicle) select {((_x select 1) isEqualTo _turret) && ((_x select 2) > 0)});

private _modify = _targetAmount - _curAmount;

If (_modify < 0) then {
_vehicle removeMagazinesTurret [_curMagazine, _turret];
for "_i" from 1 to (_curAmount - 1) do {
_vehicle addMagazineTurret [_curMagazine, _turret];
};
};
If (_modify > 0) then {
_vehicle removeMagazinesTurret [_curMagazine, _turret];
for "_i" from (_curAmount + 1) to 1 step -1 do {
_vehicle addMagazineTurret [_curMagazine, _turret];
};
};
If (abs _modify <= 1) then {
_magazines deleteAt 0;
};

[_vehicle, _turret, _magazines] call BWA3_fnc_loadMagazines;
},
{
[localize "STR_BWA3_Comp_Ace_loadingStopped", false, 5] call ace_common_fnc_displayText;
},
If (_addMagazine) then {
format[localize "STR_BWA3_Comp_Ace_addMagazine", getText(configFile >> "CfgMagazines" >> _curMagazine >> "displayNameShort")];
} else {
format[localize "STR_BWA3_Comp_Ace_removeMagazine", getText(configFile >> "CfgMagazines" >> _curMagazine >> "displayNameShort")];
},
{
[ACE_player, _vehicle] call ace_common_fnc_canInteractWith
}
] call ace_common_fnc_progressBar;
Loading