Skip to content

Commit

Permalink
Merge pull request #291 from CBATeam/sortcommon4
Browse files Browse the repository at this point in the history
rework common module
  • Loading branch information
Killswitch00 committed Mar 5, 2016
2 parents 579b0a5 + b60eb4a commit 16f9647
Show file tree
Hide file tree
Showing 93 changed files with 2,344 additions and 3,648 deletions.
668 changes: 119 additions & 549 deletions addons/common/CfgFunctions.hpp

Large diffs are not rendered by default.

89 changes: 3 additions & 86 deletions addons/common/CfgPerFrame.hpp
Original file line number Diff line number Diff line change
@@ -1,86 +1,3 @@
// Control types
#define CT_STATIC 0
#define CT_BUTTON 1
#define CT_EDIT 2
#define CT_SLIDER 3
#define CT_COMBO 4
#define CT_LISTBOX 5
#define CT_TOOLBOX 6
#define CT_CHECKBOXES 7
#define CT_PROGRESS 8
#define CT_HTML 9
#define CT_STATIC_SKEW 10
#define CT_ACTIVETEXT 11
#define CT_TREE 12
#define CT_STRUCTURED_TEXT 13
#define CT_CONTEXT_MENU 14
#define CT_CONTROLS_GROUP 15
#define CT_SHORTCUT_BUTTON 16 // Arma 2 - textured button

#define CT_XKEYDESC 40
#define CT_XBUTTON 41
#define CT_XLISTBOX 42
#define CT_XSLIDER 43
#define CT_XCOMBO 44
#define CT_ANIMATED_TEXTURE 45
#define CT_OBJECT 80
#define CT_OBJECT_ZOOM 81
#define CT_OBJECT_CONTAINER 82
#define CT_OBJECT_CONT_ANIM 83
#define CT_LINEBREAK 98
#define CT_USER 99
#define CT_MAP 100
#define CT_MAP_MAIN 101
#define CT_List_N_Box 102 // Arma 2 - N columns list box


// Static styles
#define ST_POS 0x0F
#define ST_HPOS 0x03
#define ST_VPOS 0x0C
#define ST_LEFT 0x00
#define ST_RIGHT 0x01
#define ST_CENTER 0x02
#define ST_DOWN 0x04
#define ST_UP 0x08
#define ST_VCENTER 0x0c

#define ST_TYPE 0xF0
#define ST_SINGLE 0
#define ST_MULTI 16
#define ST_TITLE_BAR 32
#define ST_PICTURE 48
#define ST_FRAME 64
#define ST_BACKGROUND 80
#define ST_GROUP_BOX 96
#define ST_GROUP_BOX2 112
#define ST_HUD_BACKGROUND 128
#define ST_TILE_PICTURE 144
#define ST_WITH_RECT 160
#define ST_LINE 176

#define ST_SHADOW 0x100
#define ST_NO_RECT 0x200
#define ST_KEEP_ASPECT_RATIO 0x800

#define ST_TITLE ST_TITLE_BAR + ST_CENTER

// Slider styles
#define SL_DIR 0x400
#define SL_VERT 0
#define SL_HORZ 0x400

#define SL_TEXTURES 0x10

// Listbox styles
#define LB_TEXTURES 0x10
#define LB_MULTI 0x20

#define FontM "Bitstream"
#define DEFAULTFONT FontM

#define true 1
#define false 0

