-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Co-authored-by: PabstMirror <[email protected]>
- Loading branch information
1 parent
3d93155
commit 88e774c
Showing
9 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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,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} |
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,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 |
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,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; |
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,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); | ||
}; | ||
}; | ||
}; |
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
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