Skip to content

Commit

Permalink
Merge pull request #492 from KillahPotatoes/0.97S5-470
Browse files Browse the repository at this point in the history
Build module refactor
  • Loading branch information
veteran29 authored Sep 9, 2018
2 parents f6fbb6b + 824aba0 commit 928cc17
Show file tree
Hide file tree
Showing 20 changed files with 579 additions and 376 deletions.
53 changes: 53 additions & 0 deletions Missionframework/modules/02_build/fnc/fn_build_camAreaLimiter.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
KPLIB_fnc_build_camera_ticker_start
File: fn_build_camera_ticker_start.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-07-01
Last Update: 2018-09-09
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Build camera per frame ticker, limits camera area
Parameter(s):
NONE
Returns:
NUMBER - PFH Handle
*/
params [
["_position", nil, [[]]],
["_radius", nil, [0]],
["_camera", nil, [objNull]]
];

private _handle = [{
params ["_args", "_handle"];
_args params ["_position", "_radius","_camera"];

if(_camera isEqualTo objNull) exitWith {
systemChat "Camera does not exist, stopping area limiter.";
_handle call CBA_fnc_removePerFrameHandler;
};

private _currentCamPos = (getPos _camera);

// Check if camera is in FOB area
private _inArea = _currentCamPos inArea [_position, _radius + 5, _radius + 5, 0, false];
// If not force it back
if (!_inArea) then {
// Get the direction towards the center
private _dir = _currentCamPos getDir _position;
// The more outside the area the faster the camera will be pulled back in
private _step = ((_currentCamPos distance2D _position) - _radius - 5) / 10;
// Get new position
private _newPos = (_camera getPos [_step, _dir]);
_newPos set [2, _currentCamPos select 2]; // use old Z
// Move camera back towards the center
_camera setPos _newPos;
};

}, 0, [_position, _radius, _camera]] call CBA_fnc_addPerFrameHandler;

_handle
27 changes: 0 additions & 27 deletions Missionframework/modules/02_build/fnc/fn_build_camClose.sqf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Opens the build camera and creates build overlay
Creates the build camera
Parameter(s):
NONE
Returns:
BOOL
OBJECT - Building camera
*/
params [
["_position", nil, [[]]],
["_radius", nil, [0]]
];

private _camera = "CamCurator" camCreate (eyePos player);

// Animate player
player playactionnow "gear";

_camera cameraEffect ["internal", "back"];
_camera camCommand "maxPitch 89";
_camera camCommand "minPitch -89";
Expand All @@ -35,11 +36,6 @@ _camera camCommand format ["speedMax %1", 1.5];
// Enable display of GUI in camera
cameraEffectEnableHUD true;

[] call KPLIB_fnc_build_camera_ticker_start;

KPLIB_build_camera = _camera;

private _display = (findDisplay 46) createDisplay "KPLIB_build";
uiNamespace setVariable ["KPLIB_build_display", _display];
[_position, _radius, _camera] call KPLIB_fnc_build_camAreaLimiter;

true
_camera

This file was deleted.

This file was deleted.

107 changes: 107 additions & 0 deletions Missionframework/modules/02_build/fnc/fn_build_displayLoad.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include "..\ui\defines.hpp"
/*
KPLIB_fnc_build_displayLoad
File: fn_build_displayLoad.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-09-09
Last Update: 2018-09-09
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Handle build display load
Parameter(s):
0: DISPLAY - Build display
Returns:
NOTHING
*/
params [["_display", nil, [displayNull]]];

systemChat "onLoad";