class RscMapControl {
class Task;
Expand Down Expand Up @@ -112,6 +29,7 @@ class RscMapControl {
class WaypointCompleted;
class ActiveMarker;
};

class CBA_Dummy_Map: RscMapControl {
idc = -1;

Expand Down Expand Up @@ -438,22 +356,21 @@ class CBA_Dummy_Map: RscMapControl {
};
};


class RscTitles {
class CBA_FrameHandlerTitle {
idd = 40121;
movingEnable = 1;
enableSimulation = 1;
enableDisplay = 1;

onLoad = QUOTE(_this call CBA_common_fnc_perFrameEngine);
onLoad = QUOTE(_this call FUNC(perFrameEngine));

duration = 99999999;
fadein = 0;
fadeout = 0;
name = "CBA_FrameHandlerTitle";
class controlsBackground {
class dummy_map : CBA_Dummy_Map {
class dummy_map: CBA_Dummy_Map {
idc = 40122;
x = -10;
y = -10;
Expand Down
3 changes: 2 additions & 1 deletion addons/common/CfgRemoteExec.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class CfgRemoteExec {

class CfgRemoteExec { // white listing currently broken! (1.56)
class Functions {
// Used by CBA_fnc_switchPlayer
class GVAR(setVehVarName) {
Expand Down
52 changes: 13 additions & 39 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

LOG(MSG_INIT);

// if (true) exitWith {};

// NOTE: Due to the way the BIS functions initializations work, and the requirement of BIS_functions_mainscope to be a unit (in a group)
// the logic is created locally on MP dedicated client, to still allow this early, called precompilation of the functions.
// But initialization doesn't officially finish until the official (server created / mission.sqm included) logic is available.
// In SP or as server (dedicated or clientServer), the logic is created with group and createUnit.
SLX_XEH_STR spawn {
0 spawn {
waitUntil {!isNil "bis_functions_mainscope"};
waitUntil {!isNull bis_functions_mainscope};
CBA_logic = bis_functions_mainscope;
Expand All @@ -18,21 +16,6 @@ SLX_XEH_STR spawn {
#endif
};

// A2 / Operation Arrowhead, standalone / combined operations check
/*
TRACE_1("OA Check",nil);
private ["_hasCbaOa", "_hasCbaA2", "_hasA2", "_hasOa"];
_hasCbaA2 = isClass(configFile >> "CfgPatches" >> "CBA_A2_main");
_hasCbaOa = isClass(configFile >> "CfgPatches" >> "CBA_OA_main");
_hasA2 = isClass(configFile >> "CfgPatches" >> "Chernarus");
_hasOa = isClass(configFile >> "CfgPatches" >> "Takistan");
if (_hasA2 && !_hasCbaA2) then { "Running A2 Content but missing @CBA_A2, please install and enable @CBA_A2, or disable A2 content" spawn FUNC(log) };
if (_hasOA && !_hasCbaOA) then { "Running OA Content but missing @CBA_OA, please install and enable @CBA_OA, or disable OA content" spawn FUNC(log) };
if (!_hasA2 && _hasCbaA2) then { "Not Running A2 Content but running @CBA_A2, please disable @CBA_A2 or enable A2 content" spawn FUNC(log) };
if (!_hasOa && _hasCbaOa) then { "Not Running OA Content but running @CBA_OA, please disable @CBA_OA or enable OA content" spawn FUNC(log) };
*/

// Upgrade check - Registry for removed addons, warn the user if found
// TODO: Evaluate registry of 'current addons' and verifying that against available CfgPatches
TRACE_1("Upgrade Check",nil);
Expand All @@ -43,14 +26,13 @@ for "_i" from 0 to ((count (CFG)) - 1) do {
if (isClass(_entry) && {isArray(_entry >> "removed")}) then {
{
if (isClass(configFile >> "CfgPatches" >> _x)) then {
format["WARNING: Found addon that should be removed: %1; Please remove and restart game", _x] spawn FUNC(log);
format["WARNING: Found addon that should be removed: %1; Please remove and restart game", _x] call FUNC(log);
};
} forEach (getArray(_entry >> "removed"));
};
};

private ["_oldPFH"];
_oldPFH = isNil "BIS_fnc_addStackedEventHandler";
private _oldPFH = isNil "BIS_fnc_addStackedEventHandler";

FUNC(initPerFrameHandlers) = {
if (_this) then {
Expand All @@ -62,33 +44,25 @@ FUNC(initPerFrameHandlers) = {

GVAR(lastFrameRender) = diag_frameNo;
// Use a trigger, runs every 0.5s, unscheduled execution
GVAR(perFrameTrigger) = createTrigger["EmptyDetector", [0,0,0], false];
GVAR(perFrameTrigger) setTriggerStatements[QUOTE(call FUNC(monitorFrameRender)), "", ""];
GVAR(perFrameTrigger) = createTrigger ["EmptyDetector", [0,0,0], false];
GVAR(perFrameTrigger) setTriggerStatements [QUOTE(call FUNC(monitorFrameRender)), "", ""];
};

// Run the per frame handler init code, bringing up the hidden map control
_oldPFH call FUNC(initPerFrameHandlers);

// TODO: Consider a waitUntil loop with tickTime check to wait for some frames as opposed to trying to sleep until time > 0. Re MP Briefings etc.
/*
[CBA_COMMON_ADDONS] spawn {
params ["_addons"];
TRACE_1("Activating addons",nil);
activateAddons _addons;
sleep 0.001;
if (SLX_XEH_MACHINE select 1) then { sleep 0.001 }; // JIP, sleep uses time, and time skips for JIP.
TRACE_1("Activating addons",nil);
activateAddons _addons;
};
*/
// system to synch team colors
PREP(onTeamColorChanged);
PREP(synchTeamColors);

["CBA_teamColorChanged", FUNC(onTeamColorChanged)] call CBA_fnc_addEventHandler;

["CBA_teamColorChanged", CBA_fnc_onTeamColorChanged] call CBA_fnc_addEventHandler;
if (hasInterface) then {
[CBA_fnc_synchTeamColors, 1, []] call CBA_fnc_addPerFrameHandler;
[FUNC(synchTeamColors), 1, []] call CBA_fnc_addPerFrameHandler;

if (didJIP) then {
private "_team";
{
_team = _x getVariable [QGVAR(synchedTeam), ""];
private _team = _x getVariable [QGVAR(synchedTeam), ""];
if (_team != "") then {
_x assignTeam _team;
};
Expand Down
8 changes: 7 additions & 1 deletion addons/common/XEH_preClientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

LOG(MSG_INIT);

call COMPILE_FILE(init_actionmonitor);
if (hasInterface) then {
// ArmA - actionmonitor.sqf v1.0 Original by BN880, converted by Sickboy (sb_at_dev-heaven.net), 6th Sense - Share the Spirit
GVAR(actionList) = [] call CBA_fnc_hashCreate;
GVAR(actionListUpdated) = false; // Set true to force recreation of actions.
GVAR(nextActionIndex) = 0; // Next index that will be given out.
GVAR(actionListPFEH) = false;
};
128 changes: 17 additions & 111 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -1,134 +1,40 @@
// Any registered functions used in the PreINIT phase must use the uiNamespace copies of the variable.
// So uiNamespace getVariable "CBA_fnc_hashCreate" instead of just CBA_fnc_hashCreate -VM
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
SCRIPT(XEH_preInit);

/*
* Prepare BIS functions/MP and precompile all functions we already have
* registered with it. In order to have the functions loaded early,
* we do so in the "init_functionsModule" script. However, to make sure
* everything is done properly, we also create a new BIS functions manager
* module so that the whole BIS MP and functions framework is initialised
* completely. (We need to do it this way since the BIS function manager
* defers initialisation by way of execVM:ing its init script.)
*
* Yes, there's some redundancy in that the functions will be
* loaded and preprocessed twice, but this should only occur once per mission
* and will hopefully ensure forward compatibility with future ArmA II patches.
*/

/*
if (isNil "RE" && isNil "BIS_MPF_logic") then
{
LOG("Initialising the MP module early.");
_this call COMPILE_FILE2(\ca\Modules\MP\data\scripts\MPframework.sqf);
};
*/

[] call COMPILE_FILE(init_functionsModule);
LOG(MSG_INIT);
// if (true) exitWith {};

ADDON = false;

CBA_nil = [nil];
GVAR(centers) = [];
CBA_actionHelper = QUOTE(PATHTO(actionHelper));
GVAR(delayless) = QUOTE(PATHTOF(delayless.fsm));
GVAR(delayless_loop) = QUOTE(PATHTOF(delayless_loop.fsm));

// DirectCall, using single-frame-code-executioner
// The directCall function will execute (with parameters) next frame, and without delay
// [[1,2,3], {mycode to execute}] call FUNC(directCall);
// _obj = [[1,2,3], {mycode to execute}] call FUNC(directCall); waitUntil {isNull _obj}; // waits until the code has completed
FUNC(directCall) = {
private "_o";
params ["_params","_code"];
_o = SLX_XEH_DUMMY createVehicleLocal [0, 0, 0];
["CBA_DC", "onEachFrame", {
params ["_args", "_code", "_o"];
_args call _code;
_o setDamage 1;
["CBA_DC", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
}, [_params, _code, _o]] call BIS_fnc_addStackedEventHandler;
_o
};

CBA_logic = objNull;

FUNC(log) = {
diag_log text _this;
sleep 1;
CBA_logic globalChat _this;
hintC _this;
_this spawn {
sleep 1;
systemChat _this;
hintC _this;
};
};

// Nil check
ISNILS(CBA_NIL_CHECKED,false);

// Prepare all functions
DEPRECATE(fAddMagazine,fnc_addMagazine);
DEPRECATE(fAddMagazineCargo,fnc_addMagazineCargo);
DEPRECATE(fAddWeapon,fnc_addWeapon);
DEPRECATE(fAddWeaponCargo,fnc_addWeaponCargo);
DEPRECATE(fDetermineMuzzles,fnc_determineMuzzles);
DEPRECATE(fDropMagazine,fnc_dropMagazine);
DEPRECATE(fDropWeapon,fnc_dropWeapon);
DEPRECATE(fGetAnimType,fnc_getAnimType);
DEPRECATE(fGetConfigEntry,fnc_getConfigEntry);
DEPRECATE(fGetPistol,fnc_getPistol);
DEPRECATE(fGetUnitAnim,fnc_getUnitAnim);
DEPRECATE(fGetUnitDeathAnim,fnc_getUnitDeathAnim);
DEPRECATE(fGetVehicleAnim,fnc_isTurnedOut);
DEPRECATE(fHeadDir,fnc_headDir);

OBSOLETE(fMyWeapon,{ currentWeapon player });

DEPRECATE(fObjectRandom,fnc_objectRandom);
DEPRECATE(fPlayers,fnc_players);
DEPRECATE(fRealHeight,fnc_realHeight);
DEPRECATE(fRemoveMagazine,fnc_removeMagazine);
DEPRECATE(fRemoveWeapon,fnc_removeWeapon);

OBSOLETE(fSelectedWeapon,{ currentWeapon _this });

DEPRECATE_SYS(DOUBLES(PREFIX,fVectorSum3d),BIS_fnc_vectorAdd);

DEPRECATE(fAddMagazineVerified,fnc_addMagazineVerified);
DEPRECATE(fCreateMarker,fnc_createMarker);
DEPRECATE(fCreateTrigger,fnc_createTrigger);
DEPRECATE(fGetArg,fnc_getArg);
DEPRECATE(fInheritsFrom,fnc_inheritsFrom);
DEPRECATE(fNearPlayer,fnc_nearPlayer);

DEPRECATE_SYS(DOUBLES(PREFIX,fRndInt),BIS_fnc_randomInt);
DEPRECATE_SYS(DOUBLES(PREFIX,fRndSelect),BIS_fnc_selectRandom);

DEPRECATE(fSelectWeapon,fnc_selectWeapon);
DEPRECATE(fShuffle,fnc_shuffle);
DEPRECATE(fSwitchPlayer,fnc_switchPlayer);
// FSM
GVAR(delayless) = QUOTE(PATHTOF(delayless.fsm));
GVAR(delayless_loop) = QUOTE(PATHTOF(delayless_loop.fsm));

// Initialize Components
GVAR(groups) = [grpNull, grpNull, grpNull, grpNull, grpNull];
call COMPILE_FILE(init_gauss);
call COMPILE_FILE(init_kron_strings);

OBSOLETE_SYS(KRON_StrUpper,{ toUpper (_this select 0) });
OBSOLETE_SYS(KRON_StrLower,{ toLower (_this select 0) });
DEPRECATE_SYS(KRON_StrIndex,DOUBLES(PREFIX,fnc_find)); // CBA_fnc_find does the same and more.
DEPRECATE_SYS(KRON_StrLen,DOUBLES(PREFIX,fnc_strLen));
DEPRECATE_SYS(KRON_StrToArray,DOUBLES(PREFIX,fnc_split)); // CBA_fnc_split does the same and more.
DEPRECATE_SYS(KRON_Replace,DOUBLES(PREFIX,fnc_replace)); // KRON is faster, but CBA one is 1 line (reuses other functions).

call COMPILE_FILE(init_tables);

call COMPILE_FILE(init_gauss);
call COMPILE_FILE(init_perFrameHandler);
call COMPILE_FILE(init_delayLess);

// NOTE: Due to activateAddons being overwritten by eachother (only the last executed command will be active), we apply this bandaid
call COMPILE_FILE(init_addons);
// Due to activateAddons being overwritten by eachother (only the last executed command will be active), we apply this bandaid
private _addons = ("true" configClasses (configFile >> "CfgPatches")) apply {configName _x};

call COMPILE_FILE(init_delayLess);
activateAddons _addons;
GVAR(addons) = _addons;

// BWC
#include "backwards_comp.sqf"

// Announce Initialization Complete
ADDON = true;
2 changes: 2 additions & 0 deletions addons/common/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "script_component.hpp"

PREP(perFrameEngine);
PREP(onTeamColorChanged);
PREP(synchTeamColors);
Loading

0 comments on commit 16f9647

Please sign in to comment.