diff --git a/addons/marker_flags/CfgEventHandlers.hpp b/addons/marker_flags/CfgEventHandlers.hpp index f6503c2479..b468b9e8b5 100644 --- a/addons/marker_flags/CfgEventHandlers.hpp +++ b/addons/marker_flags/CfgEventHandlers.hpp @@ -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)); + }; +}; diff --git a/addons/marker_flags/CfgVehicles.hpp b/addons/marker_flags/CfgVehicles.hpp index 0c8f63fe7c..6a615ca533 100644 --- a/addons/marker_flags/CfgVehicles.hpp +++ b/addons/marker_flags/CfgVehicles.hpp @@ -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)"}; }; }; diff --git a/addons/marker_flags/CfgWeapons.hpp b/addons/marker_flags/CfgWeapons.hpp index 0f80e7c78b..b4c2f88125 100644 --- a/addons/marker_flags/CfgWeapons.hpp +++ b/addons/marker_flags/CfgWeapons.hpp @@ -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); }; diff --git a/addons/marker_flags/XEH_PREP.hpp b/addons/marker_flags/XEH_PREP.hpp index fec1927b78..628433ff1c 100644 --- a/addons/marker_flags/XEH_PREP.hpp +++ b/addons/marker_flags/XEH_PREP.hpp @@ -1,5 +1,6 @@ PREP(addActions); PREP(canPlace); PREP(getFlags); +PREP(handleScrollWheel); PREP(pickUpFlag); PREP(placeFlag); diff --git a/addons/marker_flags/XEH_missionDisplayLoad.sqf b/addons/marker_flags/XEH_missionDisplayLoad.sqf new file mode 100644 index 0000000000..fc336ad799 --- /dev/null +++ b/addons/marker_flags/XEH_missionDisplayLoad.sqf @@ -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; +}]; diff --git a/addons/marker_flags/XEH_postInit.sqf b/addons/marker_flags/XEH_postInit.sqf index 0bed83af7b..19011893cc 100644 --- a/addons/marker_flags/XEH_postInit.sqf +++ b/addons/marker_flags/XEH_postInit.sqf @@ -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; diff --git a/addons/marker_flags/XEH_preStart.sqf b/addons/marker_flags/XEH_preStart.sqf index ed4901a073..2a2bc52161 100644 --- a/addons/marker_flags/XEH_preStart.sqf +++ b/addons/marker_flags/XEH_preStart.sqf @@ -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]; diff --git a/addons/marker_flags/config.cpp b/addons/marker_flags/config.cpp index 02b054fa27..078a0d8e7e 100644 --- a/addons/marker_flags/config.cpp +++ b/addons/marker_flags/config.cpp @@ -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; }; diff --git a/addons/marker_flags/functions/fnc_addActions.sqf b/addons/marker_flags/functions/fnc_addActions.sqf index 57112f8de9..346cdbe7f8 100644 --- a/addons/marker_flags/functions/fnc_addActions.sqf +++ b/addons/marker_flags/functions/fnc_addActions.sqf @@ -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}, {}, diff --git a/addons/marker_flags/functions/fnc_handleScrollWheel.sqf b/addons/marker_flags/functions/fnc_handleScrollWheel.sqf new file mode 100644 index 0000000000..c6430be650 --- /dev/null +++ b/addons/marker_flags/functions/fnc_handleScrollWheel.sqf @@ -0,0 +1,30 @@ +#include "script_component.hpp" +/* + * Author: Timi007 + * Handles the marker flag object height. + * + * Arguments: + * 0: Scroll amount + * + * Return Value: + * Handled + * + * 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 diff --git a/addons/marker_flags/functions/fnc_pickUpFlag.sqf b/addons/marker_flags/functions/fnc_pickUpFlag.sqf index 011380c020..f3ef5e118a 100644 --- a/addons/marker_flags/functions/fnc_pickUpFlag.sqf +++ b/addons/marker_flags/functions/fnc_pickUpFlag.sqf @@ -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; diff --git a/addons/marker_flags/functions/fnc_placeFlag.sqf b/addons/marker_flags/functions/fnc_placeFlag.sqf index d89bb52614..d5c4bdcb13 100644 --- a/addons/marker_flags/functions/fnc_placeFlag.sqf +++ b/addons/marker_flags/functions/fnc_placeFlag.sqf @@ -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 - * 1: Flag + * 0: Player + * 1: Flag item * * Return Value: - * Flag + * 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; diff --git a/addons/marker_flags/script_component.hpp b/addons/marker_flags/script_component.hpp index c85bdba3b1..bef8c1d423 100644 --- a/addons/marker_flags/script_component.hpp +++ b/addons/marker_flags/script_component.hpp @@ -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 diff --git a/addons/marker_flags/stringtable.xml b/addons/marker_flags/stringtable.xml index e10510face..a567ed226e 100644 --- a/addons/marker_flags/stringtable.xml +++ b/addons/marker_flags/stringtable.xml @@ -25,12 +25,29 @@ 不管地形表面是什么都可以放标记旗 - Place Flag - Flagge platzieren - Postaw chorągiewkę - 旗を設置 - 깃발 배치 - 放置标记旗 + Place Marker Flag + Markierungsfahne platzieren + + + Adjust height + Höhe anpassen + + + Cancel + Abbrechen + Cancelar + Anuluj + Annuler + Zrušit + Annulla + Mégsem + Cancelar + Отмена + 中止 + 취소 + 取消 + 取消 + Iptal Pick Up diff --git a/addons/marker_flags/ui/icons/black_place_icon.paa b/addons/marker_flags/ui/icons/black_place_icon.paa new file mode 100644 index 0000000000..5526fc2c92 Binary files /dev/null and b/addons/marker_flags/ui/icons/black_place_icon.paa differ diff --git a/addons/marker_flags/ui/icons/blue_place_icon.paa b/addons/marker_flags/ui/icons/blue_place_icon.paa new file mode 100644 index 0000000000..8f899cae24 Binary files /dev/null and b/addons/marker_flags/ui/icons/blue_place_icon.paa differ diff --git a/addons/marker_flags/ui/icons/green_place_icon.paa b/addons/marker_flags/ui/icons/green_place_icon.paa new file mode 100644 index 0000000000..151b597cfe Binary files /dev/null and b/addons/marker_flags/ui/icons/green_place_icon.paa differ diff --git a/addons/marker_flags/ui/icons/orange_place_icon.paa b/addons/marker_flags/ui/icons/orange_place_icon.paa new file mode 100644 index 0000000000..7477a4a07f Binary files /dev/null and b/addons/marker_flags/ui/icons/orange_place_icon.paa differ diff --git a/addons/marker_flags/ui/icons/purple_place_icon.paa b/addons/marker_flags/ui/icons/purple_place_icon.paa new file mode 100644 index 0000000000..1c5a63d8ef Binary files /dev/null and b/addons/marker_flags/ui/icons/purple_place_icon.paa differ diff --git a/addons/marker_flags/ui/icons/red_place_icon.paa b/addons/marker_flags/ui/icons/red_place_icon.paa new file mode 100644 index 0000000000..c0fcea9048 Binary files /dev/null and b/addons/marker_flags/ui/icons/red_place_icon.paa differ diff --git a/addons/marker_flags/ui/icons/white_pickup_icon.paa b/addons/marker_flags/ui/icons/white_pickup_icon.paa new file mode 100644 index 0000000000..bc5d4ac7e4 Binary files /dev/null and b/addons/marker_flags/ui/icons/white_pickup_icon.paa differ diff --git a/addons/marker_flags/ui/icons/white_place_icon.paa b/addons/marker_flags/ui/icons/white_place_icon.paa new file mode 100644 index 0000000000..c4f03200d8 Binary files /dev/null and b/addons/marker_flags/ui/icons/white_place_icon.paa differ diff --git a/addons/marker_flags/ui/icons/yellow_place_icon.paa b/addons/marker_flags/ui/icons/yellow_place_icon.paa new file mode 100644 index 0000000000..965a36185f Binary files /dev/null and b/addons/marker_flags/ui/icons/yellow_place_icon.paa differ