// Add ESC Handler
_display displayAddEventHandler ["keyDown", {
params ["_display","_dik","_shift","_ctrl","_alt"];
if (_dik == 1) exitWith {
// [] call KPLIB_fnc_build_stop;
// Open debug ESC menu (for debugging)
[] spawn {
private _interruptDisplay = (findDisplay 46) createDisplay "RscDisplayInterrupt";
waitUntil {_interruptDisplay isEqualTo displayNull};
(findDisplay 46) createDisplay "KPLIB_build";
};
true
};
private _logic = KPLIB_buildLogic;
_logic setVariable ["shiftKey", _shift];
_logic setVariable ["ctrlKey", _ctrl];

systemChat format["keyDown, ctrl: %1, shift: %2", [_ctrl, _shift]];
}];

_display displayAddEventHandler ["keyUp", {
params ["_display","_dik","_shift","_ctrl","_alt"];

private _logic = KPLIB_buildLogic;
_logic setVariable ["shiftKey", _shift];
_logic setVariable ["ctrlKey", _ctrl];

systemChat format["keyUp, ctrl: %1, shift: %2", [_ctrl, _shift]];
}];

// Add Item selection handler
private _itemsList = _display displayCtrl KPLIB_IDC_BUILD_ITEM_LIST;
_itemsList ctrlAddEventHandler ["LBSelChanged", {
params ["_control", "_selectedIndex"];

private _logic = KPLIB_buildLogic;
private _mode = _logic getVariable "buildMode";

if(_selectedIndex == -1) exitWith {
_logic setVariable ["buildItem", []];
};

private _buildList = KPLIB_preset_buildLists select _mode;
private _selectedItem = _buildList select _selectedIndex;

systemChat format["buildItem: %1", _selectedItem];
_logic setVariable ["buildItem", _selectedItem];
}];

// Add build confirmation handler
private _confirmButton = _display displayCtrl KPLIB_IDC_BUILD_CONFIRM;
_confirmButton ctrlAddEventHandler ["buttonClick", {
private _logic = KPLIB_buildLogic;

// TODO implement build queue handling (resource check etc.)
systemChat "buildConfirm: Resource check not implemented yet!";
{
private _dirAndUp = [vectorDir _x, vectorUp _x];
private _pos = getPos _x;
private _class = typeOf _x;

private _obj = [_class, _pos, 0, true] remoteExecCall ["KPLIB_fnc_common_spawnVehicle", 2];
_obj setVectorDirAndUp _dirAndUp;

} forEach (_logic getVariable "buildQueue");
}];

// Add tab change handler
{
_ctrl = _display displayCtrl _x;
_ctrl ctrlAddEventHandler ["buttonClick", {
_this call KPLIB_fnc_build_displayTabClick;
}];
} forEach KPLIB_BUILD_TABS_IDCS_ARRAY;

// Hide vignette, show hud
private _vignette = _display displayCtrl 1202;
_vignette ctrlShow false;
showHUD true;

private _logic = KPLIB_buildLogic;
_logic setVariable ["display", _display];
(_logic getVariable ["buildMode", 0]) call KPLIB_fnc_build_displaySetMode;
setMousePosition (_logic getVariable "mousePos");
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
KPLIB_fnc_build_displayPlaceObject
File: fn_build_displayPlaceObject.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-09-09
Last Update: 2018-09-09
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Places object into build queue
Parameter(s):
0: STRING - Classname of object to place
1: NUMBER - Supply price of placed object
2: NUMBER - Ammo price of placed object
3: NUMBER - Fuel price of placed object
Returns:
NOTHING
*/
params [
["_className", "", [""]],
["_priceSupplies", nil, [0]],
["_priceAmmo", nil, [0]],
["_priceFuel", nil, [0]]
];

systemChat format["placeObject: %1", _this];

if !(_className isEqualTo "") then {
private _logic = KPLIB_buildLogic;
private _pos = screenToWorld (_logic getVariable "mousePos");

private _obj = _className createVehicleLocal _pos;
_obj enableSimulation false;

(_logic getVariable "buildQueue") pushBack _obj;

if !(_logic getVariable "ctrlKey") then {
_logic setVariable ["buildItem", []];
}

};
Loading

0 comments on commit 928cc17

Please sign in to comment.