Skip to content

Commit

Permalink
Fixed messages not showing
Browse files Browse the repository at this point in the history
  • Loading branch information
AdlerSalbei committed Sep 10, 2021
1 parent 76523bb commit 7425467
Show file tree
Hide file tree
Showing 18 changed files with 265 additions and 252 deletions.
8 changes: 8 additions & 0 deletions addons/adminMessages/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREP(displayMessage);
PREP(initListbox);
PREP(isAdminOrZeus);
PREP(onRecipientChanged);
PREP(receiveMessage);
PREP(sendMessage);
PREP(setSendButtonPosition);
PREP(setTitle);
9 changes: 9 additions & 0 deletions addons/adminMessages/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

ADDON = true;
3 changes: 3 additions & 0 deletions addons/adminMessages/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
7 changes: 7 additions & 0 deletions addons/adminMessages/cfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ class Extended_PostInit_EventHandlers {
class Extended_PreInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_preClientInit));
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};
16 changes: 0 additions & 16 deletions addons/adminMessages/cfgFunctions.hpp

This file was deleted.

1 change: 0 additions & 1 deletion addons/adminMessages/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class CfgPatches {
};

#include "cfgEventHandlers.hpp"
#include "cfgFunctions.hpp"

#include "gui\defines.hpp"
#include "gui\sendBoxBase.hpp"
Expand Down
19 changes: 0 additions & 19 deletions addons/adminMessages/functions/fn_receiveMessage.sqf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#include "script_component.hpp"
#include "..\gui\defines.hpp"

params [["_info",""],["_message",""]];

// chat is disabled by grad_minui >> display message in custom rscTitle
if (
!isNil "grad_minui_fnc_setting" &&
{
(!visibleMap && !(["chat_enabled"] call grad_minui_fnc_setting)) ||
(visibleMap && !(["chat_enabled_map"] call grad_minui_fnc_setting))
}
) then {

QGVAR(customChatLayer) cutRsc [QGVAR(rscCustomChat),"PLAIN",-1,true];
private _customChatTitleDisplay = uiNamespace getVariable [QGVAR(rscCustomChat),displayNull];
private _ctrlText = _customChatTitleDisplay displayCtrl GA_ADMINMESSAGES_IDC_CUSTOMCHATTEXT;

_ctrlText ctrlSetStructuredText parseText format ["<t color='#E51919'>%1</t> %2",format [localize "STR_grad_ADMINMESSAGES_CHANNEL",_info],_message];

private _textHeight = ctrlTextHeight _ctrlText;
/* private _textWidth = ctrlTextWidth _ctrlText; */

(ctrlPosition _ctrlText) params ["_origX","_origY","_origW"];

_ctrlText ctrlSetPosition [_origX,_origY - _textHeight,_origW,_textHeight];
_ctrlText ctrlCommit 0;

};


// add message to chat either way >> user can check chat history on map, if enabled
GVAR(channel) radioChannelAdd [player];
GVAR(channel) radioChannelSetCallsign format [localize "STR_grad_ADMINMESSAGES_CHANNEL",_info];

player customChat [GVAR(channel), _message];
GVAR(channel) radioChannelRemove [player];
#include "script_component.hpp"
#include "..\gui\defines.hpp"

params [["_info",""],["_message",""]];

// chat is disabled by grad_minui >> display message in custom rscTitle
if (
!isNil "grad_minui_fnc_setting" &&
{
(!visibleMap && !(["chat_enabled"] call grad_minui_fnc_setting)) ||
(visibleMap && !(["chat_enabled_map"] call grad_minui_fnc_setting))
}
) then {

QGVAR(customChatLayer) cutRsc [QGVAR(rscCustomChat),"PLAIN",-1,true];
private _customChatTitleDisplay = uiNamespace getVariable [QGVAR(rscCustomChat),displayNull];
private _ctrlText = _customChatTitleDisplay displayCtrl GA_ADMINMESSAGES_IDC_CUSTOMCHATTEXT;

_ctrlText ctrlSetStructuredText parseText format ["<t color='#E51919'>%1</t> %2",format [localize "STR_grad_ADMINMESSAGES_CHANNEL",_info],_message];

private _textHeight = ctrlTextHeight _ctrlText;
/* private _textWidth = ctrlTextWidth _ctrlText; */

(ctrlPosition _ctrlText) params ["_origX","_origY","_origW"];

_ctrlText ctrlSetPosition [_origX,_origY - _textHeight,_origW,_textHeight];
_ctrlText ctrlCommit 0;

};


