Skip to content

Commit

Permalink
ACE project template
Browse files Browse the repository at this point in the history
  • Loading branch information
ampersand38 committed Jul 4, 2020
1 parent 1cd9ef2 commit 9157796
Show file tree
Hide file tree
Showing 30 changed files with 2,444 additions and 206 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
end_of_line = crlf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: python
python:
- '3.4'
script:
- python3 tools/sqf_validator.py
- python3 tools/config_style_checker.py
1 change: 1 addition & 0 deletions addons/main/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\rwyl\addons\main
17 changes: 17 additions & 0 deletions addons/main/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};

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));
};
};
14 changes: 14 additions & 0 deletions addons/main/CfgModuleCategories.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CfgFactionClasses {
class NO_CATEGORY;
class RWYL: NO_CATEGORY {
displayName = "RWYL";
priority = 2;
side = 7;
};
};

class CfgVehicleClasses {
class RWYL_Vehicles {
displayName = "RWYL Vehicles";
};
};
4 changes: 4 additions & 0 deletions addons/main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rwyl_main
========

Backbone of other components, defining most of the commonly used macros.
6 changes: 6 additions & 0 deletions addons/main/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// testing, update fncs on the fly
//#define PREP(var1) TRIPLES(ADDON,fnc,var1) = { call compile preProcessFileLineNumbers '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT_F\functions\DOUBLES(fnc,var1).sqf' }
//amp_slingload_fnc_adjustRigging = {call compile preProcessFileLineNumbers '\z\amp\addons\slingload\functions\fnc_adjustRigging.sqf'}

PREP(findSeat);
PREP(moveSeat);
40 changes: 40 additions & 0 deletions addons/main/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "script_component.hpp"

["rwyl_main_moveSeat", {
params ["_unit", "_role", "_cargoIndex", "_turretPath"];
if (rwyl_main_vehicle == vehicle _unit) then {moveOut _unit;};
[{
params ["_unit"];
vehicle _unit == _unit
},{
params ["_unit", "_role", "_cargoIndex", "_turretPath"];
if (toLower _role isEqualTo "cargo") then {
_unit moveInCargo [rwyl_main_vehicle, _cargoIndex];
} else {
_unit moveInTurret [rwyl_main_vehicle, _turretPath];
};
rwyl_main_vehicle = objNull;
rwyl_main_proxy = nil;
}, [_unit, _role, _cargoIndex, _turretPath]] call CBA_fnc_waitUntilAndExecute;
}] call CBA_fnc_addEventHandler;

