From 07525388a6b5bd293ec8afddcf596cccd00b582f Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Sat, 29 Oct 2016 15:08:46 -0400 Subject: [PATCH] Hide group buttons on use --- SQF/dayz_code/Configs/RscDisplay/RscGroups.hpp | 18 +++++++++--------- SQF/dayz_code/groups/disbandGroup.sqf | 9 ++------- SQF/dayz_code/groups/groupIcons.sqf | 3 +-- SQF/dayz_code/groups/groupMarkers.sqf | 16 ++++++++++------ SQF/dayz_code/groups/inviteToGroup.sqf | 4 +--- SQF/dayz_code/groups/joinGroup.sqf | 18 ++++++++++-------- SQF/dayz_code/groups/kickFromGroup.sqf | 6 ++---- SQF/dayz_code/groups/leaveGroup.sqf | 6 ++---- SQF/dayz_code/groups/openDialog.sqf | 6 ++++-- SQF/dayz_code/groups/promotePlayer.sqf | 5 +---- SQF/dayz_code/groups/rejectGroup.sqf | 10 +++++++--- SQF/dayz_code/groups/selectGroupMember.sqf | 6 +++--- SQF/dayz_code/groups/selectPlayer.sqf | 7 ++++--- SQF/dayz_code/init/publicEH.sqf | 3 ++- 14 files changed, 58 insertions(+), 59 deletions(-) diff --git a/SQF/dayz_code/Configs/RscDisplay/RscGroups.hpp b/SQF/dayz_code/Configs/RscDisplay/RscGroups.hpp index 985f0ebea..c46e9eee3 100644 --- a/SQF/dayz_code/Configs/RscDisplay/RscGroups.hpp +++ b/SQF/dayz_code/Configs/RscDisplay/RscGroups.hpp @@ -160,7 +160,7 @@ class DZ_GroupDialog { class controls { class Players: DZ_GroupListBox { idc = 1; - onLBSelChanged = "(_this select 0) call dayz_selectPlayer;"; + onLBSelChanged = "call dayz_selectPlayer;"; x = .04; y = .21; w = .235; @@ -168,7 +168,7 @@ class DZ_GroupDialog { }; class MyGroup: DZ_GroupListBox { idc = 2; - onLBSelChanged = "(_this select 0) call dayz_selectGroupMember;"; + onLBSelChanged = "call dayz_selectGroupMember;"; x = .5; y = .21; w = .235; @@ -184,43 +184,43 @@ class DZ_GroupDialog { class Invite: DZ_GroupButton { idc = 3; text = $STR_EPOCH_INVITE; - onButtonClick = "(_this select 0) call dayz_inviteToGroup;"; + onButtonClick = "(_this select 0) ctrlShow false; call dayz_inviteToGroup;"; y = .184; }; class Kick: DZ_GroupButton { idc = 4; text = $STR_EPOCH_KICK; - onButtonClick = "(_this select 0) call dayz_kickFromGroup;"; + onButtonClick = "(_this select 0) ctrlShow false; call dayz_kickFromGroup;"; y = .239; }; class Disband: DZ_GroupButton { idc = 5; text = $STR_EPOCH_DISBAND; - onButtonClick = "(_this select 0) call dayz_disbandGroup;"; + onButtonClick = "(_this select 0) ctrlShow false; call dayz_disbandGroup;"; y = .349; }; class Promote: DZ_GroupButton { idc = 10; text = $STR_EPOCH_PROMOTE; - onButtonClick = "(_this select 0) call dayz_promotePlayer;"; + onButtonClick = "(_this select 0) ctrlShow false; call dayz_promotePlayer;"; y = .294; }; class Leave: DZ_GroupButton { idc = 6; text = $STR_EPOCH_LEAVE; - onButtonClick = "(_this select 0) call dayz_leaveGroup;"; + onButtonClick = "(_this select 0) ctrlShow false; call dayz_leaveGroup;"; y = .405; }; class Accept: DZ_GroupButton { idc = 7; text = $STR_EPOCH_ACCEPT; - onButtonClick = "(_this select 0) call dayz_joinGroup;"; + onButtonClick = "(_this select 0) ctrlShow false; call dayz_joinGroup;"; y = .5265; }; class Reject: DZ_GroupButton { idc = 8; text = $STR_EPOCH_REJECT; - onButtonClick = "(_this select 0) call dayz_rejectGroup;"; + onButtonClick = "(_this select 0) ctrlShow false; call dayz_rejectGroup;"; y = .5765; }; }; diff --git a/SQF/dayz_code/groups/disbandGroup.sqf b/SQF/dayz_code/groups/disbandGroup.sqf index d24c6733f..5b08280ec 100644 --- a/SQF/dayz_code/groups/disbandGroup.sqf +++ b/SQF/dayz_code/groups/disbandGroup.sqf @@ -1,9 +1,7 @@ private "_group"; _group = group player; -if (count (units _group) == 1 or (!isNil "dayz_groupDisbandThread" && {!scriptDone dayz_groupDisbandThread})) exitWith { - _this ctrlShow false; -}; +if (count (units _group) == 1 or (!isNil "dayz_groupDisbandThread" && {!scriptDone dayz_groupDisbandThread})) exitWith {}; dayz_groupDisbanded = nil; PVDZ_Server_UpdateGroup = [4,player]; @@ -13,9 +11,6 @@ dayz_groupDisbandThread = _group spawn { //Wait for response from server to confirm group finished updating in DB waitUntil {!isNil "dayz_groupDisbanded"}; - { - [_x] join grpNull; - } count (units _this); - + {[_x] join grpNull} count (units _this); deleteGroup _this; }; \ No newline at end of file diff --git a/SQF/dayz_code/groups/groupIcons.sqf b/SQF/dayz_code/groups/groupIcons.sqf index 66f6ab34f..080fd78d4 100644 --- a/SQF/dayz_code/groups/groupIcons.sqf +++ b/SQF/dayz_code/groups/groupIcons.sqf @@ -8,8 +8,7 @@ if (!visibleMap && count _group > 1 && cameraView in ["INTERNAL","EXTERNAL","GUN _display = uiNamespace getVariable "DZ_GroupIcons"; _index = 0; { - _pos = getPosATL _x; - if (surfaceIsWater _pos) then {_pos = getPosASL _x;}; + _pos = [_x] call FNC_GetPos; _distance = _pos distance player; _icon = _display displayCtrl (100 + _index); if (_distance > 1 && _distance < 2500) then { diff --git a/SQF/dayz_code/groups/groupMarkers.sqf b/SQF/dayz_code/groups/groupMarkers.sqf index 265624608..8df34313e 100644 --- a/SQF/dayz_code/groups/groupMarkers.sqf +++ b/SQF/dayz_code/groups/groupMarkers.sqf @@ -1,5 +1,5 @@ // Two second loop -private ["_count","_group","_hasGPS","_index","_marker","_markBody","_markGroup","_markSelf","_pos","_self","_vehicle"]; +private ["_count","_found","_group","_hasGPS","_index","_marker","_markBody","_markGroup","_markSelf","_pos","_self","_vehicle"]; _group = player call dayz_filterGroup; @@ -20,9 +20,8 @@ if (visibleMap or !isNull findDisplay 88890) then { { _self = _x == player; _vehicle = vehicle _x; - if ((_self or _markGroup) && (!_self or _markSelf) && (driver _vehicle == _x)) then { - _pos = getPosATL _x; - if (surfaceIsWater _pos) then {_pos = getPosASL _x;}; + if ((_self or _markGroup) && (!_self or _markSelf) && (effectiveCommander _vehicle == _x)) then { + _pos = [_x] call FNC_GetPos; deleteMarkerLocal format["groupMember%1",_index]; _marker = createMarkerLocal [format["groupMember%1",_index],_pos]; _marker setMarkerTypeLocal "DestroyedVehicle"; @@ -42,15 +41,20 @@ if (visibleMap or !isNull findDisplay 88890) then { dayz_oldMemberCount = _count; if (_markBody) then { + _found = false; { - if (_x getVariable["bodyName",""] == name player) then { + //Only mark closest body to player's current position (allDead is sorted by distance) + if (_x getVariable["bodyName",""] == name player) exitWith { + _found = true; + _pos = [_x] call FNC_GetPos; deleteMarkerLocal "MyBody"; - _marker = createMarkerLocal ["MyBody",getPosATL _x]; + _marker = createMarkerLocal ["MyBody",_pos]; _marker setMarkerTypeLocal "DestroyedVehicle"; _marker setMarkerTextLocal localize "STR_EPOCH_RIP"; _marker setMarkerColorLocal "ColorRed"; }; } count allDead; + if (!_found) then {deleteMarkerLocal "MyBody";}; //Body was deleted or hidden } else { deleteMarkerLocal "MyBody"; }; diff --git a/SQF/dayz_code/groups/inviteToGroup.sqf b/SQF/dayz_code/groups/inviteToGroup.sqf index cc33957e9..04e943a55 100644 --- a/SQF/dayz_code/groups/inviteToGroup.sqf +++ b/SQF/dayz_code/groups/inviteToGroup.sqf @@ -5,9 +5,7 @@ _playerList = findDisplay 80000 displayCtrl 1; _uid = _playerList lbData (lbCurSel _playerList); _recipient = _uid call dayz_getPlayer; -if (isNull _recipient or player != leader group player or count (units group _recipient) > 1) exitWith { - _this ctrlShow false; -}; +if (isNull _recipient or player != leader group player or count (units group _recipient) > 1) exitWith {}; _hasInvite = false; { diff --git a/SQF/dayz_code/groups/joinGroup.sqf b/SQF/dayz_code/groups/joinGroup.sqf index 73caa1468..76f90f10b 100644 --- a/SQF/dayz_code/groups/joinGroup.sqf +++ b/SQF/dayz_code/groups/joinGroup.sqf @@ -1,4 +1,9 @@ -private ["_inviter","_inviterUID","_oldGroup","_uid"]; +private ["_display","_inviter","_inviteText","_inviterUID","_oldGroup","_rejectButton","_uid"]; + +_display = findDisplay 80000; +_rejectButton = _display displayCtrl 8; +_inviteText = _display displayCtrl 9; +{_x ctrlShow false} count [_inviteText,_rejectButton]; _inviterUID = "0"; _uid = getPlayerUID player; @@ -22,13 +27,10 @@ if (!isNull _inviter) then { _oldGroup = group player; [player] join (group _inviter); if (count (units _oldGroup) == 0) then {deleteGroup _oldGroup;}; - [] spawn { - uiSleep 1; //Required for group change to update on server - // Update saved group in DB - PVDZ_Server_UpdateGroup = [1,player]; - publicVariableServer "PVDZ_Server_UpdateGroup"; - }; + + // Update saved group in DB + PVDZ_Server_UpdateGroup = [1,player]; + publicVariableServer "PVDZ_Server_UpdateGroup"; } else { - _this ctrlShow false; systemChat localize "STR_EPOCH_INVITE_EXPIRED"; }; \ No newline at end of file diff --git a/SQF/dayz_code/groups/kickFromGroup.sqf b/SQF/dayz_code/groups/kickFromGroup.sqf index 09514a027..3159953f5 100644 --- a/SQF/dayz_code/groups/kickFromGroup.sqf +++ b/SQF/dayz_code/groups/kickFromGroup.sqf @@ -5,13 +5,11 @@ _myGroup = findDisplay 80000 displayCtrl 2; _targetUID = _myGroup lbData (lbCurSel _myGroup); _target = _targetUID call dayz_getPlayer; -if (isNull _target or _target == player or player != leader group player) exitWith { - _this ctrlShow false; -}; +if (isNull _target or _target == player or player != leader group player) exitWith {}; [_target] join grpNull; PVDZ_Server_UpdateGroup = [2,player,_targetUID]; publicVariableServer "PVDZ_Server_UpdateGroup"; -_myGroup call dayz_selectGroupMember; //update lbCurSel change \ No newline at end of file +call dayz_selectGroupMember; //update lbCurSel change \ No newline at end of file diff --git a/SQF/dayz_code/groups/leaveGroup.sqf b/SQF/dayz_code/groups/leaveGroup.sqf index 111a62d59..33b20facb 100644 --- a/SQF/dayz_code/groups/leaveGroup.sqf +++ b/SQF/dayz_code/groups/leaveGroup.sqf @@ -1,15 +1,13 @@ private "_group"; _group = units group player; -if (count _group == 1 or (!isNil "dayz_groupLeftThread" && {!scriptDone dayz_groupLeftThread})) exitWith { - _this ctrlShow false; -}; +if (count _group == 1 or (!isNil "dayz_groupLeaveThread" && {!scriptDone dayz_groupLeaveThread})) exitWith {}; dayz_groupLeft = nil; PVDZ_Server_UpdateGroup = [3,player]; publicVariableServer "PVDZ_Server_UpdateGroup"; -dayz_groupLeftThread = [] spawn { +dayz_groupLeaveThread = [] spawn { //Wait for response from server to confirm group finished updating in DB waitUntil {!isNil "dayz_groupLeft"}; [player] join grpNull; diff --git a/SQF/dayz_code/groups/openDialog.sqf b/SQF/dayz_code/groups/openDialog.sqf index b1942bc95..6ea32d495 100644 --- a/SQF/dayz_code/groups/openDialog.sqf +++ b/SQF/dayz_code/groups/openDialog.sqf @@ -32,8 +32,10 @@ while {!isNull findDisplay 80000} do { lbSort _myGroup; if (lbSize _myGroup > 1) then { - _leaveButton ctrlShow true; - if (player == _leader) then {_disbandButton ctrlShow true}; + if (isNil "dayz_groupLeaveThread" or {scriptDone dayz_groupLeaveThread}) then {_leaveButton ctrlShow true;}; + if (player == _leader && (isNil "dayz_groupDisbandThread" or {scriptDone dayz_groupDisbandThread})) then { + _disbandButton ctrlShow true; + }; } else { {_x ctrlShow false} count [_disbandButton,_leaveButton,_kickButton,_promoteButton]; }; diff --git a/SQF/dayz_code/groups/promotePlayer.sqf b/SQF/dayz_code/groups/promotePlayer.sqf index cb0c0d327..99bb22e66 100644 --- a/SQF/dayz_code/groups/promotePlayer.sqf +++ b/SQF/dayz_code/groups/promotePlayer.sqf @@ -5,7 +5,6 @@ _display = findDisplay 80000; _myGroup = _display displayCtrl 2; _kickButton = _display displayCtrl 4; _disbandButton = _display displayCtrl 5; -_promoteButton = _this; _uid = _myGroup lbData (lbCurSel _myGroup); _group = group player; @@ -13,7 +12,5 @@ _target = _uid call dayz_getPlayer; if (player == leader _group && {!isNull _target} && {_target != player}) then { _group selectLeader _target; - {_x ctrlShow false} count [_disbandButton,_kickButton,_promoteButton]; -} else { - _promoteButton ctrlShow false; + {_x ctrlShow false} count [_disbandButton,_kickButton]; }; \ No newline at end of file diff --git a/SQF/dayz_code/groups/rejectGroup.sqf b/SQF/dayz_code/groups/rejectGroup.sqf index 66eeedb13..96d3b3a20 100644 --- a/SQF/dayz_code/groups/rejectGroup.sqf +++ b/SQF/dayz_code/groups/rejectGroup.sqf @@ -1,4 +1,10 @@ -private "_uid"; +private ["_display","_inviteText","_joinButton","_uid"]; + +_display = findDisplay 80000; +_joinButton = _display displayCtrl 7; +_inviteText = _display displayCtrl 9; +{_x ctrlShow false} count [_inviteText,_joinButton]; + _uid = getPlayerUID player; //Remove all invites to this player @@ -9,8 +15,6 @@ _uid = getPlayerUID player; } forEach dayz_activeInvites; dayz_activeInvites = dayz_activeInvites - ["delete"]; -_this ctrlShow false; - //Sync change to all remote machines (less data than sending whole array) PVDZ_groupInvite = [false,_uid]; publicVariableServer "PVDZ_groupInvite"; \ No newline at end of file diff --git a/SQF/dayz_code/groups/selectGroupMember.sqf b/SQF/dayz_code/groups/selectGroupMember.sqf index a27e741c3..dfa0d7c0e 100644 --- a/SQF/dayz_code/groups/selectGroupMember.sqf +++ b/SQF/dayz_code/groups/selectGroupMember.sqf @@ -2,14 +2,14 @@ private ["_display","_kickButton","_myGroup","_promoteButton","_target","_uid"]; disableSerialization; _display = findDisplay 80000; -_myGroup = _this; +_myGroup = _display displayCtrl 2; _kickButton = _display displayCtrl 4; _promoteButton = _display displayCtrl 10; _uid = _myGroup lbData (lbCurSel _myGroup); _target = _uid call dayz_getPlayer; if (player == leader group player && {!isNull _target} && {_target != player}) then { - {_x ctrlShow true;} count [_kickButton,_promoteButton]; + {_x ctrlShow true} count [_kickButton,_promoteButton]; } else { - {_x ctrlShow false;} count [_kickButton,_promoteButton]; + {_x ctrlShow false} count [_kickButton,_promoteButton]; }; \ No newline at end of file diff --git a/SQF/dayz_code/groups/selectPlayer.sqf b/SQF/dayz_code/groups/selectPlayer.sqf index 9546802a4..751e8a86c 100644 --- a/SQF/dayz_code/groups/selectPlayer.sqf +++ b/SQF/dayz_code/groups/selectPlayer.sqf @@ -1,8 +1,9 @@ -private ["_inviteButton","_playerList","_target","_uid"]; +private ["_display","_inviteButton","_playerList","_target","_uid"]; disableSerialization; -_playerList = _this; -_inviteButton = findDisplay 80000 displayCtrl 3; +_display = findDisplay 80000; +_playerList = _display displayCtrl 1; +_inviteButton = _display displayCtrl 3; _uid = _playerList lbData (lbCurSel _playerList); _target = _uid call dayz_getPlayer; diff --git a/SQF/dayz_code/init/publicEH.sqf b/SQF/dayz_code/init/publicEH.sqf index 1c13519df..db2989bab 100644 --- a/SQF/dayz_code/init/publicEH.sqf +++ b/SQF/dayz_code/init/publicEH.sqf @@ -103,7 +103,8 @@ if (isServer) then { "PVDZE_handleSafeGear" addPublicVariableEventHandler {(_this select 1) spawn server_handleSafeGear}; "PVDZE_fullobj_Publish" addPublicVariableEventHandler {(_this select 1) call server_publishFullObject}; // PlotForLife take base ownership if (dayz_groupSystem) then { - "PVDZ_Server_UpdateGroup" addPublicVariableEventHandler {(_this select 1) call server_updateGroup}; + //Use spawn instead of call because small delay is needed for group changes to propagate to server + "PVDZ_Server_UpdateGroup" addPublicVariableEventHandler {(_this select 1) spawn server_updateGroup}; }; //Added as part of the maintenance system to allow the server to replace the damaged model with a normal model.