// add message to chat either way >> user can check chat history on map, if enabled
GVAR(channel) radioChannelAdd [player];
GVAR(channel) radioChannelSetCallsign format [localize "STR_grad_ADMINMESSAGES_CHANNEL",_info];

player customChat [GVAR(channel), _message];
GVAR(channel) radioChannelRemove [player];
Original file line number Diff line number Diff line change
@@ -1,73 +1,75 @@
#include "script_component.hpp"

params [["_ctrl",controlNull]];

if !([] call grad_adminMessages_fnc_isAdminOrZeus) exitWith {_ctrl ctrlShow false};

private _fnc_getHeadlineText = {
params ["_locStr"];
private _text = localize _locStr;
_text = _text + " =======================================================================================";
_text = [_text,0,30] call BIS_fnc_trimString;
_text
};

private _fnc_addEntry = {
params ["_text","_data"];
private _index = _ctrl lbAdd _text;
_ctrl lbSetData [_index,if !(_data isEqualType "") then {str _data} else {_data}];
_index
};

private _fnc_addHeadline = {
params ["_locStr"];
private _index = [[_locStr] call _fnc_getHeadlineText,-1] call _fnc_addEntry;
_ctrl lbSetColor [_index,[0.7,0.7,0.7,1]];
};


//LATEST CONVERSATIONS =========================================================
if (!isNil "grad_adminMessages_latestConvos" && {count grad_adminMessages_latestConvos > 0}) then {
["STR_grad_ADMINMESSAGES_LATESTCONVOS"] call _fnc_addHeadline;
{
_x call _fnc_addEntry;
false
} count grad_adminMessages_latestConvos;
["",-1] call _fnc_addEntry;
};


//BY SIDE ======================================================================
["STR_grad_ADMINMESSAGES_BYCATEGORY"] call _fnc_addHeadline;
[localize "STR_grad_ADMINMESSAGES_EVERYONE",-2] call _fnc_addEntry;
[localize "STR_grad_ADMINMESSAGES_OTHERADMINS",-3] call _fnc_addEntry;
["BLUFOR",-4] call _fnc_addEntry;
["OPFOR",-5] call _fnc_addEntry;
["INDEPENDENT",-6] call _fnc_addEntry;
["CIVILIAN",-7] call _fnc_addEntry;
["",-1] call _fnc_addEntry;


//LIST OF PLAYERS ==============================================================
["STR_grad_ADMINMESSAGES_BYPLAYER"] call _fnc_addHeadline;
private _playerData = [];
{
_playerData pushBack [toUpper ([_x,true] call BIS_fnc_getName),getPlayerUID _x];
false
} count ([] call CBA_fnc_players);
_playerData sort false;

{
_x call _fnc_addEntry;
false
} count _playerData;


//SET CURSEL ===================================================================
if (lbCurSel _ctrl < 0 || lbCurSel _ctrl >= lbSize _ctrl) then {
_ctrl lbSetCurSel 1;
} else {
if (call compile (_ctrl lbData (lbCursel _ctrl)) < 0) then {
_ctrl lbSetCurSel 1;
};
};
#include "script_component.hpp"

params [["_ctrl", controlNull]];

uiNamespace setVariable [QGVAR(sendBoxListboxCtrl), _ctrl];

if !([] call FUNC(isAdminOrZeus)) exitWith {_ctrl ctrlShow false};

private _fnc_getHeadlineText = {
params ["_locStr"];
private _text = localize _locStr;
_text = _text + " =======================================================================================";
_text = [_text,0,30] call BIS_fnc_trimString;
_text
};

private _fnc_addEntry = {
params ["_text","_data"];
private _index = _ctrl lbAdd _text;
_ctrl lbSetData [_index,if !(_data isEqualType "") then {str _data} else {_data}];
_index
};

private _fnc_addHeadline = {
params ["_locStr"];
private _index = [[_locStr] call _fnc_getHeadlineText,-1] call _fnc_addEntry;
_ctrl lbSetColor [_index,[0.7,0.7,0.7,1]];
};


//LATEST CONVERSATIONS =========================================================
if (!isNil QGVAR(latestConvos) && {count GVAR(latestConvos) > 0}) then {
["STR_grad_ADMINMESSAGES_LATESTCONVOS"] call _fnc_addHeadline;
{
_x call _fnc_addEntry;
false
} count GVAR(latestConvos);
["",-1] call _fnc_addEntry;
};


//BY SIDE ======================================================================
["STR_grad_ADMINMESSAGES_BYCATEGORY"] call _fnc_addHeadline;
[localize "STR_grad_ADMINMESSAGES_EVERYONE",-2] call _fnc_addEntry;
[localize "STR_grad_ADMINMESSAGES_OTHERADMINS",-3] call _fnc_addEntry;
["BLUFOR",-4] call _fnc_addEntry;
["OPFOR",-5] call _fnc_addEntry;
["INDEPENDENT",-6] call _fnc_addEntry;
["CIVILIAN",-7] call _fnc_addEntry;
["",-1] call _fnc_addEntry;


//LIST OF PLAYERS ==============================================================
["STR_grad_ADMINMESSAGES_BYPLAYER"] call _fnc_addHeadline;
private _playerData = [];
{
_playerData pushBack [toUpper ([_x,true] call BIS_fnc_getName),getPlayerUID _x];
false
} count ([] call CBA_fnc_players);
_playerData sort false;

{
_x call _fnc_addEntry;
false
} count _playerData;


//SET CURSEL ===================================================================
if (lbCurSel _ctrl < 0 || lbCurSel _ctrl >= lbSize _ctrl) then {
_ctrl lbSetCurSel 1;
} else {
if (call compile (_ctrl lbData (lbCursel _ctrl)) < 0) then {
_ctrl lbSetCurSel 1;
};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "script_component.hpp"

serverCommandAvailable "#kick" ||
!isNull (getAssignedCuratorlogic player)
#include "script_component.hpp"

serverCommandAvailable "#kick" ||
!isNull (getAssignedCuratorlogic player)
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "script_component.hpp"

params [["_ctrl",controlNull],["_selID",-1]];

private _data = call compile (_ctrl lbData _selID);

private _sendButton = uiNamespace getVariable ["grad_adminMessages_sendBoxButtonCtrl",controlNull];

if (!(_data isEqualType 0) || {_data == -1}) then {
_sendButton ctrlEnable false;
_sendButton ctrlSetText (localize "STR_grad_ADMINMESSAGES_SELECTVALIDRECIP");
} else {
_sendButton ctrlEnable true;
_sendButton ctrlSetText format [(localize "STR_grad_ADMINMESSAGES_SENDTO"),_ctrl lbText _selID];
};
#include "script_component.hpp"

params [["_ctrl", controlNull],["_selID", -1]];

private _data = call compile (_ctrl lbData _selID);

private _sendButton = uiNamespace getVariable [QGVAR(sendBoxButtonCtrl), controlNull];

if (!(_data isEqualType 0) || {_data == -1}) then {
_sendButton ctrlEnable false;
_sendButton ctrlSetText (localize "STR_grad_ADMINMESSAGES_SELECTVALIDRECIP");
} else {
_sendButton ctrlEnable true;
_sendButton ctrlSetText format [(localize "STR_grad_ADMINMESSAGES_SENDTO"), _ctrl lbText _selID];
};
19 changes: 19 additions & 0 deletions addons/adminMessages/functions/fnc_receiveMessage.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "script_component.hpp"

params ["_sender", "_UID", "_message", ["_receiveCondition",{[] call FUNC(isAdminOrZeus)}], ["_receiveConditionParams",[]]];

if !(hasInterface) exitWith {};
if !(_receiveConditionParams call _receiveCondition) exitWith {};
if (profileName == _sender) exitWith {};

if (isNil QGVAR(latestConvos)) then {GVAR(latestConvos) = []};
if (GVAR(latestConvos) find [toUpper _sender,_UID] < 0) then {
reverse GVAR(latestConvos);
GVAR(latestConvos) pushBack [toUpper _sender,_UID];
reverse GVAR(latestConvos);
};
if (count GVAR(latestConvos) > 5) then {GVAR(latestConvos) resize 5};

[_sender,_message] call FUNC(displayMessage);

playSound "3DEN_notificationWarning";
Loading

0 comments on commit 7425467

Please sign in to comment.