[
"Ride Where You Look", "rwyl_main_selectSeat", "Select Seat",{
if (isNull curatorCamera) then {
[player] call rwyl_main_fnc_findSeat;
} else {
if (count (curatorSelected # 0) == 1) then {
[curatorSelected # 0 # 0] call rwyl_main_fnc_findSeat;
};
};
},{
rwyl_main_pfh_running = false;
if (isNull curatorCamera) then {
[player] call rwyl_main_fnc_moveSeat;
} else {
if (count (curatorSelected # 0) == 1) then {
[curatorSelected # 0 # 0] call rwyl_main_fnc_moveSeat;
};
};
}, [45, [false, false, false]], false //, 0, true
] call CBA_fnc_addKeybind; // x
7 changes: 7 additions & 0 deletions addons/main/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "script_component.hpp"

ADDON = false;

#include "XEH_PREP.hpp"

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

#include "XEH_PREP.hpp"
18 changes: 18 additions & 0 deletions addons/main/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"cba_common"};
author = "Ampersand";
authors[] = {"Ampersand"};
authorUrl = "https://github.com/ampersand38/rwyl";
VERSION_CONFIG;
};
};

#include "CfgEventHandlers.hpp"
#include "CfgModuleCategories.hpp"
69 changes: 69 additions & 0 deletions addons/main/functions/fnc_findSeat.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Author: Ampers
PFH to show which seat the unit is looking at
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* -
* Exrwylle:
* [player] call rwyl_main_fnc_findSeat
*/

params ["_unit"];

rwyl_main_vehicle = vehicle _unit;
if (rwyl_main_vehicle == _unit) then {
private _start = AGLtoASL (_unit modelToWorldVisual (_unit selectionPosition "pilot"));
private _end = (_start vectorAdd (getCameraViewDirection _unit vectorMultiply 3));
private _objects = lineIntersectsSurfaces [_start, _end, _unit];
rwyl_main_vehicle = (_objects param [0, []]) param [2, objNull];
};

if (isNull rwyl_main_vehicle) exitWith {"no pfh"};
if (locked rwyl_main_vehicle in [2,3]) exitWith {
hintSilent "Vehicle Locked";
false
};

rwyl_main_pfh_running = true;
[{
params ["", "_pfID"];
rwyl_main_proxy = nil;
if (!rwyl_main_pfh_running) exitWith {
[_pfID] call CBA_fnc_removePerFrameHandler;
};

private _sn = selectionNames rwyl_main_vehicle select {
private _lastChar = _x select [count _x -1];
((parseNumber _lastChar > 0) || {_lastChar isEqualTo "0"}) && {
("cargo" in toLower _x) && {
!((rwyl_main_vehicle selectionPosition _x) isEqualTo [0,0,0])}}};

if (_sn isEqualTo []) exitWith {
rwyl_main_vehicle = objNull;
"no cargo proxies found in selectionNames"
};

private _sp = _sn apply {rwyl_main_vehicle selectionPosition _x};

private _screenPosArray = _sp apply {
private _w2s = worldToScreen (rwyl_main_vehicle modelToWorld _x);
if (_w2s isEqualTo []) then {
1000
} else {
([getMousePosition, [0.5,0.5]] select (isNull curatorCamera)) distance2D _w2s
};
};

rwyl_main_proxy = _sn # (_screenPosArray findIf {_x == selectMin _screenPosArray});

if (isNil "rwyl_main_proxy") exitWith {
rwyl_main_vehicle = objNull;
"no cargo proxies on screen"
};

drawIcon3D ["\a3\3den\Data\Cfg3DEN\Object\iconCargo_ca.paa", [1,1,1,1], rwyl_main_vehicle modelToWorld (rwyl_main_vehicle selectionPosition rwyl_main_proxy), 1, 1, 0, rwyl_main_proxy select [(rwyl_main_proxy find ".") + 1]];
}, 0] call CBA_fnc_addPerFrameHandler;
74 changes: 74 additions & 0 deletions addons/main/functions/fnc_moveSeat.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Author: Ampers
Move unit into vehicle seat near center of view
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* -
* Exrwylle:
* [player] call rwyl_main_fnc_moveSeat
*/

params ["_unit"];

rwyl_main_pfh_running = false;
if (isNull rwyl_main_vehicle) then {
rwyl_main_vehicle = vehicle _unit;
if (rwyl_main_vehicle == _unit) then {
rwyl_main_vehicle = nearestObject [positionCameraToWorld [0,0,2], "AllVehicles"];
};
};

if (isNil "rwyl_main_proxy") then {
private _sn = selectionNames rwyl_main_vehicle select {("cargo" in toLower _x) && {!((rwyl_main_vehicle selectionPosition _x) isEqualTo [0,0,0])}};

if (_sn isEqualTo []) exitWith { "no cargo proxies found in selectionNames"};

private _sp = _sn apply {rwyl_main_vehicle selectionPosition _x};

private _screenPosArray = _sp apply {
private _w2s = worldToScreen (rwyl_main_vehicle modelToWorld _x);
if (_w2s isEqualTo []) then {
1000
} else {
[0.5,0.5] distance2D _w2s
};
};

rwyl_main_proxy = _sn # (_screenPosArray findIf {_x == selectMin _screenPosArray});
};

if (rwyl_main_proxy isEqualTo "") exitWith { ["no seat found", rwyl_main_vehicle]};

// get cargo index from proxy name
private _cargoIndexStr = rwyl_main_proxy select [(rwyl_main_proxy find ".") + 1];

// get all cargo seat indexes
private _fullCrew = fullCrew [rwyl_main_vehicle, "", true];

private _role = "";
private _cargoIndex = -1;
private _turretPath = [];

{
//_x params ["_seatOccupant", "_seatRole", "_seatCargoIndex", "_seatTurretPath"];
_x params ["_seatOccupant", "_seatRole", "_seatCargoIndex", "_seatTurretPath"];
if (
isNull _seatOccupant && {
parseNumber _cargoIndexStr == _seatCargoIndex + 1}
) then {
_cargoIndex = _seatCargoIndex;
_role = _seatRole;
_turretPath = _seatTurretPath;
};
_seatCargoIndex == _cargoIndex && {isNull _seatOccupant}
} forEach _fullCrew;

if (_cargoIndex < 0) exitWith {
["_cargoIndex not found", rwyl_main_proxy, _cargoIndexStr, _cargoIndex]
};

["rwyl_main_moveSeat", [_unit, _role, _cargoIndex, _turretPath], _unit] call CBA_fnc_targetEvent;
1 change: 1 addition & 0 deletions addons/main/functions/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "\z\rwyl\addons\main\script_component.hpp"
17 changes: 17 additions & 0 deletions addons/main/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#define COMPONENT main
#include "\z\rwyl\addons\main\script_mod.hpp"

// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define CBA_DEBUG_SYNCHRONOUS
// #define ENABLE_PERFORMANCE_COUNTERS

#ifdef DEBUG_ENABLED_MAIN
#define DEBUG_MODE_FULL
#endif

#ifdef DEBUG_SETTINGS_MAIN
#define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN
#endif

#include "\z\rwyl\addons\main\script_macros.hpp"
1 change: 1 addition & 0 deletions addons/main/script_macros.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "\z\ace\addons\main\script_macros.hpp"
20 changes: 20 additions & 0 deletions addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// COMPONENT should be defined in the script_component.hpp and included BEFORE this hpp

#define MAINPREFIX z
#define PREFIX rwyl

#include "script_version.hpp"

#define VERSION MAJOR.MINOR.PATCHLVL.BUILD
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD

#define RWYL_TAG RWYL

// MINIMAL required version for the Mod. Components can specify others..
#define REQUIRED_VERSION 1.56

#ifdef COMPONENT_BEAUTIFIED
#define COMPONENT_NAME QUOTE(rwyl - COMPONENT_BEAUTIFIED)
#else
#define COMPONENT_NAME QUOTE(rwyl - COMPONENT)
#endif
4 changes: 4 additions & 0 deletions addons/main/script_version.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define MAJOR 1
#define MINOR 0
#define PATCHLVL 1
#define BUILD 0
9 changes: 0 additions & 9 deletions addons/ride_where_you_look/XEH_postInit.sqf

This file was deleted.

22 changes: 0 additions & 22 deletions addons/ride_where_you_look/config.cpp

This file was deleted.

Loading

0 comments on commit 9157796

Please sign in to comment.