Merge pull request #80 from ManiaControl/v0.2

v0.2 (only for MP4)
This commit is contained in:
Lukas Kremsmayr 2017-03-31 22:52:52 +02:00 committed by GitHub
commit aecc7b6e45
245 changed files with 20447 additions and 9829 deletions

View File

@ -11,7 +11,7 @@
error_reporting(E_ALL);
// Run configuration
define('DEV_MODE', false); // Development mode to not send error reports etc.
define('DEV_MODE', true); // Development mode to not send error reports etc.
define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder
define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder

View File

@ -10,6 +10,8 @@ use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player;
@ -22,7 +24,9 @@ use ManiaControl\Players\PlayerManager;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -124,8 +128,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
$itemMarginFactorY = 1.2;
// If game is shootmania lower the icons position by 20
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm'
) {
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm') {
$posY -= $shootManiaOffset;
}
@ -137,23 +140,23 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
// Admin Menu Icon Frame
$iconFrame = new Frame();
$manialink->add($iconFrame);
$manialink->addChild($iconFrame);
$iconFrame->setPosition($posX, $posY);
$backgroundQuad = new Quad();
$iconFrame->add($backgroundQuad);
$iconFrame->addChild($backgroundQuad);
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$itemQuad = new Quad_Icons64x64_1();
$iconFrame->add($itemQuad);
$iconFrame->addChild($itemQuad);
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconServers);
$itemQuad->setSize($itemSize, $itemSize);
// Admin Menu Description
$descriptionLabel = new Label();
$manialink->add($descriptionLabel);
$descriptionLabel->setPosition($posX - count($this->adminMenuItems) * $itemSize * 1.15 - 6, $posY);
$manialink->addChild($descriptionLabel);
$descriptionLabel->setPosition($posX - count($this->adminMenuItems) * $itemSize * 1.05 - 5, $posY);
$descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP);
$descriptionLabel->setSize(40, 4);
$descriptionLabel->setTextSize(1.4);
@ -161,17 +164,16 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
// Admin Menu
$popoutFrame = new Frame();
$manialink->add($popoutFrame);
$manialink->addChild($popoutFrame);
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY);
$popoutFrame->setHAlign($popoutFrame::RIGHT);
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
$popoutFrame->setVisible(false);
$backgroundQuad = new Quad();
$popoutFrame->add($backgroundQuad);
$backgroundQuad->setHAlign($backgroundQuad::RIGHT);
$popoutFrame->addChild($backgroundQuad);
$backgroundQuad->setHorizontalAlign($backgroundQuad::RIGHT);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setSize(count($this->adminMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
$backgroundQuad->setSize(count($this->adminMenuItems) * $itemSize * 1.05 + 2 , $itemSize * $itemMarginFactorY);
$itemQuad->addToggleFeature($popoutFrame);
@ -181,14 +183,14 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
foreach ($menuItems as $menuItem) {
$menuQuad = $menuItem[0];
/** @var Quad $menuQuad */
$popoutFrame->add($menuQuad);
$popoutFrame->addChild($menuQuad);
$menuQuad->setSize($itemSize, $itemSize);
$menuQuad->setX($itemPosX);
$menuQuad->setHAlign($menuQuad::RIGHT);
$menuQuad->setHorizontalAlign($menuQuad::RIGHT);
$itemPosX -= $itemSize * 1.05;
if ($menuItem[1]) {
$menuQuad->removeScriptFeatures();
$menuQuad->removeAllScriptFeatures();
$description = '$s' . $menuItem[1];
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
}
@ -201,23 +203,23 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
*/
// Player Menu Icon Frame
$iconFrame = new Frame();
$manialink->add($iconFrame);
$manialink->addChild($iconFrame);
$iconFrame->setPosition($posX, $posY - $itemSize * $itemMarginFactorY);
$backgroundQuad = new Quad();
$iconFrame->add($backgroundQuad);
$iconFrame->addChild($backgroundQuad);
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$itemQuad = new Quad_Icons64x64_1();
$iconFrame->add($itemQuad);
$iconFrame->addChild($itemQuad);
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconPlayers);
$itemQuad->setSize($itemSize, $itemSize);
// Player Menu Description
$descriptionLabel = new Label();
$manialink->add($descriptionLabel);
$descriptionLabel->setPosition($posX - count($this->playerMenuItems) * $itemSize * 1.15 - 6, $posY - $itemSize * $itemMarginFactorY);
$manialink->addChild($descriptionLabel);
$descriptionLabel->setPosition($posX - count($this->playerMenuItems) * $itemSize * 1.05 - 5, $posY - $itemSize * $itemMarginFactorY);
$descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP);
$descriptionLabel->setSize(40, 4);
$descriptionLabel->setTextSize(1.4);
@ -225,17 +227,16 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
// Player Menu
$popoutFrame = new Frame();
$manialink->add($popoutFrame);
$manialink->addChild($popoutFrame);
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY - $itemSize * $itemMarginFactorY);
$popoutFrame->setHAlign($popoutFrame::RIGHT);
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
$popoutFrame->setVisible(false);
$backgroundQuad = new Quad();
$popoutFrame->add($backgroundQuad);
$backgroundQuad->setHAlign($backgroundQuad::RIGHT);
$popoutFrame->addChild($backgroundQuad);
$backgroundQuad->setHorizontalAlign($backgroundQuad::RIGHT);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setSize(count($this->playerMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
$backgroundQuad->setSize(count($this->playerMenuItems) * $itemSize * 1.05 + 2, $itemSize * $itemMarginFactorY);
$itemQuad->addToggleFeature($popoutFrame);
@ -245,14 +246,14 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
foreach ($menuItems as $menuItem) {
$menuQuad = $menuItem[0];
/** @var Quad $menuQuad */
$popoutFrame->add($menuQuad);
$popoutFrame->addChild($menuQuad);
$menuQuad->setSize($itemSize, $itemSize);
$menuQuad->setX($itemPosX);
$menuQuad->setHAlign($menuQuad::RIGHT);
$menuQuad->setHorizontalAlign($menuQuad::RIGHT);
$itemPosX -= $itemSize * 1.05;
if ($menuItem[1]) {
$menuQuad->removeScriptFeatures();
$menuQuad->removeAllScriptFeatures();
$description = '$s' . $menuItem[1];
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
}

View File

@ -10,8 +10,11 @@ use FML\Controls\Quads\Quad_BgsPlayerCard;
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
use FML\ManiaLink;
use FML\Script\Features\Paging;
use FML\Script\Script;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
@ -24,7 +27,9 @@ use ManiaControl\Players\Player;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
class AdminLists implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -88,13 +93,14 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
//Create ManiaLink
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$script = $maniaLink->getScript();
$paging = new Paging();
$script = new Script();
$script->addFeature($paging);
$maniaLink->setScript($script);
// Main frame
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
$maniaLink->addChild($frame);
// Start offsets
$posX = -$width / 2;
@ -102,11 +108,11 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
//Predefine description Label
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
$frame->add($descriptionLabel);
$frame->addChild($descriptionLabel);
// Headline
$headFrame = new Frame();
$frame->add($headFrame);
$frame->addChild($headFrame);
$headFrame->setY($posY - 5);
$array = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Actions' => $posX + 120);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
@ -118,19 +124,19 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
foreach ($admins as $admin) {
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$frame->addChild($pageFrame);
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height / 2 - 10;
}
$playerFrame = new Frame();
$pageFrame->add($playerFrame);
$pageFrame->addChild($playerFrame);
$playerFrame->setY($posY);
if ($index % 2 !== 0) {
$lineQuad = new Quad_BgsPlayerCard();
$playerFrame->add($lineQuad);
$playerFrame->addChild($lineQuad);
$lineQuad->setSize($width, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ(0.001);
@ -142,14 +148,14 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
// Level Quad
$rightQuad = new Quad_BgRaceScore2();
$playerFrame->add($rightQuad);
$playerFrame->addChild($rightQuad);
$rightQuad->setX($posX + 13);
$rightQuad->setZ(5);
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
$rightQuad->setSize(7, 3.5);
$rightLabel = new Label_Text();
$playerFrame->add($rightLabel);
$playerFrame->addChild($rightLabel);
$rightLabel->setX($posX + 13.9);
$rightLabel->setTextSize(0.8);
$rightLabel->setZ(10);
@ -169,7 +175,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
// Quad
$quad = new Quad_BgsPlayerCard();
$playerFrame->add($quad);
$playerFrame->addChild($quad);
$quad->setZ(11);
$quad->setX($posX + 130);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
@ -178,7 +184,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
//Label
$label = new Label_Button();
$playerFrame->add($label);
$playerFrame->addChild($label);
$label->setX($posX + 130);
$quad->setZ(12);
$label->setStyle($style);

View File

@ -3,6 +3,8 @@
namespace ManiaControl\Admin;
use ManiaControl\Commands\CommandListener;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
@ -13,7 +15,9 @@ use ManiaControl\Players\Player;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class AuthCommands implements CommandListener {
class AuthCommands implements CommandListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Private properties
*/

View File

@ -8,6 +8,8 @@ use ManiaControl\Callbacks\EchoListener;
use ManiaControl\Communication\CommunicationAnswer;
use ManiaControl\Communication\CommunicationListener;
use ManiaControl\Communication\CommunicationMethods;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
@ -21,7 +23,9 @@ use ManiaControl\Settings\Setting;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener {
class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/

View File

@ -4,6 +4,8 @@ namespace ManiaControl\Bills;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\InvalidArgumentException;
@ -16,7 +18,9 @@ use Maniaplanet\DedicatedServer\Structures\Bill;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class BillManager implements CallbackListener {
class BillManager implements CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/

View File

@ -3,6 +3,8 @@
namespace ManiaControl\Callbacks;
use ManiaControl\Callbacks\Models\BaseCallback;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
@ -12,7 +14,9 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CallbackManager {
class CallbackManager implements UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -46,7 +50,7 @@ class CallbackManager {
/*
* Public properties
*/
public $libXmlRpcCallbacks = null;
public $libXmlRpcCallbacks = null;
public $shootManiaCallbacks = null;
public $trackManiaCallbacks = null;
@ -98,7 +102,7 @@ class CallbackManager {
return false;
}
if (!array_key_exists($callbackName, $this->callbackListenings)) {
if (!$this->callbackListeningExists($callbackName)) {
$this->callbackListenings[$callbackName] = array();
}
@ -108,6 +112,16 @@ class CallbackManager {
return true;
}
/**
* Checks if a Callback Listening exists
*
* @param $callbackName
* @return bool
*/
public function callbackListeningExists($callbackName) {
return array_key_exists($callbackName, $this->callbackListenings);
}
/**
* Register a new Script Callback Listener
*
@ -272,7 +286,7 @@ class CallbackManager {
} else {
$callbackName = $callback;
}
if (!array_key_exists($callbackName, $this->callbackListenings)) {
if (!$this->callbackListeningExists($callbackName)) {
return;
}

View File

@ -2,6 +2,8 @@
// TODO: method class for all the libxmlrpc get Methods, to fetch the callback asnyc
// TODO implement all STOP callbacks
// 22-3-2017 Added/Fixed TM Callback for WayPoint // Need to Add better checks eventually
namespace ManiaControl\Callbacks;
/**
@ -26,12 +28,87 @@ interface Callbacks {
/*
* Common Callbacks
*/
//NEW Callbacks
const XMLRPC_CALLBACKSLIST = 'XmlRpc.CallbacksList';
const MP_STARTSERVERSTART = 'Maniaplanet.StartServer_Start';
const MP_STARTSERVEREND = 'Maniaplanet.StartServer_End';
const MP_STARTMATCHSTART = 'Maniaplanet.StartMatch_Start';
const MP_STARTMATCHEND = 'Maniaplanet.StartMatch_End';
//const MP_STARTMAPSTART = 'Maniaplanet.StartMap_Start';
//const MP_STARTMAPEND = 'Maniaplanet.StartMap_End';
const MP_STARTROUNDSTART = 'Maniaplanet.StartRound_Start';
const MP_STARTROUNDEND = 'Maniaplanet.StartRound_End';
const MP_STARTTURNSTART = 'Maniaplanet.StartTurn_Start';
const MP_STARTTURNEND = 'Maniaplanet.StartTurn_End';
const MP_STARTPLAYLOOP = 'Maniaplanet.StartPlayLoop';
const MP_ENDPLAYLOOP = 'Maniaplanet.EndPlayLoop';
const MP_ENDTURNSTART = 'Maniaplanet.EndTurn_Start';
const MP_ENDTURNEND = 'Maniaplanet.EndTurn_End';
const MP_ENDROUNDSTART = 'Maniaplanet.EndRound_Start';
const MP_ENDROUNDEND = 'Maniaplanet.EndRound_End';
//const MP_ENDMAPSTART = 'Maniaplanet.EndMap_Start';
//const MP_ENDMAPEND = 'Maniaplanet.EndMap_End';
const MP_ENDMATCHSTART = 'Maniaplanet.EndMatch_Start';
const MP_ENDMATCHEND = 'Maniaplanet.EndMatch_End';
const MP_ENDSERVERSTART = 'Maniaplanet.EndServer_Start';
const MP_ENDSERVEREND = 'Maniaplanet.EndServer_End';
const MP_LOADINGMAPSTART = 'Maniaplanet.LoadingMap_Start';
const MP_LOADINGMAPEND = 'Maniaplanet.LoadingMap_End';
const MP_UNLOADINGMAPSTART = 'Maniaplanet.UnloadingMap_Start';
const MP_UNLOADINGMAPEND = 'Maniaplanet.UnloadingMap_End';
const MP_PODIUMSTART = 'Maniaplanet.Podium_Start';
const MP_PODIUMEND = 'Maniaplanet.Podium_End';
const SM_SCORES = "Shootmania.Scores";
const SM_ONEVENTDEFAULT = "Shootmania.Event.Default";
const SM_ONSHOOT = "Shootmania.Event.OnShoot";
const SM_ONHIT = "Shootmania.Event.OnHit";
const SM_ONNEARMISS = "Shootmania.Event.OnNearMiss";
const SM_ONARMOREMPTY = "Shootmania.Event.OnArmorEmpty";
const SM_ONCAPTURE = "Shootmania.Event.OnCapture";
const SM_ONSHOTDENY = "Shootmania.Event.OnShotDeny";
const SM_ONFALLDAMAGE = "Shootmania.Event.OnFallDamage";
const SM_ONCOMMAND = "Shootmania.Event.OnCommand";
//Shootmania.Event.OnPlayerRemoved Shootmania.Event.OnPlayerAdded not needed yet
const SM_ONPLAYERREQUESTRESPAWN = "Shootmania.Event.OnPlayerRequestRespawn";
const SM_ONACTIONCUSTOMEVENT = "Shootmania.Event.OnActionCustomEvent";
const SM_ONACTIONEVENT = "Shootmania.Event.OnActionEvent";
const SM_ONPLAYERTOUCHESOBJECT = "Shootmania.Event.OnPlayerTouchesObject";
const SM_ONPLAYERTRIGGERSSECTOR = "Shootmania.Event.OnPlayerTriggersSector";
const SM_ONPLAYERTHROWSOBJECT = "Shootmania.Event.OnPlayerThrowsObject";
const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange";
// New TM Callbacks
const TM_ONEVENTDEFAULT = "Trackmania.Event.Default";
const TM_ONEVENTSTARTLINE = "Trackmania.Event.StartLine";
const TM_ONCOMMAND = "Trackmania.Event.OnCommand";
const TM_ONPLAYERADDED = "Trackmania.Event.OnPlayerAdded";
const TM_ONPLAYERREMOVED = "Trackmania.Event.OnPlayerRemoved";
const TM_ONWAYPOINT = "Trackmania.Event.WayPoint";
const TM_ONGIVEUP = "Trackmania.Event.GiveUp";
const TM_ONRESPAWN = "Trackmania.Event.Respawn";
const TM_ONSTUNT = "Trackmania.Event.Stunt";
const TM_ONSTARTCOUNTDOWN = "Trackmania.Event.StartCountdown";
const TM_SCORES = "Trackmania.Scores";
const TM_WARMUPSTART = "Trackmania.WarmUp.Start";
const TM_WARMUPSTARTROUND = "Trackmania.WarmUp.StartRound";
const TM_WARMUPENDROUND = "Trackmania.WarmUp.EndRound";
const TM_WARMUPEND = "Trackmania.WarmUp.End";
//ManiaControl Callbacks
/** BeginMap Callback: Map */
const BEGINMAP = 'Callbacks.BeginMap';
//OLD Callbacks
/** BeginMatch Callback: MatchNumber */
const BEGINMATCH = 'Callbacks.BeginMatch';
/** LoadingMap Callback: MapNumber */
const LOADINGMAP = 'Callbacks.LoadingMap';
/** BeginMap Callback: Map */
const BEGINMAP = 'Callbacks.BeginMap';
/** BeginSubMatch Callback: SubmatchNumber */
const BEGINSUBMATCH = 'Callbacks.BeginSubmatch';
/** BeginRound Callback: RoundNumber */
@ -124,14 +201,14 @@ interface Callbacks {
* TrackMania Callbacks
*/
/** OnStartLine Callback */
const ONSTARTLINE = 'Callbacks.OnStartLine';
const ONSTARTLINE = 'Callbacks.StartLine';
/** OnWayPoint Callback */
const ONWAYPOINT = 'Callbacks.OnWayPoint';
const ONWAYPOINT = 'Callbacks.WayPoint';
/** OnGiveUp Callback */
const ONGIVEUP = 'Callbacks.OnGiveUp';
const ONGIVEUP = 'Callbacks.GiveUp';
/** OnRespawn Callback */
const ONRESPAWN = 'Callbacks.OnRespawn';
const ONRESPAWN = 'Callbacks.Respawn';
/** OnStunt Callback */
const ONSTUNT = 'Callbacks.OnStunt';
const ONSTUNT = 'Callbacks.Stunt';
}

View File

@ -3,6 +3,8 @@
namespace ManiaControl\Callbacks;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
@ -12,7 +14,9 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class EchoManager implements CallbackListener, EchoListener {
class EchoManager implements CallbackListener, EchoListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Private properties
*/
@ -69,8 +73,8 @@ class EchoManager implements CallbackListener, EchoListener {
$this->echoListenings[$echoName] = array();
}
$listening = new Listening($listener, $method);
array_push($this->echoListenings[$echoName], $listening);
$listening = new Listening($listener, $method);
$this->echoListenings[$echoName] = $listening;
return true;
}

View File

@ -4,8 +4,11 @@ namespace ManiaControl\Callbacks;
use ManiaControl\Callbacks\Structures\ArmorEmptyStructure;
use ManiaControl\Callbacks\Structures\CaptureStructure;
use ManiaControl\Callbacks\Structures\ManiaPlanet\StartEndStructure;
use ManiaControl\Callbacks\Structures\ManiaPlanet\StartServerStructure;
use ManiaControl\Callbacks\Structures\NearMissStructure;
use ManiaControl\Callbacks\Structures\PlayerHitStructure;
use ManiaControl\Callbacks\Structures\XmlRpc\CallbacksListStructure;
use ManiaControl\ManiaControl;
/**
@ -41,7 +44,106 @@ class LibXmlRpcCallbacks implements CallbackListener {
* @param mixed $data
*/
public function handleScriptCallback($name, $data) {
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
//return; //Leave that disabled while testing/implementing Callbacks
}
switch ($name) {
//New callbacks
case Callbacks::XMLRPC_CALLBACKSLIST:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data));
break;
case Callbacks::MP_STARTSERVERSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data));
break;
case Callbacks::MP_STARTSERVEREND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVEREND, new StartServerStructure($this->maniaControl, $data));
break;
case Callbacks::MP_STARTMATCHSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTMATCHSTART, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_STARTMATCHEND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTMATCHEND, new StartEndStructure($this->maniaControl, $data));
break;
case 'Maniaplanet.StartMap_Start': //Use the MapManager Callback
//No use for this Implementation right now (as the MapManager Callback should be used
break;
case 'Maniaplanet.StartMap_End': //Use the MapManager Callback
$jsonData = json_decode($data[0]);
$this->maniaControl->getMapManager()->handleScriptBeginMap($jsonData->map->uid, 'False');
//TODO Test if json is correctly parsed
break;
case Callbacks::MP_STARTROUNDSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTROUNDSTART, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_STARTROUNDEND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTROUNDEND, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_STARTTURNSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTTURNSTART, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_STARTTURNEND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTTURNEND, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_STARTPLAYLOOP:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTPLAYLOOP, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_ENDPLAYLOOP:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDPLAYLOOP, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_ENDTURNSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDTURNSTART, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_ENDTURNEND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDTURNEND, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_ENDROUNDSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDROUNDSTART, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_ENDROUNDEND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDROUNDEND, new StartEndStructure($this->maniaControl, $data));
break;
case 'Maniaplanet.EndMap_Start':
//no need for this implementation, callback handled by Map Manager
break;
case 'Maniaplanet.EndMap_End': //Use the MapManager Callback
$this->maniaControl->getMapManager()->handleScriptEndMap(); //Verify if better here or at EndMap_End
break;
case Callbacks::MP_ENDMATCHSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDMATCHSTART, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_ENDMATCHEND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDMATCHEND, new StartEndStructure($this->maniaControl, $data));
break;
case Callbacks::MP_ENDSERVERSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDSERVERSTART, new StartServerStructure($this->maniaControl, $data));
break;
case Callbacks::MP_ENDSERVEREND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDSERVEREND, new StartServerStructure($this->maniaControl, $data));
break;
case Callbacks::MP_LOADINGMAPSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPSTART);
break;
case Callbacks::MP_LOADINGMAPEND:
$jsonData = json_decode($data[0]);
$map = $this->maniaControl->getMapManager()->getMapByUid($jsonData->map->uid); //Verify Json
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPEND, $map);
break;
case Callbacks::MP_UNLOADINGMAPSTART:
$jsonData = json_decode($data[0]);
$map = $this->maniaControl->getMapManager()->getMapByUid($jsonData->map->uid); //Verify Json
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPSTART, $map);
break;
case Callbacks::MP_UNLOADINGMAPEND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPEND);
break;
case Callbacks::MP_PODIUMSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMSTART);
break;
case Callbacks::MP_PODIUMEND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMEND);
break;
//OLD Callbacks
case 'LibXmlRpc_BeginMatch':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]);
break;

View File

@ -2,6 +2,9 @@
namespace ManiaControl\Callbacks;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
/**
* Model Class for a Basic Listening
*
@ -9,12 +12,14 @@ namespace ManiaControl\Callbacks;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Listening {
class Listening implements UsageInformationAble {
use UsageInformationTrait;
/*
* Public Properties
*/
public $listener = null;
public $method = null;
public $method = null;
/**
* Construct a new Timer Listening

View File

@ -20,12 +20,16 @@ class RecordCallback extends BaseCallback {
/*
* Public Properties
*/
public $isEndRace = null;
public $isEndLap = null;
public $time = null;
public $lapTime = null;
public $checkpoint = null;
public $lapCheckpoint = null;
public $lap = null;
public $blockId = null;
public $player = null;
public $racetime = null;
public $laptime = null;
public $stuntsscore = null;
public $checkpointinrace = null;
public $checkpointinlap = null;
public $isendrace = null;
public $isendlap = null;
public $blockid = null;
public $speed = null;
public $distance = null;
}

View File

@ -4,6 +4,21 @@ namespace ManiaControl\Callbacks;
use ManiaControl\Callbacks\Models\RecordCallback;
use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnActionCustomEventStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnActionEvent;
use ManiaControl\Callbacks\Structures\ShootMania\OnArmorEmptyStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnHitStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnNearMissStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerObjectStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestActionChange;
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerTriggersSectorStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnScoresStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure;
use ManiaControl\Callbacks\Structures\ShootMania\OnShotDenyStructure;
use ManiaControl\ManiaControl;
/**
@ -48,7 +63,61 @@ class ShootManiaCallbacks implements CallbackListener {
* @param mixed $data
*/
public function handleScriptCallbacks($name, $data) {
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
//return; //Leave that disabled while testing/implementing Callbacks
}
switch ($name) {
//MP4 New Callbacks
case Callbacks::SM_SCORES:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_SCORES, new OnScoresStructure($this->maniaControl, $data));
break;
//TODO UI Properties Later
case Callbacks::SM_ONEVENTDEFAULT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONSHOOT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONSHOOT, new OnShootStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONHIT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONHIT, new OnHitStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONNEARMISS:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONNEARMISS, new OnNearMissStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONARMOREMPTY:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONARMOREMPTY, new OnArmorEmptyStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONCAPTURE:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONSHOTDENY:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONSHOTDENY, new OnShotDenyStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONCOMMAND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCOMMAND, new OnCommandStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERREQUESTRESPAWN:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTRESPAWN, new OnPlayerRequestRespawnStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONACTIONCUSTOMEVENT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONACTIONCUSTOMEVENT, new OnActionCustomEventStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONACTIONEVENT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONACTIONEVENT, new OnActionEvent($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERTOUCHESOBJECT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTOUCHESOBJECT, new OnPlayerObjectStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERTRIGGERSSECTOR:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTRIGGERSSECTOR, new OnPlayerTriggersSectorStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERTHROWSOBJECT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERTHROWSOBJECT, new OnPlayerObjectStructure($this->maniaControl, $data));
break;
case Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE, new OnPlayerRequestActionChange($this->maniaControl, $data));
break;
//Old Callbacks
case 'LibXmlRpc_Rankings':
$this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]);
break;

View File

@ -0,0 +1,35 @@
<?php
namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
* Base Structure of all Callback Structures
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class BaseStructure implements UsageInformationAble {
use UsageInformationTrait;
/** @var ManiaControl $maniaControl */
protected $maniaControl;
private $plainJsonObject;
protected function __construct(ManiaControl $maniaControl, $data) {
$this->maniaControl = $maniaControl;
$this->plainJsonObject = json_decode($data[0]);
}
/**
* Gets the Plain Json
*/
public function getPlainJsonObject() {
return $this->plainJsonObject;
}
}

View File

@ -0,0 +1,118 @@
<?php
namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnScores Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CommonScoresStructure extends BaseStructure {
protected $responseId;
protected $section;
protected $useTeams;
protected $winnerTeam;
protected $winnerPlayer;
protected $teamScores = array();
protected $playerScores = array();
//TODO test
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
$this->responseId = $jsonObj->responseid;
$this->section = $jsonObj->section;
$this->useTeams = $jsonObj->useteams;
$this->winnerTeam = $jsonObj->winnerteam;
$this->winnerPlayer = $this->maniaControl->getPlayerManager()->getPlayer($jsonObj->winnerplayer);
foreach ($jsonObj->teams as $team) {
if ($this instanceof \ManiaControl\Callbacks\Structures\TrackMania\OnScoresStructure) {
$teamScore = new \ManiaControl\Callbacks\Structures\TrackMania\Models\TeamScore();
} else {
$teamScore = new \ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore();
}
$teamScore->setId($team->id);
$teamScore->setName($team->name);
$teamScore->setRoundPoints($team->roundpoints);
$teamScore->setMatchPoints($team->matchpoints);
$teamScore->setMapPoints($team->mappoints);
$this->teamScores[$team->id] = $teamScore; //TODO verify that different teams have different ids
}
}
/**
* Get the Winner Player Object
*
* @return \ManiaControl\Players\Player
*/
public function getWinnerPlayer() {
return $this->winnerPlayer;
}
/**
* Get the Response Id
*
* @return string
*/
public function getResponseId() {
return $this->responseId;
}
/**
* < Current progress of the match. Can be "" | "EndRound" | "EndMap" | "EndMatch"
*
* @return string
*/
public function getSection() {
return $this->section;
}
/**
* Returns if the GameMode uses Teams or not
*
* @return boolean
*/
public function getUseTeams() {
return $this->useTeams;
}
/**
* Get the Winner Team Id
*
* @return int
*/
public function getWinnerTeamId() {
return $this->winnerTeam;
}
/**
* Returns the TeamScores
*
* @return TeamScore[]
*/
public function getTeamScores() {
return $this->teamScores;
}
/**
* Get the Player Scores
*
* @return CommonPlayerScore[]
*/
public function getPlayerScores() {
return $this->playerScores;
}
}

View File

