Marker Flags - Add placing system & icons (#8951)

This commit is contained in:
Timi007 2022-08-31 06:17:31 +02:00 committed by GitHub
parent 4eef2da0fe
commit 11984f6dcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 203 additions and 53 deletions

View File

@ -15,3 +15,9 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};
class Extended_DisplayLoad_EventHandlers {
class RscDisplayMission {
ADDON = QUOTE(_this call COMPILE_SCRIPT(XEH_missionDisplayLoad));
};
};

View File

@ -7,6 +7,7 @@ class CfgVehicles {
displayName = CSTRING(ActionPlace);
condition = QUOTE(_player call FUNC(canPlace));
insertChildren = QUOTE(_this call FUNC(addActions));
icon = QPATHTOF(ui\icons\white_place_icon.paa);
};
};
};
@ -18,34 +19,34 @@ class CfgVehicles {
scopeCurator = 2;
author = ECSTRING(common,ACETeam);
displayName = CSTRING(white);
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(1,1,1,1,co)"};
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.82,0.82,0.82,1,co)"};
};
class GVAR(black): GVAR(white) {
displayName = CSTRING(black);
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0,0,0,1,co)"};
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.18,0.18,0.18,1,co)"};
};
class GVAR(red): GVAR(white) {
displayName = CSTRING(red);
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(1,0,0,1,co)"};
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.647,0.141,0.161,1,co)"};
};
class GVAR(green): GVAR(white) {
displayName = CSTRING(green);
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0,1,0,1,co)"};
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.063,0.588,0.063,1,co)"};
};
class GVAR(blue): GVAR(white) {
displayName = CSTRING(blue);
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0,0,1,1,co)"};
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.161,0.349,0.58,1,co)"};
};
class GVAR(yellow): GVAR(white) {
displayName = CSTRING(yellow);
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(1,1,0,1,co)"};
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.776,0.729,0.129,1,co)"};
};
class GVAR(orange): GVAR(white) {
displayName = CSTRING(orange);
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(1,0.5,0,1,co)"};
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.678,0.349,0.153,1,co)"};
};
class GVAR(purple): GVAR(white) {
displayName = CSTRING(purple);
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.5,0,0.5,1,co)"};
hiddenSelectionsTextures[] = {"#(argb,8,8,3)color(0.373,0.141,0.647,1,co)"};
};
};

View File

