Commit 371a2aa6 authored by Razer's avatar Razer
Browse files

Added clan journal

parent e6b8369e
......@@ -8,8 +8,6 @@ switch _mode do {
// Get Arrows data and set the correct texts
_leftArrowCtrl = _display getVariable "arrowLeft";
_rightArrowCtrl = _display getVariable "arrowRight";
_leftArrowCtrl ctrlSetText "Exit";
_rightArrowCtrl ctrlSetText "Progression";
_display displayAddEventHandler ["KeyDown",{
["keyDisplay", _this] call SELF;
......@@ -49,6 +47,7 @@ switch _mode do {
}];
//--- Add arrow events
_rightArrowCtrl ctrlSetText "Progression";
_rightArrowCtrl ctrlAddEventHandler ["ButtonClick",{
params ["_btnCtrl"];
_display = ctrlParent _btnCtrl;
......@@ -58,14 +57,31 @@ switch _mode do {
createDialog "RscDisplayDSRJournalProgression";
};
}];
_leftArrowCtrl ctrlAddEventHandler ["ButtonClick",{
params ["_btnCtrl"];
_display = ctrlParent _btnCtrl;
[_display] spawn {
params ["_display"];
_display closeDisplay 1;
};
}];
if (player getVariable ["clanUUID",""] != "") then {
// player in clan add clan page
_leftArrowCtrl ctrlSetText "Clan";
_leftArrowCtrl ctrlAddEventHandler ["ButtonClick",{
params ["_btnCtrl"];
_display = ctrlParent _btnCtrl;
[_display] spawn {
params ["_display"];
_display closeDisplay 1;
createDialog "RscDisplayDSRJournalClan";
};
}];
} else {
// Player not in clan, use exit
_leftArrowCtrl ctrlSetText "Exit";
_leftArrowCtrl ctrlAddEventHandler ["ButtonClick",{
params ["_btnCtrl"];
_display = ctrlParent _btnCtrl;
[_display] spawn {
params ["_display"];
_display closeDisplay 1;
};
}];
};
};
case "endSearch":{
_params params ["_btnEndSearch"];
......
#define SELF DS_fnc_RscDisplayDSRJournalClan
params ["_mode","_params","_class"];
switch _mode do {
case "onLoad":{
_params params ["_display"];
// Get control classes
_titleClan = _display getVariable "TitleClan";
_TextClanPlayers = _display getVariable "TextClanPlayers";
_listPlayers = _display getVariable "ListPlayers";
// TODO ADD COMMANDS BASED ON RANK (DEFINE RANKS)
_TextUserInfo = _display getVariable "TextUserInfo";
_TextRank = _display getVariable "TextRank";
_ComboRank = _display getVariable "ComboRank";
_TextComment = _display getVariable "TextComment";
_EditComment = _display getVariable "EditComment";
_clanUUID = player getVariable ["clanUUID",""];
if (_clanUUID == "") exitWith {_display closeDisplay 1};
// [name, owners uuid, owners steamid, owners lastnick, [members],[variables]]
// [[player uuid, steamid, lastnick, rank, comment], [player uuid, steamid, lastnick, rank, comment]]
_clanData = [_clanUUID] call DB_fnc_getClanData;
_clanData params ["_clanName","_ownerUUID","_ownerSteamID","_ownerName","_clanMembers","_clanVariables"];
_display setVariable ["ClanData",_clanData];
_isOnline = {
params ["_pUUID"];
if ((allPlayers findIf {_x getVariable ["pUUID",""] == _pUUID}) != -1) then {
// Online
[0,1,0,1]
} else {
// Offline
[1,0,0,1]
};
};
// Set clan name
_titleClan ctrlSetStructuredText parseText format ["<t align='center' size='1.5'>Clan: %1</t>",_clanName];
// Add owner to list
_listPlayers lbAdd _ownerName;
_listPlayers lbSetColor [0,[_ownerUUID] call _isOnline];
// Add members to list (sort by rank?)
for "_i" from 0 to (count _clanMembers) - 1 do {
(_clanMembers select _i) params ["_memberUUID","_memberSteamID","_memberName","_memberRank","_memberComment"];
_index = _listPlayers lbAdd _memberName;
_listPlayers lbSetColor [_index,[_ownerUUID] call _isOnline];
};
// Add event to update selected target player
_listPlayers ctrlAddEventHandler ["onLBListSelChanged",{
params ["_control","_selectedIndex"];
_display = ctrlParent _control;
if (_selectedIndex == -1) exitWith {};
_clanData = _display getVariable "ClanData";
// Select owner or member
_targetUUID = [((_clanData#4)#(_selectedIndex - 1))#0,_clanData#1] select (_selectedIndex == 0);
_targetName = [((_clanData#4)#(_selectedIndex - 1))#2,_clanData#2] select (_selectedIndex == 0);
_display setVariable ["TargetUserData",[_targetUUID,_targetName]];
}];
//--- Add button events
// Kick
_buttonKick = _display getVariable "ButtonKick";
_buttonSaveComment ctrlAddEventHandler ["ButtonClick",{
["kick",_this] spawn SELF;
}];
// Save comment
_buttonSaveComment = _display getVariable "ButtonSaveComment";
_buttonSaveComment ctrlAddEventHandler ["ButtonClick",{
["savecomment",_this] spawn SELF;
}];
// Rank
_buttonSetRank = _display getVariable "ButtonSetRank";
_buttonSetRank ctrlAddEventHandler ["ButtonClick",{
["setrank",_this] spawn SELF;
}];
// Leave
_buttonLeave = _display getVariable "ButtonLeave";
_buttonLeave ctrlAddEventHandler ["ButtonClick",{
["leave",_this] spawn SELF;
}];
//--- Add arrow events
_leftArrowCtrl = _display getVariable "arrowLeft";
_rightArrowCtrl = _display getVariable "arrowRight";
_leftArrowCtrl ctrlSetText "Exit";
_rightArrowCtrl ctrlSetText "Notes";
_rightArrowCtrl ctrlAddEventHandler ["ButtonClick",{
["nextpage",_this] spawn SELF;
}];
_leftArrowCtrl ctrlAddEventHandler ["ButtonClick",{
["previouspage", _this] spawn SELF;
}];
};
case "kick":{
_params params ["_buttonKick"];
_display = ctrlParent _buttonKick;
_listPlayers = _display getVariable "ListPlayers";
_selectedPlayer = _display getVariable ["TargetUserData",[]];
_selectedPlayer params ["_clanUUID","_targetUUID","_nameTarget"];
_clanUUID = player getVariable "clanUUID";
_confirm = [(format ["Are you sure you want to kick player: %1?",_nameTarget]),"Confirm Kick",true,true] call BIS_fnc_guiMessage;
if (_confirm) then {
// TODO Make sure kick was success
[_targetUUID,_clanUUID] remoteExec ["DB_fnc_removeClanPlayer",2];
systemChat "Player kicked";
};
};
case "leave":{
_params params ["_buttonLeave"];
// TODO If clan owener, change owner?
_display = ctrlParent _buttonLeave;
_confirm = ["Are you sure?","Confirm leave",true,true] call BIS_fnc_guiMessage;
if (_confirm) then {
// TODO get success
[player] remoteExec ["DB_fnc_removeClanPlayer",2];
systemChat "You left the clan";
};
_display closeDisplay 1;
};
case "setrank":{
_params params ["_buttonSetRank"];
};
case "savecomment":{
_params params ["_buttonSaveComment"];
};
case "nextpage":{
_params params ["_rightArrowCtrl"];
_display = ctrlParent _rightArrowCtrl;
_display closeDisplay 1;
createDialog "RscDisplayDSRJournalNotes";
};
case "previouspage":{
_params params ["_leftArrowCtrl"];
_display = ctrlParent _leftArrowCtrl;
_display closeDisplay 1;
};
case "onUnload":{
_params params ["_display"];
};
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment