playerlist advanced clone und bufix
This commit is contained in:
parent
449719aa99
commit
18fd95dcd4
@ -11,7 +11,6 @@ use FML\Controls\Quad;
|
|||||||
use FML\Controls\Quads\Quad_BgRaceScore2;
|
use FML\Controls\Quads\Quad_BgRaceScore2;
|
||||||
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
||||||
use FML\Controls\Quads\Quad_Emblems;
|
use FML\Controls\Quads\Quad_Emblems;
|
||||||
use FML\Controls\Quads\Quad_Icons128x128_1;
|
|
||||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||||
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
@ -31,23 +30,23 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
|||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ACTION_FORCE_RED = 'PlayerList.ForceRed';
|
const ACTION_FORCE_RED = 'PlayerList.ForceRed';
|
||||||
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
|
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
|
||||||
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
|
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
|
||||||
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
|
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
|
||||||
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
|
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
|
||||||
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
|
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
|
||||||
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
|
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
|
||||||
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
|
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
|
||||||
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
|
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
|
||||||
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
|
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
|
||||||
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
|
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
|
||||||
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
|
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
|
||||||
const SHOWN_MAIN_WINDOW = -1;
|
const SHOWN_MAIN_WINDOW = -1;
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
@ -57,6 +56,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
private $quadStyle;
|
private $quadStyle;
|
||||||
private $quadSubstyle;
|
private $quadSubstyle;
|
||||||
private $playersListShown = array();
|
private $playersListShown = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new server commands instance
|
* Create a new server commands instance
|
||||||
*
|
*
|
||||||
@ -64,24 +64,21 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this,
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
|
||||||
'closePlayerAdvancedWidget');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||||
'handleManialinkPageAnswer');
|
|
||||||
|
|
||||||
// Update Widget Events
|
// Update Widget Events
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||||
'updateWidget');
|
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||||
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -92,23 +89,23 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
public function showPlayerList(Player $player) {
|
public function showPlayerList(Player $player) {
|
||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
|
|
||||||
// Create script and features
|
// Create script and features
|
||||||
$script = new Script();
|
$script = new Script();
|
||||||
$maniaLink->setScript($script);
|
$maniaLink->setScript($script);
|
||||||
|
|
||||||
// mainframe
|
// mainframe
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
$frame->setSize($this->width, $this->height);
|
$frame->setSize($this->width, $this->height);
|
||||||
$frame->setPosition(0, 0);
|
$frame->setPosition(0, 0);
|
||||||
|
|
||||||
// Background Quad
|
// Background Quad
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($backgroundQuad);
|
$frame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($this->width, $this->height);
|
$backgroundQuad->setSize($this->width, $this->height);
|
||||||
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle);
|
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle);
|
||||||
|
|
||||||
// Add Close Quad (X)
|
// Add Close Quad (X)
|
||||||
$closeQuad = new Quad_Icons64x64_1();
|
$closeQuad = new Quad_Icons64x64_1();
|
||||||
$frame->add($closeQuad);
|
$frame->add($closeQuad);
|
||||||
@ -136,54 +133,53 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$frame->add($headFrame);
|
$frame->add($headFrame);
|
||||||
$headFrame->setY($y - 5);
|
$headFrame->setY($y - 5);
|
||||||
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
|
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91, "Actions" => $x + 135);
|
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91, "Actions" => $x + 135);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91);
|
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91);
|
||||||
}
|
}
|
||||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||||
|
|
||||||
// get PlayerList
|
// get PlayerList
|
||||||
$players = $this->maniaControl->playerManager->getPlayers();
|
$players = $this->maniaControl->playerManager->getPlayers();
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$y -= 10;
|
$y -= 10;
|
||||||
foreach ($players as $listPlayer) {
|
foreach($players as $listPlayer) {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var Player $listPlayer
|
* @var Player $listPlayer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$path = $listPlayer->getProvince();
|
$path = $listPlayer->getProvince();
|
||||||
$playerFrame = new Frame();
|
$playerFrame = new Frame();
|
||||||
$frame->add($playerFrame);
|
$frame->add($playerFrame);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if($i % 2 != 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$playerFrame->add($lineQuad);
|
$playerFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($this->width, 4);
|
$lineQuad->setSize($this->width, 4);
|
||||||
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||||
$lineQuad->setZ(0.001);
|
$lineQuad->setZ(0.001);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $listPlayer->ladderRank =>
|
// $array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $listPlayer->ladderRank =>
|
||||||
// $x + 60, $listPlayer->ladderScore => $x + 70, $path => $x + 85);
|
// $x + 60, $listPlayer->ladderScore => $x + 70, $path => $x + 85);
|
||||||
$array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 60, $path => $x + 91);
|
$array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 60, $path => $x + 91);
|
||||||
// $properties = array('profile' => $listPlayer->login, 'script' => $script);
|
// $properties = array('profile' => $listPlayer->login, 'script' => $script);
|
||||||
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
|
|
||||||
// Team Emblem
|
// Team Emblem
|
||||||
if ($listPlayer->teamId >= 0) {
|
if($listPlayer->teamId >= 0) {
|
||||||
// Player is in a Team
|
// Player is in a Team
|
||||||
$teamQuad = new Quad_Emblems();
|
$teamQuad = new Quad_Emblems();
|
||||||
$playerFrame->add($teamQuad);
|
$playerFrame->add($teamQuad);
|
||||||
$teamQuad->setX($x + 10);
|
$teamQuad->setX($x + 10);
|
||||||
$teamQuad->setZ(0.1);
|
$teamQuad->setZ(0.1);
|
||||||
$teamQuad->setSize(3.8, 3.8);
|
$teamQuad->setSize(3.8, 3.8);
|
||||||
|
|
||||||
switch ($listPlayer->teamId) {
|
switch($listPlayer->teamId) {
|
||||||
case 0:
|
case 0:
|
||||||
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_1);
|
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_1);
|
||||||
break;
|
break;
|
||||||
@ -191,8 +187,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_2);
|
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if($listPlayer->isSpectator) {
|
||||||
else if ($listPlayer->isSpectator) {
|
|
||||||
// Player is in Spectator Mode
|
// Player is in Spectator Mode
|
||||||
$specQuad = new Quad_BgRaceScore2();
|
$specQuad = new Quad_BgRaceScore2();
|
||||||
$playerFrame->add($specQuad);
|
$playerFrame->add($specQuad);
|
||||||
@ -201,8 +196,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$specQuad->setSubStyle($specQuad::SUBSTYLE_Spectator);
|
$specQuad->setSubStyle($specQuad::SUBSTYLE_Spectator);
|
||||||
$specQuad->setSize(3.8, 3.8);
|
$specQuad->setSize(3.8, 3.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$listPlayer->isFakePlayer()) {
|
if(!$listPlayer->isFakePlayer()) {
|
||||||
// Nation Quad
|
// Nation Quad
|
||||||
$countryQuad = new Quad();
|
$countryQuad = new Quad();
|
||||||
$playerFrame->add($countryQuad);
|
$playerFrame->add($countryQuad);
|
||||||
@ -217,7 +212,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$descriptionLabel->setText($listPlayer->nickname . " from " . $listPlayer->path);
|
$descriptionLabel->setText($listPlayer->nickname . " from " . $listPlayer->path);
|
||||||
$script->addTooltip($countryQuad, $descriptionLabel);
|
$script->addTooltip($countryQuad, $descriptionLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Level Quad
|
// Level Quad
|
||||||
$rightQuad = new Quad_BgRaceScore2();
|
$rightQuad = new Quad_BgRaceScore2();
|
||||||
$playerFrame->add($rightQuad);
|
$playerFrame->add($rightQuad);
|
||||||
@ -225,7 +220,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$rightQuad->setZ(5);
|
$rightQuad->setZ(5);
|
||||||
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
||||||
$rightQuad->setSize(7, 3.5);
|
$rightQuad->setSize(7, 3.5);
|
||||||
|
|
||||||
$rightLabel = new Label_Text();
|
$rightLabel = new Label_Text();
|
||||||
$playerFrame->add($rightLabel);
|
$playerFrame->add($rightLabel);
|
||||||
$rightLabel->setX($x + 13.9);
|
$rightLabel->setX($x + 13.9);
|
||||||
@ -236,7 +231,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
$descriptionLabel->setText($this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname);
|
$descriptionLabel->setText($this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname);
|
||||||
$script->addTooltip($rightQuad, $descriptionLabel);
|
$script->addTooltip($rightQuad, $descriptionLabel);
|
||||||
|
|
||||||
// Player Profile Quad
|
// Player Profile Quad
|
||||||
$playerQuad = new Quad_UIConstruction_Buttons();
|
$playerQuad = new Quad_UIConstruction_Buttons();
|
||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
@ -245,14 +240,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
||||||
$playerQuad->setSize(3.8, 3.8);
|
$playerQuad->setSize(3.8, 3.8);
|
||||||
$script->addProfileButton($playerQuad, $listPlayer->login);
|
$script->addProfileButton($playerQuad, $listPlayer->login);
|
||||||
|
|
||||||
// Description Label
|
// Description Label
|
||||||
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
$descriptionLabel->setText("View Player profile of " . $listPlayer->nickname);
|
$descriptionLabel->setText("View Player profile of " . $listPlayer->nickname);
|
||||||
$script->addTooltip($playerQuad, $descriptionLabel);
|
$script->addTooltip($playerQuad, $descriptionLabel);
|
||||||
|
|
||||||
switch ($listPlayer->authLevel) {
|
switch($listPlayer->authLevel) {
|
||||||
case authenticationManager::AUTH_LEVEL_MASTERADMIN:
|
case authenticationManager::AUTH_LEVEL_MASTERADMIN:
|
||||||
$rightLabel->setText("MA");
|
$rightLabel->setText("MA");
|
||||||
break;
|
break;
|
||||||
@ -265,10 +260,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
case authenticationManager::AUTH_LEVEL_MODERATOR:
|
case authenticationManager::AUTH_LEVEL_MODERATOR:
|
||||||
$rightLabel->setText("MOD");
|
$rightLabel->setText("MOD");
|
||||||
}
|
}
|
||||||
|
|
||||||
$rightLabel->setTextColor("fff");
|
$rightLabel->setTextColor("fff");
|
||||||
|
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
// Further Player actions Quad
|
// Further Player actions Quad
|
||||||
$playerQuad = new Quad_Icons64x64_1();
|
$playerQuad = new Quad_Icons64x64_1();
|
||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
@ -282,7 +277,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
$descriptionLabel->setText("Advanced Player Actions on " . $listPlayer->nickname);
|
$descriptionLabel->setText("Advanced Player Actions on " . $listPlayer->nickname);
|
||||||
$script->addTooltip($playerQuad, $descriptionLabel);
|
$script->addTooltip($playerQuad, $descriptionLabel);
|
||||||
|
|
||||||
// Force to Red-Team Quad
|
// Force to Red-Team Quad
|
||||||
$redQuad = new Quad_Emblems();
|
$redQuad = new Quad_Emblems();
|
||||||
$playerFrame->add($redQuad);
|
$playerFrame->add($redQuad);
|
||||||
@ -291,14 +286,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
||||||
$redQuad->setSize(3.8, 3.8);
|
$redQuad->setSize(3.8, 3.8);
|
||||||
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
|
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Red-Team Description Label
|
// Force to Red-Team Description Label
|
||||||
$descriptionLabel = clone $preDefinedDescriptionLabel;;
|
$descriptionLabel = clone $preDefinedDescriptionLabel;;
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
$descriptionLabel->setText("Force " . $listPlayer->nickname . '$z to Red Team!');
|
$descriptionLabel->setText("Force " . $listPlayer->nickname . '$z to Red Team!');
|
||||||
$script->addTooltip($redQuad, $descriptionLabel);
|
$script->addTooltip($redQuad, $descriptionLabel);
|
||||||
|
|
||||||
|
|
||||||
// Force to Blue-Team Quad
|
// Force to Blue-Team Quad
|
||||||
$blueQuad = new Quad_Emblems();
|
$blueQuad = new Quad_Emblems();
|
||||||
$playerFrame->add($blueQuad);
|
$playerFrame->add($blueQuad);
|
||||||
@ -307,13 +302,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
||||||
$blueQuad->setSize(3.8, 3.8);
|
$blueQuad->setSize(3.8, 3.8);
|
||||||
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
|
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Blue-Team Description Label
|
// Force to Blue-Team Description Label
|
||||||
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
$descriptionLabel->setText("Force " . $listPlayer->nickname . '$z to Blue Team!');
|
$descriptionLabel->setText("Force " . $listPlayer->nickname . '$z to Blue Team!');
|
||||||
$script->addTooltip($blueQuad, $descriptionLabel);
|
$script->addTooltip($blueQuad, $descriptionLabel);
|
||||||
|
|
||||||
// Force to Spectator Quad
|
// Force to Spectator Quad
|
||||||
$spectatorQuad = new Quad_BgRaceScore2();
|
$spectatorQuad = new Quad_BgRaceScore2();
|
||||||
$playerFrame->add($spectatorQuad);
|
$playerFrame->add($spectatorQuad);
|
||||||
@ -322,7 +317,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||||
$spectatorQuad->setSize(3.8, 3.8);
|
$spectatorQuad->setSize(3.8, 3.8);
|
||||||
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." . $listPlayer->login);
|
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Spectator Description Label
|
// Force to Spectator Description Label
|
||||||
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
@ -332,13 +327,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$i++;
|
$i++;
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// show advanced window
|
// show advanced window
|
||||||
if ($this->playersListShown[$player->login] != false && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) {
|
if($this->playersListShown[$player->login] != false && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) {
|
||||||
$frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]);
|
$frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]);
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
// render and display xml
|
// render and display xml
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||||
}
|
}
|
||||||
@ -347,10 +342,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* Displays the Advanced Player Window
|
* Displays the Advanced Player Window
|
||||||
*
|
*
|
||||||
* @param Player $caller
|
* @param Player $caller
|
||||||
* @param $login
|
* @param $login
|
||||||
*/
|
*/
|
||||||
public function advancedPlayerWidget(Player $caller, $login) {
|
public function advancedPlayerWidget(Player $caller, $login) {
|
||||||
if (!$caller) return;
|
if(!$caller) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->playersListShown[$caller->login] = $login; // Show a certain player
|
$this->playersListShown[$caller->login] = $login; // Show a certain player
|
||||||
$this->showPlayerList($caller); // reopen playerlist
|
$this->showPlayerList($caller); // reopen playerlist
|
||||||
}
|
}
|
||||||
@ -363,22 +360,22 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function showAdvancedPlayerWidget($login) {
|
public function showAdvancedPlayerWidget($login) {
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
|
||||||
// todo all configurable or as constants
|
// todo all configurable or as constants
|
||||||
$x = $this->width / 2 + 2.5;
|
$x = $this->width / 2 + 2.5;
|
||||||
$width = 35;
|
$width = 35;
|
||||||
$height = $this->height * 0.7;
|
$height = $this->height * 0.7;
|
||||||
$hAlign = Control::LEFT;
|
$hAlign = Control::LEFT;
|
||||||
$style = Label_Text::STYLE_TextCardSmall;
|
$style = Label_Text::STYLE_TextCardSmall;
|
||||||
$textSize = 1.5;
|
$textSize = 1.5;
|
||||||
$textColor = 'FFF';
|
$textColor = 'FFF';
|
||||||
$quadWidth = $width - 7;
|
$quadWidth = $width - 7;
|
||||||
|
|
||||||
// mainframe
|
// mainframe
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$frame->setSize($width, $height);
|
$frame->setSize($width, $height);
|
||||||
$frame->setPosition($x + $width / 2, 0);
|
$frame->setPosition($x + $width / 2, 0);
|
||||||
|
|
||||||
// Add Close Quad (X)
|
// Add Close Quad (X)
|
||||||
$closeQuad = new Quad_Icons64x64_1();
|
$closeQuad = new Quad_Icons64x64_1();
|
||||||
$frame->add($closeQuad);
|
$frame->add($closeQuad);
|
||||||
@ -386,14 +383,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$closeQuad->setSize(6, 6);
|
$closeQuad->setSize(6, 6);
|
||||||
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
||||||
$closeQuad->setAction(self::ACTION_CLOSE_PLAYER_ADV);
|
$closeQuad->setAction(self::ACTION_CLOSE_PLAYER_ADV);
|
||||||
|
|
||||||
// Background Quad
|
// Background Quad
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($backgroundQuad);
|
$frame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($width, $height);
|
$backgroundQuad->setSize($width, $height);
|
||||||
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle);
|
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle);
|
||||||
$backgroundQuad->setZ(0.1);
|
$backgroundQuad->setZ(0.1);
|
||||||
|
|
||||||
// Show headline
|
// Show headline
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
@ -404,7 +401,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setTextSize($textSize);
|
$label->setTextSize($textSize);
|
||||||
$label->setText("Advanced Actions");
|
$label->setText("Advanced Actions");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
// Show Nickname
|
// Show Nickname
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
@ -416,7 +413,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setTextSize($textSize);
|
$label->setTextSize($textSize);
|
||||||
$label->setText($player->nickname);
|
$label->setText($player->nickname);
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y = $height / 2 - 14;
|
$y = $height / 2 - 14;
|
||||||
// Show Warn
|
// Show Warn
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = new Quad_BgsPlayerCard();
|
||||||
@ -426,7 +423,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
||||||
$quad->setSize($quadWidth, 5);
|
$quad->setSize($quadWidth, 5);
|
||||||
$quad->setAction(self::ACTION_WARN_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_WARN_PLAYER . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = new Label_Button();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
@ -436,131 +433,90 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setTextSize($textSize);
|
$label->setTextSize($textSize);
|
||||||
$label->setText("Warn");
|
$label->setText("Warn");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
|
|
||||||
// Show Kick
|
// Show Kick
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Kick");
|
$label->setText("Kick");
|
||||||
$label->setTextColor("F90");
|
$label->setTextColor("F90");
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Ban
|
// Show Ban
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_BAN_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_BAN_PLAYER . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Ban");
|
$label->setText("Ban");
|
||||||
$label->setTextColor("700");
|
$label->setTextColor("700");
|
||||||
|
|
||||||
$y -= 10;
|
$y -= 10;
|
||||||
// Show Add as Master-Admin
|
// Show Add as Master-Admin
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_ADD_AS_MASTER . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_MASTER . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
|
|
||||||
$label->setText("Set SuperAdmin");
|
$label->setText("Set SuperAdmin");
|
||||||
|
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Add as Admin
|
// Show Add as Admin
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_ADD_AS_ADMIN . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_ADMIN . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Set Admin");
|
$label->setText("Set Admin");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Add as Moderator
|
// Show Add as Moderator
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_ADD_AS_MOD . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_MOD . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Set Moderator");
|
$label->setText("Set Moderator");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Revoke Rights
|
// Revoke Rights
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
|
||||||
$quad->setSize($quadWidth, 5);
|
|
||||||
$quad->setAction(self::ACTION_REVOKE_RIGHTS . "." . $login);
|
$quad->setAction(self::ACTION_REVOKE_RIGHTS . "." . $login);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setX(0);
|
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
|
||||||
$label->setTextSize($textSize);
|
|
||||||
$label->setText("Revoke Rights");
|
$label->setText("Revoke Rights");
|
||||||
$label->setTextColor("700");
|
$label->setTextColor("700");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $frame;
|
return $frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,7 +533,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Closes the player advanced widget widget
|
* Closes the player advanced widget widget
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function closePlayerAdvancedWidget(array $callback, Player $player) {
|
public function closePlayerAdvancedWidget(array $callback, Player $player) {
|
||||||
@ -591,27 +547,24 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$actionArray = explode(".", $actionId);
|
$actionArray = explode(".", $actionId);
|
||||||
if (count($actionArray) <= 2) {
|
if(count($actionArray) <= 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$action = $actionArray[0] . "." . $actionArray[1];
|
$action = $actionArray[0] . "." . $actionArray[1];
|
||||||
$adminLogin = $callback[1][1];
|
$adminLogin = $callback[1][1];
|
||||||
$targetLogin = $actionArray[2];
|
$targetLogin = $actionArray[2];
|
||||||
|
|
||||||
switch ($action) {
|
switch($action) {
|
||||||
case self::ACTION_FORCE_BLUE:
|
case self::ACTION_FORCE_BLUE:
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::BLUE_TEAM);
|
||||||
PlayerActions::BLUE_TEAM);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_FORCE_RED:
|
case self::ACTION_FORCE_RED:
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::RED_TEAM);
|
||||||
PlayerActions::RED_TEAM);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_FORCE_SPEC:
|
case self::ACTION_FORCE_SPEC:
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||||
PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_WARN_PLAYER:
|
case self::ACTION_WARN_PLAYER:
|
||||||
$this->maniaControl->playerManager->playerActions->warnPlayer($adminLogin, $targetLogin);
|
$this->maniaControl->playerManager->playerActions->warnPlayer($adminLogin, $targetLogin);
|
||||||
@ -627,16 +580,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->advancedPlayerWidget($admin, $targetLogin);
|
$this->advancedPlayerWidget($admin, $targetLogin);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_MASTER:
|
case self::ACTION_ADD_AS_MASTER:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||||
AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_ADMIN:
|
case self::ACTION_ADD_AS_ADMIN:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
AuthenticationManager::AUTH_LEVEL_ADMIN);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_MOD:
|
case self::ACTION_ADD_AS_MOD:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_REVOKE_RIGHTS:
|
case self::ACTION_REVOKE_RIGHTS:
|
||||||
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
||||||
@ -650,17 +600,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function updateWidget(array $callback) {
|
public function updateWidget(array $callback) {
|
||||||
foreach ($this->playersListShown as $login => $shown) {
|
foreach($this->playersListShown as $login => $shown) {
|
||||||
if ($shown) {
|
if($shown) {
|
||||||
// Check if Shown player still exists
|
// Check if Shown player still exists
|
||||||
if ($shown != self::SHOWN_MAIN_WINDOW && $this->maniaControl->playerManager->getPlayer($shown) == null) {
|
if($shown != self::SHOWN_MAIN_WINDOW && $this->maniaControl->playerManager->getPlayer($shown) == null) {
|
||||||
$this->playersListShown[$login] = false;
|
$this->playersListShown[$login] = false;
|
||||||
}
|
}
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
if ($player != null) {
|
if($player != null) {
|
||||||
$this->showPlayerList($player);
|
$this->showPlayerList($player);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// if player with the open widget disconnected remove him from the shownlist
|
// if player with the open widget disconnected remove him from the shownlist
|
||||||
unset($this->playersListShown[$login]);
|
unset($this->playersListShown[$login]);
|
||||||
}
|
}
|
||||||
|
@ -19,22 +19,22 @@ class PlayerManager implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const CB_PLAYERJOINED = 'PlayerManagerCallback.PlayerJoined';
|
const CB_PLAYERJOINED = 'PlayerManagerCallback.PlayerJoined';
|
||||||
const CB_PLAYERDISCONNECTED = 'PlayerManagerCallback.PlayerDisconnected';
|
const CB_PLAYERDISCONNECTED = 'PlayerManagerCallback.PlayerDisconnected';
|
||||||
const CB_ONINIT = 'PlayerManagerCallback.OnInit';
|
const CB_ONINIT = 'PlayerManagerCallback.OnInit';
|
||||||
const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged';
|
const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged';
|
||||||
const TABLE_PLAYERS = 'mc_players';
|
const TABLE_PLAYERS = 'mc_players';
|
||||||
const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages';
|
const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages';
|
||||||
const STAT_JOIN_COUNT = 'joinCount';
|
const STAT_JOIN_COUNT = 'joinCount';
|
||||||
const STAT_PLAYTIME = 'playTime';
|
const STAT_PLAYTIME = 'playTime';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Properties
|
* Public Properties
|
||||||
*/
|
*/
|
||||||
public $playerActions = null;
|
public $playerActions = null;
|
||||||
public $playerCommands = null;
|
public $playerCommands = null;
|
||||||
public $playerList = array();
|
public $playerList = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
@ -48,21 +48,19 @@ class PlayerManager implements CallbackListener {
|
|||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
$this->initTables();
|
$this->initTables();
|
||||||
|
|
||||||
$this->playerCommands = new PlayerCommands($maniaControl);
|
$this->playerCommands = new PlayerCommands($maniaControl);
|
||||||
$this->playerActions = new PlayerActions($maniaControl);
|
$this->playerActions = new PlayerActions($maniaControl);
|
||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'playerDisconnect');
|
||||||
'playerDisconnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'playerInfoChanged');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this,
|
|
||||||
'playerInfoChanged');
|
|
||||||
|
|
||||||
// Define player stats
|
// Define player stats
|
||||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_JOIN_COUNT);
|
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_JOIN_COUNT);
|
||||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME);
|
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME);
|
||||||
@ -74,8 +72,8 @@ class PlayerManager implements CallbackListener {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function initTables() {
|
private function initTables() {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$playerTableQuery = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_PLAYERS . "` (
|
$playerTableQuery = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_PLAYERS . "` (
|
||||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`login` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
`login` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
||||||
`nickname` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
|
`nickname` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
|
||||||
@ -86,12 +84,12 @@ class PlayerManager implements CallbackListener {
|
|||||||
UNIQUE KEY `login` (`login`)
|
UNIQUE KEY `login` (`login`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Player Data' AUTO_INCREMENT=1;";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Player Data' AUTO_INCREMENT=1;";
|
||||||
$playerTableStatement = $mysqli->prepare($playerTableQuery);
|
$playerTableStatement = $mysqli->prepare($playerTableQuery);
|
||||||
if ($mysqli->error) {
|
if($mysqli->error) {
|
||||||
trigger_error($mysqli->error, E_USER_ERROR);
|
trigger_error($mysqli->error, E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$playerTableStatement->execute();
|
$playerTableStatement->execute();
|
||||||
if ($playerTableStatement->error) {
|
if($playerTableStatement->error) {
|
||||||
trigger_error($playerTableStatement->error, E_USER_ERROR);
|
trigger_error($playerTableStatement->error, E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -108,16 +106,16 @@ class PlayerManager implements CallbackListener {
|
|||||||
// Add all players
|
// Add all players
|
||||||
$this->maniaControl->client->query('GetPlayerList', 300, 0, 2);
|
$this->maniaControl->client->query('GetPlayerList', 300, 0, 2);
|
||||||
$playerList = $this->maniaControl->client->getResponse();
|
$playerList = $this->maniaControl->client->getResponse();
|
||||||
foreach ($playerList as $playerItem) {
|
foreach($playerList as $playerItem) {
|
||||||
if ($playerItem['PlayerId'] <= 0) {
|
if($playerItem['PlayerId'] <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->maniaControl->client->query('GetDetailedPlayerInfo', $playerItem['Login']);
|
$this->maniaControl->client->query('GetDetailedPlayerInfo', $playerItem['Login']);
|
||||||
$playerInfo = $this->maniaControl->client->getResponse();
|
$playerInfo = $this->maniaControl->client->getResponse();
|
||||||
$player = new Player($playerInfo);
|
$player = new Player($playerInfo);
|
||||||
$this->addPlayer($player);
|
$this->addPlayer($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger own callback
|
// Trigger own callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_ONINIT, array(self::CB_ONINIT));
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_ONINIT, array(self::CB_ONINIT));
|
||||||
}
|
}
|
||||||
@ -131,22 +129,20 @@ class PlayerManager implements CallbackListener {
|
|||||||
$login = $callback[1][0];
|
$login = $callback[1][0];
|
||||||
$this->maniaControl->client->query('GetDetailedPlayerInfo', $login);
|
$this->maniaControl->client->query('GetDetailedPlayerInfo', $login);
|
||||||
$playerInfo = $this->maniaControl->client->getResponse();
|
$playerInfo = $this->maniaControl->client->getResponse();
|
||||||
$player = new Player($playerInfo);
|
$player = new Player($playerInfo);
|
||||||
|
|
||||||
$this->addPlayer($player);
|
$this->addPlayer($player);
|
||||||
|
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
||||||
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
|
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
|
||||||
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' .
|
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!';
|
||||||
$player->getCountry() . ' $z$s$0f0joined!';
|
|
||||||
$this->maniaControl->chat->sendChat($chatMessage);
|
$this->maniaControl->chat->sendChat($chatMessage);
|
||||||
$this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
|
$this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
$logMessage = "Player joined: {$player->login} / " . Formatter::stripCodes($player->nickname) . " Nation: " .
|
$logMessage = "Player joined: {$player->login} / " . Formatter::stripCodes($player->nickname) . " Nation: " . $player->getCountry() . " IP: {$player->ipAddress}";
|
||||||
$player->getCountry() . " IP: {$player->ipAddress}";
|
|
||||||
$this->maniaControl->log($logMessage);
|
$this->maniaControl->log($logMessage);
|
||||||
|
|
||||||
// Trigger own PlayerJoined callback
|
// Trigger own PlayerJoined callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERJOINED, array(self::CB_PLAYERJOINED, $player));
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERJOINED, array(self::CB_PLAYERJOINED, $player));
|
||||||
}
|
}
|
||||||
@ -157,21 +153,21 @@ class PlayerManager implements CallbackListener {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function playerDisconnect(array $callback) {
|
public function playerDisconnect(array $callback) {
|
||||||
$login = $callback[1][0];
|
$login = $callback[1][0];
|
||||||
$player = $this->removePlayer($login);
|
$player = $this->removePlayer($login);
|
||||||
|
|
||||||
// Trigger own callback
|
// Trigger own callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERDISCONNECTED, array(self::CB_PLAYERDISCONNECTED, $player));
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERDISCONNECTED, array(self::CB_PLAYERDISCONNECTED, $player));
|
||||||
|
|
||||||
if ($player == null || $player->isFakePlayer()) {
|
if($player == null || $player->isFakePlayer()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$played = Formatter::formatTimeH(time() - $player->joinTime);
|
$played = Formatter::formatTimeH(time() - $player->joinTime);
|
||||||
$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}";
|
$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}";
|
||||||
$this->maniaControl->log(Formatter::stripCodes($logMessage));
|
$this->maniaControl->log(Formatter::stripCodes($logMessage));
|
||||||
|
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
|
||||||
$this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $s$0f0has left the game');
|
$this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $s$0f0has left the game');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,12 +179,14 @@ class PlayerManager implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function playerInfoChanged(array $callback) {
|
public function playerInfoChanged(array $callback) {
|
||||||
$player = $this->getPlayer($callback[1][0]['Login']);
|
$player = $this->getPlayer($callback[1][0]['Login']);
|
||||||
if ($player == null) return;
|
if($player == null) {
|
||||||
|
return;
|
||||||
$player->teamId = $callback[1][0]["TeamId"];
|
}
|
||||||
|
|
||||||
|
$player->teamId = $callback[1][0]["TeamId"];
|
||||||
$player->isSpectator = $callback[1][0]["SpectatorStatus"];
|
$player->isSpectator = $callback[1][0]["SpectatorStatus"];
|
||||||
$player->ladderRank = $callback[1][0]["LadderRanking"];
|
$player->ladderRank = $callback[1][0]["LadderRanking"];
|
||||||
|
|
||||||
// Trigger own callback
|
// Trigger own callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERINFOCHANGED, array(self::CB_PLAYERINFOCHANGED));
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERINFOCHANGED, array(self::CB_PLAYERINFOCHANGED));
|
||||||
}
|
}
|
||||||
@ -209,7 +207,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
* @return Player
|
* @return Player
|
||||||
*/
|
*/
|
||||||
public function getPlayer($login) {
|
public function getPlayer($login) {
|
||||||
if (!isset($this->playerList[$login])) {
|
if(!isset($this->playerList[$login])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $this->playerList[$login];
|
return $this->playerList[$login];
|
||||||
@ -222,7 +220,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function addPlayer(Player $player) {
|
private function addPlayer(Player $player) {
|
||||||
if (!$player) {
|
if(!$player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->savePlayer($player);
|
$this->savePlayer($player);
|
||||||
@ -234,16 +232,16 @@ class PlayerManager implements CallbackListener {
|
|||||||
* Remove a Player from the PlayerList
|
* Remove a Player from the PlayerList
|
||||||
*
|
*
|
||||||
* @param string $login
|
* @param string $login
|
||||||
* @param bool $savePlayedTime
|
* @param bool $savePlayedTime
|
||||||
* @return Player $player
|
* @return Player $player
|
||||||
*/
|
*/
|
||||||
private function removePlayer($login, $savePlayedTime = true) {
|
private function removePlayer($login, $savePlayedTime = true) {
|
||||||
if (!isset($this->playerList[$login])) {
|
if(!isset($this->playerList[$login])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$player = $this->playerList[$login];
|
$player = $this->playerList[$login];
|
||||||
unset($this->playerList[$login]);
|
unset($this->playerList[$login]);
|
||||||
if ($savePlayedTime) {
|
if($savePlayedTime) {
|
||||||
$this->updatePlayedTime($player);
|
$this->updatePlayedTime($player);
|
||||||
}
|
}
|
||||||
return $player;
|
return $player;
|
||||||
@ -253,14 +251,14 @@ class PlayerManager implements CallbackListener {
|
|||||||
* Save player in database and fill up object properties
|
* Save player in database and fill up object properties
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param int $joinCount
|
* @param int $joinCount
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function savePlayer(Player &$player) {
|
private function savePlayer(Player &$player) {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
|
|
||||||
// Save player
|
// Save player
|
||||||
$playerQuery = "INSERT INTO `" . self::TABLE_PLAYERS . "` (
|
$playerQuery = "INSERT INTO `" . self::TABLE_PLAYERS . "` (
|
||||||
`login`,
|
`login`,
|
||||||
`nickname`,
|
`nickname`,
|
||||||
`path`
|
`path`
|
||||||
@ -271,30 +269,30 @@ class PlayerManager implements CallbackListener {
|
|||||||
`nickname` = VALUES(`nickname`),
|
`nickname` = VALUES(`nickname`),
|
||||||
`path` = VALUES(`path`);";
|
`path` = VALUES(`path`);";
|
||||||
$playerStatement = $mysqli->prepare($playerQuery);
|
$playerStatement = $mysqli->prepare($playerQuery);
|
||||||
if ($mysqli->error) {
|
if($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$playerStatement->bind_param('sss', $player->login, $player->nickname, $player->path);
|
$playerStatement->bind_param('sss', $player->login, $player->nickname, $player->path);
|
||||||
$playerStatement->execute();
|
$playerStatement->execute();
|
||||||
if ($playerStatement->error) {
|
if($playerStatement->error) {
|
||||||
trigger_error($playerStatement->error);
|
trigger_error($playerStatement->error);
|
||||||
$playerStatement->close();
|
$playerStatement->close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$player->index = $playerStatement->insert_id;
|
$player->index = $playerStatement->insert_id;
|
||||||
$playerStatement->close();
|
$playerStatement->close();
|
||||||
|
|
||||||
// Get Player Auth Level from DB
|
// Get Player Auth Level from DB
|
||||||
$playerQuery = "SELECT `authLevel` FROM `" . self::TABLE_PLAYERS . "` WHERE `index` = ?;";
|
$playerQuery = "SELECT `authLevel` FROM `" . self::TABLE_PLAYERS . "` WHERE `index` = ?;";
|
||||||
$playerStatement = $mysqli->prepare($playerQuery);
|
$playerStatement = $mysqli->prepare($playerQuery);
|
||||||
if ($mysqli->error) {
|
if($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$playerStatement->bind_param('i', $player->index);
|
$playerStatement->bind_param('i', $player->index);
|
||||||
$playerStatement->execute();
|
$playerStatement->execute();
|
||||||
if ($playerStatement->error) {
|
if($playerStatement->error) {
|
||||||
trigger_error($playerStatement->error);
|
trigger_error($playerStatement->error);
|
||||||
$playerStatement->close();
|
$playerStatement->close();
|
||||||
return false;
|
return false;
|
||||||
@ -304,15 +302,14 @@ class PlayerManager implements CallbackListener {
|
|||||||
$playerStatement->fetch();
|
$playerStatement->fetch();
|
||||||
$playerStatement->free_result();
|
$playerStatement->free_result();
|
||||||
$playerStatement->close();
|
$playerStatement->close();
|
||||||
|
|
||||||
// Increment the Player Join Count
|
// Increment the Player Join Count
|
||||||
$success = $this->maniaControl->statisticManager->incrementStat(self::STAT_JOIN_COUNT, $player,
|
$success = $this->maniaControl->statisticManager->incrementStat(self::STAT_JOIN_COUNT, $player, $this->maniaControl->server->getLogin());
|
||||||
$this->maniaControl->server->getLogin());
|
|
||||||
|
if(!$success) {
|
||||||
if (!$success) {
|
|
||||||
trigger_error("Error while setting the JoinCount");
|
trigger_error("Error while setting the JoinCount");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,12 +320,11 @@ class PlayerManager implements CallbackListener {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function updatePlayedTime(Player $player) {
|
private function updatePlayedTime(Player $player) {
|
||||||
if (!$player) {
|
if(!$player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$playedTime = time() - $player->joinTime;
|
$playedTime = time() - $player->joinTime;
|
||||||
|
|
||||||
return $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, $this->maniaControl->server->getLogin(),
|
return $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, $this->maniaControl->server->getLogin(), $playedTime);
|
||||||
$playedTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ namespace ManiaControl\Statistics;
|
|||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
|
|
||||||
class StatisticCollector implements CallbackListener {
|
class StatisticCollector implements CallbackListener {
|
||||||
@ -19,7 +18,7 @@ class StatisticCollector implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
const SETTING_COLLECT_STATS_ENABLED = 'Collect Stats Enabled';
|
const SETTING_COLLECT_STATS_ENABLED = 'Collect Stats Enabled';
|
||||||
const SETTING_COLLECT_STATS_MINPLAYERS = 'Minimum Playercount for Collecting Stats';
|
const SETTING_COLLECT_STATS_MINPLAYERS = 'Minimum Playercount for Collecting Stats';
|
||||||
const SETTING_ON_SHOOT_PRESTORE = 'Prestore Shoots before insert into Database';
|
const SETTING_ON_SHOOT_PRESTORE = 'Prestore Shoots before insert into Database';
|
||||||
/*
|
/*
|
||||||
* Statistics
|
* Statistics
|
||||||
*/
|
*/
|
||||||
@ -36,6 +35,7 @@ class StatisticCollector implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $onShootArray = array();
|
private $onShootArray = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct player manager
|
* Construct player manager
|
||||||
*
|
*
|
||||||
@ -75,19 +75,20 @@ class StatisticCollector implements CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle Player Shoots
|
* Handle Player Shoots
|
||||||
|
*
|
||||||
* @param $login
|
* @param $login
|
||||||
*/
|
*/
|
||||||
private function handleOnShoot($login){
|
private function handleOnShoot($login) {
|
||||||
if(!isset($this->onShootArray[$login])){
|
if(!isset($this->onShootArray[$login])) {
|
||||||
$this->onShootArray[$login] = 1;
|
$this->onShootArray[$login] = 1;
|
||||||
}else{
|
} else {
|
||||||
$this->onShootArray[$login]++;
|
$this->onShootArray[$login]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Write Shoot Data into database
|
//Write Shoot Data into database
|
||||||
if($this->onShootArray[$login] > self::SETTING_ON_SHOOT_PRESTORE){
|
if($this->onShootArray[$login] > self::SETTING_ON_SHOOT_PRESTORE) {
|
||||||
$serverLogin = $this->maniaControl->server->getLogin();
|
$serverLogin = $this->maniaControl->server->getLogin();
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$login]);
|
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$login]);
|
||||||
$this->onShootArray[$login] = 0;
|
$this->onShootArray[$login] = 0;
|
||||||
}
|
}
|
||||||
@ -96,18 +97,20 @@ class StatisticCollector implements CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert OnShoot Statistic when a player leaves
|
* Insert OnShoot Statistic when a player leaves
|
||||||
* @param array $callback
|
*
|
||||||
* @param Player $player
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function onPlayerDisconnect(array $callback, Player $player) {
|
public function onPlayerDisconnect(array $callback) {
|
||||||
|
$player = $callback[1];
|
||||||
|
|
||||||
//Check if Stat Collecting is enabled
|
//Check if Stat Collecting is enabled
|
||||||
if(!$this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
if(!$this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Insert Data into Database, and destroy player
|
//Insert Data into Database, and destroy player
|
||||||
if(isset($this->onShootArray[$player->login])){
|
if(isset($this->onShootArray[$player->login])) {
|
||||||
if($this->onShootArray[$player->login] > 0){
|
if($this->onShootArray[$player->login] > 0) {
|
||||||
$serverLogin = $this->maniaControl->server->getLogin();
|
$serverLogin = $this->maniaControl->server->getLogin();
|
||||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$player->login]);
|
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$player->login]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user