@ -3,7 +3,8 @@ class CfgWeapons {
class CBA_MiscItem_ItemInfo;
class GVAR(white): ACE_ItemCore {
GVAR(vehicle) = GVAR(white);
GVAR(vehicle) = QGVAR(white);
GVAR(icon) = QPATHTOF(ui\icons\white_place_icon.paa);
author = ECSTRING(common,ACETeam);
scope = 2;
displayName = CSTRING(white);
@ -18,37 +19,44 @@ class CfgWeapons {
};
class GVAR(black): GVAR(white) {
GVAR(vehicle) = GVAR(black);
GVAR(vehicle) = QGVAR(black);
GVAR(icon) = QPATHTOF(ui\icons\black_place_icon.paa);
displayName = CSTRING(black);
picture = QPATHTOF(ui\black_ca.paa);
};
class GVAR(red): GVAR(white) {
GVAR(vehicle) = GVAR(red);
GVAR(vehicle) = QGVAR(red);
GVAR(icon) = QPATHTOF(ui\icons\red_place_icon.paa);
displayName = CSTRING(red);
picture = QPATHTOF(ui\red_ca.paa);
};
class GVAR(green): GVAR(white) {
GVAR(vehicle) = GVAR(green);
GVAR(vehicle) = QGVAR(green);
GVAR(icon) = QPATHTOF(ui\icons\green_place_icon.paa);
displayName = CSTRING(green);
picture = QPATHTOF(ui\green_ca.paa);
};
class GVAR(blue): GVAR(white) {
GVAR(vehicle) = GVAR(blue);
GVAR(vehicle) = QGVAR(blue);
GVAR(icon) = QPATHTOF(ui\icons\blue_place_icon.paa);
displayName = CSTRING(blue);
picture = QPATHTOF(ui\blue_ca.paa);
};
class GVAR(yellow): GVAR(white) {
GVAR(vehicle) = GVAR(yellow);
GVAR(vehicle) = QGVAR(yellow);
GVAR(icon) = QPATHTOF(ui\icons\yellow_place_icon.paa);
displayName = CSTRING(yellow);
picture = QPATHTOF(ui\yellow_ca.paa);
};
class GVAR(orange): GVAR(white) {
GVAR(vehicle) = GVAR(orange);
GVAR(vehicle) = QGVAR(orange);
GVAR(icon) = QPATHTOF(ui\icons\orange_place_icon.paa);
displayName = CSTRING(orange);
picture = QPATHTOF(ui\orange_ca.paa);
};
class GVAR(purple): GVAR(white) {
GVAR(vehicle) = GVAR(purple);
GVAR(vehicle) = QGVAR(purple);
GVAR(icon) = QPATHTOF(ui\icons\purple_place_icon.paa);
displayName = CSTRING(purple);
picture = QPATHTOF(ui\purple_ca.paa);
};

View File

@ -1,5 +1,6 @@
PREP(addActions);
PREP(canPlace);
PREP(getFlags);
PREP(handleScrollWheel);
PREP(pickUpFlag);
PREP(placeFlag);

View File

@ -0,0 +1,17 @@
#include "script_component.hpp"
if (!hasInterface) exitWith {};
params ["_display"];
_display displayAddEventHandler ["MouseZChanged", {
params ["", "_scroll"];
[_scroll] call FUNC(handleScrollWheel);
}];
_display displayAddEventHandler ["MouseButtonDown", {
params ["", "_button"];
if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith {false};
if (_button isNotEqualTo 1) exitWith {false}; // 1 = Left mouse button
GVAR(isPlacing) = PLACE_CANCEL;
}];

View File

@ -2,21 +2,29 @@
if (!hasInterface) exitWith {};
private _weapons = (call (uiNamespace getVariable [QGVAR(flagItems), {[]}])) apply {configFile >> "CfgWeapons" >> _x};
GVAR(isPlacing) = PLACE_CANCEL;
["ace_interactMenuOpened", {GVAR(isPlacing) = PLACE_CANCEL;}] call CBA_fnc_addEventHandler;
private _cfgWeapons = configFile >> "CfgWeapons";
private _weapons = (call (uiNamespace getVariable [QGVAR(flagItems), {[]}])) apply {_cfgWeapons >> _x};
{
private _name = configName _x;
private _vehicle = getText (_x >> QGVAR(vehicle));
GVAR(flagCache) set [_name, _vehicle];
private _vehicleClass = getText (_x >> QGVAR(vehicle));
private _displayName = getText (_x >> "displayName");
private _icon = getText (_x >> QGVAR(icon));
GVAR(flagCache) set [_name, [_vehicleClass, _displayName, _icon]];
private _action = [
QGVAR(pickup),
LLSTRING(ActionPickUp),
"",
QPATHTOF(ui\icons\white_pickup_icon.paa),
{call FUNC(pickUpFlag)},
{[_player, _target, []] call EFUNC(common,canInteractWith)},
{},
[_name]
[_name],
[0, 0.072, 0.2],
2
] call EFUNC(interact_menu,createAction);
[_vehicle, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
[_vehicleClass, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
} forEach _weapons;

View File

@ -2,5 +2,5 @@
#include "XEH_PREP.hpp"
private _weapons = (configProperties [configfile >> "CfgWeapons", QUOTE(isClass _x && (isText (_x >> QQGVAR(vehicle)))), true]) apply {configName _x};
private _weapons = (configProperties [configfile >> "CfgWeapons", QUOTE(isClass _x && {isText (_x >> QQGVAR(vehicle))}), true]) apply {configName _x};
uiNamespace setVariable [QGVAR(flagItems), compileFinal str _weapons];

View File

@ -24,9 +24,9 @@ class CfgPatches {
QGVAR(purple)
};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interact_menu"};
requiredAddons[] = {"ace_common", "ace_interaction", "ace_interact_menu"};
author = ECSTRING(common,ACETeam);
authors[] = {"Brett Mayson"};
authors[] = {"Brett Mayson", "Timi007"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Author: Brett Mayson, Timi007
* Adds the child actions for placing flags.
*
* Arguments:
@ -20,12 +20,13 @@ params ["_unit"];
private _actions = [];
{
private _config = configFile >> "CfgWeapons" >> _x;
(GVAR(flagCache) get _x) params ["_vehicle", "_displayName", "_icon"];
_actions pushBack [
[
_x,
getText (_config >> "displayName"),
getText (_config >> "picture"),
_displayName,
_icon,
{[_this select 0, _this select 2] call FUNC(placeFlag)},
{true},
{},

View File

@ -0,0 +1,30 @@
#include "script_component.hpp"
/*
* Author: Timi007
* Handles the marker flag object height.
*
* Arguments:
* 0: Scroll amount <NUMBER>
*
* Return Value:
* Handled <BOOLEAN>
*
* Example:
* [5] call ace_marker_flags_fnc_handleScrollWheel
*
* Public: No
*/
params ["_scrollAmount"];
if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith {
false
};
// Move object height 5cm per scroll
GVAR(objectHeight) = GVAR(objectHeight) + (_scrollAmount * 0.05);
// Clamp height between MIN_HEIGHT and MAX_HEIGHT
GVAR(objectHeight) = MIN_HEIGHT max (GVAR(objectHeight) min MAX_HEIGHT);
true

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Author: Brett Mayson, Timi007
* Places a flag in front of the unit.
*
* Arguments:
@ -12,17 +12,22 @@
* Nothing
*
* Example:
* [_flag,player,"x"] call ace_marker_flags_fnc_pickupFlag
* [_flag, player, ["ace_marker_flags_white"]] call ace_marker_flags_fnc_pickupFlag
*
* Public: No
*/
params [["_flag", objNull, [objNull]], ["_unit", objNull, [objNull]], ["_args", [""], [[]]]];
private _itemName = _args # 0;
_args params ["_item"];
TRACE_3("pickupFlag",_unit,_flag,_itemName);
if (isNull _flag) exitWith {};
[_unit, "PutDown"] call EFUNC(common,doGesture);
deleteVehicle _flag;
[_unit, _itemName] call EFUNC(common,addToInventory);
[{
params ["_flag", "_unit", "_item"];
[_unit, _item] call EFUNC(common,addToInventory);
deleteVehicle _flag;
}, [_flag, _unit, _item], 0.7] call CBA_fnc_waitAndExecute;

View File

@ -1,14 +1,15 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Places a flag in front of the unit.
* Author: Timi007
* Starts the placing process of the marker flag for the player.
* Flags can be placed with the special marker flag items.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Flag <STRING>
* 0: Player <OBJECT>
* 1: Flag item <STRING>
*
* Return Value:
* Flag <OBJECT>
* Nothing
*
* Example:
* [player, "ace_marker_flags_white"] call ace_marker_flags_fnc_placeFlag
@ -16,12 +17,58 @@
* Public: No
*/
params [["_unit", objNull, [objNull]], ["_flag", QGVAR(white), [""]]];
params [["_player", objNull, [objNull]], ["_item", QGVAR(white), [""]]];
TRACE_2("Placing flag", _player, _item);
_unit removeItem _flag;
_flag = GVAR(flagCache) get _flag; // convert to vehicle type
private _pos = _unit modelToWorld [0, 1, 0];
private _flag = _flag createVehicle _pos;
_flag setPos _pos;
[QGVAR(placed), [_unit, _flag]] call CBA_fnc_localEvent;
[_unit, "PutDown"] call EFUNC(common,doGesture);
(GVAR(flagCache) get _item) params ["_vehicleClass"];
private _flag = _vehicleClass createVehicle [0, 0, 0];
TRACE_1("Created flag", _flag);
// Set flag start height
GVAR(objectHeight) = MAX_HEIGHT;
GVAR(isPlacing) = PLACE_WAITING;
// Add info dialog for the player which show the controls
[LLSTRING(ActionPlace), LLSTRING(ActionCancel), LLSTRING(ActionAdjustHeight)] call EFUNC(interaction,showMouseHint);
private _mouseClickID = [_player, "DefaultAction", {
GVAR(isPlacing) isEqualTo PLACE_WAITING
}, {
GVAR(isPlacing) = PLACE_APPROVE
}] call EFUNC(common,addActionEventHandler);
[{
params ["_args", "_handle"];
_args params ["_player", "_item", "_flag", "_mouseClickID"];
if (isNull _flag || {!([_player, _flag] call EFUNC(common,canInteractWith))}) then {
GVAR(isPlacing) = PLACE_CANCEL;
};
if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
call EFUNC(interaction,hideMouseHint);
[_player, "DefaultAction", _mouseClickID] call EFUNC(common,removeActionEventHandler);
if (GVAR(isPlacing) isEqualTo PLACE_APPROVE) then {
// End position of the flag
GVAR(isPlacing) = PLACE_CANCEL;
[_player, "PutDown"] call EFUNC(common,doGesture);
_player removeItem _item;
[QGVAR(placed), [_player, _flag, _item]] call CBA_fnc_localEvent;
} else {
// Action is canceled
deleteVehicle _flag;
};
};
private _pos = (eyePos _player) vectorAdd ((getCameraViewDirection _player) vectorMultiply FLAG_PLACING_DISTANCE);
// Adjust height of flag with the scroll wheel
_pos set [2, ((getPosWorld _player) select 2) + GVAR(objectHeight)];
_flag setPosWorld _pos;
_flag setDir (getDir _player - 90);
}, 0, [_player, _item, _flag, _mouseClickID]] call CBA_fnc_addPerFrameHandler;

View File

@ -15,3 +15,12 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define PLACE_WAITING -1
#define PLACE_CANCEL 0
#define PLACE_APPROVE 1
#define MIN_HEIGHT -0.3
#define MAX_HEIGHT 0.4
#define FLAG_PLACING_DISTANCE 2

View File

@ -25,12 +25,29 @@
<Chinesesimp>不管地形表面是什么都可以放标记旗</Chinesesimp>
</Key>
<Key ID="STR_ACE_Marker_Flags_ActionPlace">
<English>Place Flag</English>
<German>Flagge platzieren</German>
<Polish>Postaw chorągiewkę</Polish>
<Japanese>旗を設置</Japanese>
<Korean>깃발 배치</Korean>
<Chinesesimp>放置标记旗</Chinesesimp>
<English>Place Marker Flag</English>
<German>Markierungsfahne platzieren</German>
</Key>
<Key ID="STR_ACE_Marker_Flags_ActionAdjustHeight">
<English>Adjust height</English>
<German>Höhe anpassen</German>
</Key>
<Key ID="STR_ACE_Marker_Flags_ActionCancel">
<English>Cancel</English>
<German>Abbrechen</German>
<Spanish>Cancelar</Spanish>
<Polish>Anuluj</Polish>
<French>Annuler</French>
<Czech>Zrušit</Czech>
<Italian>Annulla</Italian>
<Hungarian>Mégsem</Hungarian>
<Portuguese>Cancelar</Portuguese>
<Russian>Отмена</Russian>
<Japanese>中止</Japanese>
<Korean>취소</Korean>
<Chinesesimp>取消</Chinesesimp>
<Chinese>取消</Chinese>
<Turkish>Iptal</Turkish>
</Key>
<Key ID="STR_ACE_Marker_Flags_ActionPickUp">
<English>Pick Up</English>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.