@ -0,0 +1,88 @@
<?php
namespace ManiaControl\Callbacks\Structures\Common\Models;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Players\Player;
class CommonPlayerScore implements UsageInformationAble {
use UsageInformationTrait;
protected $player;
protected $rank;
protected $roundPoints;
protected $mapPoints;
/**
* Returns the Player
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* @param \ManiaControl\Players\Player $player
*/
public function setPlayer(Player $player) {
$this->player = $player;
}
/**
* Returns the Rank
*
* @return int
*/
public function getRank() {
return $this->rank;
}
/**
* Sets the Rank
*
* @param int $rank
*/
public function setRank($rank) {
$this->rank = $rank;
}
/**
* Gets the Round Points
*
* @return int
*/
public function getRoundPoints() {
return $this->roundPoints;
}
/**
* Sets the RoundPoints
*
* @param int $roundPoints
*/
public function setRoundPoints($roundPoints) {
$this->roundPoints = $roundPoints;
}
/**
* Gets the Map Points
*
* @return int
*/
public function getMapPoints() {
return $this->mapPoints;
}
/**
* Sets the Map Points
*
* @param int $mapPoints
*/
public function setMapPoints($mapPoints) {
$this->mapPoints = $mapPoints;
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace ManiaControl\Callbacks\Structures\Common\Models;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
/**
* TeamScore Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CommonTeamScore implements UsageInformationAble {
use UsageInformationTrait;
private $id;
private $name;
private $roundPoints;
private $mapPoints;
private $matchPoints;
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* @return mixed
*/
public function getName() {
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name) {
$this->name = $name;
}
/**
* @return mixed
*/
public function getRoundPoints() {
return $this->roundPoints;
}
/**
* @param mixed $roundPoints
*/
public function setRoundPoints($roundPoints) {
$this->roundPoints = $roundPoints;
}
/**
* @return mixed
*/
public function getMapPoints() {
return $this->mapPoints;
}
/**
* @param mixed $mapPoints
*/
public function setMapPoints($mapPoints) {
$this->mapPoints = $mapPoints;
}
/**
* @return mixed
*/
public function getMatchPoints() {
return $this->matchPoints;
}
/**
* @param mixed $matchPoints
*/
public function setMatchPoints($matchPoints) {
$this->matchPoints = $matchPoints;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Default Start End Callbacks
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class StartEndStructure extends BaseStructure {
private $count;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->count = $this->getPlainJsonObject()->count;
}
/**
* Get the Count of this Section
*
* @return int
*/
public function getCount() {
return $this->count;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Default Start Server Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class StartServerStructure extends BaseStructure {
private $restarted;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->restarted = $this->getPlainJsonObject()->restarted;
}
/**
* Flag if the Server got Restarted
*
* @return mixed
*/
public function getRestarted() {
return $this->restarted;
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
/**
* Landmark Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Landmark implements UsageInformationAble {
use UsageInformationTrait;
private $tag = "";
private $order = 0;
private $id = "";
private $position = null;
/**
* @return string
*/
public function getTag() {
return $this->tag;
}
/**
* @param string $tag
*/
public function setTag($tag) {
$this->tag = $tag;
}
/**
* @return mixed
*/
public function getOrder() {
return $this->order;
}
/**
* @param mixed $order
*/
public function setOrder($order) {
$this->order = $order;
}
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* @return \ManiaControl\Callbacks\Structures\ShootMania\Models\Position
*/
public function getPosition() {
return $this->position;
}
/**
* @param \ManiaControl\Callbacks\Structures\ShootMania\Models\Position $position
*/
public function setPosition(Position $position) {
$this->position = $position;
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
/**
* PlayerScore Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerScore extends CommonPlayerScore {
}

View File

@ -0,0 +1,64 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
/**
* Position Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Position implements UsageInformationAble {
use UsageInformationTrait;
private $x = 0;
private $y = 0;
private $z = 0;
/**
* @return int
*/
public function getX() {
return $this->x;
}
/**
* @param int $x
*/
public function setX($x) {
$this->x = $x;
}
/**
* @return int
*/
public function getZ() {
return $this->z;
}
/**
* @param int $z
*/
public function setZ($z) {
$this->z = $z;
}
/**
* @return int
*/
public function getY() {
return $this->y;
}
/**
* @param int $y
*/
public function setY($y) {
$this->y = $y;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore;
/**
* Shootmania TeamScore Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class TeamScore extends CommonTeamScore {
}

View File

@ -0,0 +1,17 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
/**
* Weapons Interface
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
interface Weapons {
const LASER = 1;
const ROCKET = 2;
const NUCLEUS = 3;
const ARROW = 5;
}

View File

@ -0,0 +1,91 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnCustomEvent Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnActionCustomEventStructure extends BaseStructure {
private $time;
private $actionId;
private $shooter;
private $victim;
private $param1;
private $param2 = array();
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->actionId = $this->getPlainJsonObject()->actionid;
$this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim);
$this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter);
$this->param1 = $this->getPlainJsonObject()->param1;
$this->param2 = $this->getPlainJsonObject()->param2;
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < Id of the action that triggered the event
*
* @return string
*/
public function getActionId() {
return $this->actionId;
}
/**
* < Login of the player who shot if any
*
* @return \ManiaControl\Players\Player
*/
public function getShooter() {
return $this->shooter;
}
/**
* < player who got hit if any
*
* @return \ManiaControl\Players\Player
*/
public function getVictim() {
return $this->victim;
}
/**
* < First custom param of the event
*
* @return string
*/
public function getParam1() {
return $this->param1;
}
/**
* < Second custom param of the event
*
* @return array
*/
public function getParam2() {
return $this->param2;
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnCustomEvent Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnActionEvent extends BaseStructure {
private $time;
private $player;
private $actionInput;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->actionInput = $this->getPlainJsonObject()->actioninput;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < player who triggered the action
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* < The input pressed to trigger the action
*
* @return string
*/
public function getActionInput() {
return $this->actionInput;
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
/**
* Structure Class for the OnArmorEmpty Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure {
}

View File

@ -0,0 +1,80 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Structures\ShootMania\Models\Landmark;
use ManiaControl\Callbacks\Structures\ShootMania\Models\Position;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Class for the OnCapture Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnCaptureStructure extends BaseStructure {
private $time;
private $landMark;
private $playerArray = array();
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
$this->time = $jsonObj->time;
$this->playerArray = $jsonObj->players;
$this->landMark = new Landmark();
$this->landMark->setTag($jsonObj->landmark->tag);
$this->landMark->setOrder($jsonObj->landmark->tag);
$this->landMark->setId($jsonObj->landmark->tag);
$position = new Position();
$position->setX($jsonObj->landmark->position->x);
$position->setY($jsonObj->landmark->position->y);
$position->setZ($jsonObj->landmark->position->z);
$this->landMark->setPosition($position);
}
/**
* Get the logins as Array
*
* @return string[]
*/
public function getLoginArray() {
return $this->playerArray;
}
/**
* Get the Players as Player Array
*
* @return Player[]
*/
public function getPlayerArray() {
$playerArray = array();
foreach ($this->playerArray as $login) {
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if ($player) {
$playerArray[$login] = $player;
}
}
return $playerArray;
}
/**
* Returns Information about the Captured Landmark
*
* @return \ManiaControl\Callbacks\Structures\ShootMania\Models\LandMark
*/
public function getLandMark() {
return $this->landMark;
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnCommand Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnCommandStructure extends BaseStructure {
private $time;
private $name;
private $value;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->name = $this->getPlainJsonObject()->name;
$this->value = $this->getPlainJsonObject()->value;
}
/**
* < Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < Name of the command
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* < The value passed by the command
* "boolean": true,
* "integer": 123,
* "real": 123.456,
* "text": "an example value"
*
* @return mixed
*/
public function getValue() {
return $this->value;
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Default Event Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnDefaultEventStructure extends BaseStructure {
private $time;
private $type;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->type = $this->getPlainJsonObject()->type;
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* Returns the type of event
*
* @return string
*/
public function getType() {
return $this->type;
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Class for the OnFallDamage Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnFallDamageStructure extends BaseStructure {
private $time;
/**
* @var Player $shooter
*/
private $victim;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim);
}
/**
* < Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < Player who fell
*
* @return Player
*/
public function getVictim() {
return $this->victim;
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Structures\ShootMania\Models\Position;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Base Class for the OnHit/OnNearMiss/OnArmorEmpty Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure {
private $time;
private $weapon;
private $shooterPosition;
private $victimPosition;
private $shooter;
private $victim;
//private $shooterPoints; (was in mp3)
//private $hitDistance; (was in mp3)
/**
* Construct a new On Hit Structure
*
* @param ManiaControl $maniaControl
* @param array $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
$this->time = $jsonObj->time;
$this->weapon = $jsonObj->weapon;
$this->shooterPosition = new Position();
$this->shooterPosition->setX($jsonObj->shooterposition->x);
$this->shooterPosition->setY($jsonObj->shooterposition->y);
$this->shooterPosition->setZ($jsonObj->shooterposition->z);
$this->victimPosition = new Position();
$this->victimPosition->setX($jsonObj->victimposition->x);
$this->victimPosition->setY($jsonObj->victimposition->y);
$this->victimPosition->setZ($jsonObj->victimposition->z);
$this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter);
$this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim);
}
/**
* < Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < Id of the weapon [1-Laser, 2-Rocket, 3-Nucleus, 5-Arrow]
*
* @see \ManiaControl\Callbacks\Structures\ShootMania\Models\Weapons
* @return int
*/
public function getWeapon() {
return intval($this->weapon);
}
/**
* < Position of the Shooter at the time
*
* @return Position
*/
public function getShooterPosition() {
return $this->shooterPosition;
}
/**
* < Position of the Victim at the time
*
* @return \ManiaControl\Callbacks\Structures\ShootMania\Models\Position
*/
public function getVictimPosition() {
return $this->victimPosition;
}
/**
* < Shooter Player
*
* @return Player
*/
public function getShooter() {
return $this->shooter;
}
/**
* < Victim Player
*
* @return Player
*/
public function getVictim() {
return $this->victim;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnHit Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure {
private $damage;
public function __construct(ManiaControl $maniaControl, array $data) {
parent::__construct($maniaControl, $data);
$this->damage = $this->getPlainJsonObject()->damage;
}
/**
* < Amount of Damage done by the hit (only on onHit)
*
* @return int
*/
public function getDamage() {
return $this->damage;
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnNearMiss Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnNearMissStructure extends OnHitNearMissArmorEmptyBaseStructure {
private $distance;
public function __construct(ManiaControl $maniaControl, array $data) {
parent::__construct($maniaControl, $data);
$this->distance = $this->getPlainJsonObject()->distance;
}
/**
* Returns the distance
*
* @return float
*/
public function getDistance() {
return $this->distance;
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnPlayerTouchesObject Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnPlayerObjectStructure extends BaseStructure {
private $time;
private $player;
private $objectId;
private $modelId;
private $modelName;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->objectId = $this->getPlainJsonObject()->objectid;
$this->modelId = $this->getPlainJsonObject()->modelid;
$this->modelName = $this->getPlainJsonObject()->modelname;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < Login of the player who touched the object
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* < The id of the object
*
* @return string
*/
public function getObjectId() {
return $this->objectId;
}
/**
* < The id of the object model
*
* @return string
*/
public function getModelId() {
return $this->modelId;
}
/**
* < The name of the object model
*
* @return string
*/
public function getModelName() {
return $this->modelName;
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnPlayerRequestActionChange Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnPlayerRequestActionChange extends BaseStructure {
private $time;
private $player;
private $actionChange;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->actionChange = $this->getPlainJsonObject()->actionchange;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < player who requested a new action
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* < Can be -1 (request previous action) or 1 (request next action)
*
* @return string
*/
public function getActionChange() {
return $this->actionChange;
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Class for the OnPlayerRequestRespawnStructure Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnPlayerRequestRespawnStructure extends BaseStructure {
private $time;
/**
* @var Player $player
*/
private $player;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns the Time the Event Happened
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* Gets the Player
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnPlayerTriggersSector Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnPlayerTriggersSectorStructure extends BaseStructure {
private $time;
private $player;
private $sectorId;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->sectorId = $this->getPlainJsonObject()->sectorid;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < player who touched the object
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
/**
* < Id of the triggered sector
*
* @return string
*/
public function getSectorId() {
return $this->sectorId;
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
use ManiaControl\Callbacks\Structures\ShootMania\Models\PlayerScore;
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Shootmania OnScores Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnScoresStructure extends CommonScoresStructure {
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
foreach ($jsonObj->players as $jsonPlayer) {
$playerScore = new PlayerScore();
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
$playerScore->setRank($jsonPlayer->rank);
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
$playerScore->setMapPoints($jsonPlayer->mappoints);
$this->playerScores[$jsonPlayer->login] = $playerScore;
}
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/**
* Structure Class for the OnShoot Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnShootStructure extends BaseStructure {
public $time;
public $weapon;
/**
* @var Player $shooter
*/
private $shooter;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->weapon = $this->getPlainJsonObject()->weapon;
$this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter);
}
/**
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* @return int
*/
public function getWeapon() {
return $this->weapon;
}
/**
* @return Player
*/
public function getShooter() {
return $this->shooter;
}
/** Dumps the Object with some Information */
public function dump() {
parent::dump();
var_dump("With getShooter() you get a Player Object");
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnShotDeny Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnShotDenyStructure extends BaseStructure {
private $time;
private $shooterWeapon;
private $victimWeapon;
private $shooter;
private $victim;
/**
* Construct a new On Hit Structure
*
* @param ManiaControl $maniaControl
* @param array $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
$this->time = $jsonObj->time;
$this->shooterWeapon = $jsonObj->victim;
$this->victimWeapon = $jsonObj->damage;
$this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter);
$this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim);
}
/**
* ServerTime The Event Happened //TODO add Trait for the Time Property
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* Gets the Shooter Player
*
* @return \ManiaControl\Players\Player
*/
public function getShooter() {
return $this->shooter;
}
/**
* Gets the Victim Player
*
* @return \ManiaControl\Players\Player
*/
public function getVictim() {
return $this->victim;
}
/**
* @return mixed
*/
public function getShooterWeapon() {
return $this->shooterWeapon;
}
/**
* Get the Victim Weapon
*
* @see \ManiaControl\Callbacks\Structures\ShootMania\Models\Weapons
* @return int
*/
public function getVictimWeapon() {
return $this->victimWeapon;
}
}

View File

@ -0,0 +1,91 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania\Models;
use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
use ManiaControl\Players\Player;
//TODO proper return descriptions on getter methods -> use autogenerate for setter/getter + docs
/**
* PlayerScore Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerScore extends CommonPlayerScore {
private $bestRaceTime;
private $bestLapTime;
private $stuntScore;
/**
* Returns the Rank
*
* @return int
*/
public function getRank() {
return $this->rank;
}
/**
* Sets the Rank
*
* @param int $rank
*/
public function setRank($rank) {
$this->rank = $rank;
}
/**
* Gets the bestRaceTime
*
* @param int $bestraceTime
*/
public function getBestraceTime(){
return $this->bestRaceTime;
}
/**
* Gets the bestlapTime
*
* @param int $bestlapTime
*/
public function getBestlapTime(){
return $this->bestLapTime;
}
/**
* Gets the StuntScore
*
* @param int $bestraceTime
*/
public function getStuntScore(){
return $this->stuntScore;
}
/**
* @param mixed $bestRaceTime
*/
public function setBestRaceTime($bestRaceTime) {
$this->bestRaceTime = $bestRaceTime;
}
/**
* @param mixed $bestLapTime
*/
public function setBestLapTime($bestLapTime) {
$this->bestLapTime = $bestLapTime;
}
/**
* @param mixed $stuntScore
*/
public function setStuntScore($stuntScore) {
$this->stuntScore = $stuntScore;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania\Models;
use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore;
/**
* Shootmania TeamScore Model
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class TeamScore extends CommonTeamScore {
}

View File

@ -0,0 +1,59 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the OnCommand Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnCommandStructure extends BaseStructure {
private $time;
private $name;
private $value;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->name = $this->getPlainJsonObject()->name;
$this->value = $this->getPlainJsonObject()->value;
}
/**
* < Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < Name of the command
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* < The value passed by the command
* "boolean": true,
* "integer": 123,
* "real": 123.456,
* "text": "an example value"
*
* @return mixed
*/
public function getValue() {
return $this->value;
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Default Event Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnDefaultEventStructure extends BaseStructure {
private $time;
private $type;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->type = $this->getPlainJsonObject()->type;
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* Returns the type of event
*
* @return string
*/
public function getType() {
return $this->type;
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the EventStartLine Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnEventStartLineStructure extends BaseStructure {
private $time;
private $player;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < player who triggered the action
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Models\RecordCallback;
use ManiaControl\ManiaControl;
use ManiaControl\Utils\Formatter;
/**
* Structure Class for the Default Event Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnEventWayPointStructure extends BaseStructure {
private $time;
private $player;
private $racetime;
private $laptime;
private $stuntsscore;
private $checkpointinrace;
private $checkpointinlap;
private $isendrace;
private $isendlap;
private $blockid;
private $speed;
private $distance;
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->time = $this->getPlainJsonObject()->time;
$this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login);
$this->racetime = (int) $this->getPlainJsonObject()->racetime;
$this->laptime = (int) $this->getPlainJsonObject()->laptime;
$this->stuntsscore = $this->getPlainJsonObject()->stuntsscore;
$this->checkpointinrace = (int) $this->getPlainJsonObject()->checkpointinrace;
$this->checkpointinlap = (int) $this->getPlainJsonObject()->checkpointinlap;
$this->isendrace = $this->getPlainJsonObject()->isendrace;
$this->isendlap = $this->getPlainJsonObject()->isendlap;
$this->blockid = $this->getPlainJsonObject()->blockid;
$this->speed = $this->getPlainJsonObject()->speed;
$this->distance = $this->getPlainJsonObject()->distance;
// Build callback
$wayPointCallback = new RecordCallback();
$wayPointCallback->rawCallback = $data;
$wayPointCallback->setPlayer($this->player);
$wayPointCallback->blockId = $this->blockid;
$wayPointCallback->time = $this->racetime;
$wayPointCallback->checkpoint = $this->checkpointinrace;
$wayPointCallback->isEndRace = Formatter::parseBoolean($this->isendrace);
$wayPointCallback->lapTime = $this->laptime;
$wayPointCallback->lapCheckpoint = $this->checkpointinlap;
$wayPointCallback->lap = 0;
$wayPointCallback->isEndLap = Formatter::parseBoolean($this->isendlap);
if ($wayPointCallback->checkpoint > 0) {
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$wayPointCallback->lap += $wayPointCallback->checkpoint / $currentMap->nbCheckpoints;
}
if ($wayPointCallback->isEndRace) {
$wayPointCallback->name = $wayPointCallback::FINISH;
} else if ($wayPointCallback->isEndLap) {
$wayPointCallback->name = $wayPointCallback::LAPFINISH;
} else {
$wayPointCallback->name = $wayPointCallback::CHECKPOINT;
}
$this->maniaControl->getCallbackManager()->triggerCallback($wayPointCallback);
}
/**
* Returns Server time when the event occured
*
* @return int
*/
public function getTime() {
return $this->time;
}
/**
* < player who triggered the action
*
* @return \ManiaControl\Players\Player
*/
public function getPlayer() {
return $this->player;
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
use ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore;
use ManiaControl\Callbacks\Structures\TrackMania\Models\TeamScore;
use ManiaControl\ManiaControl;
/**
* Structure Class for the Trackmania OnScores Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class OnScoresStructure extends CommonScoresStructure {
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$jsonObj = $this->getPlainJsonObject();
foreach ($jsonObj->players as $jsonPlayer) {
$playerScore = new PlayerScore();
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
$playerScore->setRank($jsonPlayer->rank);
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
$playerScore->setMapPoints($jsonPlayer->mappoints);
$playerScore->setBestRaceTime($jsonPlayer->bestracetime);
$playerScore->setBestLapTime($jsonPlayer->bestlaptime);
$playerScore->setStuntScore($jsonPlayer->stuntscore);
$this->playerScores[$jsonPlayer->login] = $playerScore;
}
}
}

View File

@ -0,0 +1,52 @@
<?php
namespace ManiaControl\Callbacks\Structures\XmlRpc;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/**
* Structure Class for the List Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CallbacksListStructure extends BaseStructure {
/** @var string $responseId */
private $responseId;
/** @var array $callbacks */
private $callbacks;
/**
* Construct a new Callbacks List Structure
*
* @param ManiaControl $maniaControl
* @param array $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
$this->responseId = $this->getPlainJsonObject()->responseid;
$this->callbacks = $this->getPlainJsonObject()->callbacks;
}
/**
* Get the Response Id //TODO Trait for all Response Ids
*
* @return string
*/
public function getResponseId() {
return $this->responseId;
}
/**
* Get Array of the Callbacks
*
* @return string[]
*/
public function getCallbacks() {
return $this->callbacks;
}
}

View File

@ -2,6 +2,9 @@
namespace ManiaControl\Callbacks;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
/**
* Model Class for a Timer Listening
*
@ -9,12 +12,14 @@ namespace ManiaControl\Callbacks;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class TimerListening extends Listening {
class TimerListening extends Listening implements UsageInformationAble {
use UsageInformationTrait;
/*
* Public Properties
*/
public $deltaTime = null;
public $oneTime = null;
public $deltaTime = null;
public $oneTime = null;
public $lastTrigger = null;
public $instantCall = null;
@ -31,11 +36,11 @@ class TimerListening extends Listening {
parent::__construct($listener, $method);
$this->deltaTime = $milliSeconds / 1000.;
$this->oneTime = (bool)$oneTime;
$this->oneTime = (bool) $oneTime;
if ($this->oneTime) {
$this->lastTrigger = time(true);
$this->lastTrigger = microtime(true); //TODO verify before here was time()
}
$this->instantCall = (bool)$instantCall;
$this->instantCall = (bool) $instantCall;
if (!$this->instantCall) {
$this->lastTrigger = microtime(true);
}

View File

@ -2,6 +2,8 @@
namespace ManiaControl\Callbacks;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
@ -11,7 +13,9 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class TimerManager {
class TimerManager implements UsageInformationAble {
use UsageInformationTrait;
/*
* Private properties
*/

View File

@ -3,6 +3,11 @@
namespace ManiaControl\Callbacks;
use ManiaControl\Callbacks\Models\RecordCallback;
use ManiaControl\Callbacks\Structures\TrackMania\OnDefaultEventStructure;
use ManiaControl\Callbacks\Structures\TrackMania\OnEventStartLineStructure;
use ManiaControl\Callbacks\Structures\TrackMania\OnCommandStructure;
use ManiaControl\Callbacks\Structures\TrackMania\OnScoresStructure;
use ManiaControl\Callbacks\Structures\TrackMania\OnEventWayPointStructure;
use ManiaControl\ManiaControl;
use ManiaControl\Utils\Formatter;
@ -20,6 +25,7 @@ class TrackManiaCallbacks implements CallbackListener {
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
/**
* Create a new TrackMania Callbacks Instance
*
@ -29,12 +35,61 @@ class TrackManiaCallbacks implements CallbackListener {
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
$this->maniaControl = $maniaControl;
// Register for callbacks
$callbackManager->registerCallbackListener(Callbacks::ONWAYPOINT, $this, 'handleOnWayPointCallback');
$callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpointCallback');
$callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinishCallback');
// Register for script callbacks
$callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks');
}
/**
* Handle Script Callbacks
*
* @param string $name
* @param mixed $data
*/
public function handleScriptCallbacks($name, $data) {
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
//return; //Leave that disabled while testing/implementing Callbacks
}
switch ($name) {
//MP4 New Callbacks
case Callbacks::TM_SCORES:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_SCORES, new OnScoresStructure($this->maniaControl, $data));
break;
case Callbacks::TM_ONEVENTDEFAULT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data));
break;
case Callbacks::TM_ONEVENTSTARTLINE:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONEVENTSTARTLINE, new OnEventStartLineStructure($this->maniaControl, $data));
break;
case Callbacks::TM_ONCOMMAND:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONCOMMAND, new OnCommandStructure($this->maniaControl, $data));
break;
case Callbacks::TM_ONPLAYERADDED:
break;
case Callbacks::TM_ONPLAYERREMOVED:
break;
case Callbacks::TM_ONWAYPOINT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONWAYPOINT, new OnEventWayPointStructure($this->maniaControl, $data));
break;
case Callbacks:: TM_ONGIVEUP:
break;
case Callbacks::TM_ONRESPAWN:
break;
case Callbacks::TM_ONSTUNT:
break;
case Callbacks::TM_ONSTARTCOUNTDOWN:
break;
case Callbacks::TM_WARMUPSTART:
break;
case Callbacks::TM_WARMUPSTARTROUND:
break;
case Callbacks::TM_WARMUPENDROUND:
break;
case Callbacks::TM_WARMUPEND:
break;
}
}
/**
* Handle OnWayPoint Callback
*
@ -52,16 +107,16 @@ class TrackManiaCallbacks implements CallbackListener {
$wayPointCallback->rawCallback = $callback;
$wayPointCallback->setPlayer($player);
$wayPointCallback->blockId = $callback[1];
$wayPointCallback->time = (int)$callback[2];
$wayPointCallback->checkpoint = (int)$callback[3];
$wayPointCallback->time = (int) $callback[2];
$wayPointCallback->checkpoint = (int) $callback[3];
$wayPointCallback->isEndRace = Formatter::parseBoolean($callback[4]);
$wayPointCallback->lapTime = (int)$callback[5];
$wayPointCallback->lapCheckpoint = (int)$callback[6];
$wayPointCallback->lapTime = (int) $callback[5];
$wayPointCallback->lapCheckpoint = (int) $callback[6];
$wayPointCallback->lap = 0;
$wayPointCallback->isEndLap = Formatter::parseBoolean($callback[7]);
if ($wayPointCallback->checkpoint > 0) {
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$wayPointCallback->lap += $wayPointCallback->checkpoint / $currentMap->nbCheckpoints;
}
@ -94,13 +149,13 @@ class TrackManiaCallbacks implements CallbackListener {
$checkpointCallback->isLegacyCallback = true;
$checkpointCallback->rawCallback = $callback;
$checkpointCallback->setPlayer($player);
$checkpointCallback->time = (int)$data[2];
$checkpointCallback->lap = (int)$data[3];
$checkpointCallback->checkpoint = (int)$data[4];
$checkpointCallback->time = (int) $data[2];
$checkpointCallback->lap = (int) $data[3];
$checkpointCallback->checkpoint = (int) $data[4];
$checkpointCallback->lapCheckpoint = $checkpointCallback->checkpoint;
if ($checkpointCallback->lap > 0) {
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
$checkpointCallback->lapCheckpoint -= $checkpointCallback->lap * $currentMap->nbCheckpoints;
}
@ -132,7 +187,7 @@ class TrackManiaCallbacks implements CallbackListener {
$finishCallback->isLegacyCallback = true;
$finishCallback->rawCallback = $callback;
$finishCallback->setPlayer($player);
$finishCallback->time = (int)$data[2];
$finishCallback->time = (int) $data[2];
$this->maniaControl->getCallbackManager()->triggerCallback($finishCallback);
}

View File

@ -8,6 +8,8 @@ use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Communication\CommunicationAnswer;
use ManiaControl\Communication\CommunicationListener;
use ManiaControl\Communication\CommunicationMethods;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
@ -18,7 +20,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Chat implements CallbackListener, CommunicationListener {
class Chat implements CallbackListener, CommunicationListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/

View File

@ -5,6 +5,8 @@ namespace ManiaControl\Commands;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Callbacks\Listening;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
@ -14,7 +16,9 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CommandManager implements CallbackListener {
class CommandManager implements CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Private properties
*/
@ -215,6 +219,6 @@ class CommandManager implements CallbackListener {
* @return bool
*/
private function isCommandMessage(array $chatCallback) {
return (bool)$chatCallback[1][3];
return (bool) $chatCallback[1][3];
}
}

View File

@ -156,7 +156,7 @@ class HelpManager implements CommandListener, CallbackListener {
// Main frame
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
$maniaLink->addChild($frame);
// Start offsets
$posX = -$width / 2;
@ -164,11 +164,11 @@ class HelpManager implements CommandListener, CallbackListener {
//Predefine description Label
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
$frame->add($descriptionLabel);
$frame->addChild($descriptionLabel);
// Headline
$headFrame = new Frame();
$frame->add($headFrame);
$frame->addChild($headFrame);
$headFrame->setY($posY - 5);
$array = array('Command' => $posX + 5, 'Description' => $posX + 50);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
@ -180,18 +180,18 @@ class HelpManager implements CommandListener, CallbackListener {
foreach ($commands as $command) {
if ($index % 15 === 1) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$frame->addChild($pageFrame);
$posY = $height / 2 - 10;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame); //TODO @Jocy
}
$playerFrame = new Frame();
$pageFrame->add($playerFrame);
$pageFrame->addChild($playerFrame);
$playerFrame->setY($posY);
if ($index % 2 !== 0) {
$lineQuad = new Quad_BgsPlayerCard();
$playerFrame->add($lineQuad);
$playerFrame->addChild($lineQuad);
$lineQuad->setSize($width, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ(0.001);

View File

@ -4,7 +4,7 @@ namespace ManiaControl\Communication;
/**
* Class for Communicating with other ManiaControls
* to call @see ManiaControl\Communication\CommunicationManager\createCommunication
* to call @see \ManiaControl\Communication\CommunicationManager::createCommunication()
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team

View File

@ -1,9 +1,12 @@
<?php
namespace ManiaControl\Communication;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Callbacks\Listening;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Settings\Setting;
@ -21,7 +24,9 @@ use React\Socket\Server;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CommunicationManager implements CallbackListener {
class CommunicationManager implements CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/** Constants */
const SETTING_SOCKET_ENABLED = "Activate Socket";
const SETTING_SOCKET_PASSWORD = "Password for the Socket Connection";
@ -249,7 +254,7 @@ class CommunicationManager implements CallbackListener {
$buffer = '';
$connection->on('data', function ($data) use (&$buffer, &$connection, $password) {
$buffer .= $data;
$arr = explode("\n", $buffer, 2);
$arr = explode("\n", $buffer, 2);
while (count($arr) == 2 && strlen($arr[1]) >= (int) $arr[0]) {
// received full message
$len = (int) $arr[0];

View File

@ -13,9 +13,11 @@ If you need methods which are not implemented, or additional Parameters, feel fr
Sample ManiaControl Implementation (for ManiaControl to ManiaControl connections)
##php code begin
//This Sample shows just the Implementation of the Method GET_SERVER_CHAT
$communication = $this->maniaControl->getCommunicationManager()->createCommunication(IP/Domain, PORT, 'YOUR_PASSWORD');
$communication->call(function($data){
var_dump($data);
//$data includes the data sent by the Website / other Controller
return new CommunicationAnswer($this->chatBuffer);
}, CommunicationMethods::GET_SERVER_CHAT);
##php code end

View File

@ -134,8 +134,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
* @param Player $player
*/
public function handleConfigCommand(array $callback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_OPEN_CONFIGURATOR)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_OPEN_CONFIGURATOR)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -198,24 +197,25 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
$manialink = new ManiaLink(ManialinkManager::MAIN_MLID);
$frame = new Frame();
$manialink->add($frame);
$frame->setPosition($menuPosX, $menuPosY, 34);
$manialink->addChild($frame);
$frame->setPosition($menuPosX, $menuPosY, ManialinkManager::MAIN_MANIALINK_Z_VALUE);
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setZ(-2)->setSize($menuWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle);
$frame->addChild($backgroundQuad);
$backgroundQuad->setZ(-1)->setSize($menuWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle);
$menuItemsFrame = new Frame();
$frame->add($menuItemsFrame);
$frame->addChild($menuItemsFrame);
$menuItemsFrame->setX($menuWidth * -0.5 + $menuListWidth * 0.5);
$menuItemsFrame->setZ(-1);
$itemsBackgroundQuad = new Quad();
$menuItemsFrame->add($itemsBackgroundQuad);
$menuItemsFrame->addChild($itemsBackgroundQuad);
$backgroundQuad->setZ(-1);
$itemsBackgroundQuad->setSize($menuListWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle);
$menusFrame = new Frame();
$frame->add($menusFrame);
$frame->addChild($menusFrame);
$menusFrame->setX($menuWidth * -0.5 + $menuListWidth + $subMenuWidth * 0.5);
// Create script and features
@ -226,14 +226,15 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
foreach ($this->menus as $menu) {
// Add title
$menuItemLabel = new Label_Text();
$menuItemsFrame->add($menuItemLabel);
$menuItemLabel->setY($menuItemY)->setSize($menuListWidth * 0.9, $menuItemHeight * 0.9)->setStyle($menuItemLabel::STYLE_TextCardRaceRank)->setText($menu->getTitle())->setAction(self::ACTION_SELECTMENU . $menuId);
$frame->addChild($menuItemLabel);
$menuItemLabel->setX($menuWidth * -0.5 + $menuListWidth * 0.5);
$menuItemLabel->setZ(2)->setStyle(Label_Text::STYLE_TextCardRaceRank)->setY($menuItemY)->setSize($menuListWidth * 0.9, $menuItemHeight * 0.9)->setText($menu->getTitle())->setAction(self::ACTION_SELECTMENU . $menuId);
// Show the menu
if ($menuId === $menuIdShown) {
$menuControl = $menu->getMenu($subMenuWidth, $subMenuHeight, $script, $player);
if ($menuControl) {
$menusFrame->add($menuControl);
$menusFrame->addChild($menuControl);
} else {
$this->maniaControl->getChat()->sendError('Error loading Menu!', $player);
}
@ -245,18 +246,18 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
// Add Close Quad (X)
$closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad);
$frame->addChild($closeQuad);
$closeQuad->setPosition($menuWidth * 0.483, $menuHeight * 0.467, 3)->setSize(6, 6)->setSubStyle($closeQuad::SUBSTYLE_QuitRace)->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
// Add close button
$closeButton = new Label_Text();
$frame->add($closeButton);
$closeButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.29, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($closeButton::STYLE_TextButtonNavBack)->setTextPrefix('$999')->setTranslate(true)->setText('Close')->setAction(self::ACTION_TOGGLEMENU);
$frame->addChild($closeButton);
$closeButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.29, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($closeButton::STYLE_TextButtonNavBack)->setTextPrefix('$999')->setText('Close')->setAction(self::ACTION_TOGGLEMENU);
// Add save button
$saveButton = new Label_Text();
$frame->add($saveButton);
$saveButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.71, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($saveButton::STYLE_TextButtonNavBack)->setTextPrefix('$0f5')->setTranslate(true)->setText('Save')->setAction(self::ACTION_SAVECONFIG);
$frame->addChild($saveButton);
$saveButton->setPosition($menuWidth * -0.5 + $menuListWidth * 0.71, $menuHeight * -0.43)->setSize($menuListWidth * 0.3, $menuListWidth * 0.1)->setStyle($saveButton::STYLE_TextButtonNavBack)->setTextPrefix('$2af')->setText('Save')->setAction(self::ACTION_SAVECONFIG);
return $manialink;
}

View File

@ -59,14 +59,14 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
*/
public static function getTitle() {
return self::TITLE;
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/
public function getMenu($width, $height, Script $script, Player $player) {
$openedClass = $player->getCache($this, self::CACHE_CLASS_OPENED);
@ -101,23 +101,23 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$frame->addChild($pagerPrev);
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
$pagerPrev->setSize($pagerSize, $pagerSize);
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
$pagerNext = new Quad_Icons64x64_1();
$frame->add($pagerNext);
$frame->addChild($pagerNext);
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
$paging->addButtonControl($pagerNext);
$paging->addButtonControl($pagerPrev);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT);
$frame->addChild($pageCountLabel);
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
$pageCountLabel->setPosition($width * 0.35, $height * -0.44);
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
$pageCountLabel->setTextSize(2);
@ -125,17 +125,17 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$paging->setLabel($pageCountLabel);
$backLabel = new Label_Button();
$frame->add($backLabel);
$frame->addChild($backLabel);
$backLabel->setStyle($backLabel::STYLE_CardMain_Quit);
$backLabel->setPosition(-$width / 2 + 7, -$height / 2 + 7);
$backLabel->setHAlign($backLabel::LEFT);
$backLabel->setHorizontalAlign($backLabel::LEFT);
$backLabel->setTextSize(2);
$backLabel->setText('Back');
$backLabel->setAction(self::ACTION_SETTINGCLASS_BACK);
$headLabel = new Label_Text();
$frame->add($headLabel);
$headLabel->setHAlign($headLabel::LEFT);
$frame->addChild($headLabel);
$headLabel->setHorizontalAlign($headLabel::LEFT);
$headLabel->setPosition($width * -0.46, $height * 0.41);
$headLabel->setSize($width * 0.6, $settingHeight);
$headLabel->setStyle($headLabel::STYLE_TextCardSmall);
@ -149,18 +149,18 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
foreach ($settings as $setting) {
if ($index % $pageMaxCount === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$frame->addChild($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height * 0.41 - $settingHeight * 1.5;
}
$settingFrame = new Frame();
$pageFrame->add($settingFrame);
$pageFrame->addChild($settingFrame);
$settingFrame->setY($posY);
$nameLabel = new Label_Text();
$settingFrame->add($nameLabel);
$nameLabel->setHAlign($nameLabel::LEFT);
$settingFrame->addChild($nameLabel);
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
$nameLabel->setX($width * -0.46);
$nameLabel->setSize($width * 0.6, $settingHeight);
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
@ -175,7 +175,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$quad->setPosition($width * 0.33, 0, -0.01);
$quad->setSize(4, 4);
$checkBox = new CheckBox($settingName, $setting->value, $quad);
$settingFrame->add($checkBox);
$settingFrame->addChild($checkBox);
} else if ($setting->type === Setting::TYPE_SET) {
// SET value picker
$label = new Label_Text();
@ -184,11 +184,11 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$label->setStyle($label::STYLE_TextValueSmall);
$label->setTextSize(1);
$valuePicker = new ValuePicker($settingName, $setting->set, $setting->value, $label);
$settingFrame->add($valuePicker);
$settingFrame->addChild($valuePicker);
} else {
// Standard entry
$entry = new Entry();
$settingFrame->add($entry);
$settingFrame->addChild($entry);
$entry->setX($width * 0.33);
$entry->setSize($width * 0.3, $settingHeight * 0.9);
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
@ -228,23 +228,23 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$frame->addChild($pagerPrev);
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
$pagerPrev->setSize($pagerSize, $pagerSize);
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
$pagerNext = new Quad_Icons64x64_1();
$frame->add($pagerNext);
$frame->addChild($pagerNext);
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
$paging->addButtonControl($pagerNext);
$paging->addButtonControl($pagerPrev);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT);
$frame->addChild($pageCountLabel);
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
$pageCountLabel->setTextSize(2);
@ -256,9 +256,9 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
foreach ($settingClasses as $settingClass) {
if ($index % $pageMaxCount === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$frame->addChild($pageFrame);
$posY = $height * 0.41;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
}
$classLabel = new Label_Text();
@ -270,8 +270,8 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
}
$className = substr($className, 0, -3);
$pageFrame->add($classLabel);
$classLabel->setHAlign($classLabel::LEFT);
$pageFrame->addChild($classLabel);
$classLabel->setHorizontalAlign($classLabel::LEFT);
$classLabel->setPosition($width * -0.45, $posY);
$classLabel->setSize($width * 0.9, $settingHeight * 0.9);
$classLabel->setStyle($classLabel::STYLE_TextCardSmall);

View File

@ -191,7 +191,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
$scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo();
} catch (GameModeException $e) {
$label = new Label();
$frame->add($label);
$frame->addChild($label);
$label->setText($e->getMessage());
return $frame;
}
@ -210,23 +210,23 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$frame->addChild($pagerPrev);
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
$pagerPrev->setSize($pagerSize, $pagerSize);
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
$pagerNext = new Quad_Icons64x64_1();
$frame->add($pagerNext);
$frame->addChild($pagerNext);
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
$paging->addButtonControl($pagerNext);
$paging->addButtonControl($pagerPrev);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT);
$frame->addChild($pageCountLabel);
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
$pageCountLabel->setTextSize(2);
@ -247,18 +247,18 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
if ($index % 13 === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$frame->addChild($pageFrame);
$posY = $height * 0.41;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
}
$settingFrame = new Frame();
$pageFrame->add($settingFrame);
$pageFrame->addChild($settingFrame);
$settingFrame->setY($posY);
$nameLabel = new Label_Text();
$settingFrame->add($nameLabel);
$nameLabel->setHAlign($nameLabel::LEFT);
$settingFrame->addChild($nameLabel);
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
$nameLabel->setX($width * -0.46);
$nameLabel->setSize($width * 0.4, $settingHeight);
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
@ -273,11 +273,11 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
$quad->setX($width / 2 * 0.545);
$quad->setSize(4, 4);
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $settingName, $settingValue, $quad);
$settingFrame->add($checkBox);
$settingFrame->addChild($checkBox);
} else {
// Value entry
$entry = new Entry();
$settingFrame->add($entry);
$settingFrame->addChild($entry);
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
$entry->setX($width / 2 * 0.55);
$entry->setTextSize(1);
@ -287,14 +287,13 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
}
$descriptionLabel = new Label();
$pageFrame->add($descriptionLabel);
$descriptionLabel->setHAlign($descriptionLabel::LEFT);
$pageFrame->addChild($descriptionLabel);
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
$descriptionLabel->setPosition($width * -0.45, $height * -0.44);
$descriptionLabel->setSize($width * 0.7, $settingHeight);
$descriptionLabel->setTextSize($labelTextSize);
$descriptionLabel->setTranslate(true);
$descriptionLabel->setText($scriptParam->desc);
$nameLabel->addTooltipFeature($descriptionLabel);
$nameLabel->addTooltipLabelFeature($descriptionLabel, $scriptParam->desc);
$posY -= $settingHeight;
}

View File

@ -27,7 +27,7 @@ class ErrorHandler {
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
private $maniaControl = null;
private $handlingError = null;
/**
@ -144,6 +144,8 @@ class ErrorHandler {
$report['ManiaControlVersion'] = ManiaControl::VERSION;
}
$report['DedicatedBuildVersion'] = $this->maniaControl->getDedicatedServerBuildVersion();
$json = json_encode(Formatter::utf8($report));
$info = base64_encode($json);
@ -235,7 +237,7 @@ class ErrorHandler {
$traceString = '';
$stepCount = 0;
foreach ($backtrace as $traceStep) {
$skipStep = $this->shouldSkipTraceStep($traceStep);
$skipStep = $this->shouldSkipTraceStep($traceStep);
$traceString .= '#' . $stepCount . ': ';
if (isset($traceStep['class'])) {
if (!$sourceClass && !$skipStep && !$this->isIgnoredSourceClass($traceStep['class'])) {
@ -329,7 +331,7 @@ class ErrorHandler {
} else if (is_array($arg)) {
$string .= 'array(' . $this->parseArgumentsArray($arg) . ')';
} else {
$type = gettype($arg);
$type = gettype($arg);
$string .= $type . '(';
if (is_string($arg)) {
$param = $arg;
@ -438,6 +440,8 @@ class ErrorHandler {
$report['ManiaControlVersion'] = ManiaControl::VERSION;
}
$report['DedicatedBuildVersion'] = $this->maniaControl->getDedicatedServerBuildVersion();
$errorReport = json_encode(Formatter::utf8($report));
$url = ManiaControl::URL_WEBSERVICE . 'errorreport';

View File

@ -4,6 +4,8 @@ namespace ManiaControl\Files;
use cURL\Event;
use cURL\Request;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
@ -13,11 +15,13 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class AsyncHttpRequest {
class AsyncHttpRequest implements UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
const CONTENT_TYPE_JSON = 'application/json';
const CONTENT_TYPE_UTF8 = 'UTF-8';
/*
* Private properties
@ -183,7 +187,7 @@ class AsyncHttpRequest {
* @return $this
*/
public function setHeaders($headers) {
if(is_array($headers)){
if (is_array($headers)) {
$this->headers = $headers;
}
return $this;

View File

@ -3,6 +3,8 @@
namespace ManiaControl\Files;
use cURL\Request;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
@ -12,7 +14,9 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class AsynchronousFileReader {
class AsynchronousFileReader implements UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/

View File

@ -0,0 +1,17 @@
<?php
namespace ManiaControl\General;
/**
* Class DumpTrait Trait for Implementing the Methods for the dumpable Interface
*
* @package ManiaControl\General
*/
trait DumpTrait {
/**
* Var_Dump Public Properties of the Object
*/
public function dump() {
var_dump(json_decode(json_encode($this)));
}
}

12
core/General/Dumpable.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace ManiaControl\General;
/**
* Object implementing this Interface has a dump() Method
*
* @package ManiaControl\General
*/
interface Dumpable {
public function dump();
}

View File

@ -0,0 +1,12 @@
<?php
namespace ManiaControl\General;
/**
* Object implementing this Interface has a dump() Method
*
* @package ManiaControl\General
*/
interface UsageInformationAble {
public function getUsageInformation();
}

View File

@ -0,0 +1,41 @@
<?php
namespace ManiaControl\General;
use ReflectionClass;
/**
* Class DumpTrait Trait for Implementing the Methods for the UsageInformationAble Interface
*
* @package ManiaControl\General
*/
trait UsageInformationTrait {
/**
* Gets Information about the Class, and a List of the Public Method
*/
public function getUsageInformation() {
$reflection = new ReflectionClass(get_class($this));
echo $reflection->getDocComment();
echo "\nStructure Name of Class = " . get_class($this);
echo "\n\nMethods:";
$methods = array_reverse($reflection->getMethods());
foreach ($methods as $key => $value) {
/** @var \ReflectionMethod $value */
//Don't print the Constructor
if ($value->isPublic() && $value->getName() != "__construct" && $value->getName() != "getUsage") {
echo "\n";
echo preg_replace('/\t/', '', $value->getDocComment());
echo "\n \$result = " . $value->getName() . "(); \n";
$parameters = $value->getParameters();
foreach ($parameters as $parameter) {
echo $parameter . "\n";
}
}
}
echo "\n";
//TODO add public Constands and Properties
}
}

View File

@ -3,6 +3,8 @@
namespace ManiaControl;
use ManiaControl\Files\FileUtil;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Utils\Formatter;
/**
@ -12,7 +14,8 @@ use ManiaControl\Utils\Formatter;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class Logger {
abstract class Logger implements UsageInformationAble {
use UsageInformationTrait;
/**
* Setup the logging mechanism

View File

@ -21,11 +21,14 @@ use ManiaControl\Configurator\Configurator;
use ManiaControl\Database\Database;
use ManiaControl\Files\AsynchronousFileReader;
use ManiaControl\Files\FileUtil;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Maps\MapManager;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\PluginManager;
use ManiaControl\Script\ModeScriptEventManager;
use ManiaControl\Server\Server;
use ManiaControl\Settings\SettingManager;
use ManiaControl\Statistics\StatisticManager;
@ -43,13 +46,15 @@ use Maniaplanet\DedicatedServer\Xmlrpc\TransportException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ManiaControl implements CallbackListener, CommandListener, TimerListener, CommunicationListener {
class ManiaControl implements CallbackListener, CommandListener, TimerListener, CommunicationListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
const VERSION = '0.166';
const VERSION = '0.201';
const API_VERSION = '2013-04-16';
const MIN_DEDIVERSION = '2014-04-02_18_00';
const MIN_DEDIVERSION = '2017-03-23_18_00';
const SCRIPT_TIMEOUT = 10;
const URL_WEBSERVICE = 'https://ws.maniacontrol.com/';
const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl';
@ -170,9 +175,16 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
private $requestQuitMessage = null;
/** @var EchoManager $echoManager */
private $echoManager = null;
private $echoManager = null;
/** @var CommunicationManager $communicationManager */
private $communicationManager = null;
/** @var ModeScriptEventManager $modeScriptEventManager */
private $modeScriptEventManager = null;
private $dedicatedServerBuildVersion = "";
/**
* Construct a new ManiaControl instance
*/
@ -184,27 +196,27 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
$this->loadConfig();
// Load ManiaControl Modules
$this->callbackManager = new CallbackManager($this);
$this->echoManager = new EchoManager($this);
$this->communicationManager = new CommunicationManager($this);
$this->timerManager = new TimerManager($this);
$this->database = new Database($this);
$this->fileReader = new AsynchronousFileReader($this);
$this->billManager = new BillManager($this);
$this->settingManager = new SettingManager($this);
$this->statisticManager = new StatisticManager($this);
$this->manialinkManager = new ManialinkManager($this);
$this->actionsMenu = new ActionsMenu($this);
$this->chat = new Chat($this);
$this->commandManager = new CommandManager($this);
$this->server = new Server($this);
$this->authenticationManager = new AuthenticationManager($this);
$this->playerManager = new PlayerManager($this);
$this->mapManager = new MapManager($this);
$this->configurator = new Configurator($this);
$this->pluginManager = new PluginManager($this);
$this->updateManager = new UpdateManager($this);
$this->callbackManager = new CallbackManager($this);
$this->modeScriptEventManager = new ModeScriptEventManager($this);
$this->echoManager = new EchoManager($this);
$this->communicationManager = new CommunicationManager($this);
$this->timerManager = new TimerManager($this);
$this->database = new Database($this);
$this->fileReader = new AsynchronousFileReader($this);
$this->billManager = new BillManager($this);
$this->settingManager = new SettingManager($this);
$this->statisticManager = new StatisticManager($this);
$this->manialinkManager = new ManialinkManager($this);
$this->actionsMenu = new ActionsMenu($this);
$this->chat = new Chat($this);
$this->commandManager = new CommandManager($this);
$this->server = new Server($this);
$this->authenticationManager = new AuthenticationManager($this);
$this->playerManager = new PlayerManager($this);
$this->mapManager = new MapManager($this);
$this->configurator = new Configurator($this);
$this->pluginManager = new PluginManager($this);
$this->updateManager = new UpdateManager($this);
$this->getErrorHandler()->init();
@ -467,6 +479,13 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
return $this->billManager;
}
/**
* @return ModeScriptEventManager
*/
public function getModeScriptEventManager() {
return $this->modeScriptEventManager;
}
/**
* Check connection
*/
@ -547,6 +566,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
$this->requestQuitMessage = $message;
}
/**
* Run ManiaControl
*/
@ -558,9 +578,10 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
$this->connect();
// Check if the version of the server is high enough
$version = $this->getClient()->getVersion();
if ($version->build < self::MIN_DEDIVERSION) {
$this->quit("The Server has Version '{$version->build}', while at least '" . self::MIN_DEDIVERSION . "' is required!", true);
$version = $this->getClient()->getVersion();
$this->dedicatedServerBuildVersion = $version->build;
if ($this->dedicatedServerBuildVersion < self::MIN_DEDIVERSION) {
$this->quit("The Server has Version '{$this->dedicatedServerBuildVersion}', while at least '" . self::MIN_DEDIVERSION . "' is required!", true);
}
// Listen for shutdown
@ -633,6 +654,16 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
$this->getServer()->getScriptManager()->enableScriptCallbacks();
}
/**
* Get The Build Version of the Dedicated Server
*
* @return string
*/
public function getDedicatedServerBuildVersion() {
return $this->dedicatedServerBuildVersion;
}
/**
* Return the server
*
@ -699,4 +730,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
public function handleServerStopCallback() {
$this->requestQuit('The Server has been shut down!');
}
}

View File

@ -2,6 +2,7 @@
namespace ManiaControl\ManiaExchange;
use FML\Components\CheckBox;
use FML\Controls\Entry;
use FML\Controls\Frame;
use FML\Controls\Gauge;
@ -17,6 +18,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\IconManager;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Maps\MapCommands;
@ -40,7 +42,9 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
const ACTION_SEARCH_MAPNAME = 'ManiaExchangeList.SearchMapName';
const ACTION_SEARCH_AUTHOR = 'ManiaExchangeList.SearchAuthor';
const ACTION_GET_MAPS_FROM_AUTHOR = 'ManiaExchangeList.GetMapsFromAuthor';
const ACTION_TOGGLE_MP4 = 'ManiaExchangeList.ToggleMp4';
const MAX_MX_MAPS_PER_PAGE = 14;
const CACHE_SHOWMP4ONLY = 'ManiaExchangeList.Mp4Only';
/*
* Private properties
@ -62,8 +66,9 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showList');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showList');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showListCommand');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showListCommand');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_TOGGLE_MP4, $this, 'toggleMP4MapsOnly');
}
/**
@ -83,10 +88,11 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
$mapId = (int) $actionArray[2];
switch ($action) {
case self::ACTION_GET_MAPS_FROM_AUTHOR:
$callback[1][2] = 'auth:' . $actionArray[2];
$this->showList($callback, $player);
$this->showListCommand($callback, $player);
break;
case self::ACTION_ADD_MAP:
$this->maniaControl->getMapManager()->addMapFromMx($mapId, $player->login);
@ -100,7 +106,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
* @param array $chatCallback
* @param Player $player
*/
public function showList(array $chatCallback, Player $player) {
public function showListCommand(array $chatCallback, Player $player) {
$this->mapListShown[$player->login] = true;
$params = explode(' ', $chatCallback[1][2]);
$searchString = '';
@ -130,11 +136,26 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
}
}
$this->getMXMapsAndShowList($player, $author, $environment, $searchString);
}
/**
* Gets MX Maps and displays maplist
*
* @param \ManiaControl\Players\Player $player
* @param string $author
* @param string $environment
* @param string $searchString
*/
private function getMXMapsAndShowList(Player $player, $author = '', $environment = '', $searchString = '') {
//Search the Maps
$mxSearch = new ManiaExchangeMapSearch($this->maniaControl);
$mxSearch->setAuthorName($author);
$mxSearch->setEnvironments($environment);
$mxSearch->setMapName($searchString);
if ($player->getCache($this, self::CACHE_SHOWMP4ONLY)) {
$mxSearch->setMapGroup(2);
}
$mxSearch->fetchMapsAsync(function (array $maps) use (&$player) {
if (!$maps) {
$this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login);
@ -144,6 +165,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
});
}
/**
* Display the Mania Exchange List
*
@ -166,19 +188,31 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
// Main frame
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
$maniaLink->addChild($frame);
//Predefine description Label
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
$frame->add($descriptionLabel);
$frame->addChild($descriptionLabel);
// Headline
$headFrame = new Frame();
$frame->add($headFrame);
$frame->addChild($headFrame);
$headFrame->setY($posY - 12);
$array = array('$oId' => $posX + 3.5, '$oName' => $posX + 12.5, '$oAuthor' => $posX + 59, '$oKarma' => $posX + 85, '$oType' => $posX + 103, '$oMood' => $posX + 118, '$oLast Update' => $posX + 130);
$array = array('$oId' => $posX + 3.5, '$oName' => $posX + 12.5, '$oAuthor' => $posX + 59, '$oKarma' => $posX + 85, '$oType' => $posX + 103, '$oMood' => $posX + 118,
'$oLast Update' => $posX + 130);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
$labelLine = new LabelLine($headFrame);
$labelLine->addLabelEntryText('Id', $posX + 3.5, 9);
$labelLine->addLabelEntryText('Name', $posX + 12.5, 38.5);
$labelLine->addLabelEntryText('Author', $posX + 59, 44);
$labelLine->addLabelEntryText('Type', $posX + 103, 15);
$labelLine->addLabelEntryText('Mood', $posX + 118, 12);
$labelLine->addLabelEntryText('Last Update', $posX + 130, $width - ($posX + 130));
$labelLine->setPrefix('$o');
$labelLine->render();
$index = 0;
$posY = $height / 2 - 16;
$pageFrame = null;
@ -187,46 +221,52 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
//TODO order possibilities
if ($index % self::MAX_MX_MAPS_PER_PAGE === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$frame->addChild($pageFrame);
$posY = $height / 2 - 16;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
}
// Map Frame
$mapFrame = new Frame();
$pageFrame->add($mapFrame);
$pageFrame->addChild($mapFrame);
if ($index % 2 === 0) {
$lineQuad = new Quad_BgsPlayerCard();
$mapFrame->add($lineQuad);
$mapFrame->addChild($lineQuad);
$lineQuad->setSize($width, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ(0.001);
}
$time = Formatter::timeElapsedString(strtotime($map->updated));
$array = array('$s' . $map->id => $posX + 3.5, '$s' . $map->name => $posX + 12.5, '$s' . $map->author => $posX + 59, '$s' . str_replace('Arena', '', $map->maptype) => $posX + 103, '$s' . $map->mood => $posX + 118, '$s' . $time => $posX + 130);
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array);
$authorLabel = $labels[2];
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
$time = Formatter::timeElapsedString(strtotime($map->updated));
$labelLine = new LabelLine($mapFrame);
$labelLine->addLabelEntryText($map->id, $posX + 3.5, 9);
$labelLine->addLabelEntryText($map->name, $posX + 12.5, 38.5);
$labelLine->addLabelEntryText($map->author, $posX + 59, 44, self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
$labelLine->addLabelEntryText(str_replace('Arena', '', $map->maptype), $posX + 103, 15);
$labelLine->addLabelEntryText($map->mood, $posX + 118, 12);
$labelLine->addLabelEntryText($time, $posX + 130, $width - ($posX + 130));
$labelLine->setPrefix('$s');
$labelLine->render();
$mapFrame->setY($posY);
$mxQuad = new Quad();
$mapFrame->add($mxQuad);
$mapFrame->addChild($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
$mxQuad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
$mxQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
$mxQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
$mxQuad->setX($posX + 56);
$mxQuad->setUrl($map->pageurl);
$mxQuad->setZ(0.01);
$description = 'View $<' . $map->name . '$> on Mania-Exchange';
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
$addQuad = new Quad_Icons64x64_1();
$mapFrame->add($addQuad);
$mapFrame->addChild($addQuad);
$addQuad->setX($posX + 53);
$addQuad->setZ(-0.1);
$addQuad->setSubStyle($addQuad::SUBSTYLE_Add);
@ -241,16 +281,16 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
//Award Quad
if ($map->awards > 0) {
$awardQuad = new Quad_Icons64x64_1();
$mapFrame->add($awardQuad);
$mapFrame->addChild($awardQuad);
$awardQuad->setSize(3, 3);
$awardQuad->setSubStyle($awardQuad::SUBSTYLE_OfficialRace);
$awardQuad->setX($posX + 97);
$awardQuad->setZ(0.01);
$awardLabel = new Label_Text();
$mapFrame->add($awardLabel);
$mapFrame->addChild($awardLabel);
$awardLabel->setX($posX + 98.5);
$awardLabel->setHAlign($awardLabel::LEFT);
$awardLabel->setHorizontalAlign($awardLabel::LEFT);
$awardLabel->setText($map->awards);
$awardLabel->setTextSize(1.3);
}
@ -260,18 +300,18 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$voteCount = $map->ratingVoteCount;
if (is_numeric($karma) && $voteCount > 0) {
$karmaGauge = new Gauge();
$mapFrame->add($karmaGauge);
$mapFrame->addChild($karmaGauge);
$karmaGauge->setZ(2);
$karmaGauge->setX($posX + 89);
$karmaGauge->setSize(16.5, 9);
$karmaGauge->setDrawBg(false);
$karmaGauge->setDrawBackground(false);
$karma = floatval($karma);
$karmaGauge->setRatio($karma + 0.15 - $karma * 0.15);
$karmaColor = ColorUtil::floatToStatusColor($karma);
$karmaGauge->setColor($karmaColor . '9');
$karmaLabel = new Label();
$mapFrame->add($karmaLabel);
$mapFrame->addChild($karmaLabel);
$karmaLabel->setZ(2);
$karmaLabel->setX($posX + 89);
$karmaLabel->setSize(16.5 * 0.9, 5);
@ -286,16 +326,16 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
}
$label = new Label_Text();
$frame->add($label);
$frame->addChild($label);
$label->setPosition(-$width / 2 + 5, $height / 2 - 5);
$label->setHAlign($label::LEFT);
$label->setHorizontalAlign($label::LEFT);
$label->setTextSize(1.3);
$label->setText('Search: ');
$entry = new Entry();
$frame->add($entry);
$frame->addChild($entry);
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
$entry->setHAlign($entry::LEFT);
$entry->setHorizontalAlign($entry::LEFT);
$entry->setPosition(-$width / 2 + 15, $height / 2 - 5);
$entry->setTextSize(1);
$entry->setSize($width * 0.25, 4);
@ -304,36 +344,68 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
//Search for Map-Name
$label = new Label_Button();
$frame->add($label);
$frame->addChild($label);
$label->setPosition(-$width / 2 + 63, $height / 2 - 5);
$label->setText('MapName');
$label->setTextSize(1.3);
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
$quad->setPosition(-$width / 2 + 63, $height / 2 - 5, 0.01);
$frame->addChild($quad);
$quad->setPosition(-$width / 2 + 63, $height / 2 - 5);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize(18, 5);
$quad->setAction(self::ACTION_SEARCH_MAPNAME);
$quad->setZ(-0.1);
//Search for Author
$label = new Label_Button();
$frame->add($label);
$frame->addChild($label);
$label->setPosition(-$width / 2 + 82, $height / 2 - 5);
$label->setText('Author');
$label->setTextSize(1.3);
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
$quad->setPosition(-$width / 2 + 82, $height / 2 - 5, 0.01);
$frame->addChild($quad);
$quad->setPosition(-$width / 2 + 82, $height / 2 - 5);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize(18, 5);
$quad->setAction(self::ACTION_SEARCH_AUTHOR);
$quad->setZ(-0.1);
//Seach for MP4Maps
$quad = new Quad();
$quad->setPosition($width / 2 - 30, $height / 2 - 5, -0.01)->setSize(4, 4);
$checkBox = new CheckBox(self::ACTION_TOGGLE_MP4, $player->getCache($this, self::CACHE_SHOWMP4ONLY), $quad);
$quad->setAction(self::ACTION_TOGGLE_MP4);
$frame->addChild($checkBox);
$label = new Label_Button();
$frame->addChild($label);
$label->setPosition($width / 2 - 28, $height / 2 - 5);
$label->setText('Only MP4-Maps');
$label->setTextSize(1.3);
$label->setHorizontalAlign($label::LEFT);
// render and display xml
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'ManiaExchangeList');
}
/**
* Toggle to view mp4 maps only for a player
*
* @param array $callback
* @param \ManiaControl\Players\Player $player
*/
public function toggleMP4MapsOnly(array $callback, Player $player) {
if ($player->getCache($this, self::CACHE_SHOWMP4ONLY) === true) {
$player->setCache($this, self::CACHE_SHOWMP4ONLY, false);
} else {
$player->setCache($this, self::CACHE_SHOWMP4ONLY, true);
}
$this->getMXMapsAndShowList($player);
}
/**
* Unset the player if he opened another Main Widget
*

View File

@ -2,7 +2,9 @@
namespace ManiaControl\ManiaExchange;
use ManiaControl\Files\AsynchronousFileReader;
use ManiaControl\Files\AsyncHttpRequest;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Maps\Map;
use ManiaControl\Maps\MapManager;
@ -14,7 +16,9 @@ use ManiaControl\Maps\MapManager;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ManiaExchangeManager {
class ManiaExchangeManager implements UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
* @deprecated SEARCH Constants
@ -166,7 +170,9 @@ class ManiaExchangeManager {
$url .= "&key=" . $key;
}
$this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use ($titlePrefix, $url) {
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $url);
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
$asyncHttpRequest->setCallable(function ($mapInfo, $error) use ($titlePrefix, $url) {
if ($error) {
trigger_error("Error: '{$error}' for Url '{$url}'");
return;
@ -192,7 +198,9 @@ class ManiaExchangeManager {
}
$this->updateMapObjectsWithManiaExchangeIds($maps);
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
});
$asyncHttpRequest->getData();
}
/**
@ -263,7 +271,9 @@ class ManiaExchangeManager {
$url .= "&key=" . $key;
}
$this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix, $url) {
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $url);
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
$asyncHttpRequest->setCallable(function ($mapInfo, $error) use (&$function, $titlePrefix, $url) {
$mxMapInfo = null;
if ($error) {
trigger_error($error);
@ -276,7 +286,9 @@ class ManiaExchangeManager {
}
}
call_user_func($function, $mxMapInfo);
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
});
$asyncHttpRequest->getData();
}
/**

View File

@ -1,7 +1,10 @@
<?php
namespace ManiaControl\ManiaExchange;
use ManiaControl\Files\AsynchronousFileReader;
use ManiaControl\Files\AsyncHttpRequest;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
@ -12,7 +15,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ManiaExchangeMapSearch {
class ManiaExchangeMapSearch implements UsageInformationAble {
use UsageInformationTrait;
//Search orders (prior parameter) https://api.mania-exchange.com/documents/enums#orderings
const SEARCH_ORDER_NONE = -1;
const SEARCH_ORDER_TRACK_NAME = 0;
@ -79,6 +84,7 @@ class ManiaExchangeMapSearch {
private $envMix = null;
private $ghostBlocks = null;
private $embeddedObjects = null;
private $key = null;
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
@ -99,7 +105,7 @@ class ManiaExchangeMapSearch {
$this->url = 'https://' . $this->titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on';
if($key = $this->maniaControl->getSettingManager()->getSettingValue($this, ManiaExchangeManager::SETTING_MX_KEY)){
if ($key = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getMapManager()->getMXManager(), ManiaExchangeManager::SETTING_MX_KEY)) {
$this->url .= "&key=" . $key;
}
@ -213,8 +219,13 @@ class ManiaExchangeMapSearch {
if (isset($this->embeddedObjects)) {
$parameters .= "&embeddedobjects=" . (int) $this->embeddedObjects;
}
if (isset($this->key)) {
$parameters .= "&key=" . $this->key;
}
$this->maniaControl->getFileReader()->loadFile($this->url . $parameters, function ($mapInfo, $error) use (&$function) {
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $this->url . $parameters);
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
$asyncHttpRequest->setCallable(function ($mapInfo, $error) use (&$function) {
if ($error) {
trigger_error($error);
return;
@ -228,7 +239,7 @@ class ManiaExchangeMapSearch {
}
$mxMapList = $mxMapList->results;
if ($mxMapList === null) {
trigger_error('Cannot decode searched JSON data');
return;
@ -242,7 +253,9 @@ class ManiaExchangeMapSearch {
}
call_user_func($function, $maps);
}, AsynchronousFileReader::CONTENT_TYPE_JSON);
});
$asyncHttpRequest->getData();
}
@ -439,4 +452,11 @@ class ManiaExchangeMapSearch {
public function setMapLimit($mapLimit) {
$this->mapLimit = $mapLimit;
}
/**
* @param null $key
*/
public function setKey($key) {
$this->key = $key;
}
}

View File

@ -5,6 +5,8 @@ namespace ManiaControl\Manialinks;
use FML\CustomUI;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\TimerListener;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
@ -16,7 +18,9 @@ use ManiaControl\Players\PlayerManager;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CustomUIManager implements CallbackListener, TimerListener {
class CustomUIManager implements CallbackListener, TimerListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/

View File

@ -7,6 +7,8 @@ use FML\Controls\Quad;
use FML\ManiaLink;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
@ -18,7 +20,9 @@ use ManiaControl\Players\PlayerManager;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class IconManager implements CallbackListener {
class IconManager implements CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -113,14 +117,14 @@ class IconManager implements CallbackListener {
public function preloadIcons($player = null) {
$maniaLink = new ManiaLink(self::PRELOAD_MLID);
$frame = new Frame();
$maniaLink->add($frame);
$maniaLink->addChild($frame);
$frame->setPosition(500, 500);
foreach ($this->icons as $iconUrl) {
$iconQuad = new Quad();
$iconQuad->setImage($iconUrl);
$iconQuad->setImageUrl($iconUrl);
$iconQuad->setSize(1, 1);
$frame->add($iconQuad);
$frame->addChild($iconQuad);
}
// Send manialink

View File

@ -0,0 +1,177 @@
<?php
namespace ManiaControl\Manialinks;
use FML\Controls\Frame;
use FML\Controls\Label;
use FML\Controls\Labels\Label_Text;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
/**
* Class providing easy labels in a line
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class LabelLine implements UsageInformationAble {
use UsageInformationTrait;
private $frame;
private $entries = array();
private $horizontalAlign = Label::LEFT;
private $style = Label_Text::STYLE_TextCardSmall;
private $textSize = 1.5;
private $textColor = 'FFF';
private $posZ = 0;
private $prefix = '';
public function __construct(Frame $frame) {
$this->frame = $frame;
}
/**
* Create a new text label
*
* @param $labelText
* @param $posX
* @param int $width
* @param string $action
*/
public function addLabelEntryText($labelText, $posX, $width = 0, $action = '') {
$label = new Label_Text();
$this->frame->addChild($label);
$label->setText($labelText);
$label->setX($posX);
if ($action) {
$label->setAction($action);
}
if ($width) {
$label->setWidth($width);
$label->setHeight(0); //TODO verify if 5 is ok for everywhere
}
$this->addLabel($label);
}
/**
* Adds a label to private attribute
*
* @param \FML\Controls\Labels\Label_Text $label
*/
private function addLabel(Label_Text $label) {
array_push($this->entries, $label);
}
/**
* Adds the labels to your frame
*/
public function render() {
/** @var Label $entry */
foreach ($this->entries as $entry) {
$entry->setHorizontalAlign($this->horizontalAlign);
$entry->setStyle($this->style);
$entry->setTextSize($this->textSize);
$entry->setTextColor($this->textColor);
$entry->setZ($this->posZ);
$entry->setTextPrefix($this->prefix);
$this->frame->addChild($entry);
}
}
/**
* @return string
*/
public function getHorizontalAlign() {
return $this->horizontalAlign;
}
/**
* @param string $horizontalAlign
*/
public function setHorizontalAlign($horizontalAlign) {
$this->horizontalAlign = $horizontalAlign;
}
/**
* @return string
*/
public function getStyle() {
return $this->style;
}
/**
* @param string $style
*/
public function setStyle($style) {
$this->style = $style;
}
/**
* @return float
*/
public function getTextSize() {
return $this->textSize;
}
/**
* @param float $textSize
*/
public function setTextSize($textSize) {
$this->textSize = $textSize;
}
/**
* @return string
*/
public function getTextColor() {
return $this->textColor;
}
/**
* @param string $textColor
*/
public function setTextColor($textColor) {
$this->textColor = $textColor;
}
/**
* @return int
*/
public function getPosZ() {
return $this->posZ;
}
/**
* @param int $posZ
*/
public function setPosZ($posZ) {
$this->posZ = $posZ;
}
/**
* @return \FML\Controls\Labels\Label_Text[]
*/
public function getEntries() {
return $this->entries;
}
/**
* @return string
*/
public function getPrefix() {
return $this->prefix;
}
/**
* @param string $prefix
*/
public function setPrefix($prefix) {
$this->prefix = $prefix;
}
}

View File

@ -8,6 +8,8 @@ use FML\Controls\Labels\Label_Text;
use FML\ManiaLink;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
@ -23,14 +25,17 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener {
class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
const MAIN_MLID = 'Main.ManiaLinkId';
const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget';
const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed';
const CB_MAIN_WINDOW_OPENED = 'ManialinkManagerCallback.MainWindowOpened';
const MAIN_MLID = 'Main.ManiaLinkId';
const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget';
const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed';
const CB_MAIN_WINDOW_OPENED = 'ManialinkManagerCallback.MainWindowOpened';
const MAIN_MANIALINK_Z_VALUE = 10;
/*
* Public properties
@ -364,6 +369,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
* @param array $labelStrings
* @param array $properties
* @return Label_Text[]
* @deprecated use \ManiaControl\Manialinks\LabelLine instead
* @see \ManiaControl\Manialinks\LabelLine
*/
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
// define standard properties
@ -371,9 +378,19 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
$style = (isset($properties['style']) ? $properties['style'] : Label_Text::STYLE_TextCardSmall);
$textSize = (isset($properties['textSize']) ? $properties['textSize'] : 1.5);
$textColor = (isset($properties['textColor']) ? $properties['textColor'] : 'FFF');
$profile = (isset($properties['profile']) ? $properties['profile'] : false);
$posZ = (isset($properties['posZ']) ? $properties['posZ'] : 0);
$labels = array();
$labelLine = new LabelLine($frame);
$labelLine->setHorizontalAlign($hAlign);
$labelLine->setStyle($style);
$labelLine->setTextSize($textSize);
$labelLine->setTextColor($textColor);
$labelLine->setPosZ($posZ);
/**
* @var Label_Text $prevLabel
*/
$prevLabel = null;
//If you call LabelLine with array(array(positions), array(texts))
if (count($labelStrings) == 2 && array_key_exists(0, $labelStrings) && array_key_exists(1, $labelStrings) && array_key_exists(0, $labelStrings[0]) && array_key_exists(0, $labelStrings[1])) {
@ -385,40 +402,15 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
}
foreach ($positions as $key => $x) {
$label = new Label_Text();
$frame->add($label);
$label->setHAlign($hAlign);
$label->setX($x);
$label->setStyle($style);
$label->setTextSize($textSize);
$label->setText($texts[$key]);
$label->setTextColor($textColor);
if ($profile) {
$label->addPlayerProfileFeature($profile);
}
array_push($labels, $label);
$labelLine->addLabelEntryText($texts[$key], $x);
}
} else {
foreach ($labelStrings as $text => $x) {
$label = new Label_Text();
$frame->add($label);
$label->setHAlign($hAlign);
$label->setX($x);
$label->setStyle($style);
$label->setTextSize($textSize);
$label->setText($text);
$label->setTextColor($textColor);
if ($profile) {
$label->addPlayerProfileFeature($profile);
}
array_push($labels, $label);
$labelLine->addLabelEntryText($text,$x);
}
}
$labelLine->render();
return $labels;
return $labelLine->getEntries();
}
}

View File

@ -11,6 +11,8 @@ use FML\Controls\Quads\Quad_Bgs1InRace;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Script\Features\Paging;
use FML\Script\Script;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
@ -20,7 +22,9 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class StyleManager {
class StyleManager implements UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -162,38 +166,37 @@ class StyleManager {
$frame->setSize($width, $height)->setZ(45); //TODO place before scoreboards
//TODO remove: (just temporary fix for tm bug)
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm'
) {
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm') {
$frame->setSize($width, $height)->setZ(32);
}
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$frame->addChild($backgroundQuad);
$backgroundQuad->setZ(-2)->setSize($width, $height)->setStyles($quadStyle, $quadSubstyle);
// Add Close Quad (X)
$closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad);
$frame->addChild($closeQuad);
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3)->setSize(6, 6)->setSubStyle($closeQuad::SUBSTYLE_QuitRace)->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
if ($script) {
$pagerSize = 6.;
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$frame->addChild($pagerPrev);
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
$pagerNext = new Quad_Icons64x64_1();
$frame->add($pagerNext);
$frame->addChild($pagerNext);
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)->setPosition($width * 0.40, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(1.3);
$frame->addChild($pageCountLabel);
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT)->setPosition($width * 0.40, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(1.3);
if ($paging) {
$paging->addButton($pagerNext)->addButton($pagerPrev)->setLabel($pageCountLabel);
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
}
}

View File

@ -128,7 +128,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$paging = new Paging();
$script->addFeature($paging);
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
$maniaLink->addChild($frame);
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
@ -137,11 +137,11 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$pageFrame = null;
$navigateRootQuad = new Quad_Icons64x64_1();
$frame->add($navigateRootQuad);
$frame->addChild($navigateRootQuad);
$navigateRootQuad->setPosition($width * -0.47, $height * 0.45)->setSize(4, 4)->setSubStyle($navigateRootQuad::SUBSTYLE_ToolRoot);
$navigateUpQuad = new Quad_Icons64x64_1();
$frame->add($navigateUpQuad);
$frame->addChild($navigateUpQuad);
$navigateUpQuad->setPosition($width * -0.44, $height * 0.45)->setSize(4, 4)->setSubStyle($navigateUpQuad::SUBSTYLE_ToolUp);
if (!$isInMapsFolder) {
@ -150,21 +150,21 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
}
$directoryLabel = new Label_Text();
$frame->add($directoryLabel);
$frame->addChild($directoryLabel);
$dataFolder = $this->maniaControl->getServer()->getDirectory()->getGameDataFolder();
$directoryText = substr($folderPath, strlen($dataFolder));
$directoryLabel->setPosition($width * -0.41, $height * 0.45)->setSize($width * 0.85, 4)->setHAlign($directoryLabel::LEFT)->setText($directoryText)->setTextSize(2);
$directoryLabel->setPosition($width * -0.41, $height * 0.45)->setSize($width * 0.85, 4)->setHorizontalAlign($directoryLabel::LEFT)->setText($directoryText)->setTextSize(2);
$tooltipLabel = new Label();
$frame->add($tooltipLabel);
$tooltipLabel->setPosition($width * -0.48, $height * -0.44)->setSize($width * 0.8, 5)->setHAlign($tooltipLabel::LEFT)->setTextSize(1)->setText('tooltip');
$frame->addChild($tooltipLabel);
$tooltipLabel->setPosition($width * -0.48, $height * -0.44)->setSize($width * 0.8, 5)->setHorizontalAlign($tooltipLabel::LEFT)->setTextSize(1);
$mapFiles = $this->scanMapFiles($folderPath);
if (is_array($mapFiles)) {
if (empty($mapFiles)) {
$emptyLabel = new Label();
$frame->add($emptyLabel);
$frame->addChild($emptyLabel);
$emptyLabel->setY(20)->setTextColor('aaa')->setText('No files found.')->setTranslate(true);
} else {
$canAddMaps = $this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP);
@ -176,27 +176,27 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
if ($index % 15 === 0) {
// New Page
$pageFrame = new Frame();
$frame->add($pageFrame);
$frame->addChild($pageFrame);
$posY = $height / 2 - 10;
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
}
// Map Frame
$mapFrame = new Frame();
$pageFrame->add($mapFrame);
$pageFrame->addChild($mapFrame);
$mapFrame->setY($posY);
if ($index % 2 === 0) {
// Striped background line
$lineQuad = new Quad_BgsPlayerCard();
$mapFrame->add($lineQuad);
$mapFrame->addChild($lineQuad);
$lineQuad->setZ(-1)->setSize($width, 4)->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
}
// File name Label
$nameLabel = new Label_Text();
$mapFrame->add($nameLabel);
$nameLabel->setX($width * -0.48)->setSize($width * 0.79, 4)->setHAlign($nameLabel::LEFT)->setStyle($nameLabel::STYLE_TextCardRaceRank)->setTextSize(1)->setText($fileName);
$mapFrame->addChild($nameLabel);
$nameLabel->setX($width * -0.48)->setSize($width * 0.79, 4)->setHorizontalAlign($nameLabel::LEFT)->setStyle($nameLabel::STYLE_TextCardRaceRank)->setTextSize(1)->setText($fileName);
if (is_dir($filePath)) {
// Folder
@ -208,14 +208,14 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
if ($canAddMaps) {
// 'Add' button
$addButton = new Quad_UIConstructionBullet_Buttons();
$mapFrame->add($addButton);
$mapFrame->addChild($addButton);
$addButton->setX($width * 0.42)->setSize(4, 4)->setSubStyle($addButton::SUBSTYLE_NewBullet)->setAction(self::ACTION_ADD_FILE . $fileName)->addTooltipLabelFeature($tooltipLabel, 'Add map ' . $fileName);
}
if ($canEraseMaps) {
// 'Erase' button
$eraseButton = new Quad_UIConstruction_Buttons();
$mapFrame->add($eraseButton);
$mapFrame->addChild($eraseButton);
$eraseButton->setX($width * 0.46)->setSize(4, 4)->setSubStyle($eraseButton::SUBSTYLE_Erase)->setAction(self::ACTION_ERASE_FILE . $fileName)->addTooltipLabelFeature($tooltipLabel, 'Erase file ' . $fileName);
}
}
@ -226,7 +226,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
}
} else {
$errorLabel = new Label();
$frame->add($errorLabel);
$frame->addChild($errorLabel);
$errorLabel->setY(20)->setTextColor('f30')->setText('No access to the directory.')->setTranslate(true);
}

View File

@ -2,6 +2,10 @@
namespace ManiaControl\Maps;
use ManiaControl\General\Dumpable;
use ManiaControl\General\DumpTrait;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaExchange\MXMapInfo;
use ManiaControl\Utils\Formatter;
@ -12,34 +16,36 @@ use ManiaControl\Utils\Formatter;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Map {
class Map implements Dumpable, UsageInformationAble {
use DumpTrait, UsageInformationTrait;
/*
* Public properties
*/
public $index = -1;
public $name = 'undefined';
public $rawName = null;
public $uid = null;
public $fileName = null;
public $environment = null;
public $authorTime = -1;
public $goldTime = -1;
public $copperPrice = -1;
public $mapType = null;
public $mapStyle = null;
public $index = -1;
public $name = 'undefined';
public $rawName = null;
public $uid = null;
public $fileName = null;
public $environment = null;
public $authorTime = -1;
public $goldTime = -1;
public $copperPrice = -1;
public $mapType = null;
public $mapStyle = null;
public $nbCheckpoints = -1;
public $nbLaps = -1;
public $nbLaps = -1;
/** @var MXMapInfo $mx */
public $mx = null;
public $mx = null;
public $authorLogin = null;
public $authorNick = null;
public $authorZone = null;
public $authorNick = null;
public $authorZone = null;
public $authorEInfo = null;
public $comment = null;
public $titleUid = null;
public $startTime = -1;
public $lastUpdate = 0;
public $karma = null;
public $comment = null;
public $titleUid = null;
public $startTime = -1;
public $lastUpdate = 0;
public $karma = null;
/**
* Construct a new map instance from xmlrpc data
@ -104,10 +110,4 @@ class Map {
return ($this->mx && ($this->lastUpdate < strtotime($this->mx->updated) || $this->uid !== $this->mx->uid));
}
/**
* Var_Dump the Map
*/
public function dump() {
var_dump(json_decode(json_encode($this)));
}
}

View File

@ -5,6 +5,8 @@ namespace ManiaControl\Maps;
use ManiaControl\Communication\CommunicationAnswer;
use ManiaControl\Communication\CommunicationListener;
use ManiaControl\Communication\CommunicationMethods;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
@ -15,7 +17,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MapActions implements CommunicationListener {
class MapActions implements CommunicationListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Private properties
*/

View File

@ -79,8 +79,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
private function initActionsMenuButtons() {
// Menu Open xList
$itemQuad = new Quad();
$itemQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
$itemQuad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
$itemQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
$itemQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
@ -132,8 +132,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_RemoveMap(array $chatCallback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -155,8 +154,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_EraseMap(array $chatCallback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -178,8 +176,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_ShuffleMaps(array $chatCallback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SHUFFLE_MAPS)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SHUFFLE_MAPS)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -195,8 +192,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_AddMap(array $chatCallback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -217,8 +213,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_NextMap(array $chat, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -237,8 +232,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_RestartMap(array $chat, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -253,6 +247,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
}
////$this->maniaControl->mapManager->mapQueue->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->mapManager->getCurrentMap());
/**
* Handle replaymap command
*
@ -260,8 +255,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_ReplayMap(array $chat, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -279,8 +273,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_WriteMapList(array $chat, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -315,8 +308,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param \ManiaControl\Players\Player $player
*/
public function command_ReadMapList(array $chat, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)
) {
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -452,8 +444,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$mapList = array();
foreach ($maps as $map) {
if ($map instanceof Map) {
if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) === true
) {
if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) === true) {
$karma = $karmaPlugin->getMapKarma($map);
$map->karma = round($karma * 100.);
} else {
@ -516,6 +507,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player
*/
public function command_xList(array $chatCallback, Player $player) {
$this->maniaControl->getMapManager()->getMXList()->showList($chatCallback, $player);
$this->maniaControl->getMapManager()->getMXList()->showListCommand($chatCallback, $player);
}
}

View File

@ -120,6 +120,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
public function showMapList(Player $player, $mapList = null, $pageIndex = -1) {
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
$buttonY = -$height / 2 + 9;
if ($pageIndex < 0) {
$pageIndex = (int) $player->getCache($this, self::CACHE_CURRENT_PAGE);
@ -150,53 +151,58 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Main frame
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
$maniaLink->addChild($frame);
// Admin Buttons
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)
) {
// Clear Map-Queue
$label = new Label_Button();
$frame->add($label);
$frame->addChild($label);
$label->setText('Clear Map-Queue');
$label->setTextSize(1);
$label->setPosition($width / 2 - 8, -$height / 2 + 9);
$label->setHAlign($label::RIGHT);
$label->setPosition($width / 2 - 8, $buttonY, 0.1);
$label->setHorizontalAlign($label::RIGHT);
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
$quad->setPosition($width / 2 - 5, -$height / 2 + 9, 0.01);
$frame->addChild($quad);
$quad->setPosition($width / 2 - 5, $buttonY, 0.01);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setHAlign($quad::RIGHT);
$quad->setHorizontalAlign($quad::RIGHT);
$quad->setSize(29, 4);
$quad->setAction(self::ACTION_CLEAR_MAPQUEUE);
}
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)
) {
$mxCheckForUpdatesX = $width / 2 - 37;
$buttonWidth = 35;
$iconSize = 3;
// Check Update
$label = new Label_Button();
$frame->add($label);
$frame->addChild($label);
$label->setText('Check MX for Updates');
$label->setPosition($mxCheckForUpdatesX - 1.5, $buttonY, 0.02);
$label->setTextSize(1);
$label->setPosition($width / 2 - 41, -$height / 2 + 9, 0.01);
$label->setHAlign($label::RIGHT);
$label->setWidth(30);
$label->setHorizontalAlign($label::RIGHT);
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
$quad->setPosition($width / 2 - 37, -$height / 2 + 9, 0.01);
$frame->addChild($quad);
$quad->setPosition($mxCheckForUpdatesX, $buttonY, 0.01);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setHAlign($quad::RIGHT);
$quad->setSize(35, 4);
$quad->setHorizontalAlign($quad::RIGHT);
$quad->setSize($buttonWidth, 4);
$quad->setAction(self::ACTION_CHECK_UPDATE);
$mxQuad = new Quad();
$frame->add($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN));
$mxQuad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN_MOVER));
$mxQuad->setPosition($width / 2 - 67, -$height / 2 + 9);
$mxQuad->setZ(0.01);
$frame->addChild($mxQuad);
$mxQuad->setSize($iconSize, $iconSize);
$mxQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN));
$mxQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN_MOVER));
$mxQuad->setPosition($mxCheckForUpdatesX - $buttonWidth + 3, $buttonY);
$mxQuad->setZ(0.02);
$mxQuad->setAction(self::ACTION_CHECK_UPDATE);
}
@ -204,14 +210,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
) {
// Directory browser
$browserButton = new Label_Button();
$frame->add($browserButton);
$browserButton->setPosition($width / -2 + 20, -$height / 2 + 9, 0.01);
$frame->addChild($browserButton);
$browserButton->setPosition($width / -2 + 20, $buttonY, 0.01);
$browserButton->setTextSize(1);
$browserButton->setText('Directory Browser');
$browserQuad = new Quad_BgsPlayerCard();
$frame->add($browserQuad);
$browserQuad->setPosition($width / -2 + 20, -$height / 2 + 9, 0.01);
$frame->addChild($browserQuad);
$browserQuad->setPosition($width / -2 + 20, $buttonY, 0.01);
$browserQuad->setSubStyle($browserQuad::SUBSTYLE_BgPlayerCardBig);
$browserQuad->setSize(35, 4);
$browserQuad->setAction(DirectoryBrowser::ACTION_SHOW);
@ -219,7 +225,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Headline
$headFrame = new Frame();
$frame->add($headFrame);
$frame->addChild($headFrame);
$headFrame->setY($height / 2 - 5);
$posX = -$width / 2;
$array = array('Id' => $posX + 5, 'Mx Id' => $posX + 10, 'Map Name' => $posX + 20, 'Author' => $posX + 68, 'Karma' => $posX + 115, 'Actions' => $width / 2 - 16);
@ -227,7 +233,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Predefine description Label
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
$frame->add($descriptionLabel);
$frame->addChild($descriptionLabel);
$queuedMaps = $this->maniaControl->getMapManager()->getMapQueue()->getQueuedMapsRanking();
/** @var KarmaPlugin $karmaPlugin */
@ -251,21 +257,21 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
/** @var Map $map */
if ($index % self::MAX_MAPS_PER_PAGE === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$frame->addChild($pageFrame);
$posY = $height / 2 - 10;
$paging->addPage($pageFrame, $pageNumber);
$paging->addPageControl($pageFrame, $pageNumber);
$pageNumber++;
}
// Map Frame
$mapFrame = new Frame();
$pageFrame->add($mapFrame);
$pageFrame->addChild($mapFrame);
$mapFrame->setY($posY);
$mapFrame->setZ(0.1);
if ($mapListId % 2 !== 0) {
$lineQuad = new Quad_BgsPlayerCard();
$mapFrame->add($lineQuad);
$mapFrame->addChild($lineQuad);
$lineQuad->setSize($width, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ(0.001);
@ -273,7 +279,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
if ($currentMap === $map) {
$currentQuad = new Quad_Icons64x64_1();
$mapFrame->add($currentQuad);
$mapFrame->addChild($currentQuad);
$currentQuad->setX($posX + 3.5);
$currentQuad->setZ(0.2);
$currentQuad->setSize(4, 4);
@ -285,10 +291,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxId = $map->mx->id;
$mxQuad = new Quad();
$mapFrame->add($mxQuad);
$mapFrame->addChild($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($mxIcon);
$mxQuad->setImageFocus($mxIconHover);
$mxQuad->setImageUrl($mxIcon);
$mxQuad->setImageFocusUrl($mxIconHover);
$mxQuad->setX($posX + 65);
$mxQuad->setUrl($map->mx->pageurl);
$mxQuad->setZ(0.01);
@ -297,10 +303,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
if ($map->updateAvailable()) {
$mxQuad = new Quad();
$mapFrame->add($mxQuad);
$mapFrame->addChild($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($mxIconGreen);
$mxQuad->setImageFocus($mxIconGreenHover);
$mxQuad->setImageUrl($mxIconGreen);
$mxQuad->setImageFocusUrl($mxIconGreenHover);
$mxQuad->setX($posX + 62);
$mxQuad->setUrl($map->mx->pageurl);
$mxQuad->setZ(0.01);
@ -331,7 +337,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Map-Queue-Map-Label
if (isset($queuedMaps[$map->uid])) {
$label = new Label_Text();
$mapFrame->add($label);
$mapFrame->addChild($label);
$label->setX($width / 2 - 13);
$label->setZ(0.2);
$label->setTextSize(1.5);
@ -351,7 +357,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
} else {
// Map-Queue-Map-Button
$queueLabel = new Label_Button();
$mapFrame->add($queueLabel);
$mapFrame->addChild($queueLabel);
$queueLabel->setX($width / 2 - 13);
$queueLabel->setZ(0.2);
$queueLabel->setSize(3, 3);
@ -377,7 +383,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
) {
// remove map button
$removeButton = new Label_Button();
$mapFrame->add($removeButton);
$mapFrame->addChild($removeButton);
$removeButton->setX($width / 2 - 5);
$removeButton->setZ(0.2);
$removeButton->setSize(3, 3);
@ -395,7 +401,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
) {
// Switch to button
$switchLabel = new Label_Button();
$mapFrame->add($switchLabel);
$mapFrame->addChild($switchLabel);
$switchLabel->setX($width / 2 - 9);
$switchLabel->setZ(0.2);
$switchLabel->setSize(3, 3);
@ -415,7 +421,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
) {
// Switch Map Voting for Admins
$switchQuad = new Quad_UIConstruction_Buttons();
$mapFrame->add($switchQuad);
$mapFrame->addChild($switchQuad);
$switchQuad->setX($width / 2 - 17);
$switchQuad->setZ(0.2);
$switchQuad->setSubStyle($switchQuad::SUBSTYLE_Validate_Step2);
@ -426,7 +432,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
} else {
// Switch Map Voting for Player
$switchLabel = new Label_Button();
$mapFrame->add($switchLabel);
$mapFrame->addChild($switchLabel);
$switchLabel->setX($width / 2 - 7);
$switchLabel->setZ(0.2);
$switchLabel->setSize(3, 3);
@ -477,18 +483,18 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
}
$karmaGauge = new Gauge();
$mapFrame->add($karmaGauge);
$mapFrame->addChild($karmaGauge);
$karmaGauge->setZ(2);
$karmaGauge->setX($posX + 120);
$karmaGauge->setSize(20, 9);
$karmaGauge->setDrawBg(false);
$karmaGauge->setDrawBackground(false);
$karma = floatval($karma);
$karmaGauge->setRatio($karma + 0.15 - $karma * 0.15);
$karmaColor = ColorUtil::floatToStatusColor($karma);
$karmaGauge->setColor($karmaColor . '9');
$karmaLabel = new Label();
$mapFrame->add($karmaLabel);
$mapFrame->addChild($karmaLabel);
$karmaLabel->setZ(2);
$karmaLabel->setX($posX + 120);
$karmaLabel->setSize(20 * 0.9, 5);
@ -549,29 +555,29 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
$confirmFrame = new Frame();
$maniaLink->add($confirmFrame);
$maniaLink->addChild($confirmFrame);
$confirmFrame->setPosition($width / 2 + 6, $posY);
$confirmFrame->setVisible(false);
$quad = new Quad();
$confirmFrame->add($quad);
$confirmFrame->addChild($quad);
$quad->setStyles($quadStyle, $quadSubstyle);
$quad->setSize(12, 4);
$quad = new Quad_BgsPlayerCard();
$confirmFrame->add($quad);
$confirmFrame->addChild($quad);
$quad->setSubStyle($quad::SUBSTYLE_BgCardSystem);
$quad->setSize(11, 3.5);
$label = new Label_Button();
$confirmFrame->add($label);
$confirmFrame->addChild($label);
$label->setText('Sure?');
$label->setTextSize(1);
$label->setScale(0.90);
$label->setX(-1.3);
$buttLabel = new Label_Button();
$confirmFrame->add($buttLabel);
$confirmFrame->addChild($buttLabel);
$buttLabel->setPosition(3.2, 0.4, 0.2);
$buttLabel->setSize(3, 3);

View File

@ -9,7 +9,10 @@ use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Communication\CommunicationAnswer;
use ManiaControl\Communication\CommunicationListener;
use ManiaControl\Communication\CommunicationMethods;
use ManiaControl\Files\AsyncHttpRequest;
use ManiaControl\Files\FileUtil;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\ManiaExchange\ManiaExchangeList;
@ -33,7 +36,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnavailableFeatureException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MapManager implements CallbackListener, CommunicationListener {
class MapManager implements CallbackListener, CommunicationListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -356,12 +361,14 @@ class MapManager implements CallbackListener, CommunicationListener {
$url = $mapInfo->downloadurl;
if ($key = $this->maniaControl->getSettingManager()->getSettingValue($this, ManiaExchangeManager::SETTING_MX_KEY)) {
$url .= "&key=" . $key;
if ($key = $this->maniaControl->getSettingManager()->getSettingValue($this->getMXManager(), ManiaExchangeManager::SETTING_MX_KEY)) {
$url .= "?key=" . $key;
}
// Download the file
$this->maniaControl->getFileReader()->loadFile($url, function ($file, $error) use (
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $url);
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_UTF8);
$asyncHttpRequest->setHeaders(array("X-ManiaPlanet-ServerLogin: " . $this->maniaControl->getServer()->login));
$asyncHttpRequest->setCallable(function ($file, $error) use (
&$login, &$mapInfo, &$update
) {
if (!$file || $error) {
@ -372,7 +379,9 @@ class MapManager implements CallbackListener, CommunicationListener {
return;
}
$this->processMapFile($file, $mapInfo, $login, $update);
}, 'UTF-8', 0, array("X-ManiaPlanet-ServerLogin: " . $this->maniaControl->getServer()->login));
});
$asyncHttpRequest->getData();
});
}
return;
@ -427,7 +436,7 @@ class MapManager implements CallbackListener, CommunicationListener {
return;
}
throw $e;
} catch(FileException $e){
} catch (FileException $e) {
$this->maniaControl->getChat()->sendError("Could not write file", $login);
return;
}
@ -452,7 +461,9 @@ class MapManager implements CallbackListener, CommunicationListener {
return;
} catch (InvalidMapException $exception) {
$this->maniaControl->getChat()->sendException($exception, $login);
return;
if ($exception->getMessage() != 'Map lightmap is not up to date. (will still load for now)') {
return;
}
}
$this->updateFullMapList();
@ -462,6 +473,7 @@ class MapManager implements CallbackListener, CommunicationListener {
// Update last updated time
$map = $this->getMapByUid($mapInfo->uid);
if (!$map) {
// TODO: improve this - error reports about not existing maps
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Map not in List after Insert!');

View File

@ -6,6 +6,8 @@ use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Commands\CommandListener;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
@ -20,7 +22,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\NotInListException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MapQueue implements CallbackListener, CommandListener {
class MapQueue implements CallbackListener, CommandListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/

View File

@ -2,6 +2,10 @@
namespace ManiaControl\Players;
use ManiaControl\General\Dumpable;
use ManiaControl\General\DumpTrait;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Utils\ClassUtil;
use ManiaControl\Utils\Formatter;
@ -14,7 +18,9 @@ use Maniaplanet\DedicatedServer\Structures\LadderStats;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Player {
class Player implements Dumpable, UsageInformationAble {
use DumpTrait, UsageInformationTrait;
/*
* Public Properties
*/
@ -346,13 +352,6 @@ class Player {
return false;
}
/**
* Var_Dump the Player
*/
public function dump() {
var_dump(json_decode(json_encode($this)));
}
/**
* Var_Dump the Players Cache
*/

View File

@ -12,6 +12,8 @@ use ManiaControl\Callbacks\EchoListener;
use ManiaControl\Communication\CommunicationAnswer;
use ManiaControl\Communication\CommunicationListener;
use ManiaControl\Communication\CommunicationMethods;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager;
@ -30,7 +32,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerActions implements EchoListener, CommunicationListener {
class PlayerActions implements EchoListener, CommunicationListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -472,18 +476,18 @@ class PlayerActions implements EchoListener, CommunicationListener {
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$frame = new Frame();
$maniaLink->add($frame);
$maniaLink->addChild($frame);
$frame->setPosition(0, 10);
// Background
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$frame->addChild($backgroundQuad);
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
// Close Quad (X)
$closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad);
$frame->addChild($closeQuad);
$closeQuad->setPosition($width * 0.473, $height * 0.457, 3);
$closeQuad->setSize(6, 6);
$closeQuad->setSubStyle($closeQuad::SUBSTYLE_QuitRace);
@ -491,7 +495,7 @@ class PlayerActions implements EchoListener, CommunicationListener {
// Headline
$label = new Label_Text();
$frame->add($label);
$frame->addChild($label);
$label->setY($height / 2 - 5);
$label->setStyle($label::STYLE_TextCardMedium);
$label->setTextSize(4);
@ -502,7 +506,7 @@ class PlayerActions implements EchoListener, CommunicationListener {
foreach ($message as $line) {
// Message lines
$label = new Label_Text();
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setStyle($label::STYLE_TextCardMedium);
$label->setText($line);

View File

@ -3,6 +3,8 @@
namespace ManiaControl\Players;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Utils\ClassUtil;
@ -13,7 +15,9 @@ use ManiaControl\Utils\ClassUtil;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerDataManager {
class PlayerDataManager implements UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -31,8 +35,8 @@ class PlayerDataManager {
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
private $metaData = array();
private $storedData = array();
private $metaData = array();
private $storedData = array();
/**
* Construct a new player manager instance
@ -318,7 +322,7 @@ class PlayerDataManager {
private function getMetaDataId($className, $statName) {
if (isset($this->metaData[$className . $statName])) {
$stat = $this->metaData[$className . $statName];
return (int)$stat->dataId;
return (int) $stat->dataId;
}
return null;
}
@ -332,16 +336,16 @@ class PlayerDataManager {
*/
private function castSetting($type, $value) {
if ($type === self::TYPE_INT) {
return (int)$value;
return (int) $value;
}
if ($type === self::TYPE_REAL) {
return (float)$value;
return (float) $value;
}
if ($type === self::TYPE_BOOL) {
return (bool)$value;
return (bool) $value;
}
if ($type === self::TYPE_STRING) {
return (string)$value;
return (string) $value;
}
if ($type === self::TYPE_ARRAY) {
return explode(self::ARRAY_DELIMITER, $value);

View File

@ -59,160 +59,160 @@ class PlayerDetailed {
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
// Create ManiaLink
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$script = $maniaLink->getScript();
$manialink = new ManiaLink(ManialinkManager::MAIN_MLID);
$script = $manialink->getScript();
// Main frame
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script);
$maniaLink->add($frame);
$manialink->addChild($frame);
// Create script and features
$script = new Script();
$maniaLink->setScript($script);
$manialink->setScript($script);
$posY = $this->height / 2 - 7;
//Nation Quad
$countryQuad = new Quad();
$frame->add($countryQuad);
$countryQuad->setImage("file://ZoneFlags/Login/{$targetLogin}/country");
$frame->addChild($countryQuad);
$countryQuad->setImageUrl("file://ZoneFlags/Login/{$targetLogin}/country");
$countryQuad->setPosition(-$this->width / 2 + 10, $posY);
$countryQuad->setSize(5, 5);
$countryQuad->setZ(-0.1);
$countryQuad->setHAlign($countryQuad::LEFT);
$countryQuad->setHorizontalAlign($countryQuad::LEFT);
//Nickname
$label = new Label_Text();
$frame->add($label);
$frame->addChild($label);
$label->setPosition(-$this->width / 2 + 15, $posY);
$label->setText($target->nickname);
$label->setHAlign($label::LEFT);
$label->setHorizontalAlign($label::LEFT);
//Define MainLabel (Login)
$posY -= 8;
$mainLabel = new Label_Text();
$frame->add($mainLabel);
$frame->addChild($mainLabel);
$mainLabel->setPosition(-$this->width / 2 + 10, $posY);
$mainLabel->setTextSize(1.2);
$mainLabel->setHAlign($mainLabel::LEFT);
$mainLabel->setHorizontalAlign($mainLabel::LEFT);
$mainLabel->setText('Login: ');
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Nation: ');
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Province: ');
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Authorization: ');
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText("Ladder Rank:");
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Ladder Score: ');
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Inscribed Zone: ');
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Avatar');
//Login
$posY = $this->height / 2 - 15;
$mainLabel = new Label_Text();
$frame->add($mainLabel);
$frame->addChild($mainLabel);
$mainLabel->setPosition(-$this->width / 2 + 30, $posY);
$mainLabel->setText($target->login);
$mainLabel->setTextSize(1.2);
$mainLabel->setHAlign($mainLabel::LEFT);
$mainLabel->setHorizontalAlign($mainLabel::LEFT);
//Country
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText($target->getCountry());
//Province
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText($target->getProvince());
//AuthLevel
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel));
//LadderRank
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText($target->ladderRank);
//LadderScore
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText(round($target->ladderScore, 2));
//Played Since
$posY -= 5;
$label = clone $mainLabel;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText(date('d M Y', time() - 3600 * 24 * $target->daysSinceZoneInscription));
$quad = new Quad();
$frame->add($quad);
$quad->setImage('file://Avatars/' . $targetLogin . "/default");
$frame->addChild($quad);
$quad->setImageUrl('file://Avatars/' . $targetLogin . "/default");
$quad->setPosition(-$this->width / 2 + 50, -$this->height / 2 + 34);
$quad->setAlign($quad::RIGHT, $quad::TOP);
$quad->setSize(20, 20);
//Statistics
$frame->add($this->statisticsFrame($target));
$frame->addChild($this->statisticsFrame($target));
$quad = new Label_Button();
$frame->add($quad);
$frame->addChild($quad);
$quad->setStyle($quad::STYLE_CardMain_Quit);
$quad->setHAlign($quad::LEFT);
$quad->setHorizontalAlign($quad::LEFT);
$quad->setScale(0.75);
$quad->setText('Back');
$quad->setPosition(-$this->width / 2 + 7, -$this->height / 2 + 7);
$quad->setAction(PlayerCommands::ACTION_OPEN_PLAYERLIST);
// render and display xml
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'PlayerDetailed');
$this->maniaControl->getManialinkManager()->displayWidget($manialink, $player, 'PlayerDetailed');
}
/**
@ -244,22 +244,22 @@ class PlayerDetailed {
if ($index % 2 !== 0) {
$lineQuad = new Quad_BgsPlayerCard();
$frame->add($lineQuad);
$frame->addChild($lineQuad);
$lineQuad->setSize(49, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setPosition($posX, $posY, 0.001);
$lineQuad->setHAlign($lineQuad::LEFT);
$lineQuad->setHorizontalAlign($lineQuad::LEFT);
}
$label = new Label_Text();
$frame->add($label);
$frame->addChild($label);
$label->setPosition($posX + 4, $posY);
$label->setText($statProperties->name);
$label->setHAlign($label::LEFT);
$label->setHorizontalAlign($label::LEFT);
$label->setTextSize(1.5);
$label = new Label_Text();
$frame->add($label);
$frame->addChild($label);
$label->setPosition($posX + 40, $posY);
$label->setText($value);
$label->setTextSize(1.5);

View File

@ -149,19 +149,23 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// Main frame
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
$maniaLink->add($frame);
$maniaLink->addChild($frame);
// Start offsets
$posX = -$width / 2;
$posY = $height / 2;
// Define z-values
$foregroundZ = 1;
$backgroundZ = 0.5;
// Predefine Description Label
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
$frame->add($descriptionLabel);
$frame->addChild($descriptionLabel);
// Headline
$headFrame = new Frame();
$frame->add($headFrame);
$frame->addChild($headFrame);
$headFrame->setY($posY - 5);
$labelLineArray = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Location' => $posX + 101);
@ -177,36 +181,36 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
foreach ($players as $listPlayer) {
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$frame->addChild($pageFrame);
$paging->addPage($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height / 2 - 10;
}
$path = $listPlayer->getProvince();
$playerFrame = new Frame();
$pageFrame->add($playerFrame);
$pageFrame->addChild($playerFrame);
if ($index % 2 !== 0) {
$lineQuad = new Quad_BgsPlayerCard();
$playerFrame->add($lineQuad);
$playerFrame->addChild($lineQuad);
$lineQuad->setSize($width, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ(0.001);
$lineQuad->setZ($backgroundZ);
}
$positions = array($posX + 5, $posX + 18, $posX + 70, $posX + 101);
$texts = array($index, $listPlayer->nickname, $listPlayer->login, $path);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts));
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts), array('posZ' => $foregroundZ));
$playerFrame->setY($posY);
// Show current Player Arrow
if ($listPlayer->index === $player->index) {
$currentQuad = new Quad_Icons64x64_1();
$playerFrame->add($currentQuad);
$playerFrame->addChild($currentQuad);
$currentQuad->setX($posX + 3.5);
$currentQuad->setZ(0.2);
$currentQuad->setZ($foregroundZ);
$currentQuad->setSize(4, 4);
$currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue);
}
@ -215,9 +219,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
if ($listPlayer->teamId >= 0) {
// Player is in a Team
$teamQuad = new Quad_Emblems();
$playerFrame->add($teamQuad);
$playerFrame->addChild($teamQuad);
$teamQuad->setX($posX + 10);
$teamQuad->setZ(0.1);
$teamQuad->setZ($foregroundZ);
$teamQuad->setSize(3.8, 3.8);
switch ($listPlayer->teamId) {
@ -231,9 +235,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
} else if ($listPlayer->isSpectator) {
// Player is in Spectator Mode
$specQuad = new Quad_BgRaceScore2();
$playerFrame->add($specQuad);
$playerFrame->addChild($specQuad);
$specQuad->setX($posX + 10);
$specQuad->setZ(0.1);
$specQuad->setZ($foregroundZ);
$specQuad->setSubStyle($specQuad::SUBSTYLE_Spectator);
$specQuad->setSize(3.8, 3.8);
}
@ -242,10 +246,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
if ($countryCode !== 'OTH') {
// Nation Quad
$countryQuad = new Quad();
$playerFrame->add($countryQuad);
$countryQuad->setImage("file://ZoneFlags/Login/{$listPlayer->login}/country");
$playerFrame->addChild($countryQuad);
$countryQuad->setImageUrl("file://ZoneFlags/Login/{$listPlayer->login}/country");
$countryQuad->setX($posX + 98);
$countryQuad->setZ(1);
$countryQuad->setZ($foregroundZ);
$countryQuad->setSize(4, 4);
$countryQuad->addTooltipLabelFeature($descriptionLabel, '$<' . $listPlayer->nickname . '$> from ' . $listPlayer->path);
@ -253,16 +257,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// Level Quad
$rightQuad = new Quad_BgRaceScore2();
$playerFrame->add($rightQuad);
$playerFrame->addChild($rightQuad);
$rightQuad->setX($posX + 13);
$rightQuad->setZ(3);
$rightQuad->setZ($foregroundZ);
$rightQuad->setSize(7, 3.5);
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
$rightLabel = new Label_Text();
$playerFrame->add($rightLabel);
$playerFrame->addChild($rightLabel);
$rightLabel->setX($posX + 13.9);
$rightLabel->setZ(3.1);
$rightLabel->setZ($foregroundZ);
$rightLabel->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelAbbreviation($listPlayer->authLevel));
$rightLabel->setTextSize(0.8);
$rightLabel->setTextColor('fff');
@ -272,9 +276,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// Player Statistics
$playerQuad = new Quad_Icons64x64_1();
$playerFrame->add($playerQuad);
$playerFrame->addChild($playerQuad);
$playerQuad->setX($posX + 61);
$playerQuad->setZ(3);
$playerQuad->setZ($foregroundZ);
$playerQuad->setSize(2.7, 2.7);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo);
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . '.' . $listPlayer->login);
@ -283,9 +287,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// Camera Quad
$playerQuad = new Quad_UIConstruction_Buttons();
$playerFrame->add($playerQuad);
$playerFrame->addChild($playerQuad);
$playerQuad->setX($posX + 64.5);
$playerQuad->setZ(3);
$playerQuad->setZ($foregroundZ);
$playerQuad->setSize(3.8, 3.8);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera);
$description = 'Spectate $<' . $listPlayer->nickname . '$>';
@ -294,9 +298,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// Player Profile Quad
$playerQuad = new Quad_UIConstruction_Buttons();
$playerFrame->add($playerQuad);
$playerFrame->addChild($playerQuad);
$playerQuad->setX($posX + 68);
$playerQuad->setZ(3);
$playerQuad->setZ($foregroundZ);
$playerQuad->setSize(3.8, 3.8);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
$playerQuad->addPlayerProfileFeature($listPlayer->login);
@ -308,9 +312,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
// Further Player actions Quad
$playerQuad = new Quad_Icons64x64_1();
$playerFrame->add($playerQuad);
$playerFrame->addChild($playerQuad);
$playerQuad->setX($posX + 132);
$playerQuad->setZ(0.1);
$playerQuad->setZ($foregroundZ);
$playerQuad->setSize(3.8, 3.8);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
$playerQuad->setAction(self::ACTION_PLAYER_ADV . '.' . $listPlayer->login);
@ -324,9 +328,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
// Force to Red-Team Quad
$redQuad = new Quad_Emblems();
$playerFrame->add($redQuad);
$playerFrame->addChild($redQuad);
$redQuad->setX($posX + 145);
$redQuad->setZ(0.1);
$redQuad->setZ($foregroundZ);
$redQuad->setSize(3.8, 3.8);
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
$redQuad->setAction(self::ACTION_FORCE_RED . '.' . $listPlayer->login);
@ -337,9 +341,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// Force to Blue-Team Quad
$blueQuad = new Quad_Emblems();
$playerFrame->add($blueQuad);
$playerFrame->addChild($blueQuad);
$blueQuad->setX($posX + 141);
$blueQuad->setZ(0.1);
$blueQuad->setZ($foregroundZ);
$blueQuad->setSize(3.8, 3.8);
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
$blueQuad->setAction(self::ACTION_FORCE_BLUE . '.' . $listPlayer->login);
@ -351,9 +355,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
} else if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
// Kick Player Vote
$kickQuad = new Quad_UIConstruction_Buttons();
$playerFrame->add($kickQuad);
$playerFrame->addChild($kickQuad);
$kickQuad->setX($posX + 141);
$kickQuad->setZ(0.1);
$kickQuad->setZ($foregroundZ);
$kickQuad->setSize(3.8, 3.8);
$kickQuad->setSubStyle($kickQuad::SUBSTYLE_Validate_Step2);
$kickQuad->setAction(self::ACTION_KICK_PLAYER_VOTE . '.' . $listPlayer->login);
@ -365,9 +369,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)) {
// Force to Play
$playQuad = new Quad_Emblems();
$playerFrame->add($playQuad);
$playerFrame->addChild($playQuad);
$playQuad->setX($posX + 143);
$playQuad->setZ(0.1);
$playQuad->setZ($foregroundZ);
$playQuad->setSize(3.8, 3.8);
$playQuad->setSubStyle($playQuad::SUBSTYLE_2);
$playQuad->setAction(self::ACTION_FORCE_PLAY . '.' . $listPlayer->login);
@ -380,9 +384,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) {
// Force to Spectator Quad
$spectatorQuad = new Quad_BgRaceScore2();
$playerFrame->add($spectatorQuad);
$playerFrame->addChild($spectatorQuad);
$spectatorQuad->setX($posX + 137);
$spectatorQuad->setZ(0.1);
$spectatorQuad->setZ($foregroundZ);
$spectatorQuad->setSize(3.8, 3.8);
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . '.' . $listPlayer->login);
@ -393,9 +397,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
} else if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
// Force to Spectator Quad
$spectatorQuad = new Quad_BgRaceScore2();
$playerFrame->add($spectatorQuad);
$playerFrame->addChild($spectatorQuad);
$spectatorQuad->setX($posX + 137);
$spectatorQuad->setZ(0.1);
$spectatorQuad->setZ($foregroundZ);
$spectatorQuad->setSize(3.8, 3.8);
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC_VOTE . '.' . $listPlayer->login);
@ -413,7 +417,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$listShownValue = $this->playersListShown[$player->login];
if ($listShownValue && $listShownValue !== self::SHOWN_MAIN_WINDOW) {
$frame = $this->showAdvancedPlayerWidget($player, $listShownValue);
$maniaLink->add($frame);
$maniaLink->addChild($frame);
}
// Render and display xml
@ -435,9 +439,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
//Settings
$posX = $width / 2 + 2.5;
$posX = $width / 2 + 0.2;
$width = 35;
$height = $height * 0.75;
$textSize = 1.5;
$textColor = 'fff';
$quadWidth = $width - 7;
@ -445,35 +448,27 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// mainframe
$frame = new Frame();
$frame->setSize($width, $height);
$frame->setPosition($posX + $width / 2, 0, 31);
$frame->setPosition($posX + $width / 2, 0, ManialinkManager::MAIN_MANIALINK_Z_VALUE);
// Add Close Quad (X)
$closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad);
$closeQuad->setPosition($width * 0.4, $height * 0.43, 3);
$frame->addChild($closeQuad);
$closeQuad->setPosition($width / 2 - 2.5, $height / 2 - 2.5, 3);
$closeQuad->setSize(6, 6);
$closeQuad->setSubStyle($closeQuad::SUBSTYLE_QuitRace);
$closeQuad->setAction(self::ACTION_CLOSE_PLAYER_ADV);
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$frame->addChild($backgroundQuad);
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setImage('https://dl.dropboxusercontent.com/u/105352981/Stuff/CAM%20SM%20BORDER%20PNG.png'); //TODO just a test
//$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setZ(-0.3);
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setSize($width - 2, $height - 2);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setZ(-0.4);
$backgroundQuad->setZ(-0.3);
// Show headline
$label = new Label_Text();
$frame->add($label);
$label->setHAlign($label::LEFT);
$frame->addChild($label);
$label->setHorizontalAlign($label::LEFT);
$label->setX(-$width / 2 + 5);
$label->setY($height / 2 - 5);
$label->setStyle($label::STYLE_TextCardSmall);
@ -481,28 +476,40 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$label->setText('Advanced Actions');
$label->setTextColor($textColor);
//Nickname background
$quad = new Quad();
$frame->addChild($quad);
$quad->setPosition(0, $height / 2 - 10, -0.1);
$quad->setStyles($quadStyle, $quadSubstyle);
$quad->setSize($width, 5);
// Show Nickname
$label = new Label_Text();
$frame->add($label);
$label->setHAlign($label::LEFT);
$label->setX(0);
$label->setY($height / 2 - 8);
$frame->addChild($label);
$label->setWidth($width * 0.9);
$label->setY($height / 2 - 10);
$label->setStyle($label::STYLE_TextCardSmall);
$label->setTextSize($textSize);
$label->setText($player->nickname);
$label->setTextColor($textColor);
$label->setHorizontalAlign($label::CENTER);
// Mute Player
$posY = $height / 2 - 14;
$buttonSpacing = 6.5;
// Background for Buttons
$posY = $height / 2 - 20;
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
$frame->addChild($quad);
$quad->setX(0);
$quad->setY($posY);
$quad->setZ(-0.1);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize($quadWidth, 5);
// Mute Button
$label = new Label_Text();
$frame->add($label);
$frame->addChild($label);
$label->setX(0);
$label->setY($posY);
$label->setStyle($label::STYLE_TextCardSmall);
@ -518,80 +525,80 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
}
// Warn Player
$posY -= 5;
$posY -= $buttonSpacing;
$quad = clone $quad;
$frame->add($quad);
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_WARN_PLAYER . '.' . $login);
$label = clone $label;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Warn');
$label->setTextColor($textColor);
$posY -= 5;
$posY -= $buttonSpacing;
// Show Kick
$quad = clone $quad;
$frame->add($quad);
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_KICK_PLAYER . '.' . $login);
$label = clone $label;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Kick');
$label->setTextColor('f90');
$posY -= 5;
$posY -= $buttonSpacing;
// Show Ban
$quad = clone $quad;
$frame->add($quad);
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_BAN_PLAYER . '.' . $login);
$label = clone $label;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Ban');
$label->setTextColor('700');
$posY -= 10;
$posY -= $buttonSpacing * 2;
// Show Add as Master-Admin
$quad = clone $quad;
$frame->add($quad);
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_ADD_AS_MASTER . '.' . $login);
$label = clone $label;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Set SuperAdmin');
$label->setTextColor($textColor);
$posY -= 5;
$posY -= $buttonSpacing;
// Show Add as Admin
$quad = clone $quad;
$frame->add($quad);
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_ADD_AS_ADMIN . '.' . $login);
$label = clone $label;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Set Admin');
$label->setTextColor($textColor);
$posY -= 5;
$posY -= $buttonSpacing;
// Show Add as Moderator
$quad = clone $quad;
$frame->add($quad);
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_ADD_AS_MOD . '.' . $login);
$label = clone $label;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Set Moderator');
$label->setTextColor($textColor);
@ -599,15 +606,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
if ($player->authLevel > 0
&& $this->maniaControl->getAuthenticationManager()->checkRight($admin, $player->authLevel + 1)
) {
$posY -= 5;
$posY -= $buttonSpacing;
// Revoke Rights
$quad = clone $quad;
$frame->add($quad);
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_REVOKE_RIGHTS . '.' . $login);
$label = clone $label;
$frame->add($label);
$frame->addChild($label);
$label->setY($posY);
$label->setText('Revoke Rights');
$label->setTextColor('700');

View File

@ -10,6 +10,8 @@ use ManiaControl\Callbacks\TimerListener;
use ManiaControl\Communication\CommunicationAnswer;
use ManiaControl\Communication\CommunicationListener;
use ManiaControl\Communication\CommunicationMethods;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Statistics\StatisticManager;
@ -23,7 +25,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerManager implements CallbackListener, TimerListener, CommunicationListener {
class PlayerManager implements CallbackListener, TimerListener, CommunicationListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/

View File

@ -53,14 +53,14 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
*/
public static function getTitle() {
return 'Install Plugins';
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/
public function getMenu($width, $height, Script $script, Player $player) {
$paging = new Paging();
@ -82,37 +82,36 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
if (!is_array($pluginList)) {
// Error text
$errorFrame = $this->getErrorFrame();
$frame->add($errorFrame);
$frame->addChild($errorFrame);
} else if (empty($pluginList)) {
// Empty text
$emptyFrame = $this->getEmptyFrame();
$frame->add($emptyFrame);
$frame->addChild($emptyFrame);
} else {
// Build plugin list
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$frame->addChild($pagerPrev);
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
$pagerNext = clone $pagerPrev;
$frame->add($pagerNext);
$frame->addChild($pagerNext);
$pagerNext->setX($width * 0.45);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)->setPosition($width * 0.35, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(2);
$frame->addChild($pageCountLabel);
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT)->setPosition($width * 0.35, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(2);
$paging->addButton($pagerNext)->addButton($pagerPrev)->setLabel($pageCountLabel);
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
// Info tooltip
$infoTooltipLabel = new Label();
$frame->add($infoTooltipLabel);
$frame->addChild($infoTooltipLabel);
$infoTooltipLabel->setAlign($infoTooltipLabel::LEFT, $infoTooltipLabel::TOP)->setPosition($width * -0.45, $height * -0.22)->setSize($width * 0.7, $entryHeight)->setTextSize(1)->setTranslate(true)->setVisible(false)->setAutoNewLine(true)->setMaxLines(5);
// List plugins
foreach ($pluginList as $plugin) {
if ($this->maniaControl->getPluginManager()->isPluginIdInstalled($plugin->id)
) {
if ($this->maniaControl->getPluginManager()->isPluginIdInstalled($plugin->id)) {
// Already installed -> Skip
continue;
}
@ -120,27 +119,28 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
if ($index % 10 === 0) {
// New page
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$frame->addChild($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height * 0.41;
}
$pluginFrame = new Frame();
$pageFrame->add($pluginFrame);
$pageFrame->addChild($pluginFrame);
$pluginFrame->setY($posY);
$nameLabel = new Label_Text();
$pluginFrame->add($nameLabel);
$nameLabel->setHAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.62, $entryHeight)->setStyle($nameLabel::STYLE_TextCardSmall)->setTextSize(2)->setText($plugin->name);
$pluginFrame->addChild($nameLabel);
$nameLabel->setHorizontalAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.62, $entryHeight)->setStyle($nameLabel::STYLE_TextCardSmall)->setTextSize(2)->setText($plugin->name);
$description = "Author: {$plugin->author}\nVersion: {$plugin->currentVersion->version}\nDesc: {$plugin->description}";
$infoTooltipLabel->setLineSpacing(1);
$nameLabel->addTooltipLabelFeature($infoTooltipLabel, $description);
if (!$this->isPluginCompatible($plugin)) {
// Incompatibility label
$infoLabel = new Label_Text();
$pluginFrame->add($infoLabel);
$infoLabel->setHAlign($infoLabel::RIGHT)->setX($width * 0.47)->setSize($width * 0.33, $entryHeight)->setTextSize(1)->setTextColor('f30');
$pluginFrame->addChild($infoLabel);
$infoLabel->setHorizontalAlign($infoLabel::RIGHT)->setX($width * 0.47)->setSize($width * 0.33, $entryHeight)->setTextSize(1)->setTextColor('f30');
if ($plugin->currentVersion->min_mc_version > ManiaControl::VERSION) {
$infoLabel->setText("Needs at least MC-Version '{$plugin->currentVersion->min_mc_version}'");
} else {
@ -149,14 +149,14 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
} else {
// Install button
$installButton = new Label_Button();
$pluginFrame->add($installButton);
$installButton->setHAlign($installButton::RIGHT)->setX($width * 0.47)->setStyle($installButton::STYLE_CardButtonSmall)->setText('Install')->setTranslate(true)->setAction(self::ACTION_PREFIX_INSTALL_PLUGIN . $plugin->id);
$pluginFrame->addChild($installButton);
$installButton->setHorizontalAlign($installButton::RIGHT)->setX($width * 0.47)->setStyle($installButton::STYLE_CardButtonSmall)->setText('Install')->setTranslate(true)->setAction(self::ACTION_PREFIX_INSTALL_PLUGIN . $plugin->id);
}
if ($plugin->currentVersion->verified > 0) {
// Suggested quad
$suggestedQuad = new Quad_Icons64x64_1();
$pluginFrame->add($suggestedQuad);
$pluginFrame->addChild($suggestedQuad);
$suggestedQuad->setPosition($width * 0.45, $entryHeight * 0.12, 2)->setSize(4, 4)->setSubStyle($suggestedQuad::SUBSTYLE_StateSuggested);
}
@ -177,11 +177,11 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
$frame = new Frame();
$infoLabel = new Label_Text();
$frame->add($infoLabel);
$infoLabel->setVAlign($infoLabel::BOTTOM)->setY(2)->setSize(100, 25)->setTextColor('f30')->setTranslate(true)->setText('An error occurred. Please try again later.');
$frame->addChild($infoLabel);
$infoLabel->setVerticalAlign($infoLabel::BOTTOM)->setY(2)->setSize(100, 25)->setTextColor('f30')->setTranslate(true)->setText('An error occurred. Please try again later.');
$refreshQuad = new Quad_Icons64x64_1();
$frame->add($refreshQuad);
$frame->addChild($refreshQuad);
$refreshQuad->setY(-4)->setSize(8, 8)->setSubStyle($refreshQuad::SUBSTYLE_Refresh)->setAction(self::ACTION_REFRESH_LIST);
return $frame;
@ -196,7 +196,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
$frame = new Frame();
$infoLabel = new Label_Text();
$frame->add($infoLabel);
$frame->addChild($infoLabel);
$infoLabel->setSize(100, 50)->setTextColor('0f3')->setTranslate(true)->setText('No other plugins available.');
return $frame;
@ -221,7 +221,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
* @see \ManiaControl\Configurator\ConfiguratorMenu::saveConfigData()
*/
public function saveConfigData(array $configData, Player $player) {
}

View File

@ -6,6 +6,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\EchoListener;
use ManiaControl\Callbacks\TimerListener;
use ManiaControl\Commands\CommandListener;
use ManiaControl\Files\AsyncHttpRequest;
use ManiaControl\Files\FileUtil;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
@ -478,9 +479,14 @@ class PluginManager {
*/
public function fetchPluginList(callable $function) {
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
$this->maniaControl->getFileReader()->loadFile($url, function ($dataJson, $error) use (&$function) {
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $url);
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
$asyncHttpRequest->setCallable(function ($dataJson, $error) use (&$function) {
$data = json_decode($dataJson);
call_user_func($function, $data, $error);
});
$asyncHttpRequest->getData();
}
}

View File

@ -69,7 +69,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
*/
public static function getTitle() {
return 'Plugins';
@ -87,7 +87,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/
public function getMenu($width, $height, Script $script, Player $player) {
$paging = new Paging();
@ -103,23 +103,23 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$frame->addChild($pagerPrev);
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
$pagerPrev->setSize($pagerSize, $pagerSize);
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
$pagerNext = new Quad_Icons64x64_1();
$frame->add($pagerNext);
$frame->addChild($pagerNext);
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
$paging->addButtonControl($pagerNext);
$paging->addButtonControl($pagerPrev);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT);
$frame->addChild($pageCountLabel);
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
$pageCountLabel->setTextSize(2);
@ -148,19 +148,19 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
/** @var Plugin $pluginClass */
if ($index % $pageMaxCount === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$frame->addChild($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height * 0.41;
}
$active = $this->maniaControl->getPluginManager()->isPluginActive($pluginClass);
$pluginFrame = new Frame();
$pageFrame->add($pluginFrame);
$pageFrame->addChild($pluginFrame);
$pluginFrame->setY($posY);
$activeQuad = new Quad_Icons64x64_1();
$pluginFrame->add($activeQuad);
$pluginFrame->addChild($activeQuad);
$activeQuad->setPosition($width * -0.45, -0.1, 1);
$activeQuad->setSize($entryHeight * 0.9, $entryHeight * 0.9);
if ($active) {
@ -170,8 +170,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
}
$nameLabel = new Label_Text();
$pluginFrame->add($nameLabel);
$nameLabel->setHAlign($nameLabel::LEFT);
$pluginFrame->addChild($nameLabel);
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
$nameLabel->setX($width * -0.4);
$nameLabel->setSize($width * 0.5, $entryHeight);
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
@ -179,21 +179,20 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$nameLabel->setText($pluginClass::getName());
$descriptionLabel = new Label();
$pageFrame->add($descriptionLabel);
$pageFrame->addChild($descriptionLabel);
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP);
$descriptionLabel->setPosition($width * -0.45, $height * -0.22);
$descriptionLabel->setSize($width * 0.7, $entryHeight);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setTranslate(true);
$descriptionLabel->setVisible(false);
$descriptionLabel->setAutoNewLine(true);
$descriptionLabel->setMaxLines(5);
$descriptionLabel->setLineSpacing(1);
$description = "Author: {$pluginClass::getAuthor()}\nVersion: {$pluginClass::getVersion()}\nDesc: {$pluginClass::getDescription()}";
$descriptionLabel->setText($description);
$nameLabel->addTooltipFeature($descriptionLabel);
$nameLabel->addTooltipLabelFeature($descriptionLabel,$description);
$quad = new Quad_Icons128x32_1();
$pluginFrame->add($quad);
$pluginFrame->addChild($quad);
$quad->setSubStyle($quad::SUBSTYLE_Settings);
$quad->setX(15);
$quad->setZ(1);
@ -201,8 +200,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$quad->setAction(self::ACTION_PREFIX_SETTINGS . $pluginClass);
$statusChangeButton = new Label_Button();
$pluginFrame->add($statusChangeButton);
$statusChangeButton->setHAlign($statusChangeButton::RIGHT);
$pluginFrame->addChild($statusChangeButton);
$statusChangeButton->setHorizontalAlign($statusChangeButton::RIGHT);
$statusChangeButton->setX($width * 0.45);
$statusChangeButton->setStyle($statusChangeButton::STYLE_CardButtonSmall);
if ($active) {
@ -217,7 +216,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
if ($pluginUpdates && array_key_exists($pluginClass::getId(), $pluginUpdates)) {
$quadUpdate = new Quad_Icons128x128_1();
$pluginFrame->add($quadUpdate);
$pluginFrame->addChild($quadUpdate);
$quadUpdate->setSubStyle($quadUpdate::SUBSTYLE_ProfileVehicle);
$quadUpdate->setX(56);
$quadUpdate->setZ(2);
@ -230,8 +229,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
if ($pluginUpdates) {
$updatePluginsButton = new Label_Button();
$frame->add($updatePluginsButton);
$updatePluginsButton->setHAlign($updatePluginsButton::RIGHT);
$frame->addChild($updatePluginsButton);
$updatePluginsButton->setHorizontalAlign($updatePluginsButton::RIGHT);
$updatePluginsButton->setPosition($width * 0.5, -29, 2);
$updatePluginsButton->setWidth(10);
$updatePluginsButton->setStyle($updatePluginsButton::STYLE_CardButtonSmallS);
@ -265,8 +264,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
//Headline Label
$headLabel = new Label_Text();
$frame->add($headLabel);
$headLabel->setHAlign($headLabel::LEFT);
$frame->addChild($headLabel);
$headLabel->setHorizontalAlign($headLabel::LEFT);
$headLabel->setPosition($width * -0.46, $height * 0.41);
$headLabel->setSize($width * 0.6, $settingHeight);
$headLabel->setStyle($headLabel::STYLE_TextCardSmall);
@ -277,18 +276,18 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
foreach ($settings as $setting) {
if ($index % $pageSettingsMaxCount === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
$paging->addPage($pageFrame);
$frame->addChild($pageFrame);
$paging->addPageControl($pageFrame);
$posY = $height * 0.41 - $settingHeight * 1.5;
}
$settingFrame = new Frame();
$pageFrame->add($settingFrame);
$pageFrame->addChild($settingFrame);
$settingFrame->setY($posY);
$nameLabel = new Label_Text();
$settingFrame->add($nameLabel);
$nameLabel->setHAlign($nameLabel::LEFT);
$settingFrame->addChild($nameLabel);
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
$nameLabel->setX($width * -0.46);
$nameLabel->setSize($width * 0.6, $settingHeight);
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
@ -302,7 +301,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$quad->setPosition($width * 0.33, 0, -0.01);
$quad->setSize(4, 4);
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $setting->index, $setting->value, $quad);
$settingFrame->add($checkBox);
$settingFrame->addChild($checkBox);
} else if ($setting->type === Setting::TYPE_SET) {
// SET value picker
$label = new Label_Text();
@ -311,11 +310,11 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$label->setStyle($label::STYLE_TextValueSmall);
$label->setTextSize(1);
$valuePicker = new ValuePicker(self::ACTION_PREFIX_SETTING . $setting->index, $setting->set, $setting->value, $label);
$settingFrame->add($valuePicker);
$settingFrame->addChild($valuePicker);
} else {
// Value entry
$entry = new Entry();
$settingFrame->add($entry);
$settingFrame->addChild($entry);
$entry->setX($width * 0.33);
$entry->setSize($width * 0.3, $settingHeight * 0.9);
$entry->setTextSize(1);
@ -330,9 +329,9 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
}
$backButton = new Label_Button();
$frame->add($backButton);
$frame->addChild($backButton);
$backButton->setStyle($backButton::STYLE_CardMain_Quit);
$backButton->setHAlign($backButton::LEFT);
$backButton->setHorizontalAlign($backButton::LEFT);
$backButton->setScale(0.75);
$backButton->setText('Back');
$backButton->setPosition(-$width / 2 + 7, -$height / 2 + 7);
@ -392,7 +391,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
* @see \ManiaControl\Configurator\ConfiguratorMenu::saveConfigData()
*/
public function saveConfigData(array $configData, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS)

View File

@ -0,0 +1,235 @@
<?php
/**
* Manager for Mode Script Events
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
namespace ManiaControl\Script;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
class ModeScriptEventManager implements UsageInformationAble {
use UsageInformationTrait;
const API_VERSION = "2.0.0";
/** @var ManiaControl $maniaControl */
private $maniaControl;
/**
* Construct a new ranking manager instance
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
}
/**
* Enables XmlRpc Callbacks
*/
public function enableCallbacks() {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true'));
$this->setApiVersion(self::API_VERSION);
}
/**
* Disables XmlRpc Callbacks
*/
public function disableCallbacks() {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('false'));
}
/**
* Request a list of all available callbacks. This method will trigger the "XmlRpc.CallbacksList" callback.
*
* @param string $responseId
*/
public function getCallbacksList($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList', array($responseId));
}
/**
* Request a list of all enabled callbacks. This method will trigger the "XmlRpc.CallbacksList_Enabled" callback.
*
* @param string $responseId
*/
public function getListOfEnabledCallbacks($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList_Enabled', array($responseId));
}
/**
* Request a list of all disabled callbacks. This method will trigger the "XmlRpc.CallbacksList_Enabled" callback.
*
* @param string $responseId
*/
public function getListOfDisabledCallbacks($responseId) {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList_Disabled', array($responseId));
}
/**
* Description: Request help about a callback. This method will trigger the "XmlRpc.CallbackHelp" callback.
*
* @param $callbackName
* @param string $responseId
*/
public function getCallbackHelp($callbackName, $responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbackHelp', array($callbackName, $responseId));
}
/**
* Request a list of all available methods. This method will trigger the "XmlRpc.MethodsList" callback.s
*
* @param string $responseId
*/
public function getMethodsList($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetMethodsList', array($responseId));
}
/**
* Sets the Api Version
*
* @param string $version
*/
public function setApiVersion($version = self::API_VERSION) {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.SetApiVersion', array($version));
}
/**
* Gets the Api Version
*
* @param string $version
*/
public function getApiVersion($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetApiVersion', array($responseId));
}
/**
* Request help about a method. This method will trigger the "XmlRpc.MethodHelp" callback.
*
* @param $callbackName
* @param string $responseId
*/
public function getMethodHelp($methodName, $responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetMethodHelp', array($methodName, $responseId));
}
/**
* Request the current game mode xmlrpc callbacks and methods documentation. This method will trigger the "XmlRpc.Documentation" callback.
*
* @param string $responseId
*/
public function getDocumentation($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetDocumentation', array($responseId));
}
/**
* Gets a List of All Api Version
*
* @param string $responseId
*/
public function getAllApiVersions($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetAllApiVersions', array($responseId));
}
/**
* Request the current scores. This method will trigger the "Shootmania.Scores" callback.
*
* @param string $responseId
*/
public function getShootmaniaScores($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetScores', array($responseId));
}
/**
* Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback.
*
* @param string $responseId
*/
public function getShootmaniaUIProperties($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetUIProperties', array($responseId));
}
/**
* Update the ui properties.
*
* @param string Json-Encoded Xml UI Property String
*/
public function setShootmaniaUIProperties($properties) {
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetUIProperties', array($properties));
}
/**
* Request the current scores. This method will trigger the "Trackmania.Scores" callback.
*
* @param string $responseId
*/
public function getTrackmaniaScores($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetScores', array($responseId));
}
/**
* Request the current points repartition. This method will trigger the "Trackmania.PointsRepartition" callback.
*
* @param string $responseId
*/
public function getTrackmaniaPointsRepartition($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetPointsRepartition', array($responseId));
}
/**
* Update the points repartition.
*
* @param array String Array of Points
*/
public function setTrackmaniaPointsRepartition($pointArray) {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetPointsRepartition', array($pointArray));
}
/**
* Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback.
*
* @param string $responseId
*/
public function getTrackmaniaUIProperties($responseId = "DefaultResponseId") {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetUIProperties', array($responseId));
}
/**
* Update the ui properties.
*
* @param string Json-Encoded Xml UI Property String
*/
public function setTrackmaniaUIProperties($properties) {
$this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetUIProperties', array($properties));
}
/**
* Stop the whole warm up sequence.
*/
public function stopTrackmaniaWarmup() {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.WarmUp.Stop');
}
/**
* Stop the current warm up round.
*/
public function stopTrackmaniaRound() {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.WarmUp.StopRound');
}
/**
* Stop the current round. Only available in Cup, Rounds and Team modes.
*/
public function forceTrackmaniaRoundEnd() {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.ForceEndRound');
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace ManiaControl\Script;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
/**
* Manager for Game Mode Script related Stuff
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptManager implements UsageInformationAble {
use UsageInformationTrait;
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
private $isScriptMode = null;
/**
* Construct a new script manager instance
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
}
/**
* Enable script callbacks
*
* @param bool $enable
* @return bool
*/
public function enableScriptCallbacks() {
if (!$this->isScriptMode()) {
return false;
}
try {
$scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings();
} catch (GameModeException $e) {
var_dump("test");
return false;
}
//TODO remove later, than only the last 2 lines are needed in future
if (array_key_exists('S_UseScriptCallbacks', $scriptSettings)) {
$scriptSettings['S_UseScriptCallbacks'] = true;
$this->maniaControl->getClient()->setModeScriptSettings($scriptSettings);
}
$this->maniaControl->getModeScriptEventManager()->enableCallbacks();
Logger::logInfo("Script Callbacks successfully enabled!");
return true;
}
/**
* Check whether the Server is running in Script Mode
*
* @return bool
*/
public function isScriptMode() {
if (is_null($this->isScriptMode)) {
$gameMode = $this->maniaControl->getClient()->getGameMode();
$this->isScriptMode = ($gameMode === 0);
}
return $this->isScriptMode;
}
}

View File

@ -5,6 +5,8 @@ namespace ManiaControl\Server;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Files\FileUtil;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
/**
@ -14,7 +16,9 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Directory implements CallbackListener {
class Directory implements CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Private properties
*/

View File

@ -5,6 +5,8 @@ namespace ManiaControl\Server;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Maps\Map;
use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
@ -16,7 +18,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class RankingManager implements CallbackListener {
class RankingManager implements CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Private properties
*/

View File

@ -1,74 +1,4 @@
<?php
// Self Destroy due moving (added 26.03.2017, remove later)
unlink(__FILE__);
namespace ManiaControl\Server;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
/**
* Manager for Game Mode Script related Stuff
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptManager {
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
private $isScriptMode = null;
/**
* Construct a new script manager instance
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
}
/**
* Enable script callbacks
*
* @param bool $enable
* @return bool
*/
public function enableScriptCallbacks($enable = true) {
if (!$this->isScriptMode()) {
return false;
}
try {
$scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings();
} catch (GameModeException $e) {
return false;
}
if (!array_key_exists('S_UseScriptCallbacks', $scriptSettings)) {
return false;
}
$scriptSettings['S_UseScriptCallbacks'] = (bool) $enable;
$actionName = ($enable ? 'en' : 'dis');
$this->maniaControl->getClient()->setModeScriptSettings($scriptSettings);
Logger::logInfo("Script Callbacks successfully {$actionName}abled!");
return true;
}
/**
* Check whether the Server is running in Script Mode
*
* @return bool
*/
public function isScriptMode() {
if (is_null($this->isScriptMode)) {
$gameMode = $this->maniaControl->getClient()->getGameMode();
$this->isScriptMode = ($gameMode === 0);
}
return $this->isScriptMode;
}
}

View File

@ -5,9 +5,12 @@ namespace ManiaControl\Server;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Commands\CommandListener;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use ManiaControl\Script\ScriptManager;
use ManiaControl\Utils\CommandLineHelper;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
@ -18,7 +21,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Server implements CallbackListener, CommandListener {
class Server implements CallbackListener, CommandListener, UsageInformationAble {
use UsageInformationTrait;
/*
* Constants
*/
@ -56,7 +61,7 @@ class Server implements CallbackListener, CommandListener {
* @see getRankingManager()
*/
public $rankingManager = null;
/** @var ScriptManager $scriptManager
/** @var \ManiaControl\Script\ScriptManager $scriptManager
* @deprecated
* @see getScriptManager()
*/
@ -178,7 +183,7 @@ class Server implements CallbackListener, CommandListener {
/**
* Return the script manager
*
* @return ScriptManager
* @return \ManiaControl\Script\ScriptManager
*/
public function getScriptManager() {
return $this->scriptManager;

Some files were not shown because too many files have changed in this diff Show More