mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Interaction - Rename group self-interact (#8346)
* Group renaming self interact * UI base * Custom UI solution (looks terrible) * Improve GUI, optimise functions * Add exitWith return value to fnc_renameGroup * tabs to spaces * Small tweaks * newlines pre-empting newline gestapo * input prompt caps * Implement suggestions * Remove already inherited value * Per-side group name handling * Add same group case sensitive changes. * Suggestions - Use ace_common_fnc_displayTextStructured - Formatting - Phrasing of strings * replace spawn with CBA_fnc_execNextFrame * Update addons/interaction/initSettings.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
3d9315529d
commit
88e774c30d
@ -303,6 +303,13 @@ class CfgVehicles {
|
||||
showDisabled = 1;
|
||||
icon = QPATHTOF(UI\team\team_management_ca.paa);
|
||||
};
|
||||
class ACE_RenameGroup {
|
||||
displayName = CSTRING(RenameGroup);
|
||||
condition = QUOTE(_player call FUNC(canRenameGroup));
|
||||
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
|
||||
statement = QUOTE(_player call FUNC(renameGroupUI));
|
||||
showDisabled =1;
|
||||
};
|
||||
};
|
||||
|
||||
class ACE_Equipment {
|
||||
|
@ -32,6 +32,9 @@ PREP(canPardon);
|
||||
PREP(pardon);
|
||||
PREP(canPullOutBody);
|
||||
PREP(pullOutBody);
|
||||
PREP(canRenameGroup);
|
||||
PREP(renameGroupUI);
|
||||
PREP(renameGroup);
|
||||
|
||||
// Weapon Attachments
|
||||
PREP(getWeaponAttachmentsActions);
|
||||
|
@ -19,3 +19,4 @@ class CfgPatches {
|
||||
#include "RscTitles.hpp"
|
||||
#include "ACE_Settings.hpp"
|
||||
#include "ACE_ZeusActions.hpp"
|
||||
#include "groupRename_GUI.hpp"
|
||||
|
20
addons/interaction/functions/fnc_canRenameGroup.sqf
Normal file
20
addons/interaction/functions/fnc_canRenameGroup.sqf
Normal file
@ -0,0 +1,20 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Seb
|
||||
* Checks if the unit is allowed to rename its group.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Is this unit allowed to rename its group? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* player call ace_interaction_fnc_canRenameGroup
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params [["_unit", objNull, [objNull]]];
|
||||
|
||||
GVAR(enableGroupRenaming) && {_unit == leader _unit}
|
39
addons/interaction/functions/fnc_renameGroup.sqf
Normal file
39
addons/interaction/functions/fnc_renameGroup.sqf
Normal file
@ -0,0 +1,39 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Seb
|
||||
* Renames a group to a given string (groupID), whilst checking that it is not an invalid name.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The group to be renamed <GROUP>
|
||||
* 1: The new name of the group <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Whether the group was succesfully renamed <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [group player, "leet squad"] call ace_interaction_fnc_renameGroup
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params [
|
||||
["_group", grpNull, [grpNull]],
|
||||
["_newName", "", [""]]
|
||||
];
|
||||
if (_newName isEqualTo (groupID _group)) exitWith {true};
|
||||
|
||||
private _lowerName = toLower _newName; // Case insensitive name search
|
||||
private _nameAlreadyTaken = allGroups findIf {
|
||||
side _x isEqualTo side _group
|
||||
&& {_lowerName isEqualTo toLower (groupID _x)}
|
||||
&& {_group != _x}
|
||||
} != -1;
|
||||
|
||||
|
||||
if (_nameAlreadyTaken) then {
|
||||
[LLSTRING(RenameGroupAlreadyExists)] call EFUNC(common,displayTextStructured);
|
||||
} else {
|
||||
_group setGroupIdGlobal [_newName];
|
||||
};
|
||||
|
||||
!_nameAlreadyTaken
|
36
addons/interaction/functions/fnc_renameGroupUI.sqf
Normal file
36
addons/interaction/functions/fnc_renameGroupUI.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Seb
|
||||
* Shows a UI to allow a unit to change its group ID.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The unit renaming their group <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* player call ace_interaction_fnc_renameGroupUI
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
// delay a frame so we don't overlap with interaction-menu as it closes
|
||||
[{
|
||||
params [["_unit", objNull, [objNull]]];
|
||||
|
||||
private _display = findDisplay 46 createDisplay QGVAR(groupNameDisplay);
|
||||
private _textCtrl = _display displayCtrl 451;
|
||||
_textCtrl ctrlSetText (groupID group _unit);
|
||||
_display setVariable [QGVAR(renamedGroup), group _unit];
|
||||
_display displayAddEventHandler ["Unload", {
|
||||
params ["_display", "_exitCode"];
|
||||
|
||||
if !(_exitCode isEqualTo 1) exitWith {};
|
||||
|
||||
private _group = _display getVariable QGVAR(renamedGroup);
|
||||
private _textCtrl = _display displayCtrl 451;
|
||||
private _newName = ctrlText _textCtrl;
|
||||
[_group, _newName] call FUNC(renameGroup);
|
||||
}];
|
||||
}, _this] call CBA_fnc_execNextFrame;
|
66
addons/interaction/groupRename_GUI.hpp
Normal file
66
addons/interaction/groupRename_GUI.hpp
Normal file
@ -0,0 +1,66 @@
|
||||
#define FONT_H (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)
|
||||
#define FONT_W (FONT_H / pixelH * pixelW)
|
||||
#define GAP_W (pixelW * 2)
|
||||
#define GAP_H (pixelH * 2)
|
||||
#define ELEMENT_HEIGHT FONT_H + FONT_W
|
||||
#define TOTAL_W FONT_W * 25
|
||||
#define TOTAL_H FONT_H * 3 + GAP_H
|
||||
|
||||
class ctrlStatic;
|
||||
class ctrlButton;
|
||||
class ctrlEdit;
|
||||
class ctrlStaticTitle;
|
||||
|
||||
class GVAR(groupNameDisplay) {
|
||||
idd = -1;
|
||||
enableSimulation = 1;
|
||||
|
||||
class ControlsBackground {
|
||||
class Title: ctrlStaticTitle {
|
||||
x = QUOTE(safeZoneX + (safeZoneW / 2) - TOTAL_W/2);
|
||||
y = QUOTE(safeZoneY + (safeZoneH / 2) - (FONT_H * 1.2) - GAP_H);
|
||||
w = QUOTE(TOTAL_W);
|
||||
h = QUOTE(FONT_H * 1.2);
|
||||
sizeEx = QUOTE(FONT_H * 1.2);
|
||||
text = CSTRING(renameGroupInput);
|
||||
};
|
||||
class Background: ctrlStatic {
|
||||
colorBackground[] = {0, 0, 0, 0.8};
|
||||
x = QUOTE(safeZoneX + (safeZoneW / 2) - TOTAL_W/2);
|
||||
y = QUOTE(safeZoneY + (safeZoneH / 2));
|
||||
w = QUOTE(TOTAL_W);
|
||||
h = QUOTE(ELEMENT_HEIGHT);
|
||||
};
|
||||
};
|
||||
|
||||
class controls {
|
||||
class Input: ctrlEdit {
|
||||
idc = 451;
|
||||
x = QUOTE(safeZoneX + (safeZoneW / 2) - TOTAL_W/2 + FONT_W/2);
|
||||
y = QUOTE(safeZoneY + (safeZoneH / 2) + FONT_W/2);
|
||||
w = QUOTE(TOTAL_W - FONT_W);
|
||||
h = QUOTE(ELEMENT_HEIGHT - FONT_W);
|
||||
sizeEx = QUOTE(FONT_H);
|
||||
};
|
||||
|
||||
class OkButton: ctrlButton {
|
||||
idc = 1;
|
||||
x = QUOTE(safeZoneX + (safeZoneW / 2) + TOTAL_W/2 - FONT_W * 15);
|
||||
y = QUOTE(safeZoneY + (safeZoneH / 2) + ELEMENT_HEIGHT + GAP_H);
|
||||
w = QUOTE(FONT_W * 15);
|
||||
h = QUOTE(ELEMENT_HEIGHT - FONT_W);
|
||||
sizeEx = QUOTE(FONT_H);
|
||||
text = CSTRING(RenameGroup);
|
||||
};
|
||||
|
||||
class CancelButton: ctrlButton {
|
||||
idc = 2;
|
||||
x = QUOTE(safeZoneX + (safeZoneW / 2) - TOTAL_W/2);
|
||||
y = QUOTE(safeZoneY + (safeZoneH / 2) + ELEMENT_HEIGHT + GAP_H);
|
||||
w = QUOTE(FONT_W * 6);
|
||||
h = QUOTE(ELEMENT_HEIGHT - FONT_W);
|
||||
sizeEx = QUOTE(FONT_H);
|
||||
text = CSTRING(CancelSelection);
|
||||
};
|
||||
};
|
||||
};
|
@ -29,3 +29,11 @@
|
||||
format ["ACE %1", LLSTRING(DisplayName)],
|
||||
true
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
QGVAR(enableGroupRenaming), "CHECKBOX",
|
||||
[LSTRING(EnableRenameGroup_DisplayName), LSTRING(EnableRenameGroup_Description)],
|
||||
format ["ACE %1", LLSTRING(DisplayName)],
|
||||
true,
|
||||
true
|
||||
] call CBA_fnc_addSetting;
|
||||
|
@ -323,6 +323,15 @@
|
||||
<Chinese>成為隊長</Chinese>
|
||||
<Turkish>Lider ol</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_RenameGroup">
|
||||
<English>Rename Group</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_RenameGroupAlreadyExists">
|
||||
<English>This group name is already in use.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_RenameGroupInput">
|
||||
<English>NEW GROUP NAME:</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_Dance">
|
||||
<English>DANCE!</English>
|
||||
<German>TANZEN!</German>
|
||||
@ -1227,5 +1236,11 @@
|
||||
<French>Cette option permet de fixer/retirer des accessoires d'arme à partir du menu d'interaction personnel.</French>
|
||||
<Polish>Włącza akcje przyczepienia/odczepienia dodatków dla obecnej broni</Polish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_enableRenameGroup_DisplayName">
|
||||
<English>Allow group rename</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_enableRenameGroup_Description">
|
||||
<English>Allows a group leader to rename their group if the name is not already taken.</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user