-
-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #492 from KillahPotatoes/0.97S5-470
Build module refactor
- Loading branch information
Showing
20 changed files
with
579 additions
and
376 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
Missionframework/modules/02_build/fnc/fn_build_camAreaLimiter.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
Missionframework/modules/02_build/fnc/fn_build_camClose.sqf
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
Missionframework/modules/02_build/fnc/fn_build_camera_ticker_start.sqf
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
Missionframework/modules/02_build/fnc/fn_build_camera_ticker_stop.sqf
This file was deleted.
Oops, something went wrong.
107 changes: 107 additions & 0 deletions
107
Missionframework/modules/02_build/fnc/fn_build_displayLoad.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
44 changes: 44 additions & 0 deletions
44
Missionframework/modules/02_build/fnc/fn_build_displayPlaceObject.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", []]; | ||
} | ||
|
||
}; |
Oops, something went wrong.