From 795df0ed2c7d920feb51fb5c0f1e007a5172b4ea Mon Sep 17 00:00:00 2001 From: W1lla van den Munckhof Date: Wed, 22 Mar 2017 11:14:15 +0100 Subject: [PATCH 01/73] Update Callbacks.php Added WayPoint Callback for TrackMania. --- core/Callbacks/Callbacks.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index cb9d76c0..24559956 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -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; /** @@ -124,14 +126,14 @@ interface Callbacks { * TrackMania Callbacks */ /** OnStartLine Callback */ - const ONSTARTLINE = 'Callbacks.OnStartLine'; + const STARTLINE = 'Callbacks.StartLine'; /** OnWayPoint Callback */ - const ONWAYPOINT = 'Callbacks.OnWayPoint'; + const WAYPOINT = 'Callbacks.WayPoint'; /** OnGiveUp Callback */ - const ONGIVEUP = 'Callbacks.OnGiveUp'; + const GIVEUP = 'Callbacks.GiveUp'; /** OnRespawn Callback */ - const ONRESPAWN = 'Callbacks.OnRespawn'; + const ONRESPAWN = 'Callbacks.Respawn'; /** OnStunt Callback */ - const ONSTUNT = 'Callbacks.OnStunt'; + const STUNT = 'Callbacks.Stunt'; } From df2d54875522203ceeb2aaa60ac63084f4d10ee4 Mon Sep 17 00:00:00 2001 From: W1lla van den Munckhof Date: Wed, 22 Mar 2017 11:15:52 +0100 Subject: [PATCH 02/73] Update ScriptManager.php Added XmlRpc.EnableCallbacks for TrackMania aswell as Shootmania. --- core/Server/ScriptManager.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/core/Server/ScriptManager.php b/core/Server/ScriptManager.php index beec41eb..177ddbe0 100644 --- a/core/Server/ScriptManager.php +++ b/core/Server/ScriptManager.php @@ -47,15 +47,8 @@ class ScriptManager { 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!"); + $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true')); + Logger::logInfo("Script Callbacks successfully enabled!"); return true; } From 60524e924435d1845d112c7ce496e0b8d312892a Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 22 Mar 2017 17:57:21 +0100 Subject: [PATCH 03/73] structural changes for v0.2 --- core/ManiaControl.php | 62 ++++++++++++++++---------- core/Server/ModeScriptEventManager.php | 41 +++++++++++++++++ core/Server/ScriptManager.php | 4 +- 3 files changed, 83 insertions(+), 24 deletions(-) create mode 100644 core/Server/ModeScriptEventManager.php diff --git a/core/ManiaControl.php b/core/ManiaControl.php index a32be38a..dd28a694 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -26,6 +26,7 @@ use ManiaControl\Maps\MapManager; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\PluginManager; +use ManiaControl\Server\ModeScriptEventManager; use ManiaControl\Server\Server; use ManiaControl\Settings\SettingManager; use ManiaControl\Statistics\StatisticManager; @@ -47,11 +48,11 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.166'; + const VERSION = '0.200'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2014-04-02_18_00'; const SCRIPT_TIMEOUT = 10; - const URL_WEBSERVICE = 'https://ws.maniacontrol.com/'; + const URL_WEBSERVICE = 'http://ws.maniacontrol.com/'; const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl'; const SETTING_PERMISSION_RESTART = 'Restart ManiaControl'; @@ -170,9 +171,14 @@ 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; + /** * Construct a new ManiaControl instance */ @@ -184,26 +190,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 +474,13 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, return $this->billManager; } + /** + * @return ModeScriptEventManager + */ + public function getModeScriptEventManager() { + return $this->modeScriptEventManager; + } + /** * Check connection */ @@ -699,4 +713,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, public function handleServerStopCallback() { $this->requestQuit('The Server has been shut down!'); } + + } diff --git a/core/Server/ModeScriptEventManager.php b/core/Server/ModeScriptEventManager.php new file mode 100644 index 00000000..500d78ae --- /dev/null +++ b/core/Server/ModeScriptEventManager.php @@ -0,0 +1,41 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +namespace ManiaControl\Server; + +//TODO maybe own folder + +use ManiaControl\ManiaControl; + +class ModeScriptEventManager { + /** @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')); + } + + /** + * Disables XmlRpc Callbacks + */ + public function disableCallbacks() { + $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('false')); + } +} \ No newline at end of file diff --git a/core/Server/ScriptManager.php b/core/Server/ScriptManager.php index 177ddbe0..a6e232e2 100644 --- a/core/Server/ScriptManager.php +++ b/core/Server/ScriptManager.php @@ -47,7 +47,9 @@ class ScriptManager { return false; } - $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true')); + //TODO verify that the old S_ isnt needed anymore + + $this->maniaControl->getModeScriptEventManager()->enableCallbacks(); Logger::logInfo("Script Callbacks successfully enabled!"); return true; } From ba86708e22f5a06dee6f363199cb6371bce8f5e7 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 22 Mar 2017 18:00:17 +0100 Subject: [PATCH 04/73] https mistake --- core/ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index dd28a694..98c07d41 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -52,7 +52,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2014-04-02_18_00'; const SCRIPT_TIMEOUT = 10; - const URL_WEBSERVICE = 'http://ws.maniacontrol.com/'; + const URL_WEBSERVICE = 'https://ws.maniacontrol.com/'; const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl'; const SETTING_PERMISSION_RESTART = 'Restart ManiaControl'; From 496039a6276e7da3dfad16c2bb07f89a681a8822 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 22 Mar 2017 18:10:21 +0100 Subject: [PATCH 05/73] added draft of new callback structure (made example) --- core/Callbacks/Callbacks.php | 14 +++-- core/Callbacks/LibXmlRpcCallbacks.php | 6 +++ .../ManiaPlanet/CallbacksListStructure.php | 53 +++++++++++++++++++ .../Trackmania/DefaultEventStructure.php | 14 +++++ 4 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php create mode 100644 core/Callbacks/Structures/Trackmania/DefaultEventStructure.php diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 24559956..df8cc2bb 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -28,6 +28,12 @@ interface Callbacks { /* * Common Callbacks */ + //NEW Callbacks + + const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; + + + //OLD Callbacks /** BeginMatch Callback: MatchNumber */ const BEGINMATCH = 'Callbacks.BeginMatch'; /** LoadingMap Callback: MapNumber */ @@ -126,14 +132,14 @@ interface Callbacks { * TrackMania Callbacks */ /** OnStartLine Callback */ - const STARTLINE = 'Callbacks.StartLine'; + const ONSTARTLINE = 'Callbacks.StartLine'; /** OnWayPoint Callback */ - const WAYPOINT = 'Callbacks.WayPoint'; + const ONWAYPOINT = 'Callbacks.WayPoint'; /** OnGiveUp Callback */ - const GIVEUP = 'Callbacks.GiveUp'; + const ONGIVEUP = 'Callbacks.GiveUp'; /** OnRespawn Callback */ const ONRESPAWN = 'Callbacks.Respawn'; /** OnStunt Callback */ - const STUNT = 'Callbacks.Stunt'; + const ONSTUNT = 'Callbacks.Stunt'; } diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 7e4008c9..3526fcac 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -4,6 +4,7 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Structures\ArmorEmptyStructure; use ManiaControl\Callbacks\Structures\CaptureStructure; +use ManiaControl\Callbacks\Structures\ManiaPlanet\CallbacksListStructure; use ManiaControl\Callbacks\Structures\NearMissStructure; use ManiaControl\Callbacks\Structures\PlayerHitStructure; use ManiaControl\ManiaControl; @@ -42,6 +43,11 @@ class LibXmlRpcCallbacks implements CallbackListener { */ public function handleScriptCallback($name, $data) { switch ($name) { + //New callbacks + case 'XmlRpc.CallbacksList': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data)); + break; + //OLD Callbacks case 'LibXmlRpc_BeginMatch': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]); break; diff --git a/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php b/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php new file mode 100644 index 00000000..00750ef5 --- /dev/null +++ b/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php @@ -0,0 +1,53 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class CallbacksListStructure { + /** @var string $responseId */ + private $responseId; + /** @var array $callbacks */ + private $callbacks; + + /** @var ManiaControl $maniaControl */ + private $maniaControl; + + /** + * Construct a new Armor Empty Structure + * + * @param ManiaControl $maniaControl + * @param array $data + */ + public function __construct(ManiaControl $maniaControl, $data) { + $this->maniaControl = $maniaControl; + + //Not tested yet, TODO test + $json = json_decode($data); + + $this->responseId = $json->responseId; + $this->callbacks = $json->callbacks; + } + + /** + * @return string + */ + public function getResponseId() { + return $this->responseId; + } + + /** + * @return array + */ + public function getCallbacks() { + return $this->callbacks; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php b/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php new file mode 100644 index 00000000..2a3fd4e0 --- /dev/null +++ b/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php @@ -0,0 +1,14 @@ + Date: Wed, 22 Mar 2017 18:21:33 +0100 Subject: [PATCH 06/73] test for api version --- core/Callbacks/LibXmlRpcCallbacks.php | 1 + core/Server/ModeScriptEventManager.php | 27 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 3526fcac..ea461701 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -42,6 +42,7 @@ class LibXmlRpcCallbacks implements CallbackListener { * @param mixed $data */ public function handleScriptCallback($name, $data) { + var_dump($name); switch ($name) { //New callbacks case 'XmlRpc.CallbacksList': diff --git a/core/Server/ModeScriptEventManager.php b/core/Server/ModeScriptEventManager.php index 500d78ae..6ff4db65 100644 --- a/core/Server/ModeScriptEventManager.php +++ b/core/Server/ModeScriptEventManager.php @@ -30,6 +30,13 @@ class ModeScriptEventManager { */ public function enableCallbacks() { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true')); + + $this->setApiVersion(); + + $this->getAllApiVersions(); + + $this->getCallbacksList(); //TODO verify why this does not work + var_dump("test"); } /** @@ -38,4 +45,24 @@ class ModeScriptEventManager { public function disableCallbacks() { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('false')); } + + /** + * @param string $responseId + * Triggers a Callback List Callback + */ + public function getCallbacksList($responseId = "DefaultResponseId"){ + $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList', array($responseId)); + } + + /** + * Sets the Api Version + * @param string $version + */ + public function setApiVersion($version = "1.2.3-beta.4.5.6+build789"){ //TODO constant of API Versions + $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.SetApiVersion', array($version)); + } + + public function getAllApiVersions($responseId = "DefaultResponseId"){ + $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetAllApiVersions', array($responseId)); + } } \ No newline at end of file From 4ab3bf765085f7b50d5d8e699f76906608ce7b63 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 22 Mar 2017 18:31:53 +0100 Subject: [PATCH 07/73] added abstract basestructure class above all callback structures --- core/Callbacks/Structures/BaseStructure.php | 25 +++++++++++++++++++ .../ManiaPlanet/CallbacksListStructure.php | 6 ++--- .../Trackmania/DefaultEventStructure.php | 4 ++- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 core/Callbacks/Structures/BaseStructure.php diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php new file mode 100644 index 00000000..8eb64e08 --- /dev/null +++ b/core/Callbacks/Structures/BaseStructure.php @@ -0,0 +1,25 @@ + Date: Wed, 22 Mar 2017 19:12:38 +0100 Subject: [PATCH 08/73] new callbacks are only supported in some modes, so leave backwards compatiblity in --- core/Server/ScriptManager.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/Server/ScriptManager.php b/core/Server/ScriptManager.php index a6e232e2..ef8c0727 100644 --- a/core/Server/ScriptManager.php +++ b/core/Server/ScriptManager.php @@ -36,7 +36,7 @@ class ScriptManager { * @param bool $enable * @return bool */ - public function enableScriptCallbacks($enable = true) { + public function enableScriptCallbacks() { if (!$this->isScriptMode()) { return false; } @@ -47,7 +47,14 @@ class ScriptManager { return false; } - //TODO verify that the old S_ isnt needed anymore + //TODO remove later, than only the last 2 lines are needed in future + if (!array_key_exists('S_UseScriptCallbacks', $scriptSettings)) { + return false; + } + $scriptSettings['S_UseScriptCallbacks'] = true; + $this->maniaControl->getClient()->setModeScriptSettings($scriptSettings); + + $this->maniaControl->getModeScriptEventManager()->enableCallbacks(); Logger::logInfo("Script Callbacks successfully enabled!"); From 2faa78c8e2f0eea75e0f2a2d7fe90b213dbbeeb2 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 23 Mar 2017 20:39:32 +0100 Subject: [PATCH 09/73] advanced callback structure --- ManiaControl.php | 2 +- core/Callbacks/LibXmlRpcCallbacks.php | 1 + core/Callbacks/Structures/BaseStructure.php | 28 ++++++++++++++++++- .../ManiaPlanet/CallbacksListStructure.php | 14 +++++----- core/Server/ModeScriptEventManager.php | 7 +++-- core/Server/ScriptManager.php | 10 +++---- 6 files changed, 44 insertions(+), 18 deletions(-) diff --git a/ManiaControl.php b/ManiaControl.php index 2fbfe8ae..0b4e7035 100644 --- a/ManiaControl.php +++ b/ManiaControl.php @@ -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 diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index ea461701..8bf4c68c 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -43,6 +43,7 @@ class LibXmlRpcCallbacks implements CallbackListener { */ public function handleScriptCallback($name, $data) { var_dump($name); + //var_dump($data); switch ($name) { //New callbacks case 'XmlRpc.CallbacksList': diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index 8eb64e08..71eb228b 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -14,12 +14,38 @@ use ManiaControl\ManiaControl; abstract class BaseStructure { /** @var ManiaControl $maniaControl */ protected $maniaControl; + private $plainJson; + /** + * Sets ManiaControl + * + * @param \ManiaControl\ManiaControl $maniaControl + */ + protected function setManiaControl(ManiaControl $maniaControl) { + $this->maniaControl = $maniaControl; + } + + /** + * Decodes the Data and Sets the Json + * + * @param array $data + */ + protected function setJson($data) { + $this->plainJson = json_decode($data[0]); + } + + /** + * Gets the Plain Json + */ + public function getJson() { + return $this->plainJson; + } + /** * Var_Dump the Structure */ public function dump() { + var_dump($this->getJson()); var_dump(json_decode(json_encode($this))); } - } \ No newline at end of file diff --git a/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php b/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php index ac767ab1..3e936746 100644 --- a/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php @@ -14,9 +14,9 @@ use ManiaControl\ManiaControl; */ class CallbacksListStructure extends BaseStructure { /** @var string $responseId */ - private $responseId; + public $responseId; /** @var array $callbacks */ - private $callbacks; + public $callbacks; /** * Construct a new Armor Empty Structure @@ -25,13 +25,13 @@ class CallbacksListStructure extends BaseStructure { * @param array $data */ public function __construct(ManiaControl $maniaControl, $data) { - $this->maniaControl = $maniaControl; + parent::setManiaControl($maniaControl); + parent::setJson($data); - //Not tested yet, TODO test - $json = json_decode($data); + $this->responseId = $this->getJson()->responseid; + $this->callbacks = $this->getJson()->callbacks; - $this->responseId = $json->responseId; - $this->callbacks = $json->callbacks; + //$this->dump(); } /** diff --git a/core/Server/ModeScriptEventManager.php b/core/Server/ModeScriptEventManager.php index 6ff4db65..2d18b6ba 100644 --- a/core/Server/ModeScriptEventManager.php +++ b/core/Server/ModeScriptEventManager.php @@ -13,6 +13,8 @@ namespace ManiaControl\Server; use ManiaControl\ManiaControl; class ModeScriptEventManager { + const API_VERSION = "2.0.0"; + /** @var ManiaControl $maniaControl */ private $maniaControl; @@ -31,12 +33,11 @@ class ModeScriptEventManager { public function enableCallbacks() { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true')); - $this->setApiVersion(); + $this->setApiVersion(self::API_VERSION); $this->getAllApiVersions(); $this->getCallbacksList(); //TODO verify why this does not work - var_dump("test"); } /** @@ -58,7 +59,7 @@ class ModeScriptEventManager { * Sets the Api Version * @param string $version */ - public function setApiVersion($version = "1.2.3-beta.4.5.6+build789"){ //TODO constant of API Versions + public function setApiVersion($version = self::API_VERSION){ $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.SetApiVersion', array($version)); } diff --git a/core/Server/ScriptManager.php b/core/Server/ScriptManager.php index ef8c0727..f980fe68 100644 --- a/core/Server/ScriptManager.php +++ b/core/Server/ScriptManager.php @@ -44,17 +44,15 @@ class ScriptManager { 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)) { - return false; + if (array_key_exists('S_UseScriptCallbacks', $scriptSettings)) { + $scriptSettings['S_UseScriptCallbacks'] = true; + $this->maniaControl->getClient()->setModeScriptSettings($scriptSettings); } - $scriptSettings['S_UseScriptCallbacks'] = true; - $this->maniaControl->getClient()->setModeScriptSettings($scriptSettings); - - $this->maniaControl->getModeScriptEventManager()->enableCallbacks(); Logger::logInfo("Script Callbacks successfully enabled!"); From ca5dd279c132daa351d70ea3bc6a6d49c9b0ba08 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 23 Mar 2017 20:43:23 +0100 Subject: [PATCH 10/73] improved base callback structure --- core/Callbacks/Structures/BaseStructure.php | 4 ++-- .../Structures/ManiaPlanet/CallbacksListStructure.php | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index 71eb228b..e277c365 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -40,12 +40,12 @@ abstract class BaseStructure { public function getJson() { return $this->plainJson; } - + /** * Var_Dump the Structure */ public function dump() { - var_dump($this->getJson()); + var_dump("Class Name including Namespace: " . get_class($this)); var_dump(json_decode(json_encode($this))); } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php b/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php index 3e936746..586d9f2a 100644 --- a/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php @@ -30,8 +30,6 @@ class CallbacksListStructure extends BaseStructure { $this->responseId = $this->getJson()->responseid; $this->callbacks = $this->getJson()->callbacks; - - //$this->dump(); } /** From 40c3955de5b3023c63b4aea91b995c6ecc4c639e Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 23 Mar 2017 20:52:23 +0100 Subject: [PATCH 11/73] adjusted folder structure (added some events which arent finished in every folder, the only finished is the one in XmlRpc) --- core/Callbacks/LibXmlRpcCallbacks.php | 2 +- .../ManiaPlanet/StartServerStructure.php | 15 +++++++++++++ .../ShootMania/DefaultEventStructure.php | 22 +++++++++++++++++++ .../Trackmania/DefaultEventStructure.php | 18 ++++++++++----- .../CallbacksListStructure.php | 2 +- 5 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/DefaultEventStructure.php rename core/Callbacks/Structures/{ManiaPlanet => XmlRpc}/CallbacksListStructure.php (94%) diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 8bf4c68c..d9bd2ee1 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -4,7 +4,7 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Structures\ArmorEmptyStructure; use ManiaControl\Callbacks\Structures\CaptureStructure; -use ManiaControl\Callbacks\Structures\ManiaPlanet\CallbacksListStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\CallbacksListStructure; use ManiaControl\Callbacks\Structures\NearMissStructure; use ManiaControl\Callbacks\Structures\PlayerHitStructure; use ManiaControl\ManiaControl; diff --git a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php new file mode 100644 index 00000000..7c07226f --- /dev/null +++ b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php @@ -0,0 +1,15 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class DefaultEventStructure extends BaseStructure { + public function __construct(ManiaControl $maniaControl, $data) { + parent::setManiaControl($maniaControl); + parent::setJson($data); + + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php b/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php index 9eba374b..8e66ad20 100644 --- a/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php +++ b/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php @@ -1,16 +1,22 @@ + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ class DefaultEventStructure extends BaseStructure { + public function __construct(ManiaControl $maniaControl, $data) { + parent::setManiaControl($maniaControl); + parent::setJson($data); + } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php similarity index 94% rename from core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php rename to core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index 586d9f2a..018b0b91 100644 --- a/core/Callbacks/Structures/ManiaPlanet/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -1,6 +1,6 @@ Date: Thu, 23 Mar 2017 20:55:20 +0100 Subject: [PATCH 12/73] fixed typo --- core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php index 7c07226f..90975fc1 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php @@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks\Structures\ManiaPlanet; use ManiaControl\Callbacks\Structures\BaseStructure; use ManiaControl\ManiaControl; -class StartServerStartStructure extends BaseStructure { +class StartServerStructure extends BaseStructure { public function __construct(ManiaControl $maniaControl, $data) { parent::setManiaControl($maniaControl); parent::setJson($data); From 4b974e66c2b05edadd46fd803fab79932644d638 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 23 Mar 2017 21:01:44 +0100 Subject: [PATCH 13/73] added parent constructor --- core/Callbacks/Structures/BaseStructure.php | 10 +++------- .../Structures/ManiaPlanet/StartServerStructure.php | 4 ++-- .../Structures/ShootMania/DefaultEventStructure.php | 3 +-- .../Structures/Trackmania/DefaultEventStructure.php | 3 +-- .../Structures/XmlRpc/CallbacksListStructure.php | 5 +++-- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index e277c365..59a8ebfd 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -16,13 +16,9 @@ abstract class BaseStructure { protected $maniaControl; private $plainJson; - /** - * Sets ManiaControl - * - * @param \ManiaControl\ManiaControl $maniaControl - */ - protected function setManiaControl(ManiaControl $maniaControl) { + protected function __construct(ManiaControl $maniaControl, $data) { $this->maniaControl = $maniaControl; + $this->setJson($data); } /** @@ -45,7 +41,7 @@ abstract class BaseStructure { * Var_Dump the Structure */ public function dump() { - var_dump("Class Name including Namespace: " . get_class($this)); var_dump(json_decode(json_encode($this))); + var_dump("Class Name including Namespace: " . get_class($this)); } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php index 90975fc1..89461340 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php @@ -8,8 +8,8 @@ use ManiaControl\ManiaControl; class StartServerStructure extends BaseStructure { public function __construct(ManiaControl $maniaControl, $data) { - parent::setManiaControl($maniaControl); - parent::setJson($data); + parent::__construct($maniaControl, $data); + } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/DefaultEventStructure.php b/core/Callbacks/Structures/ShootMania/DefaultEventStructure.php index 84506526..71d68f6a 100644 --- a/core/Callbacks/Structures/ShootMania/DefaultEventStructure.php +++ b/core/Callbacks/Structures/ShootMania/DefaultEventStructure.php @@ -15,8 +15,7 @@ use ManiaControl\ManiaControl; */ class DefaultEventStructure extends BaseStructure { public function __construct(ManiaControl $maniaControl, $data) { - parent::setManiaControl($maniaControl); - parent::setJson($data); + parent::__construct($maniaControl, $data); } } \ No newline at end of file diff --git a/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php b/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php index 8e66ad20..34fa968c 100644 --- a/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php +++ b/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php @@ -15,8 +15,7 @@ use ManiaControl\ManiaControl; */ class DefaultEventStructure extends BaseStructure { public function __construct(ManiaControl $maniaControl, $data) { - parent::setManiaControl($maniaControl); - parent::setJson($data); + parent::__construct($maniaControl, $data); } } \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index 018b0b91..a1b8d992 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -25,11 +25,12 @@ class CallbacksListStructure extends BaseStructure { * @param array $data */ public function __construct(ManiaControl $maniaControl, $data) { - parent::setManiaControl($maniaControl); - parent::setJson($data); + parent::__construct($maniaControl, $data); $this->responseId = $this->getJson()->responseid; $this->callbacks = $this->getJson()->callbacks; + + $this->dump(); } /** From bb10a6a784a5cc24100885171bd09acc63668a0d Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 23 Mar 2017 21:02:26 +0100 Subject: [PATCH 14/73] removed testdump --- core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index a1b8d992..c4f815c8 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -29,8 +29,6 @@ class CallbacksListStructure extends BaseStructure { $this->responseId = $this->getJson()->responseid; $this->callbacks = $this->getJson()->callbacks; - - $this->dump(); } /** From 55d5cf1b065b186cc995ab48e0de2e8458afff47 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 23 Mar 2017 21:04:05 +0100 Subject: [PATCH 15/73] better name for the get Json --- core/Callbacks/Structures/BaseStructure.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index 59a8ebfd..5aa15265 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -14,27 +14,18 @@ use ManiaControl\ManiaControl; abstract class BaseStructure { /** @var ManiaControl $maniaControl */ protected $maniaControl; - private $plainJson; + private $plainJsonObject; protected function __construct(ManiaControl $maniaControl, $data) { - $this->maniaControl = $maniaControl; - $this->setJson($data); + $this->maniaControl = $maniaControl; + $this->plainJsonObject = json_decode($data[0]); } - - /** - * Decodes the Data and Sets the Json - * - * @param array $data - */ - protected function setJson($data) { - $this->plainJson = json_decode($data[0]); - } - + /** * Gets the Plain Json */ - public function getJson() { - return $this->plainJson; + public function getPlainJsonObject() { + return $this->plainJsonObject; } /** From 49cc190b86b1014d97c26fb104f1c04322a12620 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 23 Mar 2017 21:19:03 +0100 Subject: [PATCH 16/73] rename json object --- core/Callbacks/Structures/BaseStructure.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index 5aa15265..75bd7393 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -20,7 +20,7 @@ abstract class BaseStructure { $this->maniaControl = $maniaControl; $this->plainJsonObject = json_decode($data[0]); } - + /** * Gets the Plain Json */ From b96c3e92fd499e8e8c13b1650254a25ffa9023a4 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 24 Mar 2017 16:49:54 +0100 Subject: [PATCH 17/73] added two new callbacks --- core/Callbacks/Callbacks.php | 3 ++- core/Callbacks/LibXmlRpcCallbacks.php | 9 ++++++++- core/Callbacks/Structures/BaseStructure.php | 13 +++++++------ .../ManiaPlanet/StartServerStructure.php | 16 ++++++++++++++++ .../Structures/XmlRpc/CallbacksListStructure.php | 4 ++-- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index df8cc2bb..579b8245 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -31,7 +31,8 @@ interface Callbacks { //NEW Callbacks const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; - + const MP_STARTSERVERSTART = 'Callbacks.ManiaPlanetStartServerStart'; + const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerStart'; //OLD Callbacks /** BeginMatch Callback: MatchNumber */ diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index d9bd2ee1..b5d74751 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -4,9 +4,10 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Structures\ArmorEmptyStructure; use ManiaControl\Callbacks\Structures\CaptureStructure; -use ManiaControl\Callbacks\Structures\XmlRpc\CallbacksListStructure; +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; /** @@ -49,6 +50,12 @@ class LibXmlRpcCallbacks implements CallbackListener { case 'XmlRpc.CallbacksList': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data)); break; + case 'Maniaplanet.StartServer_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data)); + break; + case 'Maniaplanet.StartServer_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVEREND, new StartServerStructure($this->maniaControl, $data)); + break; //OLD Callbacks case 'LibXmlRpc_BeginMatch': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]); diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index 75bd7393..f66dbb21 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -1,16 +1,17 @@ + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ abstract class BaseStructure { /** @var ManiaControl $maniaControl */ protected $maniaControl; diff --git a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php index 89461340..654c08a7 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php @@ -6,10 +6,26 @@ namespace ManiaControl\Callbacks\Structures\ManiaPlanet; use ManiaControl\Callbacks\Structures\BaseStructure; use ManiaControl\ManiaControl; +/** + * Structure Class for the Default Start Server Callback + * + * @author ManiaControl Team + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ class StartServerStructure extends BaseStructure { + public $restarted; + public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); + $this->restarted = $this->getPlainJsonObject()->restarted; + } + /** + * @return mixed + */ + public function getRestarted() { + return $this->restarted; } } \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index c4f815c8..71734037 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -27,8 +27,8 @@ class CallbacksListStructure extends BaseStructure { public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); - $this->responseId = $this->getJson()->responseid; - $this->callbacks = $this->getJson()->callbacks; + $this->responseId = $this->getPlainJsonObject()->responseid; + $this->callbacks = $this->getPlainJsonObject()->callbacks; } /** From 7c01319a4ab090cc503aeac13a9ea4af85835eb1 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 24 Mar 2017 17:08:27 +0100 Subject: [PATCH 18/73] added callback names --- core/Callbacks/Callbacks.php | 32 +++++++++++++++++-- core/Callbacks/LibXmlRpcCallbacks.php | 4 +++ .../ManiaPlanet/StartEndStructure.php | 31 ++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 579b8245..f15ae0d6 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -30,9 +30,35 @@ interface Callbacks { */ //NEW Callbacks - const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; - const MP_STARTSERVERSTART = 'Callbacks.ManiaPlanetStartServerStart'; - const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerStart'; + const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; + const MP_STARTSERVERSTART = 'Callbacks.ManiaPlanetStartServerStart'; + const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerEnd'; + const MP_STARTMATCHSTART = 'Callbacks.ManiaPlanetStartMatchStart'; + const MP_STARTMATCHEND = 'Callbacks.ManiaPlanetStartMatchEnd'; + const MP_STARTMAPSTART = 'Callbacks.ManiaPlanetStartMapStart'; + const MP_STARTMAPEND = 'Callbacks.ManiaPlanetStartMapEnd'; + const MP_STARTROUNDSTART = 'Callbacks.ManiaPlanetStartRoundStart'; + const MP_STARTROUNDEND = 'Callbacks.ManiaPlanetStartRoundEnd'; + const MP_STARTTURNSTART = 'Callbacks.ManiaPlanetStartTurnStart'; + const MP_STARTTURNEND = 'Callbacks.ManiaPlanetStartTurnEnd'; + const MP_STARTPLAYLOOPSTART = 'Callbacks.ManiaPlanetStartPlayLoopStart'; + const MP_STARTPLAYLOOPEND = 'Callbacks.ManiaPlanetStartPlayLoopEnd'; + const MP_ENDTTURNSTART = 'Callbacks.ManiaPlanetEndTurnStart'; + const MP_ENDTURNEND = 'Callbacks.ManiaPlanetEndTurnEnd'; + const MP_ENDROUNDSTART = 'Callbacks.ManiaPlanetEndRoundStart'; + const MP_ENDROUNDEND = 'Callbacks.ManiaPlanetEndRoundEnd'; + const MP_ENDMAPSTART = 'Callbacks.ManiaPlanetEndMapStart'; + const MP_ENDMAPEND = 'Callbacks.ManiaPlanetEndMapEnd'; + const MP_ENDMATCHSTART = 'Callbacks.ManiaPlanetEndMatchStart'; + const MP_ENDMATCHEND = 'Callbacks.ManiaPlanetEndMatchEnd'; + const MP_ENDSERVERSTART = 'Callbacks.ManiaPlanetEndServerStart'; + const MP_ENDSERVEREND = 'Callbacks.ManiaPlanetEndServerEnd'; + const MP_LOADINGMAPSTART = 'Callbacks.ManiaPlanetLoadingMapStart'; + const MP_LOADINGMAPEND = 'Callbacks.ManiaPlanetLoadingMapEnd'; + const MP_UNLOADINGMAPSTART = 'Callbacks.ManiaPlanetUnLoadingMapStart'; + const MP_UNLOADINGMAPEND = 'Callbacks.ManiaPlanetUnLoadingMapEnd'; + const MP_PODIUMSTART = 'Callbacks.ManiaPlanetPodiumStart'; + const MP_PODIUMEND = 'Callbacks.ManiaPlanetPodiumEnd'; //OLD Callbacks /** BeginMatch Callback: MatchNumber */ diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index b5d74751..0e77917b 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -4,6 +4,7 @@ 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; @@ -56,6 +57,9 @@ class LibXmlRpcCallbacks implements CallbackListener { case 'Maniaplanet.StartServer_End': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVEREND, new StartServerStructure($this->maniaControl, $data)); break; + case 'ManiaPlanet.StartMatch_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTMATCHSTART, new StartEndStructure($this->maniaControl, $data)); + break; //OLD Callbacks case 'LibXmlRpc_BeginMatch': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]); diff --git a/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php new file mode 100644 index 00000000..0b3c663e --- /dev/null +++ b/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php @@ -0,0 +1,31 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class StartEndStructure extends BaseStructure { + public $count; + + public function __construct(ManiaControl $maniaControl, $data) { + parent::__construct($maniaControl, $data); + + $this->count = $this->getPlainJsonObject()->count; + } + + /** + * @return mixed + */ + public function getCount() { + return $this->count; + } +} \ No newline at end of file From 7a668b53baf568401e506d94a716f8bcc9518719 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 24 Mar 2017 22:08:51 +0100 Subject: [PATCH 19/73] added dumpable interface, implemented all ManiaPlanet Callbacks --- core/Callbacks/Callbacks.php | 13 +-- core/Callbacks/LibXmlRpcCallbacks.php | 82 +++++++++++++++++++ core/Callbacks/Structures/BaseStructure.php | 3 +- core/General/DumpTrait.php | 19 +++++ core/General/Dumpable.php | 14 ++++ core/ManiaControl.php | 2 +- core/Maps/Map.php | 52 ++++++------ core/Players/Player.php | 15 ++-- .../ModeScriptEventManager.php | 4 +- 9 files changed, 158 insertions(+), 46 deletions(-) create mode 100644 core/General/DumpTrait.php create mode 100644 core/General/Dumpable.php rename core/{Server => Script}/ModeScriptEventManager.php (96%) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index f15ae0d6..622a9508 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -35,15 +35,15 @@ interface Callbacks { const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerEnd'; const MP_STARTMATCHSTART = 'Callbacks.ManiaPlanetStartMatchStart'; const MP_STARTMATCHEND = 'Callbacks.ManiaPlanetStartMatchEnd'; - const MP_STARTMAPSTART = 'Callbacks.ManiaPlanetStartMapStart'; - const MP_STARTMAPEND = 'Callbacks.ManiaPlanetStartMapEnd'; + //const MP_STARTMAPSTART = 'Callbacks.ManiaPlanetStartMapStart'; + //const MP_STARTMAPEND = 'Callbacks.ManiaPlanetStartMapEnd'; const MP_STARTROUNDSTART = 'Callbacks.ManiaPlanetStartRoundStart'; const MP_STARTROUNDEND = 'Callbacks.ManiaPlanetStartRoundEnd'; const MP_STARTTURNSTART = 'Callbacks.ManiaPlanetStartTurnStart'; const MP_STARTTURNEND = 'Callbacks.ManiaPlanetStartTurnEnd'; const MP_STARTPLAYLOOPSTART = 'Callbacks.ManiaPlanetStartPlayLoopStart'; const MP_STARTPLAYLOOPEND = 'Callbacks.ManiaPlanetStartPlayLoopEnd'; - const MP_ENDTTURNSTART = 'Callbacks.ManiaPlanetEndTurnStart'; + const MP_ENDTURNSTART = 'Callbacks.ManiaPlanetEndTurnStart'; const MP_ENDTURNEND = 'Callbacks.ManiaPlanetEndTurnEnd'; const MP_ENDROUNDSTART = 'Callbacks.ManiaPlanetEndRoundStart'; const MP_ENDROUNDEND = 'Callbacks.ManiaPlanetEndRoundEnd'; @@ -60,13 +60,16 @@ interface Callbacks { const MP_PODIUMSTART = 'Callbacks.ManiaPlanetPodiumStart'; const MP_PODIUMEND = 'Callbacks.ManiaPlanetPodiumEnd'; + //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 */ diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 0e77917b..9cc751ee 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -60,6 +60,88 @@ class LibXmlRpcCallbacks implements CallbackListener { case 'ManiaPlanet.StartMatch_Start': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTMATCHSTART, new StartEndStructure($this->maniaControl, $data)); break; + case 'ManiaPlanet.StartMatch_End': + $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 'ManiaPlanet.StartRound_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTROUNDSTART, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.StartRound_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTROUNDEND, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.StartTurn_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTTURNSTART, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.StartTurn_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTTURNEND, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.StartPlayLoop_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTPLAYLOOPSTART, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.StartPlayLoop_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTPLAYLOOPEND, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.EndTurn_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDTURNSTART, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.EndTurn_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDTURNEND, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.EndRound_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDROUNDSTART, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.EndRound_End': + $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 'ManiaPlanet.EndMatch_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDMATCHSTART, new StartEndStructure($this->maniaControl, $data)); + break; + case 'ManiaPlanet.EndMatch_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDMATCHEND, new StartEndStructure($this->maniaControl, $data)); + break; + case 'Maniaplanet.EndServer_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDSERVERSTART, new StartServerStructure($this->maniaControl, $data)); + break; + case 'Maniaplanet.EndServer_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDSERVEREND, new StartServerStructure($this->maniaControl, $data)); + break; + case 'Maniaplanet.LoadingMap_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPSTART); + break; + case 'Maniaplanet.LoadingMap_End': + $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 'Maniaplanet.UnloadingMap_Start': + $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 'Maniaplanet.UnloadingMap_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPEND); + break; + case 'Maniaplanet.Podium_Start': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMSTART); + break; + case 'Maniaplanet.Podium_End': + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMEND); + break; + //OLD Callbacks case 'LibXmlRpc_BeginMatch': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]); diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index f66dbb21..0310d222 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -3,6 +3,7 @@ namespace ManiaControl\Callbacks\Structures; +use ManiaControl\General\Dumpable; use ManiaControl\ManiaControl; /** @@ -12,7 +13,7 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class BaseStructure { +abstract class BaseStructure implements Dumpable { /** @var ManiaControl $maniaControl */ protected $maniaControl; private $plainJsonObject; diff --git a/core/General/DumpTrait.php b/core/General/DumpTrait.php new file mode 100644 index 00000000..72815407 --- /dev/null +++ b/core/General/DumpTrait.php @@ -0,0 +1,19 @@ +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))); - } } diff --git a/core/Players/Player.php b/core/Players/Player.php index 79933ef4..77767131 100644 --- a/core/Players/Player.php +++ b/core/Players/Player.php @@ -2,6 +2,8 @@ namespace ManiaControl\Players; +use ManiaControl\General\Dumpable; +use ManiaControl\General\DumpTrait; use ManiaControl\ManiaControl; use ManiaControl\Utils\ClassUtil; use ManiaControl\Utils\Formatter; @@ -14,7 +16,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 { + use DumpTrait; + /* * Public Properties */ @@ -345,14 +349,7 @@ class Player { } return false; } - - /** - * Var_Dump the Player - */ - public function dump() { - var_dump(json_decode(json_encode($this))); - } - + /** * Var_Dump the Players Cache */ diff --git a/core/Server/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php similarity index 96% rename from core/Server/ModeScriptEventManager.php rename to core/Script/ModeScriptEventManager.php index 2d18b6ba..3644c685 100644 --- a/core/Server/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -6,9 +6,7 @@ * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -namespace ManiaControl\Server; - -//TODO maybe own folder +namespace ManiaControl\Script; use ManiaControl\ManiaControl; From f15dab5d4215ae718f460a50dbda96e1f995dd3f Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 24 Mar 2017 22:49:43 +0100 Subject: [PATCH 20/73] added some shootmania callbacks --- core/Callbacks/Callbacks.php | 54 ++++++--- core/Callbacks/EchoManager.php | 4 +- core/Callbacks/ShootManiaCallbacks.php | 15 +++ .../ShootMania/DefaultEventStructure.php | 19 +++ .../Structures/ShootMania/OnHitStructure.php | 110 ++++++++++++++++++ .../ShootMania/OnShootStructure.php | 54 +++++++++ .../Structures/ShootMania/Position.php | 9 ++ .../Trackmania/DefaultEventStructure.php | 19 +++ .../XmlRpc/CallbacksListStructure.php | 2 +- 9 files changed, 265 insertions(+), 21 deletions(-) create mode 100644 core/Callbacks/Structures/ShootMania/OnHitStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/OnShootStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/Position.php diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 622a9508..3fddc9e2 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -30,11 +30,11 @@ interface Callbacks { */ //NEW Callbacks - const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; - const MP_STARTSERVERSTART = 'Callbacks.ManiaPlanetStartServerStart'; - const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerEnd'; - const MP_STARTMATCHSTART = 'Callbacks.ManiaPlanetStartMatchStart'; - const MP_STARTMATCHEND = 'Callbacks.ManiaPlanetStartMatchEnd'; + const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; + const MP_STARTSERVERSTART = 'Callbacks.ManiaPlanetStartServerStart'; + const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerEnd'; + const MP_STARTMATCHSTART = 'Callbacks.ManiaPlanetStartMatchStart'; + const MP_STARTMATCHEND = 'Callbacks.ManiaPlanetStartMatchEnd'; //const MP_STARTMAPSTART = 'Callbacks.ManiaPlanetStartMapStart'; //const MP_STARTMAPEND = 'Callbacks.ManiaPlanetStartMapEnd'; const MP_STARTROUNDSTART = 'Callbacks.ManiaPlanetStartRoundStart'; @@ -43,22 +43,40 @@ interface Callbacks { const MP_STARTTURNEND = 'Callbacks.ManiaPlanetStartTurnEnd'; const MP_STARTPLAYLOOPSTART = 'Callbacks.ManiaPlanetStartPlayLoopStart'; const MP_STARTPLAYLOOPEND = 'Callbacks.ManiaPlanetStartPlayLoopEnd'; - const MP_ENDTURNSTART = 'Callbacks.ManiaPlanetEndTurnStart'; + const MP_ENDTURNSTART = 'Callbacks.ManiaPlanetEndTurnStart'; const MP_ENDTURNEND = 'Callbacks.ManiaPlanetEndTurnEnd'; const MP_ENDROUNDSTART = 'Callbacks.ManiaPlanetEndRoundStart'; const MP_ENDROUNDEND = 'Callbacks.ManiaPlanetEndRoundEnd'; - const MP_ENDMAPSTART = 'Callbacks.ManiaPlanetEndMapStart'; - const MP_ENDMAPEND = 'Callbacks.ManiaPlanetEndMapEnd'; - const MP_ENDMATCHSTART = 'Callbacks.ManiaPlanetEndMatchStart'; - const MP_ENDMATCHEND = 'Callbacks.ManiaPlanetEndMatchEnd'; - const MP_ENDSERVERSTART = 'Callbacks.ManiaPlanetEndServerStart'; - const MP_ENDSERVEREND = 'Callbacks.ManiaPlanetEndServerEnd'; - const MP_LOADINGMAPSTART = 'Callbacks.ManiaPlanetLoadingMapStart'; - const MP_LOADINGMAPEND = 'Callbacks.ManiaPlanetLoadingMapEnd'; - const MP_UNLOADINGMAPSTART = 'Callbacks.ManiaPlanetUnLoadingMapStart'; - const MP_UNLOADINGMAPEND = 'Callbacks.ManiaPlanetUnLoadingMapEnd'; - const MP_PODIUMSTART = 'Callbacks.ManiaPlanetPodiumStart'; - const MP_PODIUMEND = 'Callbacks.ManiaPlanetPodiumEnd'; + //const MP_ENDMAPSTART = 'Callbacks.ManiaPlanetEndMapStart'; + //const MP_ENDMAPEND = 'Callbacks.ManiaPlanetEndMapEnd'; + const MP_ENDMATCHSTART = 'Callbacks.ManiaPlanetEndMatchStart'; + const MP_ENDMATCHEND = 'Callbacks.ManiaPlanetEndMatchEnd'; + const MP_ENDSERVERSTART = 'Callbacks.ManiaPlanetEndServerStart'; + const MP_ENDSERVEREND = 'Callbacks.ManiaPlanetEndServerEnd'; + const MP_LOADINGMAPSTART = 'Callbacks.ManiaPlanetLoadingMapStart'; + const MP_LOADINGMAPEND = 'Callbacks.ManiaPlanetLoadingMapEnd'; + const MP_UNLOADINGMAPSTART = 'Callbacks.ManiaPlanetUnLoadingMapStart'; + const MP_UNLOADINGMAPEND = 'Callbacks.ManiaPlanetUnLoadingMapEnd'; + const MP_PODIUMSTART = 'Callbacks.ManiaPlanetPodiumStart'; + const MP_PODIUMEND = 'Callbacks.ManiaPlanetPodiumEnd'; + + const SM_EVENTDEFAULT = "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_ONPLAYERREQUESTRESAWPN = "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"; //ManiaControl Callbacks /** BeginMap Callback: Map */ diff --git a/core/Callbacks/EchoManager.php b/core/Callbacks/EchoManager.php index faa2e716..49af62db 100644 --- a/core/Callbacks/EchoManager.php +++ b/core/Callbacks/EchoManager.php @@ -69,8 +69,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; } diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 8d394975..4ed857b8 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -4,6 +4,9 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure; +use ManiaControl\Callbacks\Structures\ShootMania\DefaultEventStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnHitStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure; use ManiaControl\ManiaControl; /** @@ -49,6 +52,18 @@ class ShootManiaCallbacks implements CallbackListener { */ public function handleScriptCallbacks($name, $data) { switch ($name) { + //MP4 New Callbacks + case Callbacks::SM_EVENTDEFAULT: + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_EVENTDEFAULT, new DefaultEventStructure($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; + + //Old Callbacks case 'LibXmlRpc_Rankings': $this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]); break; diff --git a/core/Callbacks/Structures/ShootMania/DefaultEventStructure.php b/core/Callbacks/Structures/ShootMania/DefaultEventStructure.php index 71d68f6a..e65bc5ac 100644 --- a/core/Callbacks/Structures/ShootMania/DefaultEventStructure.php +++ b/core/Callbacks/Structures/ShootMania/DefaultEventStructure.php @@ -14,8 +14,27 @@ use ManiaControl\ManiaControl; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class DefaultEventStructure extends BaseStructure { + public $time; + public $type; + public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); + $this->time = $this->getPlainJsonObject()->time; + $this->type = $this->getPlainJsonObject()->type; + } + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + /** + * @return string + */ + public function getType() { + return $this->type; } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnHitStructure.php b/core/Callbacks/Structures/ShootMania/OnHitStructure.php new file mode 100644 index 00000000..666f5aa8 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnHitStructure.php @@ -0,0 +1,110 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnHitStructure extends BaseStructure { + public $time; + public $weapon; + public $damage; + public $shooterPosition; + public $victimPosition; + + protected $shooter; + protected $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); + + $this->time = $this->getPlainJsonObject()->time; + $this->weapon = $this->getPlainJsonObject()->weapon; + $this->damage = $this->getPlainJsonObject()->damage; + $this->shooterPosition = $this->getPlainJsonObject()->shooterPosition; + $this->victimPosition = $this->getPlainJsonObject()->victimPosition; + + $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); + $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); + } + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + /** + * @return int + */ + public function getWeapon() { + return $this->weapon; + } + + /** + * @return int + */ + public function getDamage() { + return $this->damage; + } + + /** + * TODO Position Object + * + * @return Object + */ + public function getShooterPosition() { + return $this->shooterPosition; + } + + /** + * TODO Position Object + * + * @return Object + */ + public function getVictimPosition() { + return $this->victimPosition; + } + + /** + * @return Player + */ + public function getShooter() { + return $this->shooter; + } + + /** + * @return Player + */ + public function getVictim() { + return $this->victim; + } + + /** Dumps the Object with some Information */ + public function dump() { + parent::dump(); + var_dump("With getShooter() you get a Player Object"); + var_dump("With getVictim() you get a Player Object"); + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnShootStructure.php b/core/Callbacks/Structures/ShootMania/OnShootStructure.php new file mode 100644 index 00000000..2f2e9dcc --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnShootStructure.php @@ -0,0 +1,54 @@ +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"); + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/Position.php b/core/Callbacks/Structures/ShootMania/Position.php new file mode 100644 index 00000000..85df4951 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/Position.php @@ -0,0 +1,9 @@ +time = $this->getPlainJsonObject()->time; + $this->type = $this->getPlainJsonObject()->type; + } + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + /** + * @return string + */ + public function getType() { + return $this->type; } } \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index 71734037..c37c3cc7 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -19,7 +19,7 @@ class CallbacksListStructure extends BaseStructure { public $callbacks; /** - * Construct a new Armor Empty Structure + * Construct a new Callbacks List Structure * * @param ManiaControl $maniaControl * @param array $data From bd2c5a8c9c1d5b98383e9afc76144bedc66e66d8 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 25 Mar 2017 11:53:55 +0100 Subject: [PATCH 21/73] added some callbacks --- core/Callbacks/Callbacks.php | 2 + core/Callbacks/ShootManiaCallbacks.php | 16 +++- .../Structures/ShootMania/Models/Landmark.php | 73 ++++++++++++++++ .../Structures/ShootMania/Models/Position.php | 53 ++++++++++++ .../ShootMania/OnCaptureStructure.php | 86 +++++++++++++++++++ ...p => OnHitNearMissArmorEmptyStructure.php} | 37 ++++++-- .../Structures/ShootMania/Position.php | 9 -- 7 files changed, 256 insertions(+), 20 deletions(-) create mode 100644 core/Callbacks/Structures/ShootMania/Models/Landmark.php create mode 100644 core/Callbacks/Structures/ShootMania/Models/Position.php create mode 100644 core/Callbacks/Structures/ShootMania/OnCaptureStructure.php rename core/Callbacks/Structures/ShootMania/{OnHitStructure.php => OnHitNearMissArmorEmptyStructure.php} (65%) delete mode 100644 core/Callbacks/Structures/ShootMania/Position.php diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 3fddc9e2..95b89745 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -60,6 +60,8 @@ interface Callbacks { const MP_PODIUMSTART = 'Callbacks.ManiaPlanetPodiumStart'; const MP_PODIUMEND = 'Callbacks.ManiaPlanetPodiumEnd'; + const SM_SCORES = "Shootmania.Scores"; + const SM_EVENTDEFAULT = "Shootmania.Event.Default"; const SM_ONSHOOT = "Shootmania.Event.OnShoot"; const SM_ONHIT = "Shootmania.Event.OnHit"; diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 4ed857b8..535069a7 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -5,7 +5,8 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure; use ManiaControl\Callbacks\Structures\ShootMania\DefaultEventStructure; -use ManiaControl\Callbacks\Structures\ShootMania\OnHitStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnHitNearMissArmorEmptyStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure; use ManiaControl\ManiaControl; @@ -60,9 +61,18 @@ class ShootManiaCallbacks implements CallbackListener { $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)); + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONHIT, new OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + break; + case Callbacks::SM_ONNEARMISS: + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONNEARMISS, new OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + break; + case Callbacks::SM_ONARMOREMPTY: + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONARMOREMPTY, new OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + break; + case Callbacks::SM_ONCAPTURE: + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data)); + break; break; - //Old Callbacks case 'LibXmlRpc_Rankings': $this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]); diff --git a/core/Callbacks/Structures/ShootMania/Models/Landmark.php b/core/Callbacks/Structures/ShootMania/Models/Landmark.php new file mode 100644 index 00000000..ae61ad1e --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/Models/Landmark.php @@ -0,0 +1,73 @@ +tag; + } + + /** + * @param mixed $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 mixed + */ + public function getPosition() { + return $this->position; + } + + /** + * @param mixed $position + */ + public function setPosition(Position $position) { + $this->position = $position; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/Models/Position.php b/core/Callbacks/Structures/ShootMania/Models/Position.php new file mode 100644 index 00000000..155410a7 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/Models/Position.php @@ -0,0 +1,53 @@ +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; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php new file mode 100644 index 00000000..799a86f7 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php @@ -0,0 +1,86 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnCaptureStructure extends BaseStructure { + + public $time; + public $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); + + $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); + } + + + /** + * Get the logins + * + * @return array + */ + public function getLoginArray() { + return $this->playerArray; + } + + /** + * Get the players + * + * @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; + } + + /** + * @return LandMark + */ + public function getLandMark() { + return $this->landMark; + } + + /** + * @param mixed $landMark + */ + public function setLandMark(Landmark $landMark) { + $this->landMark = $landMark; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnHitStructure.php b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php similarity index 65% rename from core/Callbacks/Structures/ShootMania/OnHitStructure.php rename to core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php index 666f5aa8..92e18693 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php @@ -15,12 +15,13 @@ use ManiaControl\Players\Player; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class OnHitStructure extends BaseStructure { +class OnHitNearMissArmorEmptyStructure extends BaseStructure { public $time; public $weapon; public $damage; public $shooterPosition; public $victimPosition; + public $distance = 0; //Note no distance on the OnHit and ArmorEmpty yet protected $shooter; protected $victim; @@ -38,11 +39,24 @@ class OnHitStructure extends BaseStructure { public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); - $this->time = $this->getPlainJsonObject()->time; - $this->weapon = $this->getPlainJsonObject()->weapon; - $this->damage = $this->getPlainJsonObject()->damage; - $this->shooterPosition = $this->getPlainJsonObject()->shooterPosition; - $this->victimPosition = $this->getPlainJsonObject()->victimPosition; + $jsonObj = $this->getPlainJsonObject(); + $this->time = $jsonObj->time; + $this->weapon = $jsonObj->weapon; + $this->damage = $jsonObj->damage; + + $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); + + if (property_exists($this->getPlainJsonObject(), 'distance')) { + $this->distance = $this->getPlainJsonObject()->distance; + } $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); @@ -72,7 +86,7 @@ class OnHitStructure extends BaseStructure { /** * TODO Position Object * - * @return Object + * @return Position */ public function getShooterPosition() { return $this->shooterPosition; @@ -81,7 +95,7 @@ class OnHitStructure extends BaseStructure { /** * TODO Position Object * - * @return Object + * @return Position */ public function getVictimPosition() { return $this->victimPosition; @@ -101,6 +115,13 @@ class OnHitStructure extends BaseStructure { return $this->victim; } + /** + * @return mixed + */ + public function getDistance() { + return $this->distance; + } + /** Dumps the Object with some Information */ public function dump() { parent::dump(); diff --git a/core/Callbacks/Structures/ShootMania/Position.php b/core/Callbacks/Structures/ShootMania/Position.php deleted file mode 100644 index 85df4951..00000000 --- a/core/Callbacks/Structures/ShootMania/Position.php +++ /dev/null @@ -1,9 +0,0 @@ - Date: Sat, 25 Mar 2017 11:54:44 +0100 Subject: [PATCH 22/73] updated namespace --- core/Callbacks/Structures/ShootMania/Models/Landmark.php | 2 +- core/Callbacks/Structures/ShootMania/Models/Position.php | 2 +- core/Callbacks/Structures/ShootMania/OnCaptureStructure.php | 2 ++ .../Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/Callbacks/Structures/ShootMania/Models/Landmark.php b/core/Callbacks/Structures/ShootMania/Models/Landmark.php index ae61ad1e..81e0f2b3 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Landmark.php +++ b/core/Callbacks/Structures/ShootMania/Models/Landmark.php @@ -6,7 +6,7 @@ * Time: 11:37 */ -namespace ManiaControl\Callbacks\Structures\ShootMania; +namespace ManiaControl\Callbacks\Structures\ShootMania\Models; class Landmark { diff --git a/core/Callbacks/Structures/ShootMania/Models/Position.php b/core/Callbacks/Structures/ShootMania/Models/Position.php index 155410a7..e8e0514d 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Position.php +++ b/core/Callbacks/Structures/ShootMania/Models/Position.php @@ -1,7 +1,7 @@ Date: Sat, 25 Mar 2017 12:55:09 +0100 Subject: [PATCH 23/73] added scores shootmania callback -> TODO implement players there in a good way, maybe a Object including these properties and a getPlayer() method with a reference to the player (setable without maniacontrol reference in the object itself) --- .../ShootMania/Models/PlayerScore.php | 14 +++ .../ShootMania/Models/TeamScore.php | 88 ++++++++++++++ .../ShootMania/OnCaptureStructure.php | 9 +- .../OnHitNearMissArmorEmptyStructure.php | 29 +++-- .../ShootMania/OnScoresStructure.php | 111 ++++++++++++++++++ 5 files changed, 237 insertions(+), 14 deletions(-) create mode 100644 core/Callbacks/Structures/ShootMania/Models/PlayerScore.php create mode 100644 core/Callbacks/Structures/ShootMania/Models/TeamScore.php create mode 100644 core/Callbacks/Structures/ShootMania/OnScoresStructure.php diff --git a/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php b/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php new file mode 100644 index 00000000..3fc4ea08 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php @@ -0,0 +1,14 @@ +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; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php index 7e640513..0e73f889 100644 --- a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php @@ -18,8 +18,8 @@ use ManiaControl\Players\Player; */ class OnCaptureStructure extends BaseStructure { - public $time; - public $landMark; + public $time; + private $landMark; private $playerArray = array(); @@ -46,6 +46,11 @@ class OnCaptureStructure extends BaseStructure { $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); } + /** Dumps the Object with some Information */ + public function dump() { + var_dump($this->landMark); + parent::dump(); + } /** * Get the logins diff --git a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php index 00e6bf28..475ccef0 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php @@ -20,10 +20,10 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { public $time; public $weapon; public $damage; - public $shooterPosition; - public $victimPosition; public $distance = 0; //Note no distance on the OnHit and ArmorEmpty yet + private $shooterPosition; + private $victimPosition; protected $shooter; protected $victim; @@ -40,10 +40,10 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); - $jsonObj = $this->getPlainJsonObject(); - $this->time = $jsonObj->time; - $this->weapon = $jsonObj->weapon; - $this->damage = $jsonObj->damage; + $jsonObj = $this->getPlainJsonObject(); + $this->time = $jsonObj->time; + $this->weapon = $jsonObj->weapon; + $this->damage = $jsonObj->damage; $this->shooterPosition = new Position(); $this->shooterPosition->setX($jsonObj->shooterposition->x); @@ -63,6 +63,17 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); } + /** Dumps the Object with some Information */ + public function dump() { + var_dump("Dump of property Shooter Position"); + var_dump($this->shooterPosition); + var_dump("Dump of property Victim Position"); + var_dump($this->victimPosition); + parent::dump(); + var_dump("With getShooter() you get a Player Object"); + var_dump("With getVictim() you get a Player Object"); + } + /** * @return int */ @@ -123,10 +134,4 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { return $this->distance; } - /** Dumps the Object with some Information */ - public function dump() { - parent::dump(); - var_dump("With getShooter() you get a Player Object"); - var_dump("With getVictim() you get a Player Object"); - } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php new file mode 100644 index 00000000..b6c043a2 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php @@ -0,0 +1,111 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnScoresStructure extends BaseStructure { + public $responseId; + public $section; + public $useTeams; + public $winnerTeam; + public $winnerPlayer; + private $teamScores = array(); + public $players; //TODO implement + + //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) { + $teamScore = new 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 + } + + //TODO implement player + } + + /** Dumps the Object with some Information */ + public function dump() { + parent::dump(); + var_dump("With getWinnerPlayer() you get a Player Object"); + var_dump($this->teamScores); + } + + + /** + * @return Player + */ + public function getWinnerPlayer() { + return $this->winnerPlayer; + } + + /** + * @return mixed + */ + public function getResponseId() { + return $this->responseId; + } + + /** + * @return mixed + */ + public function getSection() { + return $this->section; + } + + /** + * @return boolean + */ + public function getUseTeams() { + return $this->useTeams; + } + + /** + * @return int + */ + public function getWinnerTeam() { + return $this->winnerTeam; + } + + /** + * @return TeamScore[] + */ + public function getTeamScores() { + return $this->teamScores; + } + + /** + * @return mixed + */ + public function getPlayers() { + //TODO proper implementation + return $this->players; + } +} \ No newline at end of file From e8586586a3762e8aee17e07f226b4dd2f562d328 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 25 Mar 2017 13:40:37 +0100 Subject: [PATCH 24/73] added check if callback got subscribed before triggering and creating structures --- core/Callbacks/CallbackManager.php | 16 +++++++++++++--- core/Callbacks/LibXmlRpcCallbacks.php | 3 +++ core/Callbacks/ShootManiaCallbacks.php | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/core/Callbacks/CallbackManager.php b/core/Callbacks/CallbackManager.php index 3e3fcf6a..e8ac4295 100644 --- a/core/Callbacks/CallbackManager.php +++ b/core/Callbacks/CallbackManager.php @@ -46,7 +46,7 @@ class CallbackManager { /* * Public properties */ - public $libXmlRpcCallbacks = null; + public $libXmlRpcCallbacks = null; public $shootManiaCallbacks = null; public $trackManiaCallbacks = null; @@ -98,7 +98,7 @@ class CallbackManager { return false; } - if (!array_key_exists($callbackName, $this->callbackListenings)) { + if (!$this->callbackListeningExists($callbackName)) { $this->callbackListenings[$callbackName] = array(); } @@ -108,6 +108,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 +282,7 @@ class CallbackManager { } else { $callbackName = $callback; } - if (!array_key_exists($callbackName, $this->callbackListenings)) { + if (!$this->callbackListeningExists($callbackName)) { return; } diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 9cc751ee..4338ae86 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -44,6 +44,9 @@ class LibXmlRpcCallbacks implements CallbackListener { * @param mixed $data */ public function handleScriptCallback($name, $data) { + if(!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)){ + return; + } var_dump($name); //var_dump($data); switch ($name) { diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 535069a7..f289a0ea 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -52,6 +52,9 @@ class ShootManiaCallbacks implements CallbackListener { * @param mixed $data */ public function handleScriptCallbacks($name, $data) { + if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { + return; + } switch ($name) { //MP4 New Callbacks case Callbacks::SM_EVENTDEFAULT: From 9a19691420d6f93a9e54e22c7851f5c5275a4d87 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 25 Mar 2017 13:44:03 +0100 Subject: [PATCH 25/73] added trackmania switch case for callbacks --- core/Callbacks/Callbacks.php | 3 ++ core/Callbacks/ShootManiaCallbacks.php | 1 - core/Callbacks/TrackManiaCallbacks.php | 44 ++++++++++++++++++++------ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 95b89745..37565f38 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -80,6 +80,9 @@ interface Callbacks { const SM_ONPLAYERTHROWSOBJECT = "Shootmania.Event.OnPlayerThrowsObject"; const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange"; + + const TM_EVENTDEFAULT = "Trackmania.Event.Default"; + //ManiaControl Callbacks /** BeginMap Callback: Map */ const BEGINMAP = 'Callbacks.BeginMap'; diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index f289a0ea..547dc125 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -75,7 +75,6 @@ class ShootManiaCallbacks implements CallbackListener { case Callbacks::SM_ONCAPTURE: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data)); break; - break; //Old Callbacks case 'LibXmlRpc_Rankings': $this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]); diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index c14f4377..8a72cf44 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -3,6 +3,7 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Models\RecordCallback; +use ManiaControl\Callbacks\Structures\Trackmania\DefaultEventStructure; use ManiaControl\ManiaControl; use ManiaControl\Utils\Formatter; @@ -29,12 +30,35 @@ class TrackManiaCallbacks implements CallbackListener { public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) { $this->maniaControl = $maniaControl; + // Register for script callbacks + $callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks'); + + // 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'); } + /** + * Handle Script Callbacks + * + * @param string $name + * @param mixed $data + */ + public function handleScriptCallbacks($name, $data) { + if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { + return; + } + switch ($name) { + //MP4 New Callbacks + case Callbacks::TM_EVENTDEFAULT: + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_EVENTDEFAULT, new DefaultEventStructure($this->maniaControl, $data)); + break; + } + } + + /** * Handle OnWayPoint Callback * @@ -52,16 +76,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 +118,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 +156,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); } From 1010c1db6b5ba9e86712598ede2e51ba12bacc5f Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 25 Mar 2017 13:57:42 +0100 Subject: [PATCH 26/73] callback renaming --- core/Callbacks/Callbacks.php | 59 ++++++++++++++------------- core/Callbacks/LibXmlRpcCallbacks.php | 58 +++++++++++++------------- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 37565f38..b74f331f 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -30,35 +30,36 @@ interface Callbacks { */ //NEW Callbacks - const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList'; - const MP_STARTSERVERSTART = 'Callbacks.ManiaPlanetStartServerStart'; - const MP_STARTSERVEREND = 'Callbacks.ManiaPlanetStartServerEnd'; - const MP_STARTMATCHSTART = 'Callbacks.ManiaPlanetStartMatchStart'; - const MP_STARTMATCHEND = 'Callbacks.ManiaPlanetStartMatchEnd'; - //const MP_STARTMAPSTART = 'Callbacks.ManiaPlanetStartMapStart'; - //const MP_STARTMAPEND = 'Callbacks.ManiaPlanetStartMapEnd'; - const MP_STARTROUNDSTART = 'Callbacks.ManiaPlanetStartRoundStart'; - const MP_STARTROUNDEND = 'Callbacks.ManiaPlanetStartRoundEnd'; - const MP_STARTTURNSTART = 'Callbacks.ManiaPlanetStartTurnStart'; - const MP_STARTTURNEND = 'Callbacks.ManiaPlanetStartTurnEnd'; - const MP_STARTPLAYLOOPSTART = 'Callbacks.ManiaPlanetStartPlayLoopStart'; - const MP_STARTPLAYLOOPEND = 'Callbacks.ManiaPlanetStartPlayLoopEnd'; - const MP_ENDTURNSTART = 'Callbacks.ManiaPlanetEndTurnStart'; - const MP_ENDTURNEND = 'Callbacks.ManiaPlanetEndTurnEnd'; - const MP_ENDROUNDSTART = 'Callbacks.ManiaPlanetEndRoundStart'; - const MP_ENDROUNDEND = 'Callbacks.ManiaPlanetEndRoundEnd'; - //const MP_ENDMAPSTART = 'Callbacks.ManiaPlanetEndMapStart'; - //const MP_ENDMAPEND = 'Callbacks.ManiaPlanetEndMapEnd'; - const MP_ENDMATCHSTART = 'Callbacks.ManiaPlanetEndMatchStart'; - const MP_ENDMATCHEND = 'Callbacks.ManiaPlanetEndMatchEnd'; - const MP_ENDSERVERSTART = 'Callbacks.ManiaPlanetEndServerStart'; - const MP_ENDSERVEREND = 'Callbacks.ManiaPlanetEndServerEnd'; - const MP_LOADINGMAPSTART = 'Callbacks.ManiaPlanetLoadingMapStart'; - const MP_LOADINGMAPEND = 'Callbacks.ManiaPlanetLoadingMapEnd'; - const MP_UNLOADINGMAPSTART = 'Callbacks.ManiaPlanetUnLoadingMapStart'; - const MP_UNLOADINGMAPEND = 'Callbacks.ManiaPlanetUnLoadingMapEnd'; - const MP_PODIUMSTART = 'Callbacks.ManiaPlanetPodiumStart'; - const MP_PODIUMEND = 'Callbacks.ManiaPlanetPodiumEnd'; + 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"; diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 4338ae86..ee4659bd 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -44,26 +44,25 @@ class LibXmlRpcCallbacks implements CallbackListener { * @param mixed $data */ public function handleScriptCallback($name, $data) { - if(!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)){ + var_dump($name); + if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { return; } - var_dump($name); - //var_dump($data); switch ($name) { //New callbacks - case 'XmlRpc.CallbacksList': + case Callbacks::XMLRPC_CALLBACKSLIST: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data)); break; - case 'Maniaplanet.StartServer_Start': + case Callbacks::MP_STARTSERVERSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data)); break; - case 'Maniaplanet.StartServer_End': + case Callbacks::MP_STARTSERVEREND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVEREND, new StartServerStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.StartMatch_Start': + case Callbacks::MP_STARTMATCHSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTMATCHSTART, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.StartMatch_End': + 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 @@ -74,34 +73,34 @@ class LibXmlRpcCallbacks implements CallbackListener { $this->maniaControl->getMapManager()->handleScriptBeginMap($jsonData->map->uid, 'False'); //TODO Test if json is correctly parsed break; - case 'ManiaPlanet.StartRound_Start': + case Callbacks::MP_STARTROUNDSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTROUNDSTART, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.StartRound_End': + case Callbacks::MP_STARTROUNDEND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTROUNDEND, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.StartTurn_Start': + case Callbacks::MP_STARTTURNSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTTURNSTART, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.StartTurn_End': + case Callbacks::MP_STARTTURNEND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTTURNEND, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.StartPlayLoop_Start': - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTPLAYLOOPSTART, new StartEndStructure($this->maniaControl, $data)); + case Callbacks::MP_STARTPLAYLOOP: + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTPLAYLOOP, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.StartPlayLoop_End': - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTPLAYLOOPEND, new StartEndStructure($this->maniaControl, $data)); + case Callbacks::MP_ENDPLAYLOOP: + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDPLAYLOOP, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.EndTurn_Start': + case Callbacks::MP_ENDTURNSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDTURNSTART, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.EndTurn_End': + case Callbacks::MP_ENDTURNEND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDTURNEND, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.EndRound_Start': + case Callbacks::MP_ENDROUNDSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDROUNDSTART, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.EndRound_End': + case Callbacks::MP_ENDROUNDEND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDROUNDEND, new StartEndStructure($this->maniaControl, $data)); break; case 'Maniaplanet.EndMap_Start': @@ -110,38 +109,37 @@ class LibXmlRpcCallbacks implements CallbackListener { case 'Maniaplanet.EndMap_End': //Use the MapManager Callback $this->maniaControl->getMapManager()->handleScriptEndMap(); //Verify if better here or at EndMap_End break; - case 'ManiaPlanet.EndMatch_Start': + case Callbacks::MP_ENDMATCHSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDMATCHSTART, new StartEndStructure($this->maniaControl, $data)); break; - case 'ManiaPlanet.EndMatch_End': + case Callbacks::MP_ENDMATCHEND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDMATCHEND, new StartEndStructure($this->maniaControl, $data)); break; - case 'Maniaplanet.EndServer_Start': + case Callbacks::MP_ENDSERVERSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDSERVERSTART, new StartServerStructure($this->maniaControl, $data)); break; - case 'Maniaplanet.EndServer_End': + case Callbacks::MP_ENDSERVEREND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_ENDSERVEREND, new StartServerStructure($this->maniaControl, $data)); break; - case 'Maniaplanet.LoadingMap_Start': + case Callbacks::MP_LOADINGMAPSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPSTART); break; - case 'Maniaplanet.LoadingMap_End': + 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 'Maniaplanet.UnloadingMap_Start': + 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 'Maniaplanet.UnloadingMap_End': + case Callbacks::MP_UNLOADINGMAPEND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_LOADINGMAPEND); break; - case 'Maniaplanet.Podium_Start': + case Callbacks::MP_PODIUMSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMSTART); break; - case 'Maniaplanet.Podium_End': $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMEND); break; From 120a0e21699bacab54a390aa93678c1d3aad6d23 Mon Sep 17 00:00:00 2001 From: Jocy Wolff Date: Sat, 25 Mar 2017 18:40:15 +0100 Subject: [PATCH 27/73] Updated to ManiaLink v3 --- core/Admin/AdminLists.php | 6 +- core/Configurator/Configurator.php | 18 +- core/Configurator/ManiaControlSettings.php | 16 +- core/Configurator/ScriptSettings.php | 9 +- core/ManiaExchange/ManiaExchangeList.php | 2 +- core/Manialinks/ManialinkManager.php | 11 +- core/Manialinks/StyleManager.php | 2 +- core/Maps/MapList.php | 2 +- core/Players/PlayerList.php | 2 +- core/Plugins/InstallMenu.php | 10 +- core/Plugins/PluginMenu.php | 19 +- core/Server/ServerOptionsMenu.php | 10 +- libs/FML/Components/CheckBox.php | 362 +++-- libs/FML/Components/CheckBoxDesign.php | 163 +++ libs/FML/Components/ValuePicker.php | 308 ++-- libs/FML/Controls/Audio.php | 340 +++-- libs/FML/Controls/Control.php | 1270 +++++++++++------ libs/FML/Controls/Entry.php | 632 +++++--- libs/FML/Controls/FileEntry.php | 91 +- libs/FML/Controls/Frame.php | 194 ++- libs/FML/Controls/Frame3d.php | 241 +++- libs/FML/Controls/FrameInstance.php | 161 ++- libs/FML/Controls/Gauge.php | 417 ++++-- libs/FML/Controls/Graph.php | 82 ++ libs/FML/Controls/Label.php | 938 ++++++++---- libs/FML/Controls/Labels/Label_Button.php | 53 +- libs/FML/Controls/Labels/Label_Text.php | 171 +-- libs/FML/Controls/Quad.php | 981 +++++++++---- libs/FML/Controls/Quads/Quad_321Go.php | 31 +- libs/FML/Controls/Quads/Quad_BgRaceScore2.php | 77 +- libs/FML/Controls/Quads/Quad_Bgs1.php | 161 ++- libs/FML/Controls/Quads/Quad_Bgs1InRace.php | 161 ++- libs/FML/Controls/Quads/Quad_BgsButtons.php | 37 +- .../Quads/Quad_BgsChallengeMedals.php | 35 +- .../FML/Controls/Quads/Quad_BgsPlayerCard.php | 51 +- libs/FML/Controls/Quads/Quad_Copilot.php | 47 +- libs/FML/Controls/Quads/Quad_Emblems.php | 29 +- libs/FML/Controls/Quads/Quad_EnergyBar.php | 35 +- .../FML/Controls/Quads/Quad_Hud3dEchelons.php | 41 +- libs/FML/Controls/Quads/Quad_Hud3dIcons.php | 39 +- .../Controls/Quads/Quad_Icons128x128_1.php | 151 +- .../Quads/Quad_Icons128x128_Blink.php | 151 +- .../FML/Controls/Quads/Quad_Icons128x32_1.php | 83 +- libs/FML/Controls/Quads/Quad_Icons64x64_1.php | 195 +-- libs/FML/Controls/Quads/Quad_Icons64x64_2.php | 53 +- .../Controls/Quads/Quad_ManiaPlanetLogos.php | 37 +- .../Quads/Quad_ManiaPlanetMainMenu.php | 45 +- .../Controls/Quads/Quad_ManiaplanetSystem.php | 35 +- libs/FML/Controls/Quads/Quad_MedalsBig.php | 37 +- libs/FML/Controls/Quads/Quad_TitleLogos.php | 31 +- .../Quad_UIConstructionBullet_Buttons.php | 69 +- .../Quads/Quad_UIConstruction_Buttons.php | 137 +- .../Quads/Quad_UIConstruction_Buttons2.php | 47 +- .../Quads/Quad_UiSMSpectatorScoreBig.php | 65 +- libs/FML/Controls/TextEdit.php | 452 ++++++ libs/FML/Controls/Video.php | 340 +++-- libs/FML/CustomUI.php | 472 +++--- libs/FML/Elements/Dico.php | 473 +++--- libs/FML/Elements/Format.php | 290 ++-- libs/FML/Elements/FrameModel.php | 248 ++-- libs/FML/Elements/Including.php | 112 +- libs/FML/Elements/Music.php | 112 +- libs/FML/Elements/SimpleScript.php | 114 +- libs/FML/Form/Parameters.php | 32 + libs/FML/ManiaCode.php | 599 ++++---- libs/FML/ManiaCode/AddBuddy.php | 112 +- libs/FML/ManiaCode/AddFavorite.php | 206 ++- libs/FML/ManiaCode/Element.php | 27 +- libs/FML/ManiaCode/GetSkin.php | 220 +-- libs/FML/ManiaCode/Go_To.php | 112 +- libs/FML/ManiaCode/InstallMacroblock.php | 219 +-- libs/FML/ManiaCode/InstallMap.php | 166 ++- libs/FML/ManiaCode/InstallPack.php | 220 +-- libs/FML/ManiaCode/InstallReplay.php | 166 ++- libs/FML/ManiaCode/InstallScript.php | 220 +-- libs/FML/ManiaCode/InstallSkin.php | 220 +-- libs/FML/ManiaCode/JoinServer.php | 206 ++- libs/FML/ManiaCode/PlayMap.php | 166 ++- libs/FML/ManiaCode/PlayReplay.php | 166 ++- libs/FML/ManiaCode/ShowMessage.php | 112 +- libs/FML/ManiaCode/ViewReplay.php | 166 ++- libs/FML/ManiaLink.php | 787 ++++++---- libs/FML/ManiaLinks.php | 281 ++-- libs/FML/Models/CheckBoxDesign.php | 129 -- libs/FML/Script/Builder.php | 337 +++-- libs/FML/Script/Features/ActionTrigger.php | 227 +-- libs/FML/Script/Features/CheckBoxFeature.php | 407 +++--- libs/FML/Script/Features/Clock.php | 211 ++- libs/FML/Script/Features/ControlScript.php | 269 ++-- libs/FML/Script/Features/EntrySubmit.php | 191 ++- libs/FML/Script/Features/GraphCurve.php | 303 ++++ libs/FML/Script/Features/KeyAction.php | 267 ++-- libs/FML/Script/Features/MapInfo.php | 169 ++- libs/FML/Script/Features/Menu.php | 245 ++-- libs/FML/Script/Features/MenuElement.php | 140 +- libs/FML/Script/Features/Paging.php | 716 ++++++---- libs/FML/Script/Features/PagingButton.php | 140 +- libs/FML/Script/Features/PagingPage.php | 131 +- libs/FML/Script/Features/PlayerProfile.php | 219 +-- libs/FML/Script/Features/Preload.php | 113 ++ libs/FML/Script/Features/ScriptFeature.php | 55 +- libs/FML/Script/Features/Toggle.php | 324 +++-- libs/FML/Script/Features/Tooltip.php | 327 +++-- libs/FML/Script/Features/UISound.php | 368 +++-- .../Script/Features/ValuePickerFeature.php | 392 ++--- libs/FML/Script/Script.php | 534 +++---- libs/FML/Script/ScriptConstant.php | 130 +- libs/FML/Script/ScriptFunction.php | 130 +- libs/FML/Script/ScriptInclude.php | 147 +- libs/FML/Script/ScriptLabel.php | 239 ++-- libs/FML/Stylesheet/Mood.php | 761 ++++++---- libs/FML/Stylesheet/SkyGradientKey.php | 117 ++ libs/FML/Stylesheet/Style3d.php | 621 +++++--- libs/FML/Stylesheet/Stylesheet.php | 204 +-- libs/FML/Types/Actionable.php | 100 +- libs/FML/Types/BackgroundColorable.php | 32 + libs/FML/Types/BgColorable.php | 21 - libs/FML/Types/Colorable.php | 32 + libs/FML/Types/Container.php | 80 +- libs/FML/Types/Identifiable.php | 39 + libs/FML/Types/Imageable.php | 32 + libs/FML/Types/Linkable.php | 98 +- libs/FML/Types/MultiLineable.php | 66 + libs/FML/Types/NewLineable.php | 37 +- libs/FML/Types/Playable.php | 144 +- libs/FML/Types/Renderable.php | 20 +- libs/FML/Types/ScriptFeatureable.php | 20 +- libs/FML/Types/Scriptable.php | 66 +- libs/FML/Types/Styleable.php | 29 +- libs/FML/Types/SubStyleable.php | 46 +- libs/FML/Types/TextFormatable.php | 121 +- libs/FML/UniqueID.php | 159 ++- libs/FML/autoload.php | 31 - 133 files changed, 16194 insertions(+), 8949 deletions(-) create mode 100644 libs/FML/Components/CheckBoxDesign.php create mode 100644 libs/FML/Controls/Graph.php create mode 100644 libs/FML/Controls/TextEdit.php create mode 100644 libs/FML/Form/Parameters.php delete mode 100644 libs/FML/Models/CheckBoxDesign.php create mode 100644 libs/FML/Script/Features/GraphCurve.php create mode 100644 libs/FML/Script/Features/Preload.php create mode 100644 libs/FML/Stylesheet/SkyGradientKey.php create mode 100644 libs/FML/Types/BackgroundColorable.php delete mode 100644 libs/FML/Types/BgColorable.php create mode 100644 libs/FML/Types/Colorable.php create mode 100644 libs/FML/Types/Identifiable.php create mode 100644 libs/FML/Types/Imageable.php create mode 100644 libs/FML/Types/MultiLineable.php delete mode 100644 libs/FML/autoload.php diff --git a/core/Admin/AdminLists.php b/core/Admin/AdminLists.php index dff133f2..e667b577 100644 --- a/core/Admin/AdminLists.php +++ b/core/Admin/AdminLists.php @@ -10,6 +10,7 @@ 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\ManiaControl; @@ -88,9 +89,10 @@ 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); @@ -120,7 +122,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $pageFrame = new Frame(); $frame->add($pageFrame); - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); $posY = $height / 2 - 10; } diff --git a/core/Configurator/Configurator.php b/core/Configurator/Configurator.php index f3a9ed83..da3cb229 100644 --- a/core/Configurator/Configurator.php +++ b/core/Configurator/Configurator.php @@ -9,6 +9,7 @@ use FML\Controls\Quads\Quad_BgRaceScore2; use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_UIConstruction_Buttons; use FML\ManiaLink; +use FML\Script\Script; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; @@ -134,8 +135,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; } @@ -199,15 +199,16 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn $frame = new Frame(); $manialink->add($frame); - $frame->setPosition($menuPosX, $menuPosY, 34); + $frame->setPosition($menuPosX, $menuPosY, ManialinkManager::MAIN_MANIALINK_Z_VALUE); $backgroundQuad = new Quad(); $frame->add($backgroundQuad); - $backgroundQuad->setZ(-2)->setSize($menuWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle); + $backgroundQuad->setZ(-1)->setSize($menuWidth, $menuHeight)->setStyles($quadStyle, $quadSubstyle); $menuItemsFrame = new Frame(); $frame->add($menuItemsFrame); $menuItemsFrame->setX($menuWidth * -0.5 + $menuListWidth * 0.5); + $menuItemsFrame->setZ(-1); $itemsBackgroundQuad = new Quad(); $menuItemsFrame->add($itemsBackgroundQuad); @@ -226,8 +227,9 @@ 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->add($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) { @@ -251,12 +253,12 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn // 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); + $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); + $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; } diff --git a/core/Configurator/ManiaControlSettings.php b/core/Configurator/ManiaControlSettings.php index f964508b..0a26e7f3 100644 --- a/core/Configurator/ManiaControlSettings.php +++ b/core/Configurator/ManiaControlSettings.php @@ -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); @@ -112,8 +112,8 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $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); @@ -150,7 +150,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { if ($index % $pageMaxCount === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); $posY = $height * 0.41 - $settingHeight * 1.5; } @@ -239,8 +239,8 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $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); @@ -258,7 +258,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $pageFrame = new Frame(); $frame->add($pageFrame); $posY = $height * 0.41; - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); } $classLabel = new Label_Text(); diff --git a/core/Configurator/ScriptSettings.php b/core/Configurator/ScriptSettings.php index 6dbd0115..2c1eb2f5 100644 --- a/core/Configurator/ScriptSettings.php +++ b/core/Configurator/ScriptSettings.php @@ -221,8 +221,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $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); @@ -249,7 +249,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $pageFrame = new Frame(); $frame->add($pageFrame); $posY = $height * 0.41; - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); } $settingFrame = new Frame(); @@ -293,8 +293,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $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; } diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index c10c8e97..a88d5f73 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -189,7 +189,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $pageFrame = new Frame(); $frame->add($pageFrame); $posY = $height / 2 - 16; - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); } // Map Frame diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 71200c87..7d4ba59b 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -27,10 +27,11 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener /* * 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 @@ -236,6 +237,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener public function sendManialink($manialinkText, $logins = null, $timeout = 0, $hideOnClick = false) { $manialinkText = (string) $manialinkText; + var_dump($manialinkText); + if (!$manialinkText) { return true; } diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index 8fc1886e..6d8faaed 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -193,7 +193,7 @@ class StyleManager { $pageCountLabel->setHAlign($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); } } diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 2494543d..068166eb 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -253,7 +253,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $pageFrame = new Frame(); $frame->add($pageFrame); $posY = $height / 2 - 10; - $paging->addPage($pageFrame, $pageNumber); + $paging->addPageControl($pageFrame, $pageNumber); $pageNumber++; } diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index f01b6456..c324691b 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -179,7 +179,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $pageFrame = new Frame(); $frame->add($pageFrame); - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); $posY = $height / 2 - 10; } diff --git a/core/Plugins/InstallMenu.php b/core/Plugins/InstallMenu.php index 7dccd77b..21e667d9 100644 --- a/core/Plugins/InstallMenu.php +++ b/core/Plugins/InstallMenu.php @@ -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(); @@ -102,7 +102,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { $frame->add($pageCountLabel); $pageCountLabel->setHAlign($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(); @@ -121,7 +121,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { // New page $pageFrame = new Frame(); $frame->add($pageFrame); - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); $posY = $height * 0.41; } @@ -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) { } diff --git a/core/Plugins/PluginMenu.php b/core/Plugins/PluginMenu.php index 92a6b43e..c42ce1a1 100644 --- a/core/Plugins/PluginMenu.php +++ b/core/Plugins/PluginMenu.php @@ -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(); @@ -114,8 +114,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $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); @@ -149,7 +149,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns if ($index % $pageMaxCount === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); $posY = $height * 0.41; } @@ -186,11 +186,10 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $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); @@ -278,7 +277,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns if ($index % $pageSettingsMaxCount === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); $posY = $height * 0.41 - $settingHeight * 1.5; } @@ -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) diff --git a/core/Server/ServerOptionsMenu.php b/core/Server/ServerOptionsMenu.php index 5d73f495..4e92497d 100644 --- a/core/Server/ServerOptionsMenu.php +++ b/core/Server/ServerOptionsMenu.php @@ -104,7 +104,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList } /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() + * @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle() */ public static function getTitle() { return 'Server Options'; @@ -241,7 +241,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList } /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() + * @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu() */ public function getMenu($width, $height, Script $script, Player $player) { $paging = new Paging(); @@ -269,7 +269,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList $frame->add($pageCountLabel); $pageCountLabel->setHAlign($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); // Pages $posY = 0.; @@ -287,7 +287,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList $pageFrame = new Frame(); $frame->add($pageFrame); $posY = $height * 0.41; - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); } $optionsFrame = new Frame(); @@ -326,7 +326,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList } /** - * @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_SERVER_OPTIONS)) { diff --git a/libs/FML/Components/CheckBox.php b/libs/FML/Components/CheckBox.php index 04703262..3955d9a7 100644 --- a/libs/FML/Components/CheckBox.php +++ b/libs/FML/Components/CheckBox.php @@ -5,7 +5,6 @@ namespace FML\Components; use FML\Controls\Entry; use FML\Controls\Frame; use FML\Controls\Quad; -use FML\Models\CheckBoxDesign; use FML\Script\Features\CheckBoxFeature; use FML\Script\Features\ScriptFeature; use FML\Types\Renderable; @@ -14,144 +13,257 @@ use FML\Types\ScriptFeatureable; /** * CheckBox Component * + * @uses Quad * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CheckBox implements Renderable, ScriptFeatureable { - /* - * Protected properties - */ - protected $name = null; - protected $feature = null; +class CheckBox implements Renderable, ScriptFeatureable +{ - /** - * Create a new CheckBox Component - * - * @param string $name (optional) CheckBox name - * @param bool $default (optional) Default value - * @param Quad $quad (optional) CheckBox quad - */ - public function __construct($name = null, $default = null, Quad $quad = null) { - $this->feature = new CheckBoxFeature(); - $this->setName($name); - $this->setDefault($default); - $this->setQuad($quad); - } + /** + * @var string $name CheckBox name + */ + protected $name = null; - /** - * Set the name - * - * @param string $name CheckBox name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var CheckBoxFeature $feature CheckBox Feature + */ + protected $feature = null; - /** - * Set the default value - * - * @param bool $default Default value - * @return static - */ - public function setDefault($default) { - $this->feature->setDefault($default); - return $this; - } + /** + * Construct a new CheckBox + * + * @api + * @param string $name (optional) CheckBox name + * @param bool $default (optional) Default value + * @param Quad $quad (optional) CheckBox quad + */ + public function __construct($name = null, $default = null, Quad $quad = null) + { + $this->feature = new CheckBoxFeature(); + if ($name) { + $this->setName($name); + } + if ($default !== null) { + $this->setDefault($default); + } + if ($quad) { + $this->setQuad($quad); + } + } - /** - * Set the enabled Design - * - * @param string $style Style name or image url - * @param string $subStyle SubStyle name - * @return static - */ - public function setEnabledDesign($style, $subStyle = null) { - if ($style instanceof CheckBoxDesign) { - $this->feature->setEnabledDesign($style); - } else { - $checkBoxDesign = new CheckBoxDesign($style, $subStyle); - $this->feature->setEnabledDesign($checkBoxDesign); - } - return $this; - } + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Set the disabled Design - * - * @param string $style Style name or image url - * @param string $subStyle SubStyle name - * @return static - */ - public function setDisabledDesign($style, $subStyle = null) { - if ($style instanceof CheckBoxDesign) { - $this->feature->setDisabledDesign($style); - } else { - $checkBoxDesign = new CheckBoxDesign($style, $subStyle); - $this->feature->setDisabledDesign($checkBoxDesign); - } - return $this; - } + /** + * Set the name + * + * @api + * @param string $name CheckBox name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } - /** - * Set the CheckBox Quad - * - * @param Quad $quad CheckBox Quad - * @return static - */ - public function setQuad(Quad $quad = null) { - $this->feature->setQuad($quad); - return $this; - } + /** + * Get the default value + * + * @api + * @return bool + */ + public function getDefault() + { + return $this->feature->getDefault(); + } - /** - * @see \FML\Types\ScriptFeatureable::getScriptFeatures() - */ - public function getScriptFeatures() { - return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry()); - } + /** + * Set the default value + * + * @api + * @param bool $default Default value + * @return static + */ + public function setDefault($default) + { + $this->feature->setDefault($default); + return $this; + } - /** - * Get the CheckBox Quad - * - * @param bool $createIfEmpty (optional) Create the Quad if it's not set - * @return \FML\Controls\Quad - */ - public function getQuad($createIfEmpty = true) { - if (!$this->feature->getQuad() && $createIfEmpty) { - $quad = new Quad(); - $quad->setSize(10, 10); - $this->setQuad($quad); - } - return $this->feature->getQuad(); - } + /** + * Get the enabled design + * + * @api + * @return CheckBoxDesign + */ + public function getEnabledDesign() + { + return $this->feature->getEnabledDesign(); + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $frame = new Frame(); + /** + * Set the enabled design + * + * @api + * @param string|CheckBoxDesign $style Style name, image url or checkbox design + * @param string $subStyle SubStyle name + * @return static + */ + public function setEnabledDesign($style, $subStyle = null) + { + if ($style instanceof CheckBoxDesign) { + $this->feature->setEnabledDesign($style); + } else { + $checkBoxDesign = new CheckBoxDesign($style, $subStyle); + $this->feature->setEnabledDesign($checkBoxDesign); + } + return $this; + } - $quad = $this->getQuad(); - $frame->add($quad); + /** + * Get the disabled design + * + * @api + * @return CheckBoxDesign + */ + public function getDisabledDesign() + { + return $this->feature->getDisabledDesign(); + } - $entry = $this->buildEntry(); - $frame->add($entry); - $this->feature->setEntry($entry); + /** + * Set the disabled design + * + * @api + * @param string|CheckBoxDesign $style Style name, image url or checkbox design + * @param string $subStyle SubStyle name + * @return static + */ + public function setDisabledDesign($style, $subStyle = null) + { + if ($style instanceof CheckBoxDesign) { + $this->feature->setDisabledDesign($style); + } else { + $checkBoxDesign = new CheckBoxDesign($style, $subStyle); + $this->feature->setDisabledDesign($checkBoxDesign); + } + return $this; + } - return $frame->render($domDocument); - } + /** + * Get the CheckBox Quad + * + * @api + * @return Quad + */ + public function getQuad() + { + $quad = $this->feature->getQuad(); + if ($quad) { + return $quad; + } + return $this->createQuad(); + } + + /** + * Set the CheckBox Quad + * + * @api + * @param Quad $quad CheckBox Quad + * @return static + */ + public function setQuad(Quad $quad) + { + $this->feature->setQuad($quad); + return $this; + } + + /** + * Create the CheckBox Quad + * + * @return Quad + */ + protected function createQuad() + { + $quad = new Quad(); + $quad->setSize(10, 10); + $this->setQuad($quad); + return $quad; + } + + /** + * Get the hidden Entry + * + * @return Entry + */ + public function getEntry() + { + $entry = $this->feature->getEntry(); + if ($entry) { + return $entry; + } + return $this->createEntry(); + } + + /** + * Set the hidden Entry + * + * @param Entry $entry Hidden Entry + * @return static + */ + public function setEntry(Entry $entry) + { + $this->feature->setEntry($entry); + return $this; + } + + /** + * Create the hidden Entry + * + * @return Entry + */ + protected function createEntry() + { + $entry = new Entry(); + $entry->setVisible(false) + ->setName($this->name); + $this->setEntry($entry); + return $entry; + } + + /** + * @see ScriptFeatureable::getScriptFeatures() + */ + public function getScriptFeatures() + { + return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry()); + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $frame = new Frame(); + + $quad = $this->getQuad(); + $frame->addChild($quad); + + $entry = $this->getEntry(); + $frame->addChild($entry); + + return $frame->render($domDocument); + } - /** - * Build the hidden Entry - * - * @return \FML\Controls\Entry - */ - protected function buildEntry() { - $entry = new Entry(); - $entry->setVisible(false)->setName($this->name); - return $entry; - } } diff --git a/libs/FML/Components/CheckBoxDesign.php b/libs/FML/Components/CheckBoxDesign.php new file mode 100644 index 00000000..54eee25a --- /dev/null +++ b/libs/FML/Components/CheckBoxDesign.php @@ -0,0 +1,163 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class CheckBoxDesign implements Imageable, Styleable, SubStyleable +{ + + /** + * @var string $style Style name + */ + protected $style = null; + + /** + * @var string $subStyle SubStyle name + */ + protected $subStyle = null; + + /** + * @var string $imageUrl Image url + */ + protected $imageUrl = null; + + /** + * Create the default Design + * + * @return static + */ + public static function defaultDesign() + { + return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check); + } + + /** + * Construct a new CheckBox Design + * + * @api + * @param string $style (optional) Style name or image url + * @param string $subStyle (optional) SubStyle name + */ + public function __construct($style = null, $subStyle = null) + { + if ($subStyle) { + $this->setStyles($style, $subStyle); + } elseif ($style) { + $this->setImageUrl($style); + } + } + + /** + * @see Styleable::getStyle() + */ + public function getStyle() + { + return $this->style; + } + + /** + * @see Styleable::setStyle() + */ + public function setStyle($style) + { + $this->style = (string)$style; + $this->url = null; + return $this; + } + + /** + * @see SubStyleable::getSubStyle() + */ + public function getSubStyle() + { + return $this->subStyle; + } + + /** + * @see SubStyleable::setSubStyle() + */ + public function setSubStyle($subStyle) + { + $this->subStyle = (string)$subStyle; + $this->url = null; + return $this; + } + + /** + * @see SubStyleable::setStyles() + */ + public function setStyles($style, $subStyle) + { + return $this->setStyle($style) + ->setSubStyle($subStyle); + } + + /** + * Get the image url + * + * @api + * @return string + */ + public function getImageUrl() + { + return $this->imageUrl; + } + + /** + * Set the image url + * + * @api + * @param string $imageUrl Image url + * @return static + */ + public function setImageUrl($imageUrl) + { + $this->style = null; + $this->subStyle = null; + $this->imageUrl = (string)$imageUrl; + return $this; + } + + /** + * Apply the Design to the given Quad + * + * @api + * @param Quad $quad CheckBox Quad + * @return static + */ + public function applyToQuad(Quad $quad) + { + if ($this->imageUrl) { + $quad->setImageUrl($this->imageUrl); + } elseif ($this->style) { + $quad->setStyles($this->style, $this->subStyle); + } + return $this; + } + + /** + * Get the CheckBox Design string + * + * @return string + */ + public function getDesignString() + { + if ($this->imageUrl) { + return $this->imageUrl; + } + return $this->style . "|" . $this->subStyle; + } + +} diff --git a/libs/FML/Components/ValuePicker.php b/libs/FML/Components/ValuePicker.php index c7e8bba7..0a9e4df2 100644 --- a/libs/FML/Components/ValuePicker.php +++ b/libs/FML/Components/ValuePicker.php @@ -13,122 +13,224 @@ use FML\Types\ScriptFeatureable; /** * ValuePicker Component * + * @uses Entry * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ValuePicker implements Renderable, ScriptFeatureable { - /* - * Protected properties - */ - protected $name = null; - protected $feature = null; +class ValuePicker implements Renderable, ScriptFeatureable +{ - /** - * Create a new ValuePicker Component - * - * @param string $name (optional) CheckBox name - * @param array $values (optional) Possible values - * @param bool $default (optional) Default value - * @param Label $label (optional) ValuePicker label - */ - public function __construct($name = null, array $values = array(), $default = null, Label $label = null) { - $this->feature = new ValuePickerFeature(); - $this->setName($name); - $this->setValues($values); - $this->setDefault($default); - $this->setLabel($label); - } + /** + * @var string $name ValuePicker name + */ + protected $name = null; - /** - * Set Name - * - * @param string $name ValuePicker name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var ValuePickerFeature $feature ValuePicker Feature + */ + protected $feature = null; - /** - * Set the possible values - * - * @param array $values Possible values - * @return static - */ - public function setValues(array $values) { - $this->feature->setValues($values); - return $this; - } + /** + * Create a new ValuePicker + * + * @api + * @param string $name (optional) ValuePicker name + * @param string[] $values (optional) Possible values + * @param string $default (optional) Default value + * @param Label $label (optional) ValuePicker label + */ + public function __construct($name = null, array $values = null, $default = null, Label $label = null) + { + $this->feature = new ValuePickerFeature(); + if ($name) { + $this->setName($name); + } + if ($values) { + $this->setValues($values); + } + if ($default !== null) { + $this->setDefault($default); + } + if ($label) { + $this->setLabel($label); + } + } - /** - * Set the default value - * - * @param bool $default Default value - * @return static - */ - public function setDefault($default) { - $this->feature->setDefault($default); - return $this; - } + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Set the ValuePicker Label - * - * @param Label $label ValuePicker Label - * @return static - */ - public function setLabel(Label $label = null) { - $this->feature->setLabel($label); - return $this; - } + /** + * Set the name + * + * @api + * @param string $name ValuePicker name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } - /** - * Get the ValuePicker Label - * - * @param bool $createIfEmpty (optional) Create the Label if it's not set - * @return \FML\Controls\Label - */ - public function getLabel($createIfEmpty = true) { - if (!$this->feature->getLabel() && $createIfEmpty) { - $label = new Label(); - $this->setLabel($label); - } - return $this->feature->getLabel(); - } + /** + * Get the possible values + * + * @api + * @return string[] + */ + public function getValues() + { + return $this->feature->getValues(); + } - /** - * @see \FML\Types\ScriptFeatureable::getScriptFeatures() - */ - public function getScriptFeatures() { - return ScriptFeature::collect($this->feature, $this->getLabel(), $this->feature->getEntry()); - } + /** + * Set the possible values + * + * @api + * @param array $values Possible values + * @return static + */ + public function setValues(array $values) + { + $this->feature->setValues($values); + return $this; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $frame = new Frame(); + /** + * Get the default value + * + * @api + * @return string + */ + public function getDefault() + { + return $this->feature->getDefault(); + } - $label = $this->getLabel(); - $frame->add($label); + /** + * Set the default value + * + * @api + * @param bool $default Default value + * @return static + */ + public function setDefault($default) + { + $this->feature->setDefault($default); + return $this; + } - $entry = $this->buildEntry(); - $frame->add($entry); - $this->feature->setEntry($entry); + /** + * Get the Label + * + * @api + * @return Label + */ + public function getLabel() + { + $label = $this->feature->getLabel(); + if ($label) { + return $label; + } + return $this->createLabel(); + } - return $frame->render($domDocument); - } + /** + * Set the Label + * + * @api + * @param Label $label ValuePicker Label + * @return static + */ + public function setLabel(Label $label) + { + $this->feature->setLabel($label); + return $this; + } + + /** + * Create the Label + * + * @return Label + */ + protected function createLabel() + { + $label = new Label(); + $this->setLabel($label); + return $label; + } + + /** + * Get the hidden Entry + * + * @return Entry + */ + public function getEntry() + { + $entry = $this->feature->getEntry(); + if ($entry) { + return $entry; + } + return $this->createEntry(); + } + + /** + * Set the hidden Entry + * + * @param Entry $entry Hidden Entry + * @return static + */ + public function setEntry(Entry $entry) + { + $this->feature->setEntry($entry); + return $this; + } + + /** + * Create the hidden Entry + * + * @return Entry + */ + protected function createEntry() + { + $entry = new Entry(); + $entry->setVisible(false) + ->setName($this->name); + $this->setEntry($entry); + return $entry; + } + + /** + * @see ScriptFeatureable::getScriptFeatures() + */ + public function getScriptFeatures() + { + return ScriptFeature::collect($this->feature, $this->getLabel(), $this->feature->getEntry()); + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $frame = new Frame(); + + $label = $this->getLabel(); + $frame->addChild($label); + + $entry = $this->getEntry(); + $frame->addChild($entry); + + return $frame->render($domDocument); + } - /** - * Build the hidden Entry - * - * @return \FML\Controls\Entry - */ - protected function buildEntry() { - $entry = new Entry(); - $entry->setVisible(false)->setName($this->name); - return $entry; - } } diff --git a/libs/FML/Controls/Audio.php b/libs/FML/Controls/Audio.php index d640709e..9f2d4deb 100644 --- a/libs/FML/Controls/Audio.php +++ b/libs/FML/Controls/Audio.php @@ -10,108 +10,262 @@ use FML\Types\Scriptable; * (CMlMediaPlayer) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Audio extends Control implements Playable, Scriptable { - /* - * Protected properties - */ - protected $tagName = 'audio'; - protected $data = null; - protected $dataId = null; - protected $play = null; - protected $looping = true; - protected $music = null; - protected $volume = 1.; - protected $scriptEvents = null; +class Audio extends Control implements Playable, Scriptable +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlMediaPlayer'; - } + /** + * @var string $data Data url + */ + protected $data = null; - /** - * @see \FML\Types\Playable::setData() - */ - public function setData($data) { - $this->data = (string)$data; - return $this; - } + /** + * @var string $dataId Data id + */ + protected $dataId = null; - /** - * @see \FML\Types\Playable::setDataId() - */ - public function setDataId($dataId) { - $this->dataId = (string)$dataId; - return $this; - } + /** + * @var bool $play Play automaticcaly + */ + protected $play = null; - /** - * @see \FML\Types\Playable::setPlay() - */ - public function setPlay($play) { - $this->play = ($play ? 1 : 0); - return $this; - } + /** + * @var bool $looping Looping + */ + protected $looping = true; - /** - * @see \FML\Types\Playable::setLooping() - */ - public function setLooping($looping) { - $this->looping = ($looping ? 1 : 0); - return $this; - } + /** + * @var bool $music Music type + */ + protected $music = null; - /** - * @see \FML\Types\Playable::setMusic() - */ - public function setMusic($music) { - $this->music = ($music ? 1 : 0); - return $this; - } + /** + * @var float $volume Volume + */ + protected $volume = 1.; - /** - * @see \FML\Types\Playable::setVolume() - */ - public function setVolume($volume) { - $this->volume = (float)$volume; - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; + + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; + + /** + * @see Playable::getData() + */ + public function getData() + { + return $this->data; + } + + /** + * @see Playable::setData() + */ + public function setData($data) + { + $this->data = (string)$data; + return $this; + } + + /** + * @see Playable::getDataId() + */ + public function getDataId() + { + return $this->dataId; + } + + /** + * @see Playable::setDataId() + */ + public function setDataId($dataId) + { + $this->dataId = (string)$dataId; + return $this; + } + + /** + * @see Playable::getPlay() + */ + public function getPlay() + { + return $this->play; + } + + /** + * @see Playable::setPlay() + */ + public function setPlay($play) + { + $this->play = (bool)$play; + return $this; + } + + /** + * @see Playable::getLooping() + */ + public function getLooping() + { + return $this->looping; + } + + /** + * @see Playable::setLooping() + */ + public function setLooping($looping) + { + $this->looping = (bool)$looping; + return $this; + } + + /** + * @see Playable::getMusic() + */ + public function getMusic() + { + return $this->music; + } + + /** + * @see Playable::setMusic() + */ + public function setMusic($music) + { + $this->music = (bool)$music; + return $this; + } + + /** + * @see Playable::getVolume() + */ + public function getVolume() + { + return $this->volume; + } + + /** + * @see Playable::setVolume() + */ + public function setVolume($volume) + { + $this->volume = (float)$volume; + return $this; + } + + /** + * @see Scriptable::getScriptEvents() + */ + public function getScriptEvents() + { + return $this->scriptEvents; + } + + /** + * @see Scriptable::setScriptEvents() + */ + public function setScriptEvents($scriptEvents) + { + $this->scriptEvents = (bool)$scriptEvents; + return $this; + } + + /** + * @see Scriptable::getScriptAction() + */ + public function getScriptAction() + { + return $this->scriptAction; + } + + /** + * @see Scriptable::setScriptAction() + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null) + { + $this->scriptAction = (string)$scriptAction; + $this->setScriptActionParameters($scriptActionParameters); + return $this; + } + + /** + * @see Scriptable::getScriptActionParameters() + */ + public function getScriptActionParameters() + { + return $this->scriptActionParameters; + } + + /** + * @see Scriptable::setScriptActionParameters() + */ + public function setScriptActionParameters(array $scriptActionParameters = null) + { + $this->scriptActionParameters = $scriptActionParameters; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "audio"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlMediaPlayer"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->data) { + $domElement->setAttribute("data", $this->data); + } + if ($this->dataId) { + $domElement->setAttribute("dataid", $this->dataId); + } + if ($this->play) { + $domElement->setAttribute("play", 1); + } + if (!$this->looping) { + $domElement->setAttribute("looping", 0); + } + if ($this->music) { + $domElement->setAttribute("music", 1); + } + if ($this->volume != 1.) { + $domElement->setAttribute("volume", $this->volume); + } + if ($this->scriptEvents) { + $domElement->setAttribute("scriptevents", 1); + } + if ($this->scriptAction) { + $scriptAction = array($this->scriptAction); + if ($this->scriptActionParameters) { + $scriptAction = array_merge($scriptAction, $this->scriptActionParameters); + } + $domElement->setAttribute("scriptaction", implode("'", $scriptAction)); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->data) { - $xmlElement->setAttribute('data', $this->data); - } - if ($this->play) { - $xmlElement->setAttribute('play', $this->play); - } - if (!$this->looping) { - $xmlElement->setAttribute('looping', $this->looping); - } - if ($this->music) { - $xmlElement->setAttribute('music', $this->music); - } - if ($this->volume != 1.) { - $xmlElement->setAttribute('volume', $this->volume); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Control.php b/libs/FML/Controls/Control.php index 054dc76d..d9600db4 100644 --- a/libs/FML/Controls/Control.php +++ b/libs/FML/Controls/Control.php @@ -2,7 +2,6 @@ namespace FML\Controls; -use FML\Script\Builder; use FML\Script\Features\ActionTrigger; use FML\Script\Features\ControlScript; use FML\Script\Features\MapInfo; @@ -12,6 +11,7 @@ use FML\Script\Features\Toggle; use FML\Script\Features\Tooltip; use FML\Script\Features\UISound; use FML\Script\ScriptLabel; +use FML\Types\Identifiable; use FML\Types\Renderable; use FML\Types\ScriptFeatureable; use FML\UniqueID; @@ -21,485 +21,865 @@ use FML\UniqueID; * (CMlControl) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class Control implements Renderable, ScriptFeatureable { - /* - * Constants - */ - const CENTER = 'center'; - const CENTER2 = 'center2'; - const TOP = 'top'; - const RIGHT = 'right'; - const BOTTOM = 'bottom'; - const LEFT = 'left'; +abstract class Control implements Identifiable, Renderable, ScriptFeatureable +{ - /* - * Protected properties - */ - protected $tagName = 'control'; - protected $controlId = null; - protected $posX = 0.; - protected $posY = 0.; - protected $posZ = 0.; - protected $width = -1.; - protected $height = -1.; - protected $hAlign = self::CENTER; - protected $vAlign = self::CENTER2; - protected $scale = 1.; - protected $hidden = null; - protected $rotation = 0.; - /** @var string[] $classes */ - protected $classes = array(); - /** @var ScriptFeature[] $scriptFeatures */ - protected $scriptFeatures = array(); + /* + * Constants + */ + const CENTER = 'center'; + const CENTER2 = 'center2'; + const TOP = 'top'; + const RIGHT = 'right'; + const BOTTOM = 'bottom'; + const LEFT = 'left'; - /** - * Create a new Control object - * - * @param string $controlId (optional) Control id - * @return static - */ - public static function create($controlId = null) { - return new static($controlId); - } + /** + * @var string $controlId Control Id + */ + protected $controlId = null; - /** - * Construct a new Control object - * - * @param string $controlId (optional) Control id - */ - public function __construct($controlId = null) { - if ($controlId !== null) { - $this->setId($controlId); - } - } + /** + * @var float $posX X position + */ + protected $posX = 0.; - /** - * Check Id for dangerous characters and assign a new unique id if necessary - * - * @param bool $forceNewId (optional) Whether to force setting a newly generated id - * @return static - */ - public function checkId($forceNewId = false) { - if ($forceNewId || !$this->getId()) { - $this->setId(new UniqueID()); - return $this; - } - $dangerousCharacters = array(' ', ' ', '.', '|', '-', PHP_EOL); - $idCharacters = str_split($this->getId()); - $danger = false; - foreach ($idCharacters as $character) { - if (!in_array($character, $dangerousCharacters)) { - continue; - } - $danger = true; - break; - } - if ($danger) { - trigger_error("Please don't use special characters in ids, they might cause problems! (I stripped them for you.)"); - $controlId = str_ireplace($dangerousCharacters, '', $this->getId()); - $this->setId($controlId); - } - return $this; - } + /** + * @var float $posY Y position + */ + protected $posY = 0.; - /** - * Get the Control id - * - * @param bool $escaped (optional) Whether the id should be escaped for ManiaScript - * @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text - * @return string - */ - public function getId($escaped = false, $addApostrophes = false) { - if ($escaped) { - return Builder::escapeText($this->controlId, $addApostrophes); - } - return $this->controlId; - } + /** + * @var float $posZ Z position + */ + protected $posZ = 0.; - /** - * Set Control id - * - * @param string $controlId Control id - * @return static - */ - public function setId($controlId) { - $this->controlId = (string)$controlId; - return $this; - } + /** + * @var float $width Width + */ + protected $width = -1.; - /** - * Set Control position - * - * @param float $posX Horizontal position - * @param float $posY Vertical position - * @param float $posZ (optional) Depth - * @return static - */ - public function setPosition($posX, $posY, $posZ = null) { - $this->setX($posX); - $this->setY($posY); - if ($posZ !== null) { - $this->setZ($posZ); - } - return $this; - } + /** + * @var float $height Height + */ + protected $height = -1.; - /** - * Set X position - * - * @param float $posX Horizontal position - * @return static - */ - public function setX($posX) { - $this->posX = (float)$posX; - return $this; - } + /** + * @var string $horizontalAlign Horizontal alignment + */ + protected $horizontalAlign = self::CENTER; - /** - * Set Y position - * - * @param float $posY Vertical position - * @return static - */ - public function setY($posY) { - $this->posY = (float)$posY; - return $this; - } + /** + * @var string $verticalAlign Vertical alignment + */ + protected $verticalAlign = self::CENTER2; - /** - * Set Z position - * - * @param float $posZ Depth - * @return static - */ - public function setZ($posZ) { - $this->posZ = (float)$posZ; - return $this; - } + /** + * @var float $scale Scale + */ + protected $scale = 1.; - /** - * Set Control size - * - * @param float $width Control width - * @param float $height Control height - * @return static - */ - public function setSize($width, $height) { - $this->setWidth($width); - $this->setHeight($height); - return $this; - } + /** + * @var bool $visible Visibility + */ + protected $visible = true; - /** - * Set Control width - * - * @param float $width Control width - * @return static - */ - public function setWidth($width) { - $this->width = (float)$width; - return $this; - } + /** + * @var float $rotation Rotation + */ + protected $rotation = 0.; - /** - * Set Control height - * - * @param float $height Control height - * @return static - */ - public function setHeight($height) { - $this->height = (float)$height; - return $this; - } + /** + * @var string[] $classes Style classes + */ + protected $classes = array(); - /** - * Center alignment - * - * @return static - */ - public function centerAlign() { - $this->setAlign(self::CENTER, self::CENTER2); - return $this; - } + /** + * @var mixed[] $dataAttributes Data attributes + */ + protected $dataAttributes = array(); - /** - * Set horizontal and vertical alignment - * - * @param string $hAlign Horizontal alignment - * @param string $vAlign Vertical alignment - * @return static - */ - public function setAlign($hAlign, $vAlign) { - $this->setHAlign($hAlign); - $this->setVAlign($vAlign); - return $this; - } + /** + * @var ScriptFeature[] $scriptFeatures Script Features + */ + protected $scriptFeatures = array(); - /** - * Set horizontal alignment - * - * @param string $hAlign Horizontal alignment - * @return static - */ - public function setHAlign($hAlign) { - $this->hAlign = (string)$hAlign; - return $this; - } + /** + * Create a new Control + * + * @api + * @param string $controlId (optional) Control Id + * @return static + */ + public static function create($controlId = null) + { + return new static($controlId); + } - /** - * Set vertical alignment - * - * @param string $vAlign Vertical alignment - * @return static - */ - public function setVAlign($vAlign) { - $this->vAlign = (string)$vAlign; - return $this; - } + /** + * Construct a new Control + * + * @api + * @param string $controlId (optional) Control Id + */ + public function __construct($controlId = null) + { + if ($controlId) { + $this->setId($controlId); + } + } - /** - * Reset alignment - * - * @return static - */ - public function resetAlign() { - $this->setAlign(null, null); - return $this; - } + /** + * @see Identifiable::getId() + */ + public function getId() + { + return $this->controlId; + } - /** - * Set Control scale - * - * @param float $scale Control scale - * @return static - */ - public function setScale($scale) { - $this->scale = (float)$scale; - return $this; - } + /** + * @see Identifiable::setId() + */ + public function setId($controlId) + { + $this->controlId = (string)$controlId; + return $this; + } - /** - * Set visibility - * - * @param bool $visible Whether the Control should be visible - * @return static - */ - public function setVisible($visible = true) { - $this->hidden = ($visible ? 0 : 1); - return $this; - } + /** + * @see Identifiable::checkId() + */ + public function checkId() + { + return UniqueID::check($this); + } - /** - * Set Control rotation - * - * @param float $rotation Control rotation - * @return static - */ - public function setRotation($rotation) { - $this->rotation = (float)$rotation; - return $this; - } + /** + * Get the X position + * + * @api + * @return float + */ + public function getX() + { + return $this->posX; + } - /** - * Add a new class name - * - * @param string $class Class name - * @return static - */ - public function addClass($class) { - $class = (string)$class; - if (!in_array($class, $this->classes)) { - array_push($this->classes, $class); - } - return $this; - } + /** + * Set the X position + * + * @api + * @param float $posX Horizontal position + * @return static + */ + public function setX($posX) + { + $this->posX = (float)$posX; + return $this; + } - /** - * Add a dynamic Action Trigger - * - * @param string $actionName Action to trigger - * @param string $eventLabel (optional) Event on which the action is triggered - * @return static - */ - public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) { - if ($actionName instanceof ActionTrigger) { - $this->addScriptFeature($actionName); - } else { - $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel); - $this->addScriptFeature($actionTrigger); - } - return $this; - } + /** + * Get the Y position + * + * @api + * @return float + */ + public function getY() + { + return $this->posY; + } - /** - * Add a new Script Feature - * - * @param ScriptFeature $scriptFeature Script Feature - * @return static - */ - public function addScriptFeature(ScriptFeature $scriptFeature) { - if (!in_array($scriptFeature, $this->scriptFeatures, true)) { - array_push($this->scriptFeatures, $scriptFeature); - } - return $this; - } + /** + * Set the Y position + * + * @api + * @param float $posY Vertical position + * @return static + */ + public function setY($posY) + { + $this->posY = (float)$posY; + return $this; + } - /** - * Add a dynamic Feature opening the current map info - * - * @param string $eventLabel (optional) Event on which the map info will be opened - * @return static - */ - public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) { - $mapInfo = new MapInfo($this, $eventLabel); - $this->addScriptFeature($mapInfo); - return $this; - } + /** + * Get the Z position + * + * @api + * @return float + */ + public function getZ() + { + return $this->posZ; + } - /** - * Add a dynamic Feature to open a specific player profile - * - * @param string $login Login of the player - * @param string $eventLabel (optional) Event on which the player profile will be opened - * @return static - */ - public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) { - $playerProfile = new PlayerProfile($login, $this, $eventLabel); - $this->addScriptFeature($playerProfile); - return $this; - } + /** + * Set the Z position + * + * @api + * @param float $posZ Depth + * @return static + */ + public function setZ($posZ) + { + $this->posZ = (float)$posZ; + return $this; + } - /** - * Add a dynamic Feature playing a UISound - * - * @param string $soundName UISound name - * @param int $variant (optional) Sound variant - * @param string $eventLabel (optional) Event on which the sound will be played - * @return static - */ - public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) { - $uiSound = new UISound($soundName, $this, $variant, $eventLabel); - $this->addScriptFeature($uiSound); - return $this; - } + /** + * Set the Control position + * + * @api + * @param float $posX Horizontal position + * @param float $posY Vertical position + * @param float $posZ (optional) Depth + * @return static + */ + public function setPosition($posX, $posY, $posZ = null) + { + $this->setX($posX) + ->setY($posY); + if ($posZ !== null) { + $this->setZ($posZ); + } + return $this; + } - /** - * Add a dynamic Feature toggling another Control - * - * @param Control $toggledControl Toggled Control - * @param string $labelName (optional) Script label name - * @param bool $onlyShow (optional) Whether it should only show the Control but not toggle - * @param bool $onlyHide (optional) Whether it should only hide the Control but not toggle - * @return static - */ - public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) { - $toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide); - $this->addScriptFeature($toggle); - return $this; - } + /** + * Get the width + * + * @api + * @return float + */ + public function getWidth() + { + return $this->width; + } - /** - * Add a dynamic Feature showing a Tooltip on hovering - * - * @param Control $tooltipControl Tooltip Control - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @return static - */ - public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) { - $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert); - $this->addScriptFeature($tooltip); - return $this; - } + /** + * Set the width + * + * @api + * @param float $width Control width + * @return static + */ + public function setWidth($width) + { + $this->width = (float)$width; + return $this; + } - /** - * Add a dynamic Feature showing a Tooltip on hovering - * - * @param Label $tooltipControl Tooltip Control - * @param string $text Text to display on the Tooltip Label - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @return static - */ - public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) { - $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert, $text); - $this->addScriptFeature($tooltip); - return $this; - } + /** + * Get the height + * + * @api + * @return float + */ + public function getHeight() + { + return $this->height; + } - /** - * Add a custom Control Script text part - * - * @param string $scriptText Script text - * @param string $label (optional) Script label name - * @return static - */ - public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) { - $customText = new ControlScript($this, $scriptText, $label); - $this->addScriptFeature($customText); - return $this; - } + /** + * Set the height + * + * @api + * @param float $height Control height + * @return static + */ + public function setHeight($height) + { + $this->height = (float)$height; + return $this; + } - /** - * Remove all Script Features - * - * @return static - */ - public function removeScriptFeatures() { - $this->scriptFeatures = array(); - return $this; - } + /** + * Set the size + * + * @api + * @param float $width Control width + * @param float $height Control height + * @return static + */ + public function setSize($width, $height) + { + return $this->setWidth($width) + ->setHeight($height); + } - /** - * @see \FML\Types\ScriptFeatureable::getScriptFeatures() - */ - public function getScriptFeatures() { - return $this->scriptFeatures; - } + /** + * Get the horizontal alignment + * + * @api + * @return string + */ + public function getHorizontalAlign() + { + return $this->horizontalAlign; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - if ($this->controlId) { - $xmlElement->setAttribute('id', $this->controlId); - } - if ($this->posX || $this->posY || $this->posZ) { - $xmlElement->setAttribute('posn', "{$this->posX} {$this->posY} {$this->posZ}"); - } - if ($this->width >= 0. || $this->height >= 0.) { - $xmlElement->setAttribute('sizen', "{$this->width} {$this->height}"); - } - if ($this->hAlign !== self::LEFT) { - $xmlElement->setAttribute('halign', $this->hAlign); - } - if ($this->vAlign !== self::TOP) { - $xmlElement->setAttribute('valign', $this->vAlign); - } - if ($this->scale != 1.) { - $xmlElement->setAttribute('scale', $this->scale); - } - if ($this->hidden) { - $xmlElement->setAttribute('hidden', $this->hidden); - } - if ($this->rotation) { - $xmlElement->setAttribute('rot', $this->rotation); - } - if (!empty($this->classes)) { - $classes = implode(' ', $this->classes); - $xmlElement->setAttribute('class', $classes); - } - return $xmlElement; - } + /** + * Set the horizontal alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @return static + * @deprecated Use setHorizontalAlign() instead + */ + public function setHAlign($horizontalAlign) + { + return $this->setHorizontalAlign($horizontalAlign); + } + + /** + * Set the horizontal alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @return static + */ + public function setHorizontalAlign($horizontalAlign) + { + $this->horizontalAlign = (string)$horizontalAlign; + return $this; + } + + /** + * Get the vertical alignment + * + * @api + * @return string + */ + public function getVerticalAlign() + { + return $this->verticalAlign; + } + + /** + * Set the vertical alignment + * + * @api + * @param string $verticalAlign Vertical alignment + * @return static + * @deprecated + */ + public function setVAlign($verticalAlign) + { + return $this->setVerticalAlign($verticalAlign); + } + + /** + * Set the vertical alignment + * + * @api + * @param string $verticalAlign Vertical alignment + * @return static + */ + public function setVerticalAlign($verticalAlign) + { + $this->verticalAlign = (string)$verticalAlign; + return $this; + } + + /** + * Set the horizontal and the vertical alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @param string $verticalAlign Vertical alignment + * @return static + */ + public function setAlign($horizontalAlign, $verticalAlign) + { + return $this->setHorizontalAlign($horizontalAlign) + ->setVerticalAlign($verticalAlign); + } + + /** + * Center the alignment + * + * @api + * @return static + */ + public function centerAlign() + { + return $this->setAlign(self::CENTER, self::CENTER2); + } + + /** + * Clear the alignment + * + * @api + * @return static + */ + public function clearAlign() + { + $this->horizontalAlign = null; + $this->verticalAlign = null; + return $this; + } + + /** + * Get the scale + * + * @api + * @return float + */ + public function getScale() + { + return $this->scale; + } + + /** + * Set the scale + * + * @api + * @param float $scale Control scale + * @return static + */ + public function setScale($scale) + { + $this->scale = (float)$scale; + return $this; + } + + /** + * Get the visibility + * + * @api + * @return bool + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set the visibility + * + * @api + * @param bool $visible If the Control should be visible + * @return static + */ + public function setVisible($visible) + { + $this->visible = $visible; + return $this; + } + + /** + * Get the rotation + * + * @api + * @return float + */ + public function getRotation() + { + return $this->rotation; + } + + /** + * Set the rotation + * + * @api + * @param float $rotation Control rotation + * @return static + */ + public function setRotation($rotation) + { + $this->rotation = (float)$rotation; + return $this; + } + + /** + * Get style classes + * + * @api + * @return string[] + */ + public function getClasses() + { + return $this->classes; + } + + /** + * Add a new style class + * + * @api + * @param string $class Style class + * @return static + */ + public function addClass($class) + { + $class = (string)$class; + if (!in_array($class, $this->classes)) { + array_push($this->classes, $class); + } + return $this; + } + + /** + * Add new style classes + * + * @api + * @param string[] $classes Style classes + * @return static + */ + public function addClasses(array $classes) + { + foreach ($classes as $class) { + $this->addClass($class); + } + return $this; + } + + /** + * Remove all style classes + * + * @api + * @return static + */ + public function removeAllClasses() + { + $this->classes = array(); + return $this; + } + + /** + * Check if a data attribute is set + * + * @api + * @param string $name Name + * @return bool + */ + public function hasDataAttribute($name) + { + return isset($this->dataAttributes[$name]); + } + + /** + * Get data attribute + * + * @api + * @param string $name Name + * @return mixed + */ + public function getDataAttribute($name) + { + if (isset($this->dataAttributes[$name])) { + return $this->dataAttributes[$name]; + } + return null; + } + + /** + * Get data attributes + * + * @api + * @return mixed[] + */ + public function getDataAttributes() + { + return $this->dataAttributes; + } + + /** + * Add data attribute + * + * @api + * @param string $name Name + * @param mixed $value Value + * @return static + */ + public function addDataAttribute($name, $value) + { + $this->dataAttributes[$name] = $value; + return $this; + } + + /** + * Add multiple data attributes + * + * @api + * @param mixed[] $dataAttributes Data attributes + * @return static + */ + public function addDataAttributes(array $dataAttributes) + { + foreach ($dataAttributes as $name => $value) { + $this->addDataAttribute($name, $value); + } + return $this; + } + + /** + * Set data attributes (replacing all previous attributes) + * + * @api + * @param mixed[] $dataAttributes Data attributes + * @return static + */ + public function setDataAttributes(array $dataAttributes) + { + return $this->removeAllDataAttributes() + ->addDataAttributes($dataAttributes); + } + + /** + * Remove data attribute + * + * @api + * @param string $name Name + * @return static + */ + public function removeDataAttribute($name) + { + unset($this->dataAttributes[$name]); + return $this; + } + + /** + * Remove all data attributes + * + * @api + * @return static + */ + public function removeAllDataAttributes() + { + $this->dataAttributes = array(); + return $this; + } + + /** + * @see ScriptFeatureable::getScriptFeatures() + */ + public function getScriptFeatures() + { + return $this->scriptFeatures; + } + + /** + * Add a new Script Feature + * + * @api + * @param ScriptFeature $scriptFeature Script Feature + * @return static + */ + public function addScriptFeature(ScriptFeature $scriptFeature) + { + if (!in_array($scriptFeature, $this->scriptFeatures, true)) { + array_push($this->scriptFeatures, $scriptFeature); + } + return $this; + } + + /** + * Remove all Script Features + * + * @api + * @return static + * @deprecated use removeAllScriptFeatures() instead + */ + public function removeScriptFeatures() + { + return $this->removeAllScriptFeatures(); + } + + /** + * Remove all Script Features + * + * @api + * @return static + */ + public function removeAllScriptFeatures() + { + $this->scriptFeatures = array(); + return $this; + } + + /** + * Add a dynamic Action Trigger + * + * @api + * @param string $actionName Action to trigger + * @param string $eventLabel (optional) Event on which the action is triggered + * @return static + */ + public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) + { + $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel); + $this->addScriptFeature($actionTrigger); + return $this; + } + + /** + * Add a dynamic Feature opening the current map info + * + * @api + * @param string $eventLabel (optional) Event on which the map info will be opened + * @return static + */ + public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) + { + $mapInfo = new MapInfo($this, $eventLabel); + $this->addScriptFeature($mapInfo); + return $this; + } + + /** + * Add a dynamic Feature to open a specific player profile + * + * @api + * @param string $login Login of the player + * @param string $eventLabel (optional) Event on which the player profile will be opened + * @return static + */ + public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) + { + $playerProfile = new PlayerProfile($login, $this, $eventLabel); + $this->addScriptFeature($playerProfile); + return $this; + } + + /** + * Add a dynamic Feature playing a UISound + * + * @api + * @param string $soundName UISound name + * @param int $variant (optional) Sound variant + * @param string $eventLabel (optional) Event on which the sound will be played + * @return static + */ + public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) + { + $uiSound = new UISound($soundName, $this, $variant, $eventLabel); + $this->addScriptFeature($uiSound); + return $this; + } + + /** + * Add a dynamic Feature toggling another Control + * + * @api + * @param Control $toggledControl Toggled Control + * @param string $labelName (optional) Script label name + * @param bool $onlyShow (optional) If it should only show the Control but not toggle + * @param bool $onlyHide (optional) If it should only hide the Control but not toggle + * @return static + */ + public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) + { + $toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide); + $this->addScriptFeature($toggle); + return $this; + } + + /** + * Add a dynamic Feature showing a Tooltip on hovering + * + * @api + * @param Control $tooltipControl Tooltip Control + * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click + * @param bool $invert (optional) Whether the visibility toggling should be inverted + * @return static + */ + public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) + { + $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert); + $this->addScriptFeature($tooltip); + return $this; + } + + /** + * Add a dynamic Feature showing a Tooltip on hovering + * + * @api + * @param Label $tooltipLabel Tooltip Label + * @param string $text Text to display on the Tooltip Label + * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click + * @param bool $invert (optional) Whether the visibility toggling should be inverted + * @return static + */ + public function addTooltipLabelFeature(Label $tooltipLabel, $text, $stayOnClick = false, $invert = false) + { + $tooltip = new Tooltip($this, $tooltipLabel, $stayOnClick, $invert, $text); + $this->addScriptFeature($tooltip); + return $this; + } + + /** + * Add a custom Control Script text part + * + * @api + * @param string $scriptText Script text + * @param string $label (optional) Script label name + * @return static + */ + public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) + { + $customText = new ControlScript($this, $scriptText, $label); + $this->addScriptFeature($customText); + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement($this->getTagName()); + if ($this->controlId) { + $domElement->setAttribute("id", $this->controlId); + } + if ($this->posX || $this->posY || $this->posZ) { + $domElement->setAttribute("posn", "{$this->posX} {$this->posY} {$this->posZ}"); + } + if ($this->posZ) { + $domElement->setAttribute("z-index", $this->posZ); + } + if ($this->width >= 0. || $this->height >= 0.) { + $domElement->setAttribute("sizen", "{$this->width} {$this->height}"); + } + if ($this->horizontalAlign) { + $domElement->setAttribute("halign", $this->horizontalAlign); + } + if ($this->verticalAlign) { + $domElement->setAttribute("valign", $this->verticalAlign); + } + if ($this->scale != 1.) { + $domElement->setAttribute("scale", $this->scale); + } + if (!$this->visible) { + $domElement->setAttribute("hidden", "1"); + } + if ($this->rotation) { + $domElement->setAttribute("rot", $this->rotation); + } + if (!empty($this->classes)) { + $classes = implode(" ", $this->classes); + $domElement->setAttribute("class", $classes); + } + foreach ($this->dataAttributes as $dataAttributeName => $dataAttributeValue) { + $domElement->setAttribute("data-" . $dataAttributeName, $dataAttributeValue); + } + return $domElement; + } + + /** + * Get the tag name of the Control + * + * @return string + */ + abstract public function getTagName(); + + /** + * Get the ManiaScript class of the Control + * + * @return string + */ + abstract public function getManiaScriptClass(); - /** - * Get the ManiaScript class of the Control - * - * @return string - */ - public abstract function getManiaScriptClass(); } diff --git a/libs/FML/Controls/Entry.php b/libs/FML/Controls/Entry.php index 210e3df8..67258a6b 100644 --- a/libs/FML/Controls/Entry.php +++ b/libs/FML/Controls/Entry.php @@ -2,6 +2,7 @@ namespace FML\Controls; +use FML\Form\Parameters; use FML\Script\Features\EntrySubmit; use FML\Types\NewLineable; use FML\Types\Scriptable; @@ -13,205 +14,470 @@ use FML\Types\TextFormatable; * (CMlEntry) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable { - /* - * Protected properties - */ - protected $tagName = 'entry'; - protected $name = null; - protected $default = null; - protected $autoNewLine = null; - protected $scriptEvents = null; - protected $style = null; - protected $textColor = null; - protected $textSize = -1; - protected $textFont = null; - protected $focusAreaColor1 = null; - protected $focusAreaColor2 = null; - protected $autoComplete = null; +class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlEntry'; - } + /* + * Constants + */ + const FORMAT_Default = "Default"; + const FORMAT_Password = "Password"; + const FORMAT_NewPassword = "NewPassword"; - /** - * Get the Entry name - * - * @return string - */ - public function getName() { - return $this->name; - } + /** + * @var string $name Entry name + */ + protected $name = null; - /** - * Set Entry name - * - * @param string $name Entry name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $default Default value + */ + protected $default = null; - /** - * Get the default value - * - * @return mixed - */ - public function getDefault() { - return $this->default; - } + /** + * @var bool $selectText Select text + */ + protected $selectText = null; - /** - * Set default value - * - * @param string $default Default value - * @return static - */ - public function setDefault($default) { - $this->default = $default; - return $this; - } + /** + * @deprecated + * @var bool $autoNewLine Auto new line + */ + protected $autoNewLine = null; - /** - * @see \FML\Types\NewLineable::setAutoNewLine() - */ - public function setAutoNewLine($autoNewLine) { - $this->autoNewLine = ($autoNewLine ? 1 : 0); - return $this; - } + /** + * @var string $textFormat Text format + */ + protected $textFormat = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; - /** - * @see \FML\Types\TextFormatable::setTextColor() - */ - public function setTextColor($textColor) { - $this->textColor = (string)$textColor; - return $this; - } + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; - /** - * @see \FML\Types\TextFormatable::setTextSize() - */ - public function setTextSize($textSize) { - $this->textSize = (int)$textSize; - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * @see \FML\Types\TextFormatable::setTextFont() - */ - public function setTextFont($textFont) { - $this->textFont = (string)$textFont; - return $this; - } + /** + * @var string $textColor Text color + */ + protected $textColor = null; - /** - * @see \FML\Types\TextFormatable::setAreaColor() - */ - public function setAreaColor($areaColor) { - $this->focusAreaColor1 = (string)$areaColor; - return $this; - } + /** + * @var int $textSize Text size + */ + protected $textSize = null; - /** - * @see \FML\Types\TextFormatable::setAreaFocusColor() - */ - public function setAreaFocusColor($areaFocusColor) { - $this->focusAreaColor2 = (string)$areaFocusColor; - return $this; - } + /** + * @var string $textFont Text font + */ + protected $textFont = null; - /** - * Set auto completion - * - * @param bool $autoComplete Whether the default value should be automatically completed based on the current request parameters - * @return static - */ - public function setAutoComplete($autoComplete) { - $this->autoComplete = (bool)$autoComplete; - return $this; - } + /** + * @var string $areaColor Area color + */ + protected $areaColor = null; - /** - * Add a dynamic Feature submitting the Entry - * - * @param string $url Submit url - * @return static - */ - public function addSubmitFeature($url) { - $entrySubmit = new EntrySubmit($this, $url); - $this->addScriptFeature($entrySubmit); - return $this; - } + /** + * @var string $focusAreaColor Focus area color + */ + protected $focusAreaColor = null; + + /** + * @var bool $autoComplete Auto complete + */ + protected $autoComplete = null; + + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the name + * + * @api + * @param string $name Entry name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the default value + * + * @api + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * Set the default value + * + * @api + * @param string $default Default value + * @return static + */ + public function setDefault($default) + { + $this->default = $default; + return $this; + } + + /** + * Get select text + * + * @api + * @return bool + */ + public function getSelectText() + { + return $this->selectText; + } + + /** + * Set select text + * + * @api + * @param bool $selectText Select text + * @return static + */ + public function setSelectText($selectText) + { + $this->selectText = $selectText; + return $this; + } + + /** + * @see NewLineable::getAutoNewLine() + */ + public function getAutoNewLine() + { + return $this->autoNewLine; + } + + /** + * @see NewLineable::setAutoNewLine() + */ + public function setAutoNewLine($autoNewLine) + { + $this->autoNewLine = (bool)$autoNewLine; + return $this; + } + + /** + * Get text format + * + * @api + * @return string + */ + public function getTextFormat() + { + return $this->textFormat; + } + + /** + * Set text format + * + * @api + * @param string $textFormat Text format + * @return static + */ + public function setTextFormat($textFormat) + { + $this->textFormat = $textFormat; + return $this; + } + + /** + * @see Scriptable::getScriptEvents() + */ + public function getScriptEvents() + { + return $this->scriptEvents; + } + + /** + * @see Scriptable::setScriptEvents() + */ + public function setScriptEvents($scriptEvents) + { + $this->scriptEvents = (bool)$scriptEvents; + return $this; + } + + /** + * @see Scriptable::getScriptAction() + */ + public function getScriptAction() + { + return $this->scriptAction; + } + + /** + * @see Scriptable::setScriptAction() + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null) + { + $this->scriptAction = (string)$scriptAction; + $this->setScriptActionParameters($scriptActionParameters); + return $this; + } + + /** + * @see Scriptable::getScriptActionParameters() + */ + public function getScriptActionParameters() + { + return $this->scriptActionParameters; + } + + /** + * @see Scriptable::setScriptActionParameters() + */ + public function setScriptActionParameters(array $scriptActionParameters = null) + { + $this->scriptActionParameters = $scriptActionParameters; + return $this; + } + + /** + * @see Styleable::getStyle() + */ + public function getStyle() + { + return $this->style; + } + + /** + * @see Styleable::setStyle() + */ + public function setStyle($style) + { + $this->style = (string)$style; + return $this; + } + + /** + * @see TextFormatable::getTextColor() + */ + public function getTextColor() + { + return $this->textColor; + } + + /** + * @see TextFormatable::setTextColor() + */ + public function setTextColor($textColor) + { + $this->textColor = (string)$textColor; + return $this; + } + + /** + * @see TextFormatable::getTextSize() + */ + public function getTextSize() + { + return $this->textSize; + } + + /** + * @see TextFormatable::setTextSize() + */ + public function setTextSize($textSize) + { + $this->textSize = (int)$textSize; + return $this; + } + + /** + * @see TextFormatable::getTextFont() + */ + public function getTextFont() + { + return $this->textFont; + } + + /** + * @see TextFormatable::setTextFont() + */ + public function setTextFont($textFont) + { + $this->textFont = (string)$textFont; + return $this; + } + + /** + * @see TextFormatable::getAreaColor() + */ + public function getAreaColor() + { + return $this->areaColor; + } + + /** + * @see TextFormatable::setAreaColor() + */ + public function setAreaColor($areaColor) + { + $this->areaColor = (string)$areaColor; + return $this; + } + + /** + * @see TextFormatable::getAreaFocusColor() + */ + public function getAreaFocusColor() + { + return $this->focusAreaColor; + } + + /** + * @see TextFormatable::setAreaFocusColor() + */ + public function setAreaFocusColor($areaFocusColor) + { + $this->focusAreaColor = (string)$areaFocusColor; + return $this; + } + + /** + * Get auto completion + * + * @api + * @return bool + */ + public function getAutoComplete() + { + return $this->autoComplete; + } + + /** + * Set auto completion + * + * @api + * @param bool $autoComplete Automatically complete the default value based on the current request parameters + * @return static + */ + public function setAutoComplete($autoComplete) + { + $this->autoComplete = (bool)$autoComplete; + return $this; + } + + /** + * Add a dynamic Feature submitting the Entry + * + * @api + * @param string $url Submit url + * @return static + */ + public function addSubmitFeature($url) + { + $entrySubmit = new EntrySubmit($this, $url); + return $this->addScriptFeature($entrySubmit); + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "entry"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlEntry"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->name) { + $domElement->setAttribute("name", $this->name); + } + if ($this->default !== null) { + $domElement->setAttribute("default", $this->default); + } else if ($this->autoComplete) { + $value = Parameters::getValue($this->name); + if ($value) { + $domElement->setAttribute("default", $value); + } + } + if ($this->selectText) { + $domElement->setAttribute("selecttext", 1); + } + if ($this->autoNewLine) { + $domElement->setAttribute("autonewline", 1); + } + if ($this->textFormat) { + $domElement->setAttribute("textformat", $this->textFormat); + } + if ($this->scriptEvents) { + $domElement->setAttribute("scriptevents", 1); + } + if ($this->scriptAction) { + $scriptAction = array($this->scriptAction); + if ($this->scriptActionParameters) { + $scriptAction = array_merge($scriptAction, $this->scriptActionParameters); + } + $domElement->setAttribute("scriptaction", implode("'", $scriptAction)); + } + if ($this->style) { + $domElement->setAttribute("style", $this->style); + } + if ($this->textColor) { + $domElement->setAttribute("textcolor", $this->textColor); + } + if ($this->textSize) { + $domElement->setAttribute("textsize", $this->textSize); + } + if ($this->textFont) { + $domElement->setAttribute("textfont", $this->textFont); + } + if ($this->areaColor) { + $domElement->setAttribute("focusareacolor1", $this->areaColor); + } + if ($this->focusAreaColor) { + $domElement->setAttribute("focusareacolor2", $this->focusAreaColor); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->name) { - $xmlElement->setAttribute('name', $this->name); - } - if ($this->default !== null) { - $xmlElement->setAttribute('default', $this->default); - } else if ($this->autoComplete) { - $value = null; - if (array_key_exists($this->name, $_GET)) { - $value = $_GET[$this->name]; - } else if (array_key_exists($this->name, $_POST)) { - $value = $_POST[$this->name]; - } - if ($value) { - $xmlElement->setAttribute('default', $value); - } - } - if ($this->autoNewLine) { - $xmlElement->setAttribute('autonewline', $this->autoNewLine); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - if ($this->style) { - $xmlElement->setAttribute('style', $this->style); - } - if ($this->textColor) { - $xmlElement->setAttribute('textcolor', $this->textColor); - } - if ($this->textSize >= 0.) { - $xmlElement->setAttribute('textsize', $this->textSize); - } - if ($this->textFont) { - $xmlElement->setAttribute('textfont', $this->textFont); - } - if ($this->focusAreaColor1) { - $xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); - } - if ($this->focusAreaColor2) { - $xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/FileEntry.php b/libs/FML/Controls/FileEntry.php index 8ccbf2a7..3fc5fe69 100644 --- a/libs/FML/Controls/FileEntry.php +++ b/libs/FML/Controls/FileEntry.php @@ -7,42 +7,67 @@ namespace FML\Controls; * (CMlFileEntry) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class FileEntry extends Entry { - /* - * Protected properties - */ - protected $tagName = 'fileentry'; - protected $folder = null; +class FileEntry extends Entry +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlFileEntry'; - } + /** + * @var string $folder Folder + */ + protected $folder = null; - /** - * Set the base folder - * - * @param string $folder Base folder - * @return static - */ - public function setFolder($folder) { - $this->folder = (string)$folder; - return $this; - } + /** + * Get the folder + * + * @api + * @return string + */ + public function getFolder() + { + return $this->folder; + } + + /** + * Set the folder + * + * @api + * @param string $folder Base folder + * @return static + */ + public function setFolder($folder) + { + $this->folder = (string)$folder; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "fileentry"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlFileEntry"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->folder) { + $domElement->setAttribute("folder", $this->folder); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->folder) { - $xmlElement->setAttribute('folder', $this->folder); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Frame.php b/libs/FML/Controls/Frame.php index fbb677cb..2ab8a5e8 100644 --- a/libs/FML/Controls/Frame.php +++ b/libs/FML/Controls/Frame.php @@ -12,88 +12,132 @@ use FML\Types\ScriptFeatureable; * (CMlFrame) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Frame extends Control implements Container { - /* - * Protected properties - */ - protected $tagName = 'frame'; - /** @var Renderable[] $children */ - protected $children = array(); - /** @var Format $format */ - protected $format = null; +class Frame extends Control implements Container +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlFrame'; - } + /** + * @var Renderable[] $children Children + */ + protected $children = array(); - /** - * @see \FML\Types\Container::add() - */ - public function add(Renderable $child) { - if (!in_array($child, $this->children, true)) { - array_push($this->children, $child); - } - return $this; - } + /** + * @var Format $format Format + */ + protected $format = null; - /** - * @see \FML\Types\Container::removeChildren() - */ - public function removeChildren() { - $this->children = array(); - return $this; - } + /** + * @see Container::getChildren() + */ + public function getChildren() + { + return $this->children; + } - /** - * @see \FML\Types\Container::getFormat() - */ - public function getFormat($createIfEmpty = true) { - if (!$this->format && $createIfEmpty) { - $this->setFormat(new Format()); - } - return $this->format; - } + /** + * @see Container::addChild() + * @deprecated use addChild() instead + */ + public function add(Renderable $child) + { + return $this->addChild($child); + } - /** - * @see \FML\Types\Container::setFormat() - */ - public function setFormat(Format $format) { - $this->format = $format; - return $this; - } + /** + * @see Container::addChild() + */ + public function addChild(Renderable $child) + { + if (!in_array($child, $this->children, true)) { + array_push($this->children, $child); + } + return $this; + } - /** - * @see \FML\Controls\Control::getScriptFeatures() - */ - public function getScriptFeatures() { - $scriptFeatures = $this->scriptFeatures; - foreach ($this->children as $child) { - if ($child instanceof ScriptFeatureable) { - $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); - } - } - return $scriptFeatures; - } + /** + * @see Container::addChildren() + */ + public function addChildren(array $children) + { + foreach ($children as $child) { + $this->addChild($child); + } + return $this; + } + + /** + * @see Container::removeAllChildren() + */ + public function removeAllChildren() + { + $this->children = array(); + return $this; + } + + /** + * @see Container::getFormat() + */ + public function getFormat() + { + return $this->format; + } + + /** + * @see Container::setFormat() + */ + public function setFormat(Format $format = null) + { + $this->format = $format; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "frame"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlFrame"; + } + + /** + * @see Control::getScriptFeatures() + */ + public function getScriptFeatures() + { + $scriptFeatures = $this->scriptFeatures; + foreach ($this->children as $child) { + if ($child instanceof ScriptFeatureable) { + $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); + } + } + return $scriptFeatures; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->format) { + $formatXml = $this->format->render($domDocument); + $domElement->appendChild($formatXml); + } + foreach ($this->children as $child) { + $childXmlElement = $child->render($domDocument); + $domElement->appendChild($childXmlElement); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->format) { - $formatXml = $this->format->render($domDocument); - $xmlElement->appendChild($formatXml); - } - foreach ($this->children as $child) { - $childXmlElement = $child->render($domDocument); - $xmlElement->appendChild($childXmlElement); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Frame3d.php b/libs/FML/Controls/Frame3d.php index 36e6b506..8449005e 100644 --- a/libs/FML/Controls/Frame3d.php +++ b/libs/FML/Controls/Frame3d.php @@ -10,79 +10,184 @@ use FML\Types\Scriptable; * (CMlFrame) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Frame3d extends Frame implements Scriptable { - /* - * Constants - */ - const STYLE_BaseStation = 'BaseStation'; - const STYLE_BaseBoxCase = 'BaseBoxCase'; - const STYLE_Titlelogo = 'Titlelogo'; - const STYLE_ButtonBack = 'ButtonBack'; - const STYLE_ButtonNav = 'ButtonNav'; - const STYLE_ButtonH = 'ButtonH'; - const STYLE_Station3x3 = 'Station3x3'; - const STYLE_Title = 'Title'; - const STYLE_TitleEditor = 'TitleEditor'; - const STYLE_Window = 'Window'; +class Frame3d extends Frame implements Scriptable +{ - /* - * Protected properties - */ - protected $tagName = 'frame3d'; - protected $style3dId = null; - /** @var Style3d $style3d */ - protected $style3d = null; - protected $scriptEvents = null; + /* + * Constants + */ + const STYLE_BaseStation = 'BaseStation'; + const STYLE_BaseBoxCase = 'BaseBoxCase'; + const STYLE_TitleLogo = 'Titlelogo'; + const STYLE_ButtonBack = 'ButtonBack'; + const STYLE_ButtonNav = 'ButtonNav'; + const STYLE_ButtonH = 'ButtonH'; + const STYLE_Station3x3 = 'Station3x3'; + const STYLE_Title = 'Title'; + const STYLE_TitleEditor = 'TitleEditor'; + const STYLE_Window = 'Window'; - /** - * Set Style3d id - * - * @param string $style3dId Style3d id - * @return static - */ - public function setStyle3dId($style3dId) { - $this->style3dId = (string)$style3dId; - $this->style3d = null; - return $this; - } + /** + * @var string $style3dId Style3d id + */ + protected $style3dId = null; - /** - * Set Style3d - * - * @param Style3d $style3d Style3d object - * @return static - */ - public function setStyle3d(Style3d $style3d) { - $this->style3d = $style3d; - $this->style3dId = null; - return $this; - } + /** + * @var Style3d $style3d Style3d + */ + protected $style3d = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; + + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; + + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; + + /** + * Get the Style3d id + * + * @api + * @return string + */ + public function getStyle3dId() + { + return $this->style3dId; + } + + /** + * Set the Style3d id + * + * @api + * @param string $style3dId Style3d id + * @return static + */ + public function setStyle3dId($style3dId) + { + $this->style3dId = (string)$style3dId; + $this->style3d = null; + return $this; + } + + /** + * Get the Style3d + * + * @api + * @return Style3d + */ + public function getStyle3d() + { + return $this->style3d; + } + + /** + * Set the Style3d + * + * @api + * @param Style3d $style3d Style3d + * @return static + */ + public function setStyle3d(Style3d $style3d) + { + $this->style3dId = null; + $this->style3d = $style3d; + return $this; + } + + /** + * @see Scriptable::getScriptEvents() + */ + public function getScriptEvents() + { + return $this->scriptEvents; + } + + /** + * @see Scriptable::setScriptEvents() + */ + public function setScriptEvents($scriptEvents) + { + $this->scriptEvents = (bool)$scriptEvents; + return $this; + } + + /** + * @see Scriptable::getScriptAction() + */ + public function getScriptAction() + { + return $this->scriptAction; + } + + /** + * @see Scriptable::setScriptAction() + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null) + { + $this->scriptAction = (string)$scriptAction; + $this->setScriptActionParameters($scriptActionParameters); + return $this; + } + + /** + * @see Scriptable::getScriptActionParameters() + */ + public function getScriptActionParameters() + { + return $this->scriptActionParameters; + } + + /** + * @see Scriptable::setScriptActionParameters() + */ + public function setScriptActionParameters(array $scriptActionParameters = null) + { + $this->scriptActionParameters = $scriptActionParameters; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "frame3d"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->style3d) { + $this->style3d->checkId(); + $domElement->setAttribute("style3d", $this->style3d->getId()); + } else if ($this->style3dId) { + $domElement->setAttribute("style3d", $this->style3dId); + } + if ($this->scriptEvents) { + $domElement->setAttribute("scriptevents", 1); + } + if ($this->scriptAction) { + $scriptAction = array($this->scriptAction); + if ($this->scriptActionParameters) { + $scriptAction = array_merge($scriptAction, $this->scriptActionParameters); + } + $domElement->setAttribute("scriptaction", implode("'", $scriptAction)); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->style3d) { - $this->style3d->checkId(); - $xmlElement->setAttribute('style3d', $this->style3d->getId()); - } else if ($this->style3dId) { - $xmlElement->setAttribute('style3d', $this->style3dId); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/FrameInstance.php b/libs/FML/Controls/FrameInstance.php index 30914afc..c4bf2200 100644 --- a/libs/FML/Controls/FrameInstance.php +++ b/libs/FML/Controls/FrameInstance.php @@ -9,84 +9,101 @@ use FML\Elements\FrameModel; * (CMlFrame) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class FrameInstance extends Control { - /* - * Protected properties - */ - protected $tagName = 'frameinstance'; - protected $modelId = null; - /** @var FrameModel $model */ - protected $model = null; +class FrameInstance extends Control +{ - /** - * Create a new Frame Instance object - * - * @param string $modelId (optional) Frame Model id - * @param string $controlId (optional) Frame id - * @return static - */ - public static function create($modelId = null, $controlId = null) { - return new static($modelId, $controlId); - } + /** + * @var string $modelId FrameModel id + */ + protected $modelId = null; - /** - * Construct a new Frame Instance object - * - * @param string $modelId (optional) Frame Model id - * @param string $controlId (optional) Frame id - */ - public function __construct($modelId = null, $controlId = null) { - parent::__construct($controlId); - if ($modelId !== null) { - $this->setModelId($modelId); - } - } + /** + * @var FrameModel $model FrameModel + */ + protected $model = null; - /** - * Set Frame Model id - * - * @param string $modelId Frame Model id - * @return static - */ - public function setModelId($modelId) { - $this->modelId = (string)$modelId; - $this->model = null; - return $this; - } + /** + * Get the FrameModel id + * + * @api + * @return string + */ + public function getModelId() + { + return $this->modelId; + } - /** - * Set Frame Model - * - * @param FrameModel $frameModel Frame Model - * @return static - */ - public function setModel(FrameModel $frameModel) { - $this->model = $frameModel; - $this->modelId = null; - return $this; - } + /** + * Set the FrameModel id + * + * @api + * @param string $modelId FrameModel id + * @return static + */ + public function setModelId($modelId) + { + $this->modelId = (string)$modelId; + $this->model = null; + return $this; + } - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlFrame'; - } + /** + * Get the FrameModel + * + * @api + * @return FrameModel + */ + public function getModel() + { + return $this->model; + } + + /** + * Set the FrameModel + * + * @api + * @param FrameModel $frameModel FrameModel + * @return static + */ + public function setModel(FrameModel $frameModel) + { + $this->modelId = null; + $this->model = $frameModel; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "frameinstance"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlFrame"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->model) { + $this->model->checkId(); + $domElement->setAttribute("modelid", $this->model->getId()); + } else if ($this->modelId) { + $domElement->setAttribute("modelid", $this->modelId); + } + return $domElement; + } - /** - * @see \FML\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->model) { - $this->model->checkId(); - $xmlElement->setAttribute('modelid', $this->model->getId()); - } else if ($this->modelId) { - $xmlElement->setAttribute('modelid', $this->modelId); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Gauge.php b/libs/FML/Controls/Gauge.php index 9c24780a..b3338eb5 100644 --- a/libs/FML/Controls/Gauge.php +++ b/libs/FML/Controls/Gauge.php @@ -2,6 +2,7 @@ namespace FML\Controls; +use FML\Types\Colorable; use FML\Types\Styleable; /** @@ -9,152 +10,298 @@ use FML\Types\Styleable; * (CMlGauge) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Gauge extends Control implements Styleable { - /* - * Constants - */ - const STYLE_BgCard = 'BgCard'; - const STYLE_EnergyBar = 'EnergyBar'; - const STYLE_ProgressBar = 'ProgressBar'; - const STYLE_ProgressBarSmall = 'ProgressBarSmall'; +class Gauge extends Control implements Colorable, Styleable +{ - /* - * Protected properties - */ - protected $tagName = 'gauge'; - protected $ratio = 0.; - protected $grading = 1.; - protected $color = null; - protected $centered = null; - protected $clan = null; - protected $drawBg = 1; - protected $drawBlockBg = 1; - protected $style = null; + /* + * Constants + */ + const STYLE_BgCard = "BgCard"; + const STYLE_EnergyBar = "EnergyBar"; + const STYLE_ProgressBar = "ProgressBar"; + const STYLE_ProgressBarSmall = "ProgressBarSmall"; - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlGauge'; - } + /** + * @var float $ratio Ratio + */ + protected $ratio = 0.0; - /** - * Set ratio - * - * @param float $ratio Ratio value - * @return static - */ - public function setRatio($ratio) { - $this->ratio = (float)$ratio; - return $this; - } + /** + * @var float $grading Grading + */ + protected $grading = 1.; - /** - * Set grading - * - * @param float $grading Grading value - * @return static - */ - public function setGrading($grading) { - $this->grading = (float)$grading; - return $this; - } + /** + * @var string $color Color + */ + protected $color = null; - /** - * Set color - * - * @param string $color Gauge color - * @return static - */ - public function setColor($color) { - $this->color = (string)$color; - return $this; - } + /** + * @var bool $centered Centered + */ + protected $centered = null; - /** - * Set centered - * - * @param bool $centered Whether the Gauge is centered - * @return static - */ - public function setCentered($centered) { - $this->centered = ($centered ? 1 : 0); - return $this; - } + /** + * @var int $clan Clan number + */ + protected $clan = null; - /** - * Set clan - * - * @param int $clan Clan number - * @return static - */ - public function setClan($clan) { - $this->clan = (int)$clan; - return $this; - } + /** + * @var bool $drawBackground Draw background + */ + protected $drawBackground = true; - /** - * Set draw background - * - * @param bool $drawBg Whether the Gauges background should be drawn - * @return static - */ - public function setDrawBg($drawBg) { - $this->drawBg = ($drawBg ? 1 : 0); - return $this; - } + /** + * @var bool $drawBlockBackground Draw block background + */ + protected $drawBlockBackground = true; - /** - * Set draw block background - * - * @param bool $drawBlockBg Whether the Gauges block background should be drawn - * @return static - */ - public function setDrawBlockBg($drawBlockBg) { - $this->drawBlockBg = ($drawBlockBg ? 1 : 0); - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * Get the ratio + * + * @api + * @return float + */ + public function getRatio() + { + return $this->ratio; + } + + /** + * Set the ratio + * + * @api + * @param float $ratio Ratio value + * @return static + */ + public function setRatio($ratio) + { + $this->ratio = (float)$ratio; + return $this; + } + + /** + * Get the grading + * + * @api + * @return float + */ + public function getGrading() + { + return $this->grading; + } + + /** + * Set the grading + * + * @api + * @param float $grading Grading value + * @return static + */ + public function setGrading($grading) + { + $this->grading = (float)$grading; + return $this; + } + + /** + * @see Colorable::getColor + */ + public function getColor() + { + return $this->color; + } + + /** + * @see Colorable::setColor + */ + public function setColor($color) + { + $this->color = (string)$color; + return $this; + } + + /** + * Get centered + * + * @api + * @return bool + */ + public function getCentered() + { + return $this->centered; + } + + /** + * Set centered + * + * @api + * @param bool $centered If the Gauge should be centered + * @return static + */ + public function setCentered($centered) + { + $this->centered = (bool)$centered; + return $this; + } + + /** + * Get the clan + * + * @api + * @return int + */ + public function getClan() + { + return $this->clan; + } + + /** + * Set the clan + * + * @api + * @param int $clan Clan number + * @return static + */ + public function setClan($clan) + { + $this->clan = (int)$clan; + return $this; + } + + /** + * Get draw background + * + * @api + * @return bool + */ + public function getDrawBackground() + { + return $this->drawBackground; + } + + /** + * Set draw background + * + * @api + * @param bool $drawBackground If the Gauges background should be drawn + * @return static + * @deprecated use setDrawBackground() instead + */ + public function setDrawBg($drawBackground) + { + return $this->setDrawBackground($drawBackground); + } + + /** + * Set draw background + * + * @api + * @param bool $drawBackground If the Gauges background should be drawn + * @return static + */ + public function setDrawBackground($drawBackground) + { + $this->drawBackground = (bool)$drawBackground; + return $this; + } + + /** + * Get draw block background + * + * @api + * @return bool + */ + public function getDrawBlockBackground() + { + return $this->drawBlockBackground; + } + + /** + * Set draw block background + * + * @api + * @param bool $drawBlockBackground If the Gauges block background should be drawn + * @return static + */ + public function setDrawBlockBackground($drawBlockBackground) + { + $this->drawBlockBackground = (bool)$drawBlockBackground; + return $this; + } + + /** + * @see Styleable::getStyle() + */ + public function getStyle() + { + return $this->style; + } + + /** + * @see Styleable::setStyle() + */ + public function setStyle($style) + { + $this->style = (string)$style; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "gauge"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlGauge"; + } + + /** + * @see Control::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->ratio) { + $domElement->setAttribute("ratio", $this->ratio); + } + if ($this->grading != 1.) { + $domElement->setAttribute("grading", $this->grading); + } + if ($this->color) { + $domElement->setAttribute("color", $this->color); + } + if ($this->centered) { + $domElement->setAttribute("centered", 1); + } + if ($this->clan) { + $domElement->setAttribute("clan", $this->clan); + } + if (!$this->drawBackground) { + $domElement->setAttribute("drawbg", 0); + } + if (!$this->drawBlockBackground) { + $domElement->setAttribute("drawblockbg", 0); + } + if ($this->style) { + $domElement->setAttribute("style", $this->style); + } + return $domElement; + } - /** - * @see \FML\Control::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->ratio) { - $xmlElement->setAttribute('ratio', $this->ratio); - } - if ($this->grading != 1.) { - $xmlElement->setAttribute('grading', $this->grading); - } - if ($this->color) { - $xmlElement->setAttribute('color', $this->color); - } - if ($this->centered) { - $xmlElement->setAttribute('centered', $this->centered); - } - if ($this->clan) { - $xmlElement->setAttribute('clan', $this->clan); - } - if (!$this->drawBg) { - $xmlElement->setAttribute('drawbg', $this->drawBg); - } - if (!$this->drawBlockBg) { - $xmlElement->setAttribute('drawblockbg', $this->drawBlockBg); - } - if ($this->style) { - $xmlElement->setAttribute('style', $this->style); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Graph.php b/libs/FML/Controls/Graph.php new file mode 100644 index 00000000..6d84b5de --- /dev/null +++ b/libs/FML/Controls/Graph.php @@ -0,0 +1,82 @@ +curves; + } + + /** + * Add curve + * + * @api + * @param GraphCurve $curve Curve + * @return static + */ + public function addCurve(GraphCurve $curve) + { + $curve->setGraph($this); + $this->addScriptFeature($curve); + array_push($this->curves, $curve); + return $this; + } + + /** + * Add curves + * + * @api + * @param GraphCurve[] $curves Curves + * @return static + */ + public function addCurves(array $curves) + { + foreach ($curves as $curve) { + $this->addCurve($curve); + } + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "graph"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlGraph"; + } + +} diff --git a/libs/FML/Controls/Label.php b/libs/FML/Controls/Label.php index 887b47c5..5bcd9532 100644 --- a/libs/FML/Controls/Label.php +++ b/libs/FML/Controls/Label.php @@ -5,6 +5,7 @@ namespace FML\Controls; use FML\Script\Features\Clock; use FML\Types\Actionable; use FML\Types\Linkable; +use FML\Types\MultiLineable; use FML\Types\NewLineable; use FML\Types\Scriptable; use FML\Types\Styleable; @@ -15,303 +16,694 @@ use FML\Types\TextFormatable; * (CMlLabel) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Label extends Control implements Actionable, Linkable, NewLineable, Scriptable, Styleable, TextFormatable { - /* - * Protected properties - */ - protected $tagName = 'label'; - protected $text = null; - protected $textId = null; - protected $textPrefix = null; - protected $textEmboss = null; - protected $translate = null; - protected $maxLines = -1; - protected $opacity = 1.; - protected $action = null; - protected $actionKey = -1; - protected $url = null; - protected $urlId = null; - protected $manialink = null; - protected $manialinkId = null; - protected $autoNewLine = null; - protected $scriptEvents = null; - protected $style = null; - protected $textSize = -1; - protected $textFont = null; - protected $textColor = null; - protected $focusAreaColor1 = null; - protected $focusAreaColor2 = null; +class Label extends Control implements Actionable, Linkable, NewLineable, MultiLineable, Scriptable, Styleable, TextFormatable +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlLabel'; - } + /** + * @var string $text Text + */ + protected $text = null; - /** - * Set text - * - * @param string $text Text value - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * @var string $textId Text ID + */ + protected $textId = null; - /** - * Set text id to use from Dico - * - * @param string $textId Text id - * @return static - */ - public function setTextId($textId) { - $this->textId = (string)$textId; - return $this; - } + /** + * @var string $textPrefix Text prefix + */ + protected $textPrefix = null; - /** - * Set text prefix - * - * @param string $textPrefix Text prefix - * @return static - */ - public function setTextPrefix($textPrefix) { - $this->textPrefix = (string)$textPrefix; - return $this; - } + /** + * @var bool $textEmboss Text emboss + */ + protected $textEmboss = null; - /** - * Set text emboss - * - * @param bool $textEmboss Whether the text should be embossed - * @return static - */ - public function setTextEmboss($textEmboss) { - $this->textEmboss = ($textEmboss ? 1 : 0); - return $this; - } + /** + * @var bool $translate Translate text + */ + protected $translate = null; - /** - * Set translate - * - * @param bool $translate Whether the text should be translated - * @return static - */ - public function setTranslate($translate) { - $this->translate = ($translate ? 1 : 0); - return $this; - } + /** + * @var int $maxLines Maximum lines + */ + protected $maxLines = -1; - /** - * Set max lines count - * - * @param int $maxLines Max lines count - * @return static - */ - public function setMaxLines($maxLines) { - $this->maxLines = (int)$maxLines; - return $this; - } + /** + * @var float $opacity Opacity + */ + protected $opacity = 1.; - /** - * @see \FML\Types\Actionable::getAction() - */ - public function getAction() { - return $this->action; - } + /** + * @var string $action Action + */ + protected $action = null; - /** - * @see \FML\Types\Actionable::setAction() - */ - public function setAction($action) { - $this->action = (string)$action; - return $this; - } + /** + * @var int $actionKey Action key + */ + protected $actionKey = -1; - /** - * @see \FML\Types\Actionable::setActionKey() - */ - public function setActionKey($actionKey) { - $this->actionKey = (int)$actionKey; - return $this; - } + /** + * @var string $url Url + */ + protected $url = null; - /** - * @see \FML\Types\Linkable::setUrl() - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * @var string $urlId Url ID + */ + protected $urlId = null; - /** - * @see \FML\Types\Linkable::setUrlId() - */ - public function setUrlId($urlId) { - $this->urlId = (string)$urlId; - return $this; - } + /** + * @var string $manialink Manialink + */ + protected $manialink = null; - /** - * @see \FML\Types\Linkable::setManialink() - */ - public function setManialink($manialink) { - $this->manialink = (string)$manialink; - return $this; - } + /** + * @var string $manialinkId Manialink ID + */ + protected $manialinkId = null; - /** - * @see \FML\Types\Linkable::setManialinkId() - */ - public function setManialinkId($manialinkId) { - $this->manialinkId = (string)$manialinkId; - return $this; - } + /** + * @var bool $autoNewLine Automatic new line + */ + protected $autoNewLine = null; - /** - * @see \FML\Types\NewLineable::setAutoNewLine() - */ - public function setAutoNewLine($autoNewLine) { - $this->autoNewLine = ($autoNewLine ? 1 : 0); - return $this; - } + /** + * @var float $lineSpacing Line spacing + */ + protected $lineSpacing = -1.; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; - /** - * @see \FML\Types\TextFormatable::setTextSize() - */ - public function setTextSize($textSize) { - $this->textSize = (int)$textSize; - return $this; - } + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; - /** - * @see \FML\Types\TextFormatable::setTextFont() - */ - public function setTextFont($textFont) { - $this->textFont = (string)$textFont; - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * @see \FML\Types\TextFormatable::setTextColor() - */ - public function setTextColor($textColor) { - $this->textColor = (string)$textColor; - return $this; - } + /** + * @var int $textSize Text size + */ + protected $textSize = -1; - /** - * @see \FML\Types\TextFormatable::setAreaColor() - */ - public function setAreaColor($areaColor) { - $this->focusAreaColor1 = (string)$areaColor; - return $this; - } + /** + * @var string $textFont Text font + */ + protected $textFont = null; - /** - * @see \FML\Types\TextFormatable::setAreaFocusColor() - */ - public function setAreaFocusColor($areaFocusColor) { - $this->focusAreaColor2 = (string)$areaFocusColor; - return $this; - } + /** + * @var string $textColor Text color + */ + protected $textColor = null; - /** - * Add a dynamic Feature showing the current time - * - * @param bool $showSeconds (optional) Whether the seconds should be shown - * @param bool $showFullDate (optional) Whether the date should be shown - * @return static - */ - public function addClockFeature($showSeconds = true, $showFullDate = false) { - $clock = new Clock($this, $showSeconds, $showFullDate); - $this->addScriptFeature($clock); - return $this; - } + /** + * @var string $areaColor Area color + */ + protected $areaColor = null; + + /** + * @var string $focusAreaColor Focus area color + */ + protected $focusAreaColor = null; + + /** + * Get the text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the text + * + * @api + * @param string $text Text value + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * Get the text id to use from Dico + * + * @api + * @return string + */ + public function getTextId() + { + return $this->textId; + } + + /** + * Set the text id to use from Dico + * + * @api + * @param string $textId Text id + * @return static + */ + public function setTextId($textId) + { + $this->textId = (string)$textId; + return $this; + } + + /** + * Get the text prefix + * + * @api + * @return string + */ + public function getTextPrefix() + { + return $this->textPrefix; + } + + /** + * Set the text prefix + * + * @api + * @param string $textPrefix Text prefix + * @return static + */ + public function setTextPrefix($textPrefix) + { + $this->textPrefix = (string)$textPrefix; + return $this; + } + + /** + * Get text emboss + * + * @api + * @return bool + */ + public function getTextEmboss() + { + return $this->textEmboss; + } + + /** + * Set text emboss + * + * @api + * @param bool $textEmboss If the text should be embossed + * @return static + */ + public function setTextEmboss($textEmboss) + { + $this->textEmboss = (bool)$textEmboss; + return $this; + } + + /** + * Get translate + * + * @api + * @return bool + */ + public function getTranslate() + { + return $this->translate; + } + + /** + * Set translate + * + * @api + * @param bool $translate If the text should be translated + * @return static + */ + public function setTranslate($translate) + { + $this->translate = (bool)$translate; + return $this; + } + + /** + * Get the opacity + * + * @api + * @return float + */ + public function getOpacity() + { + return $this->opacity; + } + + /** + * Set the opacity + * + * @api + * @param float $opacity Opacity + * @return static + */ + public function setOpacity($opacity) + { + $this->opacity = (float)$opacity; + return $this; + } + + /** + * @see Actionable::getAction() + */ + public function getAction() + { + return $this->action; + } + + /** + * @see Actionable::setAction() + */ + public function setAction($action) + { + $this->action = (string)$action; + return $this; + } + + /** + * @see Actionable::getActionKey() + */ + public function getActionKey() + { + return $this->actionKey; + } + + /** + * @see Actionable::setActionKey() + */ + public function setActionKey($actionKey) + { + $this->actionKey = (int)$actionKey; + return $this; + } + + /** + * @see Linkable::getUrl() + */ + public function getUrl() + { + return $this->url; + } + + /** + * @see Linkable::setUrl() + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Linkable::getUrlId() + */ + public function getUrlId() + { + return $this->urlId; + } + + /** + * @see Linkable::setUrlId() + */ + public function setUrlId($urlId) + { + $this->urlId = (string)$urlId; + return $this; + } + + /** + * @see Linkable::getManialink() + */ + public function getManialink() + { + return $this->manialink; + } + + /** + * @see Linkable::setManialink() + */ + public function setManialink($manialink) + { + $this->manialink = (string)$manialink; + return $this; + } + + /** + * @see Linkable::getManialinkId() + */ + public function getManialinkId() + { + return $this->manialinkId; + } + + /** + * @see Linkable::setManialinkId() + */ + public function setManialinkId($manialinkId) + { + $this->manialinkId = (string)$manialinkId; + return $this; + } + + /** + * @see MultiLineable::getAutoNewLine() + */ + public function getAutoNewLine() + { + return $this->autoNewLine; + } + + /** + * @see MultiLineable::setAutoNewLine() + */ + public function setAutoNewLine($autoNewLine) + { + $this->autoNewLine = (bool)$autoNewLine; + return $this; + } + + /** + * @see MultiLineable::getLineSpacing() + */ + public function getLineSpacing() + { + return $this->lineSpacing; + } + + /** + * @see MultiLineable::setLineSpacing() + */ + public function setLineSpacing($lineSpacing) + { + $this->lineSpacing = (float)$lineSpacing; + return $this; + } + + /** + * @see MultiLineable::getMaxLines() + */ + public function getMaxLines() + { + return $this->maxLines; + } + + /** + * @see MultiLineable::setMaxLines() + */ + public function setMaxLines($maxLines) + { + $this->maxLines = (int)$maxLines; + return $this; + } + + /** + * @see Scriptable::getScriptEvents() + */ + public function getScriptEvents() + { + return $this->scriptEvents; + } + + /** + * @see Scriptable::setScriptEvents() + */ + public function setScriptEvents($scriptEvents) + { + $this->scriptEvents = (bool)$scriptEvents; + return $this; + } + + /** + * @see Scriptable::getScriptAction() + */ + public function getScriptAction() + { + return $this->scriptAction; + } + + /** + * @see Scriptable::setScriptAction() + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null) + { + $this->scriptAction = (string)$scriptAction; + $this->setScriptActionParameters($scriptActionParameters); + return $this; + } + + /** + * @see Scriptable::getScriptActionParameters() + */ + public function getScriptActionParameters() + { + return $this->scriptActionParameters; + } + + /** + * @see Scriptable::setScriptActionParameters() + */ + public function setScriptActionParameters(array $scriptActionParameters = null) + { + $this->scriptActionParameters = $scriptActionParameters; + return $this; + } + + /** + * @see Styleable::getStyle() + */ + public function getStyle() + { + return $this->style; + } + + /** + * @see Styleable::setStyle() + */ + public function setStyle($style) + { + $this->style = (string)$style; + return $this; + } + + /** + * @see TextFormatable::getTextSize() + */ + public function getTextSize() + { + return $this->textSize; + } + + /** + * @see TextFormatable::setTextSize() + */ + public function setTextSize($textSize) + { + $this->textSize = (int)$textSize; + return $this; + } + + /** + * @see TextFormatable::getTextFont() + */ + public function getTextFont() + { + return $this->textFont; + } + + /** + * @see TextFormatable::setTextFont() + */ + public function setTextFont($textFont) + { + $this->textFont = (string)$textFont; + return $this; + } + + /** + * @see TextFormatable::getTextColor() + */ + public function getTextColor() + { + return $this->textColor; + } + + /** + * @see TextFormatable::setTextColor() + */ + public function setTextColor($textColor) + { + $this->textColor = (string)$textColor; + return $this; + } + + /** + * @see TextFormatable::getAreaColor() + */ + public function getAreaColor() + { + return $this->areaColor; + } + + /** + * @see TextFormatable::setAreaColor() + */ + public function setAreaColor($areaColor) + { + $this->areaColor = (string)$areaColor; + return $this; + } + + /** + * @see TextFormatable::getAreaFocusColor() + */ + public function getAreaFocusColor() + { + return $this->focusAreaColor; + } + + /** + * @see TextFormatable::setAreaFocusColor() + */ + public function setAreaFocusColor($areaFocusColor) + { + $this->focusAreaColor = (string)$areaFocusColor; + return $this; + } + + /** + * Add a dynamic Feature showing the current time + * + * @api + * @param bool $showSeconds (optional) If the seconds should be shown + * @param bool $showFullDate (optional) If the date should be shown + * @return static + */ + public function addClockFeature($showSeconds = true, $showFullDate = false) + { + $clock = new Clock($this, $showSeconds, $showFullDate); + $this->addScriptFeature($clock); + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "label"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlLabel"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->text) { + $domElement->setAttribute("text", $this->text); + } + if ($this->textId) { + $domElement->setAttribute("textid", $this->textId); + } + if ($this->textPrefix) { + $domElement->setAttribute("textprefix", $this->textPrefix); + } + if ($this->textEmboss) { + $domElement->setAttribute("textemboss", $this->textEmboss); + } + if ($this->translate) { + $domElement->setAttribute("translate", $this->translate); + } + if ($this->opacity != 1.) { + $domElement->setAttribute("opacity", $this->opacity); + } + if ($this->action) { + $domElement->setAttribute("action", $this->action); + } + if ($this->actionKey >= 0) { + $domElement->setAttribute("actionkey", $this->actionKey); + } + if ($this->url) { + $domElement->setAttribute("url", $this->url); + } + if ($this->urlId) { + $domElement->setAttribute("urlid", $this->urlId); + } + if ($this->manialink) { + $domElement->setAttribute("manialink", $this->manialink); + } + if ($this->manialinkId) { + $domElement->setAttribute("manialinkid", $this->manialinkId); + } + if ($this->autoNewLine) { + $domElement->setAttribute("autonewline", $this->autoNewLine); + } + if ($this->lineSpacing) { + $domElement->setAttribute("linespacing", $this->lineSpacing); + } + if ($this->maxLines > 0) { + $domElement->setAttribute("maxline", $this->maxLines); + } + if ($this->scriptEvents) { + $domElement->setAttribute("scriptevents", $this->scriptEvents); + } + if ($this->scriptAction) { + $scriptAction = array($this->scriptAction); + if ($this->scriptActionParameters) { + $scriptAction = array_merge($scriptAction, $this->scriptActionParameters); + } + $domElement->setAttribute("scriptaction", implode("'", $scriptAction)); + } + if ($this->style) { + $domElement->setAttribute("style", $this->style); + } + if ($this->textSize >= 0) { + $domElement->setAttribute("textsize", $this->textSize); + } + if ($this->textFont) { + $domElement->setAttribute("textfont", $this->textFont); + } + if ($this->textColor) { + $domElement->setAttribute("textcolor", $this->textColor); + } + if ($this->areaColor) { + $domElement->setAttribute("focusareacolor1", $this->areaColor); + } + if ($this->focusAreaColor) { + $domElement->setAttribute("focusareacolor2", $this->focusAreaColor); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if (strlen($this->text) > 0) { - $xmlElement->setAttribute('text', $this->text); - } - if ($this->textId) { - $xmlElement->setAttribute('textid', $this->textId); - } - if ($this->textPrefix) { - $xmlElement->setAttribute('textprefix', $this->textPrefix); - } - if ($this->textEmboss) { - $xmlElement->setAttribute('textemboss', $this->textEmboss); - } - if ($this->translate) { - $xmlElement->setAttribute('translate', $this->translate); - } - if ($this->maxLines >= 0) { - $xmlElement->setAttribute('maxlines', $this->maxLines); - } - if ($this->opacity != 1.) { - $xmlElement->setAttribute('opacity', $this->opacity); - } - if (strlen($this->action) > 0) { - $xmlElement->setAttribute('action', $this->action); - } - if ($this->actionKey >= 0) { - $xmlElement->setAttribute('actionkey', $this->actionKey); - } - if ($this->url) { - $xmlElement->setAttribute('url', $this->url); - } - if ($this->manialink) { - $xmlElement->setAttribute('manialink', $this->manialink); - } - if ($this->autoNewLine) { - $xmlElement->setAttribute('autonewline', $this->autoNewLine); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - if ($this->style) { - $xmlElement->setAttribute('style', $this->style); - } - if ($this->textSize >= 0) { - $xmlElement->setAttribute('textsize', $this->textSize); - } - if ($this->textFont) { - $xmlElement->setAttribute('textfont', $this->textFont); - } - if ($this->textColor) { - $xmlElement->setAttribute('textcolor', $this->textColor); - } - if ($this->focusAreaColor1) { - $xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); - } - if ($this->focusAreaColor2) { - $xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Labels/Label_Button.php b/libs/FML/Controls/Labels/Label_Button.php index da2da5c8..f97bdbf1 100644 --- a/libs/FML/Controls/Labels/Label_Button.php +++ b/libs/FML/Controls/Labels/Label_Button.php @@ -8,31 +8,34 @@ use FML\Controls\Label; * Label class for button styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Label_Button extends Label { - /* - * Constants - */ - const STYLE_CardButtonMedium = 'CardButtonMedium'; - const STYLE_CardButtonMediumL = 'CardButtonMediumL'; - const STYLE_CardButtonMediumS = 'CardButtonMediumS'; - const STYLE_CardButtonMediumWide = 'CardButtonMediumWide'; - const STYLE_CardButtonMediumXL = 'CardButtonMediumXL'; - const STYLE_CardButtonMediumXS = 'CardButtonMediumXS'; - const STYLE_CardButtonMediumXXL = 'CardButtonMediumXXL'; - const STYLE_CardButtonMediumXXXL = 'CardButtonMediumXXXL'; - const STYLE_CardButtonSmall = 'CardButtonSmall'; - const STYLE_CardButtonSmallL = 'CardButtonSmallL'; - const STYLE_CardButtonSmallS = 'CardButtonSmallS'; - const STYLE_CardButtonSmallWide = 'CardButtonSmallWide'; - const STYLE_CardButtonSmallXL = 'CardButtonSmallXL'; - const STYLE_CardButtonSmallXS = 'CardButtonSmallXS'; - const STYLE_CardButtonSmallXXL = 'CardButtonSmallXXL'; - const STYLE_CardButtonSmallXXXL = 'CardButtonSmallXXXL'; - const STYLE_CardMain_Quit = 'CardMain_Quit'; - const STYLE_CardMain_Tool = 'CardMain_Tool'; - const STYLE_CardMain_Tool_NoBg = 'CardMain_Tool_NoBg'; - const STYLE_CardMain_Tool_NoBg2 = 'CardMain_Tool_NoBg2'; +class Label_Button extends Label +{ + + /* + * Constants + */ + const STYLE_CardButtonMedium = 'CardButtonMedium'; + const STYLE_CardButtonMediumL = 'CardButtonMediumL'; + const STYLE_CardButtonMediumS = 'CardButtonMediumS'; + const STYLE_CardButtonMediumWide = 'CardButtonMediumWide'; + const STYLE_CardButtonMediumXL = 'CardButtonMediumXL'; + const STYLE_CardButtonMediumXS = 'CardButtonMediumXS'; + const STYLE_CardButtonMediumXXL = 'CardButtonMediumXXL'; + const STYLE_CardButtonMediumXXXL = 'CardButtonMediumXXXL'; + const STYLE_CardButtonSmall = 'CardButtonSmall'; + const STYLE_CardButtonSmallL = 'CardButtonSmallL'; + const STYLE_CardButtonSmallS = 'CardButtonSmallS'; + const STYLE_CardButtonSmallWide = 'CardButtonSmallWide'; + const STYLE_CardButtonSmallXL = 'CardButtonSmallXL'; + const STYLE_CardButtonSmallXS = 'CardButtonSmallXS'; + const STYLE_CardButtonSmallXXL = 'CardButtonSmallXXL'; + const STYLE_CardButtonSmallXXXL = 'CardButtonSmallXXXL'; + const STYLE_CardMain_Quit = 'CardMain_Quit'; + const STYLE_CardMain_Tool = 'CardMain_Tool'; + const STYLE_CardMain_Tool_NoBg = 'CardMain_Tool_NoBg'; + const STYLE_CardMain_Tool_NoBg2 = 'CardMain_Tool_NoBg2'; + } diff --git a/libs/FML/Controls/Labels/Label_Text.php b/libs/FML/Controls/Labels/Label_Text.php index 4ad26344..fedfb7b6 100644 --- a/libs/FML/Controls/Labels/Label_Text.php +++ b/libs/FML/Controls/Labels/Label_Text.php @@ -8,90 +8,93 @@ use FML\Controls\Label; * Label class for text styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Label_Text extends Label { - /* - * Constants - */ - const STYLE_AvatarButtonNormal = 'AvatarButtonNormal'; - const STYLE_BgMainMenuTitleHeader = 'BgMainMenuTitleHeader'; - const STYLE_Default = 'Default'; - const STYLE_FrameTransitionFromLeft = 'FrameTransitionFromLeft'; - const STYLE_FrameTransitionsFromRight = 'FrameTransitionsFromRight'; - const STYLE_ListItemMedal = 'ListItemMedal'; - const STYLE_Manialink_Body = 'Manialink_Body'; - const STYLE_ProgressBar = 'ProgressBar'; - const STYLE_ProgressBarSmall = 'ProgressBarSmall'; - const STYLE_SliderSmall = 'SliderSmall'; - const STYLE_SliderVolume = 'SliderVolume'; - const STYLE_StyleTextScriptEditor = 'StyleTextScriptEditor'; - const STYLE_StyleValueYellowSmall = 'StyleValueYellowSmall'; - const STYLE_TextActionMaker = 'TextActionMaker'; - const STYLE_TextButtonBig = 'TextButtonBig'; - const STYLE_TextButtonMedium = 'TextButtonMedium'; - const STYLE_TextButtonNav = 'TextButtonNav'; - const STYLE_TextButtonNavBack = 'TextButtonNavBack'; - const STYLE_TextButtonSmall = 'TextButtonSmall'; - const STYLE_TextCardInfoSmall = 'TextCardInfoSmall'; - const STYLE_TextCardInfoVerySmall = 'TextCardInfoVerySmall'; - const STYLE_TextCardMedium = 'TextCardMedium'; - const STYLE_TextCardMediumWhite = 'TextCardMediumWhite'; - const STYLE_TextCardRaceRank = 'TextCardRaceRank'; - const STYLE_TextCardScores2 = 'TextCardScores2'; - const STYLE_TextCardSmall = 'TextCardSmall'; - const STYLE_TextCardSmallScores2 = 'TextCardSmallScores2'; - const STYLE_TextCardSmallScores2Rank = 'TextCardSmallScores2Rank'; - const STYLE_TextChallengeNameMedal = 'TextChallengeNameMedal'; - const STYLE_TextChallengeNameMedalNone = 'TextChallengeNameMedalNone'; - const STYLE_TextChallengeNameMedium = 'TextChallengeNameMedium'; - const STYLE_TextChallengeNameSmall = 'TextChallengeNameSmall'; - const STYLE_TextCongratsBig = 'TextCongratsBig'; - const STYLE_TextCredits = 'TextCredits'; - const STYLE_TextCreditsTitle = 'TextCreditsTitle'; - const STYLE_TextEditorArticle = 'TextEditorArticle'; - const STYLE_TextInfoMedium = 'TextInfoMedium'; - const STYLE_TextInfoSmall = 'TextInfoSmall'; - const STYLE_TextPlayerCardName = 'TextPlayerCardName'; - const STYLE_TextPlayerCardScore = 'TextPlayerCardScore'; - const STYLE_TextRaceChat = 'TextRaceChat'; - const STYLE_TextRaceChrono = 'TextRaceChrono'; - const STYLE_TextRaceChronoError = 'TextRaceChronoError'; - const STYLE_TextRaceChronoOfficial = 'TextRaceChronoOfficial'; - const STYLE_TextRaceChronoWarning = 'TextRaceChronoWarning'; - const STYLE_TextRaceMessage = 'TextRaceMessage'; - const STYLE_TextRaceMessageBig = 'TextRaceMessageBig'; - const STYLE_TextRaceStaticSmall = 'TextRaceStaticSmall'; - const STYLE_TextRaceValueSmall = 'TextRaceValueSmall'; - const STYLE_TextRankingsBig = 'TextRankingsBig'; - const STYLE_TextSPScoreBig = 'TextSPScoreBig'; - const STYLE_TextSPScoreMedium = 'TextSPScoreMedium'; - const STYLE_TextSPScoreSmall = 'TextSPScoreSmall'; - const STYLE_TextStaticMedium = 'TextStaticMedium'; - const STYLE_TextStaticSmall = 'TextStaticSmall'; - const STYLE_TextStaticVerySmall = 'TextStaticVerySmall'; - const STYLE_TextSubTitle1 = 'TextSubTitle1'; - const STYLE_TextSubTitle2 = 'TextSubTitle2'; - const STYLE_TextTips = 'TextTips'; - const STYLE_TextTitle1 = 'TextTitle1'; - const STYLE_TextTitle2 = 'TextTitle2'; - const STYLE_TextTitle2Blink = 'TextTitle2Blink'; - const STYLE_TextTitle3 = 'TextTitle3'; - const STYLE_TextTitle3Header = 'TextTitle3Header'; - const STYLE_TextTitleError = 'TextTitleError'; - const STYLE_TextToolTipAM = 'TextToolTipAM'; - const STYLE_TextToolTipAMBig = 'TextToolTipAMBig'; - const STYLE_TextValueBig = 'TextValueBig'; - const STYLE_TextValueMedium = 'TextValueMedium'; - const STYLE_TextValueMediumSm = 'TextValueMediumSm'; - const STYLE_TextValueSmall = 'TextValueSmall'; - const STYLE_TextValueSmallSm = 'TextValueSmallSm'; - const STYLE_TrackerText = 'TrackerText'; - const STYLE_TrackerTextBig = 'TrackerTextBig'; - const STYLE_TrackListItem = 'TrackListItem'; - const STYLE_TrackListLine = 'TrackListLine'; - const STYLE_UiDriving_BgBottom = 'UiDriving_BgBottom'; - const STYLE_UiDriving_BgCard = 'UiDriving_BgCard'; - const STYLE_UiDriving_BgCenter = 'UiDriving_BgCenter'; +class Label_Text extends Label +{ + + /* + * Constants + */ + const STYLE_AvatarButtonNormal = 'AvatarButtonNormal'; + const STYLE_BgMainMenuTitleHeader = 'BgMainMenuTitleHeader'; + const STYLE_Default = 'Default'; + const STYLE_FrameTransitionFromLeft = 'FrameTransitionFromLeft'; + const STYLE_FrameTransitionsFromRight = 'FrameTransitionsFromRight'; + const STYLE_ListItemMedal = 'ListItemMedal'; + const STYLE_Manialink_Body = 'Manialink_Body'; + const STYLE_ProgressBar = 'ProgressBar'; + const STYLE_ProgressBarSmall = 'ProgressBarSmall'; + const STYLE_SliderSmall = 'SliderSmall'; + const STYLE_SliderVolume = 'SliderVolume'; + const STYLE_StyleTextScriptEditor = 'StyleTextScriptEditor'; + const STYLE_StyleValueYellowSmall = 'StyleValueYellowSmall'; + const STYLE_TextActionMaker = 'TextActionMaker'; + const STYLE_TextButtonBig = 'TextButtonBig'; + const STYLE_TextButtonMedium = 'TextButtonMedium'; + const STYLE_TextButtonNav = 'TextButtonNav'; + const STYLE_TextButtonNavBack = 'TextButtonNavBack'; + const STYLE_TextButtonSmall = 'TextButtonSmall'; + const STYLE_TextCardInfoSmall = 'TextCardInfoSmall'; + const STYLE_TextCardInfoVerySmall = 'TextCardInfoVerySmall'; + const STYLE_TextCardMedium = 'TextCardMedium'; + const STYLE_TextCardMediumWhite = 'TextCardMediumWhite'; + const STYLE_TextCardRaceRank = 'TextCardRaceRank'; + const STYLE_TextCardScores2 = 'TextCardScores2'; + const STYLE_TextCardSmall = 'TextCardSmall'; + const STYLE_TextCardSmallScores2 = 'TextCardSmallScores2'; + const STYLE_TextCardSmallScores2Rank = 'TextCardSmallScores2Rank'; + const STYLE_TextChallengeNameMedal = 'TextChallengeNameMedal'; + const STYLE_TextChallengeNameMedalNone = 'TextChallengeNameMedalNone'; + const STYLE_TextChallengeNameMedium = 'TextChallengeNameMedium'; + const STYLE_TextChallengeNameSmall = 'TextChallengeNameSmall'; + const STYLE_TextCongratsBig = 'TextCongratsBig'; + const STYLE_TextCredits = 'TextCredits'; + const STYLE_TextCreditsTitle = 'TextCreditsTitle'; + const STYLE_TextEditorArticle = 'TextEditorArticle'; + const STYLE_TextInfoMedium = 'TextInfoMedium'; + const STYLE_TextInfoSmall = 'TextInfoSmall'; + const STYLE_TextPlayerCardName = 'TextPlayerCardName'; + const STYLE_TextPlayerCardScore = 'TextPlayerCardScore'; + const STYLE_TextRaceChat = 'TextRaceChat'; + const STYLE_TextRaceChrono = 'TextRaceChrono'; + const STYLE_TextRaceChronoError = 'TextRaceChronoError'; + const STYLE_TextRaceChronoOfficial = 'TextRaceChronoOfficial'; + const STYLE_TextRaceChronoWarning = 'TextRaceChronoWarning'; + const STYLE_TextRaceMessage = 'TextRaceMessage'; + const STYLE_TextRaceMessageBig = 'TextRaceMessageBig'; + const STYLE_TextRaceStaticSmall = 'TextRaceStaticSmall'; + const STYLE_TextRaceValueSmall = 'TextRaceValueSmall'; + const STYLE_TextRankingsBig = 'TextRankingsBig'; + const STYLE_TextSPScoreBig = 'TextSPScoreBig'; + const STYLE_TextSPScoreMedium = 'TextSPScoreMedium'; + const STYLE_TextSPScoreSmall = 'TextSPScoreSmall'; + const STYLE_TextStaticMedium = 'TextStaticMedium'; + const STYLE_TextStaticSmall = 'TextStaticSmall'; + const STYLE_TextStaticVerySmall = 'TextStaticVerySmall'; + const STYLE_TextSubTitle1 = 'TextSubTitle1'; + const STYLE_TextSubTitle2 = 'TextSubTitle2'; + const STYLE_TextTips = 'TextTips'; + const STYLE_TextTitle1 = 'TextTitle1'; + const STYLE_TextTitle2 = 'TextTitle2'; + const STYLE_TextTitle2Blink = 'TextTitle2Blink'; + const STYLE_TextTitle3 = 'TextTitle3'; + const STYLE_TextTitle3Header = 'TextTitle3Header'; + const STYLE_TextTitleError = 'TextTitleError'; + const STYLE_TextToolTipAM = 'TextToolTipAM'; + const STYLE_TextToolTipAMBig = 'TextToolTipAMBig'; + const STYLE_TextValueBig = 'TextValueBig'; + const STYLE_TextValueMedium = 'TextValueMedium'; + const STYLE_TextValueMediumSm = 'TextValueMediumSm'; + const STYLE_TextValueSmall = 'TextValueSmall'; + const STYLE_TextValueSmallSm = 'TextValueSmallSm'; + const STYLE_TrackerText = 'TrackerText'; + const STYLE_TrackerTextBig = 'TrackerTextBig'; + const STYLE_TrackListItem = 'TrackListItem'; + const STYLE_TrackListLine = 'TrackListLine'; + const STYLE_UiDriving_BgBottom = 'UiDriving_BgBottom'; + const STYLE_UiDriving_BgCard = 'UiDriving_BgCard'; + const STYLE_UiDriving_BgCenter = 'UiDriving_BgCenter'; + } diff --git a/libs/FML/Controls/Quad.php b/libs/FML/Controls/Quad.php index f263f711..9064201f 100644 --- a/libs/FML/Controls/Quad.php +++ b/libs/FML/Controls/Quad.php @@ -2,9 +2,9 @@ namespace FML\Controls; -use FML\Models\CheckBoxDesign; use FML\Types\Actionable; -use FML\Types\BgColorable; +use FML\Types\BackgroundColorable; +use FML\Types\Imageable; use FML\Types\Linkable; use FML\Types\Scriptable; use FML\Types\Styleable; @@ -15,325 +15,716 @@ use FML\Types\SubStyleable; * (CMlQuad) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable { - /* - * Constants - */ - const KEEP_RATIO_INACTIVE = 'inactive'; - const KEEP_RATIO_CLIP = 'Clip'; - const KEEP_RATIO_FIT = 'Fit'; +class Quad extends Control implements Actionable, BackgroundColorable, Imageable, Linkable, Scriptable, Styleable, SubStyleable +{ - /* - * Protected properties - */ - protected $tagName = 'quad'; - protected $image = null; - protected $imageId = null; - protected $imageFocus = null; - protected $imageFocusId = null; - protected $colorize = null; - protected $modulizeColor = null; - protected $autoScale = 1; - protected $keepRatio = null; - protected $action = null; - protected $actionKey = -1; - protected $bgColor = null; - protected $url = null; - protected $urlId = null; - protected $manialink = null; - protected $manialinkId = null; - protected $scriptEvents = null; - protected $style = null; - protected $subStyle = null; - protected $styleSelected = null; - protected $opacity = null; + /* + * Constants + */ + const KEEP_RATIO_INACTIVE = "inactive"; + const KEEP_RATIO_CLIP = "Clip"; + const KEEP_RATIO_FIT = "Fit"; - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlQuad'; - } + /** + * @var string $imageUrl Image url + */ + protected $imageUrl = null; - /** - * Set image url - * - * @param string $image Image url - * @return static - */ - public function setImage($image) { - $this->image = (string)$image; - return $this; - } + /** + * @var string $imageId Image ID + */ + protected $imageId = null; - /** - * Set image id to use from Dico - * - * @param string $imageId Image id - * @return static - */ - public function setImageId($imageId) { - $this->imageId = (string)$imageId; - return $this; - } + /** + * @var string $imageFocusUrl Focus image url + */ + protected $imageFocusUrl = null; - /** - * Set focus image url - * - * @param string $imageFocus Focus image url - * @return static - */ - public function setImageFocus($imageFocus) { - $this->imageFocus = (string)$imageFocus; - return $this; - } + /** + * @var string $imageFocusId Focus image ID + */ + protected $imageFocusId = null; - /** - * Set focus image id to use from Dico - * - * @param string $imageFocusId Focus image id - * @return static - */ - public function setImageFocusId($imageFocusId) { - $this->imageFocusId = (string)$imageFocusId; - return $this; - } + /** + * @var string $colorize Colorize value + */ + protected $colorize = null; - /** - * Set colorization - * - * @param string $colorize Colorize value - * @return static - */ - public function setColorize($colorize) { - $this->colorize = (string)$colorize; - return $this; - } + /** + * @var string $modulizeColor Modulization color + */ + protected $modulizeColor = null; - /** - * Set modulization - * - * @param string $modulizeColor Modulize value - * @return static - */ - public function setModulizeColor($modulizeColor) { - $this->modulizeColor = (string)$modulizeColor; - return $this; - } + /** + * @var bool $autoScale Automatic scaling + */ + protected $autoScale = true; - /** - * Disable the automatic image scaling - * - * @param bool $autoScale Whether the image should scale automatically - * @return static - */ - public function setAutoScale($autoScale) { - $this->autoScale = ($autoScale ? 1 : 0); - return $this; - } + /** + * @var float $autoScaleFixedWidth Fixed width for automatic scaling + */ + protected $autoScaleFixedWidth = -1.; - /** - * Set Keep Ratio Mode - * - * @param string $keepRatio Keep Ratio Mode - * @return static - */ - public function setKeepRatio($keepRatio) { - $this->keepRatio = (string)$keepRatio; - return $this; - } + /** + * @var string $keepRatio Keep ratio mode + */ + protected $keepRatio = null; - /** - * @see \FML\Types\Actionable::getAction() - */ - public function getAction() { - return $this->action; - } + /** + * @var float $opacity Opacity + */ + protected $opacity = 1.; - /** - * @see \FML\Types\Actionable::setAction() - */ - public function setAction($action) { - $this->action = (string)$action; - return $this; - } + /** + * @var string $backgroundColor Background color + */ + protected $backgroundColor = null; - /** - * @see \FML\Types\Actionable::setActionKey() - */ - public function setActionKey($actionKey) { - $this->actionKey = (int)$actionKey; - return $this; - } + /** + * @var string $action Action name + */ + protected $action = null; - /** - * @see \FML\Types\BgColorable::setBgColor() - */ - public function setBgColor($bgColor) { - $this->bgColor = (string)$bgColor; - return $this; - } + /** + * @var int $actionKey Action key + */ + protected $actionKey = -1; - /** - * @see \FML\Types\Linkable::setUrl() - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * @var string $url Link url + */ + protected $url = null; - /** - * @see \FML\Types\Linkable::setUrlId() - */ - public function setUrlId($urlId) { - $this->urlId = (string)$urlId; - return $this; - } + /** + * @var string $urlId Link url ID + */ + protected $urlId = null; - /** - * @see \FML\Types\Linkable::setManialink() - */ - public function setManialink($manialink) { - $this->manialink = (string)$manialink; - return $this; - } + /** + * @var string $manialink Manialink + */ + protected $manialink = null; - /** - * @see \FML\Types\Linkable::setManialinkId() - */ - public function setManialinkId($manialinkId) { - $this->manialinkId = (string)$manialinkId; - return $this; - } + /** + * @var string $manialinkId Manialink ID + */ + protected $manialinkId = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\SubStyleable::setStyles() - */ - public function setStyles($style, $subStyle) { - $this->setStyle($style); - $this->setSubStyle($subStyle); - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; - /** - * @see \FML\Types\SubStyleable::setSubStyle() - */ - public function setSubStyle($subStyle) { - $this->subStyle = (string)$subStyle; - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * Set selected mode - * - * @param bool $styleSelected - * @return static - */ - public function setStyleSelected($styleSelected) { - $this->styleSelected = ($styleSelected ? 1 : 0); - return $this; - } + /** + * @var string $subStyle SubStyle + */ + protected $subStyle = null; - /** - * Set opacity - * - * @param float $opacity - * @return static - */ - public function setOpacity($opacity) { - $this->opacity = (float)$opacity; - return $this; - } + /** + * @var bool $styleSelected Style selected + */ + protected $styleSelected = null; - /** - * Apply the given CheckBox Design - * - * @param CheckBoxDesign $checkBoxDesign CheckBox Design - * @return static - */ - public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) { - $checkBoxDesign->applyToQuad($this); - return $this; - } + /** + * @see Imageable::getImageUrl() + */ + public function getImageUrl() + { + return $this->imageUrl; + } + + /** + * @deprecated use setImageUrl() instead + */ + public function setImage($imageUrl) + { + return $this->setImageUrl($imageUrl); + } + + /** + * @see Imageable::setImageUrl() + */ + public function setImageUrl($imageUrl) + { + $this->imageUrl = (string)$imageUrl; + return $this; + } + + /** + * Get the image id to use from Dico + * + * @api + * @return string + */ + public function getImageId() + { + return $this->imageId; + } + + /** + * Set the image id to use from Dico + * + * @api + * @param string $imageId Image id + * @return static + */ + public function setImageId($imageId) + { + $this->imageId = (string)$imageId; + return $this; + } + + /** + * Get the focus image url + * + * @api + * @return string + */ + public function getImageFocusUrl() + { + return $this->imageFocusUrl; + } + + /** + * @param $imageFocusUrl + * @return \FML\Controls\Quad + * @deprecated + */ + public function setImageFocus($imageFocusUrl) + { + return $this->setImageFocusUrl($imageFocusUrl); + } + + /** + * Set the focus image url + * + * @api + * @param string $imageFocusUrl Focus image url + * @return static + */ + public function setImageFocusUrl($imageFocusUrl) + { + $this->imageFocusUrl = (string)$imageFocusUrl; + return $this; + } + + /** + * Get the focus image id to use from Dico + * + * @api + * @return string + */ + public function getImageFocusId() + { + return $this->imageFocusId; + } + + /** + * Set the focus image id to use from Dico + * + * @api + * @param string $imageFocusId Focus image id + * @return static + */ + public function setImageFocusId($imageFocusId) + { + $this->imageFocusId = (string)$imageFocusId; + return $this; + } + + /** + * Get the colorization + * + * @api + * @return string + */ + public function getColorize() + { + return $this->colorize; + } + + /** + * Set the colorization + * + * @api + * @param string $colorize Colorize value + * @return static + */ + public function setColorize($colorize) + { + $this->colorize = (string)$colorize; + return $this; + } + + /** + * Get the modulization color + * + * @api + * @return string + */ + public function getModulizeColor() + { + return $this->modulizeColor; + } + + /** + * Set the modulization color + * + * @api + * @param string $modulizeColor Modulization color + * @return static + */ + public function setModulizeColor($modulizeColor) + { + $this->modulizeColor = (string)$modulizeColor; + return $this; + } + + /** + * Get the automatic image scaling + * + * @api + * @return bool + */ + public function getAutoScale() + { + return $this->autoScale; + } + + /** + * Set the automatic image scaling + * + * @api + * @param bool $autoScale If the image should scale automatically + * @return static + */ + public function setAutoScale($autoScale) + { + $this->autoScale = (bool)$autoScale; + return $this; + } + + /** + * Get the fixed width for automatic image scaling + * + * @api + * @return float + */ + public function getAutoScaleFixedWidth() + { + return $this->autoScaleFixedWidth; + } + + /** + * Set the fixed width for automatic image scaling + * + * @api + * @param float $autoScaleFixedWidth Fixed width for automatic image scaling + * @return static + */ + public function setAutoScaleFixedWidth($autoScaleFixedWidth) + { + $this->autoScaleFixedWidth = (float)$autoScaleFixedWidth; + return $this; + } + + /** + * Get the Keep Ratio mode + * + * @api + * @return string + */ + public function getKeepRatio() + { + return $this->keepRatio; + } + + /** + * Set the Keep Ratio mode + * + * @api + * @param string $keepRatio Keep Ratio mode + * @return static + */ + public function setKeepRatio($keepRatio) + { + $this->keepRatio = (string)$keepRatio; + return $this; + } + + /** + * Get the opacity + * + * @api + * @return float + */ + public function getOpacity() + { + return $this->opacity; + } + + /** + * Set the opacity + * + * @api + * @param float $opacity Opacity value + * @return static + */ + public function setOpacity($opacity) + { + $this->opacity = (float)$opacity; + return $this; + } + + /** + * @see BackgroundColorable::getBackgroundColor() + */ + public function getBackgroundColor() + { + return $this->backgroundColor; + } + + /** + * @see BackgroundColorable::setBgColor() + */ + public function setBackgroundColor($backgroundColor) + { + $this->backgroundColor = (string)$backgroundColor; + return $this; + } + + /** + * @see Actionable::getAction() + */ + public function getAction() + { + return $this->action; + } + + /** + * @see Actionable::setAction() + */ + public function setAction($action) + { + $this->action = (string)$action; + return $this; + } + + /** + * @see Actionable::getActionKey() + */ + public function getActionKey() + { + return $this->actionKey; + } + + /** + * @see Actionable::setActionKey() + */ + public function setActionKey($actionKey) + { + $this->actionKey = (int)$actionKey; + return $this; + } + + /** + * @see Linkable::getUrl() + */ + public function getUrl() + { + return $this->url; + } + + /** + * @see Linkable::setUrl() + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Linkable::getUrlId() + */ + public function getUrlId() + { + return $this->urlId; + } + + /** + * @see Linkable::setUrlId() + */ + public function setUrlId($urlId) + { + $this->urlId = (string)$urlId; + return $this; + } + + /** + * @see Linkable::getManialink() + */ + public function getManialink() + { + return $this->manialink; + } + + /** + * @see Linkable::setManialink() + */ + public function setManialink($manialink) + { + $this->manialink = (string)$manialink; + return $this; + } + + /** + * @see Linkable::getManialinkId() + */ + public function getManialinkId() + { + return $this->manialinkId; + } + + /** + * @see Linkable::setManialinkId() + */ + public function setManialinkId($manialinkId) + { + $this->manialinkId = (string)$manialinkId; + return $this; + } + + /** + * @see Scriptable::getScriptEvents() + */ + public function getScriptEvents() + { + return $this->scriptEvents; + } + + /** + * @see Scriptable::setScriptEvents() + */ + public function setScriptEvents($scriptEvents) + { + $this->scriptEvents = (bool)$scriptEvents; + return $this; + } + + /** + * @see Scriptable::getScriptAction() + */ + public function getScriptAction() + { + return $this->scriptAction; + } + + /** + * @see Scriptable::setScriptAction() + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null) + { + $this->scriptAction = (string)$scriptAction; + $this->setScriptActionParameters($scriptActionParameters); + return $this; + } + + /** + * @see Scriptable::getScriptActionParameters() + */ + public function getScriptActionParameters() + { + return $this->scriptActionParameters; + } + + /** + * @see Scriptable::setScriptActionParameters() + */ + public function setScriptActionParameters(array $scriptActionParameters = null) + { + $this->scriptActionParameters = $scriptActionParameters; + return $this; + } + + /** + * @see Styleable::getStyle() + */ + public function getStyle() + { + return $this->style; + } + + /** + * @see Styleable::setStyle() + */ + public function setStyle($style) + { + $this->style = (string)$style; + return $this; + } + + /** + * @see Styleable::getSubStyle() + */ + public function getSubStyle() + { + return $this->subStyle; + } + + /** + * @see SubStyleable::setSubStyle() + */ + public function setSubStyle($subStyle) + { + $this->subStyle = (string)$subStyle; + return $this; + } + + /** + * @see SubStyleable::setStyles() + */ + public function setStyles($style, $subStyle) + { + return $this->setStyle($style) + ->setSubStyle($subStyle); + } + + /** + * Get selected style + * + * @api + * @return bool + */ + public function getStyleSelected() + { + return $this->styleSelected; + } + + /** + * Set selected style + * + * @api + * @param bool $styleSelected If the quad should be styled selected + * @return static + */ + public function setStyleSelected($styleSelected) + { + $this->styleSelected = (bool)$styleSelected; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "quad"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlQuad"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->imageUrl) { + $domElement->setAttribute("image", $this->imageUrl); + } + if ($this->imageId) { + $domElement->setAttribute("imageid", $this->imageId); + } + if ($this->imageFocusUrl) { + $domElement->setAttribute("imagefocus", $this->imageFocusUrl); + } + if ($this->imageFocusId) { + $domElement->setAttribute("imagefocusid", $this->imageFocusId); + } + if ($this->colorize) { + $domElement->setAttribute("colorize", $this->colorize); + } + if ($this->modulizeColor) { + $domElement->setAttribute("modulizecolor", $this->modulizeColor); + } + if (!$this->autoScale) { + $domElement->setAttribute("autoscale", 0); + } + if ($this->autoScaleFixedWidth > 0.) { + $domElement->setAttribute("autoscalefixedWidth", $this->autoScaleFixedWidth); + } + if ($this->keepRatio) { + $domElement->setAttribute("keepratio", $this->keepRatio); + } + if ($this->opacity !== 1.) { + $domElement->setAttribute("opacity", $this->opacity); + } + if ($this->backgroundColor) { + $domElement->setAttribute("bgcolor", $this->backgroundColor); + } + if ($this->action) { + $domElement->setAttribute("action", $this->action); + } + if ($this->actionKey) { + $domElement->setAttribute("actionkey", $this->actionKey); + } + if ($this->url) { + $domElement->setAttribute("url", $this->url); + } + if ($this->urlId) { + $domElement->setAttribute("urlid", $this->urlId); + } + if ($this->manialink) { + $domElement->setAttribute("manialink", $this->manialink); + } + if ($this->manialinkId) { + $domElement->setAttribute("manialinkid", $this->manialinkId); + } + if ($this->scriptEvents) { + $domElement->setAttribute("scriptevents", 1); + } + if ($this->scriptAction) { + $scriptAction = array($this->scriptAction); + if ($this->scriptActionParameters) { + $scriptAction = array_merge($scriptAction, $this->scriptActionParameters); + } + $domElement->setAttribute("scriptaction", implode("'", $scriptAction)); + } + if ($this->style) { + $domElement->setAttribute("style", $this->style); + } + if ($this->subStyle) { + $domElement->setAttribute("substyle", $this->subStyle); + } + if ($this->styleSelected) { + $domElement->setAttribute("styleselected", 1); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->image) { - $xmlElement->setAttribute('image', $this->image); - } - if ($this->imageId) { - $xmlElement->setAttribute('imageid', $this->imageId); - } - if ($this->imageFocus) { - $xmlElement->setAttribute('imagefocus', $this->imageFocus); - } - if ($this->imageFocusId) { - $xmlElement->setAttribute('imagefocusid', $this->imageFocusId); - } - if ($this->colorize) { - $xmlElement->setAttribute('colorize', $this->colorize); - } - if ($this->modulizeColor) { - $xmlElement->setAttribute('modulizecolor', $this->modulizeColor); - } - if (!$this->autoScale) { - $xmlElement->setAttribute('autoscale', $this->autoScale); - } - if ($this->keepRatio) { - $xmlElement->setAttribute('keepratio', $this->keepRatio); - } - if (strlen($this->action) > 0) { - $xmlElement->setAttribute('action', $this->action); - } - if ($this->actionKey >= 0) { - $xmlElement->setAttribute('actionkey', $this->actionKey); - } - if ($this->bgColor) { - $xmlElement->setAttribute('bgcolor', $this->bgColor); - } - if ($this->url) { - $xmlElement->setAttribute('url', $this->url); - } - if ($this->manialink) { - $xmlElement->setAttribute('manialink', $this->manialink); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - if ($this->style) { - $xmlElement->setAttribute('style', $this->style); - } - if ($this->subStyle) { - $xmlElement->setAttribute('substyle', $this->subStyle); - } - if ($this->styleSelected) { - $xmlElement->setAttribute('styleselected', $this->styleSelected); - } - if ($this->opacity !== 1.) { - $xmlElement->setAttribute('opacity', $this->opacity); - } - return $xmlElement; - } } diff --git a/libs/FML/Controls/Quads/Quad_321Go.php b/libs/FML/Controls/Quads/Quad_321Go.php index d4525e20..81f6aaef 100644 --- a/libs/FML/Controls/Quads/Quad_321Go.php +++ b/libs/FML/Controls/Quads/Quad_321Go.php @@ -8,21 +8,24 @@ use FML\Controls\Quad; * Quad class for '321Go' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_321Go extends Quad { - /* - * Constants - */ - const STYLE = '321Go'; - const SUBSTYLE_3 = '3'; - const SUBSTYLE_2 = '2'; - const SUBSTYLE_1 = '1'; - const SUBSTYLE_Go = 'Go!'; +class Quad_321Go extends Quad +{ + + /* + * Constants + */ + const STYLE = '321Go'; + const SUBSTYLE_3 = '3'; + const SUBSTYLE_2 = '2'; + const SUBSTYLE_1 = '1'; + const SUBSTYLE_Go = 'Go!'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_BgRaceScore2.php b/libs/FML/Controls/Quads/Quad_BgRaceScore2.php index c0db325e..82f0d21d 100644 --- a/libs/FML/Controls/Quads/Quad_BgRaceScore2.php +++ b/libs/FML/Controls/Quads/Quad_BgRaceScore2.php @@ -8,44 +8,47 @@ use FML\Controls\Quad; * Quad class for 'BgRaceScore2' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_BgRaceScore2 extends Quad { - /* - * Constants - */ - const STYLE = 'BgRaceScore2'; - const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; - const SUBSTYLE_BgCardServer = 'BgCardServer'; - const SUBSTYLE_BgScores = 'BgScores'; - const SUBSTYLE_Cartouche = 'Cartouche'; - const SUBSTYLE_CartoucheLine = 'CartoucheLine'; - const SUBSTYLE_CupFinisher = 'CupFinisher'; - const SUBSTYLE_CupPotentialFinisher = 'CupPotentialFinisher'; - const SUBSTYLE_Fame = 'Fame'; - const SUBSTYLE_Handle = 'Handle'; - const SUBSTYLE_HandleBlue = 'HandleBlue'; - const SUBSTYLE_HandleRed = 'HandleRed'; - const SUBSTYLE_HandleSelectable = 'HandleSelectable'; - const SUBSTYLE_IsLadderDisabled = 'IsLadderDisabled'; - const SUBSTYLE_IsLocalPlayer = 'IsLocalPlayer'; - const SUBSTYLE_LadderPoints = 'LadderPoints'; - const SUBSTYLE_LadderRank = 'LadderRank'; - const SUBSTYLE_Laps = 'Laps'; - const SUBSTYLE_Podium = 'Podium'; - const SUBSTYLE_Points = 'Points'; - const SUBSTYLE_SandTimer = 'SandTimer'; - const SUBSTYLE_ScoreLink = 'ScoreLink'; - const SUBSTYLE_ScoreReplay = 'ScoreReplay'; - const SUBSTYLE_SendScore = 'SendScore'; - const SUBSTYLE_Speaking = 'Speaking'; - const SUBSTYLE_Spectator = 'Spectator'; - const SUBSTYLE_Tv = 'Tv'; - const SUBSTYLE_Warmup = 'Warmup'; +class Quad_BgRaceScore2 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'BgRaceScore2'; + const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; + const SUBSTYLE_BgCardServer = 'BgCardServer'; + const SUBSTYLE_BgScores = 'BgScores'; + const SUBSTYLE_Cartouche = 'Cartouche'; + const SUBSTYLE_CartoucheLine = 'CartoucheLine'; + const SUBSTYLE_CupFinisher = 'CupFinisher'; + const SUBSTYLE_CupPotentialFinisher = 'CupPotentialFinisher'; + const SUBSTYLE_Fame = 'Fame'; + const SUBSTYLE_Handle = 'Handle'; + const SUBSTYLE_HandleBlue = 'HandleBlue'; + const SUBSTYLE_HandleRed = 'HandleRed'; + const SUBSTYLE_HandleSelectable = 'HandleSelectable'; + const SUBSTYLE_IsLadderDisabled = 'IsLadderDisabled'; + const SUBSTYLE_IsLocalPlayer = 'IsLocalPlayer'; + const SUBSTYLE_LadderPoints = 'LadderPoints'; + const SUBSTYLE_LadderRank = 'LadderRank'; + const SUBSTYLE_Laps = 'Laps'; + const SUBSTYLE_Podium = 'Podium'; + const SUBSTYLE_Points = 'Points'; + const SUBSTYLE_SandTimer = 'SandTimer'; + const SUBSTYLE_ScoreLink = 'ScoreLink'; + const SUBSTYLE_ScoreReplay = 'ScoreReplay'; + const SUBSTYLE_SendScore = 'SendScore'; + const SUBSTYLE_Speaking = 'Speaking'; + const SUBSTYLE_Spectator = 'Spectator'; + const SUBSTYLE_Tv = 'Tv'; + const SUBSTYLE_Warmup = 'Warmup'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Bgs1.php b/libs/FML/Controls/Quads/Quad_Bgs1.php index 7e03f281..5edba09d 100644 --- a/libs/FML/Controls/Quads/Quad_Bgs1.php +++ b/libs/FML/Controls/Quads/Quad_Bgs1.php @@ -8,86 +8,89 @@ use FML\Controls\Quad; * Quad class for 'Bgs1' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Bgs1 extends Quad { - /* - * Constants - */ - const STYLE = 'Bgs1'; - const SUBSTYLE_ArrowDown = 'ArrowDown'; - const SUBSTYLE_ArrowLeft = 'ArrowLeft'; - const SUBSTYLE_ArrowRight = 'ArrowRight'; - const SUBSTYLE_ArrowUp = 'ArrowUp'; - const SUBSTYLE_BgButton = 'BgButton'; - const SUBSTYLE_BgButtonBig = 'BgButtonBig'; - const SUBSTYLE_BgButtonGlow = 'BgButtonGlow'; - const SUBSTYLE_BgButtonGrayed = 'BgButtonGrayed'; - const SUBSTYLE_BgButtonOff = 'BgButtonOff'; - const SUBSTYLE_BgButtonShadow = 'BgButtonShadow'; - const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; - const SUBSTYLE_BgCard = 'BgCard'; - const SUBSTYLE_BgCard1 = 'BgCard1'; - const SUBSTYLE_BgCard2 = 'BgCard2'; - const SUBSTYLE_BgCard3 = 'BgCard3'; - const SUBSTYLE_BgCardBuddy = 'BgCardBuddy'; - const SUBSTYLE_BgCardChallenge = 'BgCardChallenge'; - const SUBSTYLE_BgCardFolder = 'BgCardFolder'; - const SUBSTYLE_BgCardInventoryItem = 'BgCardInventoryItem'; - const SUBSTYLE_BgCardList = 'BgCardList'; - const SUBSTYLE_BgCardOnline = 'BgCardOnline'; - const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; - const SUBSTYLE_BgCardProperty = 'BgCardProperty'; - const SUBSTYLE_BgCardSystem = 'BgCardSystem'; - const SUBSTYLE_BgCardZone = 'BgCardZone'; - const SUBSTYLE_BgColorContour = 'BgColorContour'; - const SUBSTYLE_BgDialogBlur = 'BgDialogBlur'; - const SUBSTYLE_BgEmpty = 'BgEmpty'; - const SUBSTYLE_BgGlow2 = 'BgGlow2'; - const SUBSTYLE_BgGradBottom = 'BgGradBottom'; - const SUBSTYLE_BgGradLeft = 'BgGradLeft'; - const SUBSTYLE_BgGradRight = 'BgGradRight'; - const SUBSTYLE_BgGradTop = 'BgGradTop'; - const SUBSTYLE_BgGradV = 'BgGradV'; - const SUBSTYLE_BgHealthBar = 'BgHealthBar'; - const SUBSTYLE_BgIconBorder = 'BgIconBorder'; - const SUBSTYLE_BgList = 'BgList'; - const SUBSTYLE_BgListLine = 'BgListLine'; - const SUBSTYLE_BgMetalBar = 'BgMetalBar'; - const SUBSTYLE_BgPager = 'BgPager'; - const SUBSTYLE_BgProgressBar = 'BgProgressBar'; - const SUBSTYLE_BgShadow = 'BgShadow'; - const SUBSTYLE_BgSlider = 'BgSlider'; - const SUBSTYLE_BgSystemBar = 'BgSystemBar'; - const SUBSTYLE_BgTitle = 'BgTitle'; - const SUBSTYLE_BgTitle2 = 'BgTitle2'; - const SUBSTYLE_BgTitle3 = 'BgTitle3'; - const SUBSTYLE_BgTitle3_1 = 'BgTitle3_1'; - const SUBSTYLE_BgTitle3_2 = 'BgTitle3_2'; - const SUBSTYLE_BgTitle3_3 = 'BgTitle3_3'; - const SUBSTYLE_BgTitle3_4 = 'BgTitle3_4'; - const SUBSTYLE_BgTitle3_5 = 'BgTitle3_5'; - const SUBSTYLE_BgTitleGlow = 'BgTitleGlow'; - const SUBSTYLE_BgTitlePage = 'BgTitlePage'; - const SUBSTYLE_BgTitleShadow = 'BgTitleShadow'; - const SUBSTYLE_BgWindow1 = 'BgWindow1'; - const SUBSTYLE_BgWindow2 = 'BgWindow2'; - const SUBSTYLE_BgWindow3 = 'BgWindow3'; - const SUBSTYLE_BgWindow4 = 'BgWindow4'; - const SUBSTYLE_EnergyBar = 'EnergyBar'; - const SUBSTYLE_EnergyTeam2 = 'EnergyTeam2'; - const SUBSTYLE_Glow = 'Glow'; - const SUBSTYLE_HealthBar = 'HealthBar'; - const SUBSTYLE_NavButton = 'NavButton'; - const SUBSTYLE_NavButtonBlink = 'NavButtonBlink'; - const SUBSTYLE_NavButtonQuit = 'NavButtonQuit'; - const SUBSTYLE_ProgressBar = 'ProgressBar'; - const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; - const SUBSTYLE_Shadow = 'Shadow'; +class Quad_Bgs1 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Bgs1'; + const SUBSTYLE_ArrowDown = 'ArrowDown'; + const SUBSTYLE_ArrowLeft = 'ArrowLeft'; + const SUBSTYLE_ArrowRight = 'ArrowRight'; + const SUBSTYLE_ArrowUp = 'ArrowUp'; + const SUBSTYLE_BgButton = 'BgButton'; + const SUBSTYLE_BgButtonBig = 'BgButtonBig'; + const SUBSTYLE_BgButtonGlow = 'BgButtonGlow'; + const SUBSTYLE_BgButtonGrayed = 'BgButtonGrayed'; + const SUBSTYLE_BgButtonOff = 'BgButtonOff'; + const SUBSTYLE_BgButtonShadow = 'BgButtonShadow'; + const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; + const SUBSTYLE_BgCard = 'BgCard'; + const SUBSTYLE_BgCard1 = 'BgCard1'; + const SUBSTYLE_BgCard2 = 'BgCard2'; + const SUBSTYLE_BgCard3 = 'BgCard3'; + const SUBSTYLE_BgCardBuddy = 'BgCardBuddy'; + const SUBSTYLE_BgCardChallenge = 'BgCardChallenge'; + const SUBSTYLE_BgCardFolder = 'BgCardFolder'; + const SUBSTYLE_BgCardInventoryItem = 'BgCardInventoryItem'; + const SUBSTYLE_BgCardList = 'BgCardList'; + const SUBSTYLE_BgCardOnline = 'BgCardOnline'; + const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; + const SUBSTYLE_BgCardProperty = 'BgCardProperty'; + const SUBSTYLE_BgCardSystem = 'BgCardSystem'; + const SUBSTYLE_BgCardZone = 'BgCardZone'; + const SUBSTYLE_BgColorContour = 'BgColorContour'; + const SUBSTYLE_BgDialogBlur = 'BgDialogBlur'; + const SUBSTYLE_BgEmpty = 'BgEmpty'; + const SUBSTYLE_BgGlow2 = 'BgGlow2'; + const SUBSTYLE_BgGradBottom = 'BgGradBottom'; + const SUBSTYLE_BgGradLeft = 'BgGradLeft'; + const SUBSTYLE_BgGradRight = 'BgGradRight'; + const SUBSTYLE_BgGradTop = 'BgGradTop'; + const SUBSTYLE_BgGradV = 'BgGradV'; + const SUBSTYLE_BgHealthBar = 'BgHealthBar'; + const SUBSTYLE_BgIconBorder = 'BgIconBorder'; + const SUBSTYLE_BgList = 'BgList'; + const SUBSTYLE_BgListLine = 'BgListLine'; + const SUBSTYLE_BgMetalBar = 'BgMetalBar'; + const SUBSTYLE_BgPager = 'BgPager'; + const SUBSTYLE_BgProgressBar = 'BgProgressBar'; + const SUBSTYLE_BgShadow = 'BgShadow'; + const SUBSTYLE_BgSlider = 'BgSlider'; + const SUBSTYLE_BgSystemBar = 'BgSystemBar'; + const SUBSTYLE_BgTitle = 'BgTitle'; + const SUBSTYLE_BgTitle2 = 'BgTitle2'; + const SUBSTYLE_BgTitle3 = 'BgTitle3'; + const SUBSTYLE_BgTitle3_1 = 'BgTitle3_1'; + const SUBSTYLE_BgTitle3_2 = 'BgTitle3_2'; + const SUBSTYLE_BgTitle3_3 = 'BgTitle3_3'; + const SUBSTYLE_BgTitle3_4 = 'BgTitle3_4'; + const SUBSTYLE_BgTitle3_5 = 'BgTitle3_5'; + const SUBSTYLE_BgTitleGlow = 'BgTitleGlow'; + const SUBSTYLE_BgTitlePage = 'BgTitlePage'; + const SUBSTYLE_BgTitleShadow = 'BgTitleShadow'; + const SUBSTYLE_BgWindow1 = 'BgWindow1'; + const SUBSTYLE_BgWindow2 = 'BgWindow2'; + const SUBSTYLE_BgWindow3 = 'BgWindow3'; + const SUBSTYLE_BgWindow4 = 'BgWindow4'; + const SUBSTYLE_EnergyBar = 'EnergyBar'; + const SUBSTYLE_EnergyTeam2 = 'EnergyTeam2'; + const SUBSTYLE_Glow = 'Glow'; + const SUBSTYLE_HealthBar = 'HealthBar'; + const SUBSTYLE_NavButton = 'NavButton'; + const SUBSTYLE_NavButtonBlink = 'NavButtonBlink'; + const SUBSTYLE_NavButtonQuit = 'NavButtonQuit'; + const SUBSTYLE_ProgressBar = 'ProgressBar'; + const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; + const SUBSTYLE_Shadow = 'Shadow'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Bgs1InRace.php b/libs/FML/Controls/Quads/Quad_Bgs1InRace.php index 5081d706..a1c0a2ba 100644 --- a/libs/FML/Controls/Quads/Quad_Bgs1InRace.php +++ b/libs/FML/Controls/Quads/Quad_Bgs1InRace.php @@ -8,86 +8,89 @@ use FML\Controls\Quad; * Quad class for 'Bgs1InRace' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Bgs1InRace extends Quad { - /* - * Constants - */ - const STYLE = 'Bgs1InRace'; - const SUBSTYLE_ArrowDown = 'ArrowDown'; - const SUBSTYLE_ArrowLeft = 'ArrowLeft'; - const SUBSTYLE_ArrowRight = 'ArrowRight'; - const SUBSTYLE_ArrowUp = 'ArrowUp'; - const SUBSTYLE_BgButton = 'BgButton'; - const SUBSTYLE_BgButtonBig = 'BgButtonBig'; - const SUBSTYLE_BgButtonGlow = 'BgButtonGlow'; - const SUBSTYLE_BgButtonGrayed = 'BgButtonGrayed'; - const SUBSTYLE_BgButtonOff = 'BgButtonOff'; - const SUBSTYLE_BgButtonShadow = 'BgButtonShadow'; - const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; - const SUBSTYLE_BgCard = 'BgCard'; - const SUBSTYLE_BgCard1 = 'BgCard1'; - const SUBSTYLE_BgCard2 = 'BgCard2'; - const SUBSTYLE_BgCard3 = 'BgCard3'; - const SUBSTYLE_BgCardBuddy = 'BgCardBuddy'; - const SUBSTYLE_BgCardChallenge = 'BgCardChallenge'; - const SUBSTYLE_BgCardFolder = 'BgCardFolder'; - const SUBSTYLE_BgCardInventoryItem = 'BgCardInventoryItem'; - const SUBSTYLE_BgCardList = 'BgCardList'; - const SUBSTYLE_BgCardOnline = 'BgCardOnline'; - const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; - const SUBSTYLE_BgCardProperty = 'BgCardProperty'; - const SUBSTYLE_BgCardSystem = 'BgCardSystem'; - const SUBSTYLE_BgCardZone = 'BgCardZone'; - const SUBSTYLE_BgColorContour = 'BgColorContour'; - const SUBSTYLE_BgDialogBlur = 'BgDialogBlur'; - const SUBSTYLE_BgEmpty = 'BgEmpty'; - const SUBSTYLE_BgGlow2 = 'BgGlow2'; - const SUBSTYLE_BgGradBottom = 'BgGradBottom'; - const SUBSTYLE_BgGradLeft = 'BgGradLeft'; - const SUBSTYLE_BgGradRight = 'BgGradRight'; - const SUBSTYLE_BgGradTop = 'BgGradTop'; - const SUBSTYLE_BgGradV = 'BgGradV'; - const SUBSTYLE_BgHealthBar = 'BgHealthBar'; - const SUBSTYLE_BgIconBorder = 'BgIconBorder'; - const SUBSTYLE_BgList = 'BgList'; - const SUBSTYLE_BgListLine = 'BgListLine'; - const SUBSTYLE_BgMetalBar = 'BgMetalBar'; - const SUBSTYLE_BgPager = 'BgPager'; - const SUBSTYLE_BgProgressBar = 'BgProgressBar'; - const SUBSTYLE_BgShadow = 'BgShadow'; - const SUBSTYLE_BgSlider = 'BgSlider'; - const SUBSTYLE_BgSystemBar = 'BgSystemBar'; - const SUBSTYLE_BgTitle = 'BgTitle'; - const SUBSTYLE_BgTitle2 = 'BgTitle2'; - const SUBSTYLE_BgTitle3 = 'BgTitle3'; - const SUBSTYLE_BgTitle3_1 = 'BgTitle3_1'; - const SUBSTYLE_BgTitle3_2 = 'BgTitle3_2'; - const SUBSTYLE_BgTitle3_3 = 'BgTitle3_3'; - const SUBSTYLE_BgTitle3_4 = 'BgTitle3_4'; - const SUBSTYLE_BgTitle3_5 = 'BgTitle3_5'; - const SUBSTYLE_BgTitleGlow = 'BgTitleGlow'; - const SUBSTYLE_BgTitlePage = 'BgTitlePage'; - const SUBSTYLE_BgTitleShadow = 'BgTitleShadow'; - const SUBSTYLE_BgWindow1 = 'BgWindow1'; - const SUBSTYLE_BgWindow2 = 'BgWindow2'; - const SUBSTYLE_BgWindow3 = 'BgWindow3'; - const SUBSTYLE_BgWindow4 = 'BgWindow4'; - const SUBSTYLE_EnergyBar = 'EnergyBar'; - const SUBSTYLE_EnergyTeam2 = 'EnergyTeam2'; - const SUBSTYLE_Glow = 'Glow'; - const SUBSTYLE_HealthBar = 'HealthBar'; - const SUBSTYLE_NavButton = 'NavButton'; - const SUBSTYLE_NavButtonBlink = 'NavButtonBlink'; - const SUBSTYLE_NavButtonQuit = 'NavButtonQuit'; - const SUBSTYLE_ProgressBar = 'ProgressBar'; - const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; - const SUBSTYLE_Shadow = 'Shadow'; +class Quad_Bgs1InRace extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Bgs1InRace'; + const SUBSTYLE_ArrowDown = 'ArrowDown'; + const SUBSTYLE_ArrowLeft = 'ArrowLeft'; + const SUBSTYLE_ArrowRight = 'ArrowRight'; + const SUBSTYLE_ArrowUp = 'ArrowUp'; + const SUBSTYLE_BgButton = 'BgButton'; + const SUBSTYLE_BgButtonBig = 'BgButtonBig'; + const SUBSTYLE_BgButtonGlow = 'BgButtonGlow'; + const SUBSTYLE_BgButtonGrayed = 'BgButtonGrayed'; + const SUBSTYLE_BgButtonOff = 'BgButtonOff'; + const SUBSTYLE_BgButtonShadow = 'BgButtonShadow'; + const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; + const SUBSTYLE_BgCard = 'BgCard'; + const SUBSTYLE_BgCard1 = 'BgCard1'; + const SUBSTYLE_BgCard2 = 'BgCard2'; + const SUBSTYLE_BgCard3 = 'BgCard3'; + const SUBSTYLE_BgCardBuddy = 'BgCardBuddy'; + const SUBSTYLE_BgCardChallenge = 'BgCardChallenge'; + const SUBSTYLE_BgCardFolder = 'BgCardFolder'; + const SUBSTYLE_BgCardInventoryItem = 'BgCardInventoryItem'; + const SUBSTYLE_BgCardList = 'BgCardList'; + const SUBSTYLE_BgCardOnline = 'BgCardOnline'; + const SUBSTYLE_BgCardPlayer = 'BgCardPlayer'; + const SUBSTYLE_BgCardProperty = 'BgCardProperty'; + const SUBSTYLE_BgCardSystem = 'BgCardSystem'; + const SUBSTYLE_BgCardZone = 'BgCardZone'; + const SUBSTYLE_BgColorContour = 'BgColorContour'; + const SUBSTYLE_BgDialogBlur = 'BgDialogBlur'; + const SUBSTYLE_BgEmpty = 'BgEmpty'; + const SUBSTYLE_BgGlow2 = 'BgGlow2'; + const SUBSTYLE_BgGradBottom = 'BgGradBottom'; + const SUBSTYLE_BgGradLeft = 'BgGradLeft'; + const SUBSTYLE_BgGradRight = 'BgGradRight'; + const SUBSTYLE_BgGradTop = 'BgGradTop'; + const SUBSTYLE_BgGradV = 'BgGradV'; + const SUBSTYLE_BgHealthBar = 'BgHealthBar'; + const SUBSTYLE_BgIconBorder = 'BgIconBorder'; + const SUBSTYLE_BgList = 'BgList'; + const SUBSTYLE_BgListLine = 'BgListLine'; + const SUBSTYLE_BgMetalBar = 'BgMetalBar'; + const SUBSTYLE_BgPager = 'BgPager'; + const SUBSTYLE_BgProgressBar = 'BgProgressBar'; + const SUBSTYLE_BgShadow = 'BgShadow'; + const SUBSTYLE_BgSlider = 'BgSlider'; + const SUBSTYLE_BgSystemBar = 'BgSystemBar'; + const SUBSTYLE_BgTitle = 'BgTitle'; + const SUBSTYLE_BgTitle2 = 'BgTitle2'; + const SUBSTYLE_BgTitle3 = 'BgTitle3'; + const SUBSTYLE_BgTitle3_1 = 'BgTitle3_1'; + const SUBSTYLE_BgTitle3_2 = 'BgTitle3_2'; + const SUBSTYLE_BgTitle3_3 = 'BgTitle3_3'; + const SUBSTYLE_BgTitle3_4 = 'BgTitle3_4'; + const SUBSTYLE_BgTitle3_5 = 'BgTitle3_5'; + const SUBSTYLE_BgTitleGlow = 'BgTitleGlow'; + const SUBSTYLE_BgTitlePage = 'BgTitlePage'; + const SUBSTYLE_BgTitleShadow = 'BgTitleShadow'; + const SUBSTYLE_BgWindow1 = 'BgWindow1'; + const SUBSTYLE_BgWindow2 = 'BgWindow2'; + const SUBSTYLE_BgWindow3 = 'BgWindow3'; + const SUBSTYLE_BgWindow4 = 'BgWindow4'; + const SUBSTYLE_EnergyBar = 'EnergyBar'; + const SUBSTYLE_EnergyTeam2 = 'EnergyTeam2'; + const SUBSTYLE_Glow = 'Glow'; + const SUBSTYLE_HealthBar = 'HealthBar'; + const SUBSTYLE_NavButton = 'NavButton'; + const SUBSTYLE_NavButtonBlink = 'NavButtonBlink'; + const SUBSTYLE_NavButtonQuit = 'NavButtonQuit'; + const SUBSTYLE_ProgressBar = 'ProgressBar'; + const SUBSTYLE_ProgressBarSmall = 'ProgressBarSmall'; + const SUBSTYLE_Shadow = 'Shadow'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_BgsButtons.php b/libs/FML/Controls/Quads/Quad_BgsButtons.php index 95edb26f..0d184f83 100644 --- a/libs/FML/Controls/Quads/Quad_BgsButtons.php +++ b/libs/FML/Controls/Quads/Quad_BgsButtons.php @@ -8,24 +8,27 @@ use FML\Controls\Quad; * Quad class for 'BgsButtons' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_BgsButtons extends Quad { - /* - * Constants - */ - const STYLE = 'BgsButtons'; - const SUBSTYLE_BgButtonLarge = 'BgButtonLarge'; - const SUBSTYLE_BgButtonMedium = 'BgButtonMedium'; - const SUBSTYLE_BgButtonMediumSelector = 'BgButtonMediumSelector'; - const SUBSTYLE_BgButtonMediumSpecial = 'BgButtonMediumSpecial'; - const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; - const SUBSTYLE_BgButtonSmall2 = 'BgButtonSmall2'; - const SUBSTYLE_BgButtonXSmall = 'BgButtonXSmall'; +class Quad_BgsButtons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'BgsButtons'; + const SUBSTYLE_BgButtonLarge = 'BgButtonLarge'; + const SUBSTYLE_BgButtonMedium = 'BgButtonMedium'; + const SUBSTYLE_BgButtonMediumSelector = 'BgButtonMediumSelector'; + const SUBSTYLE_BgButtonMediumSpecial = 'BgButtonMediumSpecial'; + const SUBSTYLE_BgButtonSmall = 'BgButtonSmall'; + const SUBSTYLE_BgButtonSmall2 = 'BgButtonSmall2'; + const SUBSTYLE_BgButtonXSmall = 'BgButtonXSmall'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_BgsChallengeMedals.php b/libs/FML/Controls/Quads/Quad_BgsChallengeMedals.php index b0c9800c..2b462799 100644 --- a/libs/FML/Controls/Quads/Quad_BgsChallengeMedals.php +++ b/libs/FML/Controls/Quads/Quad_BgsChallengeMedals.php @@ -8,23 +8,26 @@ use FML\Controls\Quad; * Quad class for 'BgsChallengeMedals' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_BgsChallengeMedals extends Quad { - /* - * Constants - */ - const STYLE = 'BgsChallengeMedals'; - const SUBSTYLE_BgBronze = 'BgBronze'; - const SUBSTYLE_BgGold = 'BgGold'; - const SUBSTYLE_BgNadeo = 'BgNadeo'; - const SUBSTYLE_BgNotPlayed = 'BgNotPlayed'; - const SUBSTYLE_BgPlayed = 'BgPlayed'; - const SUBSTYLE_BgSilver = 'BgSilver'; +class Quad_BgsChallengeMedals extends Quad +{ + + /* + * Constants + */ + const STYLE = 'BgsChallengeMedals'; + const SUBSTYLE_BgBronze = 'BgBronze'; + const SUBSTYLE_BgGold = 'BgGold'; + const SUBSTYLE_BgNadeo = 'BgNadeo'; + const SUBSTYLE_BgNotPlayed = 'BgNotPlayed'; + const SUBSTYLE_BgPlayed = 'BgPlayed'; + const SUBSTYLE_BgSilver = 'BgSilver'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_BgsPlayerCard.php b/libs/FML/Controls/Quads/Quad_BgsPlayerCard.php index e18612df..509d9a54 100644 --- a/libs/FML/Controls/Quads/Quad_BgsPlayerCard.php +++ b/libs/FML/Controls/Quads/Quad_BgsPlayerCard.php @@ -8,31 +8,34 @@ use FML\Controls\Quad; * Quad class for 'BgsPlayerCard' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_BgsPlayerCard extends Quad { - /* - * Constants - */ - const STYLE = 'BgsPlayerCard'; - const SUBSTYLE_BgActivePlayerCard = 'BgActivePlayerCard'; - const SUBSTYLE_BgActivePlayerName = 'BgActivePlayerName'; - const SUBSTYLE_BgActivePlayerScore = 'BgActivePlayerScore'; - const SUBSTYLE_BgCard = 'BgCard'; - const SUBSTYLE_BgCardSystem = 'BgCardSystem'; - const SUBSTYLE_BgMediaTracker = 'BgMediaTracker'; - const SUBSTYLE_BgPlayerCard = 'BgPlayerCard'; - const SUBSTYLE_BgPlayerCardBig = 'BgPlayerCardBig'; - const SUBSTYLE_BgPlayerCardSmall = 'BgPlayerCardSmall'; - const SUBSTYLE_BgPlayerName = 'BgPlayerName'; - const SUBSTYLE_BgPlayerScore = 'BgPlayerScore'; - const SUBSTYLE_BgRacePlayerLine = 'BgRacePlayerLine'; - const SUBSTYLE_BgRacePlayerName = 'BgRacePlayerName'; - const SUBSTYLE_ProgressBar = 'ProgressBar'; +class Quad_BgsPlayerCard extends Quad +{ + + /* + * Constants + */ + const STYLE = 'BgsPlayerCard'; + const SUBSTYLE_BgActivePlayerCard = 'BgActivePlayerCard'; + const SUBSTYLE_BgActivePlayerName = 'BgActivePlayerName'; + const SUBSTYLE_BgActivePlayerScore = 'BgActivePlayerScore'; + const SUBSTYLE_BgCard = 'BgCard'; + const SUBSTYLE_BgCardSystem = 'BgCardSystem'; + const SUBSTYLE_BgMediaTracker = 'BgMediaTracker'; + const SUBSTYLE_BgPlayerCard = 'BgPlayerCard'; + const SUBSTYLE_BgPlayerCardBig = 'BgPlayerCardBig'; + const SUBSTYLE_BgPlayerCardSmall = 'BgPlayerCardSmall'; + const SUBSTYLE_BgPlayerName = 'BgPlayerName'; + const SUBSTYLE_BgPlayerScore = 'BgPlayerScore'; + const SUBSTYLE_BgRacePlayerLine = 'BgRacePlayerLine'; + const SUBSTYLE_BgRacePlayerName = 'BgRacePlayerName'; + const SUBSTYLE_ProgressBar = 'ProgressBar'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Copilot.php b/libs/FML/Controls/Quads/Quad_Copilot.php index 6e16cc41..22d7a9ff 100644 --- a/libs/FML/Controls/Quads/Quad_Copilot.php +++ b/libs/FML/Controls/Quads/Quad_Copilot.php @@ -8,29 +8,32 @@ use FML\Controls\Quad; * Quad class for 'Copilot' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Copilot extends Quad { - /* - * Constants - */ - const STYLE = 'Copilot'; - const SUBSTYLE_Down = 'Down'; - const SUBSTYLE_DownGood = 'DownGood'; - const SUBSTYLE_DownWrong = 'DownWrong'; - const SUBSTYLE_Left = 'Left'; - const SUBSTYLE_LeftGood = 'LeftGood'; - const SUBSTYLE_LeftWrong = 'LeftWrong'; - const SUBSTYLE_Right = 'Right'; - const SUBSTYLE_RightGood = 'RightGood'; - const SUBSTYLE_RightWrong = 'RightWrong'; - const SUBSTYLE_Up = 'Up'; - const SUBSTYLE_UpGood = 'UpGood'; - const SUBSTYLE_UpWrong = 'UpWrong'; +class Quad_Copilot extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Copilot'; + const SUBSTYLE_Down = 'Down'; + const SUBSTYLE_DownGood = 'DownGood'; + const SUBSTYLE_DownWrong = 'DownWrong'; + const SUBSTYLE_Left = 'Left'; + const SUBSTYLE_LeftGood = 'LeftGood'; + const SUBSTYLE_LeftWrong = 'LeftWrong'; + const SUBSTYLE_Right = 'Right'; + const SUBSTYLE_RightGood = 'RightGood'; + const SUBSTYLE_RightWrong = 'RightWrong'; + const SUBSTYLE_Up = 'Up'; + const SUBSTYLE_UpGood = 'UpGood'; + const SUBSTYLE_UpWrong = 'UpWrong'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Emblems.php b/libs/FML/Controls/Quads/Quad_Emblems.php index 2c1d91dd..b97c2a88 100644 --- a/libs/FML/Controls/Quads/Quad_Emblems.php +++ b/libs/FML/Controls/Quads/Quad_Emblems.php @@ -8,20 +8,23 @@ use FML\Controls\Quad; * Quad class for 'Emblems' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Emblems extends Quad { - /* - * Constants - */ - const STYLE = 'Emblems'; - const SUBSTYLE_0 = '#0'; - const SUBSTYLE_1 = '#1'; - const SUBSTYLE_2 = '#2'; +class Quad_Emblems extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Emblems'; + const SUBSTYLE_0 = '#0'; + const SUBSTYLE_1 = '#1'; + const SUBSTYLE_2 = '#2'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_EnergyBar.php b/libs/FML/Controls/Quads/Quad_EnergyBar.php index 24433c23..86eccfa9 100644 --- a/libs/FML/Controls/Quads/Quad_EnergyBar.php +++ b/libs/FML/Controls/Quads/Quad_EnergyBar.php @@ -8,23 +8,26 @@ use FML\Controls\Quad; * Quad class for 'EnergyBar' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_EnergyBar extends Quad { - /* - * Constants - */ - const STYLE = 'EnergyBar'; - const SUBSTYLE_BgText = 'BgText'; - const SUBSTYLE_EnergyBar = 'EnergyBar'; - const SUBSTYLE_EnergyBar_0_25 = 'EnergyBar_0.25'; - const SUBSTYLE_EnergyBar_Thin = 'EnergyBar_Thin'; - const SUBSTYLE_HeaderGaugeLeft = 'HeaderGaugeLeft'; - const SUBSTYLE_HeaderGaugeRight = 'HeaderGaugeRight'; +class Quad_EnergyBar extends Quad +{ + + /* + * Constants + */ + const STYLE = 'EnergyBar'; + const SUBSTYLE_BgText = 'BgText'; + const SUBSTYLE_EnergyBar = 'EnergyBar'; + const SUBSTYLE_EnergyBar_0_25 = 'EnergyBar_0.25'; + const SUBSTYLE_EnergyBar_Thin = 'EnergyBar_Thin'; + const SUBSTYLE_HeaderGaugeLeft = 'HeaderGaugeLeft'; + const SUBSTYLE_HeaderGaugeRight = 'HeaderGaugeRight'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Hud3dEchelons.php b/libs/FML/Controls/Quads/Quad_Hud3dEchelons.php index 994a61e3..c21f293c 100644 --- a/libs/FML/Controls/Quads/Quad_Hud3dEchelons.php +++ b/libs/FML/Controls/Quads/Quad_Hud3dEchelons.php @@ -8,26 +8,29 @@ use FML\Controls\Quad; * Quad class for 'Hud3dEchelons' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Hud3dEchelons extends Quad { - /* - * Constants - */ - const STYLE = 'Hud3dEchelons'; - const SUBSTYLE_EchelonBronze1 = 'EchelonBronze1'; - const SUBSTYLE_EchelonBronze2 = 'EchelonBronze2'; - const SUBSTYLE_EchelonBronze3 = 'EchelonBronze3'; - const SUBSTYLE_EchelonGold1 = 'EchelonGold1'; - const SUBSTYLE_EchelonGold2 = 'EchelonGold2'; - const SUBSTYLE_EchelonGold3 = 'EchelonGold3'; - const SUBSTYLE_EchelonSilver1 = 'EchelonSilver1'; - const SUBSTYLE_EchelonSilver2 = 'EchelonSilver2'; - const SUBSTYLE_EchelonSilver3 = 'EchelonSilver3'; +class Quad_Hud3dEchelons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Hud3dEchelons'; + const SUBSTYLE_EchelonBronze1 = 'EchelonBronze1'; + const SUBSTYLE_EchelonBronze2 = 'EchelonBronze2'; + const SUBSTYLE_EchelonBronze3 = 'EchelonBronze3'; + const SUBSTYLE_EchelonGold1 = 'EchelonGold1'; + const SUBSTYLE_EchelonGold2 = 'EchelonGold2'; + const SUBSTYLE_EchelonGold3 = 'EchelonGold3'; + const SUBSTYLE_EchelonSilver1 = 'EchelonSilver1'; + const SUBSTYLE_EchelonSilver2 = 'EchelonSilver2'; + const SUBSTYLE_EchelonSilver3 = 'EchelonSilver3'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Hud3dIcons.php b/libs/FML/Controls/Quads/Quad_Hud3dIcons.php index 84bd8801..4385cdc7 100644 --- a/libs/FML/Controls/Quads/Quad_Hud3dIcons.php +++ b/libs/FML/Controls/Quads/Quad_Hud3dIcons.php @@ -8,25 +8,28 @@ use FML\Controls\Quad; * Quad class for 'Hud3dIcons' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Hud3dIcons extends Quad { - /* - * Constants - */ - const STYLE = 'Hud3dIcons'; - const SUBSTYLE_Cross = 'Cross'; - const SUBSTYLE_CrossTargeted = 'CrossTargeted'; - const SUBSTYLE_Player1 = 'Player1'; - const SUBSTYLE_Player2 = 'Player2'; - const SUBSTYLE_Player3 = 'Player3'; - const SUBSTYLE_PointA = 'PointA'; - const SUBSTYLE_PointB = 'PointB'; - const SUBSTYLE_PointC = 'PointC'; +class Quad_Hud3dIcons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Hud3dIcons'; + const SUBSTYLE_Cross = 'Cross'; + const SUBSTYLE_CrossTargeted = 'CrossTargeted'; + const SUBSTYLE_Player1 = 'Player1'; + const SUBSTYLE_Player2 = 'Player2'; + const SUBSTYLE_Player3 = 'Player3'; + const SUBSTYLE_PointA = 'PointA'; + const SUBSTYLE_PointB = 'PointB'; + const SUBSTYLE_PointC = 'PointC'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons128x128_1.php b/libs/FML/Controls/Quads/Quad_Icons128x128_1.php index 7953b336..926fd32f 100644 --- a/libs/FML/Controls/Quads/Quad_Icons128x128_1.php +++ b/libs/FML/Controls/Quads/Quad_Icons128x128_1.php @@ -8,81 +8,84 @@ use FML\Controls\Quad; * Quad class for 'Icons128x128_1' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Icons128x128_1 extends Quad { - /* - * Constants - */ - const STYLE = 'Icons128x128_1'; - const SUBSTYLE_Advanced = 'Advanced'; - const SUBSTYLE_Back = 'Back'; - const SUBSTYLE_BackFocusable = 'BackFocusable'; - const SUBSTYLE_Beginner = 'Beginner'; - const SUBSTYLE_Browse = 'Browse'; - const SUBSTYLE_Buddies = 'Buddies'; - const SUBSTYLE_Challenge = 'Challenge'; - const SUBSTYLE_ChallengeAuthor = 'ChallengeAuthor'; - const SUBSTYLE_Coppers = 'Coppers'; - const SUBSTYLE_Create = 'Create'; - const SUBSTYLE_Credits = 'Credits'; - const SUBSTYLE_Custom = 'Custom'; - const SUBSTYLE_CustomStars = 'CustomStars'; - const SUBSTYLE_Default = 'Default'; - const SUBSTYLE_Download = 'Download'; - const SUBSTYLE_Easy = 'Easy'; - const SUBSTYLE_Editor = 'Editor'; - const SUBSTYLE_Event = 'Event'; - const SUBSTYLE_Extreme = 'Extreme'; - const SUBSTYLE_Forever = 'Forever'; - const SUBSTYLE_GhostEditor = 'GhostEditor'; - const SUBSTYLE_Hard = 'Hard'; - const SUBSTYLE_Hotseat = 'Hotseat'; - const SUBSTYLE_Inputs = 'Inputs'; - const SUBSTYLE_Invite = 'Invite'; - const SUBSTYLE_LadderPoints = 'LadderPoints'; - const SUBSTYLE_Lan = 'Lan'; - const SUBSTYLE_Launch = 'Launch'; - const SUBSTYLE_Load = 'Load'; - const SUBSTYLE_LoadTrack = 'LoadTrack'; - const SUBSTYLE_Manialink = 'Manialink'; - const SUBSTYLE_ManiaZones = 'ManiaZones'; - const SUBSTYLE_MedalCount = 'MedalCount'; - const SUBSTYLE_MediaTracker = 'MediaTracker'; - const SUBSTYLE_Medium = 'Medium'; - const SUBSTYLE_Multiplayer = 'Multiplayer'; - const SUBSTYLE_Nations = 'Nations'; - const SUBSTYLE_NewTrack = 'NewTrack'; - const SUBSTYLE_Options = 'Options'; - const SUBSTYLE_Padlock = 'Padlock'; - const SUBSTYLE_Paint = 'Paint'; - const SUBSTYLE_Platform = 'Platform'; - const SUBSTYLE_PlayerPage = 'PlayerPage'; - const SUBSTYLE_Profile = 'Profile'; - const SUBSTYLE_ProfileAdvanced = 'ProfileAdvanced'; - const SUBSTYLE_ProfileVehicle = 'ProfileVehicle'; - const SUBSTYLE_Puzzle = 'Puzzle'; - const SUBSTYLE_Quit = 'Quit'; - const SUBSTYLE_Race = 'Race'; - const SUBSTYLE_Rankings = 'Rankings'; - const SUBSTYLE_Replay = 'Replay'; - const SUBSTYLE_Save = 'Save'; - const SUBSTYLE_ServersAll = 'ServersAll'; - const SUBSTYLE_ServersFavorites = 'ServersFavorites'; - const SUBSTYLE_ServersSuggested = 'ServersSuggested'; - const SUBSTYLE_Share = 'Share'; - const SUBSTYLE_ShareBlink = 'ShareBlink'; - const SUBSTYLE_SkillPoints = 'SkillPoints'; - const SUBSTYLE_Solo = 'Solo'; - const SUBSTYLE_Statistics = 'Statistics'; - const SUBSTYLE_Stunts = 'Stunts'; - const SUBSTYLE_United = 'United'; - const SUBSTYLE_Upload = 'Upload'; - const SUBSTYLE_Vehicles = 'Vehicles'; +class Quad_Icons128x128_1 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons128x128_1'; + const SUBSTYLE_Advanced = 'Advanced'; + const SUBSTYLE_Back = 'Back'; + const SUBSTYLE_BackFocusable = 'BackFocusable'; + const SUBSTYLE_Beginner = 'Beginner'; + const SUBSTYLE_Browse = 'Browse'; + const SUBSTYLE_Buddies = 'Buddies'; + const SUBSTYLE_Challenge = 'Challenge'; + const SUBSTYLE_ChallengeAuthor = 'ChallengeAuthor'; + const SUBSTYLE_Coppers = 'Coppers'; + const SUBSTYLE_Create = 'Create'; + const SUBSTYLE_Credits = 'Credits'; + const SUBSTYLE_Custom = 'Custom'; + const SUBSTYLE_CustomStars = 'CustomStars'; + const SUBSTYLE_Default = 'Default'; + const SUBSTYLE_Download = 'Download'; + const SUBSTYLE_Easy = 'Easy'; + const SUBSTYLE_Editor = 'Editor'; + const SUBSTYLE_Event = 'Event'; + const SUBSTYLE_Extreme = 'Extreme'; + const SUBSTYLE_Forever = 'Forever'; + const SUBSTYLE_GhostEditor = 'GhostEditor'; + const SUBSTYLE_Hard = 'Hard'; + const SUBSTYLE_Hotseat = 'Hotseat'; + const SUBSTYLE_Inputs = 'Inputs'; + const SUBSTYLE_Invite = 'Invite'; + const SUBSTYLE_LadderPoints = 'LadderPoints'; + const SUBSTYLE_Lan = 'Lan'; + const SUBSTYLE_Launch = 'Launch'; + const SUBSTYLE_Load = 'Load'; + const SUBSTYLE_LoadTrack = 'LoadTrack'; + const SUBSTYLE_Manialink = 'Manialink'; + const SUBSTYLE_ManiaZones = 'ManiaZones'; + const SUBSTYLE_MedalCount = 'MedalCount'; + const SUBSTYLE_MediaTracker = 'MediaTracker'; + const SUBSTYLE_Medium = 'Medium'; + const SUBSTYLE_Multiplayer = 'Multiplayer'; + const SUBSTYLE_Nations = 'Nations'; + const SUBSTYLE_NewTrack = 'NewTrack'; + const SUBSTYLE_Options = 'Options'; + const SUBSTYLE_Padlock = 'Padlock'; + const SUBSTYLE_Paint = 'Paint'; + const SUBSTYLE_Platform = 'Platform'; + const SUBSTYLE_PlayerPage = 'PlayerPage'; + const SUBSTYLE_Profile = 'Profile'; + const SUBSTYLE_ProfileAdvanced = 'ProfileAdvanced'; + const SUBSTYLE_ProfileVehicle = 'ProfileVehicle'; + const SUBSTYLE_Puzzle = 'Puzzle'; + const SUBSTYLE_Quit = 'Quit'; + const SUBSTYLE_Race = 'Race'; + const SUBSTYLE_Rankings = 'Rankings'; + const SUBSTYLE_Replay = 'Replay'; + const SUBSTYLE_Save = 'Save'; + const SUBSTYLE_ServersAll = 'ServersAll'; + const SUBSTYLE_ServersFavorites = 'ServersFavorites'; + const SUBSTYLE_ServersSuggested = 'ServersSuggested'; + const SUBSTYLE_Share = 'Share'; + const SUBSTYLE_ShareBlink = 'ShareBlink'; + const SUBSTYLE_SkillPoints = 'SkillPoints'; + const SUBSTYLE_Solo = 'Solo'; + const SUBSTYLE_Statistics = 'Statistics'; + const SUBSTYLE_Stunts = 'Stunts'; + const SUBSTYLE_United = 'United'; + const SUBSTYLE_Upload = 'Upload'; + const SUBSTYLE_Vehicles = 'Vehicles'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons128x128_Blink.php b/libs/FML/Controls/Quads/Quad_Icons128x128_Blink.php index f0c797fe..65a6cb92 100644 --- a/libs/FML/Controls/Quads/Quad_Icons128x128_Blink.php +++ b/libs/FML/Controls/Quads/Quad_Icons128x128_Blink.php @@ -8,81 +8,84 @@ use FML\Controls\Quad; * Quad class for 'Icons128x128_Blink' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Icons128x128_Blink extends Quad { - /* - * Constants - */ - const STYLE = 'Icons128x128_Blink'; - const SUBSTYLE_Advanced = 'Advanced'; - const SUBSTYLE_Back = 'Back'; - const SUBSTYLE_BackFocusable = 'BackFocusable'; - const SUBSTYLE_Beginner = 'Beginner'; - const SUBSTYLE_Browse = 'Browse'; - const SUBSTYLE_Buddies = 'Buddies'; - const SUBSTYLE_Challenge = 'Challenge'; - const SUBSTYLE_ChallengeAuthor = 'ChallengeAuthor'; - const SUBSTYLE_Coppers = 'Coppers'; - const SUBSTYLE_Create = 'Create'; - const SUBSTYLE_Credits = 'Credits'; - const SUBSTYLE_Custom = 'Custom'; - const SUBSTYLE_CustomStars = 'CustomStars'; - const SUBSTYLE_Default = 'Default'; - const SUBSTYLE_Download = 'Download'; - const SUBSTYLE_Easy = 'Easy'; - const SUBSTYLE_Editor = 'Editor'; - const SUBSTYLE_Event = 'Event'; - const SUBSTYLE_Extreme = 'Extreme'; - const SUBSTYLE_Forever = 'Forever'; - const SUBSTYLE_GhostEditor = 'GhostEditor'; - const SUBSTYLE_Hard = 'Hard'; - const SUBSTYLE_Hotseat = 'Hotseat'; - const SUBSTYLE_Inputs = 'Inputs'; - const SUBSTYLE_Invite = 'Invite'; - const SUBSTYLE_LadderPoints = 'LadderPoints'; - const SUBSTYLE_Lan = 'Lan'; - const SUBSTYLE_Launch = 'Launch'; - const SUBSTYLE_Load = 'Load'; - const SUBSTYLE_LoadTrack = 'LoadTrack'; - const SUBSTYLE_Manialink = 'Manialink'; - const SUBSTYLE_ManiaZones = 'ManiaZones'; - const SUBSTYLE_MedalCount = 'MedalCount'; - const SUBSTYLE_MediaTracker = 'MediaTracker'; - const SUBSTYLE_Medium = 'Medium'; - const SUBSTYLE_Multiplayer = 'Multiplayer'; - const SUBSTYLE_Nations = 'Nations'; - const SUBSTYLE_NewTrack = 'NewTrack'; - const SUBSTYLE_Options = 'Options'; - const SUBSTYLE_Padlock = 'Padlock'; - const SUBSTYLE_Paint = 'Paint'; - const SUBSTYLE_Platform = 'Platform'; - const SUBSTYLE_PlayerPage = 'PlayerPage'; - const SUBSTYLE_Profile = 'Profile'; - const SUBSTYLE_ProfileAdvanced = 'ProfileAdvanced'; - const SUBSTYLE_ProfileVehicle = 'ProfileVehicle'; - const SUBSTYLE_Puzzle = 'Puzzle'; - const SUBSTYLE_Quit = 'Quit'; - const SUBSTYLE_Race = 'Race'; - const SUBSTYLE_Rankings = 'Rankings'; - const SUBSTYLE_Replay = 'Replay'; - const SUBSTYLE_Save = 'Save'; - const SUBSTYLE_ServersAll = 'ServersAll'; - const SUBSTYLE_ServersFavorites = 'ServersFavorites'; - const SUBSTYLE_ServersSuggested = 'ServersSuggested'; - const SUBSTYLE_Share = 'Share'; - const SUBSTYLE_ShareBlink = 'ShareBlink'; - const SUBSTYLE_SkillPoints = 'SkillPoints'; - const SUBSTYLE_Solo = 'Solo'; - const SUBSTYLE_Statistics = 'Statistics'; - const SUBSTYLE_Stunts = 'Stunts'; - const SUBSTYLE_United = 'United'; - const SUBSTYLE_Upload = 'Upload'; - const SUBSTYLE_Vehicles = 'Vehicles'; +class Quad_Icons128x128_Blink extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons128x128_Blink'; + const SUBSTYLE_Advanced = 'Advanced'; + const SUBSTYLE_Back = 'Back'; + const SUBSTYLE_BackFocusable = 'BackFocusable'; + const SUBSTYLE_Beginner = 'Beginner'; + const SUBSTYLE_Browse = 'Browse'; + const SUBSTYLE_Buddies = 'Buddies'; + const SUBSTYLE_Challenge = 'Challenge'; + const SUBSTYLE_ChallengeAuthor = 'ChallengeAuthor'; + const SUBSTYLE_Coppers = 'Coppers'; + const SUBSTYLE_Create = 'Create'; + const SUBSTYLE_Credits = 'Credits'; + const SUBSTYLE_Custom = 'Custom'; + const SUBSTYLE_CustomStars = 'CustomStars'; + const SUBSTYLE_Default = 'Default'; + const SUBSTYLE_Download = 'Download'; + const SUBSTYLE_Easy = 'Easy'; + const SUBSTYLE_Editor = 'Editor'; + const SUBSTYLE_Event = 'Event'; + const SUBSTYLE_Extreme = 'Extreme'; + const SUBSTYLE_Forever = 'Forever'; + const SUBSTYLE_GhostEditor = 'GhostEditor'; + const SUBSTYLE_Hard = 'Hard'; + const SUBSTYLE_Hotseat = 'Hotseat'; + const SUBSTYLE_Inputs = 'Inputs'; + const SUBSTYLE_Invite = 'Invite'; + const SUBSTYLE_LadderPoints = 'LadderPoints'; + const SUBSTYLE_Lan = 'Lan'; + const SUBSTYLE_Launch = 'Launch'; + const SUBSTYLE_Load = 'Load'; + const SUBSTYLE_LoadTrack = 'LoadTrack'; + const SUBSTYLE_Manialink = 'Manialink'; + const SUBSTYLE_ManiaZones = 'ManiaZones'; + const SUBSTYLE_MedalCount = 'MedalCount'; + const SUBSTYLE_MediaTracker = 'MediaTracker'; + const SUBSTYLE_Medium = 'Medium'; + const SUBSTYLE_Multiplayer = 'Multiplayer'; + const SUBSTYLE_Nations = 'Nations'; + const SUBSTYLE_NewTrack = 'NewTrack'; + const SUBSTYLE_Options = 'Options'; + const SUBSTYLE_Padlock = 'Padlock'; + const SUBSTYLE_Paint = 'Paint'; + const SUBSTYLE_Platform = 'Platform'; + const SUBSTYLE_PlayerPage = 'PlayerPage'; + const SUBSTYLE_Profile = 'Profile'; + const SUBSTYLE_ProfileAdvanced = 'ProfileAdvanced'; + const SUBSTYLE_ProfileVehicle = 'ProfileVehicle'; + const SUBSTYLE_Puzzle = 'Puzzle'; + const SUBSTYLE_Quit = 'Quit'; + const SUBSTYLE_Race = 'Race'; + const SUBSTYLE_Rankings = 'Rankings'; + const SUBSTYLE_Replay = 'Replay'; + const SUBSTYLE_Save = 'Save'; + const SUBSTYLE_ServersAll = 'ServersAll'; + const SUBSTYLE_ServersFavorites = 'ServersFavorites'; + const SUBSTYLE_ServersSuggested = 'ServersSuggested'; + const SUBSTYLE_Share = 'Share'; + const SUBSTYLE_ShareBlink = 'ShareBlink'; + const SUBSTYLE_SkillPoints = 'SkillPoints'; + const SUBSTYLE_Solo = 'Solo'; + const SUBSTYLE_Statistics = 'Statistics'; + const SUBSTYLE_Stunts = 'Stunts'; + const SUBSTYLE_United = 'United'; + const SUBSTYLE_Upload = 'Upload'; + const SUBSTYLE_Vehicles = 'Vehicles'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons128x32_1.php b/libs/FML/Controls/Quads/Quad_Icons128x32_1.php index 33388e97..eadf34d8 100644 --- a/libs/FML/Controls/Quads/Quad_Icons128x32_1.php +++ b/libs/FML/Controls/Quads/Quad_Icons128x32_1.php @@ -8,47 +8,50 @@ use FML\Controls\Quad; * Quad class for 'Icons128x32_1' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Icons128x32_1 extends Quad { - /* - * Constants - */ - const STYLE = 'Icons128x32_1'; - const SUBSTYLE_ArrowUp = 'ArrowUp'; - const SUBSTYLE_BgQuadWhite = 'BgQuadWhite'; - // TODO: validate existence of 'close' - const SUBSTYLE_Close = 'Close'; - const SUBSTYLE_Empty = 'Empty'; - const SUBSTYLE_ManiaLinkHome = 'ManiaLinkHome'; - const SUBSTYLE_ManiaLinkSwitch = 'ManiaLinkSwitch'; - const SUBSTYLE_ManiaPlanet = 'ManiaPlanet'; - const SUBSTYLE_Minimize = 'Minimize'; - const SUBSTYLE_Music = 'Music'; - const SUBSTYLE_PainterBrush = 'PainterBrush'; - const SUBSTYLE_PainterFill = 'PainterFill'; - const SUBSTYLE_PainterLayer = 'PainterLayer'; - const SUBSTYLE_PainterMirror = 'PainterMirror'; - const SUBSTYLE_PainterSticker = 'PainterSticker'; - const SUBSTYLE_PainterTeam = 'PainterTeam'; - const SUBSTYLE_RT_Cup = 'RT_Cup'; - const SUBSTYLE_RT_Laps = 'RT_Laps'; - const SUBSTYLE_RT_Rounds = 'RT_Rounds'; - const SUBSTYLE_RT_Script = 'RT_Script'; - const SUBSTYLE_RT_Team = 'RT_Team'; - const SUBSTYLE_RT_TimeAttack = 'RT_TimeAttack'; - const SUBSTYLE_RT_Stunts = 'RT_Stunts'; - const SUBSTYLE_Settings = 'Settings'; - const SUBSTYLE_SliderBar = 'SliderBar'; - const SUBSTYLE_SliderBar2 = 'SliderBar2'; - const SUBSTYLE_SliderCursor = 'SliderCursor'; - const SUBSTYLE_Sound = 'Sound'; - const SUBSTYLE_UrlBg = 'UrlBg'; - const SUBSTYLE_Windowed = 'Windowed'; +class Quad_Icons128x32_1 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons128x32_1'; + const SUBSTYLE_ArrowUp = 'ArrowUp'; + const SUBSTYLE_BgQuadWhite = 'BgQuadWhite'; + // TODO: validate existence of 'close' + const SUBSTYLE_Close = 'Close'; + const SUBSTYLE_Empty = 'Empty'; + const SUBSTYLE_ManiaLinkHome = 'ManiaLinkHome'; + const SUBSTYLE_ManiaLinkSwitch = 'ManiaLinkSwitch'; + const SUBSTYLE_ManiaPlanet = 'ManiaPlanet'; + const SUBSTYLE_Minimize = 'Minimize'; + const SUBSTYLE_Music = 'Music'; + const SUBSTYLE_PainterBrush = 'PainterBrush'; + const SUBSTYLE_PainterFill = 'PainterFill'; + const SUBSTYLE_PainterLayer = 'PainterLayer'; + const SUBSTYLE_PainterMirror = 'PainterMirror'; + const SUBSTYLE_PainterSticker = 'PainterSticker'; + const SUBSTYLE_PainterTeam = 'PainterTeam'; + const SUBSTYLE_RT_Cup = 'RT_Cup'; + const SUBSTYLE_RT_Laps = 'RT_Laps'; + const SUBSTYLE_RT_Rounds = 'RT_Rounds'; + const SUBSTYLE_RT_Script = 'RT_Script'; + const SUBSTYLE_RT_Team = 'RT_Team'; + const SUBSTYLE_RT_TimeAttack = 'RT_TimeAttack'; + const SUBSTYLE_RT_Stunts = 'RT_Stunts'; + const SUBSTYLE_Settings = 'Settings'; + const SUBSTYLE_SliderBar = 'SliderBar'; + const SUBSTYLE_SliderBar2 = 'SliderBar2'; + const SUBSTYLE_SliderCursor = 'SliderCursor'; + const SUBSTYLE_Sound = 'Sound'; + const SUBSTYLE_UrlBg = 'UrlBg'; + const SUBSTYLE_Windowed = 'Windowed'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons64x64_1.php b/libs/FML/Controls/Quads/Quad_Icons64x64_1.php index 1462d947..6e925893 100644 --- a/libs/FML/Controls/Quads/Quad_Icons64x64_1.php +++ b/libs/FML/Controls/Quads/Quad_Icons64x64_1.php @@ -8,103 +8,106 @@ use FML\Controls\Quad; * Quad class for 'Icons64x64_1' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Icons64x64_1 extends Quad { - /* - * Constants - */ - const STYLE = 'Icons64x64_1'; - const SUBSTYLE_3DStereo = '3DStereo'; - const SUBSTYLE_Add = 'Add'; - const SUBSTYLE_ArrowBlue = 'ArrowBlue'; - const SUBSTYLE_ArrowDisabled = 'ArrowDisabled'; - const SUBSTYLE_ArrowDown = 'ArrowDown'; - const SUBSTYLE_ArrowFastNext = 'ArrowFastNext'; - const SUBSTYLE_ArrowFastPrev = 'ArrowFastPrev'; - const SUBSTYLE_ArrowFirst = 'ArrowFirst'; - const SUBSTYLE_ArrowGreen = 'ArrowGreen'; - const SUBSTYLE_ArrowLast = 'ArrowLast'; - const SUBSTYLE_ArrowNext = 'ArrowNext'; - const SUBSTYLE_ArrowPrev = 'ArrowPrev'; - const SUBSTYLE_ArrowRed = 'ArrowRed'; - const SUBSTYLE_ArrowUp = 'ArrowUp'; - const SUBSTYLE_Browser = 'Browser'; - const SUBSTYLE_Buddy = 'Buddy'; - const SUBSTYLE_ButtonLeagues = 'ButtonLeagues'; - const SUBSTYLE_Camera = 'Camera'; - const SUBSTYLE_CameraLocal = 'CameraLocal'; - const SUBSTYLE_Check = 'Check'; - const SUBSTYLE_ClipPause = 'ClipPause'; - const SUBSTYLE_ClipPlay = 'ClipPlay'; - const SUBSTYLE_ClipRewind = 'ClipRewind'; - const SUBSTYLE_Close = 'Close'; - const SUBSTYLE_Empty = 'Empty'; - const SUBSTYLE_Finish = 'Finish'; - const SUBSTYLE_FinishGrey = 'FinishGrey'; - const SUBSTYLE_First = 'First'; - const SUBSTYLE_GenericButton = 'GenericButton'; - const SUBSTYLE_Green = 'Green'; - const SUBSTYLE_IconLeaguesLadder = 'IconLeaguesLadder'; - const SUBSTYLE_IconPlayers = 'IconPlayers'; - const SUBSTYLE_IconPlayersLadder = 'IconPlayersLadder'; - const SUBSTYLE_IconServers = 'IconServers'; - const SUBSTYLE_Inbox = 'Inbox'; - const SUBSTYLE_LvlGreen = 'LvlGreen'; - const SUBSTYLE_LvlRed = 'LvlRed'; - const SUBSTYLE_LvlYellow = 'LvlYellow'; - const SUBSTYLE_ManiaLinkNext = 'ManiaLinkNext'; - const SUBSTYLE_ManiaLinkPrev = 'ManiaLinkPrev'; - const SUBSTYLE_Maximize = 'Maximize'; - const SUBSTYLE_MediaAudioDownloading = 'MediaAudioDownloading'; - const SUBSTYLE_MediaPlay = 'MediaPlay'; - const SUBSTYLE_MediaStop = 'MediaStop'; - const SUBSTYLE_MediaVideoDownloading = 'MediaVideoDownloading'; - const SUBSTYLE_NewMessage = 'NewMessage'; - const SUBSTYLE_NotBuddy = 'NotBuddy'; - const SUBSTYLE_OfficialRace = 'OfficialRace'; - const SUBSTYLE_Opponents = 'Opponents'; - const SUBSTYLE_Outbox = 'Outbox'; - const SUBSTYLE_QuitRace = 'QuitRace'; - const SUBSTYLE_RedHigh = 'RedHigh'; - const SUBSTYLE_RedLow = 'RedLow'; - const SUBSTYLE_Refresh = 'Refresh'; - const SUBSTYLE_RestartRace = 'RestartRace'; - const SUBSTYLE_Save = 'Save'; - const SUBSTYLE_Second = 'Second'; - const SUBSTYLE_ShowDown = 'ShowDown'; - const SUBSTYLE_ShowDown2 = 'ShowDown2'; - const SUBSTYLE_ShowLeft = 'ShowLeft'; - const SUBSTYLE_ShowLeft2 = 'ShowLeft2'; - const SUBSTYLE_ShowRight = 'ShowRight'; - const SUBSTYLE_ShowRight2 = 'ShowRight2'; - const SUBSTYLE_ShowUp = 'ShowUp'; - const SUBSTYLE_ShowUp2 = 'ShowUp2'; - const SUBSTYLE_ShowUpChanging = 'ShowUpChanging'; - const SUBSTYLE_SliderCursor = 'SliderCursor'; - const SUBSTYLE_SliderCursor2 = 'SliderCursor2'; - const SUBSTYLE_StateFavourite = 'StateFavourite'; - const SUBSTYLE_StatePrivate = 'StatePrivate'; - const SUBSTYLE_StateSuggested = 'StateSuggested'; - const SUBSTYLE_Sub = 'Sub'; - const SUBSTYLE_TagTypeBronze = 'TagTypeBronze'; - const SUBSTYLE_TagTypeGold = 'TagTypeGold'; - const SUBSTYLE_TagTypeNadeo = 'TagTypeNadeo'; - const SUBSTYLE_TagTypeNone = 'TagTypeNone'; - const SUBSTYLE_TagTypeSilver = 'TagTypeSilver'; - const SUBSTYLE_Third = 'Third'; - const SUBSTYLE_ToolLeague1 = 'ToolLeague1'; - const SUBSTYLE_ToolRoot = 'ToolRoot'; - const SUBSTYLE_ToolTree = 'ToolTree'; - const SUBSTYLE_ToolUp = 'ToolUp'; - const SUBSTYLE_TrackInfo = 'TrackInfo'; - const SUBSTYLE_TV = 'TV'; - const SUBSTYLE_YellowHigh = 'YellowHigh'; - const SUBSTYLE_YellowLow = 'YellowLow'; +class Quad_Icons64x64_1 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons64x64_1'; + const SUBSTYLE_3DStereo = '3DStereo'; + const SUBSTYLE_Add = 'Add'; + const SUBSTYLE_ArrowBlue = 'ArrowBlue'; + const SUBSTYLE_ArrowDisabled = 'ArrowDisabled'; + const SUBSTYLE_ArrowDown = 'ArrowDown'; + const SUBSTYLE_ArrowFastNext = 'ArrowFastNext'; + const SUBSTYLE_ArrowFastPrev = 'ArrowFastPrev'; + const SUBSTYLE_ArrowFirst = 'ArrowFirst'; + const SUBSTYLE_ArrowGreen = 'ArrowGreen'; + const SUBSTYLE_ArrowLast = 'ArrowLast'; + const SUBSTYLE_ArrowNext = 'ArrowNext'; + const SUBSTYLE_ArrowPrev = 'ArrowPrev'; + const SUBSTYLE_ArrowRed = 'ArrowRed'; + const SUBSTYLE_ArrowUp = 'ArrowUp'; + const SUBSTYLE_Browser = 'Browser'; + const SUBSTYLE_Buddy = 'Buddy'; + const SUBSTYLE_ButtonLeagues = 'ButtonLeagues'; + const SUBSTYLE_Camera = 'Camera'; + const SUBSTYLE_CameraLocal = 'CameraLocal'; + const SUBSTYLE_Check = 'Check'; + const SUBSTYLE_ClipPause = 'ClipPause'; + const SUBSTYLE_ClipPlay = 'ClipPlay'; + const SUBSTYLE_ClipRewind = 'ClipRewind'; + const SUBSTYLE_Close = 'Close'; + const SUBSTYLE_Empty = 'Empty'; + const SUBSTYLE_Finish = 'Finish'; + const SUBSTYLE_FinishGrey = 'FinishGrey'; + const SUBSTYLE_First = 'First'; + const SUBSTYLE_GenericButton = 'GenericButton'; + const SUBSTYLE_Green = 'Green'; + const SUBSTYLE_IconLeaguesLadder = 'IconLeaguesLadder'; + const SUBSTYLE_IconPlayers = 'IconPlayers'; + const SUBSTYLE_IconPlayersLadder = 'IconPlayersLadder'; + const SUBSTYLE_IconServers = 'IconServers'; + const SUBSTYLE_Inbox = 'Inbox'; + const SUBSTYLE_LvlGreen = 'LvlGreen'; + const SUBSTYLE_LvlRed = 'LvlRed'; + const SUBSTYLE_LvlYellow = 'LvlYellow'; + const SUBSTYLE_ManiaLinkNext = 'ManiaLinkNext'; + const SUBSTYLE_ManiaLinkPrev = 'ManiaLinkPrev'; + const SUBSTYLE_Maximize = 'Maximize'; + const SUBSTYLE_MediaAudioDownloading = 'MediaAudioDownloading'; + const SUBSTYLE_MediaPlay = 'MediaPlay'; + const SUBSTYLE_MediaStop = 'MediaStop'; + const SUBSTYLE_MediaVideoDownloading = 'MediaVideoDownloading'; + const SUBSTYLE_NewMessage = 'NewMessage'; + const SUBSTYLE_NotBuddy = 'NotBuddy'; + const SUBSTYLE_OfficialRace = 'OfficialRace'; + const SUBSTYLE_Opponents = 'Opponents'; + const SUBSTYLE_Outbox = 'Outbox'; + const SUBSTYLE_QuitRace = 'QuitRace'; + const SUBSTYLE_RedHigh = 'RedHigh'; + const SUBSTYLE_RedLow = 'RedLow'; + const SUBSTYLE_Refresh = 'Refresh'; + const SUBSTYLE_RestartRace = 'RestartRace'; + const SUBSTYLE_Save = 'Save'; + const SUBSTYLE_Second = 'Second'; + const SUBSTYLE_ShowDown = 'ShowDown'; + const SUBSTYLE_ShowDown2 = 'ShowDown2'; + const SUBSTYLE_ShowLeft = 'ShowLeft'; + const SUBSTYLE_ShowLeft2 = 'ShowLeft2'; + const SUBSTYLE_ShowRight = 'ShowRight'; + const SUBSTYLE_ShowRight2 = 'ShowRight2'; + const SUBSTYLE_ShowUp = 'ShowUp'; + const SUBSTYLE_ShowUp2 = 'ShowUp2'; + const SUBSTYLE_ShowUpChanging = 'ShowUpChanging'; + const SUBSTYLE_SliderCursor = 'SliderCursor'; + const SUBSTYLE_SliderCursor2 = 'SliderCursor2'; + const SUBSTYLE_StateFavourite = 'StateFavourite'; + const SUBSTYLE_StatePrivate = 'StatePrivate'; + const SUBSTYLE_StateSuggested = 'StateSuggested'; + const SUBSTYLE_Sub = 'Sub'; + const SUBSTYLE_TagTypeBronze = 'TagTypeBronze'; + const SUBSTYLE_TagTypeGold = 'TagTypeGold'; + const SUBSTYLE_TagTypeNadeo = 'TagTypeNadeo'; + const SUBSTYLE_TagTypeNone = 'TagTypeNone'; + const SUBSTYLE_TagTypeSilver = 'TagTypeSilver'; + const SUBSTYLE_Third = 'Third'; + const SUBSTYLE_ToolLeague1 = 'ToolLeague1'; + const SUBSTYLE_ToolRoot = 'ToolRoot'; + const SUBSTYLE_ToolTree = 'ToolTree'; + const SUBSTYLE_ToolUp = 'ToolUp'; + const SUBSTYLE_TrackInfo = 'TrackInfo'; + const SUBSTYLE_TV = 'TV'; + const SUBSTYLE_YellowHigh = 'YellowHigh'; + const SUBSTYLE_YellowLow = 'YellowLow'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_Icons64x64_2.php b/libs/FML/Controls/Quads/Quad_Icons64x64_2.php index 5482bcc7..153a805f 100644 --- a/libs/FML/Controls/Quads/Quad_Icons64x64_2.php +++ b/libs/FML/Controls/Quads/Quad_Icons64x64_2.php @@ -8,32 +8,35 @@ use FML\Controls\Quad; * Quad class for 'Icons64x64_2' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_Icons64x64_2 extends Quad { - /* - * Constants - */ - const STYLE = 'Icons64x64_2'; - const SUBSTYLE_ArrowElimination = 'ArrowElimination'; - const SUBSTYLE_ArrowHit = 'ArrowHit'; - const SUBSTYLE_Calendar = 'Calendar'; - const SUBSTYLE_Disconnected = 'Disconnected'; - const SUBSTYLE_DisconnectedLight = 'DisconnectedLight'; - const SUBSTYLE_LaserElimination = 'LaserElimination'; - const SUBSTYLE_LaserHit = 'LaserHit'; - const SUBSTYLE_NucleusElimination = 'NucleusElimination'; - const SUBSTYLE_NucleusHit = 'NucleusHit'; - const SUBSTYLE_RocketElimination = 'RocketElimination'; - const SUBSTYLE_RocketHit = 'RocketHit'; - const SUBSTYLE_ServerNotice = 'ServerNotice'; - const SUBSTYLE_SortBy = 'SortBy'; - const SUBSTYLE_UnknownElimination = 'UnknownElimination'; - const SUBSTYLE_UnknownHit = 'UnknownHit'; +class Quad_Icons64x64_2 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'Icons64x64_2'; + const SUBSTYLE_ArrowElimination = 'ArrowElimination'; + const SUBSTYLE_ArrowHit = 'ArrowHit'; + const SUBSTYLE_Calendar = 'Calendar'; + const SUBSTYLE_Disconnected = 'Disconnected'; + const SUBSTYLE_DisconnectedLight = 'DisconnectedLight'; + const SUBSTYLE_LaserElimination = 'LaserElimination'; + const SUBSTYLE_LaserHit = 'LaserHit'; + const SUBSTYLE_NucleusElimination = 'NucleusElimination'; + const SUBSTYLE_NucleusHit = 'NucleusHit'; + const SUBSTYLE_RocketElimination = 'RocketElimination'; + const SUBSTYLE_RocketHit = 'RocketHit'; + const SUBSTYLE_ServerNotice = 'ServerNotice'; + const SUBSTYLE_SortBy = 'SortBy'; + const SUBSTYLE_UnknownElimination = 'UnknownElimination'; + const SUBSTYLE_UnknownHit = 'UnknownHit'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_ManiaPlanetLogos.php b/libs/FML/Controls/Quads/Quad_ManiaPlanetLogos.php index 5ed4b67c..3ed1b967 100644 --- a/libs/FML/Controls/Quads/Quad_ManiaPlanetLogos.php +++ b/libs/FML/Controls/Quads/Quad_ManiaPlanetLogos.php @@ -8,24 +8,27 @@ use FML\Controls\Quad; * Quad class for 'ManiaPlanetLogos' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_ManiaPlanetLogos extends Quad { - /* - * Constants - */ - const STYLE = 'ManiaPlanetLogos'; - const SUBSTYLE_IconPlanets = 'IconPlanets'; - const SUBSTYLE_IconPlanetsPerspective = 'IconPlanetsPerspective'; - const SUBSTYLE_IconPlanetsSmall = 'IconPlanetsSmall'; - const SUBSTYLE_ManiaPlanetLogoBlack = 'ManiaPlanetLogoBlack'; - const SUBSTYLE_ManiaPlanetLogoBlackSmall = 'ManiaPlanetLogoBlackSmall'; - const SUBSTYLE_ManiaPlanetLogoWhite = 'ManiaPlanetLogoWhite'; - const SUBSTYLE_ManiaPlanetLogoWhiteSmall = 'ManiaPlanetLogoWhiteSmall'; +class Quad_ManiaPlanetLogos extends Quad +{ + + /* + * Constants + */ + const STYLE = 'ManiaPlanetLogos'; + const SUBSTYLE_IconPlanets = 'IconPlanets'; + const SUBSTYLE_IconPlanetsPerspective = 'IconPlanetsPerspective'; + const SUBSTYLE_IconPlanetsSmall = 'IconPlanetsSmall'; + const SUBSTYLE_ManiaPlanetLogoBlack = 'ManiaPlanetLogoBlack'; + const SUBSTYLE_ManiaPlanetLogoBlackSmall = 'ManiaPlanetLogoBlackSmall'; + const SUBSTYLE_ManiaPlanetLogoWhite = 'ManiaPlanetLogoWhite'; + const SUBSTYLE_ManiaPlanetLogoWhiteSmall = 'ManiaPlanetLogoWhiteSmall'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_ManiaPlanetMainMenu.php b/libs/FML/Controls/Quads/Quad_ManiaPlanetMainMenu.php index abf750bd..b8c3b5f2 100644 --- a/libs/FML/Controls/Quads/Quad_ManiaPlanetMainMenu.php +++ b/libs/FML/Controls/Quads/Quad_ManiaPlanetMainMenu.php @@ -8,28 +8,31 @@ use FML\Controls\Quad; * Quad class for 'ManiaPlanetMainMenu' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_ManiaPlanetMainMenu extends Quad { - /* - * Constants - */ - const STYLE = 'ManiaPlanetMainMenu'; - const SUBSTYLE_BottomBar = 'BottomBar'; - const SUBSTYLE_Highlight = 'Highlight'; - const SUBSTYLE_IconAdd = 'IconAdd'; - const SUBSTYLE_IconHome = 'IconHome'; - const SUBSTYLE_IconPlay = 'IconPlay'; - const SUBSTYLE_IconQuit = 'IconQuit'; - const SUBSTYLE_IconSettings = 'IconSettings'; - const SUBSTYLE_IconStore = 'IconStore'; - const SUBSTYLE_MainBg = 'MainBg'; - const SUBSTYLE_TitleBg = 'TitleBg'; - const SUBSTYLE_TopBar = 'TopBar'; +class Quad_ManiaPlanetMainMenu extends Quad +{ + + /* + * Constants + */ + const STYLE = 'ManiaPlanetMainMenu'; + const SUBSTYLE_BottomBar = 'BottomBar'; + const SUBSTYLE_Highlight = 'Highlight'; + const SUBSTYLE_IconAdd = 'IconAdd'; + const SUBSTYLE_IconHome = 'IconHome'; + const SUBSTYLE_IconPlay = 'IconPlay'; + const SUBSTYLE_IconQuit = 'IconQuit'; + const SUBSTYLE_IconSettings = 'IconSettings'; + const SUBSTYLE_IconStore = 'IconStore'; + const SUBSTYLE_MainBg = 'MainBg'; + const SUBSTYLE_TitleBg = 'TitleBg'; + const SUBSTYLE_TopBar = 'TopBar'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_ManiaplanetSystem.php b/libs/FML/Controls/Quads/Quad_ManiaplanetSystem.php index 82d3fb29..4217d4ec 100644 --- a/libs/FML/Controls/Quads/Quad_ManiaplanetSystem.php +++ b/libs/FML/Controls/Quads/Quad_ManiaplanetSystem.php @@ -8,23 +8,26 @@ use FML\Controls\Quad; * Quad class for 'ManiaplanetSystem' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_ManiaplanetSystem extends Quad { - /* - * Constants - */ - const STYLE = 'ManiaplanetSystem'; - const SUBSTYLE_BgDialog = 'BgDialog'; - const SUBSTYLE_BgDialogAnchor = 'BgDialogAnchor'; - const SUBSTYLE_BgFloat = 'BgFloat'; - const SUBSTYLE_Events = 'Events'; - const SUBSTYLE_Medals = 'Medals'; - const SUBSTYLE_Statistics = 'Statistics'; +class Quad_ManiaplanetSystem extends Quad +{ + + /* + * Constants + */ + const STYLE = 'ManiaplanetSystem'; + const SUBSTYLE_BgDialog = 'BgDialog'; + const SUBSTYLE_BgDialogAnchor = 'BgDialogAnchor'; + const SUBSTYLE_BgFloat = 'BgFloat'; + const SUBSTYLE_Events = 'Events'; + const SUBSTYLE_Medals = 'Medals'; + const SUBSTYLE_Statistics = 'Statistics'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_MedalsBig.php b/libs/FML/Controls/Quads/Quad_MedalsBig.php index 1628ecbe..708a74ba 100644 --- a/libs/FML/Controls/Quads/Quad_MedalsBig.php +++ b/libs/FML/Controls/Quads/Quad_MedalsBig.php @@ -8,24 +8,27 @@ use FML\Controls\Quad; * Quad class for 'MedalsBig' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_MedalsBig extends Quad { - /* - * Constants - */ - const STYLE = 'MedalsBig'; - const SUBSTYLE_MedalBronze = 'MedalBronze'; - const SUBSTYLE_MedalGold = 'MedalGold'; - const SUBSTYLE_MedalGoldPerspective = 'MedalGoldPerspective'; - const SUBSTYLE_MedalNadeo = 'MedalNadeo'; - const SUBSTYLE_MedalNadeoPerspective = 'MedalNadeoPerspective'; - const SUBSTYLE_MedalSilver = 'MedalSilver'; - const SUBSTYLE_MedalSlot = 'MedalSlot'; +class Quad_MedalsBig extends Quad +{ + + /* + * Constants + */ + const STYLE = 'MedalsBig'; + const SUBSTYLE_MedalBronze = 'MedalBronze'; + const SUBSTYLE_MedalGold = 'MedalGold'; + const SUBSTYLE_MedalGoldPerspective = 'MedalGoldPerspective'; + const SUBSTYLE_MedalNadeo = 'MedalNadeo'; + const SUBSTYLE_MedalNadeoPerspective = 'MedalNadeoPerspective'; + const SUBSTYLE_MedalSilver = 'MedalSilver'; + const SUBSTYLE_MedalSlot = 'MedalSlot'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_TitleLogos.php b/libs/FML/Controls/Quads/Quad_TitleLogos.php index f97fb628..3c10dc8d 100644 --- a/libs/FML/Controls/Quads/Quad_TitleLogos.php +++ b/libs/FML/Controls/Quads/Quad_TitleLogos.php @@ -8,21 +8,24 @@ use FML\Controls\Quad; * Quad class for 'TitleLogos' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_TitleLogos extends Quad { - /* - * Constants - */ - const STYLE = 'TitleLogos'; - const SUBSTYLE_Author = 'Author'; - const SUBSTYLE_Collection = 'Collection'; - const SUBSTYLE_Icon = 'Icon'; - const SUBSTYLE_Title = 'Title'; +class Quad_TitleLogos extends Quad +{ + + /* + * Constants + */ + const STYLE = 'TitleLogos'; + const SUBSTYLE_Author = 'Author'; + const SUBSTYLE_Collection = 'Collection'; + const SUBSTYLE_Icon = 'Icon'; + const SUBSTYLE_Title = 'Title'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_UIConstructionBullet_Buttons.php b/libs/FML/Controls/Quads/Quad_UIConstructionBullet_Buttons.php index 88288389..18396137 100644 --- a/libs/FML/Controls/Quads/Quad_UIConstructionBullet_Buttons.php +++ b/libs/FML/Controls/Quads/Quad_UIConstructionBullet_Buttons.php @@ -8,40 +8,43 @@ use FML\Controls\Quad; * Quad class for 'UIConstructionBullet_Buttons' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_UIConstructionBullet_Buttons extends Quad { - /* - * Constants - */ - const STYLE = 'UIConstructionBullet_Buttons'; - const SUBSTYLE_AnimMode = 'AnimMode'; - const SUBSTYLE_BlocMode = 'BlocMode'; - const SUBSTYLE_BulletEditorMode = 'BulletEditorMode'; - const SUBSTYLE_Circle = 'Circle'; - const SUBSTYLE_Core = 'Core'; - const SUBSTYLE_CoreFolder = 'CoreFolder'; - const SUBSTYLE_DeltaMode = 'DeltaMode'; - const SUBSTYLE_Disc = 'Disc'; - const SUBSTYLE_ExplosionMode = 'ExplosionMode'; - const SUBSTYLE_NewBullet = 'NewBullet'; - const SUBSTYLE_NewRandomBullet = 'NewRandomBullet'; - const SUBSTYLE_Point = 'Point'; - const SUBSTYLE_Power = 'Power'; - const SUBSTYLE_PowerFolder = 'PowerFolder'; - const SUBSTYLE_PreviewMode = 'PreviewMode'; - const SUBSTYLE_RootMotionMode = 'RootMotionMode'; - const SUBSTYLE_SmokeDebris = 'SmokeDebris'; - const SUBSTYLE_SmokeDebrisFolder = 'SmokeDebrisFolder'; - const SUBSTYLE_SoundMode = 'SoundMode'; - const SUBSTYLE_SphereEmpty = 'SphereEmpty'; - const SUBSTYLE_SphereFull = 'SphereFull'; - const SUBSTYLE_Trail = 'Trail'; - const SUBSTYLE_TrailFolder = 'TrailFolder'; +class Quad_UIConstructionBullet_Buttons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'UIConstructionBullet_Buttons'; + const SUBSTYLE_AnimMode = 'AnimMode'; + const SUBSTYLE_BlocMode = 'BlocMode'; + const SUBSTYLE_BulletEditorMode = 'BulletEditorMode'; + const SUBSTYLE_Circle = 'Circle'; + const SUBSTYLE_Core = 'Core'; + const SUBSTYLE_CoreFolder = 'CoreFolder'; + const SUBSTYLE_DeltaMode = 'DeltaMode'; + const SUBSTYLE_Disc = 'Disc'; + const SUBSTYLE_ExplosionMode = 'ExplosionMode'; + const SUBSTYLE_NewBullet = 'NewBullet'; + const SUBSTYLE_NewRandomBullet = 'NewRandomBullet'; + const SUBSTYLE_Point = 'Point'; + const SUBSTYLE_Power = 'Power'; + const SUBSTYLE_PowerFolder = 'PowerFolder'; + const SUBSTYLE_PreviewMode = 'PreviewMode'; + const SUBSTYLE_RootMotionMode = 'RootMotionMode'; + const SUBSTYLE_SmokeDebris = 'SmokeDebris'; + const SUBSTYLE_SmokeDebrisFolder = 'SmokeDebrisFolder'; + const SUBSTYLE_SoundMode = 'SoundMode'; + const SUBSTYLE_SphereEmpty = 'SphereEmpty'; + const SUBSTYLE_SphereFull = 'SphereFull'; + const SUBSTYLE_Trail = 'Trail'; + const SUBSTYLE_TrailFolder = 'TrailFolder'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons.php b/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons.php index 55744b9a..a768467e 100644 --- a/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons.php +++ b/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons.php @@ -8,74 +8,77 @@ use FML\Controls\Quad; * Quad class for 'UIConstruction_Buttons' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_UIConstruction_Buttons extends Quad { - /* - * Constants - */ - const STYLE = 'UIConstruction_Buttons'; - const SUBSTYLE_ActionMaker = 'ActionMaker'; - const SUBSTYLE_Add = 'Add'; - const SUBSTYLE_AirMapping = 'AirMapping'; - const SUBSTYLE_Author = 'Author'; - const SUBSTYLE_AuthorTime = 'AuthorTime'; - const SUBSTYLE_BgEditors = 'BgEditors'; - const SUBSTYLE_BgIcons = 'BgIcons'; - const SUBSTYLE_BgMain = 'BgMain'; - const SUBSTYLE_BgTools = 'BgTools'; - const SUBSTYLE_BlockEditor = 'BlockEditor'; - const SUBSTYLE_Camera = 'Camera'; - const SUBSTYLE_Challenge = 'Challenge'; - const SUBSTYLE_CopyPaste = 'CopyPaste'; - const SUBSTYLE_DecalEditor = 'DecalEditor'; - const SUBSTYLE_Delete = 'Delete'; - const SUBSTYLE_Directory = 'Directory'; - const SUBSTYLE_Down = 'Down'; - const SUBSTYLE_Drive = 'Drive'; - const SUBSTYLE_Erase = 'Erase'; - const SUBSTYLE_FreeItems = 'FreeItems'; - const SUBSTYLE_GhostBlocks = 'GhostBlocks'; - const SUBSTYLE_Help = 'Help'; - const SUBSTYLE_Item = 'Item'; - const SUBSTYLE_Left = 'Left'; - const SUBSTYLE_MacroBlockEditor = 'MacroBlockEditor'; - const SUBSTYLE_MediaTracker = 'MediaTracker'; - const SUBSTYLE_ObjectEditor = 'ObjectEditor'; - const SUBSTYLE_OffZone = 'OffZone'; - const SUBSTYLE_Options = 'Options'; - const SUBSTYLE_Paint = 'Paint'; - const SUBSTYLE_Pick = 'Pick'; - const SUBSTYLE_Plugins = 'Plugins'; - const SUBSTYLE_Quit = 'Quit'; - const SUBSTYLE_Redo = 'Redo'; - const SUBSTYLE_Reload = 'Reload'; - const SUBSTYLE_Right = 'Right'; - const SUBSTYLE_Save = 'Save'; - const SUBSTYLE_SaveAs = 'SaveAs'; - const SUBSTYLE_ScriptEditor = 'ScriptEditor'; - const SUBSTYLE_SpotModelClearUnused = 'SpotModelClearUnused'; - const SUBSTYLE_SpotModelDuplicate = 'SpotModelDuplicate'; - const SUBSTYLE_SpotModelNew = 'SpotModelNew'; - const SUBSTYLE_SpotModelRename = 'SpotModelRename'; - const SUBSTYLE_Square = 'Square'; - const SUBSTYLE_Stats = 'Stats'; - const SUBSTYLE_Sub = 'Sub'; - const SUBSTYLE_TerrainEditor = 'TerrainEditor'; - const SUBSTYLE_TestSm = 'TestSm'; - const SUBSTYLE_Text = 'Text'; - const SUBSTYLE_Tools = 'Tools'; - const SUBSTYLE_Underground = 'Underground'; - const SUBSTYLE_Undo = 'Undo'; - const SUBSTYLE_Up = 'Up'; - const SUBSTYLE_Validate = 'Validate'; - const SUBSTYLE_Validate_Step1 = 'Validate_Step1'; - const SUBSTYLE_Validate_Step2 = 'Validate_Step2'; - const SUBSTYLE_Validate_Step3 = 'Validate_Step3'; +class Quad_UIConstruction_Buttons extends Quad +{ + + /* + * Constants + */ + const STYLE = 'UIConstruction_Buttons'; + const SUBSTYLE_ActionMaker = 'ActionMaker'; + const SUBSTYLE_Add = 'Add'; + const SUBSTYLE_AirMapping = 'AirMapping'; + const SUBSTYLE_Author = 'Author'; + const SUBSTYLE_AuthorTime = 'AuthorTime'; + const SUBSTYLE_BgEditors = 'BgEditors'; + const SUBSTYLE_BgIcons = 'BgIcons'; + const SUBSTYLE_BgMain = 'BgMain'; + const SUBSTYLE_BgTools = 'BgTools'; + const SUBSTYLE_BlockEditor = 'BlockEditor'; + const SUBSTYLE_Camera = 'Camera'; + const SUBSTYLE_Challenge = 'Challenge'; + const SUBSTYLE_CopyPaste = 'CopyPaste'; + const SUBSTYLE_DecalEditor = 'DecalEditor'; + const SUBSTYLE_Delete = 'Delete'; + const SUBSTYLE_Directory = 'Directory'; + const SUBSTYLE_Down = 'Down'; + const SUBSTYLE_Drive = 'Drive'; + const SUBSTYLE_Erase = 'Erase'; + const SUBSTYLE_FreeItems = 'FreeItems'; + const SUBSTYLE_GhostBlocks = 'GhostBlocks'; + const SUBSTYLE_Help = 'Help'; + const SUBSTYLE_Item = 'Item'; + const SUBSTYLE_Left = 'Left'; + const SUBSTYLE_MacroBlockEditor = 'MacroBlockEditor'; + const SUBSTYLE_MediaTracker = 'MediaTracker'; + const SUBSTYLE_ObjectEditor = 'ObjectEditor'; + const SUBSTYLE_OffZone = 'OffZone'; + const SUBSTYLE_Options = 'Options'; + const SUBSTYLE_Paint = 'Paint'; + const SUBSTYLE_Pick = 'Pick'; + const SUBSTYLE_Plugins = 'Plugins'; + const SUBSTYLE_Quit = 'Quit'; + const SUBSTYLE_Redo = 'Redo'; + const SUBSTYLE_Reload = 'Reload'; + const SUBSTYLE_Right = 'Right'; + const SUBSTYLE_Save = 'Save'; + const SUBSTYLE_SaveAs = 'SaveAs'; + const SUBSTYLE_ScriptEditor = 'ScriptEditor'; + const SUBSTYLE_SpotModelClearUnused = 'SpotModelClearUnused'; + const SUBSTYLE_SpotModelDuplicate = 'SpotModelDuplicate'; + const SUBSTYLE_SpotModelNew = 'SpotModelNew'; + const SUBSTYLE_SpotModelRename = 'SpotModelRename'; + const SUBSTYLE_Square = 'Square'; + const SUBSTYLE_Stats = 'Stats'; + const SUBSTYLE_Sub = 'Sub'; + const SUBSTYLE_TerrainEditor = 'TerrainEditor'; + const SUBSTYLE_TestSm = 'TestSm'; + const SUBSTYLE_Text = 'Text'; + const SUBSTYLE_Tools = 'Tools'; + const SUBSTYLE_Underground = 'Underground'; + const SUBSTYLE_Undo = 'Undo'; + const SUBSTYLE_Up = 'Up'; + const SUBSTYLE_Validate = 'Validate'; + const SUBSTYLE_Validate_Step1 = 'Validate_Step1'; + const SUBSTYLE_Validate_Step2 = 'Validate_Step2'; + const SUBSTYLE_Validate_Step3 = 'Validate_Step3'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons2.php b/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons2.php index f9249629..f638d4b4 100644 --- a/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons2.php +++ b/libs/FML/Controls/Quads/Quad_UIConstruction_Buttons2.php @@ -8,29 +8,32 @@ use FML\Controls\Quad; * Quad class for 'UIConstruction_Buttons2' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_UIConstruction_Buttons2 extends Quad { - /* - * Constants - */ - const STYLE = 'UIConstruction_Buttons2'; - const SUBSTYLE_AirMapping = 'AirMapping'; - const SUBSTYLE_BlockEditor = 'BlockEditor'; - const SUBSTYLE_Copy = 'Copy'; - const SUBSTYLE_Cut = 'Cut'; - const SUBSTYLE_GhostBlocks = 'GhostBlocks'; - const SUBSTYLE_KeysAdd = 'KeysAdd'; - const SUBSTYLE_KeysCopy = 'KeysCopy'; - const SUBSTYLE_KeysDelete = 'KeysDelete'; - const SUBSTYLE_KeysPaste = 'KeysPaste'; - const SUBSTYLE_New = 'New'; - const SUBSTYLE_Open = 'Open'; - const SUBSTYLE_Symmetry = 'Symmetry'; +class Quad_UIConstruction_Buttons2 extends Quad +{ + + /* + * Constants + */ + const STYLE = 'UIConstruction_Buttons2'; + const SUBSTYLE_AirMapping = 'AirMapping'; + const SUBSTYLE_BlockEditor = 'BlockEditor'; + const SUBSTYLE_Copy = 'Copy'; + const SUBSTYLE_Cut = 'Cut'; + const SUBSTYLE_GhostBlocks = 'GhostBlocks'; + const SUBSTYLE_KeysAdd = 'KeysAdd'; + const SUBSTYLE_KeysCopy = 'KeysCopy'; + const SUBSTYLE_KeysDelete = 'KeysDelete'; + const SUBSTYLE_KeysPaste = 'KeysPaste'; + const SUBSTYLE_New = 'New'; + const SUBSTYLE_Open = 'Open'; + const SUBSTYLE_Symmetry = 'Symmetry'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php b/libs/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php index 1852184e..3cc144fc 100644 --- a/libs/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php +++ b/libs/FML/Controls/Quads/Quad_UiSMSpectatorScoreBig.php @@ -8,38 +8,41 @@ use FML\Controls\Quad; * Quad class for 'UiSMSpectatorScoreBig' styles * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Quad_UiSMSpectatorScoreBig extends Quad { - /* - * Constants - */ - const STYLE = 'UiSMSpectatorScoreBig'; - CONST SUBSTYLE_BotLeft = 'BotLeft'; - CONST SUBSTYLE_BotLeftGlass = 'BotLeftGlass'; - CONST SUBSTYLE_BotRight = 'BotRight'; - CONST SUBSTYLE_BotRightGlass = 'BotRightGlass'; - CONST SUBSTYLE_CenterShield = 'CenterShield'; - CONST SUBSTYLE_CenterShieldSmall = 'CenterShieldSmall'; - CONST SUBSTYLE_HandleLeft = 'HandleLeft'; - CONST SUBSTYLE_HandleRight = 'HandleRight'; - CONST SUBSTYLE_PlayerGlass = 'PlayerGlass'; - CONST SUBSTYLE_PlayerIconBg = 'PlayerIconBg'; - CONST SUBSTYLE_PlayerJunction = 'PlayerJunction'; - CONST SUBSTYLE_PlayerSlot = 'PlayerSlot'; - CONST SUBSTYLE_PlayerSlotCenter = 'PlayerSlotCenter'; - CONST SUBSTYLE_PlayerSlotRev = 'PlayerSlotRev'; - CONST SUBSTYLE_PlayerSlotSmall = 'PlayerSlotSmall'; - CONST SUBSTYLE_PlayerSlotSmallRev = 'PlayerSlotSmallRev'; - CONST SUBSTYLE_TableBgHoriz = 'TableBgHoriz'; - CONST SUBSTYLE_TableBgVert = 'TableBgVert'; - CONST SUBSTYLE_Top = 'Top'; - CONST SUBSTYLE_UIRange1Bg = 'UIRange1Bg'; - CONST SUBSTYLE_UIRange2Bg = 'UIRange2Bg'; +class Quad_UiSMSpectatorScoreBig extends Quad +{ + + /* + * Constants + */ + const STYLE = 'UiSMSpectatorScoreBig'; + CONST SUBSTYLE_BotLeft = 'BotLeft'; + CONST SUBSTYLE_BotLeftGlass = 'BotLeftGlass'; + CONST SUBSTYLE_BotRight = 'BotRight'; + CONST SUBSTYLE_BotRightGlass = 'BotRightGlass'; + CONST SUBSTYLE_CenterShield = 'CenterShield'; + CONST SUBSTYLE_CenterShieldSmall = 'CenterShieldSmall'; + CONST SUBSTYLE_HandleLeft = 'HandleLeft'; + CONST SUBSTYLE_HandleRight = 'HandleRight'; + CONST SUBSTYLE_PlayerGlass = 'PlayerGlass'; + CONST SUBSTYLE_PlayerIconBg = 'PlayerIconBg'; + CONST SUBSTYLE_PlayerJunction = 'PlayerJunction'; + CONST SUBSTYLE_PlayerSlot = 'PlayerSlot'; + CONST SUBSTYLE_PlayerSlotCenter = 'PlayerSlotCenter'; + CONST SUBSTYLE_PlayerSlotRev = 'PlayerSlotRev'; + CONST SUBSTYLE_PlayerSlotSmall = 'PlayerSlotSmall'; + CONST SUBSTYLE_PlayerSlotSmallRev = 'PlayerSlotSmallRev'; + CONST SUBSTYLE_TableBgHoriz = 'TableBgHoriz'; + CONST SUBSTYLE_TableBgVert = 'TableBgVert'; + CONST SUBSTYLE_Top = 'Top'; + CONST SUBSTYLE_UIRange1Bg = 'UIRange1Bg'; + CONST SUBSTYLE_UIRange2Bg = 'UIRange2Bg'; + + /** + * @var string $style Style + */ + protected $style = self::STYLE; - /* - * Protected properties - */ - protected $style = self::STYLE; } diff --git a/libs/FML/Controls/TextEdit.php b/libs/FML/Controls/TextEdit.php new file mode 100644 index 00000000..e1241e05 --- /dev/null +++ b/libs/FML/Controls/TextEdit.php @@ -0,0 +1,452 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class TextEdit extends Control implements MultiLineable, Scriptable, Styleable, TextFormatable +{ + + /* + * Constants + */ + const FORMAT_Default = "Default"; + const FORMAT_Script = "Script"; + const FORMAT_Password = "Password"; + const FORMAT_NewPassword = "NewPassword"; + + /** + * @var string $default Default value + */ + protected $default = null; + + /** + * @var bool $autoNewLine Auto new line + */ + protected $autoNewLine = null; + + /** + * @var float $lineSpacing Line spacing + */ + protected $lineSpacing = -1.; + + /** + * @var int $maxLines Maximum number of lines + */ + protected $maxLines = -1; + + /** + * @var bool $showLineNumbers Show lines numbers + */ + protected $showLineNumbers = null; + + /** + * @var string $textFormat Text format + */ + protected $textFormat = null; + + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; + + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; + + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; + + /** + * @var string $style Style + */ + protected $style = null; + + /** + * @var string $textColor Text color + */ + protected $textColor = null; + + /** + * @var int $textSize Text size + */ + protected $textSize = null; + + /** + * @var string $textFont Text font + */ + protected $textFont = null; + + /** + * @var string $areaColor Area color + */ + protected $areaColor = null; + + /** + * @var string $focusAreaColor Focus area color + */ + protected $focusAreaColor = null; + + /** + * Get the default value + * + * @api + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * Set the default value + * + * @api + * @param string $default Default value + * @return static + */ + public function setDefault($default) + { + $this->default = $default; + return $this; + } + + /** + * @see MultiLineable::getAutoNewLine() + */ + public function getAutoNewLine() + { + return $this->autoNewLine; + } + + /** + * @see MultiLineable::setAutoNewLine() + */ + public function setAutoNewLine($autoNewLine) + { + $this->autoNewLine = (bool)$autoNewLine; + return $this; + } + + /** + * @see MultiLineable::getLineSpacing() + */ + public function getLineSpacing() + { + return $this->lineSpacing; + } + + /** + * @see MultiLineable::setLineSpacing() + */ + public function setLineSpacing($lineSpacing) + { + $this->lineSpacing = (float)$lineSpacing; + return $this; + } + + /** + * @see MultiLineable::getMaxLines() + */ + public function getMaxLines() + { + return $this->maxLines; + } + + /** + * @see MultiLineable::setMaxLines() + */ + public function setMaxLines($maxLines) + { + $this->maxLines = (int)$maxLines; + return $this; + } + + /** + * Get showing of line numbers + * + * @api + * @return bool + */ + public function getShowLineNumbers() + { + return $this->showLineNumbers; + } + + /** + * Set showing of line numbers + * + * @api + * @param bool $showLineNumbers Show line numbers + * @return static + */ + public function setShowLineNumbers($showLineNumbers) + { + $this->showLineNumbers = (bool)$showLineNumbers; + return $this; + } + + /** + * Get text format + * + * @api + * @return string + */ + public function getTextFormat() + { + return $this->textFormat; + } + + /** + * Set text format + * + * @api + * @param string $textFormat Text format + * @return static + */ + public function setTextFormat($textFormat) + { + $this->textFormat = (string)$textFormat; + return $this; + } + + /** + * @see Scriptable::getScriptEvents() + */ + public function getScriptEvents() + { + return $this->scriptEvents; + } + + /** + * @see Scriptable::setScriptEvents() + */ + public function setScriptEvents($scriptEvents) + { + $this->scriptEvents = (bool)$scriptEvents; + return $this; + } + + /** + * @see Scriptable::getScriptAction() + */ + public function getScriptAction() + { + return $this->scriptAction; + } + + /** + * @see Scriptable::setScriptAction() + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null) + { + $this->scriptAction = (string)$scriptAction; + $this->setScriptActionParameters($scriptActionParameters); + return $this; + } + + /** + * @see Scriptable::getScriptActionParameters() + */ + public function getScriptActionParameters() + { + return $this->scriptActionParameters; + } + + /** + * @see Scriptable::setScriptActionParameters() + */ + public function setScriptActionParameters(array $scriptActionParameters = null) + { + $this->scriptActionParameters = $scriptActionParameters; + return $this; + } + + /** + * @see Styleable::getStyle() + */ + public function getStyle() + { + return $this->style; + } + + /** + * @see Styleable::setStyle() + */ + public function setStyle($style) + { + $this->style = (string)$style; + return $this; + } + + /** + * @see TextFormatable::getTextColor() + */ + public function getTextColor() + { + return $this->textColor; + } + + /** + * @see TextFormatable::setTextColor() + */ + public function setTextColor($textColor) + { + $this->textColor = (string)$textColor; + return $this; + } + + /** + * @see TextFormatable::getTextSize() + */ + public function getTextSize() + { + return $this->textSize; + } + + /** + * @see TextFormatable::setTextSize() + */ + public function setTextSize($textSize) + { + $this->textSize = (int)$textSize; + return $this; + } + + /** + * @see TextFormatable::getTextFont() + */ + public function getTextFont() + { + return $this->textFont; + } + + /** + * @see TextFormatable::setTextFont() + */ + public function setTextFont($textFont) + { + $this->textFont = (string)$textFont; + return $this; + } + + /** + * @see TextFormatable::getAreaColor() + */ + public function getAreaColor() + { + return $this->areaColor; + } + + /** + * @see TextFormatable::setAreaColor() + */ + public function setAreaColor($areaColor) + { + $this->areaColor = (string)$areaColor; + return $this; + } + + /** + * @see TextFormatable::getAreaFocusColor() + */ + public function getAreaFocusColor() + { + return $this->focusAreaColor; + } + + /** + * @see TextFormatable::setAreaFocusColor() + */ + public function setAreaFocusColor($areaFocusColor) + { + $this->focusAreaColor = (string)$areaFocusColor; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "textedit"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlTextEdit"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->default !== null) { + $domElement->setAttribute("default", $this->default); + } + if ($this->autoNewLine) { + $domElement->setAttribute("autonewline", 1); + } + if ($this->lineSpacing > 0) { + $domElement->setAttribute("linespacing", $this->lineSpacing); + } + if ($this->maxLines > 0) { + $domElement->setAttribute("maxline", $this->maxLines); + } + if ($this->showLineNumbers) { + $domElement->setAttribute("showlinenumbers", 1); + } + if ($this->textFormat) { + $domElement->setAttribute("textformat", $this->textFormat); + } + if ($this->scriptEvents) { + $domElement->setAttribute("scriptevents", 1); + } + if ($this->scriptAction) { + $scriptAction = array($this->scriptAction); + if ($this->scriptActionParameters) { + $scriptAction = array_merge($scriptAction, $this->scriptActionParameters); + } + $domElement->setAttribute("scriptaction", implode("'", $scriptAction)); + } + if ($this->style) { + $domElement->setAttribute("style", $this->style); + } + if ($this->textColor) { + $domElement->setAttribute("textcolor", $this->textColor); + } + if ($this->textSize) { + $domElement->setAttribute("textsize", $this->textSize); + } + if ($this->textFont) { + $domElement->setAttribute("textfont", $this->textFont); + } + if ($this->areaColor) { + $domElement->setAttribute("focusareacolor1", $this->areaColor); + } + if ($this->focusAreaColor) { + $domElement->setAttribute("focusareacolor2", $this->focusAreaColor); + } + return $domElement; + } + +} diff --git a/libs/FML/Controls/Video.php b/libs/FML/Controls/Video.php index 94f94bdd..614a9b92 100644 --- a/libs/FML/Controls/Video.php +++ b/libs/FML/Controls/Video.php @@ -10,108 +10,262 @@ use FML\Types\Scriptable; * (CMlMediaPlayer) * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Video extends Control implements Playable, Scriptable { - /* - * Protected properties - */ - protected $tagName = 'video'; - protected $data = null; - protected $dataId = null; - protected $play = null; - protected $looping = true; - protected $music = null; - protected $volume = 1.; - protected $scriptEvents = null; +class Video extends Control implements Playable, Scriptable +{ - /** - * @see \FML\Controls\Control::getManiaScriptClass() - */ - public function getManiaScriptClass() { - return 'CMlMediaPlayer'; - } + /** + * @var string $data Data url + */ + protected $data = null; - /** - * @see \FML\Types\Playable::setData() - */ - public function setData($data) { - $this->data = (string)$data; - return $this; - } + /** + * @var string $dataId Data id + */ + protected $dataId = null; - /** - * @see \FML\Types\Playable::setDataId() - */ - public function setDataId($dataId) { - $this->dataId = (string)$dataId; - return $this; - } + /** + * @var bool $play Play automaticcaly + */ + protected $play = null; - /** - * @see \FML\Types\Playable::setPlay() - */ - public function setPlay($play) { - $this->play = ($play ? 1 : 0); - return $this; - } + /** + * @var bool $looping Looping + */ + protected $looping = true; - /** - * @see \FML\Types\Playable::setLooping() - */ - public function setLooping($looping) { - $this->looping = ($looping ? 1 : 0); - return $this; - } + /** + * @var bool $music Music type + */ + protected $music = null; - /** - * @see \FML\Types\Playable::setMusic() - */ - public function setMusic($music) { - $this->music = ($music ? 1 : 0); - return $this; - } + /** + * @var float $volume Volume + */ + protected $volume = 1.; - /** - * @see \FML\Types\Playable::setVolume() - */ - public function setVolume($volume) { - $this->volume = (float)$volume; - return $this; - } + /** + * @var bool $scriptEvents Script events usage + */ + protected $scriptEvents = null; - /** - * @see \FML\Types\Scriptable::setScriptEvents() - */ - public function setScriptEvents($scriptEvents) { - $this->scriptEvents = ($scriptEvents ? 1 : 0); - return $this; - } + /** + * @var string $scriptAction Script action + */ + protected $scriptAction = null; + + /** + * @var string[] $scriptActionParameters Script action parameters + */ + protected $scriptActionParameters = null; + + /** + * @see Playable::getData() + */ + public function getData() + { + return $this->data; + } + + /** + * @see Playable::setData() + */ + public function setData($data) + { + $this->data = (string)$data; + return $this; + } + + /** + * @see Playable::getDataId() + */ + public function getDataId() + { + return $this->dataId; + } + + /** + * @see Playable::setDataId() + */ + public function setDataId($dataId) + { + $this->dataId = (string)$dataId; + return $this; + } + + /** + * @see Playable::getPlay() + */ + public function getPlay() + { + return $this->play; + } + + /** + * @see Playable::setPlay() + */ + public function setPlay($play) + { + $this->play = (bool)$play; + return $this; + } + + /** + * @see Playable::getLooping() + */ + public function getLooping() + { + return $this->looping; + } + + /** + * @see Playable::setLooping() + */ + public function setLooping($looping) + { + $this->looping = (bool)$looping; + return $this; + } + + /** + * @see Playable::getMusic() + */ + public function getMusic() + { + return $this->music; + } + + /** + * @see Playable::setMusic() + */ + public function setMusic($music) + { + $this->music = (bool)$music; + return $this; + } + + /** + * @see Playable::getVolume() + */ + public function getVolume() + { + return $this->volume; + } + + /** + * @see Playable::setVolume() + */ + public function setVolume($volume) + { + $this->volume = (float)$volume; + return $this; + } + + /** + * @see Scriptable::getScriptEvents() + */ + public function getScriptEvents() + { + return $this->scriptEvents; + } + + /** + * @see Scriptable::setScriptEvents() + */ + public function setScriptEvents($scriptEvents) + { + $this->scriptEvents = (bool)$scriptEvents; + return $this; + } + + /** + * @see Scriptable::getScriptAction() + */ + public function getScriptAction() + { + return $this->scriptAction; + } + + /** + * @see Scriptable::setScriptAction() + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null) + { + $this->scriptAction = (string)$scriptAction; + $this->setScriptActionParameters($scriptActionParameters); + return $this; + } + + /** + * @see Scriptable::getScriptActionParameters() + */ + public function getScriptActionParameters() + { + return $this->scriptActionParameters; + } + + /** + * @see Scriptable::setScriptActionParameters() + */ + public function setScriptActionParameters(array $scriptActionParameters = null) + { + $this->scriptActionParameters = $scriptActionParameters; + return $this; + } + + /** + * @see Control::getTagName() + */ + public function getTagName() + { + return "video"; + } + + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() + { + return "CMlMediaPlayer"; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = parent::render($domDocument); + if ($this->data) { + $domElement->setAttribute("data", $this->data); + } + if ($this->dataId) { + $domElement->setAttribute("dataid", $this->dataId); + } + if ($this->play) { + $domElement->setAttribute("play", 1); + } + if (!$this->looping) { + $domElement->setAttribute("looping", 0); + } + if ($this->music) { + $domElement->setAttribute("music", 1); + } + if ($this->volume != 1.) { + $domElement->setAttribute("volume", $this->volume); + } + if ($this->scriptEvents) { + $domElement->setAttribute("scriptevents", 1); + } + if ($this->scriptAction) { + $scriptAction = array($this->scriptAction); + if ($this->scriptActionParameters) { + $scriptAction = array_merge($scriptAction, $this->scriptActionParameters); + } + $domElement->setAttribute("scriptaction", implode("'", $scriptAction)); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->data) { - $xmlElement->setAttribute('data', $this->data); - } - if ($this->play) { - $xmlElement->setAttribute('play', $this->play); - } - if (!$this->looping) { - $xmlElement->setAttribute('looping', $this->looping); - } - if ($this->music) { - $xmlElement->setAttribute('music', $this->music); - } - if ($this->volume != 1.) { - $xmlElement->setAttribute('volume', $this->volume); - } - if ($this->scriptEvents) { - $xmlElement->setAttribute('scriptevents', $this->scriptEvents); - } - return $xmlElement; - } } diff --git a/libs/FML/CustomUI.php b/libs/FML/CustomUI.php index a4137684..831b8678 100644 --- a/libs/FML/CustomUI.php +++ b/libs/FML/CustomUI.php @@ -6,187 +6,323 @@ namespace FML; * Class representing a Custom_UI * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CustomUI { - /* - * Protected properties - */ - protected $encoding = 'utf-8'; - protected $tagName = 'custom_ui'; - protected $noticeVisible = null; - protected $challengeInfoVisible = null; - protected $netInfosVisible = null; - protected $chatVisible = null; - protected $checkpointListVisible = null; - protected $roundScoresVisible = null; - protected $scoretableVisible = null; - protected $globalVisible = null; +class CustomUI +{ - /** - * Create a new CustomUI object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var bool $globalVisible If the UI should be shown at all + */ + protected $globalVisible = null; - /** - * Set XML encoding - * - * @param string $encoding XML encoding - * @return static - */ - public function setXMLEncoding($encoding) { - $this->encoding = (string)$encoding; - return $this; - } + /** + * @var bool $challengeInfoVisible If the challenge info should be shown + */ + protected $challengeInfoVisible = null; - /** - * Set showing of notices - * - * @param bool $visible Whether notices should be shown - * @return static - */ - public function setNoticeVisible($visible) { - $this->noticeVisible = $visible; - return $this; - } + /** + * @var bool $chatVisible If the chat should be shown + */ + protected $chatVisible = null; - /** - * Set showing of the challenge info - * - * @param bool $visible Whether the challenge info should be shown - * @return static - */ - public function setChallengeInfoVisible($visible) { - $this->challengeInfoVisible = $visible; - return $this; - } + /** + * @var bool $checkpointListVisible If the checkpoint list should be shown + */ + protected $checkpointListVisible = null; - /** - * Set showing of the net infos - * - * @param bool $visible Whether the net infos should be shown - * @return static - */ - public function setNetInfosVisible($visible) { - $this->netInfosVisible = $visible; - return $this; - } + /** + * @var bool $netInfosVisible If the net infos should be shown + */ + protected $netInfosVisible = null; - /** - * Set showing of the chat - * - * @param bool $visible Whether the chat should be shown - * @return static - */ - public function setChatVisible($visible) { - $this->chatVisible = $visible; - return $this; - } + /** + * @var bool $noticeVisible If notices should be shown + */ + protected $noticeVisible = null; - /** - * Set showing of the checkpoint list - * - * @param bool $visible Whether the checkpoint should be shown - * @return static - */ - public function setCheckpointListVisible($visible) { - $this->checkpointListVisible = $visible; - return $this; - } + /** + * @var bool $roundScoresVisible If round scores should be shown + */ + protected $roundScoresVisible = null; - /** - * Set showing of round scores - * - * @param bool $visible Whether the round scores should be shown - * @return static - */ - public function setRoundScoresVisible($visible) { - $this->roundScoresVisible = $visible; - return $this; - } + /** + * @var bool $scoretableVisible If the score table should be shown + */ + protected $scoretableVisible = null; - /** - * Set showing of the scoretable - * - * @param bool $visible Whether the scoretable should be shown - * @return static - */ - public function setScoretableVisible($visible) { - $this->scoretableVisible = $visible; - return $this; - } + /** + * Create a new CustomUI + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Set global showing - * - * @param bool $visible Whether the UI should be disabled completely - * @return static - */ - public function setGlobalVisible($visible) { - $this->globalVisible = $visible; - return $this; - } + /** + * Get global visibility + * + * @api + * @return bool + */ + public function getGlobalVisible() + { + return $this->globalVisible; + } - /** - * Render the XML document - * - * @param \DOMDocument $domDocument (optional) DOMDocument for which the XML element should be rendered - * @return \DOMDocument - */ - public function render($domDocument = null) { - $isChild = (bool)$domDocument; - if (!$isChild) { - $domDocument = new \DOMDocument('1.0', $this->encoding); - $domDocument->xmlStandalone = true; - } - $xmlElement = $domDocument->createElement($this->tagName); - if (!$isChild) { - $domDocument->appendChild($xmlElement); - } - $settings = $this->getSettings(); - foreach ($settings as $setting => $value) { - if ($value === null) { - continue; - } - $xmlSubElement = $domDocument->createElement($setting); - $xmlSubElement->setAttribute('visible', ($value ? 1 : 0)); - $xmlElement->appendChild($xmlSubElement); - } - if ($isChild) { - return $xmlElement; - } - return $domDocument; - } + /** + * Set global visibility + * + * @api + * @param bool $visible If the UI should be shown at all + * @return static + */ + public function setGlobalVisible($visible) + { + $this->globalVisible = $visible; + return $this; + } - /** - * Get string representation - * - * @return string - */ - public function __toString() { - return $this->render()->saveXML(); - } + /** + * Get showing of the challenge info + * + * @api + * @return bool + */ + public function getChallengeInfoVisible() + { + return $this->challengeInfoVisible; + } + + /** + * Set showing of the challenge info + * + * @api + * @param bool $visible If the challenge info should be shown + * @return static + */ + public function setChallengeInfoVisible($visible) + { + $this->challengeInfoVisible = $visible; + return $this; + } + + /** + * Get showing of the chat + * + * @api + * @return bool + */ + public function getChatVisible() + { + return $this->chatVisible; + } + + /** + * Set showing of the chat + * + * @api + * @param bool $visible If the chat should be shown + * @return static + */ + public function setChatVisible($visible) + { + $this->chatVisible = $visible; + return $this; + } + + /** + * Get showing of the checkpoint list + * + * @api + * @return bool + */ + public function getCheckpointListVisible() + { + return $this->checkpointListVisible; + } + + /** + * Set showing of the checkpoint list + * + * @api + * @param bool $visible If the checkpoint list should be shown + * @return static + */ + public function setCheckpointListVisible($visible) + { + $this->checkpointListVisible = $visible; + return $this; + } + + /** + * Get showing of the net infos + * + * @api + * @return bool + */ + public function getNetInfosVisible() + { + return $this->netInfosVisible; + } + + /** + * Set showing of the net infos + * + * @api + * @param bool $visible If the net infos should be shown + * @return static + */ + public function setNetInfosVisible($visible) + { + $this->netInfosVisible = $visible; + return $this; + } + + /** + * Get showing of notices + * + * @api + * @return bool + */ + public function getNoticeVisible() + { + return $this->noticeVisible; + } + + /** + * Set showing of notices + * + * @api + * @param bool $visible If notices should be shown + * @return static + */ + public function setNoticeVisible($visible) + { + $this->noticeVisible = $visible; + return $this; + } + + /** + * Get showing of round scores + * + * @api + * @return bool + */ + public function getRoundScoresVisible() + { + return $this->roundScoresVisible; + } + + /** + * Set showing of round scores + * + * @api + * @param bool $visible If round scores should be shown + * @return static + */ + public function setRoundScoresVisible($visible) + { + $this->roundScoresVisible = $visible; + return $this; + } + + /** + * Get showing of the score table + * + * @api + * @return bool + */ + public function getScoretableVisible() + { + return $this->scoretableVisible; + } + + /** + * Set showing of the score table + * + * @api + * @param bool $visible If the score table should be shown + * @return static + */ + public function setScoretableVisible($visible) + { + $this->scoretableVisible = $visible; + return $this; + } + + /** + * Render the CustomUI standalone + * + * @return \DOMDocument + */ + public function renderStandalone() + { + $domDocument = new \DOMDocument("1.0", "utf-8"); + $domDocument->xmlStandalone = true; + + $domElement = $this->render($domDocument); + $domDocument->appendChild($domElement); + + return $domDocument; + } + + /** + * Render the CustomUI + * + * @param \DOMDocument $domDocument DOMDocument for which the CustomUI should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("custom_ui"); + + $settings = $this->getSettings(); + foreach ($settings as $setting => $value) { + if ($value === null) { + continue; + } + + $settingDomElement = $domDocument->createElement($setting); + $settingDomElement->setAttribute("visible", ($value ? 1 : 0)); + $domElement->appendChild($settingDomElement); + } + + return $domElement; + } + + /** + * Get string representation + * + * @return string + */ + public function __toString() + { + return $this->renderStandalone() + ->saveXML(); + } + + /** + * Get associative array of all CustomUI settings + * + * @return array + */ + protected function getSettings() + { + return array( + "global" => $this->globalVisible, + "challenge_info" => $this->challengeInfoVisible, + "chat" => $this->chatVisible, + "checkpoint_list" => $this->checkpointListVisible, + "net_infos" => $this->netInfosVisible, + "notice" => $this->noticeVisible, + "round_scores" => $this->roundScoresVisible, + "scoretable" => $this->scoretableVisible + ); + } - /** - * Get associative array of all CustomUI settings - * - * @return array - */ - protected function getSettings() { - $settings = array(); - $settings['challenge_info'] = $this->challengeInfoVisible; - $settings['chat'] = $this->chatVisible; - $settings['checkpoint_list'] = $this->checkpointListVisible; - $settings['global'] = $this->globalVisible; - $settings['net_infos'] = $this->netInfosVisible; - $settings['notice'] = $this->noticeVisible; - $settings['round_scores'] = $this->roundScoresVisible; - $settings['scoretable'] = $this->scoretableVisible; - return $settings; - } } diff --git a/libs/FML/Elements/Dico.php b/libs/FML/Elements/Dico.php index f948d2ba..a7f809c5 100644 --- a/libs/FML/Elements/Dico.php +++ b/libs/FML/Elements/Dico.php @@ -6,261 +6,276 @@ namespace FML\Elements; * Dictionary Element * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Dico { - /** - * Czech language - * - * @var string - */ - const LANG_CZECH = 'cz'; +class Dico +{ - /** - * Danish language - * - * @var string - */ - const LANG_DANISH = 'da'; + /** + * Czech language + * + * @var string + */ + const LANG_CZECH = 'cz'; - /** - * German language - * - * @var string - */ - const LANG_GERMAN = 'de'; + /** + * Danish language + * + * @var string + */ + const LANG_DANISH = 'da'; - /** - * English language - * - * @var string - */ - const LANG_ENGLISH = 'en'; + /** + * German language + * + * @var string + */ + const LANG_GERMAN = 'de'; - /** - * Spanish language - * - * @var string - */ - const LANG_SPANISH = 'es'; + /** + * English language + * + * @var string + */ + const LANG_ENGLISH = 'en'; - /** - * French language - * - * @var string - */ - const LANG_FRENCH = 'fr'; + /** + * Spanish language + * + * @var string + */ + const LANG_SPANISH = 'es'; - /** - * Hungarian language - * - * @var string - */ - const LANG_HUNGARIAN = 'hu'; + /** + * French language + * + * @var string + */ + const LANG_FRENCH = 'fr'; - /** - * Italian language - * - * @var string - */ - const LANG_ITALIAN = 'it'; + /** + * Hungarian language + * + * @var string + */ + const LANG_HUNGARIAN = 'hu'; - /** - * Japanese language - * - * @var string - */ - const LANG_JAPANESE = 'jp'; + /** + * Italian language + * + * @var string + */ + const LANG_ITALIAN = 'it'; - /** - * Korean language - * - * @var string - */ - const LANG_KOREAN = 'kr'; + /** + * Japanese language + * + * @var string + */ + const LANG_JAPANESE = 'jp'; - /** - * Norwegian language - * - * @var string - */ - const LANG_NORWEGIAN = 'nb'; + /** + * Korean language + * + * @var string + */ + const LANG_KOREAN = 'kr'; - /** - * Dutch language - * - * @var string - */ - const LANG_DUTCH = 'nl'; + /** + * Norwegian language + * + * @var string + */ + const LANG_NORWEGIAN = 'nb'; - /** - * Polish language - * - * @var string - */ - const LANG_POLISH = 'pl'; + /** + * Dutch language + * + * @var string + */ + const LANG_DUTCH = 'nl'; - /** - * Portuguese language - * - * @var string - */ - const LANG_PORTUGUESE = 'pt'; + /** + * Polish language + * + * @var string + */ + const LANG_POLISH = 'pl'; - /** - * Brazilian Portuguese language - * - * @var string - */ - const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR'; + /** + * Portuguese language + * + * @var string + */ + const LANG_PORTUGUESE = 'pt'; - /** - * Romanian language - * - * @var string - */ - const LANG_ROMANIAN = 'ro'; + /** + * Brazilian Portuguese language + * + * @var string + */ + const LANG_BRAZILIAN_PORTUGUESE = 'pt_BR'; - /** - * Russian language - * - * @var string - */ - const LANG_RUSSIAN = 'ru'; + /** + * Romanian language + * + * @var string + */ + const LANG_ROMANIAN = 'ro'; - /** - * Slovak language - * - * @var string - */ - const LANG_SLOVAK = 'sk'; + /** + * Russian language + * + * @var string + */ + const LANG_RUSSIAN = 'ru'; - /** - * Turkish language - * - * @var string - */ - const LANG_TURKISH = 'tr'; + /** + * Slovak language + * + * @var string + */ + const LANG_SLOVAK = 'sk'; - /** - * Chinese language - * - * @var string - */ - const LANG_CHINESE = 'zh'; + /** + * Turkish language + * + * @var string + */ + const LANG_TURKISH = 'tr'; - /* - * Protected properties - */ - protected $tagName = 'dico'; - protected $entries = array(); + /** + * Chinese language + * + * @var string + */ + const LANG_CHINESE = 'zh'; - /** - * Create a new Dictionary object - * - * @return static - */ - public static function create() { - return new static(); - } + /* + * Protected properties + */ + protected $entries = array(); - /** - * Set the translatable entry for the specific language - * - * @param string $language Language id - * @param string $entryId Entry id - * @param string $entryValue Translated entry value - * @return static - */ - public function setEntry($language, $entryId, $entryValue) { - $language = (string)$language; - $entryId = (string)$entryId; - $entryValue = (string)$entryValue; - if (!isset($this->entries[$language]) && $entryValue) { - $this->entries[$language] = array(); - } - if ($entryValue) { - $this->entries[$language][$entryId] = $entryValue; - } else { - if (isset($this->entries[$language][$entryId])) { - unset($this->entries[$language][$entryId]); - } - } - return $this; - } + /** + * Create a new Dico + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Remove entries of the given id - * - * @param string $entryId Entry id that should be removed - * @param string $language (optional) Only remove entries of the given language - * @return static - */ - public function removeEntry($entryId, $language = null) { - $entryId = (string)$entryId; - if ($language) { - $language = (string)$language; - if (isset($this->entries[$language])) { - unset($this->entries[$language][$entryId]); - } - } else { - foreach ($this->entries as $language => $entries) { - if (isset($entries[$entryId])) { - unset($entries[$language][$entryId]); - } - } - } - return $this; - } + /** + * Get the translatable entry + * + * @api + * @param string $language Language id + * @param string $entryId Entry id + * @return string + */ + public function getEntry($language, $entryId) + { + if (isset($this->entries[$language]) && isset($this->entries[$language][$entryId])) { + return $this->entries[$language][$entryId]; + } + return null; + } - /** - * Remove entries of the given language - * - * @param string $language Language which entries should be removed - * @param string $entryId (optional) Only remove the given entry id - * @return static - */ - public function removeLanguage($language, $entryId = null) { - $language = (string)$language; - if (isset($this->entries[$language])) { - if ($entryId) { - $entryId = (string)$entryId; - unset($this->entries[$language][$entryId]); - } else { - unset($this->entries[$language]); - } - } - return $this; - } + /** + * Set the translatable entry for the specific language + * + * @api + * @param string $language Language id + * @param string $entryId Entry id + * @param string $entryValue Translated entry value + * @return static + */ + public function setEntry($language, $entryId, $entryValue) + { + $language = (string)$language; + $entryId = (string)$entryId; + $entryValue = (string)$entryValue; + if (!isset($this->entries[$language]) && $entryValue) { + $this->entries[$language] = array(); + } + if ($entryValue) { + $this->entries[$language][$entryId] = $entryValue; + } else { + if (isset($this->entries[$language][$entryId])) { + unset($this->entries[$language][$entryId]); + } + } + return $this; + } - /** - * Remove all entries from the Dictionary - * - * @return static - */ - public function removeEntries() { - $this->entries = array(); - return $this; - } + /** + * Remove entries of the given id + * + * @api + * @param string $entryId Entry id that should be removed + * @return static + */ + public function removeEntry($entryId) + { + $entryId = (string)$entryId; + foreach ($this->entries as $language => $entries) { + if (isset($this->entries[$language][$entryId])) { + unset($this->entries[$language][$entryId]); + } + } + return $this; + } + + /** + * Remove entries of the given language + * + * @api + * @param string $language Language which entries should be removed + * @return static + */ + public function removeLanguage($language) + { + $language = (string)$language; + if (isset($this->entries[$language])) { + unset($this->entries[$language]); + } + return $this; + } + + /** + * Remove all entries + * + * @api + * @return static + */ + public function removeAllEntries() + { + $this->entries = array(); + return $this; + } + + /** + * Render the Dico + * + * @param \DOMDocument $domDocument DOMDocument for which the Dico should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("dico"); + foreach ($this->entries as $language => $entries) { + $languageElement = $domDocument->createElement("language"); + $languageElement->setAttribute("id", $language); + foreach ($entries as $entryId => $entryValue) { + $entryElement = $domDocument->createElement($entryId, $entryValue); + $languageElement->appendChild($entryElement); + } + $domElement->appendChild($languageElement); + } + return $domElement; + } - /** - * Render the Dico XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the Dico XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - foreach ($this->entries as $language => $entries) { - $languageElement = $domDocument->createElement('language'); - $languageElement->setAttribute('id', $language); - foreach ($entries as $entryId => $entryValue) { - $entryElement = $domDocument->createElement($entryId, $entryValue); - $languageElement->appendChild($entryElement); - } - $xmlElement->appendChild($languageElement); - } - return $xmlElement; - } } diff --git a/libs/FML/Elements/Format.php b/libs/FML/Elements/Format.php index 41649fc5..3631e434 100644 --- a/libs/FML/Elements/Format.php +++ b/libs/FML/Elements/Format.php @@ -2,7 +2,7 @@ namespace FML\Elements; -use FML\Types\BgColorable; +use FML\Types\BackgroundColorable; use FML\Types\Renderable; use FML\Types\Styleable; use FML\Types\TextFormatable; @@ -11,113 +11,205 @@ use FML\Types\TextFormatable; * Format Element * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Format implements BgColorable, Renderable, Styleable, TextFormatable { - /* - * Protected properties - */ - protected $tagName = 'format'; - protected $bgColor = null; - protected $style = null; - protected $textSize = -1; - protected $textFont = null; - protected $textColor = null; - protected $focusAreaColor1 = null; - protected $focusAreaColor2 = null; +class Format implements BackgroundColorable, Renderable, Styleable, TextFormatable +{ - /** - * Create a new Format Element - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var string $backgroundColor Background color + */ + protected $backgroundColor = null; - /** - * @see \FML\Types\BgColorable::setBgColor() - */ - public function setBgColor($bgColor) { - $this->bgColor = (string)$bgColor; - return $this; - } + /** + * @var string $style Style + */ + protected $style = null; - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - return $this; - } + /** + * @var int $textSize Text size + */ + protected $textSize = null; - /** - * @see \FML\Types\TextFormatable::setTextSize() - */ - public function setTextSize($textSize) { - $this->textSize = (int)$textSize; - return $this; - } + /** + * @var string $textFont Text font + */ + protected $textFont = null; - /** - * @see \FML\Types\TextFormatable::setTextFont() - */ - public function setTextFont($textFont) { - $this->textFont = (string)$textFont; - return $this; - } + /** + * @var string $textColor Text color + */ + protected $textColor = null; - /** - * @see \FML\Types\TextFormatable::setTextColor() - */ - public function setTextColor($textColor) { - $this->textColor = (string)$textColor; - return $this; - } + /** + * @var string $areaColor Area color + */ + protected $areaColor = null; - /** - * @see \FML\Types\TextFormatable::setAreaColor() - */ - public function setAreaColor($areaColor) { - $this->focusAreaColor1 = (string)$areaColor; - return $this; - } + /** + * @var string $focusAreaColor Focus area color + */ + protected $focusAreaColor = null; - /** - * @see \FML\Types\TextFormatable::setAreaFocusColor() - */ - public function setAreaFocusColor($areaFocusColor) { - $this->focusAreaColor2 = (string)$areaFocusColor; - return $this; - } + /** + * Create a new Format + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } + + /** + * @see BgColorable::getBackgroundColor() + */ + public function getBackgroundColor() + { + return $this->backgroundColor; + } + + /** + * @see BgColorable::setBackgroundColor() + */ + public function setBackgroundColor($backgroundColor) + { + $this->backgroundColor = (string)$backgroundColor; + return $this; + } + + /** + * @see Styleable::getStyle() + */ + public function getStyle() + { + return $this->style; + } + + /** + * @see Styleable::setStyle() + */ + public function setStyle($style) + { + $this->style = (string)$style; + return $this; + } + + /** + * @see TextFormatable::getTextSize() + */ + public function getTextSize() + { + return $this->textSize; + } + + /** + * @see TextFormatable::setTextSize() + */ + public function setTextSize($textSize) + { + $this->textSize = (int)$textSize; + return $this; + } + + /** + * @see TextFormatable::getTextFont() + */ + public function getTextFont() + { + return $this->textFont; + } + + /** + * @see TextFormatable::setTextFont() + */ + public function setTextFont($textFont) + { + $this->textFont = (string)$textFont; + return $this; + } + + /** + * @see TextFormatable::getTextColor() + */ + public function getTextColor() + { + return $this->textColor; + } + + /** + * @see TextFormatable::setTextColor() + */ + public function setTextColor($textColor) + { + $this->textColor = (string)$textColor; + return $this; + } + + /** + * @see TextFormatable::getAreaColor() + */ + public function getAreaColor() + { + return $this->areaColor; + } + + /** + * @see TextFormatable::setAreaColor() + */ + public function setAreaColor($areaColor) + { + $this->areaColor = (string)$areaColor; + return $this; + } + + /** + * @see TextFormatable::getAreaFocusColor() + */ + public function getAreaFocusColor() + { + return $this->focusAreaColor; + } + + /** + * @see TextFormatable::setAreaFocusColor() + */ + public function setAreaFocusColor($areaFocusColor) + { + $this->focusAreaColor = (string)$areaFocusColor; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("format"); + if ($this->backgroundColor) { + $domElement->setAttribute("bgcolor", $this->backgroundColor); + } + if ($this->style) { + $domElement->setAttribute("style", $this->style); + } + if ($this->textSize) { + $domElement->setAttribute("textsize", $this->textSize); + } + if ($this->textFont) { + $domElement->setAttribute("textfont", $this->textFont); + } + if ($this->textColor) { + $domElement->setAttribute("textcolor", $this->textColor); + } + if ($this->areaColor) { + $domElement->setAttribute("focusareacolor1", $this->areaColor); + } + if ($this->focusAreaColor) { + $domElement->setAttribute("focusareacolor2", $this->focusAreaColor); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $formatXmlElement = $domDocument->createElement($this->tagName); - if ($this->bgColor) { - $formatXmlElement->setAttribute('bgcolor', $this->bgColor); - } - if ($this->style) { - $formatXmlElement->setAttribute('style', $this->style); - } - if ($this->textSize >= 0) { - $formatXmlElement->setAttribute('textsize', $this->textSize); - } - if ($this->textFont) { - $formatXmlElement->setAttribute('textfont', $this->textFont); - } - if ($this->textColor) { - $formatXmlElement->setAttribute('textcolor', $this->textColor); - } - if ($this->focusAreaColor1) { - $formatXmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1); - } - if ($this->focusAreaColor2) { - $formatXmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2); - } - return $formatXmlElement; - } } diff --git a/libs/FML/Elements/FrameModel.php b/libs/FML/Elements/FrameModel.php index 19ff4433..152a5c37 100644 --- a/libs/FML/Elements/FrameModel.php +++ b/libs/FML/Elements/FrameModel.php @@ -3,6 +3,7 @@ namespace FML\Elements; use FML\Types\Container; +use FML\Types\Identifiable; use FML\Types\Renderable; use FML\UniqueID; @@ -10,103 +11,172 @@ use FML\UniqueID; * Class representing a Frame Model * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class FrameModel implements Container, Renderable { - /* - * Protected properties - */ - protected $tagName = 'framemodel'; - protected $modelId = null; - /** @var Renderable[] $children */ - protected $children = array(); - /** @var Format $format */ - protected $format = null; +class FrameModel implements Container, Identifiable, Renderable +{ - /** - * Set Model id - * - * @param string $modelId Model id - * @return static - */ - public function setId($modelId) { - $this->modelId = (string)$modelId; - return $this; - } + /** + * @var string $modelId Model id + */ + protected $modelId = null; - /** - * Get Model id - * - * @return string - */ - public function getId() { - return $this->modelId; - } + /** + * @var Renderable[] $children Children + */ + protected $children = array(); - /** - * Assign an id if necessary - * - * @return string - */ - public function checkId() { - if (!$this->modelId) { - $this->setId(UniqueID::create()); - } - return $this; - } + /** + * @var Format $format Format + */ + protected $format = null; - /** - * @see \FML\Types\Container::add() - */ - public function add(Renderable $childElement) { - if (!in_array($childElement, $this->children, true)) { - array_push($this->children, $childElement); - } - return $this; - } + /** + * Create a new Frame Model + * + * @api + * @param string $modelId Model id + * @param Renderable[] $children Children + * @return static + */ + public static function create($modelId = null, array $children = null) + { + return new static($modelId, $children); + } - /** - * @see \FML\Types\Container::removeChildren() - */ - public function removeChildren() { - $this->children = array(); - return $this; - } + /** + * Construct a new Frame Model + * + * @api + * @param string $modelId Model id + * @param Renderable[] $children Children + */ + public function __construct($modelId = null, array $children = null) + { + if ($modelId) { + $this->setId($modelId); + } + if ($children) { + $this->addChildren($children); + } + } - /** - * @see \FML\Types\Container::setFormat() - */ - public function setFormat(Format $format) { - $this->format = $format; - return $this; - } + /** + * @see Identifiable::getId() + */ + public function getId() + { + if (!$this->modelId) { + return $this->createId(); + } + return $this->modelId; + } - /** - * @see \FML\Types\Container::getFormat() - */ - public function getFormat($createIfEmpty = true) { - if (!$this->format && $createIfEmpty) { - $this->setFormat(new Format()); - } - return $this->format; - } + /** + * @see Identifiable::setId() + */ + public function setId($modelId) + { + $this->modelId = (string)$modelId; + return $this; + } + + /** + * @see Identifiable::checkId() + */ + public function checkId() + { + return UniqueID::check($this); + } + + /** + * Create a new model id + * + * @return string + */ + protected function createId() + { + $modelId = UniqueID::create(); + $this->setId($modelId); + return $this->getId(); + } + + /** + * @see Container::getChildren() + */ + public function getChildren() + { + return $this->children; + } + + /** + * @see Container::addChild() + */ + public function addChild(Renderable $childElement) + { + if (!in_array($childElement, $this->children, true)) { + array_push($this->children, $childElement); + } + return $this; + } + + /** + * @see Container::addChildren() + */ + public function addChildren(array $children) + { + foreach ($children as $child) { + $this->addChild($child); + } + return $this; + } + + /** + * @see Container::removeAllChildren() + */ + public function removeAllChildren() + { + $this->children = array(); + return $this; + } + + /** + * @see Container::getFormat() + */ + public function getFormat() + { + return $this->format; + } + + /** + * @see Container::setFormat() + */ + public function setFormat(Format $format = null) + { + $this->format = $format; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("framemodel"); + $domElement->setAttribute("id", $this->getId()); + + if ($this->format) { + $formatElement = $this->format->render($domDocument); + $domElement->appendChild($formatElement); + } + + foreach ($this->children as $child) { + $childElement = $child->render($domDocument); + $domElement->appendChild($childElement); + } + + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - $this->checkId(); - $xmlElement->setAttribute('id', $this->getId()); - if ($this->format) { - $formatXml = $this->format->render($domDocument); - $xmlElement->appendChild($formatXml); - } - foreach ($this->children as $child) { - $childElement = $child->render($domDocument); - $xmlElement->appendChild($childElement); - } - return $xmlElement; - } } diff --git a/libs/FML/Elements/Including.php b/libs/FML/Elements/Including.php index 4d5979ef..b984cf65 100644 --- a/libs/FML/Elements/Including.php +++ b/libs/FML/Elements/Including.php @@ -8,56 +8,76 @@ use FML\Types\Renderable; * Include Element * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Including implements Renderable { - /* - * Protected properties - */ - protected $tagName = 'include'; - protected $url = null; +class Including implements Renderable +{ - /** - * Create a new Include object - * - * @param string $url (optional) Include url - * @return static - */ - public static function create($url = null) { - return new static($url); - } + /** + * @var string $url Include url + */ + protected $url = null; - /** - * Construct a new Include object - * - * @param string $url (optional) Include url - */ - public function __construct($url = null) { - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * Create a new Include + * + * @api + * @param string $url (optional) Include url + * @return static + */ + public static function create($url = null) + { + return new static($url); + } - /** - * Set url - * - * @param string $url Include url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new Include + * + * @api + * @param string $url (optional) Include url + */ + public function __construct($url = null) + { + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the url + * + * @api + * @param string $url Include url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("include"); + if ($this->url) { + $domElement->setAttribute("url", $this->url); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - if ($this->url) { - $xmlElement->setAttribute('url', $this->url); - } - return $xmlElement; - } } diff --git a/libs/FML/Elements/Music.php b/libs/FML/Elements/Music.php index 1daefc9c..3cab9dd4 100644 --- a/libs/FML/Elements/Music.php +++ b/libs/FML/Elements/Music.php @@ -8,56 +8,76 @@ use FML\Types\Renderable; * Music Element * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Music implements Renderable { - /* - * Protected properties - */ - protected $tagName = 'music'; - protected $data = null; +class Music implements Renderable +{ - /** - * Create a new Music object - * - * @param string $data (optional) Media url - * @return static - */ - public static function create($data = null) { - return new static($data); - } + /** + * @var string $data Media url + */ + protected $data = null; - /** - * Construct a new Music object - * - * @param string $data (optional) Media url - */ - public function __construct($data = null) { - if ($data !== null) { - $this->setData($data); - } - } + /** + * Create a new Music + * + * @api + * @param string $data (optional) Media url + * @return static + */ + public static function create($data = null) + { + return new static($data); + } - /** - * Set data url - * - * @param string $data Data url - * @return static - */ - public function setData($data) { - $this->data = (string)$data; - return $this; - } + /** + * Construct a new Music + * + * @api + * @param string $data (optional) Media url + */ + public function __construct($data = null) + { + if ($data) { + $this->setData($data); + } + } + + /** + * Get the media url + * + * @api + * @return string + */ + public function getData() + { + return $this->data; + } + + /** + * Set the media url + * + * @api + * @param string $data Media url + * @return static + */ + public function setData($data) + { + $this->data = (string)$data; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("music"); + if ($this->data) { + $domElement->setAttribute("data", $this->data); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - if ($this->data) { - $xmlElement->setAttribute('data', $this->data); - } - return $xmlElement; - } } diff --git a/libs/FML/Elements/SimpleScript.php b/libs/FML/Elements/SimpleScript.php index 871c250d..dc271be2 100644 --- a/libs/FML/Elements/SimpleScript.php +++ b/libs/FML/Elements/SimpleScript.php @@ -8,57 +8,77 @@ use FML\Types\Renderable; * Class representing a ManiaLink script tag with a simple script text * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class SimpleScript implements Renderable { - /* - * Protected properties - */ - protected $tagName = 'script'; - protected $text = null; +class SimpleScript implements Renderable +{ - /** - * Create a new SimpleScript object - * - * @param string $text (optional) Script text - * @return static - */ - public static function create($text = null) { - return new static($text); - } + /** + * @var string $text Script text + */ + protected $text = null; - /** - * Construct a new SimpleScript object - * - * @param string $text (optional) Script text - */ - public function __construct($text = null) { - if ($text !== null) { - $this->setText($text); - } - } + /** + * Create a new SimpleScript + * + * @api + * @param string $text (optional) Script text + * @return static + */ + public static function create($text = null) + { + return new static($text); + } - /** - * Set script text - * - * @param string $text Complete script text - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * Construct a new SimpleScript + * + * @api + * @param string $text (optional) Script text + */ + public function __construct($text = null) + { + if ($text) { + $this->setText($text); + } + } + + /** + * Get the script text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the script text + * + * @api + * @param string $text Complete script text + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("script"); + if ($this->text) { + $scriptComment = $domDocument->createComment($this->text); + $domElement->appendChild($scriptComment); + } + return $domElement; + } - /** - * @see \FML\Types\Renderable::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - if ($this->text) { - $scriptComment = $domDocument->createComment($this->text); - $xmlElement->appendChild($scriptComment); - } - return $xmlElement; - } } diff --git a/libs/FML/Form/Parameters.php b/libs/FML/Form/Parameters.php new file mode 100644 index 00000000..036c69f3 --- /dev/null +++ b/libs/FML/Form/Parameters.php @@ -0,0 +1,32 @@ + - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ManiaCode { - /* - * Protected properties - */ - protected $encoding = 'utf-8'; - protected $tagName = 'maniacode'; - protected $noConfirmation = null; - /** @var Element[] $elements */ - protected $elements = array(); +class ManiaCode +{ - /** - * Create a new ManiaCode object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var bool $disableConfirmation Disable the confirmation + */ + protected $disableConfirmation = null; - /** - * Set XML encoding - * - * @param string $encoding XML encoding - * @return static - */ - public function setXmlEncoding($encoding) { - $this->encoding = (string)$encoding; - return $this; - } + /** + * @var Element[] $elements ManiaCode Elements + */ + protected $elements = array(); - /** - * Disable the showing of the confirmation at the end of the ManiaCode - * - * @param bool $disable Whether the confirmation should be shown - * @return static - */ - public function disableConfirmation($disable) { - $this->noConfirmation = ($disable ? 1 : 0); - return $this; - } + /** + * Create a new ManiaCode + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Show a message - * - * @param string $message Message text - * @return static - */ - public function addShowMessage($message) { - $messageElement = new ShowMessage($message); - $this->addElement($messageElement); - return $this; - } + /** + * Get if the confirmation is disabled + * + * @api + * @return bool + */ + public function getDisableConfirmation() + { + return $this->disableConfirmation; + } - /** - * Install a Macroblock - * - * @param string $name Macroblock name - * @param string $file Macroblock file - * @param string $url Macroblock url - * @return static - */ - public function addInstallMacroblock($name, $file, $url) { - $macroblockElement = new InstallMacroblock($name, $file, $url); - $this->addElement($macroblockElement); - return $this; - } + /** + * Disable the showing of the confirmation at the end of the ManiaCode + * + * @api + * @param bool $disableConfirmation If the confirmation should be disabled + * @return static + */ + public function setDisableConfirmation($disableConfirmation) + { + $this->disableConfirmation = (bool)$disableConfirmation; + return $this; + } - /** - * Install a map - * - * @param string $name Map name - * @param string $url Map url - * @return static - */ - public function addInstallMap($name, $url) { - $mapElement = new InstallMap($name, $url); - $this->addElement($mapElement); - return $this; - } + /** + * Show a message + * + * @api + * @param string $message Message text + * @return static + */ + public function addShowMessage($message) + { + $messageElement = new ShowMessage($message); + return $this->addElement($messageElement); + } - /** - * Play a map - * - * @param string $name Map name - * @param string $url Map url - * @return static - */ - public function addPlayMap($name, $url) { - $mapElement = new PlayMap($name, $url); - $this->addElement($mapElement); - return $this; - } + /** + * Install a Macroblock + * + * @api + * @param string $name Macroblock name + * @param string $file Macroblock file + * @param string $url Macroblock url + * @return static + */ + public function addInstallMacroblock($name, $file, $url) + { + $macroblockElement = new InstallMacroblock($name, $file, $url); + return $this->addElement($macroblockElement); + } - /** - * Install a replay - * - * @param string $name Replay name - * @param string $url Replay url - * @return static - */ - public function addInstallReplay($name, $url) { - $replayElement = new InstallReplay($name, $url); - $this->addElement($replayElement); - return $this; - } + /** + * Install a map + * + * @api + * @param string $name Map name + * @param string $url Map url + * @return static + */ + public function addInstallMap($name, $url) + { + $mapElement = new InstallMap($name, $url); + return $this->addElement($mapElement); + } - /** - * View a replay - * - * @param string $name Replay name - * @param string $url Replay url - * @return static - */ - public function addViewReplay($name, $url) { - $replayElement = new ViewReplay($name, $url); - $this->addElement($replayElement); - return $this; - } + /** + * Play a map + * + * @api + * @param string $name Map name + * @param string $url Map url + * @return static + */ + public function addPlayMap($name, $url) + { + $mapElement = new PlayMap($name, $url); + return $this->addElement($mapElement); + } - /** - * Play a replay - * - * @param string $name Replay name - * @param string $url Replay url - * @return static - */ - public function addPlayReplay($name, $url) { - $replayElement = new PlayReplay($name, $url); - $this->addElement($replayElement); - return $this; - } + /** + * Install a replay + * + * @api + * @param string $name Replay name + * @param string $url Replay url + * @return static + */ + public function addInstallReplay($name, $url) + { + $replayElement = new InstallReplay($name, $url); + return $this->addElement($replayElement); + } - /** - * Install a skin - * - * @param string $name Skin name - * @param string $file Skin file - * @param string $url Skin url - * @return static - */ - public function addInstallSkin($name, $file, $url) { - $skinElement = new InstallSkin($name, $file, $url); - $this->addElement($skinElement); - return $this; - } + /** + * View a replay + * + * @api + * @param string $name Replay name + * @param string $url Replay url + * @return static + */ + public function addViewReplay($name, $url) + { + $replayElement = new ViewReplay($name, $url); + return $this->addElement($replayElement); + } - /** - * Get a skin - * - * @param string $name Skin name - * @param string $file Skin file - * @param string $url Skin url - * @return static - */ - public function addGetSkin($name, $file, $url) { - $skinElement = new GetSkin($name, $file, $url); - $this->addElement($skinElement); - return $this; - } + /** + * Play a replay + * + * @api + * @param string $name Replay name + * @param string $url Replay url + * @return static + */ + public function addPlayReplay($name, $url) + { + $replayElement = new PlayReplay($name, $url); + return $this->addElement($replayElement); + } - /** - * Add a buddy - * - * @param string $login Buddy login - * @return static - */ - public function addAddBuddy($login) { - $buddyElement = new AddBuddy($login); - $this->addElement($buddyElement); - return $this; - } + /** + * Install a skin + * + * @api + * @param string $name Skin name + * @param string $file Skin file + * @param string $url Skin url + * @return static + */ + public function addInstallSkin($name, $file, $url) + { + $skinElement = new InstallSkin($name, $file, $url); + return $this->addElement($skinElement); + } - /** - * Go to a link - * - * @param string $link Goto link - * @return static - */ - public function addGoto($link) { - $gotoElement = new Go_To($link); - $this->addElement($gotoElement); - return $this; - } + /** + * Get a skin + * + * @api + * @param string $name Skin name + * @param string $file Skin file + * @param string $url Skin url + * @return static + */ + public function addGetSkin($name, $file, $url) + { + $skinElement = new GetSkin($name, $file, $url); + return $this->addElement($skinElement); + } - /** - * Join a server - * - * @param string $login Server login - * @return static - */ - public function addJoinServer($login) { - $serverElement = new JoinServer($login); - $this->addElement($serverElement); - return $this; - } + /** + * Add a buddy + * + * @api + * @param string $login Buddy login + * @return static + */ + public function addAddBuddy($login) + { + $buddyElement = new AddBuddy($login); + return $this->addElement($buddyElement); + } - /** - * Add a server as favorite - * - * @param string $login Server login - * @return static - */ - public function addAddFavorite($login) { - $favoriteElement = new AddFavorite($login); - $this->addElement($favoriteElement); - return $this; - } + /** + * Go to a link + * + * @api + * @param string $link Goto link + * @return static + */ + public function addGoto($link) + { + $gotoElement = new Go_To($link); + return $this->addElement($gotoElement); + } - /** - * Install a script - * - * @param string $name Script name - * @param string $file Script file - * @param string $url Script url - * @return static - */ - public function addInstallScript($name, $file, $url) { - $scriptElement = new InstallScript($name, $file, $url); - $this->addElement($scriptElement); - return $this; - } + /** + * Join a server + * + * @api + * @param string $login Server login + * @return static + */ + public function addJoinServer($login) + { + $serverElement = new JoinServer($login); + return $this->addElement($serverElement); + } - /** - * Install a title pack - * - * @param string $name Pack name - * @param string $file Pack file - * @param string $url Pack url - * @return static - */ - public function addInstallPack($name, $file, $url) { - $packElement = new InstallPack($name, $file, $url); - $this->addElement($packElement); - return $this; - } + /** + * Add a server as favorite + * + * @api + * @param string $login Server login + * @return static + */ + public function addAddFavorite($login) + { + $favoriteElement = new AddFavorite($login); + return $this->addElement($favoriteElement); + } - /** - * Add a ManiaCode element - * - * @param Element $element Element to add - * @return static - */ - public function addElement(Element $element) { - array_push($this->elements, $element); - return $this; - } + /** + * Install a script + * + * @api + * @param string $name Script name + * @param string $file Script file + * @param string $url Script url + * @return static + */ + public function addInstallScript($name, $file, $url) + { + $scriptElement = new InstallScript($name, $file, $url); + return $this->addElement($scriptElement); + } - /** - * Remove all elements from the ManiaCode - * - * @return static - */ - public function removeElements() { - $this->elements = array(); - return $this; - } + /** + * Install a title pack + * + * @api + * @param string $name Pack name + * @param string $file Pack file + * @param string $url Pack url + * @return static + */ + public function addInstallPack($name, $file, $url) + { + $packElement = new InstallPack($name, $file, $url); + return $this->addElement($packElement); + } - /** - * Render the XML document - * - * @param bool $echo (optional) Whether the XML text should be echoed and the Content-Type header should be set - * @return \DOMDocument - */ - public function render($echo = false) { - $domDocument = new \DOMDocument('1.0', $this->encoding); - $domDocument->xmlStandalone = true; - $maniaCode = $domDocument->createElement($this->tagName); - $domDocument->appendChild($maniaCode); - if ($this->noConfirmation) { - $maniaCode->setAttribute('noconfirmation', $this->noConfirmation); - } - foreach ($this->elements as $element) { - $xmlElement = $element->render($domDocument); - $maniaCode->appendChild($xmlElement); - } - if ($echo) { - header('Content-Type: application/xml; charset=utf-8;'); - echo $domDocument->saveXML(); - } - return $domDocument; - } + /** + * Get all Elements + * + * @api + * @return Element[] + */ + public function getElements() + { + return $this->elements; + } + + /** + * Add a ManiaCode Element + * + * @api + * @param Element $element Element to add + * @return static + */ + public function addElement(Element $element) + { + if (!in_array($element, $this->elements, true)) { + array_push($this->elements, $element); + } + return $this; + } + + /** + * Remove all ManiaCode Elements + * + * @api + * @return static + * @deprecated use removeAllElements() instead + */ + public function removeElements() + { + return $this->removeAllElements(); + } + + /** + * Remove all ManiaCode Elements + * + * @api + * @return static + */ + public function removeAllElements() + { + $this->elements = array(); + return $this; + } + + /** + * Render the ManiaCode + * + * @api + * @param bool $echo (optional) If the XML text should be echoed and the Content-Type header should be set + * @return \DOMDocument + */ + public function render($echo = false) + { + $domDocument = new \DOMDocument("1.0", "utf-8"); + $domDocument->xmlStandalone = true; + + $domElement = $domDocument->createElement("maniacode"); + $domDocument->appendChild($domElement); + + if ($this->disableConfirmation) { + $domElement->setAttribute("noconfirmation", 1); + } + + foreach ($this->elements as $element) { + $childDomElement = $element->render($domDocument); + $domElement->appendChild($childDomElement); + } + + if ($echo) { + header("Content-Type: application/xml; charset=utf-8;"); + echo $domDocument->saveXML(); + } + + return $domDocument; + } + + /** + * Get the string representation + * + * @return string + */ + public function __toString() + { + return $this->render() + ->saveXML(); + } - /** - * Get string representation - * - * @return string - */ - public function __toString() { - return $this->render()->saveXML(); - } } diff --git a/libs/FML/ManiaCode/AddBuddy.php b/libs/FML/ManiaCode/AddBuddy.php index fe36815c..02ad07d5 100644 --- a/libs/FML/ManiaCode/AddBuddy.php +++ b/libs/FML/ManiaCode/AddBuddy.php @@ -6,55 +6,77 @@ namespace FML\ManiaCode; * ManiaCode Element adding a buddy * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class AddBuddy extends Element { - /* - * Protected properties - */ - protected $tagName = 'add_buddy'; - protected $login = null; +class AddBuddy implements Element +{ - /** - * Create a new AddBuddy Element - * - * @param string $login (optional) Buddy login - * @return static - */ - public static function create($login = null) { - return new static($login); - } + /** + * @var string $login Buddy login + */ + protected $login = null; - /** - * Construct a new AddBuddy Element - * - * @param string $login (optional) Buddy login - */ - public function __construct($login = null) { - if ($login !== null) { - $this->setLogin($login); - } - } + /** + * Create a new AddBuddy Element + * + * @api + * @param string $login (optional) Buddy login + * @return static + */ + public static function create($login = null) + { + return new static($login); + } - /** - * Set the buddy login - * - * @param string $login Buddy login - * @return static - */ - public function setLogin($login) { - $this->login = (string)$login; - return $this; - } + /** + * Construct a new AddBuddy Element + * + * @api + * @param string $login (optional) Buddy login + */ + public function __construct($login = null) + { + if ($login) { + $this->setLogin($login); + } + } + + /** + * Get the buddy login + * + * @api + * @return string + */ + public function getLogin() + { + return $this->login; + } + + /** + * Set the buddy login + * + * @api + * @param string $login Buddy login + * @return static + */ + public function setLogin($login) + { + $this->login = (string)$login; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("add_buddy"); + + $loginElement = $domDocument->createElement("login", $this->login); + $domElement->appendChild($loginElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $loginElement = $domDocument->createElement('login', $this->login); - $xmlElement->appendChild($loginElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/AddFavorite.php b/libs/FML/ManiaCode/AddFavorite.php index f1b19591..b3a1122a 100644 --- a/libs/FML/ManiaCode/AddFavorite.php +++ b/libs/FML/ManiaCode/AddFavorite.php @@ -6,78 +6,150 @@ namespace FML\ManiaCode; * ManiaCode Element adding a server as favorite * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class AddFavorite extends Element { - /* - * Protected properties - */ - protected $tagName = 'add_favourite'; - protected $login = null; - protected $serverIp = null; - protected $serverPort = null; +class AddFavorite implements Element +{ - /** - * Create a new AddFavorite object - * - * @param string $login (optional) Server login - * @return static - */ - public static function create($login = null) { - return new static($login); - } + /** + * @var string $login Server login + */ + protected $login = null; - /** - * Construct a new AddFavorite object - * - * @param string $login (optional) Server login - */ - public function __construct($login = null) { - if ($login !== null) { - $this->setLogin($login); - } - } + /** + * @var string $ip Server ip + */ + protected $ip = null; - /** - * Set the server login - * - * @param string $login Server login - * @return static - */ - public function setLogin($login) { - $this->login = (string)$login; - $this->serverIp = null; - $this->serverPort = null; - return $this; - } + /** + * @var int $port Server port + */ + protected $port = null; - /** - * Set the server ip and port - * - * @param string $serverIp Server ip - * @param int $serverPort Server port - * @return static - */ - public function setIp($serverIp, $serverPort) { - $this->serverIp = (string)$serverIp; - $this->serverPort = (int)$serverPort; - $this->login = null; - return $this; - } + /** + * Create a new AddFavorite Element + * + * @api + * @param string $loginOrIp (optional) Server login or ip + * @param int $port (optional) Server port + * @return static + */ + public static function create($loginOrIp = null, $port = null) + { + return new static($loginOrIp, $port); + } + + /** + * Construct a new AddFavorite Element + * + * @api + * @param string $loginOrIp (optional) Server login or ip + * @param int $port (optional) Server port + */ + public function __construct($loginOrIp = null, $port = null) + { + if ($port) { + $this->setIp($loginOrIp, $port); + } elseif ($loginOrIp) { + $this->setLogin($loginOrIp); + } + } + + /** + * Get the server login + * + * @api + * @return string + */ + public function getLogin() + { + return $this->login; + } + + /** + * Set the server login + * + * @api + * @param string $login Server login + * @return static + */ + public function setLogin($login) + { + $this->login = (string)$login; + $this->ip = null; + $this->port = null; + return $this; + } + + /** + * Get the server ip + * + * @api + * @return string + */ + public function getIp() + { + return $this->ip; + } + + /** + * Set the server ip and port + * + * @api + * @param string $ip Server ip + * @param int $port (optional) Server port + * @return static + */ + public function setIp($ip, $port = null) + { + $this->login = null; + $this->ip = (string)$ip; + if ($port) { + $this->setPort($port); + } + return $this; + } + + /** + * Get the server port + * + * @api + * @return int + */ + public function getPort() + { + return $this->port; + } + + /** + * Set the server port + * + * @param int $port Server port + * @return static + */ + public function setPort($port) + { + $this->port = (int)$port; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("add_favourite"); + + if ($this->login) { + $loginElement = $domDocument->createElement("login", $this->login); + $domElement->appendChild($loginElement); + } else { + $ipElement = $domDocument->createElement("ip", $this->ip . ":" . $this->port); + $domElement->appendChild($ipElement); + } + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->serverIp === null) { - $loginElement = $domDocument->createElement('login', $this->login); - $xmlElement->appendChild($loginElement); - } else { - $ipElement = $domDocument->createElement('ip', $this->serverIp . ':' . $this->serverPort); - $xmlElement->appendChild($ipElement); - } - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/Element.php b/libs/FML/ManiaCode/Element.php index cde49572..300506cd 100644 --- a/libs/FML/ManiaCode/Element.php +++ b/libs/FML/ManiaCode/Element.php @@ -6,23 +6,18 @@ namespace FML\ManiaCode; * Base ManiaCode Element * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class Element { - /* - * Protected properties - */ - protected $tagName = 'element'; +interface Element +{ + + /** + * Render the ManiaCode Element + * + * @param \DOMDocument $domDocument The DOMDocument for which the Element should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument); - /** - * Render the ManiaCode Element - * - * @param \DOMDocument $domDocument The DOMDocument for which the Element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = $domDocument->createElement($this->tagName); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/GetSkin.php b/libs/FML/ManiaCode/GetSkin.php index 958c72b8..fb6d7841 100644 --- a/libs/FML/ManiaCode/GetSkin.php +++ b/libs/FML/ManiaCode/GetSkin.php @@ -6,93 +6,151 @@ namespace FML\ManiaCode; * ManiaCode Element downloading a skin * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class GetSkin extends Element { - /* - * Protected properties - */ - protected $tagName = 'get_skin'; - protected $name = null; - protected $file = null; - protected $url = null; +class GetSkin implements Element +{ - /** - * Create a new GetSkin object - * - * @param string $name (optional) Skin name - * @param string $file (optional) Skin file - * @param string $url (optional) Skin url - * @return static - */ - public static function create($name = null, $file = null, $url = null) { - return new static($name, $file, $url); - } + /** + * @var string $name Skin name + */ + protected $name = null; - /** - * Construct a new GetSkin object - * - * @param string $name (optional) Skin name - * @param string $file (optional) Skin file - * @param string $url (optional) Skin url - */ - public function __construct($name = null, $file = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Skin file + */ + protected $file = null; - /** - * Set the name of the skin - * - * @param string $name Skin name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Skin url + */ + protected $url = null; - /** - * Set the file of the skin - * - * @param string $file Skin file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * Create a new GetSkin Element + * + * @api + * @param string $name (optional) Skin name + * @param string $file (optional) Skin file + * @param string $url (optional) Skin url + * @return static + */ + public static function create($name = null, $file = null, $url = null) + { + return new static($name, $file, $url); + } - /** - * Set the url of the skin - * - * @param string $url Skin url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new GetSkin Element + * + * @api + * @param string $name (optional) Skin name + * @param string $file (optional) Skin file + * @param string $url (optional) Skin url + */ + public function __construct($name = null, $file = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the skin name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the skin name + * + * @api + * @param string $name Skin name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the skin file + * + * @api + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set the skin file + * + * @api + * @param string $file Skin file + * @return static + */ + public function setFile($file) + { + $this->file = (string)$file; + return $this; + } + + /** + * Get the skin url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the skin url + * + * @api + * @param string $url Skin url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("get_skin"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $fileElement = $domDocument->createElement("file", $this->file); + $domElement->appendChild($fileElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $fileElement = $domDocument->createElement('file', $this->file); - $xmlElement->appendChild($fileElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/Go_To.php b/libs/FML/ManiaCode/Go_To.php index 3b511fc4..5636e394 100644 --- a/libs/FML/ManiaCode/Go_To.php +++ b/libs/FML/ManiaCode/Go_To.php @@ -6,55 +6,77 @@ namespace FML\ManiaCode; * ManiaCode Element for going to a link * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Go_To extends Element { - /* - * Protected properties - */ - protected $tagName = 'goto'; - protected $link = null; +class Go_To implements Element +{ - /** - * Create a new Go_To object - * - * @param string $link (optional) Goto link - * @return static - */ - public static function create($link = null) { - return new static($link); - } + /** + * @var string $link Link + */ + protected $link = null; - /** - * Construct a new Go_To object - * - * @param string $link (optional) Goto link - */ - public function __construct($link = null) { - if ($link !== null) { - $this->setLink($link); - } - } + /** + * Create a new Go_To Element + * + * @api + * @param string $link (optional) Link + * @return static + */ + public static function create($link = null) + { + return new static($link); + } - /** - * Set link - * - * @param string $link Goto link - * @return static - */ - public function setLink($link) { - $this->link = (string)$link; - return $this; - } + /** + * Construct a new Go_To Element + * + * @api + * @param string $link (optional) Link + */ + public function __construct($link = null) + { + if ($link) { + $this->setLink($link); + } + } + + /** + * Get the link + * + * @api + * @return string + */ + public function getLink() + { + return $this->link; + } + + /** + * Set the link + * + * @api + * @param string $link Link + * @return static + */ + public function setLink($link) + { + $this->link = (string)$link; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("goto"); + + $linkElement = $domDocument->createElement("link", $this->link); + $domElement->appendChild($linkElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $linkElement = $domDocument->createElement('link', $this->link); - $xmlElement->appendChild($linkElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/InstallMacroblock.php b/libs/FML/ManiaCode/InstallMacroblock.php index a8d20ba1..0b973153 100644 --- a/libs/FML/ManiaCode/InstallMacroblock.php +++ b/libs/FML/ManiaCode/InstallMacroblock.php @@ -6,92 +6,151 @@ namespace FML\ManiaCode; * ManiaCode Element installing a macroblock * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class InstallMacroblock extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_macroblock'; - protected $name = null; - protected $file = null; - protected $url = null; +class InstallMacroblock implements Element +{ - /** - * Create a new InstallMacroblock object - * - * @param string $name (optional) Macroblock name - * @param string $url (optional) Macroblock url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Macroblock name + */ + protected $name = null; - /** - * Construct a new InstallMacroblock object - * - * @param string $name (optional) Macroblock name - * @param string $file (optional) Macroblock file - * @param string $url (optional) Macroblock url - */ - public function __construct($name = null, $file = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Macroblock file + */ + protected $file = null; - /** - * Set the name of the macroblock - * - * @param string $name Macroblock name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Macroblock url + */ + protected $url = null; - /** - * Set the file of the macroblock - * - * @param string $file Macroblock file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * Create a new InstallMacroblock Element + * + * @api + * @param string $name (optional) Macroblock name + * @param string $file (optional) Macroblock file + * @param string $url (optional) Macroblock url + * @return static + */ + public static function create($name = null, $file = null, $url = null) + { + return new static($name, $file, $url); + } - /** - * Set the url of the macroblock - * - * @param string $url Macroblock url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new InstallMacroblock Element + * + * @api + * @param string $name (optional) Macroblock name + * @param string $file (optional) Macroblock file + * @param string $url (optional) Macroblock url + */ + public function __construct($name = null, $file = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the macroblock name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the macroblock name + * + * @api + * @param string $name Macroblock name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the macroblock file + * + * @api + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set the macroblock file + * + * @api + * @param string $file Macroblock file + * @return static + */ + public function setFile($file) + { + $this->file = (string)$file; + return $this; + } + + /** + * Get the macroblock url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the macroblock url + * + * @api + * @param string $url Macroblock url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("install_macroblock"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $fileElement = $domDocument->createElement("file", $this->file); + $domElement->appendChild($fileElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $fileElement = $domDocument->createElement('file', $this->file); - $xmlElement->appendChild($fileElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/InstallMap.php b/libs/FML/ManiaCode/InstallMap.php index 10be08a2..764ed3be 100644 --- a/libs/FML/ManiaCode/InstallMap.php +++ b/libs/FML/ManiaCode/InstallMap.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element installing a map * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class InstallMap extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_map'; - protected $name = null; - protected $url = null; +class InstallMap implements Element +{ - /** - * Create a new InstallMap object - * - * @param string $name (optional) Map name - * @param string $url (optional) Map url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Map name + */ + protected $name = null; - /** - * Construct a new InstallMap object - * - * @param string $name (optional) Map name - * @param string $url (optional) Map url - */ - public function __construct($name = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Map url + */ + protected $url = null; - /** - * Set the name of the map - * - * @param string $name Map name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * Create a new InstallMap Element + * + * @api + * @param string $name (optional) Map name + * @param string $url (optional) Map url + * @return static + */ + public static function create($name = null, $url = null) + { + return new static($name, $url); + } - /** - * Set the url of the map - * - * @param string $url Map url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new InstallMap Element + * + * @api + * @param string $name (optional) Map name + * @param string $url (optional) Map url + */ + public function __construct($name = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the map name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the map name + * + * @api + * @param string $name Map name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the map url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the map url + * + * @api + * @param string $url Map url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("install_map"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/InstallPack.php b/libs/FML/ManiaCode/InstallPack.php index 33781e59..870d7e18 100644 --- a/libs/FML/ManiaCode/InstallPack.php +++ b/libs/FML/ManiaCode/InstallPack.php @@ -6,93 +6,151 @@ namespace FML\ManiaCode; * ManiaCode Element installing a title pack * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class InstallPack extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_pack'; - protected $name = null; - protected $file = null; - protected $url = null; +class InstallPack implements Element +{ - /** - * Create a new InstallPack object - * - * @param string $name (optional) Pack name - * @param string $file (optional) Pack file - * @param string $url (optional) Pack url - * @return static - */ - public static function create($name = null, $file = null, $url = null) { - return new static($name, $file, $url); - } + /** + * @var string $name Pack name + */ + protected $name = null; - /** - * Construct a new InstallPack object - * - * @param string $name (optional) Pack name - * @param string $file (optional) Pack file - * @param string $url (optional) Pack url - */ - public function __construct($name = null, $file = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Pack file + */ + protected $file = null; - /** - * Set the name of the pack - * - * @param string $name Pack name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Pack url + */ + protected $url = null; - /** - * Set the file of the pack - * - * @param string $file Pack file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * Create a new InstallPack Element + * + * @api + * @param string $name (optional) Pack name + * @param string $file (optional) Pack file + * @param string $url (optional) Pack url + * @return static + */ + public static function create($name = null, $file = null, $url = null) + { + return new static($name, $file, $url); + } - /** - * Set the url of the pack - * - * @param string $url Pack url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new InstallPack Element + * + * @api + * @param string $name (optional) Pack name + * @param string $file (optional) Pack file + * @param string $url (optional) Pack url + */ + public function __construct($name = null, $file = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the pack name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the pack name + * + * @api + * @param string $name Pack name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the pack file + * + * @api + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set the pack file + * + * @api + * @param string $file Pack file + * @return static + */ + public function setFile($file) + { + $this->file = (string)$file; + return $this; + } + + /** + * Get the pack url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the pack url + * + * @api + * @param string $url Pack url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("install_pack"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $fileElement = $domDocument->createElement("file", $this->file); + $domElement->appendChild($fileElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $fileElement = $domDocument->createElement('file', $this->file); - $xmlElement->appendChild($fileElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/InstallReplay.php b/libs/FML/ManiaCode/InstallReplay.php index b851ec72..ba97d900 100644 --- a/libs/FML/ManiaCode/InstallReplay.php +++ b/libs/FML/ManiaCode/InstallReplay.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element installing a replay * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class InstallReplay extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_replay'; - protected $name = null; - protected $url = null; +class InstallReplay implements Element +{ - /** - * Create a new InstallReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Replay name + */ + protected $name = null; - /** - * Construct a new InstallReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - */ - public function __construct($name = null, $url = null) { - if ($name!== null) { - $this->setName($name); - } - if ($url!== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Replay url + */ + protected $url = null; - /** - * Set the name of the replay - * - * @param string $name Replay name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * Create a new InstallReplay Element + * + * @api + * @param string $name (optional) Replay name + * @param string $url (optional) Replay url + * @return static + */ + public static function create($name = null, $url = null) + { + return new static($name, $url); + } - /** - * Set the url of the replay - * - * @param string $url Replay url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new InstallReplay Element + * + * @api + * @param string $name (optional) Replay name + * @param string $url (optional) Replay url + */ + public function __construct($name = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the replay name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the replay name + * + * @api + * @param string $name Replay name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the replay url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the replay url + * + * @api + * @param string $url Replay url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("install_replay"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/InstallScript.php b/libs/FML/ManiaCode/InstallScript.php index e11e693a..bed4c6ca 100644 --- a/libs/FML/ManiaCode/InstallScript.php +++ b/libs/FML/ManiaCode/InstallScript.php @@ -6,93 +6,151 @@ namespace FML\ManiaCode; * ManiaCode Element installing a script * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class InstallScript extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_script'; - protected $name = null; - protected $file = null; - protected $url = null; +class InstallScript implements Element +{ - /** - * Create a new InstallScript object - * - * @param string $name (optional) Script name - * @param string $file (optional) Script file - * @param string $url (optional) Script url - * @return static - */ - public static function create($name = null, $file = null, $url = null) { - return new static($name, $file, $url); - } + /** + * @var string $name Script name + */ + protected $name = null; - /** - * Construct a new InstallScript object - * - * @param string $name (optional) Script name - * @param string $file (optional) Script file - * @param string $url (optional) Script url - */ - public function __construct($name = null, $file = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Script file + */ + protected $file = null; - /** - * Set the name of the script - * - * @param string $name Script name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Script url + */ + protected $url = null; - /** - * Set the file of the script - * - * @param string $file Script file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * Create a new InstallScript Element + * + * @api + * @param string $name (optional) Script name + * @param string $file (optional) Script file + * @param string $url (optional) Script url + * @return static + */ + public static function create($name = null, $file = null, $url = null) + { + return new static($name, $file, $url); + } - /** - * Set the url of the script - * - * @param string $url Script url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new InstallScript Element + * + * @api + * @param string $name (optional) Script name + * @param string $file (optional) Script file + * @param string $url (optional) Script url + */ + public function __construct($name = null, $file = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the script name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the script name + * + * @api + * @param string $name Script name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the script file + * + * @api + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set the script file + * + * @api + * @param string $file Script file + * @return static + */ + public function setFile($file) + { + $this->file = (string)$file; + return $this; + } + + /** + * Get the script url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the script url + * + * @api + * @param string $url Script url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("install_script"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $fileElement = $domDocument->createElement("file", $this->file); + $domElement->appendChild($fileElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $fileElement = $domDocument->createElement('file', $this->file); - $xmlElement->appendChild($fileElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/InstallSkin.php b/libs/FML/ManiaCode/InstallSkin.php index a6584ec4..23c29b05 100644 --- a/libs/FML/ManiaCode/InstallSkin.php +++ b/libs/FML/ManiaCode/InstallSkin.php @@ -6,93 +6,151 @@ namespace FML\ManiaCode; * ManiaCode Element installing a skin * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class InstallSkin extends Element { - /* - * Protected properties - */ - protected $tagName = 'install_skin'; - protected $name = null; - protected $file = null; - protected $url = null; +class InstallSkin implements Element +{ - /** - * Create a new InstallSkin object - * - * @param string $name (optional) Skin name - * @param string $file (optional) Skin file - * @param string $url (optional) Skin url - * @return static - */ - public static function create($name = null, $file = null, $url = null) { - return new static($name, $file, $url); - } + /** + * @var string $name Skin name + */ + protected $name = null; - /** - * Construct a new InstallSkin object - * - * @param string $name (optional) Skin name - * @param string $file (optional) Skin file - * @param string $url (optional) Skin url - */ - public function __construct($name = null, $file = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($file !== null) { - $this->setFile($file); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $file Skin file + */ + protected $file = null; - /** - * Set the name of the skin - * - * @param string $name Skin name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $url Skin url + */ + protected $url = null; - /** - * Set the file of the skin - * - * @param string $file Skin file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * Create a new InstallSkin Element + * + * @api + * @param string $name (optional) Skin name + * @param string $file (optional) Skin file + * @param string $url (optional) Skin url + * @return static + */ + public static function create($name = null, $file = null, $url = null) + { + return new static($name, $file, $url); + } - /** - * Set the url of the skin - * - * @param string $url Skin url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new InstallSkin Element + * + * @api + * @param string $name (optional) Skin name + * @param string $file (optional) Skin file + * @param string $url (optional) Skin url + */ + public function __construct($name = null, $file = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($file) { + $this->setFile($file); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the skin name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the skin name + * + * @api + * @param string $name Skin name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the skin file + * + * @api + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set the skin file + * + * @api + * @param string $file Skin file + * @return static + */ + public function setFile($file) + { + $this->file = (string)$file; + return $this; + } + + /** + * Get the skin url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the skin url + * + * @api + * @param string $url Skin url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("install_skin"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $fileElement = $domDocument->createElement("file", $this->file); + $domElement->appendChild($fileElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $fileElement = $domDocument->createElement('file', $this->file); - $xmlElement->appendChild($fileElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/JoinServer.php b/libs/FML/ManiaCode/JoinServer.php index 2a0299fd..c1fdf5de 100644 --- a/libs/FML/ManiaCode/JoinServer.php +++ b/libs/FML/ManiaCode/JoinServer.php @@ -6,78 +6,150 @@ namespace FML\ManiaCode; * ManiaCode Element for joining a server * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class JoinServer extends Element { - /* - * Protected properties - */ - protected $tagName = 'join_server'; - protected $login = null; - protected $serverIp = null; - protected $serverPort = null; +class JoinServer implements Element +{ - /** - * Create a new JoinServer object - * - * @param string $login (optional) Server login - * @return static - */ - public static function create($login = null) { - return new static($login); - } + /** + * @var string $login Server login + */ + protected $login = null; - /** - * Construct a new JoinServer object - * - * @param string $login (optional) Server login - */ - public function __construct($login = null) { - if ($login !== null) { - $this->setLogin($login); - } - } + /** + * @var string $ip Server ip + */ + protected $ip = null; - /** - * Set the server login - * - * @param string $login Server login - * @return static - */ - public function setLogin($login) { - $this->login = (string)$login; - $this->serverIp = null; - $this->serverPort = null; - return $this; - } + /** + * @var int $port Server port + */ + protected $port = null; - /** - * Set the server ip and port - * - * @param string $serverIp Server ip - * @param int $serverPort Server port - * @return static - */ - public function setIp($serverIp, $serverPort) { - $this->serverIp = (string)$serverIp; - $this->serverPort = (int)$serverPort; - $this->login = null; - return $this; - } + /** + * Create a new JoinServer Element + * + * @api + * @param string $loginOrIp (optional) Server login or ip + * @param int $port (optional) Server port + * @return static + */ + public static function create($loginOrIp = null, $port = null) + { + return new static($loginOrIp, $port); + } + + /** + * Construct a new JoinServer Element + * + * @api + * @param string $loginOrIp (optional) Server login or ip + * @param int $port (optional) Server port + */ + public function __construct($loginOrIp = null, $port = null) + { + if ($port) { + $this->setIp($loginOrIp, $port); + } elseif ($loginOrIp) { + $this->setLogin($loginOrIp); + } + } + + /** + * Get the server login + * + * @api + * @return string + */ + public function getLogin() + { + return $this->login; + } + + /** + * Set the server login + * + * @api + * @param string $login Server login + * @return static + */ + public function setLogin($login) + { + $this->login = (string)$login; + $this->ip = null; + $this->port = null; + return $this; + } + + /** + * Get the server ip + * + * @api + * @return string + */ + public function getIp() + { + return $this->ip; + } + + /** + * Set the server ip and port + * + * @api + * @param string $ip Server ip + * @param int $port (optional) Server port + * @return static + */ + public function setIp($ip, $port = null) + { + $this->login = null; + $this->ip = (string)$ip; + if ($port) { + $this->setPort($port); + } + return $this; + } + + /** + * Get the server port + * + * @api + * @return int + */ + public function getPort() + { + return $this->port; + } + + /** + * Set the server port + * + * @param int $port Server port + * @return static + */ + public function setPort($port) + { + $this->port = (int)$port; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("join_server"); + + if ($this->login) { + $loginElement = $domDocument->createElement("login", $this->login); + $domElement->appendChild($loginElement); + } else { + $ipElement = $domDocument->createElement("ip", $this->ip . ":" . $this->port); + $domElement->appendChild($ipElement); + } + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - if ($this->serverIp === null) { - $loginElement = $domDocument->createElement('login', $this->login); - $xmlElement->appendChild($loginElement); - } else { - $ipElement = $domDocument->createElement('ip', $this->serverIp . ':' . $this->serverPort); - $xmlElement->appendChild($ipElement); - } - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/PlayMap.php b/libs/FML/ManiaCode/PlayMap.php index 5e0d9406..a1e6053d 100644 --- a/libs/FML/ManiaCode/PlayMap.php +++ b/libs/FML/ManiaCode/PlayMap.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element for playing a map * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PlayMap extends Element { - /* - * Protected properties - */ - protected $tagName = 'play_map'; - protected $name = null; - protected $url = null; +class PlayMap implements Element +{ - /** - * Create a new PlayMap object - * - * @param string $name (optional) Map name - * @param string $url (optional) Map url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /*+ + * @var string $name Map name + */ + protected $name = null; - /** - * Construct a new PlayMap object - * - * @param string $name (optional) Map name - * @param string $url (optional) Map url - */ - public function __construct($name = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Map url + */ + protected $url = null; - /** - * Set the name of the map - * - * @param string $name Map name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * Create a new PlayMap Element + * + * @api + * @param string $name (optional) Map name + * @param string $url (optional) Map url + * @return static + */ + public static function create($name = null, $url = null) + { + return new static($name, $url); + } - /** - * Set the url of the map - * - * @param string $url Map url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new PlayMap Element + * + * @api + * @param string $name (optional) Map name + * @param string $url (optional) Map url + */ + public function __construct($name = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the map name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the map name + * + * @api + * @param string $name Map name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the map url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the map url + * + * @api + * @param string $url Map url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("play_map"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/PlayReplay.php b/libs/FML/ManiaCode/PlayReplay.php index 667e98ce..dc7157ba 100644 --- a/libs/FML/ManiaCode/PlayReplay.php +++ b/libs/FML/ManiaCode/PlayReplay.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element playing a replay * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PlayReplay extends Element { - /* - * Protected properties - */ - protected $tagName = 'play_replay'; - protected $name = null; - protected $url = null; +class PlayReplay implements Element +{ - /** - * Create a new PlayReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Replay name + */ + protected $name = null; - /** - * Construct a new PlayReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - */ - public function __construct($name = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Replay url + */ + protected $url = null; - /** - * Set the name of the replay - * - * @param string $name Replay name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * Create a new PlayReplay Element + * + * @api + * @param string $name (optional) Replay name + * @param string $url (optional) Replay url + * @return static + */ + public static function create($name = null, $url = null) + { + return new static($name, $url); + } - /** - * Set the url of the replay - * - * @param string $url Replay url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new PlayReplay Element + * + * @api + * @param string $name (optional) Replay name + * @param string $url (optional) Replay url + */ + public function __construct($name = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the replay name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the replay name + * + * @api + * @param string $name Replay name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the replay url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the replay url + * + * @api + * @param string $url Replay url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("play_replay"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/ShowMessage.php b/libs/FML/ManiaCode/ShowMessage.php index 917e6c9a..d534cf81 100644 --- a/libs/FML/ManiaCode/ShowMessage.php +++ b/libs/FML/ManiaCode/ShowMessage.php @@ -6,55 +6,77 @@ namespace FML\ManiaCode; * ManiaCode Element showing a Message * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ShowMessage extends Element { - /* - * Protected properties - */ - protected $tagName = 'show_message'; - protected $message = null; +class ShowMessage implements Element +{ - /** - * Create a new ShowMessage object - * - * @param string $message (optional) Message text - * @return static - */ - public static function create($message = null) { - return new static($message); - } + /** + * @var string $message Message text + */ + protected $message = null; - /** - * Construct a new ShowMessage object - * - * @param string $message (optional) Message text - */ - public function __construct($message = null) { - if ($message !== null) { - $this->setMessage($message); - } - } + /** + * Create a new ShowMessage Element + * + * @api + * @param string $message (optional) Message text + * @return static + */ + public static function create($message = null) + { + return new static($message); + } - /** - * Set the message text - * - * @param string $message Message text - * @return static - */ - public function setMessage($message) { - $this->message = (string)$message; - return $this; - } + /** + * Construct a new ShowMessage Element + * + * @api + * @param string $message (optional) Message text + */ + public function __construct($message = null) + { + if ($message) { + $this->setMessage($message); + } + } + + /** + * Get the message text + * + * @api + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * Set the message text + * + * @api + * @param string $message Message text + * @return static + */ + public function setMessage($message) + { + $this->message = (string)$message; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("show_message"); + + $messageElement = $domDocument->createElement("message", $this->message); + $domElement->appendChild($messageElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $messageElement = $domDocument->createElement('message', $this->message); - $xmlElement->appendChild($messageElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaCode/ViewReplay.php b/libs/FML/ManiaCode/ViewReplay.php index 1ffd9549..2c2088f5 100644 --- a/libs/FML/ManiaCode/ViewReplay.php +++ b/libs/FML/ManiaCode/ViewReplay.php @@ -6,74 +6,114 @@ namespace FML\ManiaCode; * ManiaCode Element for viewing a replay * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ViewReplay extends Element { - /* - * Protected properties - */ - protected $tagName = 'view_replay'; - protected $name = null; - protected $url = null; +class ViewReplay implements Element +{ - /** - * Create a new ViewReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - * @return static - */ - public static function create($name = null, $url = null) { - return new static($name, $url); - } + /** + * @var string $name Replay name + */ + protected $name = null; - /** - * Construct a new ViewReplay object - * - * @param string $name (optional) Replay name - * @param string $url (optional) Replay url - */ - public function __construct($name = null, $url = null) { - if ($name !== null) { - $this->setName($name); - } - if ($url !== null) { - $this->setUrl($url); - } - } + /** + * @var string $url Replay url + */ + protected $url = null; - /** - * Set the name of the replay - * - * @param string $name Replay name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * Create a new ViewReplay Element + * + * @api + * @param string $name (optional) Replay name + * @param string $url (optional) Replay url + * @return static + */ + public static function create($name = null, $url = null) + { + return new static($name, $url); + } - /** - * Set the url of the replay - * - * @param string $url Replay url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new ViewReplay Element + * + * @api + * @param string $name (optional) Replay name + * @param string $url (optional) Replay url + */ + public function __construct($name = null, $url = null) + { + if ($name) { + $this->setName($name); + } + if ($url) { + $this->setUrl($url); + } + } + + /** + * Get the replay name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the replay name + * + * @api + * @param string $name Replay name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the replay url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the replay url + * + * @api + * @param string $url Replay url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see Element::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("view_replay"); + + $nameElement = $domDocument->createElement("name", $this->name); + $domElement->appendChild($nameElement); + + $urlElement = $domDocument->createElement("url", $this->url); + $domElement->appendChild($urlElement); + + return $domElement; + } - /** - * @see \FML\ManiaCode\Element::render() - */ - public function render(\DOMDocument $domDocument) { - $xmlElement = parent::render($domDocument); - $nameElement = $domDocument->createElement('name', $this->name); - $xmlElement->appendChild($nameElement); - $urlElement = $domDocument->createElement('url', $this->url); - $xmlElement->appendChild($urlElement); - return $xmlElement; - } } diff --git a/libs/FML/ManiaLink.php b/libs/FML/ManiaLink.php index 61bb8601..0e9c622c 100644 --- a/libs/FML/ManiaLink.php +++ b/libs/FML/ManiaLink.php @@ -12,317 +12,522 @@ use FML\Types\ScriptFeatureable; * Class representing a ManiaLink * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ManiaLink { - /* - * Constants - */ - const BACKGROUND_0 = '0'; - const BACKGROUND_1 = '1'; - const BACKGROUND_STARS = 'stars'; - const BACKGROUND_STATIONS = 'stations'; - const BACKGROUND_TITLE = 'title'; +class ManiaLink +{ - /* - * Protected properties - */ - protected $encoding = 'utf-8'; - protected $tagName = 'manialink'; - protected $maniaLinkId = null; - protected $version = 1; - protected $background = null; - protected $navigable3d = 1; - protected $name = null; - protected $timeout = 0; - /** @var Renderable[] $children */ - protected $children = array(); - /** @var Dico $dico */ - protected $dico = null; - /** @var Stylesheet $stylesheet */ - protected $stylesheet = null; - /** @var Script $script */ - protected $script = null; + /* + * Constants + */ + const MANIALINK_VERSION = 3; + const BACKGROUND_0 = "0"; + const BACKGROUND_1 = "1"; + const BACKGROUND_STARS = "stars"; + const BACKGROUND_STATIONS = "stations"; + const BACKGROUND_TITLE = "title"; - /** - * Create a new ManiaLink object - * - * @param string $maniaLinkId (optional) ManiaLink id - * @param string $maniaLinkName (optional) ManiaLink Name - * @return static - */ - public static function create($maniaLinkId = null, $maniaLinkName = null) { - return new static($maniaLinkId, $maniaLinkName); - } + /** + * @var string $maniaLinkId ManiaLink ID + */ + protected $maniaLinkId = null; - /** - * Construct a new ManiaLink object - * - * @param string $maniaLinkId (optional) ManiaLink id - * @param string $maniaLinkName (optional) ManiaLink Name - */ - public function __construct($maniaLinkId = null, $maniaLinkName = null) { - if ($maniaLinkId !== null) { - $this->setId($maniaLinkId); - } - if ($maniaLinkName !== false) { - if ($maniaLinkName) { - $this->setName($maniaLinkName); - } else { - $this->setName($maniaLinkId); - } - } - } + /** + * @var int $version ManiaLink version + */ + protected $version = 1; - /** - * Set XML encoding - * - * @param string $encoding XML encoding - * @return static - */ - public function setXmlEncoding($encoding) { - $this->encoding = (string)$encoding; - return $this; - } + /** + * @var string $name ManiaLink name + */ + protected $name = null; - /** - * Set ManiaLink id - * - * @param string $maniaLinkId ManiaLink id - * @return static - */ - public function setId($maniaLinkId) { - $this->maniaLinkId = (string)$maniaLinkId; - return $this; - } + /** + * @var string $background Background + */ + protected $background = null; - /** - * Get ManiaLink id - * - * @return string - */ - public function getId() { - return $this->maniaLinkId; - } + /** + * @var bool $navigable3d 3d navigable + */ + protected $navigable3d = true; - /** - * Set background - * - * @param string $background Background value - * @return static - */ - public function setBackground($background) { - $this->background = (string)$background; - return $this; - } + /** + * @var int $timeout Timeout + */ + protected $timeout = null; - /** - * Set navigable3d - * - * @param bool $navigable3d Whether the manialink should be 3d navigable - * @return static - */ - public function setNavigable3d($navigable3d) { - $this->navigable3d = ($navigable3d ? 1 : 0); - return $this; - } + /** + * @var Renderable[] $children Children + */ + protected $children = array(); - /** - * Set the ManiaLink Name - * - * @param string $name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var Dico $dico Dictionary + */ + protected $dico = null; - /** - * Set timeout - * - * @param int $timeout Timeout duration - * @return static - */ - public function setTimeout($timeout) { - $this->timeout = (int)$timeout; - return $this; - } + /** + * @var Stylesheet $stylesheet Style sheet + */ + protected $stylesheet = null; - /** - * Add an element to the ManiaLink - * - * @param Renderable $child Child element to add - * @return static - */ - public function add(Renderable $child) { - if (!in_array($child, $this->children, true)) { - array_push($this->children, $child); - } - return $this; - } + /** + * @var Script $script Script + */ + protected $script = null; - /** - * Remove all elements from the ManiaLink - * - * @return static - */ - public function removeChildren() { - $this->children = array(); - return $this; - } + /** + * Create a new ManiaLink + * + * @api + * @param string $maniaLinkId (optional) ManiaLink ID + * @param int $version (optional) Version + * @param string $name (optional) Name + * @param Renderable[] $children (optional) Children + * @return static + */ + public static function create($maniaLinkId = null, $version = null, $name = null, array $children = null) + { + return new static($maniaLinkId, $version, $name, $children); + } - /** - * Set the Dictionary of the ManiaLink - * - * @param Dico $dico Dictionary for the ManiaLink - * @return static - */ - public function setDico(Dico $dico) { - $this->dico = $dico; - return $this; - } + /** + * Construct a new ManiaLink + * + * @api + * @param string $maniaLinkId (optional) ManiaLink ID + * @param int $version (optional) Version + * @param string $name (optional) Name + * @param Renderable[] $children (optional) Children + */ + public function __construct($maniaLinkId = null, $version = null, $name = null, array $children = null) + { + if (is_string($version)) { + // backwards-compatibility (version has been introduced later) + $children = $name; + $name = $version; + $version = null; + } + if ($maniaLinkId) { + $this->setId($maniaLinkId); + } + $this->setVersion(self::MANIALINK_VERSION); + if ($version) { + $this->setVersion($version); + } + if ($name) { + $this->setName($name); + } + if ($children) { + $this->setChildren($children); + } + $this->createScript(); + } - /** - * Get the Dictionary of the ManiaLink - * - * @param bool $createIfEmpty (optional) Whether the Dico object should be created if it's not set - * @return \FML\Elements\Dico - */ - public function getDico($createIfEmpty = true) { - if (!$this->dico && $createIfEmpty) { - $this->setDico(new Dico()); - } - return $this->dico; - } + /** + * Get the ID + * + * @api + * @return string + */ + public function getId() + { + return $this->maniaLinkId; + } - /** - * Set the Stylesheet of the ManiaLink - * - * @param Stylesheet $stylesheet Stylesheet for the ManiaLink - * @return static - */ - public function setStylesheet(Stylesheet $stylesheet) { - $this->stylesheet = $stylesheet; - return $this; - } + /** + * Set the ID + * + * @api + * @param string $maniaLinkId ManiaLink ID + * @return static + */ + public function setId($maniaLinkId) + { + $this->maniaLinkId = (string)$maniaLinkId; + if ($this->maniaLinkId && !$this->name) { + $this->setName($this->maniaLinkId); + } + return $this; + } - /** - * Get the Stylesheet of the ManiaLink - * - * @param bool $createIfEmpty (optional) Whether the Stylesheet object should be created if it's not set - * @return \FML\Stylesheet\Stylesheet - */ - public function getStylesheet($createIfEmpty = true) { - if (!$this->stylesheet && $createIfEmpty) { - $this->setStylesheet(new Stylesheet()); - } - return $this->stylesheet; - } + /** + * Get the version + * + * @api + * @return int + */ + public function getVersion() + { + return $this->version; + } - /** - * Set the Script of the ManiaLink - * - * @param Script $script Script for the ManiaLink - * @return static - */ - public function setScript(Script $script) { - $this->script = $script; - return $this; - } + /** + * Set the version + * + * @api + * @param int $version ManiaLink version + * @return static + */ + public function setVersion($version) + { + $this->version = (int)$version; + return $this; + } - /** - * Get the current Script of the ManiaLink - * - * @param bool $createIfEmpty (optional) Whether the Script object should be created if it's not set - * @return \FML\Script\Script - */ - public function getScript($createIfEmpty = true) { - if (!$this->script && $createIfEmpty) { - $this->setScript(new Script()); - } - return $this->script; - } + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Render the XML document - * - * @param bool $echo (optional) If the XML text should be echoed and the Content-Type header should be set - * @param \DOMDocument $domDocument (optional) DOMDocument for which the XML element should be created - * @return \DOMDocument - */ - public function render($echo = false, $domDocument = null) { - $isChild = (bool)$domDocument; - if (!$isChild) { - $domDocument = new \DOMDocument('1.0', $this->encoding); - $domDocument->xmlStandalone = true; - } - $maniaLink = $domDocument->createElement($this->tagName); - if (!$isChild) { - $domDocument->appendChild($maniaLink); - } - if (strlen($this->maniaLinkId) > 0) { - $maniaLink->setAttribute('id', $this->maniaLinkId); - } - if ($this->version) { - $maniaLink->setAttribute('version', $this->version); - } - if (strlen($this->background) > 0) { - $maniaLink->setAttribute('background', $this->background); - } - if (!$this->navigable3d) { - $maniaLink->setAttribute('navigable3d', $this->navigable3d); - } - if ($this->name) { - $maniaLink->setAttribute('name', $this->name); - } - if ($this->timeout) { - $timeoutXml = $domDocument->createElement('timeout', $this->timeout); - $maniaLink->appendChild($timeoutXml); - } - if ($this->dico) { - $dicoXml = $this->dico->render($domDocument); - $maniaLink->appendChild($dicoXml); - } - $scriptFeatures = array(); - foreach ($this->children as $child) { - $childXml = $child->render($domDocument, $this->getScript()); - $maniaLink->appendChild($childXml); - if ($child instanceof ScriptFeatureable) { - $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); - } - } - if ($scriptFeatures) { - $this->getScript()->loadFeatures($scriptFeatures); - } - if ($this->stylesheet) { - $stylesheetXml = $this->stylesheet->render($domDocument); - $maniaLink->appendChild($stylesheetXml); - } - if ($this->script) { - if ($this->script->needsRendering()) { - $scriptXml = $this->script->render($domDocument); - $maniaLink->appendChild($scriptXml); - } - $this->script->resetGenericScriptLabels(); - } - if ($isChild) { - return $maniaLink; - } - if ($echo) { - header('Content-Type: application/xml; charset=utf-8;'); - echo $domDocument->saveXML(); - } - return $domDocument; - } + /** + * Set the name + * + * @api + * @param string $name ManiaLink Name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the background + * + * @api + * @return string + */ + public function getBackground() + { + return $this->background; + } + + /** + * Set the background + * + * @api + * @param string $background Background value + * @return static + */ + public function setBackground($background) + { + $this->background = (string)$background; + return $this; + } + + /** + * Get navigable3d + * + * @api + * @return bool + */ + public function getNavigable3d() + { + return $this->navigable3d; + } + + /** + * Set navigable3d + * + * @api + * @param bool $navigable3d If the ManiaLink should be 3d navigable + * @return static + */ + public function setNavigable3d($navigable3d) + { + $this->navigable3d = (bool)$navigable3d; + return $this; + } + + /** + * Get the timeout + * + * @api + * @return int + */ + public function getTimeout() + { + return $this->timeout; + } + + /** + * Set the timeout + * + * @api + * @param int $timeout Timeout duration + * @return static + */ + public function setTimeout($timeout) + { + $this->timeout = (int)$timeout; + return $this; + } + + /** + * Get children + * + * @api + * @return Renderable[] + */ + public function getChildren() + { + return $this->children; + } + + /** + * Add a child + * + * @api + * @param Renderable $child Child Element to add + * @return static + * @deprecated use addChild() instead + */ + public function add(Renderable $child) + { + return $this->addChild($child); + } + + /** + * Add a child + * + * @api + * @param Renderable $child Child Element to add + * @return static + */ + public function addChild(Renderable $child) + { + if (!in_array($child, $this->children, true)) { + array_push($this->children, $child); + } + return $this; + } + + /** + * Set children + * + * @api + * @param Renderable[] $children Child Elements + * @return static + */ + public function setChildren(array $children) + { + $this->children = array(); + foreach ($children as $child) { + $this->addChild($child); + } + return $this; + } + + /** + * Remove all children + * + * @api + * @return static + * @deprecated use removeAllChildren() instead + */ + public function removeChildren() + { + return $this->removeAllChildren(); + } + + /** + * Remove all children + * + * @api + * @return static + */ + public function removeAllChildren() + { + $this->children = array(); + return $this; + } + + /** + * Get the Dictionary + * + * @api + * @return Dico + */ + public function getDico() + { + return $this->dico; + } + + /** + * Set the Dictionary + * + * @api + * @param Dico $dico Dictionary + * @return static + */ + public function setDico(Dico $dico = null) + { + $this->dico = $dico; + return $this; + } + + /** + * Get the Stylesheet + * + * @api + * @return Stylesheet + */ + public function getStylesheet() + { + return $this->stylesheet; + } + + /** + * Set the Stylesheet + * + * @api + * @param Stylesheet $stylesheet Stylesheet + * @return static + */ + public function setStylesheet(Stylesheet $stylesheet = null) + { + $this->stylesheet = $stylesheet; + return $this; + } + + /** + * Get the Script + * + * @api + * @return Script + */ + public function getScript() + { + return $this->script; + } + + /** + * Set the Script + * + * @api + * @param Script $script Script + * @return static + */ + public function setScript(Script $script = null) + { + $this->script = $script; + return $this; + } + + /** + * Create and assign a new Script if necessary + * + * @api + * @return Script + */ + public function createScript() + { + if ($this->script) { + return $this->script; + } + $script = new Script(); + $this->setScript($script); + return $this->script; + } + + /** + * Render the ManiaLink + * + * @param bool $echo (optional) If the XML text should be echoed and the Content-Type header should be set + * @param \DOMDocument $domDocument (optional) DOMDocument for which the ManiaLink should be rendered + * @return \DOMDocument + */ + public function render($echo = false, $domDocument = null) + { + $isChild = (bool)$domDocument; + if (!$isChild) { + $domDocument = new \DOMDocument("1.0", "utf-8"); + $domDocument->xmlStandalone = true; + } + $maniaLink = $domDocument->createElement("manialink"); + if (!$isChild) { + $domDocument->appendChild($maniaLink); + } + + if ($this->maniaLinkId) { + $maniaLink->setAttribute("id", $this->maniaLinkId); + } + if ($this->version > 0) { + $maniaLink->setAttribute("version", $this->version); + } + if ($this->name) { + $maniaLink->setAttribute("name", $this->name); + } + if ($this->background) { + $maniaLink->setAttribute("background", $this->background); + } + if (!$this->navigable3d) { + $maniaLink->setAttribute("navigable3d", "0"); + } + if ($this->timeout) { + $timeoutXml = $domDocument->createElement("timeout", $this->timeout); + $maniaLink->appendChild($timeoutXml); + } + if ($this->dico) { + $dicoXml = $this->dico->render($domDocument); + $maniaLink->appendChild($dicoXml); + } + + $scriptFeatures = array(); + foreach ($this->children as $child) { + $childXml = $child->render($domDocument); + $maniaLink->appendChild($childXml); + if ($child instanceof ScriptFeatureable) { + $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); + } + } + + if ($this->stylesheet) { + $stylesheetXml = $this->stylesheet->render($domDocument); + $maniaLink->appendChild($stylesheetXml); + } + + if ($scriptFeatures) { + $this->createScript() + ->loadFeatures($scriptFeatures); + } + if ($this->script) { + if ($this->script->needsRendering()) { + $scriptXml = $this->script->render($domDocument); + $maniaLink->appendChild($scriptXml); + } + $this->script->resetGenericScriptLabels(); + } + + if ($isChild) { + return $maniaLink; + } + if ($echo) { + header("Content-Type: application/xml; charset=utf-8;"); + echo $domDocument->saveXML(); + } + return $domDocument; + } + + /** + * Get the string representation + * + * @return string + */ + public function __toString() + { + return $this->render() + ->saveXML(); + } - /** - * Get string representation - * - * @return string - */ - public function __toString() { - return $this->render()->saveXML(); - } } diff --git a/libs/FML/ManiaLinks.php b/libs/FML/ManiaLinks.php index 374e21d2..44dc2cf9 100644 --- a/libs/FML/ManiaLinks.php +++ b/libs/FML/ManiaLinks.php @@ -6,119 +6,190 @@ namespace FML; * Class holding several ManiaLinks at once * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ManiaLinks { - /* - * Protected Properties - */ - protected $encoding = 'utf-8'; - protected $tagName = 'manialinks'; - /** @var ManiaLink[] $children */ - protected $children = array(); - /** @var CustomUI $customUI */ - protected $customUI = null; +class ManiaLinks +{ - /** - * Create a new ManiaLinks object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var ManiaLink[] $children ManiaLinks children + */ + protected $children = array(); - /** - * Set XML encoding - * - * @param string $encoding XML encoding - * @return static - */ - public function setXmlEncoding($encoding) { - $this->encoding = (string)$encoding; - return $this; - } + /** + * @var CustomUI $customUI Custom UI + */ + protected $customUI = null; - /** - * Add a child ManiaLink - * - * @param ManiaLink $child Child ManiaLink - * @return static - */ - public function add(ManiaLink $child) { - if (!in_array($child, $this->children, true)) { - array_push($this->children, $child); - } - return $this; - } + /** + * Create a new ManiaLinks object + * + * @api + * @param ManiaLink[] $children ManiaLink children + * @return static + */ + public static function create(array $children = null) + { + return new static($children); + } - /** - * Remove all child ManiaLinks - * - * @return static - */ - public function removeChildren() { - $this->children = array(); - return $this; - } + /** + * Construct a new ManiaLinks object + * + * @api + * @param ManiaLink[] $children ManiaLink children + */ + public function __construct(array $children = null) + { + if ($children) { + $this->setChildren($children); + } + } - /** - * Set the CustomUI - * - * @param CustomUI $customUI CustomUI object - * @return static - */ - public function setCustomUI(CustomUI $customUI) { - $this->customUI = $customUI; - return $this; - } + /** + * Get all child ManiaLinks + * + * @api + * @return ManiaLink[] + */ + public function getChildren() + { + return $this->children; + } - /** - * Get the CustomUI - * - * @param bool $createIfEmpty (optional) Whether the CustomUI object should be created if it's not set - * @return \FML\CustomUI - */ - public function getCustomUI($createIfEmpty = true) { - if (!$this->customUI && $createIfEmpty) { - $this->setCustomUI(new CustomUI()); - } - return $this->customUI; - } + /** + * Add a child ManiaLink + * + * @api + * @param ManiaLink $child Child ManiaLink + * @return static + * @deprecated use addChild() instead + */ + public function add(ManiaLink $child) + { + return $this->addChild($child); + } - /** - * Render the XML document - * - * @param bool (optional) $echo Whether the XML text should be echoed and the Content-Type header should be set - * @return \DOMDocument - */ - public function render($echo = false) { - $domDocument = new \DOMDocument('1.0', $this->encoding); - $domDocument->xmlStandalone = true; - $maniaLinks = $domDocument->createElement($this->tagName); - $domDocument->appendChild($maniaLinks); - foreach ($this->children as $child) { - $childXml = $child->render(false, $domDocument); - $maniaLinks->appendChild($childXml); - } - if ($this->customUI) { - $customUIXml = $this->customUI->render($domDocument); - $maniaLinks->appendChild($customUIXml); - } - if ($echo) { - header('Content-Type: application/xml; charset=utf-8;'); - echo $domDocument->saveXML(); - } - return $domDocument; - } + /** + * Add a child ManiaLink + * + * @api + * @param ManiaLink $child Child ManiaLink + * @return static + */ + public function addChild(ManiaLink $child) + { + if (!in_array($child, $this->children, true)) { + array_push($this->children, $child); + } + return $this; + } + + /** + * Set ManiaLink children + * + * @api + * @param ManiaLink[] $children ManiaLink children + * @return static + */ + public function setChildren(array $children) + { + $this->children = array(); + foreach ($children as $child) { + $this->addChild($child); + } + return $this; + } + + /** + * Remove all child ManiaLinks + * + * @api + * @return static + * @deprecated use removeAllChildren instead + */ + public function removeChildren() + { + return $this->removeAllChildren(); + } + + /** + * Remove all child ManiaLinks + * + * @api + * @return static + */ + public function removeAllChildren() + { + $this->children = array(); + return $this; + } + + /** + * Get the CustomUI + * + * @api + * @return CustomUI + */ + public function getCustomUI() + { + return $this->customUI; + } + + /** + * Set the CustomUI + * + * @api + * @param CustomUI $customUI CustomUI object + * @return static + */ + public function setCustomUI(CustomUI $customUI = null) + { + $this->customUI = $customUI; + return $this; + } + + /** + * Render the ManiaLinks object + * + * @param bool (optional) $echo If the XML text should be echoed and the Content-Type header should be set + * @return \DOMDocument + */ + public function render($echo = false) + { + $domDocument = new \DOMDocument("1.0", "utf-8"); + $domDocument->xmlStandalone = true; + $maniaLinks = $domDocument->createElement("manialinks"); + $domDocument->appendChild($maniaLinks); + + foreach ($this->children as $child) { + $childXml = $child->render(false, $domDocument); + $maniaLinks->appendChild($childXml); + } + + if ($this->customUI) { + $customUIElement = $this->customUI->render($domDocument); + $maniaLinks->appendChild($customUIElement); + } + + if ($echo) { + header("Content-Type: application/xml; charset=utf-8;"); + echo $domDocument->saveXML(); + } + + return $domDocument; + } + + /** + * Get string representation + * + * @return string + */ + public function __toString() + { + return $this->render() + ->saveXML(); + } - /** - * Get string representation - * - * @return string - */ - public function __toString() { - return $this->render()->saveXML(); - } } diff --git a/libs/FML/Models/CheckBoxDesign.php b/libs/FML/Models/CheckBoxDesign.php deleted file mode 100644 index eda65813..00000000 --- a/libs/FML/Models/CheckBoxDesign.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder - * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 - */ -class CheckBoxDesign implements Styleable, SubStyleable { - /* - * Protected properties - */ - protected $url = null; - protected $style = null; - protected $subStyle = null; - - /** - * Create the default enabled Design - * - * @return static - */ - public static function defaultEnabledDesign() { - return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check); - } - - /** - * Create the default disabled Design - * - * @return static - */ - public static function defaultDisabledDesign() { - return new static(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_Check); - } - - /** - * Construct a new CheckBox Design object - * - * @param string $style Style name or image url - * @param string $subStyle (optional) SubStyle name - */ - public function __construct($style, $subStyle = null) { - if ($subStyle === null) { - $this->setImageUrl($style); - } else { - $this->setStyle($style); - $this->setSubStyle($subStyle); - } - } - - /** - * Set the image url - * - * @param string $url Image url - * @return static - */ - public function setImageUrl($url) { - $this->url = (string)$url; - $this->style = null; - $this->subStyle = null; - return $this; - } - - /** - * @see \FML\Types\Styleable::setStyle() - */ - public function setStyle($style) { - $this->style = (string)$style; - $this->url = null; - return $this; - } - - /** - * @see \FML\Types\SubStyleable::setSubStyle() - */ - public function setSubStyle($subStyle) { - $this->subStyle = (string)$subStyle; - $this->url = null; - return $this; - } - - /** - * @see \FML\Types\SubStyleable::setStyles() - */ - public function setStyles($style, $subStyle) { - $this->setStyle($style); - $this->setSubStyle($subStyle); - return $this; - } - - /** - * Apply the Design to the given Quad - * - * @param Quad $quad CheckBox Quad - * @return static - */ - public function applyToQuad(Quad $quad) { - $quad->setImage($this->url); - $quad->setStyles($this->style, $this->subStyle); - return $this; - } - - /** - * Get the CheckBox Design string - * - * @param bool $escaped (optional) Whether the string should be escaped for the Script - * @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text - * @return string - */ - public function getDesignString($escaped = true, $addApostrophes = true) { - if ($this->url !== null) { - $string = $this->url; - } else { - $string = $this->style . '|' . $this->subStyle;; - } - if ($escaped) { - return Builder::escapeText($string, $addApostrophes); - } - return $string; - } -} diff --git a/libs/FML/Script/Builder.php b/libs/FML/Script/Builder.php index a1d97a00..225370d2 100644 --- a/libs/FML/Script/Builder.php +++ b/libs/FML/Script/Builder.php @@ -2,149 +2,222 @@ namespace FML\Script; +use FML\Types\Identifiable; + /** * ManiaScript Builder class * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class Builder { - /* - * Constants - */ - const EMPTY_STRING = '""'; +abstract class Builder +{ - /** - * Build a label implementation block - * - * @param string $labelName Name of the label - * @param string $implementationCode Label implementation coding (without declaration) - * @param bool $isolate Whether the code should be isolated in an own block - * @return string - */ - public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true) { - if ($isolate) { - $implementationCode = 'if(True){' . $implementationCode . '}'; - } - $labelText = PHP_EOL . "***{$labelName}***" . PHP_EOL . "***{$implementationCode}***" . PHP_EOL; - return $labelText; - } + /* + * Constants + */ + const EMPTY_STRING = '""'; - /** - * Escape dangerous characters in the given text - * - * @param string $text Text to escape - * @param bool $addApostrophes (optional) Whether to add apostrophes before and after the text - * @return string - */ - public static function escapeText($text, $addApostrophes = false) { - $dangers = array('\\', '"', "\n"); - $replacements = array('\\\\', '\\"', '\\n'); - $escapedText = str_ireplace($dangers, $replacements, $text); - if ($addApostrophes) { - $escapedText = '"' . $escapedText . '"'; - } - return $escapedText; - } + /** + * Build a script label implementation block + * + * @api + * @param string $labelName Name of the label + * @param string $implementationCode Label implementation coding (without declaration) + * @param bool $isolate (optional) If the code should be isolated in an own block + * @return string + */ + public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true) + { + if ($isolate) { + $implementationCode = "if(True){{$implementationCode}}"; + } + return " +***{$labelName}*** +***{$implementationCode}*** +"; + } - /** - * Get the 'Real' string representation of the given value - * - * @param float $value Float value to convert to a ManiaScript 'Real' - * @return string - */ - public static function getReal($value) { - $value = (float)$value; - $stringVal = (string)$value; - if (!fmod($value, 1)) { - $stringVal .= '.'; - } - return $stringVal; - } + /** + * Escape dangerous characters in the given text + * + * @api + * @param string $text Text to escape + * @param bool $addApostrophes (optional) Add apostrophes before and after the text + * @return string + */ + public static function escapeText($text, $addApostrophes = true) + { + $dangers = array('\\', '"', "\n"); + $replacements = array('\\\\', '\\"', '\\n'); + $escapedText = str_ireplace($dangers, $replacements, $text); + if ($addApostrophes) { + $escapedText = '"' . $escapedText . '"'; + } + return $escapedText; + } - /** - * Get the 'Boolean' string representation of the given value - * - * @param bool $value Value to convert to a ManiaScript 'Boolean' - * @return string - */ - public static function getBoolean($value) { - $bool = (bool)$value; - if ($bool) { - return 'True'; - } - return 'False'; - } + /** + * Get the escaped Id of the given Element + * + * @param Identifiable $element Element + * @return string + */ + public static function getId(Identifiable $element) + { + return static::escapeText($element->getId(), false); + } - /** - * Get the string representation of the given array - * - * @param array $array Array to convert to a ManiaScript array - * @param bool $associative (optional) Whether the array should be associative - * @return string - */ - public static function getArray(array $array, $associative = false) { - $arrayText = '['; - $index = 0; - $count = count($array); - foreach ($array as $key => $value) { - if ($associative) { - if (is_string($key)) { - $arrayText .= '"' . static::escapeText($key) . '"'; - } else { - $arrayText .= $key; - } - $arrayText .= ' => '; - } - if (is_string($value)) { - $arrayText .= '"' . static::escapeText($value) . '"'; - } else { - $arrayText .= $value; - } - if ($index < $count - 1) { - $arrayText .= ', '; - $index++; - } - } - $arrayText .= ']'; - return $arrayText; - } + /** + * Get the 'Real' string representation of the given value + * + * @api + * @param float $value Float value to convert to a ManiaScript 'Real' + * @return string + */ + public static function getReal($value) + { + $value = (float)$value; + $stringVal = (string)$value; + if (!fmod($value, 1)) { + $stringVal .= "."; + } + return $stringVal; + } - /** - * Get the include command for the given file and namespace - * - * @param string $file Include file - * @param string $namespace (optional) Include namespace - * @return string - */ - public static function getInclude($file, $namespace = null) { - if (!$namespace && stripos($file, '.') === false) { - $namespace = $file; - } - $file = static::escapeText($file, true); - $includeText = "#Include {$file}"; - if ($namespace) { - $includeText .= " as {$namespace}"; - } - $includeText .= PHP_EOL; - return $includeText; - } + /** + * Get the 'Boolean' string representation of the given value + * + * @api + * @param bool $value Value to convert to a ManiaScript 'Boolean' + * @return string + */ + public static function getBoolean($value) + { + $bool = (bool)$value; + if ($bool) { + return "True"; + } + return "False"; + } + + /** + * Get the Vec3 representation for the given values + * + * @api + * @param float|float[] $valueX Value X + * @param float $valueY (optional) Value Y + * @return string + */ + public static function getVec2($valueX, $valueY = null) + { + if (is_array($valueX)) { + $valueY = (isset($valueX[1]) ? $valueX[1] : 0.); + $valueX = (isset($valueX[0]) ? $valueX[0] : 0.); + } + return "<" . static::getReal($valueX) . "," . static::getReal($valueY) . ">"; + } + + /** + * Get the Vec3 representation for the given values + * + * @api + * @param float|float[] $valueX Value X + * @param float $valueY (optional) Value Y + * @param float $valueZ (optional) Value Z + * @return string + */ + public static function getVec3($valueX, $valueY = null, $valueZ = null) + { + if (is_array($valueX)) { + $valueZ = (isset($valueX[2]) ? $valueX[2] : 0.); + $valueY = (isset($valueX[1]) ? $valueX[1] : 0.); + $valueX = (isset($valueX[0]) ? $valueX[0] : 0.); + } + return "<" . static::getReal($valueX) . "," . static::getReal($valueY) . "," . static::getReal($valueZ) . ">"; + } + + /** + * Get the string representation of the given array + * + * @api + * @param array $array Array to convert to a ManiaScript array + * @param bool $associative (optional) Whether the array should be associative + * @return string + */ + public static function getArray(array $array, $associative = false) + { + $arrayText = "["; + $index = 0; + $count = count($array); + foreach ($array as $key => $value) { + if ($associative) { + $arrayText .= static::getValue($key); + $arrayText .= " => "; + } + $arrayText .= static::getValue($value); + if ($index < $count - 1) { + $arrayText .= ", "; + $index++; + } + } + return $arrayText . "]"; + } + + /** + * Get the string representation for the given value + * + * @api + * @param mixed $value Value + * @return string + */ + public static function getValue($value) + { + if (is_string($value)) { + return static::escapeText($value); + } + if (is_bool($value)) { + return static::getBoolean($value); + } + return $value; + } + + /** + * Get the include command for the given file and namespace + * + * @api + * @param string $file Include file + * @param string $namespace (optional) Include namespace + * @return string + */ + public static function getInclude($file, $namespace = null) + { + if (!$namespace && stripos($file, ".") === false) { + $namespace = $file; + } + $file = static::escapeText($file); + $includeText = "#Include {$file}"; + if ($namespace) { + $includeText .= " as {$namespace}"; + } + return $includeText . " +"; + } + + /** + * Get the constant command for the given name and value + * + * @api + * @param string $name Constant name + * @param string $value Constant value + * @return string + */ + public static function getConstant($name, $value) + { + $value = static::getValue($value); + return "#Const {$name} {$value} +"; + } - /** - * Get the constant command for the given name and value - * - * @param string $name Constant name - * @param string $value Constant value - * @return string - */ - public static function getConstant($name, $value) { - if (is_string($value)) { - $value = static::escapeText($value, true); - } else if (is_bool($value)) { - $value = static::getBoolean($value); - } - $constantText = "#Const {$name} {$value}" . PHP_EOL; - return $constantText; - } } diff --git a/libs/FML/Script/Features/ActionTrigger.php b/libs/FML/Script/Features/ActionTrigger.php index 32aa2d6a..fc6b393b 100644 --- a/libs/FML/Script/Features/ActionTrigger.php +++ b/libs/FML/Script/Features/ActionTrigger.php @@ -9,104 +9,159 @@ use FML\Script\ScriptLabel; use FML\Types\Scriptable; /** - * Script Feature for triggering a manialink page action + * Script Feature for triggering a ManiaLink page action * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ActionTrigger extends ScriptFeature { - /* - * Protected properties - */ - protected $actionName = null; - /** @var Control $control */ - protected $control = null; - protected $labelName = null; +class ActionTrigger extends ScriptFeature +{ - /** - * Construct a new Action Trigger Feature - * - * @param string $actionName (optional) Triggered action - * @param Control $control (optional) Action Control - * @param string $labelName (optional) Script Label name - */ - public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) { - if ($actionName !== null) { - $this->setActionName($actionName); - } - if ($control !== null) { - $this->setControl($control); - } - if ($labelName !== null) { - $this->setLabelName($labelName); - } - } + /** + * @var string $actionName Triggered action + */ + protected $actionName = null; - /** - * Set the action to trigger - * - * @param string $actionName - * @return static - */ - public function setActionName($actionName) { - $this->actionName = (string)$actionName; - return $this; - } + /** + * @var Control $control Action Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Action Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var string $labelName Script label name + */ + protected $labelName = null; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * Construct a new Action Trigger + * + * @api + * @param string $actionName (optional) Triggered action + * @param Control $control (optional) Action Control + * @param string $labelName (optional) Script label name + */ + public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) + { + if ($actionName) { + $this->setActionName($actionName); + } + if ($control) { + $this->setControl($control); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the action to trigger + * + * @api + * @return string + */ + public function getActionName() + { + return $this->actionName; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $actionName = Builder::escapeText($this->actionName, true); - if ($this->control) { - // Control event - $controlId = Builder::escapeText($this->control->getId(), true); - $scriptText = " + /** + * Set the action to trigger + * + * @api + * @param string $actionName Action name + * @return static + */ + public function setActionName($actionName) + { + $this->actionName = (string)$actionName; + return $this; + } + + /** + * Get the Control that should trigger the action + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the Control that should trigger the action + * + * @api + * @param Control $control Action Control + * @return static + */ + public function setControl(Control $control = null) + { + if ($control) { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + } + $this->control = $control; + return $this; + } + + /** + * Get the script label name + * + * @api + * @return string + */ + public function getLabelName() + { + return $this->labelName; + } + + /** + * Set the script label name + * + * @api + * @param string $labelName Script Label name + * @return static + */ + public function setLabelName($labelName) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $actionName = Builder::escapeText($this->actionName); + if ($this->control) { + // Control event + $controlId = Builder::escapeText($this->control->getId()); + $scriptText = " if (Event.Control.ControlId == {$controlId}) { TriggerPageAction({$actionName}); }"; - } else { - // Other - $scriptText = " + } else { + // Other + $scriptText = " TriggerPageAction({$actionName});"; - } - return $scriptText; - } + } + return $scriptText; + } + } diff --git a/libs/FML/Script/Features/CheckBoxFeature.php b/libs/FML/Script/Features/CheckBoxFeature.php index b4fa40fd..8e57bda0 100644 --- a/libs/FML/Script/Features/CheckBoxFeature.php +++ b/libs/FML/Script/Features/CheckBoxFeature.php @@ -2,9 +2,9 @@ namespace FML\Script\Features; +use FML\Components\CheckBoxDesign; use FML\Controls\Entry; use FML\Controls\Quad; -use FML\Models\CheckBoxDesign; use FML\Script\Builder; use FML\Script\Script; use FML\Script\ScriptInclude; @@ -14,145 +14,213 @@ use FML\Script\ScriptLabel; * Script Feature for creating a CheckBox behavior * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CheckBoxFeature extends ScriptFeature { - /* - * Constants - */ - const FUNCTION_UPDATE_QUAD_DESIGN = 'FML_UpdateQuadDesign'; - const VAR_CHECKBOX_ENABLED = 'FML_CheckBox_Enabled'; - const VAR_CHECKBOX_DESIGNS = 'FML_CheckBox_Designs'; - const VAR_CHECKBOX_ENTRY_ID = 'FML_CheckBox_EntryId'; +class CheckBoxFeature extends ScriptFeature +{ - /* - * Protected properties - */ - /** @var Quad $quad */ - protected $quad = null; - /** @var Entry $entry */ - protected $entry = null; - protected $default = null; - /** @var CheckBoxDesign $enabledDesign */ - protected $enabledDesign = null; - /** @var CheckBoxDesign $disabledDesign */ - protected $disabledDesign = null; + /* + * Constants + */ + const FUNCTION_UPDATE_QUAD_DESIGN = "FML_UpdateQuadDesign"; + const VAR_CHECKBOX_ENABLED = "FML_CheckBox_Enabled"; + const VAR_CHECKBOX_DESIGNS = "FML_CheckBox_Designs"; + const VAR_CHECKBOX_ENTRY_ID = "FML_CheckBox_EntryId"; - /** - * Construct a new CheckBox Feature - * - * @param Quad $quad (optional) CheckBox Quad - * @param Entry $entry (optional) Hidden Entry - * @param bool $default (optional) Default value - */ - public function __construct(Quad $quad = null, Entry $entry = null, $default = null) { - if ($quad !== null) { - $this->setQuad($quad); - } - if ($entry !== null) { - $this->setEntry($entry); - } - if ($default !== null) { - $this->setDefault($default); - } - $this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign()); - $this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign()); - } + /** + * @var Quad $quad CheckBox Quad + */ + protected $quad = null; - /** - * Set the CheckBox Quad - * - * @param Quad $quad CheckBox Quad - * @return static - */ - public function setQuad(Quad $quad) { - $this->quad = $quad->checkId()->setScriptEvents(true); - return $this; - } + /** + * @var Entry $entry Hidden Entry for submitting the value + */ + protected $entry = null; - /** - * Get the CheckBox Quad - * - * @return \FML\Controls\Quad - */ - public function getQuad() { - return $this->quad; - } + /** + * @var bool $default Default value + */ + protected $default = null; - /** - * Set the CheckBox Entry - * - * @param Entry $entry CheckBox Entry - * @return static - */ - public function setEntry(Entry $entry) { - $this->entry = $entry->checkId(); - return $this; - } + /** + * @var CheckBoxDesign $enabledDesign Enabled Design + */ + protected $enabledDesign = null; - /** - * Get the managed Entry - * - * @return \FML\Controls\Entry - */ - public function getEntry() { - return $this->entry; - } + /** + * @var CheckBoxDesign $disabledDesign Disabled Design + */ + protected $disabledDesign = null; - /** - * Set the default value - * - * @param bool $default Default value - * @return static - */ - public function setDefault($default) { - $this->default = (bool)$default; - return $this; - } + /** + * Construct a new CheckBox Feature + * + * @api + * @param Quad $quad (optional) CheckBox Quad + * @param Entry $entry (optional) Hidden Entry + * @param bool $default (optional) Default value + */ + public function __construct(Quad $quad = null, Entry $entry = null, $default = null) + { + if ($quad) { + $this->setQuad($quad); + } + if ($entry) { + $this->setEntry($entry); + } + if ($default !== null) { + $this->setDefault($default); + } + $this->setEnabledDesign(CheckBoxDesign::defaultDesign()); + $this->setDisabledDesign(CheckBoxDesign::defaultDesign()); + } - /** - * Set the enabled Design - * - * @param CheckBoxDesign $checkBoxDesign Enabled CheckBox Design - * @return static - */ - public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) { - $this->enabledDesign = $checkBoxDesign; - return $this; - } + /** + * Get the CheckBox Quad + * + * @api + * @return Quad + */ + public function getQuad() + { + return $this->quad; + } - /** - * Set the disabled Design - * - * @param CheckBoxDesign $checkBoxDesign Disabled CheckBox Design - * @return static - */ - public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) { - $this->disabledDesign = $checkBoxDesign; - return $this; - } + /** + * Set the CheckBox Quad + * + * @api + * @param Quad $quad CheckBox Quad + * @return static + */ + public function setQuad(Quad $quad) + { + $quad->checkId(); + $quad->setScriptEvents(true); + $this->quad = $quad; + return $this; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - if ($this->getQuad()) { - $script->setScriptInclude(ScriptInclude::TEXTLIB); - $script->addScriptFunction(self::FUNCTION_UPDATE_QUAD_DESIGN, $this->buildUpdateQuadDesignFunction()); - $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true); - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText()); - } - return $this; - } + /** + * Get the hidden Entry + * + * @api + * @return Entry + */ + public function getEntry() + { + return $this->entry; + } - /** - * Build the function text - * - * @return string - */ - protected function buildUpdateQuadDesignFunction() { - return " + /** + * Set the hidden Entry + * + * @api + * @param Entry $entry Hidden Entry + * @return static + */ + public function setEntry(Entry $entry) + { + $entry->checkId(); + $this->entry = $entry; + return $this; + } + + /** + * Get the default value + * + * @api + * @return bool + */ + public function getDefault() + { + return $this->default; + } + + /** + * Set the default value + * + * @api + * @param bool $default Default value + * @return static + */ + public function setDefault($default) + { + $this->default = (bool)$default; + return $this; + } + + /** + * Get the enabled Design + * + * @api + * @return CheckBoxDesign + */ + public function getEnabledDesign() + { + return $this->enabledDesign; + } + + /** + * Set the enabled Design + * + * @api + * @param CheckBoxDesign $checkBoxDesign Enabled CheckBox Design + * @return static + */ + public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) + { + $this->enabledDesign = $checkBoxDesign; + return $this; + } + + /** + * Get the disabled Design + * + * @api + * @return CheckBoxDesign + */ + public function getDisabledDesign() + { + return $this->disabledDesign; + } + + /** + * Set the disabled Design + * + * @api + * @param CheckBoxDesign $checkBoxDesign Disabled CheckBox Design + * @return static + */ + public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) + { + $this->disabledDesign = $checkBoxDesign; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + if ($this->getQuad()) { + $script->setScriptInclude(ScriptInclude::TEXTLIB); + $script->addScriptFunction(self::FUNCTION_UPDATE_QUAD_DESIGN, $this->buildUpdateQuadDesignFunction()); + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true); + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText()); + } + return $this; + } + + /** + * Build the function text + * + * @return string + */ + protected function buildUpdateQuadDesignFunction() + { + return " Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) { declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True; Enabled = !Enabled; @@ -160,62 +228,69 @@ Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) { declare " . self::VAR_CHECKBOX_DESIGNS . " as Designs for _Quad = Text[Boolean]; declare Design = Designs[Enabled]; declare DesignParts = TextLib::Split(\"|\", Design); - if (DesignParts.count > 1) { + if (DesignParts.count == 2) { _Quad.Style = DesignParts[0]; _Quad.Substyle = DesignParts[1]; } else { _Quad.ImageUrl = Design; } - declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = " . Builder::EMPTY_STRING . "; - if (EntryId != " . Builder::EMPTY_STRING . ") { - declare Value = \"0\"; - if (Enabled) { - Value = \"1\"; - } + declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = \"\"; + if (EntryId != \"\") { declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry); - Entry.Value = Value; + if (Entry != Null) { + if (Enabled) { + Entry.Value = \"1\"; + } else { + Entry.Value = \"0\"; + } + } } }"; - } + } - /** - * Build the init script text - * - * @return string - */ - protected function buildInitScriptText() { - $quadId = $this->getQuad()->getId(true, true); - $entryId = '""'; - if ($this->entry) { - $entryId = $this->entry->getId(true, true); - } - $default = Builder::getBoolean($this->default); - $enabledDesignString = $this->enabledDesign->getDesignString(); - $disabledDesignString = $this->disabledDesign->getDesignString(); - return " -declare Quad_CheckBox <=> (Page.GetFirstChild({$quadId}) as CMlQuad); + /** + * Build the init script text + * + * @return string + */ + protected function buildInitScriptText() + { + $quadId = Builder::getId($this->getQuad()); + $entryId = Builder::EMPTY_STRING; + if ($this->entry) { + $entryId = Builder::getId($this->getEntry()); + } + + $default = Builder::getBoolean($this->default); + $enabledDesignString = $this->enabledDesign->getDesignString(); + $disabledDesignString = $this->disabledDesign->getDesignString(); + + return " +declare Quad_CheckBox <=> (Page.GetFirstChild(\"{$quadId}\") as CMlQuad); declare Text[Boolean] " . self::VAR_CHECKBOX_DESIGNS . " as Designs for Quad_CheckBox; -Designs[True] = {$enabledDesignString}; -Designs[False] = {$disabledDesignString}; +Designs[True] = \"{$enabledDesignString}\"; +Designs[False] = \"{$disabledDesignString}\"; declare Boolean " . self::VAR_CHECKBOX_ENABLED . " as Enabled for Quad_CheckBox; Enabled = !{$default}; declare Text " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for Quad_CheckBox; -EntryId = {$entryId}; +EntryId = \"{$entryId}\"; " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox); "; - } + } - /** - * Build the script text for Quad clicks - * - * @return string - */ - protected function buildClickScriptText() { - $quadId = $this->getQuad()->getId(true, true); - return " -if (Event.ControlId == {$quadId}) { + /** + * Build the script text for Quad clicks + * + * @return string + */ + protected function buildClickScriptText() + { + $quadId = Builder::getId($this->getQuad()); + return " +if (Event.ControlId == \"{$quadId}\") { declare Quad_CheckBox <=> (Event.Control as CMlQuad); " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox); }"; - } + } + } diff --git a/libs/FML/Script/Features/Clock.php b/libs/FML/Script/Features/Clock.php index 2efd528c..92b25302 100644 --- a/libs/FML/Script/Features/Clock.php +++ b/libs/FML/Script/Features/Clock.php @@ -3,6 +3,7 @@ namespace FML\Script\Features; use FML\Controls\Label; +use FML\Script\Builder; use FML\Script\Script; use FML\Script\ScriptInclude; use FML\Script\ScriptLabel; @@ -11,95 +12,149 @@ use FML\Script\ScriptLabel; * Script Feature showing the current time on a Label * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Clock extends ScriptFeature { - /* - * Protected properties - */ - /** @var Label $label */ - protected $label = null; - protected $showSeconds = null; - protected $showFullDate = null; +class Clock extends ScriptFeature +{ - /** - * Construct a new Clock Feature - * - * @param Label $label (optional) Clock Label - * @param bool $showSeconds (optional) Whether the seconds should be shown - * @param bool $showFullDate (optional) Whether the date should be shown - */ - public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) { - if ($label !== null) { - $this->setLabel($label); - } - $this->setShowSeconds($showSeconds); - $this->setShowFullDate($showFullDate); - } + /** + * @var Label $label Clock Label + */ + protected $label = null; - /** - * Set the Label - * - * @param Label $label Clock Label - * @return static - */ - public function setLabel(Label $label) { - $this->label = $label->checkId(); - return $this; - } + /** + * @var bool $showSeconds Show the seconds + */ + protected $showSeconds = null; - /** - * Set whether seconds should be shown - * - * @param bool $showSeconds Whether seconds should be shown - * @return static - */ - public function setShowSeconds($showSeconds) { - $this->showSeconds = (bool)$showSeconds; - return $this; - } + /** + * @var bool $showFullDate Show the date + */ + protected $showFullDate = null; - /** - * Set whether the full date should be shown - * - * @param bool $showFullDate Whether the full date should be shown - * @return static - */ - public function setShowFullDate($showFullDate) { - $this->showFullDate = (bool)$showFullDate; - return $this; - } + /** + * Construct a new Clock + * + * @api + * @param Label $label (optional) Clock Label + * @param bool $showSeconds (optional) Show the seconds + * @param bool $showFullDate (optional) Show the date + */ + public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) + { + if ($label) { + $this->setLabel($label); + } + $this->setShowSeconds($showSeconds) + ->setShowFullDate($showFullDate); + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->setScriptInclude(ScriptInclude::TEXTLIB); - $script->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true); - return $this; - } + /** + * Get the Label + * + * @api + * @return Label + */ + public function getLabel() + { + return $this->label; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $controlId = $this->label->getId(true, true); - $scriptText = " + /** + * Set the Label + * + * @api + * @param Label $label Clock Label + * @return static + */ + public function setLabel(Label $label) + { + $label->checkId(); + $this->label = $label; + return $this; + } + + /** + * Get if seconds should be shown + * + * @api + * @return bool + */ + public function getShowSeconds() + { + return $this->showSeconds; + } + + /** + * Set if seconds should be shown + * + * @api + * @param bool $showSeconds If seconds should be shown + * @return static + */ + public function setShowSeconds($showSeconds) + { + $this->showSeconds = (bool)$showSeconds; + return $this; + } + + /** + * Get if the full date should be shown + * + * @api + * @return bool + */ + public function getShowFullDate() + { + return $this->showFullDate; + } + + /** + * Set if the full date should be shown + * + * @api + * @param bool $showFullDate If the full date should be shown + * @return static + */ + public function setShowFullDate($showFullDate) + { + $this->showFullDate = (bool)$showFullDate; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->setScriptInclude(ScriptInclude::TEXTLIB) + ->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $controlId = Builder::escapeText($this->label->getId()); + $scriptText = " declare ClockLabel <=> (Page.GetFirstChild({$controlId}) as CMlLabel); declare TimeText = CurrentLocalDateText;"; - if (!$this->showSeconds) { - $scriptText .= " + if (!$this->showSeconds) { + $scriptText .= " TimeText = TextLib::SubText(TimeText, 0, 16);"; - } - if (!$this->showFullDate) { - $scriptText .= " + } + if (!$this->showFullDate) { + $scriptText .= " TimeText = TextLib::SubText(TimeText, 11, 9);"; - } - $scriptText .= " + } + $scriptText .= " ClockLabel.Value = TimeText;"; - return $scriptText; - } + return $scriptText; + } + } diff --git a/libs/FML/Script/Features/ControlScript.php b/libs/FML/Script/Features/ControlScript.php index 30f5782b..1bd2ab29 100644 --- a/libs/FML/Script/Features/ControlScript.php +++ b/libs/FML/Script/Features/ControlScript.php @@ -3,6 +3,7 @@ namespace FML\Script\Features; use FML\Controls\Control; +use FML\Script\Builder; use FML\Script\Script; use FML\Script\ScriptLabel; use FML\Types\Scriptable; @@ -11,115 +12,179 @@ use FML\Types\Scriptable; * Script Feature for a Control related script * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ControlScript extends ScriptFeature { - /* - * Protected properties - */ - /** @var Control $control */ - protected $control = null; - protected $labelName = null; - protected $text = null; +class ControlScript extends ScriptFeature +{ - /** - * Construct a new Control Script - * - * @param Control $control Event Control - * @param string $text Script text - * @param string $labelName (optional) Script Label name - */ - public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK) { - $this->setControl($control); - $this->setText($text); - $this->setLabelName($labelName); - } + /** + * @var Control $control Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Event Control - * @return static - */ - public function setControl(Control $control) { - $this->control = $control->checkId(); - $this->updateScriptEvents(); - return $this; - } + /** + * @var string $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the script text - * - * @param string $text Script text - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * @var string $scriptText Script text + */ + protected $scriptText = null; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - $this->updateScriptEvents(); - return $this; - } + /** + * Construct a new Control Script + * + * @api + * @param Control $control (optional) Control + * @param string $scriptText (optional) Script text + * @param string $labelName (optional) Script Label name + */ + public function __construct(Control $control = null, $scriptText = null, $labelName = ScriptLabel::MOUSECLICK) + { + if ($control) { + $this->setControl($control); + } + if ($scriptText) { + $this->setScriptText($scriptText); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * Enable Script Events on the Control if needed - */ - protected function updateScriptEvents() { - if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) { - return; - } - if ($this->control instanceof Scriptable) { - $this->control->setScriptEvents(true); - } - } + /** + * Get the Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $isolated = !ScriptLabel::isEventLabel($this->labelName); - $script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), $isolated); - return $this; - } + /** + * Set the Control + * + * @api + * @param Control $control Control + * @return static + */ + public function setControl(Control $control) + { + $control->checkId(); + $this->control = $control; + $this->updateScriptEvents(); + return $this; + } + + /** + * Get the script text + * + * @api + * @return string + */ + public function getScriptText() + { + return $this->scriptText; + } + + /** + * Set the script text + * + * @api + * @param string $scriptText Script text + * @return static + */ + public function setScriptText($scriptText) + { + $this->scriptText = (string)$scriptText; + return $this; + } + + /** + * Get the Script Label name + * + * @api + * @return string + */ + public function getLabelName() + { + return $this->labelName; + } + + /** + * Set the Script Label name + * + * @api + * @param string $labelName Script Label name + * @return static + */ + public function setLabelName($labelName) + { + $this->labelName = (string)$labelName; + $this->updateScriptEvents(); + return $this; + } + + /** + * Enable Script Events on the Control if needed + * + * @return static + */ + protected function updateScriptEvents() + { + if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) { + return $this; + } + if ($this->control instanceof Scriptable) { + $this->control->setScriptEvents(true); + } + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $isolated = !ScriptLabel::isEventLabel($this->labelName); + $script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), $isolated); + return $this; + } + + /** + * Build the script text for the Control + * + * @return string + */ + protected function buildScriptText() + { + $controlId = Builder::escapeText($this->control->getId()); + $scriptText = ''; + $closeBlock = false; + if (ScriptLabel::isEventLabel($this->labelName)) { + $scriptText .= " +if (Event.ControlId == {$controlId}) { +declare Control <=> Event.Control;"; + $closeBlock = true; + } else { + $scriptText .= " +declare Control <=> Page.GetFirstChild({$controlId});"; + } + $class = $this->control->getManiaScriptClass(); + $name = preg_replace('/^CMl/', '', $class, 1); + $scriptText .= " +declare {$name} <=> (Control as {$class}); +"; + $scriptText .= $this->scriptText . " +"; + if ($closeBlock) { + $scriptText .= "}"; + } + return $scriptText; + } - /** - * Build the script text for the Control - * - * @return string - */ - protected function buildScriptText() { - $controlId = $this->control->getId(true); - $scriptText = ''; - $closeBlock = false; - if (ScriptLabel::isEventLabel($this->labelName)) { - $scriptText .= ' -if (Event.ControlId == "' . $controlId . '") { -declare Control <=> Event.Control;'; - $closeBlock = true; - } else { - $scriptText .= ' -declare Control <=> Page.GetFirstChild("' . $controlId . '");'; - } - $class = $this->control->getManiaScriptClass(); - $name = preg_replace('/^CMl/', '', $class, 1); - $scriptText .= ' -declare ' . $name . ' <=> (Control as ' . $class . '); -'; - $scriptText .= $this->text . ' -'; - if ($closeBlock) { - $scriptText .= '}'; - } - return $scriptText; - } } diff --git a/libs/FML/Script/Features/EntrySubmit.php b/libs/FML/Script/Features/EntrySubmit.php index 4ae21094..a1842204 100644 --- a/libs/FML/Script/Features/EntrySubmit.php +++ b/libs/FML/Script/Features/EntrySubmit.php @@ -12,90 +12,131 @@ use FML\Script\ScriptLabel; * Script Feature for submitting an Entry * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class EntrySubmit extends ScriptFeature { - /* - * Protected properties - */ - /** @var Entry $entry */ - protected $entry = null; - protected $url = null; +class EntrySubmit extends ScriptFeature +{ - /** - * Construct a new Entry Submit Feature - * - * @param Entry $entry (optional) Entry Control - * @param string $url (optional) Submit url - */ - public function __construct(Entry $entry = null, $url = null) { - if ($entry !== null) { - $this->setEntry($entry); - } - $this->setUrl($url); - } + /** + * @var Entry $entry Entry + */ + protected $entry = null; - /** - * Set the Entry - * - * @param Entry $entry Entry Control - * @return static - */ - public function setEntry(Entry $entry) { - $this->entry = $entry->checkId()->setScriptEvents(true); - return $this; - } + /** + * @var string $url Sumit url + */ + protected $url = null; - /** - * Set the submit url - * - * @param string $url Submit url - * @return static - */ - public function setUrl($url) { - $this->url = (string)$url; - return $this; - } + /** + * Construct a new Entry Submit + * + * @api + * @param Entry $entry (optional) Entry Control + * @param string $url (optional) Submit url + */ + public function __construct(Entry $entry = null, $url = null) + { + if ($entry) { + $this->setEntry($entry); + } + if ($url) { + $this->setUrl($url); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->setScriptInclude(ScriptInclude::TEXTLIB); - $controlScript = new ControlScript($this->entry, $this->getScriptText(), ScriptLabel::ENTRYSUBMIT); - $controlScript->prepare($script); - return $this; - } + /** + * Get the Entry + * + * @api + * @return Entry + */ + public function getEntry() + { + return $this->entry; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $url = $this->buildCompatibleUrl(); - $entryName = $this->entry->getName(); - $link = Builder::escapeText($entryName . $url . '=', true); - return " + /** + * Set the Entry + * + * @api + * @param Entry $entry Entry Control + * @return static + */ + public function setEntry(Entry $entry) + { + $entry->setScriptEvents(true) + ->checkId(); + $this->entry = $entry; + return $this; + } + + /** + * Get the submit url + * + * @api + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the submit url + * + * @api + * @param string $url Submit url + * @return static + */ + public function setUrl($url) + { + $this->url = (string)$url; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->setScriptInclude(ScriptInclude::TEXTLIB); + $controlScript = new ControlScript($this->entry, $this->getScriptText(), ScriptLabel::ENTRYSUBMIT); + $controlScript->prepare($script); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $url = $this->buildCompatibleUrl(); + $entryName = $this->entry->getName(); + $link = Builder::escapeText($entryName . $url . "="); + return " declare Value = TextLib::URLEncode(Entry.Value); OpenLink({$link}^Value, CMlScript::LinkType::Goto); "; - } + } + + /** + * Build the submit url compatible for the Entry parameter + * + * @return string + */ + protected function buildCompatibleUrl() + { + $url = $this->url; + $paramsBegin = stripos($url, '?'); + if (!is_int($paramsBegin) || $paramsBegin < 0) { + $url .= '?'; + } else { + $url .= '&'; + } + return $url; + } - /** - * Build the submit url compatible for the Entry parameter - * - * @return string - */ - protected function buildCompatibleUrl() { - $url = $this->url; - $paramsBegin = stripos($url, '?'); - if (!is_int($paramsBegin) || $paramsBegin < 0) { - $url .= '?'; - } else { - $url .= '&'; - } - return $url; - } } diff --git a/libs/FML/Script/Features/GraphCurve.php b/libs/FML/Script/Features/GraphCurve.php new file mode 100644 index 00000000..5dad1ab9 --- /dev/null +++ b/libs/FML/Script/Features/GraphCurve.php @@ -0,0 +1,303 @@ +setGraph($graph); + } + if ($points) { + $this->setPoints($points); + } + } + + /** + * Get the Graph + * + * @api + * @return Graph + */ + public function getGraph() + { + return $this->graph; + } + + /** + * Set the Graph + * + * @api + * @param Graph $graph Graph + * @return static + */ + public function setGraph(Graph $graph) + { + $graph->checkId(); + $this->graph = $graph; + return $this; + } + + /** + * Get the points + * + * @api + * @return array[] + */ + public function getPoints() + { + return $this->points; + } + + /** + * Add point + * + * @api + * @param float|float[] $coordX X-coordinate or point + * @param float $coordY (optional) Y-coordinate + * @return static + */ + public function addPoint($coordX, $coordY = null) + { + if (is_array($coordX)) { + $coordY = (isset($coordX[1]) ? $coordX[1] : 0.); + $coordX = (isset($coordX[0]) ? $coordX[0] : 0.); + } + array_push($this->points, array($coordX, $coordY)); + return $this; + } + + /** + * Add points + * + * @api + * @param array[] $points Points + * @return static + */ + public function addPoints(array $points) + { + foreach ($points as $point) { + $this->addPoint($point); + } + return $this; + } + + /** + * Set the points + * + * @api + * @param array[] $points Points + * @return static + */ + public function setPoints(array $points) + { + return $this->removeAllPoints() + ->addPoints($points); + } + + /** + * Remove all points + * + * @api + * @return static + */ + public function removeAllPoints() + { + $this->points = array(); + return $this; + } + + /** + * Get if point should be sorted + * + * @api + * @return bool + */ + public function getSortPoints() + { + return $this->sortPoints; + } + + /** + * Set if point should be sorted + * + * @api + * @param bool $sortPoints If point should be sorted + * @return static + */ + public function setSortPoints($sortPoints) + { + $this->sortPoints = (bool)$sortPoints; + return $this; + } + + /** + * Get the color + * + * @api + * @return float[] + */ + public function getColor() + { + return $this->color; + } + + /** + * Set the color + * + * @api + * @param float[] $color (optional) Color + * @return static + */ + public function setColor(array $color = null) + { + $this->color = $color; + return $this; + } + + /** + * Get the style + * + * @api + * @return string + */ + public function getStyle() + { + return $this->style; + } + + /** + * Set the style + * + * @api + * @return static + */ + public function setStyle($style) + { + $this->style = (string)$style; + return $this; + } + + /** + * Get the width + * + * @api + * @return float + */ + public function getWidth() + { + return $this->width; + } + + /** + * Set the width + * + * @api + * @return static + */ + public function setWidth($width) + { + $this->width = (float)$width; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->getScriptText(), true); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $graphId = Builder::escapeText($this->graph->getId(), false); + $scriptText = " +declare Graph <=> (Page.GetFirstChild(\"{$graphId}\") as CMlGraph); +if (Graph != Null) { + declare GraphCurve <=> Graph.AddCurve(); +"; + foreach ($this->points as $point) { + $pointVec2 = Builder::getVec2($point); + $scriptText .= " +GraphCurve.Points.add({$pointVec2});"; + } + if ($this->sortPoints) { + $scriptText .= " +GraphCurve.SortPoints();"; + } + if ($this->color) { + $colorVec3 = Builder::getVec3($this->color); + $scriptText .= " +GraphCurve.Color = {$colorVec3};"; + } + if ($this->style) { + $scriptText .= " +GraphCurve.Style = {$this->style};"; + } + if ($this->width > 0) { + $scriptText .= " +GraphCurve.Width = {$this->width};"; + } + return $scriptText . " +}"; + } + +} diff --git a/libs/FML/Script/Features/KeyAction.php b/libs/FML/Script/Features/KeyAction.php index c5d5e6aa..f51f0524 100644 --- a/libs/FML/Script/Features/KeyAction.php +++ b/libs/FML/Script/Features/KeyAction.php @@ -11,114 +11,185 @@ use FML\Script\ScriptLabel; * * @author steeffeen * @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class KeyAction extends ScriptFeature { - /* - * Protected properties - */ - protected $actionName = null; - protected $keyName = null; - protected $keyCode = null; - protected $charPressed = null; +class KeyAction extends ScriptFeature +{ - /** - * Construct a new Key Action Feature - * - * @param string $actionName (optional) Triggered action - * @param string $keyName (optional) Key name - */ - public function __construct($actionName = null, $keyName = null) { - if ($actionName !== null) { - $this->setActionName($actionName); - } - if ($keyName !== null) { - $this->setKeyName($keyName); - } - } + /** + * @var string $actionName Action name + */ + protected $actionName = null; - /** - * Set the action to trigger - * - * @param string $actionName Triggered action - * @return static - */ - public function setActionName($actionName) { - $this->actionName = (string)$actionName; - return $this; - } + /** + * @var string $keyName Key name + */ + protected $keyName = null; - /** - * Set the key name for triggering the action - * - * @param string $keyName Key Name - * @return static - */ - public function setKeyName($keyName) { - $this->keyName = (string)$keyName; - $this->keyCode = null; - $this->charPressed = null; - return $this; - } + /** + * @var int $keyCode Key code + */ + protected $keyCode = null; - /** - * Set the key code for triggering the action - * - * @param int $keyCode Key Code - * @return static - */ - public function setKeyCode($keyCode) { - $this->keyCode = (int)$keyCode; - $this->keyName = null; - $this->charPressed = null; - return $this; - } + /** + * @var string $charPressed Pressed character + */ + protected $charPressed = null; - /** - * Set the char to press for triggering the action - * - * @param string $charPressed Pressed char - * @return static - */ - public function setCharPressed($charPressed) { - $this->charPressed = (string)$charPressed; - $this->keyName = null; - $this->keyCode = null; - return $this; - } + /** + * Construct a new Key Action + * + * @api + * @param string $actionName (optional) Triggered action + * @param string $keyName (optional) Key name + */ + public function __construct($actionName = null, $keyName = null) + { + if ($actionName) { + $this->setActionName($actionName); + } + if ($keyName) { + $this->setKeyName($keyName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel(ScriptLabel::KEYPRESS, $this->getScriptText()); - return $this; - } + /** + * Get the action to trigger + * + * @api + * @return string + */ + public function getActionName() + { + return $this->actionName; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $actionName = Builder::escapeText($this->actionName, true); - $key = null; - $value = null; - if ($this->keyName !== null) { - $key = 'KeyName'; - $value = $this->keyName; - } else if ($this->keyCode !== null) { - $key = 'KeyCode'; - $value = $this->keyCode; - } else if ($this->charPressed !== null) { - $key = 'CharPressed'; - $value = $this->charPressed; - } - $value = Builder::escapeText($value, true); - return " + /** + * Set the action to trigger + * + * @api + * @param string $actionName Triggered action + * @return static + */ + public function setActionName($actionName) + { + $this->actionName = (string)$actionName; + return $this; + } + + /** + * Get the key name for triggering the action + * + * @api + * @return string + */ + public function getKeyName() + { + return $this->keyName; + } + + /** + * Set the key name for triggering the action + * + * @api + * @param string $keyName Key Name + * @return static + */ + public function setKeyName($keyName) + { + $this->keyName = (string)$keyName; + $this->keyCode = null; + $this->charPressed = null; + return $this; + } + + /** + * Get the key code for triggering the action + * + * @api + * @return int + */ + public function getKeyCode() + { + return $this->keyCode; + } + + /** + * Set the key code for triggering the action + * + * @api + * @param int $keyCode Key Code + * @return static + */ + public function setKeyCode($keyCode) + { + $this->keyName = null; + $this->keyCode = (int)$keyCode; + $this->charPressed = null; + return $this; + } + + /** + * Get the character to press for triggering the action + * + * @api + * @return string + */ + public function getCharPressed() + { + return $this->charPressed; + } + + /** + * Set the character to press for triggering the action + * + * @api + * @param string $charPressed Pressed character + * @return static + */ + public function setCharPressed($charPressed) + { + $this->keyName = null; + $this->keyCode = null; + $this->charPressed = (string)$charPressed; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel(ScriptLabel::KEYPRESS, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $actionName = Builder::escapeText($this->actionName); + $key = null; + $value = null; + if ($this->keyName !== null) { + $key = "KeyName"; + $value = $this->keyName; + } else if ($this->keyCode !== null) { + $key = "KeyCode"; + $value = $this->keyCode; + } else if ($this->charPressed !== null) { + $key = "CharPressed"; + $value = $this->charPressed; + } + $value = Builder::escapeText($value); + return " if (Event.{$key} == {$value}) { TriggerPageAction({$actionName}); }"; - } + } + } diff --git a/libs/FML/Script/Features/MapInfo.php b/libs/FML/Script/Features/MapInfo.php index 93ea9e6d..ce29d5e8 100644 --- a/libs/FML/Script/Features/MapInfo.php +++ b/libs/FML/Script/Features/MapInfo.php @@ -12,80 +12,119 @@ use FML\Types\Scriptable; * Script Feature for opening the map info * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class MapInfo extends ScriptFeature { - /* - * Protected properties - */ - /** @var Control $control */ - protected $control = null; - protected $labelName = null; +class MapInfo extends ScriptFeature +{ - /** - * Construct a new Map Info Feature - * - * @param Control $control (optional) Map Info Control - * @param string $labelName (optional) Script Label name - */ - public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) { - $this->setControl($control); - $this->setLabelName($labelName); - } + /** + * @var Control $control Map Info Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Map Info Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var string $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * Construct a new Map Info + * + * @api + * @param Control $control (optional) Map Info Control + * @param string $labelName (optional) Script Label name + */ + public function __construct(Control $control = null, $labelName = ScriptLabel::MOUSECLICK) + { + if ($control) { + $this->setControl($control); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - if ($this->control) { - // Control event - $controlId = Builder::escapeText($this->control->getId(), true); - $scriptText = " + /** + * Set the Control + * + * @api + * @param Control $control Map Info Control + * @return static + */ + public function setControl(Control $control) + { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + $this->control = $control; + return $this; + } + + /** + * Get the Script Label name + * + * @api + * @return string + */ + public function getLabelName() + { + return $this->labelName; + } + + /** + * Set the Script Label name + * + * @api + * @param string $labelName Script Label name + * @return static + */ + public function setLabelName($labelName) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + if ($this->control) { + // Control event + $controlId = Builder::escapeText($this->control->getId()); + return " if (Event.Control.ControlId == {$controlId}) { ShowCurChallengeCard(); }"; - } else { - // Other - $scriptText = " + } + + // Other events + return " ShowCurChallengeCard();"; - } - return $scriptText; - } + } + } diff --git a/libs/FML/Script/Features/Menu.php b/libs/FML/Script/Features/Menu.php index 8883f226..9e8ace41 100644 --- a/libs/FML/Script/Features/Menu.php +++ b/libs/FML/Script/Features/Menu.php @@ -11,130 +11,173 @@ use FML\Script\ScriptLabel; * Script Feature realising a Menu showing specific Controls for the different items * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Menu extends ScriptFeature { - /* - * Constants - */ - const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu'; +class Menu extends ScriptFeature +{ - /* - * Protected properties - */ - /** @var MenuElement[] $elements */ - protected $elements = array(); - /** @var MenuElement $startElement */ - protected $startElement = null; + /* + * Constants + */ + const FUNCTION_UPDATE_MENU = "FML_UpdateMenu"; - /** - * Construct a new Menu Feature - * - * @param Control $item (optional) Item Control in the Menu bar - * @param Control $control (optional) Toggled Menu Control - */ - public function __construct(Control $item = null, Control $control = null) { - if ($item && $control) { - $this->addElement($item, $control); - } - } + /** + * @var MenuElement[] $elements Menu Elements + */ + protected $elements = array(); - /** - * Add a new Element to the Menu - * - * @param Control $item Item Control in the Menu bar - * @param Control $control Toggled Menu Control - * @param bool $isStartElement (optional) Whether the Menu should start with this Element - * @return static - */ - public function addElement(Control $item, Control $control, $isStartElement = false) { - $menuElement = new MenuElement($item, $control); - $this->appendElement($menuElement, $isStartElement); - return $this; - } + /** + * @var MenuElement $startElement Start Element + */ + protected $startElement = null; - /** - * Append an Element to the Menu - * - * @param MenuElement $menuElement Menu Element - * @param bool $isStartElement (optional) Whether the Menu should start with this Element - * @return static - */ - public function appendElement(MenuElement $menuElement, $isStartElement = false) { - if (!in_array($menuElement, $this->elements, true)) { - array_push($this->elements, $menuElement); - if ($isStartElement) { - $this->setStartElement($menuElement); - } else if (count($this->elements) > 1) { - $menuElement->getControl()->setVisible(false); - } - } - return $this; - } + /** + * Construct a new Menu + * + * @api + * @param Control $item (optional) Item Control in the Menu bar + * @param Control $control (optional) Toggled Menu Control + * @param bool $isStartElement (optional) Whether the Menu should start with the given Element + */ + public function __construct(Control $item = null, Control $control = null, $isStartElement = true) + { + if ($item && $control) { + $this->addItem($item, $control, $isStartElement); + } + } - /** - * Set the Element to start with - * - * @param MenuElement $startElement Starting Element - * @return static - */ - public function setStartElement(MenuElement $startElement) { - $this->startElement = $startElement; - if (!in_array($startElement, $this->elements, true)) { - array_push($this->elements, $startElement); - } - return $this; - } + /** + * Get the Menu Elements + * + * @api + * @return MenuElement[] + */ + public function getElements() + { + return $this->elements; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $updateFunctionName = self::FUNCTION_UPDATE_MENU; - $elementsArrayText = $this->getElementsArrayText(); + /** + * Add a Menu item + * + * @api + * @param Control $item Item Control in the Menu bar + * @param Control $control Toggled Menu Control + * @param bool $isStartElement (optional) Whether the Menu should start with this Element + * @return static + */ + public function addItem(Control $item, Control $control, $isStartElement = false) + { + $menuElement = new MenuElement($item, $control); + $this->addElement($menuElement, $isStartElement); + return $this; + } - // OnInit - if ($this->startElement) { - $startControlId = $this->startElement->getControl()->getId(true, true); - $initScriptText = " + /** + * Add a Menu Element + * + * @api + * @param MenuElement $menuElement Menu Element + * @param bool $isStartElement (optional) Whether the Menu should start with this Element + * @return static + */ + public function addElement(MenuElement $menuElement, $isStartElement = false) + { + if (!in_array($menuElement, $this->elements, true)) { + array_push($this->elements, $menuElement); + if ($isStartElement) { + // new start element + $this->setStartElement($menuElement); + } else { + // additional element - set invisible + $menuElement->getControl() + ->setVisible(false); + } + } + return $this; + } + + /** + * Get the Element to start with + * + * @api + * @return MenuElement + */ + public function getStartElement() + { + return $this->startElement; + } + + /** + * Set the Element to start with + * + * @api + * @param MenuElement $startElement Start Element + * @return static + */ + public function setStartElement(MenuElement $startElement = null) + { + $this->startElement = $startElement; + if ($startElement && !in_array($startElement, $this->elements, true)) { + array_push($this->elements, $startElement); + } + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $updateFunctionName = self::FUNCTION_UPDATE_MENU; + $elementsArrayText = $this->getElementsArrayText(); + + // OnInit + if ($this->startElement) { + $startControlId = Builder::escapeText($this->startElement->getControl()->getId()); + $initScriptText = " {$updateFunctionName}({$elementsArrayText}, {$startControlId});"; - $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); - } + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); + } - // MouseClick - $scriptText = " + // MouseClick + $scriptText = " declare MenuElements = {$elementsArrayText}; if (MenuElements.existskey(Event.Control.ControlId)) { declare ShownControlId = MenuElements[Event.Control.ControlId]; {$updateFunctionName}(MenuElements, ShownControlId); }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true); + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true); - // Update menu function - $updateFunctionText = " + // Update menu function + $updateFunctionText = " Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) { foreach (ItemId => ControlId in _Elements) { declare Control <=> (Page.GetFirstChild(ControlId)); Control.Visible = (ControlId == _ShownControlId); } }"; - $script->addScriptFunction($updateFunctionName, $updateFunctionText); + $script->addScriptFunction($updateFunctionName, $updateFunctionText); - return $this; - } + return $this; + } + + /** + * Build the array text for the Elements + * + * @return string + */ + protected function getElementsArrayText() + { + $elements = array(); + foreach ($this->elements as $element) { + $elementId = $element->getItem() + ->getId(); + $elements[$elementId] = $element->getControl() + ->getId(); + } + return Builder::getArray($elements, true); + } - /** - * Build the array text for the Elements - * - * @return string - */ - protected function getElementsArrayText() { - $elements = array(); - foreach ($this->elements as $element) { - $elementId = $element->getItem()->getId(); - $elements[$elementId] = $element->getControl()->getId(); - } - return Builder::getArray($elements, true); - } } diff --git a/libs/FML/Script/Features/MenuElement.php b/libs/FML/Script/Features/MenuElement.php index d67a113f..a9fb48ef 100644 --- a/libs/FML/Script/Features/MenuElement.php +++ b/libs/FML/Script/Features/MenuElement.php @@ -9,72 +9,90 @@ use FML\Types\Scriptable; * Menu Element for the Menu Feature * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class MenuElement { - /* - * Protected properties - */ - protected $item = null; - protected $control = null; +class MenuElement +{ - /** - * Create a new Menu Element - * - * @param Control $item (optional) Item Control in the Menu bar - * @param Control $control (optional) Toggled Menu Control - */ - public function __construct(Control $item = null, Control $control = null) { - if ($item !== null) { - $this->setItem($item); - } - if ($control !== null) { - $this->setControl($control); - } - } + /** + * @var Control $item Menu Item + */ + protected $item = null; - /** - * Set the Item Control - * - * @param Control $item Item Control in the Menu bar - * @return static - */ - public function setItem(Control $item) { - $item->checkId(); - if ($item instanceof Scriptable) { - $item->setScriptEvents(true); - } - $this->item = $item; - return $this; - } + /** + * @var Control $control Menu Control + */ + protected $control = null; - /** - * Get the Item Control - * - * @return \FML\Controls\Control - */ - public function getItem() { - return $this->item; - } + /** + * Create a new Menu Element + * + * @api + * @param Control $item (optional) Item Control in the Menu bar + * @param Control $control (optional) Toggled Menu Control + */ + public function __construct(Control $item = null, Control $control = null) + { + if ($item) { + $this->setItem($item); + } + if ($control) { + $this->setControl($control); + } + } - /** - * Set the Menu Control - * - * @param Control $control Toggled Menu Control - * @return static - */ - public function setControl(Control $control) { - $this->control = $control->checkId(); - return $this; - } + /** + * Get the Item Control + * + * @api + * @return Control + */ + public function getItem() + { + return $this->item; + } + + /** + * Set the Item Control + * + * @api + * @param Control $item Item Control + * @return static + */ + public function setItem(Control $item) + { + $item->checkId(); + if ($item instanceof Scriptable) { + $item->setScriptEvents(true); + } + $this->item = $item; + return $this; + } + + /** + * Get the Menu Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the Menu Control + * + * @api + * @param Control $control Menu Control + * @return static + */ + public function setControl(Control $control) + { + $control->checkId(); + $this->control = $control; + return $this; + } - /** - * Get the Menu Control - * - * @return \FML\Controls\Control - */ - public function getControl() { - return $this->control; - } } diff --git a/libs/FML/Script/Features/Paging.php b/libs/FML/Script/Features/Paging.php index 3a1a743b..fc995309 100644 --- a/libs/FML/Script/Features/Paging.php +++ b/libs/FML/Script/Features/Paging.php @@ -10,235 +10,418 @@ use FML\Script\ScriptInclude; use FML\Script\ScriptLabel; /** - * Script Feature realising a mechanism for browsing through Pages + * Script Feature realizing a mechanism for browsing through Pages * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Paging extends ScriptFeature { - /* - * Constants - */ - const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage'; - const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage'; +class Paging extends ScriptFeature +{ - /* - * Protected properties - */ - /** @var PagingPage[] $pages */ - protected $pages = array(); - /** @var PagingButton[] $buttons */ - protected $buttons = array(); - /** @var Label $label */ - protected $label = null; - protected $startPageNumber = null; - protected $customMaxPageNumber = null; - protected $previousChunkAction = null; - protected $nextChunkAction = null; - protected $chunkActionAppendsPageNumber = null; + /* + * Constants + */ + const VAR_CURRENT_PAGE = "FML_Paging_CurrentPage"; + const FUNCTION_UPDATE_CURRENT_PAGE = "FML_UpdateCurrentPage"; - /** - * Construct a new Paging Script Feature - * - * @param Label $label (optional) Page number Label - */ - public function __construct(Label $label = null) { - if ($label !== null) { - $this->setLabel($label); - } - } + /** + * @var Label $label Page number Label + */ + protected $label = null; - /** - * Add a new Page Control - * - * @param Control $pageControl Page Control - * @param string $pageNumber (optional) Page number - * @return static - */ - public function addPage(Control $pageControl, $pageNumber = null) { - if ($pageNumber === null) { - $pageNumber = count($this->pages) + 1; - } - $page = new PagingPage($pageControl, $pageNumber); - $this->appendPage($page); - return $this; - } + /** + * @var PagingPage[] $pages Pages + */ + protected $pages = array(); - /** - * Append a Page - * - * @param PagingPage $page Paging Page - * @return static - */ - public function appendPage(PagingPage $page) { - if (!in_array($page, $this->pages, true)) { - array_push($this->pages, $page); - } - return $this; - } + /** + * @var PagingButton[] $buttons Paging Buttons + */ + protected $buttons = array(); - /** - * Add a new Button to browse through the Pages - * - * @param Control $buttonControl Button used for browsing - * @param int $browseAction (optional) Number of browsed Pages per click - * @return static - */ - public function addButton(Control $buttonControl, $browseAction = null) { - if ($browseAction === null) { - $buttonCount = count($this->buttons); - if ($buttonCount % 2 === 0) { - $browseAction = $buttonCount / 2 + 1; - } else { - $browseAction = $buttonCount / -2 - 1; - } - } - $button = new PagingButton($buttonControl, $browseAction); - $this->appendButton($button); - return $this; - } + /** + * @var int $startPageNumber Start Page number + */ + protected $startPageNumber = null; - /** - * Append a Button to browse through Pages - * - * @param PagingButton $button Paging Button - * @return static - */ - public function appendButton(PagingButton $button) { - if (!in_array($button, $this->buttons, true)) { - array_push($this->buttons, $button); - } - return $this; - } + /** + * @var int $customMaxPageNumber Custom maximum page number + */ + protected $customMaxPageNumber = null; - /** - * Set the Label showing the Page number - * - * @param Label $label Page number Label - * @return static - */ - public function setLabel(Label $label) { - $this->label = $label->checkId(); - return $this; - } + /** + * @var string $previousChunkAction Previous chunk action name + */ + protected $previousChunkAction = null; - /** - * Set the Start Page number - * - * @param int $startPageNumber Page number to start with - * @return static - */ - public function setStartPageNumber($startPageNumber) { - $this->startPageNumber = (int)$startPageNumber; - } + /** + * @var string $nextChunkAction Next chunk action name + */ + protected $nextChunkAction = null; - /** - * Set a custom maximum Page number for using chunks - * - * @param int $maxPageNumber Custom maximum Page number - * @return static - */ - public function setCustomMaxPageNumber($maxPageNumber) { - $this->customMaxPageNumber = (int)$maxPageNumber; - return $this; - } + /** + * @var bool $chunkActionAppendsPageNumber Chunk action appended with Page number + */ + protected $chunkActionAppendsPageNumber = null; - /** - * Set the action triggered when the previous chunk is needed - * - * @param string $previousChunkAction Triggered action - * @return static - */ - public function setPreviousChunkAction($previousChunkAction) { - $this->previousChunkAction = (string)$previousChunkAction; - return $this; - } + /** + * Construct a new Paging + * + * @api + * @param Label $label (optional) Page number Label + * @param PagingPage[] $pages (optional) Pages + * @param PagingButton[] $buttons (optional) Pageing Buttons + */ + public function __construct(Label $label = null, array $pages = null, array $buttons = null) + { + if ($label) { + $this->setLabel($label); + } + if ($pages) { + $this->setPages($pages); + } + if ($buttons) { + $this->setButtons($buttons); + } + } - /** - * Set the action triggered when the next chunk is needed - * - * @param string $nextChunkAction Triggered action - * @return static - */ - public function setNextChunkAction($nextChunkAction) { - $this->nextChunkAction = (string)$nextChunkAction; - return $this; - } + /** + * Get the Label showing the Page number + * + * @api + * @return Label + */ + public function getLabel() + { + return $this->label; + } - /** - * Set the actions triggered when another chunk is needed - * - * @param string $chunkAction Triggered action - * @return static - */ - public function setChunkActions($chunkAction) { - $this->setNextChunkAction($chunkAction); - $this->setPreviousChunkAction($chunkAction); - return $this; - } + /** + * Set the Label showing the Page number + * + * @api + * @param Label $label Page number Label + * @return static + */ + public function setLabel(Label $label) + { + $label->checkId(); + $this->label = $label; + return $this; + } - /** - * Set if the chunk action should get the needed Page number appended - * - * @param bool $appendPageNumber Whether to append the needed Page number - * @return static - */ - public function setChunkActionAppendsPageNumber($appendPageNumber) { - $this->chunkActionAppendsPageNumber = (bool)$appendPageNumber; - return $this; - } + /** + * Get the Pages + * + * @api + * @return PagingPage[] + */ + public function getPages() + { + return $this->pages; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - if (empty($this->pages)) { - return $this; - } - $script->setScriptInclude(ScriptInclude::TEXTLIB); + /** + * Add a new Page Control + * + * @api + * @param Control $pageControl Page Control + * @param string $pageNumber (optional) Page number + * @return static + */ + public function addPageControl(Control $pageControl, $pageNumber = null) + { + if ($pageNumber === null) { + $pageNumber = count($this->pages) + 1; + } + $page = new PagingPage($pageControl, $pageNumber); + return $this->addPage($page); + } - $currentPageVariable = self::VAR_CURRENT_PAGE; - $updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE; + /** + * Add a new Page + * + * @api + * @param PagingPage $page Page + * @return static + */ + public function addPage(PagingPage $page) + { + if (!in_array($page, $this->pages, true)) { + array_push($this->pages, $page); + } + return $this; + } - $minPageNumber = 1; - $startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber); - $maxPage = $this->getMaxPage(); - $maxPageNumber = $this->customMaxPageNumber; - if (!is_int($maxPageNumber)) { - $maxPageNumber = $maxPage->getPageNumber(); - } + /** + * Add new Pages + * + * @api + * @param PagingPage[] $pages Pages + * @return static + */ + public function setPages(array $pages) + { + $this->pages = array(); + foreach ($pages as $page) { + $this->addPage($page); + } + return $this; + } - $pagingId = $maxPage->getControl()->getId(true, true); - $pageLabelId = '""'; - if ($this->label) { - $pageLabelId = $this->label->getId(true, true); - } - $pagesArrayText = $this->getPagesArrayText(); - $pageButtonsArrayText = $this->getPageButtonsArrayText(); + /** + * Get the Buttons + * + * @api + * @return PagingButton[] + */ + public function getButtons() + { + return $this->buttons; + } - $previousChunkAction = Builder::escapeText($this->previousChunkAction, true); - $nextChunkAction = Builder::escapeText($this->nextChunkAction, true); - $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber); + /** + * Add a new Button Control to browse through the Pages + * + * @api + * @param Control $buttonControl Button used for browsing + * @param int $browseAction (optional) Number of browsed Pages per click + * @return static + */ + public function addButtonControl(Control $buttonControl, $browseAction = null) + { + if ($browseAction === null) { + $buttonCount = count($this->buttons); + if ($buttonCount % 2 === 0) { + $browseAction = $buttonCount / 2 + 1; + } else { + $browseAction = $buttonCount / -2 - 1; + } + } + $button = new PagingButton($buttonControl, $browseAction); + return $this->addButton($button); + } - // Init - $initScriptText = " + /** + * Add a new Button to browse through Pages + * + * @api + * @param PagingButton $button Paging Button + * @return static + */ + public function addButton(PagingButton $button) + { + if (!in_array($button, $this->buttons, true)) { + array_push($this->buttons, $button); + } + return $this; + } + + /** + * Set the Paging Buttons + * + * @api + * @param PagingButton[] $buttons Paging Buttons + * @return static + */ + public function setButtons(array $buttons) + { + $this->buttons = array(); + foreach ($buttons as $button) { + $this->addButton($button); + } + return $this; + } + + /** + * Get the start Page number + * + * @api + * @return int + */ + public function getStartPageNumber() + { + return $this->startPageNumber; + } + + /** + * Set the start Page number + * + * @api + * @param int $startPageNumber Page number to start with + * @return static + */ + public function setStartPageNumber($startPageNumber) + { + $this->startPageNumber = (int)$startPageNumber; + return $this; + } + + /** + * Get a custom maximum Page number for using chunks + * + * @api + * @return int + */ + public function getCustomMaxPageNumber() + { + return $this->customMaxPageNumber; + } + + /** + * Set a custom maximum Page number for using chunks + * + * @api + * @param int $maxPageNumber Custom maximum Page number + * @return static + */ + public function setCustomMaxPageNumber($maxPageNumber) + { + $this->customMaxPageNumber = (int)$maxPageNumber; + return $this; + } + + /** + * Get the action triggered when the previous chunk is needed + * + * @api + * @return string + */ + public function getPreviousChunkAction() + { + return $this->previousChunkAction; + } + + /** + * Set the action triggered when the previous chunk is needed + * + * @api + * @param string $previousChunkAction Triggered action + * @return static + */ + public function setPreviousChunkAction($previousChunkAction) + { + $this->previousChunkAction = (string)$previousChunkAction; + return $this; + } + + /** + * Get the action triggered when the next chunk is needed + * + * @api + * @return string + */ + public function getNextChunkAction() + { + return $this->nextChunkAction; + } + + /** + * Set the action triggered when the next chunk is needed + * + * @api + * @param string $nextChunkAction Triggered action + * @return static + */ + public function setNextChunkAction($nextChunkAction) + { + $this->nextChunkAction = (string)$nextChunkAction; + return $this; + } + + /** + * Set the actions triggered when another chunk is needed + * + * @api + * @param string $chunkAction Triggered action + * @return static + */ + public function setChunkActions($chunkAction) + { + return $this->setNextChunkAction($chunkAction) + ->setPreviousChunkAction($chunkAction); + } + + /** + * Get if the chunk action should append the needed Page number + * + * @api + * @return bool + */ + public function getChunkActionAppendsPageNumber() + { + return $this->chunkActionAppendsPageNumber; + } + + /** + * Set if the chunk action should append the needed Page number + * + * @api + * @param bool $appendPageNumber Append the needed Page number + * @return static + */ + public function setChunkActionAppendsPageNumber($appendPageNumber) + { + $this->chunkActionAppendsPageNumber = (bool)$appendPageNumber; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + if (empty($this->pages)) { + return $this; + } + $script->setScriptInclude(ScriptInclude::TEXTLIB); + + $currentPageVariable = self::VAR_CURRENT_PAGE; + $updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE; + + $minPageNumber = 1; + $startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber); + $maxPage = $this->getMaxPage(); + $maxPageNumber = $this->customMaxPageNumber; + if (!is_int($maxPageNumber)) { + $maxPageNumber = $maxPage->getPageNumber(); + } + + $pagingId = $maxPage->getControl() + ->getId(true, true); + $pagingId = Builder::escapeText($maxPage->getControl() + ->getId()); + $pageLabelId = Builder::EMPTY_STRING; + if ($this->label) { + $pageLabelId = Builder::escapeText($this->label->getId()); + } + + $pagesArrayText = $this->getPagesArrayText(); + $pageButtonsArrayText = $this->getPageButtonsArrayText(); + + $previousChunkAction = Builder::escapeText($this->previousChunkAction); + $nextChunkAction = Builder::escapeText($this->nextChunkAction); + $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber); + + // Init + $initScriptText = " declare {$currentPageVariable} for This = Integer[Text]; {$currentPageVariable}[{$pagingId}] = {$startPageNumber}; {$updatePageFunction}({$pagingId}, {$pageLabelId}, 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});"; - $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); - // MouseClick - $clickScriptText = " + // MouseClick + $clickScriptText = " declare PageButtons = {$pageButtonsArrayText}; if (PageButtons.existskey(Event.Control.ControlId)) { declare BrowseAction = PageButtons[Event.Control.ControlId]; {$updatePageFunction}({$pagingId}, {$pageLabelId}, BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber}); }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true); + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true); - // Update function - $functionText = " + // Update function + $functionText = " Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAction, Integer _MinPageNumber, Integer _MaxPageNumber, Text[Integer] _Pages, Text _PreviousChunkAction, Text _NextChunkAction, Boolean _ChunkActionAppendPageNumber) { declare {$currentPageVariable} for This = Integer[Text]; if (!{$currentPageVariable}.existskey(_PagingId)) return; @@ -274,75 +457,82 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct if (PageLabel == Null) return; PageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber; }"; - $script->addScriptFunction($updatePageFunction, $functionText); - return $this; - } + $script->addScriptFunction($updatePageFunction, $functionText); + return $this; + } - /** - * Get the minimum Page - * - * @return \FML\Script\Features\PagingPage - */ - protected function getMinPage() { - $minPageNumber = null; - $minPage = null; - foreach ($this->pages as $page) { - $pageNumber = $page->getPageNumber(); - if ($minPageNumber === null || $pageNumber < $minPageNumber) { - $minPageNumber = $pageNumber; - $minPage = $page; - } - } - return $minPage; - } + /** + * Get the minimum Page + * + * @return PagingPage + */ + protected function getMinPage() + { + $minPageNumber = null; + $minPage = null; + foreach ($this->pages as $page) { + $pageNumber = $page->getPageNumber(); + if ($minPageNumber === null || $pageNumber < $minPageNumber) { + $minPageNumber = $pageNumber; + $minPage = $page; + } + } + return $minPage; + } - /** - * Get the maximum Page - * - * @return \FML\Script\Features\PagingPage - */ - protected function getMaxPage() { - $maxPageNumber = null; - $maxPage = null; - foreach ($this->pages as $page) { - $pageNumber = $page->getPageNumber(); - if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { - $maxPageNumber = $pageNumber; - $maxPage = $page; - } - } - return $maxPage; - } + /** + * Get the maximum Page + * + * @return PagingPage + */ + protected function getMaxPage() + { + $maxPageNumber = null; + $maxPage = null; + foreach ($this->pages as $page) { + $pageNumber = $page->getPageNumber(); + if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { + $maxPageNumber = $pageNumber; + $maxPage = $page; + } + } + return $maxPage; + } - /** - * Build the array text for the Pages - * - * @return string - */ - protected function getPagesArrayText() { - if (empty($this->pages)) { - return Builder::getArray(array(0 => ''), true); - } - $pages = array(); - foreach ($this->pages as $page) { - $pages[$page->getPageNumber()] = $page->getControl()->getId(); - } - return Builder::getArray($pages, true); - } + /** + * Build the array text for the Pages + * + * @return string + */ + protected function getPagesArrayText() + { + if (empty($this->pages)) { + return Builder::getArray(array(0 => ''), true); + } + $pages = array(); + foreach ($this->pages as $page) { + $pages[$page->getPageNumber()] = $page->getControl() + ->getId(); + } + return Builder::getArray($pages, true); + } + + /** + * Build the array text for the Page Buttons + * + * @return string + */ + protected function getPageButtonsArrayText() + { + if (empty($this->buttons)) { + return Builder::getArray(array('' => 0), true); + } + $pageButtons = array(); + foreach ($this->buttons as $pageButton) { + $pageButtons[$pageButton->getControl() + ->getId()] = $pageButton->getPagingCount(); + } + return Builder::getArray($pageButtons, true); + } - /** - * Build the array text for the Page Buttons - * - * @return string - */ - protected function getPageButtonsArrayText() { - if (empty($this->buttons)) { - return Builder::getArray(array('' => 0), true); - } - $pageButtons = array(); - foreach ($this->buttons as $pageButton) { - $pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction(); - } - return Builder::getArray($pageButtons, true); - } } diff --git a/libs/FML/Script/Features/PagingButton.php b/libs/FML/Script/Features/PagingButton.php index b6cc7af7..010c1aa6 100644 --- a/libs/FML/Script/Features/PagingButton.php +++ b/libs/FML/Script/Features/PagingButton.php @@ -9,73 +9,89 @@ use FML\Types\Scriptable; * Paging Button for browsing through Pages * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PagingButton { - /* - * Protected properties - */ - /** @var Control $control */ - protected $control = null; - protected $browseAction = null; +class PagingButton +{ - /** - * Construct a new Paging Button - * - * @param Control $control (optional) Browse Control - * @param int $browseAction (optional) Number of browsed Pages per Click - */ - public function __construct(Control $control = null, $browseAction = null) { - if ($control !== null) { - $this->setControl($control); - } - if ($browseAction !== null) { - $this->setBrowseAction($browseAction); - } - } + /** + * @var Control $control Paging Control + */ + protected $control = null; - /** - * Set the Button Control - * - * @param Control $control Browse Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var int Paging count + */ + protected $pagingCount = 1; - /** - * Get the Button Control - * - * @return \FML\Controls\Control - */ - public function getControl() { - return $this->control; - } + /** + * Construct a new Paging Button + * + * @api + * @param Control $control (optional) Paging Control + * @param int $pagingCount (optional) Number of browsed pages per click + */ + public function __construct(Control $control = null, $pagingCount = 1) + { + if ($control) { + $this->setControl($control); + } + if ($pagingCount) { + $this->setPagingCount($pagingCount); + } + } - /** - * Set the browse action - * - * @param int $browseAction Number of browsed Pages per click - * @return static - */ - public function setBrowseAction($browseAction) { - $this->browseAction = (int)$browseAction; - return $this; - } + /** + * Get the paging Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the paging Control + * + * @api + * @param Control $control Paging Control + * @return static + */ + public function setControl(Control $control) + { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + $this->control = $control; + return $this; + } + + /** + * Get the paging count + * + * @api + * @return int + */ + public function getPagingCount() + { + return $this->pagingCount; + } + + /** + * Set the paging count + * + * @api + * @param int $pagingCount Number of browsed pages per click + * @return static + */ + public function setPagingCount($pagingCount) + { + $this->pagingCount = (int)$pagingCount; + return $this; + } - /** - * Get the browse action - * - * @return int - */ - public function getBrowseAction() { - return $this->browseAction; - } } diff --git a/libs/FML/Script/Features/PagingPage.php b/libs/FML/Script/Features/PagingPage.php index 1f2ef86a..60b9a948 100644 --- a/libs/FML/Script/Features/PagingPage.php +++ b/libs/FML/Script/Features/PagingPage.php @@ -8,67 +8,86 @@ use FML\Controls\Control; * Paging Page * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PagingPage { - /* - * Protected properties - */ - /** @var Control $control */ - protected $control = null; - protected $number = null; +class PagingPage +{ - /** - * Construct a new Paging Page - * - * @param Control $control (optional) Page Control - * @param int $pageNumber (optional) Number of the Page - */ - public function __construct(Control $control = null, $pageNumber = 1) { - if ($control !== null) { - $this->setControl($control); - } - $this->setPageNumber($pageNumber); - } + /** + * @var Control $control Page Control + */ + protected $control = null; - /** - * Set the Page Control - * - * @param Control $control Page Control - * @return static - */ - public function setControl(Control $control) { - $this->control = $control->checkId(); - return $this; - } + /** + * @var int $pageNumber Page number + */ + protected $pageNumber = null; - /** - * Get the Page Control - * - * @return \FML\Controls\Control - */ - public function getControl() { - return $this->control; - } + /** + * Construct a new Paging Page + * + * @api + * @param Control $control (optional) Page Control + * @param int $pageNumber (optional) Number of the Page + */ + public function __construct(Control $control = null, $pageNumber = null) + { + if ($control) { + $this->setControl($control); + } + if ($pageNumber) { + $this->setPageNumber($pageNumber); + } + } - /** - * Set the Page number - * - * @param int $pageNumber Number of the Page - * @return static - */ - public function setPageNumber($pageNumber) { - $this->number = (int)$pageNumber; - return $this; - } + /** + * Get the Page Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the Page Control + * + * @api + * @param Control $control Page Control + * @return static + */ + public function setControl(Control $control) + { + $control->checkId(); + $this->control = $control; + return $this; + } + + /** + * Get the Page number + * + * @api + * @return int + */ + public function getPageNumber() + { + return $this->pageNumber; + } + + /** + * Set the Page number + * + * @api + * @param int $pageNumber Number of the Page + * @return static + */ + public function setPageNumber($pageNumber) + { + $this->pageNumber = (int)$pageNumber; + return $this; + } - /** - * Get the Page number - * - * @return int - */ - public function getPageNumber() { - return $this->number; - } } diff --git a/libs/FML/Script/Features/PlayerProfile.php b/libs/FML/Script/Features/PlayerProfile.php index 08d30274..0ef0f50f 100644 --- a/libs/FML/Script/Features/PlayerProfile.php +++ b/libs/FML/Script/Features/PlayerProfile.php @@ -12,97 +12,154 @@ use FML\Types\Scriptable; * Script Feature for opening a player profile * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PlayerProfile extends ScriptFeature { - /* - * Protected properties - */ - protected $login = null; - /** @var Control $control */ - protected $control = null; - protected $labelName = null; +class PlayerProfile extends ScriptFeature +{ - /** - * Construct a new Player Profile Feature - * - * @param string $login (optional) Player login - * @param Control $control (optional) Action Control - * @param string $labelName (optional) Script Label name - */ - public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) { - $this->setLogin($login); - if ($control !== null) { - $this->setControl($control); - } - $this->setLabelName($labelName); - } + /** + * @var string $login Player login + */ + protected $login = null; - /** - * Set the login of the opened player - * - * @param string $login Player login - * @return static - */ - public function setLogin($login) { - $this->login = $login; - return $this; - } + /** + * @var Control $control Profile Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Profile Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var string $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * Construct a new Player Profile + * + * @api + * @param string $login (optional) Player login + * @param Control $control (optional) Profile Control + * @param string $labelName (optional) Script Label name + */ + public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) + { + if ($login) { + $this->setLogin($login); + } + if ($control) { + $this->setControl($control); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the login of the opened player + * + * @api + * @return string + */ + public function getLogin() + { + return $this->login; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $login = Builder::escapeText($this->login, true); - if ($this->control) { - // Control event - $controlId = Builder::escapeText($this->control->getId(), true); - $scriptText = " + /** + * Set the login of the opened player + * + * @api + * @param string $login Player login + * @return static + */ + public function setLogin($login) + { + $this->login = (string)$login; + return $this; + } + + /** + * Get the Profile Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the Profile Control + * + * @api + * @param Control $control Profile Control + * @return static + */ + public function setControl(Control $control) + { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + $this->control = $control; + return $this; + } + + /** + * Get the Script Label name + * + * @api + * @return string + */ + public function getLabelName() + { + return $this->labelName; + } + + /** + * Set the Script Label name + * + * @api + * @param string $labelName Script Label name + * @return static + */ + public function setLabelName($labelName) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $login = Builder::escapeText($this->login); + + if ($this->control) { + // Control event + $controlId = Builder::escapeText($this->control->getId()); + return " if (Event.Control.ControlId == {$controlId}) { ShowProfile({$login}); }"; - } else { - // Other - $scriptText = " + } + + // Other events + return " ShowProfile({$login});"; - } - return $scriptText; - } + } + } diff --git a/libs/FML/Script/Features/Preload.php b/libs/FML/Script/Features/Preload.php new file mode 100644 index 00000000..11df0473 --- /dev/null +++ b/libs/FML/Script/Features/Preload.php @@ -0,0 +1,113 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class Preload extends ScriptFeature +{ + + /** + * @var string[] $imageUrls Image urls + */ + protected $imageUrls = array(); + + /** + * Construct a new Preload + * + * @api + * @param string[] $imageUrls (optional) Image urls + */ + public function __construct(array $imageUrls = null) + { + if ($imageUrls) { + $this->setImageUrls($imageUrls); + } + } + + /** + * Get Image Urls to preload + * + * @api + * @return string[] + */ + public function getImageUrls() + { + return $this->imageUrls; + } + + /** + * Add an Image Url to preload + * + * @api + * @param string $imageUrl Image Url + * @return static + */ + public function addImageUrl($imageUrl) + { + if (!in_array($imageUrl, $this->imageUrls)) { + array_push($this->imageUrls, $imageUrl); + } + return $this; + } + + /** + * Set Image Urls to preload + * + * @api + * @param string[] $imageUrls Image Urls + * @return static + */ + public function setImageUrls(array $imageUrls = array()) + { + $this->imageUrls = $imageUrls; + return $this; + } + + /** + * Remove all Image Urls + * + * @api + * @return static + */ + public function removeAllImageUrls() + { + $this->imageUrls = array(); + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $scriptText = ""; + foreach ($this->imageUrls as $imageUrl) { + $escapedImageUrl = Builder::escapeText($imageUrl); + $scriptText .= " +PreloadImage({$escapedImageUrl});"; + } + return $scriptText; + } + +} diff --git a/libs/FML/Script/Features/ScriptFeature.php b/libs/FML/Script/Features/ScriptFeature.php index bf31691d..9cf1dd7f 100644 --- a/libs/FML/Script/Features/ScriptFeature.php +++ b/libs/FML/Script/Features/ScriptFeature.php @@ -9,34 +9,37 @@ use FML\Types\ScriptFeatureable; * ManiaLink Script Feature Class * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class ScriptFeature { +abstract class ScriptFeature +{ - /** - * Collect the Script Features of the given objects - * - * @return ScriptFeature[] - */ - public static function collect() { - $params = func_get_args(); - $scriptFeatures = array(); - foreach ($params as $object) { - if ($object instanceof ScriptFeatureable) { - $scriptFeatures = array_merge($scriptFeatures, $object->getScriptFeatures()); - } else if ($object instanceof ScriptFeature) { - array_push($scriptFeatures, $object); - } - } - return $scriptFeatures; - } + /** + * Collect the Script Features of the given objects + * + * @return ScriptFeature[] + */ + public static function collect() + { + $params = func_get_args(); + $scriptFeatures = array(); + foreach ($params as $object) { + if ($object instanceof ScriptFeatureable) { + $scriptFeatures = array_merge($scriptFeatures, $object->getScriptFeatures()); + } else if ($object instanceof ScriptFeature) { + array_push($scriptFeatures, $object); + } + } + return $scriptFeatures; + } + + /** + * Prepare the given Script for rendering by adding the needed Labels, etc. + * + * @param Script $script Script to prepare + * @return static + */ + public abstract function prepare(Script $script); - /** - * Prepare the given Script for rendering by adding the needed Labels, etc. - * - * @param Script $script Script to prepare - * @return static - */ - public abstract function prepare(Script $script); } diff --git a/libs/FML/Script/Features/Toggle.php b/libs/FML/Script/Features/Toggle.php index 3f0c5d27..395c1ac8 100644 --- a/libs/FML/Script/Features/Toggle.php +++ b/libs/FML/Script/Features/Toggle.php @@ -3,6 +3,7 @@ namespace FML\Script\Features; use FML\Controls\Control; +use FML\Script\Builder; use FML\Script\Script; use FML\Script\ScriptLabel; use FML\Types\Scriptable; @@ -11,128 +12,231 @@ use FML\Types\Scriptable; * Script Feature for toggling Controls * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Toggle extends ScriptFeature { - /* - * Protected properties - */ - /** @var Control $togglingControl */ - protected $togglingControl = null; - /** @var Control $toggledControl */ - protected $toggledControl = null; - protected $labelName = null; - protected $onlyShow = null; - protected $onlyHide = null; +class Toggle extends ScriptFeature +{ - /** - * Construct a new Toggle Feature - * - * @param Control $togglingControl (optional) Toggling Control - * @param Control $toggledControl (optional) Toggled Control - * @param string $labelName (optional) Script Label name - * @param bool $onlyShow (optional) Whether it should only show the Control but not toggle - * @param bool $onlyHide (optional) Whether it should only hide the Control but not toggle - */ - public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK, - $onlyShow = false, $onlyHide = false) { - if ($togglingControl !== null) { - $this->setTogglingControl($togglingControl); - } - if ($toggledControl !== null) { - $this->setToggledControl($toggledControl); - } - $this->setLabelName($labelName); - $this->setOnlyShow($onlyShow); - $this->setOnlyHide($onlyHide); - } + /** + * @var Control $togglingControl Toggling Control + */ + protected $togglingControl = null; - /** - * Set the toggling Control - * - * @param Control $control Toggling Control - * @return static - */ - public function setTogglingControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->togglingControl = $control; - return $this; - } + /** + * @var Control $toggledControl Toggled Control + */ + protected $toggledControl = null; - /** - * Set the toggled Control - * - * @param Control $control Toggling Control - * @return static - */ - public function setToggledControl(Control $control) { - $this->toggledControl = $control->checkId(); - return $this; - } + /** + * @var $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the label name - * - * @param string $labelName Script Label Name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * @var bool $onlyShow Show only + */ + protected $onlyShow = null; - /** - * Set to only show - * - * @param bool $onlyShow Whether it should only show the Control but not toggle - * @return static - */ - public function setOnlyShow($onlyShow) { - $this->onlyShow = (bool)$onlyShow; - return $this; - } + /** + * @var bool $onlyHide Hide only + */ + protected $onlyHide = null; - /** - * Set to only hide - * - * @param bool $onlyHide Whether it should only hide the Control but not toggle - * @return static - */ - public function setOnlyHide($onlyHide) { - $this->onlyHide = (bool)$onlyHide; - return $this; - } + /** + * Construct a new Toggle + * + * @api + * @param Control $togglingControl (optional) Toggling Control + * @param Control $toggledControl (optional) Toggled Control + * @param string $labelName (optional) Script Label name + * @param bool $onlyShow (optional) If it should only show the Control but not toggle + * @param bool $onlyHide (optional) If it should only hide the Control but not toggle + */ + public function __construct( + Control $togglingControl = null, + Control $toggledControl = null, + $labelName = ScriptLabel::MOUSECLICK, + $onlyShow = false, + $onlyHide = false + ) { + if ($togglingControl) { + $this->setTogglingControl($togglingControl); + } + if ($toggledControl) { + $this->setToggledControl($toggledControl); + } + if ($labelName) { + $this->setLabelName($labelName); + } + if ($onlyShow) { + $this->setOnlyShow($onlyShow); + } + if ($onlyHide) { + $this->setOnlyHide($onlyHide); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the toggling Control + * + * @api + * @return Control + */ + public function getTogglingControl() + { + return $this->togglingControl; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - $togglingControlId = $this->togglingControl->getId(true, true); - $toggledControlId = $this->toggledControl->getId(true, true); - $visibility = '!ToggleControl.Visible'; - if ($this->onlyShow) { - $visibility = 'True'; - } else if ($this->onlyHide) { - $visibility = 'False'; - } - return " + /** + * Set the toggling Control + * + * @api + * @param Control $control Toggling Control + * @return static + */ + public function setTogglingControl(Control $control) + { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + $this->togglingControl = $control; + return $this; + } + + /** + * Get the toggled Control + * + * @api + * @return Control + */ + public function getToggledControl() + { + return $this->toggledControl; + } + + /** + * Set the toggled Control + * + * @api + * @param Control $control Toggled Control + * @return static + */ + public function setToggledControl(Control $control) + { + $control->checkId(); + $this->toggledControl = $control; + return $this; + } + + /** + * Get the Script Label name + * + * @api + * @return string + */ + public function getLabelName() + { + return $this->labelName; + } + + /** + * Set the Script Label name + * + * @api + * @param string $labelName Script Label Name + * @return static + */ + public function setLabelName($labelName) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * Get Show Only + * + * @api + * @return bool + */ + public function getOnlyShow() + { + return $this->onlyShow; + } + + /** + * Set Show Only + * + * @api + * @param bool $onlyShow If it should only show the Control but not toggle + * @return static + */ + public function setOnlyShow($onlyShow) + { + $this->onlyShow = (bool)$onlyShow; + if ($this->onlyShow) { + $this->onlyHide = null; + } + return $this; + } + + /** + * Get Hide Only + * + * @api + * @return bool + */ + public function getOnlyHide() + { + return $this->onlyHide; + } + + /** + * Set Hide Only + * + * @api + * @param bool $onlyHide If it should only hide the Control but not toggle + * @return static + */ + public function setOnlyHide($onlyHide) + { + $this->onlyHide = (bool)$onlyHide; + if ($this->onlyHide) { + $this->onlyShow = null; + } + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + $togglingControlId = Builder::escapeText($this->togglingControl->getId()); + $toggledControlId = Builder::escapeText($this->toggledControl->getId()); + $visibility = "!ToggleControl.Visible"; + if ($this->onlyShow) { + $visibility = "True"; + } else if ($this->onlyHide) { + $visibility = "False"; + } + return " if (Event.Control.ControlId == {$togglingControlId}) { declare ToggleControl = Page.GetFirstChild({$toggledControlId}); ToggleControl.Visible = {$visibility}; }"; - } + } + } diff --git a/libs/FML/Script/Features/Tooltip.php b/libs/FML/Script/Features/Tooltip.php index 2b640557..ca87b3ff 100644 --- a/libs/FML/Script/Features/Tooltip.php +++ b/libs/FML/Script/Features/Tooltip.php @@ -13,150 +13,241 @@ use FML\Types\Scriptable; * Script Feature for showing Tooltips * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Tooltip extends ScriptFeature { - /* - * Protected properties - */ - /** @var Control $hoverControl */ - protected $hoverControl = null; - /** @var Control $tooltipControl */ - protected $tooltipControl = null; - protected $stayOnClick = null; - protected $invert = null; - protected $text = null; +class Tooltip extends ScriptFeature +{ - /** - * Construct a new Tooltip Feature - * - * @param Control $hoverControl (optional) Hover Control - * @param Control $tooltipControl (optional) Tooltip Control - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @param string $text (optional) Text to display if the TooltipControl is a Label - */ - public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = false, $invert = false, $text = null) { - if ($hoverControl !== null) { - $this->setHoverControl($hoverControl); - } - if ($tooltipControl !== null) { - $this->setTooltipControl($tooltipControl); - } - $this->setStayOnClick($stayOnClick); - $this->setInvert($invert); - if ($text !== null) { - $this->setText($text); - } - } + /** + * @var Control $hoverControl Hover Control + */ + protected $hoverControl = null; - /** - * Set the Hover Control - * - * @param Control $hoverControl Hover Control - * @return static - */ - public function setHoverControl(Control $hoverControl) { - $hoverControl->checkId(); - if ($hoverControl instanceof Scriptable) { - $hoverControl->setScriptEvents(true); - } - $this->hoverControl = $hoverControl; - return $this; - } + /** + * @var Control $tooltipControl Tooltip Control + */ + protected $tooltipControl = null; - /** - * Set the Tooltip Control - * - * @param Control $tooltipControl Tooltip Control - * @return static - */ - public function setTooltipControl(Control $tooltipControl) { - $this->tooltipControl = $tooltipControl->checkId()->setVisible(false); - return $this; - } + /** + * @var bool $stayOnClick Stay on click + */ + protected $stayOnClick = null; - /** - * Set to only show - * - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @return static - */ - public function setStayOnClick($stayOnClick) { - $this->stayOnClick = (bool)$stayOnClick; - return $this; - } + /** + * @var bool $invert Inverted visibility toggling + */ + protected $invert = null; - /** - * Set to only hide - * - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @return static - */ - public function setInvert($invert) { - $this->invert = (bool)$invert; - return $this; - } + /** + * @var string $text Tooltip Text + */ + protected $text = null; - /** - * Set text - * - * @param string $text (optional) Text to display if the TooltipControl is a Label - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * Construct a new Tooltip + * + * @api + * @param Control $hoverControl (optional) Hover Control + * @param Control $tooltipControl (optional) Tooltip Control + * @param bool $stayOnClick (optional) If the Tooltip should stay on click + * @param bool $invert (optional) If the visibility toggling should be inverted + * @param string $text (optional) Text to display if the TooltipControl is a Label + */ + public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = null, $invert = null, $text = null) + { + if ($hoverControl) { + $this->setHoverControl($hoverControl); + } + if ($tooltipControl) { + $this->setTooltipControl($tooltipControl); + } + if ($stayOnClick) { + $this->setStayOnClick($stayOnClick); + } + if ($invert) { + $this->setInvert($invert); + } + if ($text) { + $this->setText($text); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $hoverControlId = $this->hoverControl->getId(true, true); - $tooltipControlId = $this->tooltipControl->getId(true, true); + /** + * Get the Hover Control + * + * @api + * @return Control + */ + public function getHoverControl() + { + return $this->hoverControl; + } - // MouseOver - $visibility = ($this->invert ? 'False' : 'True'); - $scriptText = " + /** + * Set the Hover Control + * + * @api + * @param Control $hoverControl Hover Control + * @return static + */ + public function setHoverControl(Control $hoverControl) + { + $hoverControl->checkId(); + if ($hoverControl instanceof Scriptable) { + $hoverControl->setScriptEvents(true); + } + $this->hoverControl = $hoverControl; + return $this; + } + + /** + * Get the Tooltip Control + * + * @api + * @return Control + */ + public function getTooltipControl() + { + return $this->tooltipControl; + } + + /** + * Set the Tooltip Control + * + * @api + * @param Control $tooltipControl Tooltip Control + * @return static + */ + public function setTooltipControl(Control $tooltipControl) + { + $tooltipControl->checkId(); + $tooltipControl->setVisible(false); + $this->tooltipControl = $tooltipControl; + return $this; + } + + /** + * Get the staying on click + * + * @api + * @return bool + */ + public function getStayOnClick() + { + return $this->stayOnClick; + } + + /** + * Set the staying on click + * + * @api + * @param bool $stayOnClick If the Tooltip should stay on click + * @return static + */ + public function setStayOnClick($stayOnClick) + { + $this->stayOnClick = (bool)$stayOnClick; + return $this; + } + + /** + * Get inverting of the visibility + * + * @api + * @return bool + */ + public function getInvert() + { + return $this->invert; + } + + /** + * Set inverting of the visibility + * + * @api + * @param bool $invert If the visibility toggling should be inverted + * @return static + */ + public function setInvert($invert) + { + $this->invert = (bool)$invert; + return $this; + } + + /** + * Get the text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the text + * + * @api + * @param string $text Text to display if the TooltipControl is a Label + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $hoverControlId = Builder::escapeText($this->hoverControl->getId()); + $tooltipControlId = Builder::escapeText($this->tooltipControl->getId()); + + // MouseOver + $visibility = Builder::getBoolean(!$this->invert); + $scriptText = " if (Event.Control.ControlId == {$hoverControlId}) { declare TooltipControl = Page.GetFirstChild({$tooltipControlId}); TooltipControl.Visible = {$visibility};"; - if (is_string($this->text) && ($this->tooltipControl instanceof Label)) { - $tooltipText = Builder::escapeText($this->text, true); - $scriptText .= " + if (is_string($this->text) && ($this->tooltipControl instanceof Label)) { + $tooltipText = Builder::escapeText($this->text); + $scriptText .= " declare TooltipLabel = (TooltipControl as CMlLabel); TooltipLabel.Value = {$tooltipText};"; - } - $scriptText .= " + } + $scriptText .= " }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText); + $script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText); - // MouseOut - $visibility = ($this->invert ? 'True' : 'False'); - $scriptText = " + // MouseOut + $visibility = Builder::getBoolean($this->invert); + $scriptText = " if (Event.Control.ControlId == {$hoverControlId}) { declare TooltipControl = Page.GetFirstChild({$tooltipControlId});"; - if ($this->stayOnClick) { - $scriptText .= " + if ($this->stayOnClick) { + $scriptText .= " declare FML_Clicked for Event.Control = False; if (!FML_Clicked) "; - } - $scriptText .= " + } + $scriptText .= " TooltipControl.Visible = {$visibility}; }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText); + $script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText); - // MouseClick - if ($this->stayOnClick) { - $scriptText = " + // MouseClick + if ($this->stayOnClick) { + $scriptText = " if (Event.Control.ControlId == {$hoverControlId}) { declare FML_Clicked for Event.Control = False; FML_Clicked = !FML_Clicked; }"; - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText); - } - return $this; - } + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText); + } + return $this; + } + } diff --git a/libs/FML/Script/Features/UISound.php b/libs/FML/Script/Features/UISound.php index 70152f67..eba267ae 100644 --- a/libs/FML/Script/Features/UISound.php +++ b/libs/FML/Script/Features/UISound.php @@ -12,157 +12,249 @@ use FML\Types\Scriptable; * Script Feature for playing a UISound * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class UISound extends ScriptFeature { - /* - * Constants - */ - const Bonus = 'Bonus'; - const Capture = 'Capture'; - const Checkpoint = 'Checkpoint'; - const Combo = 'Combo'; - const Custom1 = 'Custom1'; - const Custom2 = 'Custom2'; - const Custom3 = 'Custom3'; - const Custom4 = 'Custom4'; - const Default_ = 'Default'; - const EndMatch = 'EndMatch'; - const EndRound = 'EndRound'; - const Finish = 'Finish'; - const FirstHit = 'FirstHit'; - const Notice = 'Notice'; - const PhaseChange = 'PhaseChange'; - const PlayerEliminated = 'PlayerEliminated'; - const PlayerHit = 'PlayerHit'; - const PlayersRemaining = 'PlayersRemaining'; - const RankChange = 'RankChange'; - const Record = 'Record'; - const ScoreProgress = 'ScoreProgress'; - const Silence = 'Silence'; - const StartMatch = 'StartMatch'; - const StartRound = 'StartRound'; - const TieBreakPoint = 'TieBreakPoint'; - const TiePoint = 'TiePoint'; - const TimeOut = 'TimeOut'; - const VictoryPoint = 'VictoryPoint'; - const Warning = 'Warning'; +class UISound extends ScriptFeature +{ - /* - * Protected properties - */ - protected $soundName = null; - /** @var Control $control */ - protected $control = null; - protected $variant = 0; - protected $volume = 1.; - protected $labelName = null; + /* + * Constants + */ + const Bonus = "Bonus"; + const Capture = "Capture"; + const Checkpoint = "Checkpoint"; + const Combo = "Combo"; + const Custom1 = "Custom1"; + const Custom2 = "Custom2"; + const Custom3 = "Custom3"; + const Custom4 = "Custom4"; + const Default_ = "Default"; + const EndMatch = "EndMatch"; + const EndRound = "EndRound"; + const Finish = "Finish"; + const FirstHit = "FirstHit"; + const Notice = "Notice"; + const PhaseChange = "PhaseChange"; + const PlayerEliminated = "PlayerEliminated"; + const PlayerHit = "PlayerHit"; + const PlayersRemaining = "PlayersRemaining"; + const RankChange = "RankChange"; + const Record = "Record"; + const ScoreProgress = "ScoreProgress"; + const Silence = "Silence"; + const StartMatch = "StartMatch"; + const StartRound = "StartRound"; + const TieBreakPoint = "TieBreakPoint"; + const TiePoint = "TiePoint"; + const TimeOut = "TimeOut"; + const VictoryPoint = "VictoryPoint"; + const Warning = "Warning"; - /** - * Construct a new UISound Feature - * - * @param string $soundName (optional) Played sound - * @param Control $control (optional) Action Control - * @param int $variant (optional) Sound variant - * @param string $labelName (optional) Script Label name - */ - public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) { - if ($soundName !== null) { - $this->setSoundName($soundName); - } - if ($control !== null) { - $this->setControl($control); - } - $this->setVariant($variant); - $this->setLabelName($labelName); - } + /** + * @var string $soundName Sound name + */ + protected $soundName = null; - /** - * Set the sound to play - * - * @param string $soundName Sound name - * @return static - */ - public function setSoundName($soundName) { - $this->soundName = (string)$soundName; - return $this; - } + /** + * @var Control $control Sound Control + */ + protected $control = null; - /** - * Set the Control - * - * @param Control $control Action Control - * @return static - */ - public function setControl(Control $control) { - $control->checkId(); - if ($control instanceof Scriptable) { - $control->setScriptEvents(true); - } - $this->control = $control; - return $this; - } + /** + * @var int $variant Sound variant + */ + protected $variant = 0; - /** - * Set the sound variant - * - * @param int $variant Sound variant - * @return static - */ - public function setVariant($variant) { - $this->variant = (int)$variant; - return $this; - } + /** + * @var string $labelName Script Label name + */ + protected $labelName = null; - /** - * Set the volume - * - * @param float $volume Sound volume - * @return static - */ - public function setVolume($volume) { - $this->volume = (float)$volume; - return $this; - } + /** + * @var float $volume Volume + */ + protected $volume = 1.; - /** - * Set the label name - * - * @param string $labelName Script Label name - * @return static - */ - public function setLabelName($labelName) { - $this->labelName = (string)$labelName; - return $this; - } + /** + * Construct a new UISound + * + * @api + * @param string $soundName (optional) Sound name + * @param Control $control (optional) Sound Control + * @param int $variant (optional) Sound variant + * @param string $labelName (optional) Script Label name + */ + public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) + { + if ($soundName) { + $this->setSoundName($soundName); + } + if ($control) { + $this->setControl($control); + } + if ($variant) { + $this->setVariant($variant); + } + if ($labelName) { + $this->setLabelName($labelName); + } + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); - return $this; - } + /** + * Get the sound to play + * + * @api + * @return string + */ + public function getSoundName() + { + return $this->soundName; + } - /** - * Get the script text - * - * @return string - */ - protected function getScriptText() { - if ($this->control) { - // Control event - $controlId = Builder::escapeText($this->control->getId(), true); - $scriptText = " + /** + * Set the sound to play + * + * @api + * @param string $soundName Sound name + * @return static + */ + public function setSoundName($soundName) + { + $this->soundName = (string)$soundName; + return $this; + } + + /** + * Get the sound Control + * + * @api + * @return Control + */ + public function getControl() + { + return $this->control; + } + + /** + * Set the sound Control + * + * @api + * @param Control $control (optional) Sound Control + * @return static + */ + public function setControl(Control $control = null) + { + if ($control) { + $control->checkId(); + if ($control instanceof Scriptable) { + $control->setScriptEvents(true); + } + } + $this->control = $control; + return $this; + } + + /** + * Get the sound variant + * + * @api + * @return int + */ + public function getVariant() + { + return $this->variant; + } + + /** + * Set the sound variant + * + * @api + * @param int $variant Sound variant + * @return static + */ + public function setVariant($variant) + { + $this->variant = (int)$variant; + return $this; + } + + /** + * Get the Script Label name + * + * @api + * @return string + */ + public function getLabelName() + { + return $this->labelName; + } + + /** + * Set the Script Label name + * + * @api + * @param string $labelName Script Label name + * @return static + */ + public function setLabelName($labelName) + { + $this->labelName = (string)$labelName; + return $this; + } + + /** + * Get the volume + * + * @api + * @return float + */ + public function getVolume() + { + return $this->volume; + } + + /** + * Set the volume + * + * @api + * @param float $volume Sound volume + * @return static + */ + public function setVolume($volume) + { + $this->volume = (float)$volume; + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); + return $this; + } + + /** + * Get the script text + * + * @return string + */ + protected function getScriptText() + { + if ($this->control) { + // Control event + $controlId = Builder::escapeText($this->control->getId()); + return " if (Event.Control.ControlId == {$controlId}) { PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume}); }"; - } else { - // Other - $scriptText = " + } + + // Other events + return " PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});"; - } - return $scriptText; - } + } + } diff --git a/libs/FML/Script/Features/ValuePickerFeature.php b/libs/FML/Script/Features/ValuePickerFeature.php index fe12841f..eebe8be5 100644 --- a/libs/FML/Script/Features/ValuePickerFeature.php +++ b/libs/FML/Script/Features/ValuePickerFeature.php @@ -13,150 +13,211 @@ use FML\Script\ScriptLabel; * Script Feature for creating a ValuePicker behavior * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ValuePickerFeature extends ScriptFeature { - /* - * Constants - */ - const FUNCTION_UPDATE_PICKER_VALUE = 'FML_UpdatePickerValue'; - const VAR_PICKER_VALUES = 'FML_Picker_Values'; - const VAR_PICKER_DEFAULT_VALUE = 'FML_Picker_Default_Value'; - const VAR_PICKER_ENTRY_ID = 'FML_Picker_EntryId'; +class ValuePickerFeature extends ScriptFeature +{ - /* - * Protected properties - */ - /** @var Label $label */ - protected $label = null; - /** @var Entry $entry */ - protected $entry = null; - protected $values = array(); - protected $default = null; + /* + * Constants + */ + const FUNCTION_UPDATE_PICKER_VALUE = "FML_UpdatePickerValue"; + const VAR_PICKER_VALUES = "FML_Picker_Values"; + const VAR_PICKER_DEFAULT_VALUE = "FML_Picker_Default_Value"; + const VAR_PICKER_ENTRY_ID = "FML_Picker_EntryId"; - /** - * Construct a new ValuePicker Feature - * - * @param Label $label (optional) ValuePicker Label - * @param Entry $entry (optional) Hidden Entry - * @param array $values (optional) Possible values - * @param string $default (optional) Default value - */ - public function __construct(Label $label = null, Entry $entry = null, array $values = array(), $default = null) { - if ($label !== null) { - $this->setLabel($label); - } - if ($entry !== null) { - $this->setEntry($entry); - } - if (!empty($values)) { - $this->setValues($values); - } - if ($default !== null) { - $this->setDefault($default); - } - } + /** + * @var Label $label Label + */ + protected $label = null; - /** - * Set the ValuePicker Label - * - * @param Label $label ValuePicker Label - * @return static - */ - public function setLabel(Label $label) { - $this->label = $label->checkId()->setScriptEvents(true); - return $this; - } + /** + * @var Entry $entry Hidden Entry + */ + protected $entry = null; - /** - * Get the ValuePicker Label - * - * @return \FML\Controls\Label - */ - public function getLabel() { - return $this->label; - } + /** + * @var string[] $values Possible values + */ + protected $values = array(); - /** - * Set the hidden Entry - * - * @param Entry $entry Hidden Entry - * @return static - */ - public function setEntry(Entry $entry) { - $this->entry = $entry->checkId(); - return $this; - } + /** + * @var string $default Default value + */ + protected $default = null; - /** - * Get the hidden Entry - * - * @return \FML\Controls\Entry - */ - public function getEntry() { - return $this->entry; - } + /** + * Construct a new ValuePicker Feature + * + * @api + * @param Label $label (optional) Label + * @param Entry $entry (optional) Hidden Entry + * @param string[] $values (optional) Possible values + * @param string $default (optional) Default value + */ + public function __construct(Label $label = null, Entry $entry = null, array $values = null, $default = null) + { + if ($label) { + $this->setLabel($label); + } + if ($entry) { + $this->setEntry($entry); + } + if ($values && !empty($values)) { + $this->setValues($values); + } + if ($default !== null) { + $this->setDefault($default); + } + } - /** - * Set the possible values - * - * @param array $values Possible values - * @return static - */ - public function setValues(array $values) { - $this->values = array(); - foreach ($values as $value) { - array_push($this->values, (string)$value); - } - return $this; - } + /** + * Get the Label + * + * @api + * @return Label + */ + public function getLabel() + { + return $this->label; + } - /** - * Set the default value - * - * @param string $default Default value - * @return static - */ - public function setDefault($default) { - $this->default = (string)$default; - } + /** + * Set the Label + * + * @api + * @param Label $label Label + * @return static + */ + public function setLabel(Label $label) + { + $label->checkId(); + $label->setScriptEvents(true); + $this->label = $label; + return $this; + } - /** - * Get the default value - * - * @return string - */ - public function getDefault() { - if ($this->default) { - return $this->default; - } - if (!empty($this->values)) { - return reset($this->values); - } - return null; - } + /** + * Get the hidden Entry + * + * @api + * @return Entry + */ + public function getEntry() + { + return $this->entry; + } - /** - * @see \FML\Script\Features\ScriptFeature::prepare() - */ - public function prepare(Script $script) { - if ($this->label) { - $script->setScriptInclude(ScriptInclude::TEXTLIB); - $script->addScriptFunction(self::FUNCTION_UPDATE_PICKER_VALUE, $this->buildUpdatePickerValueFunction()); - $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true); - $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText()); - } - return $this; - } + /** + * Set the hidden Entry + * + * @api + * @param Entry $entry Hidden Entry + * @return static + */ + public function setEntry(Entry $entry) + { + $entry->checkId(); + $this->entry = $entry; + return $this; + } - /** - * Build the function text - * - * @return string - */ - protected function buildUpdatePickerValueFunction() { - return " + /** + * Get the possible values + * + * @api + * @return string[] + */ + public function getValues() + { + return $this->values; + } + + /** + * Add a possible value + * + * @api + * @param string $value Possible value + * @return static + */ + public function addValue($value) + { + array_push($this->values, (string)$value); + return $this; + } + + /** + * Set the possible values + * + * @api + * @param string[] $values Possible values + * @return static + */ + public function setValues(array $values) + { + $this->values = array(); + foreach ($values as $value) { + $this->addValue($value); + } + return $this; + } + + /** + * Get the default value + * + * @api + * @return string + */ + public function getDefault() + { + if ($this->default) { + return $this->default; + } + if (!empty($this->values)) { + return reset($this->values); + } + return null; + } + + /** + * Set the default value + * + * @api + * @param string $default Default value + * @return static + */ + public function setDefault($default) + { + $this->default = (string)$default; + if ($this->default && !in_array($this->default, $this->values, true)) { + $this->addValue($this->default); + } + return $this; + } + + /** + * @see ScriptFeature::prepare() + */ + public function prepare(Script $script) + { + if ($this->label) { + $script->setScriptInclude(ScriptInclude::TEXTLIB); + $script->addScriptFunction(self::FUNCTION_UPDATE_PICKER_VALUE, $this->buildUpdatePickerValueFunction()); + $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true); + $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText()); + } + return $this; + } + + /** + * Build the function text + * + * @return string + */ + protected function buildUpdatePickerValueFunction() + { + return " Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) { declare " . self::VAR_PICKER_VALUES . " as Values for _Label = Text[]; declare NewValueIndex = -1; @@ -169,58 +230,63 @@ Void " . self::FUNCTION_UPDATE_PICKER_VALUE . "(CMlLabel _Label) { NewValueIndex = 0; } } - declare NewValue = " . Builder::EMPTY_STRING . "; + declare NewValue = \"\"; if (Values.existskey(NewValueIndex)) { NewValue = Values[NewValueIndex]; } else { - declare " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for _Label = " . Builder::EMPTY_STRING . "; + declare " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for _Label = \"\"; NewValue = Default; } _Label.Value = NewValue; - declare " . self::VAR_PICKER_ENTRY_ID . " as EntryId for _Label = " . Builder::EMPTY_STRING . "; - if (EntryId != " . Builder::EMPTY_STRING . ") { + declare " . self::VAR_PICKER_ENTRY_ID . " as EntryId for _Label = \"\"; + if (EntryId != \"\") { declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry); Entry.Value = NewValue; } }"; - } + } - /** - * Build the init script text - * - * @return string - */ - protected function buildInitScriptText() { - $labelId = $this->label->getId(true, true); - $entryId = '""'; - if ($this->entry) { - $entryId = $this->entry->getId(true, true); - } - $values = Builder::getArray($this->values); - $default = Builder::escapeText($this->getDefault(), true); - return " -declare Label_Picker <=> (Page.GetFirstChild({$labelId}) as CMlLabel); + /** + * Build the init script text + * + * @return string + */ + protected function buildInitScriptText() + { + $labelId = Builder::getId($this->label); + $entryId = Builder::EMPTY_STRING; + if ($this->entry) { + $entryId = Builder::getId($this->entry); + } + + $values = Builder::getArray($this->values); + $default = Builder::escapeText($this->getDefault()); + + return " +declare Label_Picker <=> (Page.GetFirstChild(\"{$labelId}\") as CMlLabel); declare Text[] " . self::VAR_PICKER_VALUES . " as Values for Label_Picker; Values = {$values}; declare Text " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for Label_Picker; Default = {$default}; declare Text " . self::VAR_PICKER_ENTRY_ID . " as EntryId for Label_Picker; -EntryId = {$entryId}; +EntryId = \"{$entryId}\"; " . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker); "; - } + } - /** - * Build the script text for Label clicks - * - * @return string - */ - protected function buildClickScriptText() { - $labelId = $this->label->getId(true, true); - return " -if (Event.ControlId == {$labelId}) { + /** + * Build the script text for Label clicks + * + * @return string + */ + protected function buildClickScriptText() + { + $labelId = Builder::getId($this->label); + return " +if (Event.ControlId == \"{$labelId}\") { declare Label_Picker <=> (Event.Control as CMlLabel); " . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker); }"; - } + } + } diff --git a/libs/FML/Script/Script.php b/libs/FML/Script/Script.php index 57866cb3..fbb7d1a7 100644 --- a/libs/FML/Script/Script.php +++ b/libs/FML/Script/Script.php @@ -8,276 +8,307 @@ use FML\Script\Features\ScriptFeature; * Class representing the ManiaLink Script * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Script { - /* - * Constants - */ - const TICKINTERVAL = 250; - const VAR_ScriptStart = 'FML_ScriptStart'; - const VAR_LoopCounter = 'FML_LoopCounter'; - const VAR_LastTick = 'FML_LastTick'; +class Script +{ - /* - * Protected properties - */ - protected $tagName = 'script'; - protected $features = array(); - protected $includes = array(); - protected $constants = array(); - protected $functions = array(); - protected $customLabels = array(); - protected $genericLabels = array(); + /* + * Constants + */ + const TICKINTERVAL = 250; + const VAR_ScriptStart = 'FML_ScriptStart'; + const VAR_LoopCounter = 'FML_LoopCounter'; + const VAR_LastTick = 'FML_LastTick'; - /** - * Set a Script Include - * - * @param string $file Include file - * @param string $namespace Include namespace - * @return static - */ - public function setScriptInclude($file, $namespace = null) { - if ($file instanceof ScriptInclude) { - $scriptInclude = $file; - } else { - $scriptInclude = new ScriptInclude($file, $namespace); - } - $this->includes[$scriptInclude->getNamespace()] = $scriptInclude; - return $this; - } + /* + * Protected properties + */ + protected $tagName = 'script'; + protected $features = array(); + protected $includes = array(); + protected $constants = array(); + protected $functions = array(); + protected $customLabels = array(); + protected $genericLabels = array(); - /** - * Add a Script Constant - * - * @param string $name Constant name - * @param string $value Constant value - * @return static - */ - public function addScriptConstant($name, $value = null) { - if ($name instanceof ScriptConstant) { - $scriptConstant = $name; - } else { - $scriptConstant = new ScriptConstant($name, $value); - } - if (!in_array($scriptConstant, $this->constants)) { - array_push($this->constants, $scriptConstant); - } - return $this; - } + /** + * Set a Script Include + * + * @api + * @param string|ScriptInclude $file Include file or ScriptInclude + * @param string $namespace Include namespace + * @return static + */ + public function setScriptInclude($file, $namespace = null) + { + if ($file instanceof ScriptInclude) { + $scriptInclude = $file; + } else { + $scriptInclude = new ScriptInclude($file, $namespace); + } + $this->includes[$scriptInclude->getNamespace()] = $scriptInclude; + return $this; + } - /** - * Add a Script Function - * - * @param string $name Function name - * @param string $text Function text - * @return static - */ - public function addScriptFunction($name, $text = null) { - if ($name instanceof ScriptFunction) { - $scriptFunction = $name; - } else { - $scriptFunction = new ScriptFunction($name, $text); - } - if (!in_array($scriptFunction, $this->functions)) { - array_push($this->functions, $scriptFunction); - } - return $this; - } + /** + * Add a Script Constant + * + * @api + * @param string|ScriptConstant $name Constant name or ScriptConstant + * @param string $value Constant value + * @return static + */ + public function addScriptConstant($name, $value = null) + { + if ($name instanceof ScriptConstant) { + $scriptConstant = $name; + } else { + $scriptConstant = new ScriptConstant($name, $value); + } + if (!in_array($scriptConstant, $this->constants)) { + array_push($this->constants, $scriptConstant); + } + return $this; + } - /** - * Add a custom Script text - * - * @param string $name Label name - * @param string $text Script text - * @return static - */ - public function addCustomScriptLabel($name, $text = null) { - if ($name instanceof ScriptLabel) { - $scriptLabel = $name; - } else { - $scriptLabel = new ScriptLabel($name, $text); - } - array_push($this->customLabels, $scriptLabel); - return $this; - } + /** + * Add a Script Function + * + * @api + * @param string|ScriptFunction $name Function name or ScriptFunction + * @param string $text Function text + * @return static + */ + public function addScriptFunction($name, $text = null) + { + if ($name instanceof ScriptFunction) { + $scriptFunction = $name; + } else { + $scriptFunction = new ScriptFunction($name, $text); + } + if (!in_array($scriptFunction, $this->functions)) { + array_push($this->functions, $scriptFunction); + } + return $this; + } - /** - * Append a generic Script text for the next rendering - * - * @param string $name Label name - * @param string $text Script text - * @param bool $isolated (optional) Whether to isolate the Label Script - * @return static - */ - public function appendGenericScriptLabel($name, $text = null, $isolated = false) { - if ($name instanceof ScriptLabel) { - $scriptLabel = $name; - } else { - $scriptLabel = new ScriptLabel($name, $text, $isolated); - } - array_push($this->genericLabels, $scriptLabel); - return $this; - } + /** + * Add a custom Script text + * + * @api + * @param string|ScriptLabel $name Label name or ScriptLabel + * @param string $text Script text + * @return static + */ + public function addCustomScriptLabel($name, $text = null) + { + if ($name instanceof ScriptLabel) { + $scriptLabel = $name; + } else { + $scriptLabel = new ScriptLabel($name, $text); + } + if (!in_array($scriptLabel, $this->customLabels)) { + array_push($this->customLabels, $scriptLabel); + } + return $this; + } - /** - * Remove all generic Script texts - * - * @return static - */ - public function resetGenericScriptLabels() { - $this->genericLabels = array(); - return $this; - } + /** + * Append a generic Script text for the next rendering + * + * @TODO: get rid of generic script labels approach + * @param string|ScriptLabel $name Label name or ScriptLabel + * @param string $text Script text + * @param bool $isolated (optional) Whether to isolate the Label Script + * @return static + */ + public function appendGenericScriptLabel($name, $text = null, $isolated = false) + { + if ($name instanceof ScriptLabel) { + $scriptLabel = $name; + } else { + $scriptLabel = new ScriptLabel($name, $text, $isolated); + } + if (!in_array($scriptLabel, $this->genericLabels)) { + array_push($this->genericLabels, $scriptLabel); + } + return $this; + } - /** - * Add a Script Feature - * - * @param ScriptFeature $feature Script Feature - * @return static - */ - public function addFeature(ScriptFeature $feature) { - if (!in_array($feature, $this->features, true)) { - array_push($this->features, $feature); - } - return $this; - } + /** + * Remove all generic Script texts + * + * @TODO: get rid of generic script labels approach + * @return static + */ + public function resetGenericScriptLabels() + { + $this->genericLabels = array(); + return $this; + } - /** - * Load the given Script Feature - * - * @param ScriptFeature $scriptFeature Script Feature to load - * @return static - */ - public function loadFeature(ScriptFeature $scriptFeature) { - $scriptFeature->prepare($this); - return $this; - } + /** + * Add a Script Feature + * + * @api + * @param ScriptFeature $feature Script Feature + * @return static + */ + public function addFeature(ScriptFeature $feature) + { + if (!in_array($feature, $this->features, true)) { + array_push($this->features, $feature); + } + return $this; + } - /** - * Load the given Script Features - * - * @param ScriptFeature[] $scriptFeatures Script Features to load - * @return static - */ - public function loadFeatures(array $scriptFeatures) { - foreach ($scriptFeatures as $scriptFeature) { - $this->loadFeature($scriptFeature); - } - return $this; - } + /** + * Load the given Script Feature + * + * @param ScriptFeature $scriptFeature Script Feature to load + * @return static + */ + public function loadFeature(ScriptFeature $scriptFeature) + { + $scriptFeature->prepare($this); + return $this; + } - /** - * Check if the Script has content so that it needs to be rendered - * - * @return bool - */ - public function needsRendering() { - if ($this->features || $this->customLabels || $this->genericLabels) { - return true; - } - return false; - } + /** + * Load the given Script Features + * + * @param ScriptFeature[] $scriptFeatures Script Features to load + * @return static + */ + public function loadFeatures(array $scriptFeatures) + { + foreach ($scriptFeatures as $scriptFeature) { + $this->loadFeature($scriptFeature); + } + return $this; + } - /** - * Build the complete Script text - * - * @return string - */ - public function buildScriptText() { - $scriptText = PHP_EOL; - $scriptText .= $this->getHeaderComment(); - $scriptText .= $this->getIncludes(); - $scriptText .= $this->getConstants(); - $scriptText .= $this->getFunctions(); - $scriptText .= $this->getLabels(); - $scriptText .= $this->getMainFunction(); - return $scriptText; - } + /** + * Check if the Script has content so that it needs to be rendered + * + * @return bool + */ + public function needsRendering() + { + if ($this->features || $this->customLabels || $this->genericLabels) { + return true; + } + return false; + } - /** - * Build the Script XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the XML element should be created - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $this->loadFeatures($this->features); - $scriptXml = $domDocument->createElement($this->tagName); - $scriptText = $this->buildScriptText(); - $scriptComment = $domDocument->createComment($scriptText); - $scriptXml->appendChild($scriptComment); - return $scriptXml; - } + /** + * Build the complete Script text + * + * @return string + */ + public function buildScriptText() + { + $scriptText = PHP_EOL; + $scriptText .= $this->getHeaderComment(); + $scriptText .= $this->getIncludes(); + $scriptText .= $this->getConstants(); + $scriptText .= $this->getFunctions(); + $scriptText .= $this->getLabels(); + $scriptText .= $this->getMainFunction(); + return $scriptText; + } - /** - * Get the header comment - * - * @return string - */ - protected function getHeaderComment() { - $headerComment = '/**************************************************** + /** + * Render the Script + * + * @param \DOMDocument $domDocument DOMDocument for which the Script should be created + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $this->loadFeatures($this->features); + $scriptXml = $domDocument->createElement($this->tagName); + $scriptText = $this->buildScriptText(); + $scriptComment = $domDocument->createComment($scriptText); + $scriptXml->appendChild($scriptComment); + return $scriptXml; + } + + /** + * Get the header comment + * + * @return string + */ + protected function getHeaderComment() + { + $headerComment = '/**************************************************** * FancyManiaLinks'; - if (defined('FML_VERSION')) { - $headerComment .= ' v' . FML_VERSION; - } - $headerComment .= ' by steeffeen * + if (defined('FML_VERSION')) { + $headerComment .= ' v' . FML_VERSION; + } + $headerComment .= ' by steeffeen * * http://github.com/steeffeen/FancyManiaLinks * ****************************************************/ '; - return $headerComment; - } + return $headerComment; + } - /** - * Get the Includes text - * - * @return string - */ - protected function getIncludes() { - $includesText = implode(PHP_EOL, $this->includes); - return $includesText; - } + /** + * Get the Includes text + * + * @return string + */ + protected function getIncludes() + { + $includesText = implode(PHP_EOL, $this->includes); + return $includesText; + } - /** - * Get the Constants text - * - * @return string - */ - protected function getConstants() { - $constantsText = implode(PHP_EOL, $this->constants); - return $constantsText; - } + /** + * Get the Constants text + * + * @return string + */ + protected function getConstants() + { + $constantsText = implode(PHP_EOL, $this->constants); + return $constantsText; + } - /** - * Get the Functions text - * - * @return string - */ - protected function getFunctions() { - $functionsText = implode(PHP_EOL, $this->functions); - return $functionsText; - } + /** + * Get the Functions text + * + * @return string + */ + protected function getFunctions() + { + $functionsText = implode(PHP_EOL, $this->functions); + return $functionsText; + } - /** - * Get the Labels text - * - * @return string - */ - protected function getLabels() { - $customLabelsText = implode(PHP_EOL, $this->customLabels); - $genericLabelsText = implode(PHP_EOL, $this->genericLabels); - return $customLabelsText . $genericLabelsText; - } + /** + * Get the Labels text + * + * @return string + */ + protected function getLabels() + { + $customLabelsText = implode(PHP_EOL, $this->customLabels); + $genericLabelsText = implode(PHP_EOL, $this->genericLabels); + return $customLabelsText . $genericLabelsText; + } - /** - * Get the main function text - * - * @return string - */ - protected function getMainFunction() { - $mainFunction = ' + /** + * Get the main function text + * + * @return string + */ + protected function getMainFunction() + { + $mainFunction = ' Void FML_Dummy() {} main() { declare ' . self::VAR_ScriptStart . ' = Now; @@ -312,6 +343,17 @@ main() { ' . self::VAR_LastTick . ' = Now; } }'; - return $mainFunction; - } + return $mainFunction; + } + + /** + * Get the string representation + * + * @return string + */ + public function __toString() + { + return $this->buildScriptText(); + } + } diff --git a/libs/FML/Script/ScriptConstant.php b/libs/FML/Script/ScriptConstant.php index 0f4db636..932d73c0 100644 --- a/libs/FML/Script/ScriptConstant.php +++ b/libs/FML/Script/ScriptConstant.php @@ -6,55 +6,95 @@ namespace FML\Script; * Class representing a Constant of the ManiaLink Script * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ScriptConstant { - /* - * Protected properties - */ - protected $name = null; - protected $value = null; +class ScriptConstant +{ - /** - * Construct a new Script Constant - * - * @param string $name (optional) Constant name - * @param string $value (optional) Constant value - */ - public function __construct($name = null, $value = null) { - $this->setName($name); - $this->setValue($value); - } + /** + * @var string $name Name + */ + protected $name = null; - /** - * Set the name - * - * @param string $name Constant name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var mixed $value Value + */ + protected $value = null; - /** - * Set the value - * - * @param string $value Constant value - * @return static - */ - public function setValue($value) { - $this->value = $value; - return $this; - } + /** + * Construct a new Script Constant + * + * @api + * @param string $name (optional) Constant name + * @param mixed $value (optional) Constant value + */ + public function __construct($name = null, $value = null) + { + if ($name) { + $this->setName($name); + } + if ($value !== null) { + $this->setValue($value); + } + } + + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the name + * + * @api + * @param string $name Constant name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the value + * + * @api + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * Set the value + * + * @api + * @param mixed $value Constant value + * @return static + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + + /** + * Build the Script Constant text + * + * @return string + */ + public function __toString() + { + return Builder::getConstant($this->name, $this->value); + } - /** - * Build the Script Constant text - * - * @return string - */ - public function __toString() { - return Builder::getConstant($this->name, $this->value); - } } diff --git a/libs/FML/Script/ScriptFunction.php b/libs/FML/Script/ScriptFunction.php index c4163285..32e87a15 100644 --- a/libs/FML/Script/ScriptFunction.php +++ b/libs/FML/Script/ScriptFunction.php @@ -6,55 +6,95 @@ namespace FML\Script; * Class representing a Function of the ManiaLink Script * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ScriptFunction { - /* - * Protected properties - */ - protected $name = null; - protected $text = null; +class ScriptFunction +{ - /** - * Construct a new Script Function - * - * @param string $name (optional) Function name - * @param string $text (optional) Function text - */ - public function __construct($name = null, $text = null) { - $this->setName($name); - $this->setText($text); - } + /** + * @var string $name Function name + */ + protected $name = null; - /** - * Set the name - * - * @param string $name Function name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $text Function text + */ + protected $text = null; - /** - * Set the text - * - * @param string $text Function text - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * Construct a new Script Function + * + * @api + * @param string $name (optional) Function name + * @param string $text (optional) Function text + */ + public function __construct($name = null, $text = null) + { + if ($name) { + $this->setName($name); + } + if ($text) { + $this->setText($text); + } + } + + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the name + * + * @api + * @param string $name Function name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the text + * + * @api + * @param string $text Function text + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * Get the Script Function text + * + * @return string + */ + public function __toString() + { + return $this->text; + } - /** - * Get the Script Function text - * - * @return string - */ - public function __toString() { - return $this->text; - } } diff --git a/libs/FML/Script/ScriptInclude.php b/libs/FML/Script/ScriptInclude.php index 793a2876..c56695e2 100644 --- a/libs/FML/Script/ScriptInclude.php +++ b/libs/FML/Script/ScriptInclude.php @@ -6,70 +6,101 @@ namespace FML\Script; * Class representing an Include of the ManiaLink Script * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ScriptInclude { - /* - * Constants - */ - const MATHLIB = 'MathLib'; - const TEXTLIB = 'TextLib'; +class ScriptInclude +{ - /* - * Protected properties - */ - protected $file = null; - protected $namespace = null; + /* + * Constants + */ + const MATHLIB = 'MathLib'; + const TEXTLIB = 'TextLib'; - /** - * Construct a new Script Include - * - * @param string $file (optional) Include file - * @param string $namespace (optional) Include namespace - */ - public function __construct($file = null, $namespace = null) { - $this->setFile($file); - $this->setNamespace($namespace); - } + /** + * @var string $file File name + */ + protected $file = null; - /** - * Set the file - * - * @param string $file Include file - * @return static - */ - public function setFile($file) { - $this->file = (string)$file; - return $this; - } + /** + * @var string $namespace Namespace + */ + protected $namespace = null; - /** - * Set the namespace - * - * @param string $namespace Include namespace - * @return static - */ - public function setNamespace($namespace) { - $this->namespace = (string)$namespace; - return $this; - } + /** + * Construct a new Script Include + * + * @api + * @param string $file (optional) File name + * @param string $namespace (optional) Namespace + */ + public function __construct($file = null, $namespace = null) + { + if ($file) { + $this->setFile($file); + } + if ($namespace) { + $this->setNamespace($namespace); + } + } - /** - * Get the namespace - * - * @return string - */ - public function getNamespace() { - return $this->namespace; - } + /** + * Get the file + * + * @api + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Set the file + * + * @api + * @param string $file File name + * @return static + */ + public function setFile($file) + { + $this->file = (string)$file; + return $this; + } + + /** + * Get the namespace + * + * @api + * @return string + */ + public function getNamespace() + { + return $this->namespace; + } + + /** + * Set the namespace + * + * @api + * @param string $namespace Namespace + * @return static + */ + public function setNamespace($namespace) + { + $this->namespace = (string)$namespace; + return $this; + } + + /** + * Build the Script Include text + * + * @return string + */ + public function __toString() + { + return Builder::getInclude($this->file, $this->namespace); + } - /** - * Build the Script Include text - * - * @return string - */ - public function __toString() { - return Builder::getInclude($this->file, $this->namespace); - } } diff --git a/libs/FML/Script/ScriptLabel.php b/libs/FML/Script/ScriptLabel.php index b85388fe..689f749b 100644 --- a/libs/FML/Script/ScriptLabel.php +++ b/libs/FML/Script/ScriptLabel.php @@ -6,103 +6,164 @@ namespace FML\Script; * Class representing a part of the ManiaLink Script * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ScriptLabel { - /* - * Constants - */ - const ONINIT = 'FML_OnInit'; - const LOOP = 'FML_Loop'; - const TICK = 'FML_Tick'; - const ENTRYSUBMIT = 'FML_EntrySubmit'; - const KEYPRESS = 'FML_KeyPress'; - const MOUSECLICK = 'FML_MouseClick'; - const MOUSEOUT = 'FML_MouseOut'; - const MOUSEOVER = 'FML_MouseOver'; +class ScriptLabel +{ - /* - * Protected properties - */ - protected $name = null; - protected $text = null; - protected $isolated = null; + /* + * Constants + */ + const ONINIT = 'FML_OnInit'; + const LOOP = 'FML_Loop'; + const TICK = 'FML_Tick'; + const ENTRYSUBMIT = 'FML_EntrySubmit'; + const KEYPRESS = 'FML_KeyPress'; + const MOUSECLICK = 'FML_MouseClick'; + const MOUSEOUT = 'FML_MouseOut'; + const MOUSEOVER = 'FML_MouseOver'; - /** - * Construct a new ScriptLabel - * - * @param string $name (optional) Label name - * @param string $text (optional) Script text - * @param bool $isolated (optional) Isolate the Label Script - */ - public function __construct($name = self::LOOP, $text = null, $isolated = false) { - $this->setName($name); - $this->setText($text); - $this->setIsolated($isolated); - } + /** + * @var string $name Label name + */ + protected $name = null; - /** - * Set the name - * - * @param string $name Label name - * @return static - */ - public function setName($name) { - $this->name = (string)$name; - return $this; - } + /** + * @var string $text Script text + */ + protected $text = null; - /** - * Set the text - * - * @param string $text Script text - * @return static - */ - public function setText($text) { - $this->text = (string)$text; - return $this; - } + /** + * @var bool $isolated Isolate the script + */ + protected $isolated = null; - /** - * Set isolation - * - * @param bool $isolated Whether the code should be isolated in an own block - * @return static - */ - public function setIsolated($isolated) { - $this->isolated = (bool)$isolated; - return $this; - } + /** + * Construct a new ScriptLabel + * + * @api + * @param string $name (optional) Label name + * @param string $text (optional) Script text + * @param bool $isolated (optional) Isolate the script + */ + public function __construct($name = self::LOOP, $text = null, $isolated = null) + { + if ($name) { + $this->setName($name); + } + if ($text) { + $this->setText($text); + } + if ($isolated) { + $this->setIsolated($isolated); + } + } - /** - * Check if the given label is an event label - * - * @param string $label Label name - * @return bool - */ - public static function isEventLabel($label) { - if (in_array($label, static::getEventLabels())) { - return true; - } - return false; - } + /** + * Get the name + * + * @api + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Get the possible event label names - * - * @return string[] - */ - public static function getEventLabels() { - return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER); - } + /** + * Set the name + * + * @api + * @param string $name Label name + * @return static + */ + public function setName($name) + { + $this->name = (string)$name; + return $this; + } + + /** + * Get the text + * + * @api + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set the text + * + * @api + * @param string $text Script text + * @return static + */ + public function setText($text) + { + $this->text = (string)$text; + return $this; + } + + /** + * Get isolation + * + * @api + * @return bool + */ + public function getIsolated() + { + return $this->isolated; + } + + /** + * Set isolation + * + * @api + * @param bool $isolated If the code should be isolated in an own block + * @return static + */ + public function setIsolated($isolated) + { + $this->isolated = (bool)$isolated; + return $this; + } + + /** + * Build the full Script Label text + * + * @return string + */ + public function __toString() + { + return Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated); + } + + /** + * Get the possible event label names + * + * @return string[] + */ + public static function getEventLabels() + { + return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER); + } + + /** + * Check if the given label name describes an event label + * + * @param string $label Label name + * @return bool + */ + public static function isEventLabel($label) + { + if (in_array($label, static::getEventLabels())) { + return true; + } + return false; + } - /** - * Build the full Script Label text - * - * @return string - */ - public function __toString() { - return Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated); - } } diff --git a/libs/FML/Stylesheet/Mood.php b/libs/FML/Stylesheet/Mood.php index 400b1e76..47fdfceb 100644 --- a/libs/FML/Stylesheet/Mood.php +++ b/libs/FML/Stylesheet/Mood.php @@ -2,284 +2,531 @@ namespace FML\Stylesheet; - // Warning: The mood class isn't fully supported yet! - // Missing attributes: LDir1.. - /** * Class representing a Stylesheet Mood + * Warning: The mood class isn't fully supported yet - Missing attributes: LDir1 etc. * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Mood { - /* - * Protected properties - */ - protected $tagName = 'mood'; - protected $lAmbient_LinearRgb = null; - protected $cloudsRgbMinLinear = null; - protected $cloudsRgbMaxLinear = null; - protected $lDir0_LinearRgb = null; - protected $lDir0_Intens = 1.; - protected $lDir0_DirPhi = 0.; - protected $lDir0_DirTheta = 0.; - protected $lBall_LinearRgb = null; - protected $lBall_Intensity = 1.; - protected $lBall_Radius = 0.; - protected $fogColorSrgb = null; - protected $selfIllumColor = null; - protected $skyGradientV_Scale = 1.; - protected $skyGradientKeys = array(); +class Mood +{ - /** - * Create a new Mood object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var string $lightAmbientColor Light ambient color + */ + protected $lightAmbientColor = null; - /** - * Set ambient color in which the Elements reflect the light - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setLightAmbientColor($red, $green, $blue) { - $this->lAmbient_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var string $cloudsMinimumColor Clouds minimum color + */ + protected $cloudsMinimumColor = null; - /** - * Set minimum value for the background color range - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setCloudsColorMin($red, $green, $blue) { - $this->cloudsRgbMinLinear = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var string $cloudsMaximumColor Clouds maximum color + */ + protected $cloudsMaximumColor = null; - /** - * Set maximum value for the background color range - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setCloudsColorMax($red, $green, $blue) { - $this->cloudsRgbMaxLinear = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var string $light0Color Color of light source 0 + */ + protected $light0Color = null; - /** - * Set RGB color of light source 0 - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setLight0Color($red, $green, $blue) { - $this->lDir0_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var float $light0Intensity Intensity of light source 0 + */ + protected $light0Intensity = 1.; - /** - * Set intensity of light source 0 - * - * @param float $intensity Light intensity - * @return static - */ - public function setLight0Intensity($intensity) { - $this->lDir0_Intens = (float)$intensity; - return $this; - } + /** + * @var float $light0PhiAngle Phi angle of light source 0 + */ + protected $light0PhiAngle = 0.; - /** - * Set phi angle of light source 0 - * - * @param float $phiAngle Phi angle - * @return static - */ - public function setLight0PhiAngle($phiAngle) { - $this->lDir0_DirPhi = (float)$phiAngle; - return $this; - } + /** + * @var float $light0ThetaAngle Theta angle of light source 0 + */ + protected $light0ThetaAngle = 0.; - /** - * Set theta angle of light source 0 - * - * @param float $thetaAngle Theta angle - * @return static - */ - public function setLight0ThetaAngle($thetaAngle) { - $this->lDir0_DirTheta = (float)$thetaAngle; - return $this; - } + /** + * @var string $lightBallColor Light ball color + */ + protected $lightBallColor = null; - /** - * Set light ball color - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setLightBallColor($red, $green, $blue) { - $this->lBall_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var float $lightBallIntensity Light ball intensity + */ + protected $lightBallIntensity = 1.; - /** - * Set light ball intensity - * - * @param float $intensity Light ball intensity - * @return static - */ - public function setLightBallIntensity($intensity) { - $this->lBall_Intensity = (float)$intensity; - return $this; - } + /** + * @var float $lightBallRadius Light ball radius + */ + protected $lightBallRadius = 0.; - /** - * Set light ball radius - * - * @param float $radius Light ball radius - * @return static - */ - public function setLightBallRadius($radius) { - $this->lBall_Radius = (float)$radius; - return $this; - } + /** + * @var string $fogColor Fog color + */ + protected $fogColor = null; - /** - * Set fog color - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setFogColor($red, $green, $blue) { - $this->fogColorSrgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var float $selfIlluminationColor Self illumination color + */ + protected $selfIlluminationColor = null; - /** - * Set self illumination color - * - * @param float $red Red color value - * @param float $green Green color value - * @param float $blue Blue color value - * @return static - */ - public function setSelfIllumColor($red, $green, $blue) { - $this->selfIllumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); - return $this; - } + /** + * @var float $skyGradientV_Scale Sky gradient scale + */ + protected $skyGradientScale = 1.; - /** - * Set sky gradient scale - * - * @param float $scale Gradient scale - * @return static - */ - public function setSkyGradientScale($scale) { - $this->skyGradientV_Scale = (float)$scale; - return $this; - } + /** + * @var SkyGradientKey[] $skyGradientKeys Sky Gradient Keys + */ + protected $skyGradientKeys = array(); - /** - * Add a sky gradient key - * - * @param float $gradientX Scale value - * @param string $color Gradient color - * @return static - */ - public function addSkyGradientKey($gradientX, $color) { - $gradientX = (float)$gradientX; - $color = (string)$color; - $gradientKey = array('x' => $gradientX, 'color' => $color); - array_push($this->skyGradientKeys, $gradientKey); - return $this; - } + /** + * Create a new Mood + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Remove all sky gradient keys - * - * @return static - */ - public function removeSkyGradientKeys() { - $this->skyGradientKeys = array(); - return $this; - } + /** + * Get the light ambient color + * + * @api + * @return string + */ + public function getLightAmbientColor() + { + return $this->lightAmbientColor; + } + + /** + * Set the ambient color in which elements reflect the light + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setLightAmbientColor($red, $green, $blue) + { + $this->lightAmbientColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the minimum value for the background color range + * + * @api + * @return string + */ + public function getCloudsMinimumColor() + { + return $this->cloudsMinimumColor; + } + + /** + * Set the minimum value for the background color range + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setCloudsMinimumColor($red, $green, $blue) + { + $this->cloudsMinimumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the maximum value for the background color range + * + * @api + * @return string + */ + public function getCloudsMaximumColor() + { + return $this->cloudsMaximumColor; + } + + /** + * Set the maximum value for the background color range + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setCloudsMaximumColor($red, $green, $blue) + { + $this->cloudsMaximumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the RGB color of light source 0 + * + * @api + * @return string + */ + public function getLight0Color() + { + return $this->light0Color; + } + + /** + * Set the RGB color of light source 0 + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setLight0Color($red, $green, $blue) + { + $this->light0Color = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the intensity of light source 0 + * + * @api + * @return float + */ + public function getLight0Intensity() + { + return $this->light0Intensity; + } + + /** + * Set the intensity of light source 0 + * + * @api + * @param float $intensity Light intensity + * @return static + */ + public function setLight0Intensity($intensity) + { + $this->light0Intensity = (float)$intensity; + return $this; + } + + /** + * Get the phi angle of light source 0 + * + * @api + * @return float + */ + public function getLight0PhiAngle() + { + return $this->light0PhiAngle; + } + + /** + * Set the phi angle of light source 0 + * + * @api + * @param float $phiAngle Phi angle + * @return static + */ + public function setLight0PhiAngle($phiAngle) + { + $this->light0PhiAngle = (float)$phiAngle; + return $this; + } + + /** + * Get the theta angle of light source 0 + * + * @api + * @return float + */ + public function getLight0ThetaAngle() + { + return $this->light0ThetaAngle; + } + + /** + * Set the theta angle of light source 0 + * + * @api + * @param float $thetaAngle Theta angle + * @return static + */ + public function setLight0ThetaAngle($thetaAngle) + { + $this->light0ThetaAngle = (float)$thetaAngle; + return $this; + } + + /** + * Get the light ball color + * + * @api + * @return string + */ + public function getLightBallColor() + { + return $this->lightBallColor; + } + + /** + * Set the light ball color + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setLightBallColor($red, $green, $blue) + { + $this->lightBallColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the light ball intensity + * + * @api + * @return float + */ + public function getLightBallIntensity() + { + return $this->lightBallIntensity; + } + + /** + * Set the light ball intensity + * + * @api + * @param float $intensity Light ball intensity + * @return static + */ + public function setLightBallIntensity($intensity) + { + $this->lightBallIntensity = (float)$intensity; + return $this; + } + + /** + * Get the light ball radius + * + * @api + * @return float + */ + public function getLightBallRadius() + { + return $this->lightBallRadius; + } + + /** + * Set the light ball radius + * + * @api + * @param float $radius Light ball radius + * @return static + */ + public function setLightBallRadius($radius) + { + $this->lightBallRadius = (float)$radius; + return $this; + } + + /** + * Get the fog color + * + * @api + * @return string + */ + public function getFogColor() + { + return $this->fogColor; + } + + /** + * Set the fog color + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setFogColor($red, $green, $blue) + { + $this->fogColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the self illumination color + * + * @api + * @return string + */ + public function getSelfIlluminationColor() + { + return $this->selfIlluminationColor; + } + + /** + * Set the self illumination color + * + * @api + * @param float $red Red color value + * @param float $green Green color value + * @param float $blue Blue color value + * @return static + */ + public function setSelfIlluminationColor($red, $green, $blue) + { + $this->selfIlluminationColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); + return $this; + } + + /** + * Get the sky gradient scale + * + * @api + * @return float + */ + public function getSkyGradientScale() + { + return $this->skyGradientScale; + } + + /** + * Set the sky gradient scale + * + * @api + * @param float $skyGradientScale Sky gradient scale + * @return static + */ + public function setSkyGradientScale($skyGradientScale) + { + $this->skyGradientScale = (float)$skyGradientScale; + return $this; + } + + /** + * Get Sky Gradient Keys + * + * @api + * @return SkyGradientKey[] + */ + public function getSkyGradientKeys() + { + return $this->skyGradientKeys; + } + + /** + * Add a sky gradient key + * + * @api + * @param SkyGradientKey $skyGradientKey Sky Gradient Key + * @return static + */ + public function addSkyGradientKey(SkyGradientKey $skyGradientKey) + { + array_push($this->skyGradientKeys, $skyGradientKey); + return $this; + } + + /** + * Add a sky gradient + * + * @api + * @param float $x X value + * @param string $color Color value + * @return static + */ + public function addSkyGradient($x, $color) + { + $skyGradientKey = new SkyGradientKey($x, $color); + return $this->addSkyGradientKey($skyGradientKey); + } + + /** + * Remove all Sky Gradient Keys + * + * @api + * @return static + */ + public function removeAllSkyGradientKeys() + { + $this->skyGradientKeys = array(); + return $this; + } + + /** + * Render the Mood + * + * @param \DOMDocument $domDocument DOMDocument for which the Mood should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("mood"); + if ($this->lightAmbientColor) { + $domElement->setAttribute("LAmbient_LinearRgb", $this->lightAmbientColor); + } + if ($this->cloudsMinimumColor) { + $domElement->setAttribute("CloudsRgbMinLinear", $this->cloudsMinimumColor); + } + if ($this->cloudsMaximumColor) { + $domElement->setAttribute("CloudsRgbMaxLinear", $this->cloudsMaximumColor); + } + if ($this->light0Color) { + $domElement->setAttribute("LDir0_LinearRgb", $this->light0Color); + } + if ($this->light0Intensity != 1.) { + $domElement->setAttribute("LDir0_Intens", $this->light0Intensity); + } + if ($this->light0PhiAngle) { + $domElement->setAttribute("LDir0_DirPhi", $this->light0PhiAngle); + } + if ($this->light0ThetaAngle) { + $domElement->setAttribute("LDir0_DirTheta", $this->light0ThetaAngle); + } + if ($this->lightBallColor) { + $domElement->setAttribute("LBall_LinearRgb", $this->lightBallColor); + } + if ($this->lightBallIntensity != 1.) { + $domElement->setAttribute("LBall_Intens", $this->lightBallIntensity); + } + if ($this->lightBallRadius) { + $domElement->setAttribute("LBall_Radius", $this->lightBallRadius); + } + if ($this->fogColor) { + $domElement->setAttribute("FogColorSrgb", $this->fogColor); + } + if ($this->selfIlluminationColor) { + $domElement->setAttribute("SelfIllumColor", $this->selfIlluminationColor); + } + if ($this->skyGradientScale != 1.) { + $domElement->setAttribute("SkyGradientV_Scale", $this->skyGradientScale); + } + if ($this->skyGradientKeys) { + $skyGradientElement = $domDocument->createElement("skygradient"); + $domElement->appendChild($skyGradientElement); + foreach ($this->skyGradientKeys as $skyGradientKey) { + $skyGradientKeyElement = $skyGradientKey->render($domDocument); + $skyGradientElement->appendChild($skyGradientKeyElement); + } + } + return $domElement; + } - /** - * Render the Mood XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the Mood XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $moodXml = $domDocument->createElement($this->tagName); - if ($this->lAmbient_LinearRgb) { - $moodXml->setAttribute('LAmbient_LinearRgb', $this->lAmbient_LinearRgb); - } - if ($this->cloudsRgbMinLinear) { - $moodXml->setAttribute('CloudsRgbMinLinear', $this->cloudsRgbMinLinear); - } - if ($this->cloudsRgbMaxLinear) { - $moodXml->setAttribute('CloudsRgbMaxLinear', $this->cloudsRgbMaxLinear); - } - if ($this->lDir0_LinearRgb) { - $moodXml->setAttribute('LDir0_LinearRgb', $this->lDir0_LinearRgb); - } - if ($this->lDir0_Intens) { - $moodXml->setAttribute('LDir0_Intens', $this->lDir0_Intens); - } - if ($this->lDir0_DirPhi) { - $moodXml->setAttribute('LDir0_DirPhi', $this->lDir0_DirPhi); - } - if ($this->lDir0_DirTheta) { - $moodXml->setAttribute('LDir0_DirTheta', $this->lDir0_DirTheta); - } - if ($this->lBall_LinearRgb) { - $moodXml->setAttribute('LBall_LinearRgb', $this->lBall_LinearRgb); - } - if ($this->lBall_Intensity) { - $moodXml->setAttribute('LBall_Intens', $this->lBall_Intensity); - } - if ($this->lBall_Radius) { - $moodXml->setAttribute('LBall_Radius', $this->lBall_Radius); - } - if ($this->fogColorSrgb) { - $moodXml->setAttribute('FogColorSrgb', $this->fogColorSrgb); - } - if ($this->selfIllumColor) { - $moodXml->setAttribute('SelfIllumColor', $this->selfIllumColor); - } - if ($this->skyGradientV_Scale) { - $moodXml->setAttribute('SkyGradientV_Scale', $this->skyGradientV_Scale); - } - if ($this->skyGradientKeys) { - $skyGradientXml = $domDocument->createElement('skygradient'); - $moodXml->appendChild($skyGradientXml); - foreach ($this->skyGradientKeys as $gradientKey) { - $keyXml = $domDocument->createElement('key'); - $skyGradientXml->appendChild($keyXml); - $keyXml->setAttribute('x', $gradientKey['x']); - $keyXml->setAttribute('color', $gradientKey['color']); - } - } - return $moodXml; - } } diff --git a/libs/FML/Stylesheet/SkyGradientKey.php b/libs/FML/Stylesheet/SkyGradientKey.php new file mode 100644 index 00000000..8ef7ea9b --- /dev/null +++ b/libs/FML/Stylesheet/SkyGradientKey.php @@ -0,0 +1,117 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class SkyGradientKey +{ + + /** + * @var float $x X value + */ + protected $x = null; + + /** + * @var string $color Color value + */ + protected $color = null; + + /** + * Create a new SkyGradientKey + * + * @api + * @param float $x X value + * @param string $color Color value + * @return static + */ + public static function create($x = null, $color = null) + { + return new static($x, $color); + } + + /** + * Construct a new SkyGradientKey + * + * @api + * @param float $x X value + * @param string $color Color value + */ + public function __construct($x = null, $color = null) + { + if ($x) { + $this->setX($x); + } + if ($color) { + $this->setColor($color); + } + } + + /** + * Get the X value + * + * @api + * @return float + */ + public function getX() + { + return $this->x; + } + + /** + * Set the X value + * + * @api + * @param float $x X value + * @return static + */ + public function setX($x) + { + $this->x = (float)$x; + return $this; + } + + /** + * Get the Color value + * + * @api + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set the Color value + * + * @api + * @param string $color Color value + * @return static + */ + public function setColor($color) + { + $this->color = (string)$color; + return $this; + } + + /** + * Render the SkyGradientKey + * + * @param \DOMDocument $domDocument DOMDocument for which the Sky Gradient Key should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement("key"); + $domElement->setAttribute("x", $this->x); + $domElement->setAttribute("color", $this->color); + return $domElement; + } + +} diff --git a/libs/FML/Stylesheet/Style3d.php b/libs/FML/Stylesheet/Style3d.php index 45476ab4..6129845a 100644 --- a/libs/FML/Stylesheet/Style3d.php +++ b/libs/FML/Stylesheet/Style3d.php @@ -8,240 +8,427 @@ use FML\UniqueID; * Class representing a Style3d * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Style3d { - /* - * Constants - */ - const MODEL_Box = 'Box'; - const MODEL_Button = 'Button'; - const MODEL_ButtonH = 'ButtonH'; - const MODEL_Title = 'Title'; - const MODEL_Window = 'Window'; +class Style3d +{ - /* - * Protected properties - */ - protected $tagName = 'style3d'; - protected $styleId = null; - protected $model = self::MODEL_Box; - protected $thickness = null; - protected $color = null; - protected $focusColor = null; - protected $lightColor = null; - protected $focusLightColor = null; - protected $yOffset = null; - protected $focusYOffset = null; - protected $zOffset = null; - protected $focusZOffset = null; + /* + * Constants + */ + const MODEL_Box = "Box"; + const MODEL_Button = "Button"; + const MODEL_ButtonH = "ButtonH"; + const MODEL_Title = "Title"; + const MODEL_Window = "Window"; - /** - * Create a new Style3d object - * - * @param string $styleId (optional) Style id - * @return static - */ - public static function create($styleId = null) { - return new static($styleId); - } + /** + * @var string $styleId Style ID + */ + protected $styleId = null; - /** - * Construct a new Style3d object - * - * @param string $styleId (optional) Style id - */ - public function __construct($styleId = null) { - if ($styleId !== null) { - $this->setId($styleId); - } - } + /** + * @var string $model Style model + */ + protected $model = self::MODEL_Box; - /** - * Set style id - * - * @param string $styleId Style id - * @return static - */ - public function setId($styleId) { - $this->styleId = (string)$styleId; - return $this; - } + /** + * @var float $thickness Thickness + */ + protected $thickness = null; - /** - * Check for id and assign one if necessary - * - * @return static - */ - public function checkId() { - if (!$this->styleId) { - $this->setId(new UniqueID()); - } - return $this; - } + /** + * @var string $color Color + */ + protected $color = null; - /** - * Get style id - * - * @return string - */ - public function getId() { - return $this->styleId; - } + /** + * @var string $focusColor Focus color + */ + protected $focusColor = null; - /** - * Set model - * - * @param string $model Style model - * @return static - */ - public function setModel($model) { - $this->model = (string)$model; - return $this; - } + /** + * @var string $lightColor Light color + */ + protected $lightColor = null; - /** - * Set thickness - * - * @param float $thickness Style thickness - * @return static - */ - public function setThickness($thickness) { - $this->thickness = (float)$thickness; - return $this; - } + /** + * @var string $focusLightColor Focus light color + */ + protected $focusLightColor = null; - /** - * Set color - * - * @param string $color Style color - * @return static - */ - public function setColor($color) { - $this->color = (string)$color; - return $this; - } + /** + * @var float $yOffset Y-offset + */ + protected $yOffset = null; - /** - * Set focus color - * - * @param string $focusColor Style focus color - * @return static - */ - public function setFocusColor($focusColor) { - $this->focusColor = (string)$focusColor; - return $this; - } + /** + * @var float $focusYOffset Focus Y-offset + */ + protected $focusYOffset = null; - /** - * Set light color - * - * @param string $lightColor Light color - * @return static - */ - public function setLightColor($lightColor) { - $this->lightColor = (string)$lightColor; - return $this; - } + /** + * @var float $zOffset Z-offset + */ + protected $zOffset = null; - /** - * Set focus light color - * - * @param string $focusLightColor Focus light color - * @return static - */ - public function setFocusLightColor($focusLightColor) { - $this->focusLightColor = (string)$focusLightColor; - return $this; - } + /** + * @var float $focusZOffset Focus Z-offset + */ + protected $focusZOffset = null; - /** - * Set Y-offset - * - * @param float $yOffset Y-offset - * @return static - */ - public function setYOffset($yOffset) { - $this->yOffset = (float)$yOffset; - return $this; - } + /** + * Create a new Style3d + * + * @api + * @param string $styleId (optional) Style ID + * @param string $model (optional) Style model + * @return static + */ + public static function create($styleId = null, $model = null) + { + return new static($styleId, $model); + } - /** - * Set focus Y-offset - * - * @param float $focusYOffset Focus Y-offset - * @return static - */ - public function setFocusYOffset($focusYOffset) { - $this->focusYOffset = (float)$focusYOffset; - return $this; - } + /** + * Construct a new Style3d + * + * @api + * @param string $styleId (optional) Style ID + * @param string $model (optional) Style model + */ + public function __construct($styleId = null, $model = null) + { + if ($styleId) { + $this->setId($styleId); + } + if ($model) { + $this->setModel($model); + } + } - /** - * Set Z-offset - * - * @param float $zOffset Z-offset - * @return static - */ - public function setZOffset($zOffset) { - $this->zOffset = (float)$zOffset; - return $this; - } + /** + * Get the Style ID + * + * @api + * @return string + */ + public function getId() + { + return $this->styleId; + } - /** - * Set focus Z-offset - * - * @param float $focusZOffset Focus Z-offset - * @return static - */ - public function setFocusZOffset($focusZOffset) { - $this->focusZOffset = (float)$focusZOffset; - return $this; - } + /** + * Set the Style ID + * + * @api + * @param string $styleId Style ID + * @return static + */ + public function setId($styleId) + { + $this->styleId = (string)$styleId; + return $this; + } + + /** + * Check the ID and assign one if necessary + * + * @return static + */ + public function checkId() + { + if (!$this->styleId) { + $this->setId(new UniqueID()); + } + return $this; + } + + /** + * Get the model + * + * @api + * @return string + */ + public function getModel() + { + return $this->model; + } + + /** + * Set the model + * + * @api + * @param string $model Style model + * @return static + */ + public function setModel($model) + { + $this->model = (string)$model; + return $this; + } + + /** + * Get the thickness + * + * @api + * @return float + */ + public function getThickness() + { + return $this->thickness; + } + + /** + * Set the thickness + * + * @api + * @param float $thickness Style thickness + * @return static + */ + public function setThickness($thickness) + { + $this->thickness = (float)$thickness; + return $this; + } + + /** + * Get the color + * + * @api + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set the color + * + * @api + * @param string $color Style color + * @return static + */ + public function setColor($color) + { + $this->color = (string)$color; + return $this; + } + + /** + * Get the focus color + * + * @api + * @return string + */ + public function getFocusColor() + { + return $this->focusColor; + } + + /** + * Set the focus color + * + * @api + * @param string $focusColor Style focus color + * @return static + */ + public function setFocusColor($focusColor) + { + $this->focusColor = (string)$focusColor; + return $this; + } + + /** + * Get the light color + * + * @api + * @return string + */ + public function getLightColor() + { + return $this->lightColor; + } + + /** + * Set the light color + * + * @api + * @param string $lightColor Light color + * @return static + */ + public function setLightColor($lightColor) + { + $this->lightColor = (string)$lightColor; + return $this; + } + + /** + * Get the focus light color + * + * @api + * @return string + */ + public function getFocusLightColor() + { + return $this->focusLightColor; + } + + /** + * Set the focus light color + * + * @api + * @param string $focusLightColor Focus light color + * @return static + */ + public function setFocusLightColor($focusLightColor) + { + $this->focusLightColor = (string)$focusLightColor; + return $this; + } + + /** + * Get the Y-offset + * + * @api + * @return float + */ + public function getYOffset() + { + return $this->yOffset; + } + + /** + * Set the Y-offset + * + * @api + * @param float $yOffset Y-offset + * @return static + */ + public function setYOffset($yOffset) + { + $this->yOffset = (float)$yOffset; + return $this; + } + + /** + * Get the focus Y-offset + * + * @api + * @return float + */ + public function getFocusYOffset() + { + return $this->focusYOffset; + } + + /** + * Set the focus Y-offset + * + * @api + * @param float $focusYOffset Focus Y-offset + * @return static + */ + public function setFocusYOffset($focusYOffset) + { + $this->focusYOffset = (float)$focusYOffset; + return $this; + } + + /** + * Get the Z-offset + * + * @api + * @return float + */ + public function getZOffset() + { + return $this->zOffset; + } + + /** + * Set the Z-offset + * + * @api + * @param float $zOffset Z-offset + * @return static + */ + public function setZOffset($zOffset) + { + $this->zOffset = (float)$zOffset; + return $this; + } + + /** + * Get the focus Z-offset + * + * @api + * @return float + */ + public function getFocusZOffset() + { + return $this->focusZOffset; + } + + /** + * Set the focus Z-offset + * + * @api + * @param float $focusZOffset Focus Z-offset + * @return static + */ + public function setFocusZOffset($focusZOffset) + { + $this->focusZOffset = (float)$focusZOffset; + return $this; + } + + /** + * Render the Style3d + * + * @param \DOMDocument $domDocument DOMDocument for which the Style3d should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $style3dXml = $domDocument->createElement("style3d"); + $this->checkId(); + if ($this->styleId) { + $style3dXml->setAttribute("id", $this->styleId); + } + if ($this->model) { + $style3dXml->setAttribute("model", $this->model); + } + if ($this->thickness) { + $style3dXml->setAttribute("thickness", $this->thickness); + } + if ($this->color) { + $style3dXml->setAttribute("color", $this->color); + } + if ($this->focusColor) { + $style3dXml->setAttribute("fcolor", $this->focusColor); + } + if ($this->lightColor) { + $style3dXml->setAttribute("lightcolor", $this->lightColor); + } + if ($this->focusLightColor) { + $style3dXml->setAttribute("flightcolor", $this->focusLightColor); + } + if ($this->yOffset) { + $style3dXml->setAttribute("yoffset", $this->yOffset); + } + if ($this->focusYOffset) { + $style3dXml->setAttribute("fyoffset", $this->focusYOffset); + } + if ($this->zOffset) { + $style3dXml->setAttribute("zoffset", $this->zOffset); + } + if ($this->focusZOffset) { + $style3dXml->setAttribute("fzoffset", $this->focusZOffset); + } + return $style3dXml; + } - /** - * Render the Style3d XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the Style3d XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $style3dXml = $domDocument->createElement($this->tagName); - $this->checkId(); - if ($this->styleId) { - $style3dXml->setAttribute('id', $this->styleId); - } - if ($this->model) { - $style3dXml->setAttribute('model', $this->model); - } - if ($this->thickness) { - $style3dXml->setAttribute('thickness', $this->thickness); - } - if ($this->color) { - $style3dXml->setAttribute('color', $this->color); - } - if ($this->focusColor) { - $style3dXml->setAttribute('fcolor', $this->focusColor); - } - if ($this->lightColor) { - $style3dXml->setAttribute('lightcolor', $this->lightColor); - } - if ($this->focusLightColor) { - $style3dXml->setAttribute('flightcolor', $this->focusLightColor); - } - if ($this->yOffset) { - $style3dXml->setAttribute('yoffset', $this->yOffset); - } - if ($this->focusYOffset) { - $style3dXml->setAttribute('fyoffset', $this->focusYOffset); - } - if ($this->zOffset) { - $style3dXml->setAttribute('zoffset', $this->zOffset); - } - if ($this->focusZOffset) { - $style3dXml->setAttribute('fzoffset', $this->focusZOffset); - } - return $style3dXml; - } } diff --git a/libs/FML/Stylesheet/Stylesheet.php b/libs/FML/Stylesheet/Stylesheet.php index bc62900f..40865290 100644 --- a/libs/FML/Stylesheet/Stylesheet.php +++ b/libs/FML/Stylesheet/Stylesheet.php @@ -6,95 +6,133 @@ namespace FML\Stylesheet; * Class representing a ManiaLink Stylesheet * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Stylesheet { - /* - * Protected properties - */ - protected $tagName = 'stylesheet'; - /** @var Style3d[] $styles3d */ - protected $styles3d = array(); - /** @var Mood $mood */ - protected $mood = null; +class Stylesheet +{ - /** - * Create a new Stylesheet object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var Style3d[] $styles3d 3d Styles + */ + protected $styles3d = array(); - /** - * Add a new Style3d - * - * @param Style3d $style3d Style3d object - * @return static - */ - public function addStyle3d(Style3d $style3d) { - if (!in_array($style3d, $this->styles3d, true)) { - array_push($this->styles3d, $style3d); - } - return $this; - } + /** + * @var Mood $mood Mood + */ + protected $mood = null; - /** - * Remove all Style3ds - * - * @return static - */ - public function removeStyles() { - $this->styles3d = array(); - return $this; - } + /** + * Create a new Stylesheet + * + * @api + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Set the Mood object of the Stylesheet - * - * @param Mood $mood Mood object - * @return static - */ - public function setMood(Mood $mood) { - $this->mood = $mood; - return $this; - } + /** + * Get the Styles3d + * + * @api + * @return Style3d[] + */ + public function getStyles3d() + { + return $this->styles3d; + } - /** - * Get the Mood object - * - * @param bool $createIfEmpty (optional) Whether the Mood object should be created if it's not set - * @return \FML\Stylesheet\Mood - */ - public function getMood($createIfEmpty = true) { - if (!$this->mood && $createIfEmpty) { - $this->setMood(new Mood()); - } - return $this->mood; - } + /** + * Add a new Style3d + * + * @api + * @param Style3d $style3d The Style3d to be added + * @return static + */ + public function addStyle3d(Style3d $style3d) + { + if (!in_array($style3d, $this->styles3d, true)) { + array_push($this->styles3d, $style3d); + } + return $this; + } + + /** + * Remove all Style3ds + * + * @api + * @return static + */ + public function removeAllStyles3d() + { + $this->styles3d = array(); + return $this; + } + + /** + * Get the Mood + * + * @api + * @return Mood + */ + public function getMood() + { + return $this->mood; + } + + /** + * Set the Mood + * + * @api + * @param Mood $mood Mood + * @return static + */ + public function setMood(Mood $mood = null) + { + $this->mood = $mood; + return $this; + } + + /** + * Create a new Mood if necessary + * + * @api + * @return Mood + */ + public function createMood() + { + if ($this->mood) { + return $this->mood; + } + $mood = new Mood(); + $this->setMood($mood); + return $this->mood; + } + + /** + * Render the Stylesheet + * + * @param \DOMDocument $domDocument DOMDocument for which the Stylesheet should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument) + { + $stylesheetXml = $domDocument->createElement("stylesheet"); + if ($this->styles3d) { + $stylesXml = $domDocument->createElement("frame3dstyles"); + $stylesheetXml->appendChild($stylesXml); + foreach ($this->styles3d as $style3d) { + $style3dXml = $style3d->render($domDocument); + $stylesXml->appendChild($style3dXml); + } + } + if ($this->mood) { + $moodXml = $this->mood->render($domDocument); + $stylesheetXml->appendChild($moodXml); + } + return $stylesheetXml; + } - /** - * Render the Stylesheet XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the Stylesheet XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument) { - $stylesheetXml = $domDocument->createElement($this->tagName); - if ($this->styles3d) { - $stylesXml = $domDocument->createElement('frame3dstyles'); - $stylesheetXml->appendChild($stylesXml); - foreach ($this->styles3d as $style3d) { - $style3dXml = $style3d->render($domDocument); - $stylesXml->appendChild($style3dXml); - } - } - if ($this->mood) { - $moodXml = $this->mood->render($domDocument); - $stylesheetXml->appendChild($moodXml); - } - return $stylesheetXml; - } } diff --git a/libs/FML/Types/Actionable.php b/libs/FML/Types/Actionable.php index e6d5a16b..2ca61d61 100644 --- a/libs/FML/Types/Actionable.php +++ b/libs/FML/Types/Actionable.php @@ -6,52 +6,66 @@ namespace FML\Types; * Interface for Elements that support the action attribute * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface Actionable { - /* - * Constants - */ - const ACTION_0 = '0'; - const ACTION_BACK = 'back'; - const ACTION_ENTER = 'enter'; - const ACTION_HOME = 'home'; - const ACTION_MENU_SOLO = 'menu_solo'; - const ACTION_MENU_COMPETITIONS = 'menu_competitions'; - const ACTION_MENU_LOCAL = 'menu_local'; - const ACTION_MENU_INTERNET = 'menu_internet'; - const ACTION_MENU_EDITORS = 'menu_editors'; - const ACTION_MENU_PROFILE = 'menu_profile'; - const ACTION_QUIT = 'quit'; - const ACTION_QUITSERVER = 'maniaplanet:quitserver'; - const ACTION_SAVEREPLAY = 'maniaplanet:savereplay'; - const ACTION_TOGGLESPEC = 'maniaplanet:togglespec'; - const ACTIONKEY_F5 = 1; - const ACTIONKEY_F6 = 2; - const ACTIONKEY_F7 = 3; - const ACTIONKEY_F8 = 4; +interface Actionable +{ - /** - * Set action - * - * @param string $action Action name - * @return static - */ - public function setAction($action); + /* + * Constants + */ + const ACTION_0 = '0'; + const ACTION_BACK = 'back'; + const ACTION_ENTER = 'enter'; + const ACTION_HOME = 'home'; + const ACTION_MENU_SOLO = 'menu_solo'; + const ACTION_MENU_COMPETITIONS = 'menu_competitions'; + const ACTION_MENU_LOCAL = 'menu_local'; + const ACTION_MENU_INTERNET = 'menu_internet'; + const ACTION_MENU_EDITORS = 'menu_editors'; + const ACTION_MENU_PROFILE = 'menu_profile'; + const ACTION_QUIT = 'quit'; + const ACTION_QUITSERVER = 'maniaplanet:quitserver'; + const ACTION_SAVEREPLAY = 'maniaplanet:savereplay'; + const ACTION_TOGGLESPEC = 'maniaplanet:togglespec'; + const ACTIONKEY_F5 = 1; + const ACTIONKEY_F6 = 2; + const ACTIONKEY_F7 = 3; + const ACTIONKEY_F8 = 4; - /** - * Get the assigned action - * - * @return string - */ - public function getAction(); + /** + * Set the action + * + * @api + * @param string $action Action name + * @return static + */ + public function setAction($action); + + /** + * Get the action + * + * @api + * @return string + */ + public function getAction(); + + /** + * Get the action key + * + * @api + * @return int + */ + public function getActionKey(); + + /** + * Set the action key + * + * @api + * @param int $actionKey Action key + * @return static + */ + public function setActionKey($actionKey); - /** - * Set action key - * - * @param int $actionKey Action key - * @return static - */ - public function setActionKey($actionKey); } diff --git a/libs/FML/Types/BackgroundColorable.php b/libs/FML/Types/BackgroundColorable.php new file mode 100644 index 00000000..191f2dc8 --- /dev/null +++ b/libs/FML/Types/BackgroundColorable.php @@ -0,0 +1,32 @@ + - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface Container { +interface Container +{ - /** - * Add a new child Element - * - * @param Renderable $child Child Control to add - * @return static - */ - public function add(Renderable $child); + /** + * Get the children + * + * @api + * @return Renderable[] + */ + public function getChildren(); - /** - * Remove all children - * - * @return static - */ - public function removeChildren(); + /** + * Add a new child + * + * @api + * @param Renderable $child Child Control to add + * @return static + */ + public function addChild(Renderable $child); - /** - * Set the Format object of the Container - * - * @param Format $format New Format object - * @return static - */ - public function setFormat(Format $format); + /** + * Add new children + * + * @api + * @param Renderable[] $children Child Controls to add + * @return static + */ + public function addChildren(array $children); + + /** + * Remove all children + * + * @api + * @return static + */ + public function removeAllChildren(); + + /** + * Get the Format + * + * @api + * @return Format + */ + public function getFormat(); + + /** + * Set the Format + * + * @api + * @param Format $format New Format + * @return static + */ + public function setFormat(Format $format = null); - /** - * Get the Format object of the Container - * - * @param bool $createIfEmpty (optional) Whether the Format object should be created if it's not set - * @return \FML\Elements\Format - */ - public function getFormat($createIfEmpty = true); } diff --git a/libs/FML/Types/Identifiable.php b/libs/FML/Types/Identifiable.php new file mode 100644 index 00000000..a7d284dc --- /dev/null +++ b/libs/FML/Types/Identifiable.php @@ -0,0 +1,39 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +interface Identifiable +{ + + /** + * Get the Id + * + * @api + * @return string + */ + public function getId(); + + /** + * Set the Id + * + * @api + * @param string $id ID + * @return static + */ + public function setId($id); + + /** + * Check and return the Id + * + * @return string + */ + public function checkId(); + +} diff --git a/libs/FML/Types/Imageable.php b/libs/FML/Types/Imageable.php new file mode 100644 index 00000000..4adcb328 --- /dev/null +++ b/libs/FML/Types/Imageable.php @@ -0,0 +1,32 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +interface Imageable +{ + + /** + * Get the image url + * + * @api + * @return string + */ + public function getImageUrl(); + + /** + * Set the image url + * + * @api + * @param string $imageUrl Image url + * @return static + */ + public function setImageUrl($imageUrl); + +} diff --git a/libs/FML/Types/Linkable.php b/libs/FML/Types/Linkable.php index c029c51e..a2149e36 100644 --- a/libs/FML/Types/Linkable.php +++ b/libs/FML/Types/Linkable.php @@ -6,40 +6,78 @@ namespace FML\Types; * Interface for Elements with url attributes * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface Linkable { +interface Linkable +{ - /** - * Set url - * - * @param string $url Link url - * @return static - */ - public function setUrl($url); + /** + * Get the url + * + * @api + * @return string + */ + public function getUrl(); - /** - * Set url id to use from Dico - * - * @param string $urlId Url id - * @return static - */ - public function setUrlId($urlId); + /** + * Set the url + * + * @api + * @param string $url Link url + * @return static + */ + public function setUrl($url); - /** - * Set manialink - * - * @param string $manialink Manialink name - * @return static - */ - public function setManialink($manialink); + /** + * Get the url id to use from Dico + * + * @api + * @return string + */ + public function getUrlId(); + + /** + * Set the url id to use from Dico + * + * @api + * @param string $urlId Url id + * @return static + */ + public function setUrlId($urlId); + + /** + * Get the manialink + * + * @api + * @return string + */ + public function getManialink(); + + /** + * Set the manialink + * + * @api + * @param string $manialink Manialink name + * @return static + */ + public function setManialink($manialink); + + /** + * Get the manialink id to use from Dico + * + * @api + * @return string + */ + public function getManialinkId(); + + /** + * Set the manialink id to use from Dico + * + * @api + * @param string $manialinkId Manialink id + * @return static + */ + public function setManialinkId($manialinkId); - /** - * Set manialink id to use from Dico - * - * @param string $manialinkId Manialink id - * @return static - */ - public function setManialinkId($manialinkId); } diff --git a/libs/FML/Types/MultiLineable.php b/libs/FML/Types/MultiLineable.php new file mode 100644 index 00000000..573f8590 --- /dev/null +++ b/libs/FML/Types/MultiLineable.php @@ -0,0 +1,66 @@ + + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +interface MultiLineable +{ + + /** + * Get auto new line + * + * @api + * @return bool + */ + public function getAutoNewLine(); + + /** + * Set auto new line + * + * @api + * @param bool $autoNewLine If the Element should insert new lines automatically + * @return static + */ + public function setAutoNewLine($autoNewLine); + + /** + * Get line spacing + * + * @api + * @return float + */ + public function getLineSpacing(); + + /** + * Set line spacing + * + * @api + * @param float $lineSpacing Line spacing + * @return static + */ + public function setLineSpacing($lineSpacing); + + /** + * Get the maximum number of lines + * + * @api + * @return int + */ + public function getMaxLines(); + + /** + * Set the maximum number of lines + * + * @api + * @param int $maxLines Maximum number of lines + * @return static + */ + public function setMaxLines($maxLines); + +} diff --git a/libs/FML/Types/NewLineable.php b/libs/FML/Types/NewLineable.php index cf85856e..1c72a594 100644 --- a/libs/FML/Types/NewLineable.php +++ b/libs/FML/Types/NewLineable.php @@ -5,17 +5,32 @@ namespace FML\Types; /** * Interface for Elements with autonewline attribute * - * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder - * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + * @deprecated Use MultiLineable + * @see MultiLineable + * @author steeffeen + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface NewLineable { +interface NewLineable +{ + + /** + * Get auto new line + * + * @api + * @deprecated + * @return bool + */ + public function getAutoNewLine(); + + /** + * Set auto new line + * + * @api + * @deprecated + * @param bool $autoNewLine If the Element should insert new lines automatically + * @return static + */ + public function setAutoNewLine($autoNewLine); - /** - * Set auto new line - * - * @param bool $autoNewLine Whether the Control should insert new lines automatically - * @return static - */ - public function setAutoNewLine($autoNewLine); } diff --git a/libs/FML/Types/Playable.php b/libs/FML/Types/Playable.php index 9bb18230..89c9c26e 100644 --- a/libs/FML/Types/Playable.php +++ b/libs/FML/Types/Playable.php @@ -6,56 +6,112 @@ namespace FML\Types; * Interface for Elements with media attributes * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface Playable { +interface Playable +{ - /** - * Set data - * - * @param string $data Media url - * @return static - */ - public function setData($data); + /** + * Get the data url + * + * @api + * @return string + */ + public function getData(); - /** - * Set data id to use from Dico - * - * @param string $dataId Data id - * @return static - */ - public function setDataId($dataId); + /** + * Set the data url + * + * @api + * @param string $data Data url + * @return static + */ + public function setData($data); - /** - * Set play - * - * @param bool $play Whether the Control should start playing automatically - * @return static - */ - public function setPlay($play); + /** + * Get the data id to use from Dico + * + * @api + * @return string + */ + public function getDataId(); - /** - * Set looping - * - * @param bool $looping Whether the Control should play looping - * @return static - */ - public function setLooping($looping); + /** + * Set the data id to use from Dico + * + * @api + * @param string $dataId Data id + * @return static + */ + public function setDataId($dataId); - /** - * Set music - * - * @param bool $music Whether the Control represents background music - * @return static - */ - public function setMusic($music); + /** + * Get play + * + * @api + * @return bool + */ + public function getPlay(); + + /** + * Set play + * + * @api + * @param bool $play If the Control should start playing automatically + * @return static + */ + public function setPlay($play); + + /** + * Get looping + * + * @api + * @return bool + */ + public function getLooping(); + + /** + * Set looping + * + * @api + * @param bool $looping If the Control should play looping + * @return static + */ + public function setLooping($looping); + + /** + * Get music + * + * @api + * @return bool + */ + public function getMusic(); + + /** + * Set music + * + * @api + * @param bool $music If the Control represents background music + * @return static + */ + public function setMusic($music); + + /** + * Get the volume + * + * @api + * @return float + */ + public function getVolume(); + + /** + * Set the volume + * + * @api + * @param float $volume Media volume + * @return static + */ + public function setVolume($volume); - /** - * Set volume - * - * @param float $volume Media volume - * @return static - */ - public function setVolume($volume); } diff --git a/libs/FML/Types/Renderable.php b/libs/FML/Types/Renderable.php index 24e54240..2733b082 100644 --- a/libs/FML/Types/Renderable.php +++ b/libs/FML/Types/Renderable.php @@ -6,16 +6,18 @@ namespace FML\Types; * Interface for renderable Elements * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface Renderable { +interface Renderable +{ + + /** + * Render the XML element + * + * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered + * @return \DOMElement + */ + public function render(\DOMDocument $domDocument); - /** - * Render the XML element - * - * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered - * @return \DOMElement - */ - public function render(\DOMDocument $domDocument); } diff --git a/libs/FML/Types/ScriptFeatureable.php b/libs/FML/Types/ScriptFeatureable.php index 2c6db6ba..83d401b5 100644 --- a/libs/FML/Types/ScriptFeatureable.php +++ b/libs/FML/Types/ScriptFeatureable.php @@ -2,19 +2,23 @@ namespace FML\Types; +use FML\Script\Features\ScriptFeature; + /** * Interface for Elements supporting ScriptFeatures * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface ScriptFeatureable { +interface ScriptFeatureable +{ + + /** + * Get the Script Features + * + * @return ScriptFeature[] + */ + public function getScriptFeatures(); - /** - * Get the assigned Script Features of the Element - * - * @return \FML\Script\Features\ScriptFeature[] - */ - public function getScriptFeatures(); } diff --git a/libs/FML/Types/Scriptable.php b/libs/FML/Types/Scriptable.php index 3dc585c6..ce4fbe34 100644 --- a/libs/FML/Types/Scriptable.php +++ b/libs/FML/Types/Scriptable.php @@ -3,19 +3,65 @@ namespace FML\Types; /** - * Interface for Elements with scriptevents attribute + * Interface for Elements with script event attributes * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface Scriptable { +interface Scriptable +{ + + /** + * Get script events + * + * @api + * @return bool + */ + public function getScriptEvents(); + + /** + * Set script events + * + * @api + * @param bool $scriptEvents If script events should be enabled + * @return static + */ + public function setScriptEvents($scriptEvents); + + /** + * Get script action + * + * @api + * @return string + */ + public function getScriptAction(); + + /** + * Set script action + * + * @api + * @param string $scriptAction Script action to be triggered + * @param string[] $scriptActionParameters (optional) Script action parameters + * @return static + */ + public function setScriptAction($scriptAction, array $scriptActionParameters = null); + + /** + * Get script action parameters + * + * @api + * @return string[] + */ + public function getScriptActionParameters(); + + /** + * Set script action parameters + * + * @api + * @param string[] $scriptActionParameters (optional) Script action parameters + * @return static + */ + public function setScriptActionParameters(array $scriptActionParameters = null); - /** - * Set script events - * - * @param bool $scriptEvents Whether script events should be enabled - * @return static - */ - public function setScriptEvents($scriptEvents); } diff --git a/libs/FML/Types/Styleable.php b/libs/FML/Types/Styleable.php index 7ca8755f..43831192 100644 --- a/libs/FML/Types/Styleable.php +++ b/libs/FML/Types/Styleable.php @@ -6,16 +6,27 @@ namespace FML\Types; * Interface for Elements with style attribute * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface Styleable { +interface Styleable +{ + + /** + * Get the style + * + * @api + * @return string + */ + public function getStyle(); + + /** + * Set the style + * + * @api + * @param string $style Style name + * @return static + */ + public function setStyle($style); - /** - * Set style - * - * @param string $style Style name - * @return static - */ - public function setStyle($style); } diff --git a/libs/FML/Types/SubStyleable.php b/libs/FML/Types/SubStyleable.php index 337ae0fc..f0d103c1 100644 --- a/libs/FML/Types/SubStyleable.php +++ b/libs/FML/Types/SubStyleable.php @@ -6,25 +6,37 @@ namespace FML\Types; * Interface for Elements with substyle attribute * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface SubStyleable { +interface SubStyleable +{ - /** - * Set sub style - * - * @param string $subStyle SubStyle name - * @return static - */ - public function setSubStyle($subStyle); + /** + * Get the sub style + * + * @api + * @return string + */ + public function getSubStyle(); + + /** + * Set the sub style + * + * @api + * @param string $subStyle SubStyle name + * @return static + */ + public function setSubStyle($subStyle); + + /** + * Set the style and the sub style + * + * @api + * @param string $style Style name + * @param string $subStyle SubStyle name + * @return static + */ + public function setStyles($style, $subStyle); - /** - * Set style and sub style - * - * @param string $style Style name - * @param string $subStyle SubStyle name - * @return static - */ - public function setStyles($style, $subStyle); } diff --git a/libs/FML/Types/TextFormatable.php b/libs/FML/Types/TextFormatable.php index 161a8298..5ecff9ca 100644 --- a/libs/FML/Types/TextFormatable.php +++ b/libs/FML/Types/TextFormatable.php @@ -6,48 +6,95 @@ namespace FML\Types; * Interface for Elements with formatable text * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -interface TextFormatable { +interface TextFormatable +{ - /** - * Set text size - * - * @param int $textSize Text size - * @return static - */ - public function setTextSize($textSize); + /** + * Get the text size + * + * @api + * @return int + */ + public function getTextSize(); - /** - * Set text font - * - * @param string $textFont - * @return static - */ - public function setTextFont($textFont); + /** + * Set the text size + * + * @api + * @param int $textSize Text size + * @return static + */ + public function setTextSize($textSize); - /** - * Set text color - * - * @param string $textColor Text color - * @return static - */ - public function setTextColor($textColor); + /** + * Get the text font + * + * @api + * @return string + */ + public function getTextFont(); - /** - * Set area color - * - * @param string $areaColor Area color - * @return static - */ - public function setAreaColor($areaColor); + /** + * Set the text font + * + * @api + * @param string $textFont + * @return static + */ + public function setTextFont($textFont); + + /** + * Get the text color + * + * @api + * @return string + */ + public function getTextColor(); + + /** + * Set the text color + * + * @api + * @param string $textColor Text color + * @return static + */ + public function setTextColor($textColor); + + /** + * Get the area color + * + * @api + * @return string + */ + public function getAreaColor(); + + /** + * Set the area color + * + * @api + * @param string $areaColor Area color + * @return static + */ + public function setAreaColor($areaColor); + + /** + * Get the area focus color + * + * @api + * @return string + */ + public function getAreaFocusColor(); + + /** + * Set the area focus color + * + * @api + * @param string $areaFocusColor Area focus color + * @return static + */ + public function setAreaFocusColor($areaFocusColor); - /** - * Set area focus color - * - * @param string $areaFocusColor Area focus color - * @return static - */ - public function setAreaFocusColor($areaFocusColor); } diff --git a/libs/FML/UniqueID.php b/libs/FML/UniqueID.php index 4efa151b..add7285a 100644 --- a/libs/FML/UniqueID.php +++ b/libs/FML/UniqueID.php @@ -2,70 +2,123 @@ namespace FML; +use FML\Types\Identifiable; + /** * Unique ID Model Class * * @author steeffeen - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder + * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class UniqueID { - /* - * Constants - */ - const PREFIX = 'FML_ID_'; +class UniqueID +{ - /* - * Static properties - */ - protected static $currentIndex = 0; + /* + * Constants + */ + const PREFIX = 'FML_ID_'; - /* - * Protected properties - */ - protected $index = null; + /** + * @var int $currentIndex Current global id index + */ + protected static $currentIndex = 0; - /** - * Create a new Unique ID object - * - * @return static - */ - public static function create() { - return new static(); - } + /** + * @var int $index Unique id index + */ + protected $index = null; - /** - * Get a new unique index - * - * @return int - */ - protected static function newIndex() { - self::$currentIndex++; - return self::$currentIndex; - } + /** + * Create a new Unique ID + * + * @return static + */ + public static function create() + { + return new static(); + } - /** - * Construct a Unique ID object - */ - public function __construct() { - $this->index = static::newIndex(); - } + /** + * Check and return the Id of an Identifable Element + * + * @param Identifiable $element Identifable element + * @return string + */ + public static function check(Identifiable $element) + { + $elementId = $element->getId(); - /** - * Get the Unique ID value - * - * @return string - */ - public function getValue() { - return self::PREFIX . $this->index; - } + if (!$elementId) { + $element->setId(new static()); + return $element->getId(); + } + + $dangerousCharacters = array(' ', '|', PHP_EOL); + $danger = false; + foreach ($dangerousCharacters as $dangerousCharacter) { + if (stripos($elementId, $dangerousCharacter) !== false) { + $danger = true; + break; + } + } + + if ($danger) { + trigger_error("Don't use special characters in IDs, they might cause problems! Stripping them for you..."); + $elementId = str_ireplace($dangerousCharacters, '', $elementId); + $element->setId($elementId); + } + + return $element->getId(); + } + + /** + * Get a new global unique index + * + * @return int + */ + protected static function newIndex() + { + self::$currentIndex++; + return self::$currentIndex; + } + + /** + * Construct a Unique ID + */ + public function __construct() + { + $this->index = static::newIndex(); + } + + /** + * Get the Unique ID index + * + * @return int + */ + public function getIndex() + { + return $this->index; + } + + /** + * Get the Unique ID value + * + * @return string + */ + public function getValue() + { + return self::PREFIX . $this->getIndex(); + } + + /** + * Get the string representation + * + * @return string + */ + public function __toString() + { + return $this->getValue(); + } - /** - * Get the string representation - * - * @return string - */ - public function __toString() { - return $this->getValue(); - } } diff --git a/libs/FML/autoload.php b/libs/FML/autoload.php deleted file mode 100644 index ffa9b429..00000000 --- a/libs/FML/autoload.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @version 1.4 - * @link http://github.com/steeffeen/FancyManiaLinks - * @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder - * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 - */ -if (!defined('FML_PATH')) { - define('FML_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR); -} -if (!defined('FML_VERSION')) { - define('FML_VERSION', '1.4'); -} - -/* - * Autoload function that loads FML class files on demand - */ -if (!defined('FML_AUTOLOAD_DEFINED')) { - define('FML_AUTOLOAD_DEFINED', true); - spl_autoload_register(function ($className) { - $classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className); - $filePath = FML_PATH . $classPath . '.php'; - if (file_exists($filePath)) { - require_once $filePath; - } - }); -} From a9e24234e0b03d5bc6fc14881bac7bf3365ef961 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 25 Mar 2017 19:15:50 +0100 Subject: [PATCH 28/73] reanmed to new FML names --- core/Admin/ActionsMenu.php | 44 ++++----- core/Admin/AdminLists.php | 20 ++-- core/Callbacks/LibXmlRpcCallbacks.php | 1 + core/Commands/HelpManager.php | 14 +-- core/Configurator/Configurator.php | 21 ++--- core/Configurator/ManiaControlSettings.php | 44 ++++----- core/Configurator/ScriptSettings.php | 26 +++--- core/ManiaExchange/ManiaExchangeList.php | 48 +++++----- core/Manialinks/IconManager.php | 6 +- core/Manialinks/ManialinkManager.php | 10 +- core/Manialinks/StyleManager.php | 12 +-- core/Maps/DirectoryBrowser.php | 32 +++---- core/Maps/MapCommands.php | 4 +- core/Maps/MapList.php | 80 ++++++++-------- core/Players/PlayerActions.php | 10 +- core/Players/PlayerDetailed.php | 74 +++++++-------- core/Players/PlayerList.php | 96 ++++++++++---------- core/Plugins/InstallMenu.php | 44 ++++----- core/Plugins/PluginMenu.php | 54 +++++------ core/Server/ServerOptionsMenu.php | 20 ++-- core/Server/VoteRatiosMenu.php | 12 +-- core/Statistics/SimpleStatsList.php | 20 ++-- plugins/MCTeam/CustomVotesPlugin.php | 51 ++++++----- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 36 ++++---- plugins/MCTeam/DonationPlugin.php | 40 ++++---- plugins/MCTeam/KarmaPlugin.php | 14 +-- plugins/MCTeam/LocalRecordsPlugin.php | 36 ++++---- plugins/MCTeam/ServerRankingPlugin.php | 12 +-- plugins/MCTeam/WidgetPlugin.php | 81 ++++++++--------- 29 files changed, 476 insertions(+), 486 deletions(-) diff --git a/core/Admin/ActionsMenu.php b/core/Admin/ActionsMenu.php index 1aaca7ac..ead9b954 100644 --- a/core/Admin/ActionsMenu.php +++ b/core/Admin/ActionsMenu.php @@ -137,22 +137,22 @@ 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); + $manialink->addChild($descriptionLabel); $descriptionLabel->setPosition($posX - count($this->adminMenuItems) * $itemSize * 1.15 - 6, $posY); $descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP); $descriptionLabel->setSize(40, 4); @@ -161,15 +161,15 @@ 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->setHorizontalAlign($popoutFrame::RIGHT); $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); $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); @@ -181,14 +181,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,22 +201,22 @@ 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); + $manialink->addChild($descriptionLabel); $descriptionLabel->setPosition($posX - count($this->playerMenuItems) * $itemSize * 1.15 - 6, $posY - $itemSize * $itemMarginFactorY); $descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP); $descriptionLabel->setSize(40, 4); @@ -225,15 +225,15 @@ 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->setHorizontalAlign($popoutFrame::RIGHT); $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); $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); @@ -245,14 +245,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); } diff --git a/core/Admin/AdminLists.php b/core/Admin/AdminLists.php index e667b577..e2b2df6f 100644 --- a/core/Admin/AdminLists.php +++ b/core/Admin/AdminLists.php @@ -96,7 +96,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { // Main frame $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); - $maniaLink->add($frame); + $maniaLink->addChild($frame); // Start offsets $posX = -$width / 2; @@ -104,11 +104,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); @@ -120,19 +120,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->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); @@ -144,14 +144,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); @@ -171,7 +171,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); @@ -180,7 +180,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); diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index ee4659bd..a5dbdc19 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -140,6 +140,7 @@ class LibXmlRpcCallbacks implements CallbackListener { case Callbacks::MP_PODIUMSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMSTART); break; + case Callbacks::MP_PODIUMEND: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_PODIUMEND); break; diff --git a/core/Commands/HelpManager.php b/core/Commands/HelpManager.php index b413af84..f7fbda38 100644 --- a/core/Commands/HelpManager.php +++ b/core/Commands/HelpManager.php @@ -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->addPage($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); diff --git a/core/Configurator/Configurator.php b/core/Configurator/Configurator.php index da3cb229..c229f931 100644 --- a/core/Configurator/Configurator.php +++ b/core/Configurator/Configurator.php @@ -9,7 +9,6 @@ use FML\Controls\Quads\Quad_BgRaceScore2; use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_UIConstruction_Buttons; use FML\ManiaLink; -use FML\Script\Script; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; @@ -198,25 +197,25 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn $manialink = new ManiaLink(ManialinkManager::MAIN_MLID); $frame = new Frame(); - $manialink->add($frame); + $manialink->addChild($frame); $frame->setPosition($menuPosX, $menuPosY, ManialinkManager::MAIN_MANIALINK_Z_VALUE); $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $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 @@ -227,7 +226,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn foreach ($this->menus as $menu) { // Add title $menuItemLabel = new Label_Text(); - $frame->add($menuItemLabel); + $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); @@ -235,7 +234,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn 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); } @@ -247,17 +246,17 @@ 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); + $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); + $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; diff --git a/core/Configurator/ManiaControlSettings.php b/core/Configurator/ManiaControlSettings.php index 0a26e7f3..6ad9498c 100644 --- a/core/Configurator/ManiaControlSettings.php +++ b/core/Configurator/ManiaControlSettings.php @@ -101,13 +101,13 @@ 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); @@ -116,8 +116,8 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $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); + $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,13 +228,13 @@ 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); @@ -243,8 +243,8 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $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,7 +256,7 @@ 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->addPageControl($pageFrame); } @@ -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); diff --git a/core/Configurator/ScriptSettings.php b/core/Configurator/ScriptSettings.php index 2c1eb2f5..48b4b9ce 100644 --- a/core/Configurator/ScriptSettings.php +++ b/core/Configurator/ScriptSettings.php @@ -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,13 +210,13 @@ 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); @@ -225,8 +225,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $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->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,8 +287,8 @@ 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); diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index a88d5f73..7c991aee 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -166,15 +166,15 @@ 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); $this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); @@ -187,18 +187,18 @@ 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->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); @@ -213,10 +213,10 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $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); @@ -226,7 +226,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener 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 +241,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 +260,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 +286,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,13 +304,13 @@ 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); + $frame->addChild($quad); $quad->setPosition(-$width / 2 + 63, $height / 2 - 5, 0.01); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); $quad->setSize(18, 5); @@ -318,13 +318,13 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener //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); + $frame->addChild($quad); $quad->setPosition(-$width / 2 + 82, $height / 2 - 5, 0.01); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); $quad->setSize(18, 5); diff --git a/core/Manialinks/IconManager.php b/core/Manialinks/IconManager.php index 2037cb5b..cfdea67e 100644 --- a/core/Manialinks/IconManager.php +++ b/core/Manialinks/IconManager.php @@ -113,14 +113,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 diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 7d4ba59b..0de72303 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -237,8 +237,6 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener public function sendManialink($manialinkText, $logins = null, $timeout = 0, $hideOnClick = false) { $manialinkText = (string) $manialinkText; - var_dump($manialinkText); - if (!$manialinkText) { return true; } @@ -389,8 +387,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener foreach ($positions as $key => $x) { $label = new Label_Text(); - $frame->add($label); - $label->setHAlign($hAlign); + $frame->addChild($label); + $label->setHorizontalAlign($hAlign); $label->setX($x); $label->setStyle($style); $label->setTextSize($textSize); @@ -406,8 +404,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener } else { foreach ($labelStrings as $text => $x) { $label = new Label_Text(); - $frame->add($label); - $label->setHAlign($hAlign); + $frame->addChild($label); + $label->setHorizontalAlign($hAlign); $label->setX($x); $label->setStyle($style); $label->setTextSize($textSize); diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index 6d8faaed..bcfa9378 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -170,27 +170,27 @@ class StyleManager { // 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->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel); diff --git a/core/Maps/DirectoryBrowser.php b/core/Maps/DirectoryBrowser.php index ffee2a2f..76904651 100644 --- a/core/Maps/DirectoryBrowser.php +++ b/core/Maps/DirectoryBrowser.php @@ -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)->setText('tooltip'); $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); } // 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); } diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index cc47fa66..e063ab18 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -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'); diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 068166eb..778451c3 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -150,24 +150,24 @@ 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->setHorizontalAlign($label::RIGHT); $quad = new Quad_BgsPlayerCard(); - $frame->add($quad); + $frame->addChild($quad); $quad->setPosition($width / 2 - 5, -$height / 2 + 9, 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); } @@ -176,25 +176,25 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { ) { // Check Update $label = new Label_Button(); - $frame->add($label); + $frame->addChild($label); $label->setText('Check MX for Updates'); $label->setTextSize(1); $label->setPosition($width / 2 - 41, -$height / 2 + 9, 0.01); - $label->setHAlign($label::RIGHT); + $label->setHorizontalAlign($label::RIGHT); $quad = new Quad_BgsPlayerCard(); - $frame->add($quad); + $frame->addChild($quad); $quad->setPosition($width / 2 - 37, -$height / 2 + 9, 0.01); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); - $quad->setHAlign($quad::RIGHT); + $quad->setHorizontalAlign($quad::RIGHT); $quad->setSize(35, 4); $quad->setAction(self::ACTION_CHECK_UPDATE); $mxQuad = new Quad(); - $frame->add($mxQuad); + $frame->addChild($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->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN)); + $mxQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN_MOVER)); $mxQuad->setPosition($width / 2 - 67, -$height / 2 + 9); $mxQuad->setZ(0.01); $mxQuad->setAction(self::ACTION_CHECK_UPDATE); @@ -204,13 +204,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { ) { // Directory browser $browserButton = new Label_Button(); - $frame->add($browserButton); + $frame->addChild($browserButton); $browserButton->setPosition($width / -2 + 20, -$height / 2 + 9, 0.01); $browserButton->setTextSize(1); $browserButton->setText('Directory Browser'); $browserQuad = new Quad_BgsPlayerCard(); - $frame->add($browserQuad); + $frame->addChild($browserQuad); $browserQuad->setPosition($width / -2 + 20, -$height / 2 + 9, 0.01); $browserQuad->setSubStyle($browserQuad::SUBSTYLE_BgPlayerCardBig); $browserQuad->setSize(35, 4); @@ -219,7 +219,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 +227,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,7 +251,7 @@ 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->addPageControl($pageFrame, $pageNumber); $pageNumber++; @@ -259,13 +259,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { // 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 +273,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 +285,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 +297,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 +331,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 +351,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 +377,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 +395,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 +415,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 +426,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 +477,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 +549,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); diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index 15779189..b6e9f5cb 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -472,18 +472,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 +491,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 +502,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); diff --git a/core/Players/PlayerDetailed.php b/core/Players/PlayerDetailed.php index 79999e97..9c4906f7 100644 --- a/core/Players/PlayerDetailed.php +++ b/core/Players/PlayerDetailed.php @@ -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); diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index c324691b..bbc49cda 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -149,7 +149,7 @@ 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; @@ -157,11 +157,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // 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,7 +177,7 @@ 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->addPageControl($pageFrame); $posY = $height / 2 - 10; @@ -185,11 +185,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $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); @@ -204,7 +204,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // 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->setSize(4, 4); @@ -215,7 +215,7 @@ 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->setSize(3.8, 3.8); @@ -231,7 +231,7 @@ 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->setSubStyle($specQuad::SUBSTYLE_Spectator); @@ -242,8 +242,8 @@ 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->setSize(4, 4); @@ -253,14 +253,14 @@ 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->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->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelAbbreviation($listPlayer->authLevel)); @@ -272,7 +272,7 @@ 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->setSize(2.7, 2.7); @@ -283,7 +283,7 @@ 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->setSize(3.8, 3.8); @@ -294,7 +294,7 @@ 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->setSize(3.8, 3.8); @@ -308,7 +308,7 @@ 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->setSize(3.8, 3.8); @@ -324,7 +324,7 @@ 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->setSize(3.8, 3.8); @@ -337,7 +337,7 @@ 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->setSize(3.8, 3.8); @@ -351,7 +351,7 @@ 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->setSize(3.8, 3.8); @@ -365,7 +365,7 @@ 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->setSize(3.8, 3.8); @@ -380,7 +380,7 @@ 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->setSize(3.8, 3.8); @@ -393,7 +393,7 @@ 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->setSize(3.8, 3.8); @@ -413,7 +413,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 @@ -449,7 +449,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Add Close Quad (X) $closeQuad = new Quad_Icons64x64_1(); - $frame->add($closeQuad); + $frame->addChild($closeQuad); $closeQuad->setPosition($width * 0.4, $height * 0.43, 3); $closeQuad->setSize(6, 6); $closeQuad->setSubStyle($closeQuad::SUBSTYLE_QuitRace); @@ -457,23 +457,23 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // 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->setImageUrl('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); + $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width - 2, $height - 2); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $backgroundQuad->setZ(-0.4); // 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); @@ -483,8 +483,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Show Nickname $label = new Label_Text(); - $frame->add($label); - $label->setHAlign($label::LEFT); + $frame->addChild($label); + $label->setHorizontalAlign($label::LEFT); $label->setX(0); $label->setY($height / 2 - 8); $label->setStyle($label::STYLE_TextCardSmall); @@ -495,14 +495,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Mute Player $posY = $height / 2 - 14; $quad = new Quad_BgsPlayerCard(); - $frame->add($quad); + $frame->addChild($quad); $quad->setX(0); $quad->setY($posY); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); $quad->setSize($quadWidth, 5); $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setX(0); $label->setY($posY); $label->setStyle($label::STYLE_TextCardSmall); @@ -520,12 +520,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Warn Player $posY -= 5; $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); @@ -534,12 +534,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // 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'); @@ -547,12 +547,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $posY -= 5; // 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'); @@ -560,12 +560,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $posY -= 10; // 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); @@ -573,12 +573,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $posY -= 5; // 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); @@ -586,12 +586,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $posY -= 5; // 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); @@ -602,12 +602,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $posY -= 5; // 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'); diff --git a/core/Plugins/InstallMenu.php b/core/Plugins/InstallMenu.php index 21e667d9..26c2dd51 100644 --- a/core/Plugins/InstallMenu.php +++ b/core/Plugins/InstallMenu.php @@ -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->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); + $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; diff --git a/core/Plugins/PluginMenu.php b/core/Plugins/PluginMenu.php index c42ce1a1..98d97189 100644 --- a/core/Plugins/PluginMenu.php +++ b/core/Plugins/PluginMenu.php @@ -103,13 +103,13 @@ 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); @@ -118,8 +118,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $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,7 +148,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns /** @var Plugin $pluginClass */ if ($index % $pageMaxCount === 0) { $pageFrame = new Frame(); - $frame->add($pageFrame); + $frame->addChild($pageFrame); $paging->addPageControl($pageFrame); $posY = $height * 0.41; } @@ -156,11 +156,11 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $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,7 +179,7 @@ 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); @@ -192,7 +192,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $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); @@ -200,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) { @@ -216,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); @@ -229,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); @@ -264,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); @@ -276,18 +276,18 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns foreach ($settings as $setting) { if ($index % $pageSettingsMaxCount === 0) { $pageFrame = new Frame(); - $frame->add($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); @@ -301,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(); @@ -310,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); @@ -329,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); diff --git a/core/Server/ServerOptionsMenu.php b/core/Server/ServerOptionsMenu.php index 4e92497d..dea5ee47 100644 --- a/core/Server/ServerOptionsMenu.php +++ b/core/Server/ServerOptionsMenu.php @@ -258,16 +258,16 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList // 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 = 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.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->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel); @@ -285,29 +285,29 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList if ($index % 13 === 0) { $pageFrame = new Frame(); - $frame->add($pageFrame); + $frame->addChild($pageFrame); $posY = $height * 0.41; $paging->addPageControl($pageFrame); } $optionsFrame = new Frame(); - $pageFrame->add($optionsFrame); + $pageFrame->addChild($optionsFrame); $optionsFrame->setY($posY); $nameLabel = new Label_Text(); - $optionsFrame->add($nameLabel); - $nameLabel->setHAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.4, $optionHeight)->setStyle($nameLabel::STYLE_TextCardSmall)->setTextSize($labelTextSize)->setText($name)->setTextColor('fff'); + $optionsFrame->addChild($nameLabel); + $nameLabel->setHorizontalAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.4, $optionHeight)->setStyle($nameLabel::STYLE_TextCardSmall)->setTextSize($labelTextSize)->setText($name)->setTextColor('fff'); if (is_bool($value)) { // Boolean checkbox $quad = new Quad(); $quad->setPosition($width * 0.23, 0, -0.01)->setSize(4, 4); $checkBox = new CheckBox(self::ACTION_PREFIX_OPTION . $name, $value, $quad); - $optionsFrame->add($checkBox); + $optionsFrame->addChild($checkBox); } else { // Other $entry = new Entry(); - $optionsFrame->add($entry); + $optionsFrame->addChild($entry); $entry->setStyle(Label_Text::STYLE_TextValueSmall)->setX($width * 0.23)->setTextSize(1)->setSize($width * 0.48, $optionHeight * 0.9)->setName(self::ACTION_PREFIX_OPTION . $name)->setDefault($value); if ($name === 'Comment') { diff --git a/core/Server/VoteRatiosMenu.php b/core/Server/VoteRatiosMenu.php index de6ffaf3..7c85698c 100644 --- a/core/Server/VoteRatiosMenu.php +++ b/core/Server/VoteRatiosMenu.php @@ -47,14 +47,14 @@ class VoteRatiosMenu implements CallbackListener, ConfiguratorMenu, TimerListene } /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() + * @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle() */ public static function getTitle() { return 'Vote Ratios'; } /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() + * @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu() */ public function getMenu($width, $height, Script $script, Player $player) { $frame = new Frame(); @@ -66,15 +66,15 @@ class VoteRatiosMenu implements CallbackListener, ConfiguratorMenu, TimerListene $voteRatios = $this->maniaControl->getClient()->getCallVoteRatios(); foreach ($voteRatioCommands as $voteRatioCommand => $voteRatioDescription) { $voteRatioFrame = new Frame(); - $frame->add($voteRatioFrame); + $frame->addChild($voteRatioFrame); $voteRatioFrame->setY($posY); $nameLabel = new Label_Text(); - $voteRatioFrame->add($nameLabel); - $nameLabel->setHAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.7, $lineHeight)->setTextSize(2)->setTranslate(true)->setText($voteRatioDescription); + $voteRatioFrame->addChild($nameLabel); + $nameLabel->setHorizontalAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.7, $lineHeight)->setTextSize(2)->setTranslate(true)->setText($voteRatioDescription); $entry = new Entry(); - $voteRatioFrame->add($entry); + $voteRatioFrame->addChild($entry); $entry->setX($width * 0.35)->setSize($width * 0.14, $lineHeight * 0.9)->setStyle(Label_Text::STYLE_TextValueSmall)->setTextSize($index === 0 ? 2 : 1)->setName(self::ACTION_PREFIX_VOTE_RATIO . $voteRatioCommand); $voteRatio = $this->getVoteRatioForCommand($voteRatios, $voteRatioCommand); diff --git a/core/Statistics/SimpleStatsList.php b/core/Statistics/SimpleStatsList.php index c42a314e..a3715854 100644 --- a/core/Statistics/SimpleStatsList.php +++ b/core/Statistics/SimpleStatsList.php @@ -130,19 +130,19 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, // Main frame $frame = new Frame(); - $maniaLink->add($frame); + $maniaLink->addChild($frame); $frame->setSize($width, $height); $frame->setPosition(0, 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.483, $height * 0.467, 3); $closeQuad->setSize(6, 6); $closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace); @@ -154,7 +154,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, // Predefine Description Label $descriptionLabel = new Label(); - $frame->add($descriptionLabel); + $frame->addChild($descriptionLabel); $descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP); $descriptionLabel->setPosition($xStart + 10, -$height / 2 + 5); $descriptionLabel->setSize($width * 0.7, 4); @@ -163,7 +163,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, // Headline $headFrame = new Frame(); - $frame->add($headFrame); + $frame->addChild($headFrame); $headFrame->setY($posY - 5); $posX = $xStart; @@ -221,12 +221,12 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, } $playerFrame = new Frame(); - $frame->add($playerFrame); + $frame->addChild($playerFrame); // Show current Player Arrow if ($playerId == $player->index) { $currentQuad = new Quad_Icons64x64_1(); - $playerFrame->add($currentQuad); + $playerFrame->addChild($currentQuad); $currentQuad->setX($xStart + 3.5); $currentQuad->setZ(0.2); $currentQuad->setSize(4, 4); @@ -254,8 +254,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $posX = $xStart + 55; foreach ($displayArray as $key => $array) { $label = new Label_Text(); - $playerFrame->add($label); - $label->setHAlign($label::LEFT); + $playerFrame->addChild($label); + $label->setHorizontalAlign($label::LEFT); $label->setX($posX); $label->setStyle($label::STYLE_TextCardSmall); $label->setTextSize($textSize); @@ -269,7 +269,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, 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); diff --git a/plugins/MCTeam/CustomVotesPlugin.php b/plugins/MCTeam/CustomVotesPlugin.php index 5b7982dd..560ec377 100644 --- a/plugins/MCTeam/CustomVotesPlugin.php +++ b/plugins/MCTeam/CustomVotesPlugin.php @@ -304,31 +304,31 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP //Custom Vote Menu Iconsframe $frame = new Frame(); - $maniaLink->add($frame); + $maniaLink->addChild($frame); $frame->setPosition($posX, $posY); $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width * $itemMarginFactorX, $height * $itemMarginFactorY); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $iconFrame = new Frame(); - $frame->add($iconFrame); + $frame->addChild($iconFrame); $iconFrame->setSize($itemSize, $itemSize); $itemQuad = new Quad_UIConstruction_Buttons(); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Add); $itemQuad->setSize($itemSize, $itemSize); - $iconFrame->add($itemQuad); + $iconFrame->addChild($itemQuad); //Define Description Label $menuEntries = count($this->voteMenuItems); $descriptionFrame = new Frame(); - $maniaLink->add($descriptionFrame); + $manialink->addChild($descriptionFrame); $descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.15 - 6, $posY); $descriptionLabel = new Label(); - $descriptionFrame->add($descriptionLabel); + $descriptionFrame->addChild($descriptionLabel); $descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP); $descriptionLabel->setSize(40, 4); $descriptionLabel->setTextSize(1.4); @@ -336,15 +336,16 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP //Popout Frame $popoutFrame = new Frame(); - $maniaLink->add($popoutFrame); + $manialink->addChild($popoutFrame); $popoutFrame->setPosition($posX - $itemSize * 0.5, $posY); - $popoutFrame->setHAlign($popoutFrame::RIGHT); + $popoutFrame->setHorizontalAlign($popoutFrame::RIGHT); $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); $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($menuEntries * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY); @@ -356,14 +357,14 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP foreach ($menuItems as $menuItem) { /** @var Quad $menuQuad */ $menuQuad = $menuItem[0]; - $popoutFrame->add($menuQuad); + $popoutFrame->addChild($menuQuad); $menuQuad->setSize($itemSize, $itemSize); $menuQuad->setX($posX); - $menuQuad->setHAlign($menuQuad::RIGHT); + $menuQuad->setHorizontalAlign($menuQuad::RIGHT); $posX -= $itemSize * 1.05; if ($menuItem[1]) { - $menuQuad->removeScriptFeatures(); + $menuQuad->removeAllScriptFeatures(); $description = '$s' . $menuItem[1]; $menuQuad->addTooltipLabelFeature($descriptionLabel, $description); } @@ -702,19 +703,19 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP // mainframe $frame = new Frame(); - $maniaLink->add($frame); + $maniaLink->addChild($frame); $frame->setSize($width, $height); $frame->setPosition($posX, $posY, 30); // Background Quad $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); //Vote for label $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setY($height / 2 - 3); $label->setSize($width - 5, $height); $label->setTextSize(1.3); @@ -722,7 +723,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP //Started by nick $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setY($height / 2 - 6); $label->setSize($width - 5, 2); $label->setTextSize(1); @@ -731,7 +732,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP //Time Gauge $timeGauge = new Gauge(); - $frame->add($timeGauge); + $frame->addChild($timeGauge); $timeGauge->setY(1.5); $timeGauge->setSize($width * 0.95, 6); $timeGauge->setDrawBg(false); @@ -745,7 +746,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP //Time Left $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setY(0); $label->setSize($width - 5, $height); $label->setTextSize(1.1); @@ -754,7 +755,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP //Vote Gauge $voteGauge = new Gauge(); - $frame->add($voteGauge); + $frame->addChild($voteGauge); $voteGauge->setY(-4); $voteGauge->setSize($width * 0.65, 12); $voteGauge->setDrawBg(false); @@ -764,7 +765,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $posY = -4.4; $voteLabel = new Label(); - $frame->add($voteLabel); + $frame->addChild($voteLabel); $voteLabel->setY($posY); $voteLabel->setSize($width * 0.65, 12); $voteLabel->setStyle($labelStyle); @@ -773,13 +774,13 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $positiveQuad = new Quad_BgsPlayerCard(); - $frame->add($positiveQuad); + $frame->addChild($positiveQuad); $positiveQuad->setPosition(-$width / 2 + 6, $posY); $positiveQuad->setSubStyle($positiveQuad::SUBSTYLE_BgPlayerCardBig); $positiveQuad->setSize(5, 5); $positiveLabel = new Label_Button(); - $frame->add($positiveLabel); + $frame->addChild($positiveLabel); $positiveLabel->setPosition(-$width / 2 + 6, $posY); $positiveLabel->setStyle($labelStyle); $positiveLabel->setTextSize(1); @@ -788,11 +789,11 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $positiveLabel->setText('F1'); $negativeQuad = clone $positiveQuad; - $frame->add($negativeQuad); + $frame->addChild($negativeQuad); $negativeQuad->setX($width / 2 - 6); $negativeLabel = clone $positiveLabel; - $frame->add($negativeLabel); + $frame->addChild($negativeLabel); $negativeLabel->setX($width / 2 - 6); $negativeLabel->setTextColor('F00'); $negativeLabel->setText('F2'); diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 86287307..5af18ddd 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -476,18 +476,18 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $manialink = new ManiaLink(self::MLID_DEDIMANIA); $frame = new Frame(); - $manialink->add($frame); + $manialink->addChild($frame); $frame->setPosition($posX, $posY); $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); - $backgroundQuad->setVAlign($backgroundQuad::TOP); + $frame->addChild($backgroundQuad); + $backgroundQuad->setVerticalAlign($backgroundQuad::TOP); $height = 7. + $lines * $lineHeight; $backgroundQuad->setSize($width * 1.05, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $titleLabel = new Label(); - $frame->add($titleLabel); + $frame->addChild($titleLabel); $titleLabel->setPosition(0, $lineHeight * -0.9); $titleLabel->setWidth($width); $titleLabel->setStyle($labelStyle); @@ -504,18 +504,18 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $y = -8. - $index * $lineHeight; $recordFrame = new Frame(); - $frame->add($recordFrame); + $frame->addChild($recordFrame); $recordFrame->setPosition(0, $y); /*$backgroundQuad = new Quad(); - $recordFrame->add($backgroundQuad); + $recordFrame->addChild($backgroundQuad); $backgroundQuad->setSize($width * 1.04, $lineHeight * 1.4); $backgroundQuad->setStyles($quadStyle, $quadSubstyle);*/ //Rank $rankLabel = new Label(); - $recordFrame->add($rankLabel); - $rankLabel->setHAlign($rankLabel::LEFT); + $recordFrame->addChild($rankLabel); + $rankLabel->setHorizontalAlign($rankLabel::LEFT); $rankLabel->setX($width * -0.47); $rankLabel->setSize($width * 0.06, $lineHeight); $rankLabel->setTextSize(1); @@ -525,8 +525,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene //Name $nameLabel = new Label(); - $recordFrame->add($nameLabel); - $nameLabel->setHAlign($nameLabel::LEFT); + $recordFrame->addChild($nameLabel); + $nameLabel->setHorizontalAlign($nameLabel::LEFT); $nameLabel->setX($width * -0.4); $nameLabel->setSize($width * 0.6, $lineHeight); $nameLabel->setTextSize(1); @@ -535,8 +535,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene //Time $timeLabel = new Label(); - $recordFrame->add($timeLabel); - $timeLabel->setHAlign($timeLabel::RIGHT); + $recordFrame->addChild($timeLabel); + $timeLabel->setHorizontalAlign($timeLabel::RIGHT); $timeLabel->setX($width * 0.47); $timeLabel->setSize($width * 0.25, $lineHeight); $timeLabel->setTextSize(1); @@ -1113,7 +1113,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene // Main frame $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); - $maniaLink->add($frame); + $maniaLink->addChild($frame); // Start offsets $posX = -$width / 2; @@ -1121,11 +1121,11 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene // 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('Rank' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Time' => $posX + 101); $this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); @@ -1137,17 +1137,17 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene foreach ($records as $listRecord) { if ($index % 15 === 0) { $pageFrame = new Frame(); - $frame->add($pageFrame); + $frame->addChild($pageFrame); $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $recordFrame = new Frame(); - $pageFrame->add($recordFrame); + $pageFrame->addChild($recordFrame); if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); - $recordFrame->add($lineQuad); + $recordFrame->addChild($lineQuad); $lineQuad->setSize($width, 4); $lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig); $lineQuad->setZ(0.001); diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index 40536c0d..24ec5942 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -170,50 +170,50 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { // Donate Menu Icon Frame $frame = new Frame(); - $maniaLink->add($frame); + $maniaLink->addChild($frame); $frame->setPosition($posX, $posY); $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width * $itemMarginFactorX, $height * $itemMarginFactorY); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $iconFrame = new Frame(); - $frame->add($iconFrame); + $frame->addChild($iconFrame); $iconFrame->setSize($itemSize, $itemSize); $itemQuad = new Quad_BgRaceScore2(); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Points); $itemQuad->setSize($itemSize, $itemSize); - $iconFrame->add($itemQuad); + $iconFrame->addChild($itemQuad); $valueArray = explode(',', $values); // Values Menu $popoutFrame = new Frame(); - $maniaLink->add($popoutFrame); + $manialink->addChild($popoutFrame); $popoutFrame->setPosition($posX - $itemSize * 0.5, $posY); - $popoutFrame->setHAlign($popoutFrame::RIGHT); + $popoutFrame->setHorizontalAlign($popoutFrame::RIGHT); $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); $popoutFrame->setVisible(false); $quad = new Quad(); - $popoutFrame->add($quad); - $quad->setHAlign($quad::RIGHT); + $popoutFrame->addChild($quad); + $quad->setHorizontalAlign($quad::RIGHT); $quad->setStyles($quadStyle, $quadSubstyle); $quad->setSize(strlen($values) * 2 + count($valueArray) * 1, $itemSize * $itemMarginFactorY); - $popoutFrame->add($quad); + $popoutFrame->addChild($quad); $itemQuad->addToggleFeature($popoutFrame); // Description Label $descriptionFrame = new Frame(); - $maniaLink->add($descriptionFrame); + $manialink->addChild($descriptionFrame); $descriptionFrame->setPosition($posX - 50, $posY - 5); - $descriptionFrame->setHAlign($descriptionFrame::RIGHT); + $descriptionFrame->setHorizontalAlign($descriptionFrame::RIGHT); $descriptionLabel = new Label(); - $descriptionFrame->add($descriptionLabel); + $descriptionFrame->addChild($descriptionLabel); $descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP); $descriptionLabel->setSize(40, 4); $descriptionLabel->setTextSize(2); @@ -224,9 +224,9 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $posX = -2; foreach (array_reverse($valueArray) as $value) { $label = new Label_Text(); - $popoutFrame->add($label); + $popoutFrame->addChild($label); $label->setX($posX); - $label->setHAlign($label::RIGHT); + $label->setHorizontalAlign($label::RIGHT); $label->setText('$s$FFF' . $value . '$09FP'); $label->setTextSize(1.2); $label->setAction(self::ACTION_DONATE_VALUE . "." . $value); @@ -478,7 +478,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { // Main frame $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); - $maniaLink->add($frame); + $maniaLink->addChild($frame); // Start offsets $posX = -$width / 2; @@ -486,11 +486,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { //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('$oId' => $posX + 5, '$oNickname' => $posX + 18, '$oLogin' => $posX + 70, '$oDonated planets' => $posX + 110); $this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); @@ -502,18 +502,18 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { foreach ($stats as $playerIndex => $donations) { if ($index % 15 === 1) { $pageFrame = new Frame(); - $frame->add($pageFrame); + $frame->addChild($pageFrame); $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $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); diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index 7bd20b5d..7f78b334 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -922,17 +922,17 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $manialink = new ManiaLink(self::MLID_KARMA); $frame = new Frame(); - $manialink->add($frame); + $manialink->addChild($frame); $frame->setPosition($posX, $posY); $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $frame->addChild($backgroundQuad); $backgroundQuad->setY($height * 0.15); $backgroundQuad->setSize($width, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $titleLabel = new Label(); - $frame->add($titleLabel); + $frame->addChild($titleLabel); $titleLabel->setY($height * 0.36); $titleLabel->setWidth($width * 0.85); $titleLabel->setStyle($labelStyle); @@ -942,13 +942,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $titleLabel->setText($title); $karmaGauge = new Gauge(); - $frame->add($karmaGauge); + $frame->addChild($karmaGauge); $karmaGauge->setSize($width * 0.95, $height * 0.92); - $karmaGauge->setDrawBg(false); + $karmaGauge->setDrawBackground(false); $manialink->karmaGauge = $karmaGauge; $karmaLabel = new Label(); - $frame->add($karmaLabel); + $frame->addChild($karmaLabel); $karmaLabel->setPosition(0, -0.4, 1); $karmaLabel->setSize($width * 0.9, $height * 0.9); $karmaLabel->setStyle($labelStyle); @@ -956,7 +956,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $manialink->karmaLabel = $karmaLabel; $votesFrame = new Frame(); - $frame->add($votesFrame); + $frame->addChild($votesFrame); $manialink->votesFrame = $votesFrame; $this->manialink = $manialink; diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index 6fa65665..4a10f3a8 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -233,12 +233,12 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $manialink = new ManiaLink(self::MLID_RECORDS); $frame = new Frame(); - $manialink->add($frame); + $manialink->addChild($frame); $frame->setPosition($posX, $posY); $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); - $backgroundQuad->setVAlign($backgroundQuad::TOP); + $frame->addChild($backgroundQuad); + $backgroundQuad->setVerticalAlign($backgroundQuad::TOP); $adjustOuterBorder = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ADJUST_OUTER_BORDER); $height = 7. + ($adjustOuterBorder ? count($records) : $lines) * $lineHeight; $backgroundQuad->setSize($width * 1.05, $height); @@ -246,7 +246,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $backgroundQuad->setAction(self::ACTION_SHOW_RECORDSLIST); $titleLabel = new Label(); - $frame->add($titleLabel); + $frame->addChild($titleLabel); $titleLabel->setPosition(0, $lineHeight * -0.9); $titleLabel->setWidth($width); $titleLabel->setStyle($labelStyle); @@ -263,16 +263,16 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $y = -8. - $index * $lineHeight; $recordFrame = new Frame(); - $frame->add($recordFrame); + $frame->addChild($recordFrame); $recordFrame->setPosition(0, $y); /* - * $backgroundQuad = new Quad(); $recordFrame->add($backgroundQuad); $backgroundQuad->setSize($width * 1.04, $lineHeight * 1.4); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); + * $backgroundQuad = new Quad(); $recordFrame->addChild($backgroundQuad); $backgroundQuad->setSize($width * 1.04, $lineHeight * 1.4); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); */ $rankLabel = new Label(); - $recordFrame->add($rankLabel); - $rankLabel->setHAlign($rankLabel::LEFT); + $recordFrame->addChild($rankLabel); + $rankLabel->setHorizontalAlign($rankLabel::LEFT); $rankLabel->setX($width * -0.47); $rankLabel->setSize($width * 0.06, $lineHeight); $rankLabel->setTextSize(1); @@ -281,8 +281,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $rankLabel->setTextEmboss(true); $nameLabel = new Label(); - $recordFrame->add($nameLabel); - $nameLabel->setHAlign($nameLabel::LEFT); + $recordFrame->addChild($nameLabel); + $nameLabel->setHorizontalAlign($nameLabel::LEFT); $nameLabel->setX($width * -0.4); $nameLabel->setSize($width * 0.6, $lineHeight); $nameLabel->setTextSize(1); @@ -290,8 +290,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $nameLabel->setTextEmboss(true); $timeLabel = new Label(); - $recordFrame->add($timeLabel); - $timeLabel->setHAlign($timeLabel::RIGHT); + $recordFrame->addChild($timeLabel); + $timeLabel->setHorizontalAlign($timeLabel::RIGHT); $timeLabel->setX($width * 0.47); $timeLabel->setSize($width * 0.25, $lineHeight); $timeLabel->setTextSize(1); @@ -566,7 +566,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList // Main frame $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); - $maniaLink->add($frame); + $maniaLink->addChild($frame); // Start offsets $posX = -$width / 2; @@ -574,11 +574,11 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList // 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('Rank' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Time' => $posX + 101); $this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); @@ -590,17 +590,17 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList foreach ($records as $listRecord) { if ($index % 15 === 0) { $pageFrame = new Frame(); - $frame->add($pageFrame); + $frame->addChild($pageFrame); $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $recordFrame = new Frame(); - $pageFrame->add($recordFrame); + $pageFrame->addChild($recordFrame); if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); - $recordFrame->add($lineQuad); + $recordFrame->addChild($lineQuad); $lineQuad->setSize($width, 4); $lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig); $lineQuad->setZ(0.001); diff --git a/plugins/MCTeam/ServerRankingPlugin.php b/plugins/MCTeam/ServerRankingPlugin.php index c2d3e7d2..2d127466 100644 --- a/plugins/MCTeam/ServerRankingPlugin.php +++ b/plugins/MCTeam/ServerRankingPlugin.php @@ -493,7 +493,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { // Main frame $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); - $maniaLink->add($frame); + $maniaLink->addChild($frame); // Start offsets $posX = -$width / 2; @@ -501,11 +501,11 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { //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('$oRank' => $posX + 5, '$oNickname' => $posX + 18, '$oAverage' => $posX + 70); $this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); @@ -517,18 +517,18 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { while ($rankedPlayer = $result->fetch_object()) { if ($index % 15 === 1) { $pageFrame = new Frame(); - $frame->add($pageFrame); + $frame->addChild($pageFrame); $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $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); diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index 91a3f6b7..6875c12c 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -169,17 +169,14 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { */ private function displayWidgets() { // Display Map Widget - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { $this->maniaControl->getClient()->triggerModeScriptEvent("Siege_SetProgressionLayerPosition", array("160.", "-67.", "0.")); $this->displayMapWidget(); } - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) { $this->displayClockWidget(); } - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { $this->displayServerInfoWidget(); } } @@ -203,13 +200,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { // mainframe $frame = new Frame(); - $maniaLink->add($frame); + $maniaLink->addChild($frame); $frame->setSize($width, $height); $frame->setPosition($posX, $posY); // Background Quad $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); //$backgroundQuad->addMapInfoFeature(); @@ -217,7 +214,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $map = $this->maniaControl->getMapManager()->getCurrentMap(); $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(0, 1.5, 0.2); $label->setTextSize(1.3); $label->setText(Formatter::stripDirtyCodes($map->name)); @@ -225,7 +222,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $label->setSize($width - 5, $height); $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(0, -1.4, 0.2); $label->setTextSize(1); $label->setScale(0.8); @@ -235,9 +232,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { if (isset($map->mx->pageurl)) { $quad = new Quad(); - $frame->add($quad); - $quad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER)); - $quad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON)); + $frame->addChild($quad); + $quad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER)); + $quad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON)); $quad->setPosition(-$width / 2 + 4, -1.5, -0.5); $quad->setSize(4, 4); $quad->setUrl($map->mx->pageurl); @@ -264,20 +261,20 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { // mainframe $frame = new Frame(); - $maniaLink->add($frame); + $maniaLink->addChild($frame); $frame->setSize($width, $height); $frame->setPosition($posX, $posY); // Background Quad $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(0, 1.5, 0.2); - $label->setVAlign($label::TOP); + $label->setVerticalAlign($label::TOP); $label->setTextSize(1); $label->setTextColor('fff'); $label->addClockFeature(false); @@ -303,13 +300,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { // mainframe $frame = new Frame(); - $maniaLink->add($frame); + $maniaLink->addChild($frame); $frame->setSize($width, $height); $frame->setPosition($posX, $posY); // Background Quad $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); @@ -322,7 +319,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $maxSpectators = $this->maniaControl->getClient()->getMaxSpectators(); $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(0, 1.5, 0.2); $label->setSize($width - 5, $height); $label->setTextSize(1.3); @@ -332,39 +329,39 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { // Player Quad / Label $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(-$width / 2 + 9, -1.5, 0.2); - $label->setHAlign($label::LEFT); + $label->setHorizontalAlign($label::LEFT); $label->setTextSize(1); $label->setScale(0.8); $label->setText($playerCount . " / " . $maxPlayers['NextValue']); $label->setTextColor('fff'); $quad = new Quad_Icons128x128_1(); - $frame->add($quad); + $frame->addChild($quad); $quad->setSubStyle($quad::SUBSTYLE_Multiplayer); $quad->setPosition(-$width / 2 + 7, -1.6, 0.2); $quad->setSize(2.5, 2.5); // Spectator Quad / Label $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(2, -1.5, 0.2); - $label->setHAlign($label::LEFT); + $label->setHorizontalAlign($label::LEFT); $label->setTextSize(1); $label->setScale(0.8); $label->setText($spectatorCount . " / " . $maxSpectators['NextValue']); $label->setTextColor('fff'); $quad = new Quad_Icons64x64_1(); - $frame->add($quad); + $frame->addChild($quad); $quad->setSubStyle($quad::SUBSTYLE_Camera); $quad->setPosition(0, -1.6, 0.2); $quad->setSize(3.3, 2.5); // Favorite quad $quad = new Quad_Icons64x64_1(); - $frame->add($quad); + $frame->addChild($quad); $quad->setSubStyle($quad::SUBSTYLE_StateFavourite); $quad->setPosition($width / 2 - 4, -1.5, -0.5); $quad->setSize(3, 3); @@ -400,8 +397,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * Handle Begin Map Callback */ public function handleOnBeginMap() { - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { $this->displayMapWidget(); } $this->closeWidget(self::MLID_NEXTMAP_WIDGET); @@ -411,8 +407,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * Handle End Map Callback */ public function handleOnEndMap() { - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) { $this->displayNextMapWidget(); } } @@ -435,13 +430,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { // mainframe $frame = new Frame(); - $maniaLink->add($frame); + $maniaLink->addChild($frame); $frame->setSize($width, $height); $frame->setPosition($posX, $posY); // Background Quad $backgroundQuad = new Quad(); - $frame->add($backgroundQuad); + $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); @@ -470,7 +465,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { } $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(0, $height / 2 - 2.3, 0.2); $label->setTextSize(1); $label->setText('Next Map'); @@ -478,7 +473,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $label->setStyle($labelStyle); $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(0, $height / 2 - 5.5, 0.2); $label->setTextSize(1.3); $label->setText($name); @@ -486,7 +481,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $label->setSize($width - 5, $height); $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(0, -$height / 2 + 4); $label->setZ(0.2); $label->setTextSize(1); @@ -496,7 +491,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { if ($requester) { $label = new Label_Text(); - $frame->add($label); + $frame->addChild($label); $label->setPosition(0, -$height / 2 + 2, 0.2); $label->setTextSize(1); $label->setScale(0.7); @@ -516,16 +511,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { */ public function handlePlayerConnect(Player $player) { // Display Map Widget - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { $this->displayMapWidget($player->login); } - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) { $this->displayClockWidget($player->login); } - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { $this->displayServerInfoWidget(); } } @@ -545,8 +537,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * Update Widget on certain callbacks */ public function updateWidgets() { - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { $this->displayServerInfoWidget(); } } From 8a9ae9465a988ad7fda90f7df21f017b2b0143d8 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 25 Mar 2017 19:25:20 +0100 Subject: [PATCH 29/73] small fault fixes --- core/Players/PlayerList.php | 2 +- plugins/MCTeam/CustomVotesPlugin.php | 4 ++-- plugins/MCTeam/DonationPlugin.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index bbc49cda..45e33bbf 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -413,7 +413,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->addChild($frame); + $maniaLink->addChild($frame); } // Render and display xml diff --git a/plugins/MCTeam/CustomVotesPlugin.php b/plugins/MCTeam/CustomVotesPlugin.php index 560ec377..492e9551 100644 --- a/plugins/MCTeam/CustomVotesPlugin.php +++ b/plugins/MCTeam/CustomVotesPlugin.php @@ -324,7 +324,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP //Define Description Label $menuEntries = count($this->voteMenuItems); $descriptionFrame = new Frame(); - $manialink->addChild($descriptionFrame); + $maniaLink->addChild($descriptionFrame); $descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.15 - 6, $posY); $descriptionLabel = new Label(); @@ -336,7 +336,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP //Popout Frame $popoutFrame = new Frame(); - $manialink->addChild($popoutFrame); + $maniaLink->addChild($popoutFrame); $popoutFrame->setPosition($posX - $itemSize * 0.5, $posY); $popoutFrame->setHorizontalAlign($popoutFrame::RIGHT); $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index 24ec5942..d1de33d1 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -191,7 +191,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { // Values Menu $popoutFrame = new Frame(); - $manialink->addChild($popoutFrame); + $maniaLink->addChild($popoutFrame); $popoutFrame->setPosition($posX - $itemSize * 0.5, $posY); $popoutFrame->setHorizontalAlign($popoutFrame::RIGHT); $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); @@ -208,7 +208,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { // Description Label $descriptionFrame = new Frame(); - $manialink->addChild($descriptionFrame); + $maniaLink->addChild($descriptionFrame); $descriptionFrame->setPosition($posX - 50, $posY - 5); $descriptionFrame->setHorizontalAlign($descriptionFrame::RIGHT); From d6995f211d33035323ed1daf5786706a49cf329a Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 25 Mar 2017 20:19:45 +0100 Subject: [PATCH 30/73] callback implementation --- core/Callbacks/Callbacks.php | 22 ++--- core/Callbacks/LibXmlRpcCallbacks.php | 2 +- core/Callbacks/ShootManiaCallbacks.php | 22 ++++- .../Structures/ShootMania/Models/Landmark.php | 6 -- .../ShootMania/Models/PlayerScore.php | 8 +- .../Structures/ShootMania/Models/Position.php | 2 +- .../ShootMania/Models/TeamScore.php | 8 +- .../Structures/ShootMania/Models/Weapons.php | 17 ++++ .../ShootMania/OnCommandStructure.php | 57 ++++++++++++ .../ShootMania/OnCustomEventStructure.php | 14 +++ ...ucture.php => OnDefaultEventStructure.php} | 2 +- .../ShootMania/OnFallDamageStructure.php | 50 +++++++++++ .../OnPlayerRequestRespawnStructure.php | 50 +++++++++++ .../ShootMania/OnShootStructure.php | 8 +- .../ShootMania/OnShotDenyStructure.php | 88 +++++++++++++++++++ .../TrackMania/OnCommandStructure.php | 57 ++++++++++++ .../OnDefaultEventStructure.php} | 4 +- core/Callbacks/TrackManiaCallbacks.php | 8 +- 18 files changed, 380 insertions(+), 45 deletions(-) create mode 100644 core/Callbacks/Structures/ShootMania/Models/Weapons.php create mode 100644 core/Callbacks/Structures/ShootMania/OnCommandStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/OnCustomEventStructure.php rename core/Callbacks/Structures/ShootMania/{DefaultEventStructure.php => OnDefaultEventStructure.php} (93%) create mode 100644 core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php create mode 100644 core/Callbacks/Structures/TrackMania/OnCommandStructure.php rename core/Callbacks/Structures/{Trackmania/DefaultEventStructure.php => TrackMania/OnDefaultEventStructure.php} (87%) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index b74f331f..b997a1f9 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -63,17 +63,17 @@ interface Callbacks { const SM_SCORES = "Shootmania.Scores"; - const SM_EVENTDEFAULT = "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"; + 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_ONPLAYERREQUESTRESAWPN = "Shootmania.Event.OnPlayerRequestRespawn"; + const SM_ONPLAYERREQUESTRESPAWN = "Shootmania.Event.OnPlayerRequestRespawn"; const SM_ONACTIONCUSTOMEVENT = "Shootmania.Event.OnActionCustomEvent"; const SM_ONACTIONEVENT = "Shootmania.Event.OnActionEvent"; const SM_ONPLAYERTOUCHESOBJECT = "Shootmania.Event.OnPlayerTouchesObject"; @@ -82,7 +82,7 @@ interface Callbacks { const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange"; - const TM_EVENTDEFAULT = "Trackmania.Event.Default"; + const TM_ONEVENTDEFAULT = "Trackmania.Event.Default"; //ManiaControl Callbacks /** BeginMap Callback: Map */ diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index a5dbdc19..5f2adfc7 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -46,7 +46,7 @@ class LibXmlRpcCallbacks implements CallbackListener { public function handleScriptCallback($name, $data) { var_dump($name); if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { - return; + //return; //Leave that disabled while testing/implementing Callbacks } switch ($name) { //New callbacks diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 547dc125..4a7f2d21 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -4,10 +4,13 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure; -use ManiaControl\Callbacks\Structures\ShootMania\DefaultEventStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnHitNearMissArmorEmptyStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnShotDenyStructure; use ManiaControl\ManiaControl; /** @@ -53,12 +56,12 @@ class ShootManiaCallbacks implements CallbackListener { */ public function handleScriptCallbacks($name, $data) { if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { - return; + //return; //Leave that disabled while testing/implementing Callbacks } switch ($name) { //MP4 New Callbacks - case Callbacks::SM_EVENTDEFAULT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_EVENTDEFAULT, new DefaultEventStructure($this->maniaControl, $data)); + 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)); @@ -75,6 +78,17 @@ class ShootManiaCallbacks implements CallbackListener { 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: + break; //Old Callbacks case 'LibXmlRpc_Rankings': $this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]); diff --git a/core/Callbacks/Structures/ShootMania/Models/Landmark.php b/core/Callbacks/Structures/ShootMania/Models/Landmark.php index 81e0f2b3..bcf87d87 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Landmark.php +++ b/core/Callbacks/Structures/ShootMania/Models/Landmark.php @@ -1,10 +1,4 @@ + * @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; +} diff --git a/core/Callbacks/Structures/ShootMania/OnCommandStructure.php b/core/Callbacks/Structures/ShootMania/OnCommandStructure.php new file mode 100644 index 00000000..5140daaf --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnCommandStructure.php @@ -0,0 +1,57 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnCommandStructure extends BaseStructure { + public $time; + public $name; + public $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; + } + + /** Dumps the Object with some Information */ + public function dump() { + parent::dump(); + var_dump("With getShooter() you get a Player Object"); + } + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + /** + * @return mixed + */ + public function getName() { + return $this->name; + } + + /** + * @return \ManiaControl\Players\Player + */ + public function getValue() { + return $this->value; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnCustomEventStructure.php b/core/Callbacks/Structures/ShootMania/OnCustomEventStructure.php new file mode 100644 index 00000000..7137f8d6 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnCustomEventStructure.php @@ -0,0 +1,14 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnFallDamageStructure extends BaseStructure { + public $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); + } + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + /** + * @return Player + */ + public function getVictim() { + return $this->victim; + } + + /** Dumps the Object with some Information */ + public function dump() { + parent::dump(); + var_dump("With getVictim() you get a Player Object"); + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php new file mode 100644 index 00000000..dcf98c07 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php @@ -0,0 +1,50 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnPlayerRequestRespawnStructure extends BaseStructure { + public $time; + /** + * @var Player $shooter + */ + 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()->victim); + } + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + /** + * @return Player + */ + public function getPlayer() { + return $this->player; + } + + /** Dumps the Object with some Information */ + public function dump() { + parent::dump(); + var_dump("With getPlayer() you get a Player Object"); + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnShootStructure.php b/core/Callbacks/Structures/ShootMania/OnShootStructure.php index 2f2e9dcc..2b3b69c5 100644 --- a/core/Callbacks/Structures/ShootMania/OnShootStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnShootStructure.php @@ -7,6 +7,13 @@ use ManiaControl\Callbacks\Structures\BaseStructure; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; +/** + * Structure Class for the OnShoot Structure Callback + * + * @author ManiaControl Team + * @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; @@ -15,7 +22,6 @@ class OnShootStructure extends BaseStructure { */ private $shooter; - //TODO test public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); diff --git a/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php b/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php new file mode 100644 index 00000000..6b496d9d --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php @@ -0,0 +1,88 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnShotDenyStructure extends BaseStructure { + public $time; + public $shooterWeapon; + public $victimWeapon; + + protected $shooter; + protected $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); + } + + /** Dumps the Object with some Information */ + public function dump() { + parent::dump(); + var_dump("With getShooter() you get a Player Object"); + var_dump("With getVictim() you get a Player Object"); + } + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + + /** + * @return Player + */ + public function getShooter() { + return $this->shooter; + } + + /** + * @return Player + */ + public function getVictim() { + return $this->victim; + } + + /** + * @return mixed + */ + public function getShooterWeapon() { + return $this->shooterWeapon; + } + + /** + * @return mixed + */ + public function getVictimWeapon() { + return $this->victimWeapon; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnCommandStructure.php b/core/Callbacks/Structures/TrackMania/OnCommandStructure.php new file mode 100644 index 00000000..dd8fc655 --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/OnCommandStructure.php @@ -0,0 +1,57 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnCommandStructure extends BaseStructure { + public $time; + public $name; + public $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; + } + + /** Dumps the Object with some Information */ + public function dump() { + parent::dump(); + var_dump("With getShooter() you get a Player Object"); + } + + /** + * @return int + */ + public function getTime() { + return $this->time; + } + + /** + * @return mixed + */ + public function getName() { + return $this->name; + } + + /** + * @return \ManiaControl\Players\Player + */ + public function getValue() { + return $this->value; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php b/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php similarity index 87% rename from core/Callbacks/Structures/Trackmania/DefaultEventStructure.php rename to core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php index 80d63848..0d4abec8 100644 --- a/core/Callbacks/Structures/Trackmania/DefaultEventStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php @@ -1,6 +1,6 @@ maniaControl->getCallbackManager()->callbackListeningExists($name)) { - return; + //return; //Leave that disabled while testing/implementing Callbacks } switch ($name) { //MP4 New Callbacks - case Callbacks::TM_EVENTDEFAULT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_EVENTDEFAULT, new DefaultEventStructure($this->maniaControl, $data)); + case Callbacks::TM_ONEVENTDEFAULT: + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data)); break; } } From 4effad8f6d0a5618e6cf563c65840166f9abf4c8 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 25 Mar 2017 20:37:39 +0100 Subject: [PATCH 31/73] callback fixes --- core/Callbacks/Structures/ShootMania/OnCaptureStructure.php | 2 -- .../Structures/ShootMania/OnPlayerRequestRespawnStructure.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php index 0e73f889..9b9d23b3 100644 --- a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php @@ -42,8 +42,6 @@ class OnCaptureStructure extends BaseStructure { $position->setZ($jsonObj->landmark->position->z); $this->landMark->setPosition($position); - - $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); } /** Dumps the Object with some Information */ diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php index dcf98c07..ec086fe9 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php @@ -25,7 +25,7 @@ class OnPlayerRequestRespawnStructure extends BaseStructure { parent::__construct($maniaControl, $data); $this->time = $this->getPlainJsonObject()->time; - $this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); + $this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login); } /** From de3bae902947170cf7005ac8d8a33332eef4a2de Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 12:42:20 +0200 Subject: [PATCH 32/73] proper scoping to callback structures + usage Information Method --- core/Callbacks/Structures/BaseStructure.php | 36 +++++++++++--- .../ManiaPlanet/StartEndStructure.php | 6 ++- .../ManiaPlanet/StartServerStructure.php | 4 +- .../Structures/ShootMania/Models/Landmark.php | 8 ++-- .../ShootMania/OnCaptureStructure.php | 25 +++------- .../ShootMania/OnCommandStructure.php | 26 +++++----- .../ShootMania/OnDefaultEventStructure.php | 8 +++- .../ShootMania/OnFallDamageStructure.php | 11 ++--- .../OnHitNearMissArmorEmptyStructure.php | 47 ++++++++++--------- .../OnPlayerRequestRespawnStructure.php | 18 +++---- .../ShootMania/OnScoresStructure.php | 43 +++++++++-------- .../ShootMania/OnShootStructure.php | 1 + .../ShootMania/OnShotDenyStructure.php | 33 ++++++------- .../TrackMania/OnCommandStructure.php | 28 ++++++----- .../TrackMania/OnDefaultEventStructure.php | 8 +++- .../XmlRpc/CallbacksListStructure.php | 2 + 16 files changed, 172 insertions(+), 132 deletions(-) diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index 0310d222..7ee3b33a 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -3,8 +3,8 @@ namespace ManiaControl\Callbacks\Structures; -use ManiaControl\General\Dumpable; use ManiaControl\ManiaControl; +use ReflectionClass; /** * Base Structure of all Callback Structures @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class BaseStructure implements Dumpable { +abstract class BaseStructure { /** @var ManiaControl $maniaControl */ protected $maniaControl; private $plainJsonObject; @@ -31,10 +31,34 @@ abstract class BaseStructure implements Dumpable { } /** - * Var_Dump the Structure + * Gets Information about the Class, and a List of the Public Method */ - public function dump() { - var_dump(json_decode(json_encode($this))); - var_dump("Class Name including Namespace: " . get_class($this)); + public function getUsage() { + $reflection = new ReflectionClass(get_class($this)); + echo $reflection->getDocComment(); + + echo "\nStructure Name of Class = " . get_class($this); + + echo "\nMethods:\n"; + + $metody = $reflection->getMethods(); + $methods = array_reverse($metody); + foreach ($methods as $key => $value) { + /** @var \ReflectionMethod $value */ + //Don't print the Constructor + if ($value->isPublic() && $value->getName() != "__construct" && $value->getName() != "getUsage") { + echo "\n\n"; + $txt = preg_replace('/\t/', '', $value->getDocComment()); + + echo $txt; + echo "\n \$result = " . $value->getName() . "();"; + $parameters = $value->getParameters(); + + foreach ($parameters as $parameter) { + echo "\n" . $parameter; + } + echo "\n"; + } + } } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php index 0b3c663e..3f4f8d0f 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php @@ -14,7 +14,7 @@ use ManiaControl\ManiaControl; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class StartEndStructure extends BaseStructure { - public $count; + private $count; public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); @@ -23,7 +23,9 @@ class StartEndStructure extends BaseStructure { } /** - * @return mixed + * Get the Count of this Section + * + * @return int */ public function getCount() { return $this->count; diff --git a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php index 654c08a7..c3d2d6b8 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php @@ -14,7 +14,7 @@ use ManiaControl\ManiaControl; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class StartServerStructure extends BaseStructure { - public $restarted; + private $restarted; public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); @@ -23,6 +23,8 @@ class StartServerStructure extends BaseStructure { } /** + * Flag if the Server got Restarted + * * @return mixed */ public function getRestarted() { diff --git a/core/Callbacks/Structures/ShootMania/Models/Landmark.php b/core/Callbacks/Structures/ShootMania/Models/Landmark.php index bcf87d87..af562863 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Landmark.php +++ b/core/Callbacks/Structures/ShootMania/Models/Landmark.php @@ -10,14 +10,14 @@ class Landmark { private $position = null; /** - * @return mixed + * @return string */ public function getTag() { return $this->tag; } /** - * @param mixed $tag + * @param string $tag */ public function setTag($tag) { $this->tag = $tag; @@ -52,14 +52,14 @@ class Landmark { } /** - * @return mixed + * @return \ManiaControl\Callbacks\Structures\ShootMania\Models\Position */ public function getPosition() { return $this->position; } /** - * @param mixed $position + * @param \ManiaControl\Callbacks\Structures\ShootMania\Models\Position $position */ public function setPosition(Position $position) { $this->position = $position; diff --git a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php index 9b9d23b3..65a8e622 100644 --- a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php @@ -18,7 +18,7 @@ use ManiaControl\Players\Player; */ class OnCaptureStructure extends BaseStructure { - public $time; + private $time; private $landMark; private $playerArray = array(); @@ -44,23 +44,17 @@ class OnCaptureStructure extends BaseStructure { $this->landMark->setPosition($position); } - /** Dumps the Object with some Information */ - public function dump() { - var_dump($this->landMark); - parent::dump(); - } - /** - * Get the logins + * Get the logins as Array * - * @return array + * @return string[] */ public function getLoginArray() { return $this->playerArray; } /** - * Get the players + * Get the Players as Player Array * * @return Player[] */ @@ -76,16 +70,11 @@ class OnCaptureStructure extends BaseStructure { } /** - * @return LandMark + * Returns Information about the Captured Landmark + * + * @return \ManiaControl\Callbacks\Structures\ShootMania\Models\LandMark */ public function getLandMark() { return $this->landMark; } - - /** - * @param mixed $landMark - */ - public function setLandMark(Landmark $landMark) { - $this->landMark = $landMark; - } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnCommandStructure.php b/core/Callbacks/Structures/ShootMania/OnCommandStructure.php index 5140daaf..5a0a49a4 100644 --- a/core/Callbacks/Structures/ShootMania/OnCommandStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnCommandStructure.php @@ -14,9 +14,9 @@ use ManiaControl\ManiaControl; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnCommandStructure extends BaseStructure { - public $time; - public $name; - public $value; + private $time; + private $name; + private $value; public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); @@ -26,13 +26,9 @@ class OnCommandStructure extends BaseStructure { $this->value = $this->getPlainJsonObject()->value; } - /** Dumps the Object with some Information */ - public function dump() { - parent::dump(); - var_dump("With getShooter() you get a Player Object"); - } - /** + * < Server time when the event occured + * * @return int */ public function getTime() { @@ -40,14 +36,22 @@ class OnCommandStructure extends BaseStructure { } /** - * @return mixed + * < Name of the command + * + * @return string */ public function getName() { return $this->name; } /** - * @return \ManiaControl\Players\Player + * < 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; diff --git a/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php b/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php index 9675bb49..d3ac0d51 100644 --- a/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php @@ -14,8 +14,8 @@ use ManiaControl\ManiaControl; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnDefaultEventStructure extends BaseStructure { - public $time; - public $type; + private $time; + private $type; public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); @@ -25,6 +25,8 @@ class OnDefaultEventStructure extends BaseStructure { } /** + * Returns Server time when the event occured + * * @return int */ public function getTime() { @@ -32,6 +34,8 @@ class OnDefaultEventStructure extends BaseStructure { } /** + * Returns the type of event + * * @return string */ public function getType() { diff --git a/core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php b/core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php index c5bcc2d8..ee52c20f 100644 --- a/core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php @@ -15,7 +15,7 @@ use ManiaControl\Players\Player; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnFallDamageStructure extends BaseStructure { - public $time; + private $time; /** * @var Player $shooter */ @@ -29,6 +29,8 @@ class OnFallDamageStructure extends BaseStructure { } /** + * < Server time when the event occured + * * @return int */ public function getTime() { @@ -36,15 +38,12 @@ class OnFallDamageStructure extends BaseStructure { } /** + * < Player who fell + * * @return Player */ public function getVictim() { return $this->victim; } - /** Dumps the Object with some Information */ - public function dump() { - parent::dump(); - var_dump("With getVictim() you get a Player Object"); - } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php index 475ccef0..740e9c6b 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php @@ -17,15 +17,15 @@ use ManiaControl\Players\Player; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnHitNearMissArmorEmptyStructure extends BaseStructure { - public $time; - public $weapon; - public $damage; - public $distance = 0; //Note no distance on the OnHit and ArmorEmpty yet + private $time; + private $weapon; + private $damage; + private $distance = 0; //Note no distance on the OnHit and ArmorEmpty yet - private $shooterPosition; - private $victimPosition; - protected $shooter; - protected $victim; + private $shooterPosition; + private $victimPosition; + private $shooter; + private $victim; //private $shooterPoints; (was in mp3) //private $hitDistance; (was in mp3) @@ -43,7 +43,7 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { $jsonObj = $this->getPlainJsonObject(); $this->time = $jsonObj->time; $this->weapon = $jsonObj->weapon; - $this->damage = $jsonObj->damage; + $this->damage = $jsonObj->damage; //TODO does only exist on onhit -> make baseclass $this->shooterPosition = new Position(); $this->shooterPosition->setX($jsonObj->shooterposition->x); @@ -63,18 +63,9 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); } - /** Dumps the Object with some Information */ - public function dump() { - var_dump("Dump of property Shooter Position"); - var_dump($this->shooterPosition); - var_dump("Dump of property Victim Position"); - var_dump($this->victimPosition); - parent::dump(); - var_dump("With getShooter() you get a Player Object"); - var_dump("With getVictim() you get a Player Object"); - } - /** + * < Server time when the event occured + * * @return int */ public function getTime() { @@ -82,6 +73,9 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { } /** + * < Id of the weapon [1-Laser, 2-Rocket, 3-Nucleus, 5-Arrow] + * + * @see \ManiaControl\Callbacks\Structures\ShootMania\Models\Weapons * @return int */ public function getWeapon() { @@ -89,6 +83,9 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { } /** + * < Amount of Damage done by the hit (only on onHit) + * TODO base class and extend properties) + * * @return int */ public function getDamage() { @@ -96,7 +93,7 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { } /** - * TODO Position Object + * < Position of the Shooter at the time * * @return Position */ @@ -105,15 +102,17 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { } /** - * TODO Position Object + * < Position of the Victim at the time * - * @return Position + * @return \ManiaControl\Callbacks\Structures\ShootMania\Models\Position */ public function getVictimPosition() { return $this->victimPosition; } /** + * < Shooter Player + * * @return Player */ public function getShooter() { @@ -121,6 +120,8 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { } /** + * < Victim Player + * * @return Player */ public function getVictim() { diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php index ec086fe9..4419e9c5 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php @@ -15,9 +15,9 @@ use ManiaControl\Players\Player; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnPlayerRequestRespawnStructure extends BaseStructure { - public $time; + private $time; /** - * @var Player $shooter + * @var Player $player */ private $player; @@ -26,9 +26,13 @@ class OnPlayerRequestRespawnStructure extends BaseStructure { $this->time = $this->getPlainJsonObject()->time; $this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login); + + $this->getUsage(); } /** + * Returns the Time the Event Happened + * * @return int */ public function getTime() { @@ -36,15 +40,11 @@ class OnPlayerRequestRespawnStructure extends BaseStructure { } /** - * @return Player + * Gets the Player + * + * @return \ManiaControl\Players\Player */ public function getPlayer() { return $this->player; } - - /** Dumps the Object with some Information */ - public function dump() { - parent::dump(); - var_dump("With getPlayer() you get a Player Object"); - } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php index b6c043a2..5f171665 100644 --- a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php @@ -6,7 +6,6 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; use ManiaControl\Callbacks\Structures\BaseStructure; use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore; use ManiaControl\ManiaControl; -use ManiaControl\Players\Player; /** * Structure Class for the OnScores Structure Callback @@ -16,13 +15,13 @@ use ManiaControl\Players\Player; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnScoresStructure extends BaseStructure { - public $responseId; - public $section; - public $useTeams; - public $winnerTeam; - public $winnerPlayer; + private $responseId; + private $section; + private $useTeams; + private $winnerTeam; + private $winnerPlayer; private $teamScores = array(); - public $players; //TODO implement + private $players; //TODO implement //TODO test public function __construct(ManiaControl $maniaControl, $data) { @@ -51,36 +50,36 @@ class OnScoresStructure extends BaseStructure { //TODO implement player } - /** Dumps the Object with some Information */ - public function dump() { - parent::dump(); - var_dump("With getWinnerPlayer() you get a Player Object"); - var_dump($this->teamScores); - } - - /** - * @return Player + * Get the Winner Player Object + * + * @return \ManiaControl\Players\Player */ public function getWinnerPlayer() { return $this->winnerPlayer; } /** - * @return mixed + * Get the Response Id + * + * @return string */ public function getResponseId() { return $this->responseId; } /** - * @return mixed + * < 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() { @@ -88,13 +87,17 @@ class OnScoresStructure extends BaseStructure { } /** + * Get the Winner Team Id + * * @return int */ - public function getWinnerTeam() { + public function getWinnerTeamId() { return $this->winnerTeam; } /** + * Returns the TeamScores + * * @return TeamScore[] */ public function getTeamScores() { @@ -102,6 +105,8 @@ class OnScoresStructure extends BaseStructure { } /** + * Get The Player Scores + * * @return mixed */ public function getPlayers() { diff --git a/core/Callbacks/Structures/ShootMania/OnShootStructure.php b/core/Callbacks/Structures/ShootMania/OnShootStructure.php index 2b3b69c5..5735c268 100644 --- a/core/Callbacks/Structures/ShootMania/OnShootStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnShootStructure.php @@ -29,6 +29,7 @@ class OnShootStructure extends BaseStructure { $this->weapon = $this->getPlainJsonObject()->weapon; $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); + } /** diff --git a/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php b/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php index 6b496d9d..9b652f9c 100644 --- a/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php @@ -5,7 +5,6 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; use ManiaControl\Callbacks\Structures\BaseStructure; use ManiaControl\ManiaControl; -use ManiaControl\Players\Player; /** @@ -16,12 +15,12 @@ use ManiaControl\Players\Player; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnShotDenyStructure extends BaseStructure { - public $time; - public $shooterWeapon; - public $victimWeapon; + private $time; + private $shooterWeapon; + private $victimWeapon; - protected $shooter; - protected $victim; + private $shooter; + private $victim; /** * Construct a new On Hit Structure @@ -41,14 +40,9 @@ class OnShotDenyStructure extends BaseStructure { $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); } - /** Dumps the Object with some Information */ - public function dump() { - parent::dump(); - var_dump("With getShooter() you get a Player Object"); - var_dump("With getVictim() you get a Player Object"); - } - /** + * ServerTime The Event Happened //TODO add Trait for the Time Property + * * @return int */ public function getTime() { @@ -57,14 +51,18 @@ class OnShotDenyStructure extends BaseStructure { /** - * @return Player + * Gets the Shooter Player + * + * @return \ManiaControl\Players\Player */ public function getShooter() { return $this->shooter; } /** - * @return Player + * Gets the Victim Player + * + * @return \ManiaControl\Players\Player */ public function getVictim() { return $this->victim; @@ -78,7 +76,10 @@ class OnShotDenyStructure extends BaseStructure { } /** - * @return mixed + * Get the Victim Weapon + * + * @see \ManiaControl\Callbacks\Structures\ShootMania\Models\Weapons + * @return int */ public function getVictimWeapon() { return $this->victimWeapon; diff --git a/core/Callbacks/Structures/TrackMania/OnCommandStructure.php b/core/Callbacks/Structures/TrackMania/OnCommandStructure.php index dd8fc655..de56dd67 100644 --- a/core/Callbacks/Structures/TrackMania/OnCommandStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnCommandStructure.php @@ -14,9 +14,9 @@ use ManiaControl\ManiaControl; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnCommandStructure extends BaseStructure { - public $time; - public $name; - public $value; + private $time; + private $name; + private $value; public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); @@ -26,13 +26,9 @@ class OnCommandStructure extends BaseStructure { $this->value = $this->getPlainJsonObject()->value; } - /** Dumps the Object with some Information */ - public function dump() { - parent::dump(); - var_dump("With getShooter() you get a Player Object"); - } - /** + * < Server time when the event occured + * * @return int */ public function getTime() { @@ -40,18 +36,24 @@ class OnCommandStructure extends BaseStructure { } /** - * @return mixed + * < Name of the command + * + * @return string */ public function getName() { return $this->name; } /** - * @return \ManiaControl\Players\Player + * < 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; } - - } \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php b/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php index 0d4abec8..98a01331 100644 --- a/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php @@ -14,8 +14,8 @@ use ManiaControl\ManiaControl; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnDefaultEventStructure extends BaseStructure { - public $time; - public $type; + private $time; + private $type; public function __construct(ManiaControl $maniaControl, $data) { parent::__construct($maniaControl, $data); @@ -25,6 +25,8 @@ class OnDefaultEventStructure extends BaseStructure { } /** + * Returns Server time when the event occured + * * @return int */ public function getTime() { @@ -32,6 +34,8 @@ class OnDefaultEventStructure extends BaseStructure { } /** + * Returns the type of event + * * @return string */ public function getType() { diff --git a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index c37c3cc7..4c30bc5d 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -29,6 +29,8 @@ class CallbacksListStructure extends BaseStructure { $this->responseId = $this->getPlainJsonObject()->responseid; $this->callbacks = $this->getPlainJsonObject()->callbacks; + + $this->getUsage(); } /** From 46daaee61a28d34bba60326dc36478ff7f3a8431 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 12:56:44 +0200 Subject: [PATCH 33/73] added UsageInformationTrait / INterface + updated mindediversion --- core/Callbacks/Structures/BaseStructure.php | 39 +++--------------- .../XmlRpc/CallbacksListStructure.php | 12 +++--- core/General/DumpTrait.php | 12 +++--- core/General/Dumpable.php | 12 +++--- core/General/UsageInformationAble.php | 12 ++++++ core/General/UsageInformationTrait.php | 41 +++++++++++++++++++ core/ManiaControl.php | 8 +++- 7 files changed, 81 insertions(+), 55 deletions(-) create mode 100644 core/General/UsageInformationAble.php create mode 100644 core/General/UsageInformationTrait.php diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/BaseStructure.php index 7ee3b33a..4596c962 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/BaseStructure.php @@ -3,8 +3,9 @@ namespace ManiaControl\Callbacks\Structures; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; -use ReflectionClass; /** * Base Structure of all Callback Structures @@ -13,7 +14,9 @@ use ReflectionClass; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class BaseStructure { +abstract class BaseStructure implements UsageInformationAble { + use UsageInformationTrait; + /** @var ManiaControl $maniaControl */ protected $maniaControl; private $plainJsonObject; @@ -29,36 +32,4 @@ abstract class BaseStructure { public function getPlainJsonObject() { return $this->plainJsonObject; } - - /** - * Gets Information about the Class, and a List of the Public Method - */ - public function getUsage() { - $reflection = new ReflectionClass(get_class($this)); - echo $reflection->getDocComment(); - - echo "\nStructure Name of Class = " . get_class($this); - - echo "\nMethods:\n"; - - $metody = $reflection->getMethods(); - $methods = array_reverse($metody); - foreach ($methods as $key => $value) { - /** @var \ReflectionMethod $value */ - //Don't print the Constructor - if ($value->isPublic() && $value->getName() != "__construct" && $value->getName() != "getUsage") { - echo "\n\n"; - $txt = preg_replace('/\t/', '', $value->getDocComment()); - - echo $txt; - echo "\n \$result = " . $value->getName() . "();"; - $parameters = $value->getParameters(); - - foreach ($parameters as $parameter) { - echo "\n" . $parameter; - } - echo "\n"; - } - } - } } \ No newline at end of file diff --git a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index 4c30bc5d..0ca3788a 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -14,9 +14,9 @@ use ManiaControl\ManiaControl; */ class CallbacksListStructure extends BaseStructure { /** @var string $responseId */ - public $responseId; + private $responseId; /** @var array $callbacks */ - public $callbacks; + private $callbacks; /** * Construct a new Callbacks List Structure @@ -29,11 +29,11 @@ class CallbacksListStructure extends BaseStructure { $this->responseId = $this->getPlainJsonObject()->responseid; $this->callbacks = $this->getPlainJsonObject()->callbacks; - - $this->getUsage(); } /** + * Get the Response Id //TODO Trait for all Response Ids + * * @return string */ public function getResponseId() { @@ -41,7 +41,9 @@ class CallbacksListStructure extends BaseStructure { } /** - * @return array + * Get Array of the Callbacks + * + * @return string[] */ public function getCallbacks() { return $this->callbacks; diff --git a/core/General/DumpTrait.php b/core/General/DumpTrait.php index 72815407..242a08de 100644 --- a/core/General/DumpTrait.php +++ b/core/General/DumpTrait.php @@ -1,14 +1,12 @@ 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 + } +} \ No newline at end of file diff --git a/core/ManiaControl.php b/core/ManiaControl.php index d92deef7..fb572fa7 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -21,6 +21,8 @@ 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; @@ -44,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.200'; 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'; From 602ec5b7fc04aff71e7d91ab4f01b9bd69a75c4e Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 13:01:18 +0200 Subject: [PATCH 34/73] renamed the new usageinformation method --- core/General/UsageInformationAble.php | 2 +- core/General/UsageInformationTrait.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/General/UsageInformationAble.php b/core/General/UsageInformationAble.php index e819034d..80283fb0 100644 --- a/core/General/UsageInformationAble.php +++ b/core/General/UsageInformationAble.php @@ -8,5 +8,5 @@ namespace ManiaControl\General; * @package ManiaControl\General */ interface UsageInformationAble { - public function getUsage(); + public function getUsageInformation(); } \ No newline at end of file diff --git a/core/General/UsageInformationTrait.php b/core/General/UsageInformationTrait.php index 40a98260..35f577f3 100644 --- a/core/General/UsageInformationTrait.php +++ b/core/General/UsageInformationTrait.php @@ -13,7 +13,7 @@ trait UsageInformationTrait { /** * Gets Information about the Class, and a List of the Public Method */ - public function getUsage() { + public function getUsageInformation() { $reflection = new ReflectionClass(get_class($this)); echo $reflection->getDocComment(); From f2ab40a50f3f63c7ddde1eee59e7ae599f9abc15 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 13:11:30 +0200 Subject: [PATCH 35/73] moved scriptmanager --- core/Script/ScriptManager.php | 74 +++++++++++++++++++++++++++++++++++ core/Server/ScriptManager.php | 74 +---------------------------------- core/Server/Server.php | 5 ++- 3 files changed, 79 insertions(+), 74 deletions(-) create mode 100644 core/Script/ScriptManager.php diff --git a/core/Script/ScriptManager.php b/core/Script/ScriptManager.php new file mode 100644 index 00000000..a069943a --- /dev/null +++ b/core/Script/ScriptManager.php @@ -0,0 +1,74 @@ + + * @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() { + 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; + } +} diff --git a/core/Server/ScriptManager.php b/core/Server/ScriptManager.php index f980fe68..2c1a1117 100644 --- a/core/Server/ScriptManager.php +++ b/core/Server/ScriptManager.php @@ -1,74 +1,4 @@ - * @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() { - 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; - } -} diff --git a/core/Server/Server.php b/core/Server/Server.php index 6a4609d9..ad628f17 100644 --- a/core/Server/Server.php +++ b/core/Server/Server.php @@ -8,6 +8,7 @@ use ManiaControl\Commands\CommandListener; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; +use ManiaControl\Script\ScriptManager; use ManiaControl\Utils\CommandLineHelper; use Maniaplanet\DedicatedServer\Xmlrpc\Exception; @@ -56,7 +57,7 @@ class Server implements CallbackListener, CommandListener { * @see getRankingManager() */ public $rankingManager = null; - /** @var ScriptManager $scriptManager + /** @var \ManiaControl\Script\ScriptManager $scriptManager * @deprecated * @see getScriptManager() */ @@ -178,7 +179,7 @@ class Server implements CallbackListener, CommandListener { /** * Return the script manager * - * @return ScriptManager + * @return \ManiaControl\Script\ScriptManager */ public function getScriptManager() { return $this->scriptManager; From d46eb59fb99d51f5f17e45558fc53f77a6dede3c Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 13:58:23 +0200 Subject: [PATCH 36/73] added dedibuild to error and usage reporting --- ManiaControl.php | 2 +- core/ErrorHandler.php | 10 +- core/ManiaControl.php | 21 ++- core/Server/UsageReporter.php | 18 +-- plugins/MCTeam/KarmaPlugin.php | 241 ++++++++++++++++----------------- 5 files changed, 150 insertions(+), 142 deletions(-) diff --git a/ManiaControl.php b/ManiaControl.php index 0b4e7035..2fbfe8ae 100644 --- a/ManiaControl.php +++ b/ManiaControl.php @@ -11,7 +11,7 @@ error_reporting(E_ALL); // Run configuration -define('DEV_MODE', true); // Development mode to not send error reports etc. +define('DEV_MODE', false); // 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 diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index c63c91ac..44bfa519 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -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'; diff --git a/core/ManiaControl.php b/core/ManiaControl.php index fb572fa7..eb158f05 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -183,6 +183,8 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /** @var ModeScriptEventManager $modeScriptEventManager */ private $modeScriptEventManager = null; + private $dedicatedServerBuildVersion = ""; + /** * Construct a new ManiaControl instance */ @@ -216,7 +218,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, $this->pluginManager = new PluginManager($this); $this->updateManager = new UpdateManager($this); - $this->getErrorHandler()->init(); // Permissions @@ -565,6 +566,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, $this->requestQuitMessage = $message; } + /** * Run ManiaControl */ @@ -576,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 @@ -651,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 * diff --git a/core/Server/UsageReporter.php b/core/Server/UsageReporter.php index 72bdb0e0..88cb21aa 100644 --- a/core/Server/UsageReporter.php +++ b/core/Server/UsageReporter.php @@ -51,19 +51,21 @@ class UsageReporter implements TimerListener { return; } - $properties = array(); - $properties['ManiaControlVersion'] = ManiaControl::VERSION; - $properties['OperatingSystem'] = php_uname(); - $properties['PHPVersion'] = phpversion(); - $properties['ServerLogin'] = $this->maniaControl->getServer()->login; - $properties['TitleId'] = $this->maniaControl->getServer()->titleId; - $properties['ServerName'] = Formatter::stripDirtyCodes($this->maniaControl->getClient()->getServerName()); - $properties['UpdateChannel'] = $this->maniaControl->getUpdateManager()->getCurrentUpdateChannelSetting(); + $properties = array(); + $properties['ManiaControlVersion'] = ManiaControl::VERSION; + $properties['OperatingSystem'] = php_uname(); + $properties['PHPVersion'] = phpversion(); + $properties['ServerLogin'] = $this->maniaControl->getServer()->login; + $properties['TitleId'] = $this->maniaControl->getServer()->titleId; + $properties['ServerName'] = Formatter::stripDirtyCodes($this->maniaControl->getClient()->getServerName()); + $properties['UpdateChannel'] = $this->maniaControl->getUpdateManager()->getCurrentUpdateChannelSetting(); + $properties['DedicatedBuildVersion'] = $this->maniaControl->getDedicatedServerBuildVersion(); $properties['PlayerCount'] = $this->maniaControl->getPlayerManager()->getPlayerCount(); $properties['MemoryUsage'] = memory_get_usage(); $properties['MemoryPeakUsage'] = memory_get_peak_usage(); + $maxPlayers = $this->maniaControl->getClient()->getMaxPlayers(); $properties['MaxPlayers'] = $maxPlayers['CurrentValue']; diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index 7f78b334..1796a32f 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -69,7 +69,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { * Private properties */ /** @var ManiaControl $maniaControl */ - private $maniaControl = null; + private $maniaControl = null; private $updateManialink = false; /** @var ManiaLink $manialink */ private $manialink = null; @@ -229,8 +229,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { * Open a Mx Karma Session */ private function mxKarmaOpenSession() { - if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) - ) { + if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) { return; } @@ -253,26 +252,26 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $this->mxKarma['connectionInProgress'] = true; $this->maniaControl->getFileReader()->loadFile($query, function ($json, $error) use ($mxKarmaCode) { - $this->mxKarma['connectionInProgress'] = false; - if ($error) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error: ' . $error); - return; - } - $data = json_decode($json); - if (!$data) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $json, $data); - return; - } - if ($data->success) { - $this->mxKarma['session'] = $data->data; - $this->activateSession($mxKarmaCode); - } else { - Logger::logError("Error while authenticating on Mania-Exchange Karma"); - // TODO remove temp trigger - $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message); - $this->mxKarma['connectionInProgress'] = false; - } - }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); + $this->mxKarma['connectionInProgress'] = false; + if ($error) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error: ' . $error); + return; + } + $data = json_decode($json); + if (!$data) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $json, $data); + return; + } + if ($data->success) { + $this->mxKarma['session'] = $data->data; + $this->activateSession($mxKarmaCode); + } else { + Logger::logError("Error while authenticating on Mania-Exchange Karma"); + // TODO remove temp trigger + $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message); + $this->mxKarma['connectionInProgress'] = false; + } + }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); } /** @@ -288,32 +287,32 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $query .= '&activationHash=' . urlencode($hash); $this->maniaControl->getFileReader()->loadFile($query, function ($json, $error) use ($query) { - $this->mxKarma['connectionInProgress'] = false; - if ($error) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); - return; - } - $data = json_decode($json); - if (!$data) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); - return; - } - if ($data->success && $data->data->activated) { - Logger::log('Successfully authenticated on Mania-Exchange Karma'); + $this->mxKarma['connectionInProgress'] = false; + if ($error) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); + return; + } + $data = json_decode($json); + if (!$data) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); + return; + } + if ($data->success && $data->data->activated) { + Logger::log('Successfully authenticated on Mania-Exchange Karma'); - // Fetch the Mx Karma Votes - $this->getMxKarmaVotes(); - } else { - if ($data->data->message === 'invalid hash') { - $permission = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); - $this->maniaControl->getChat()->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission); - } else { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message, $query); - } - Logger::logError("Error while activating Mania-Exchange Karma Session: " . $data->data->message); - unset($this->mxKarma['session']); - } - }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); + // Fetch the Mx Karma Votes + $this->getMxKarmaVotes(); + } else { + if ($data->data->message === 'invalid hash') { + $permission = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); + $this->maniaControl->getChat()->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission); + } else { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message, $query); + } + Logger::logError("Error while activating Mania-Exchange Karma Session: " . $data->data->message); + unset($this->mxKarma['session']); + } + }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); } /** @@ -331,8 +330,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { * Fetch the mxKarmaVotes for the current map */ public function getMxKarmaVotes(Player $player = null) { - if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) - ) { + if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) { return; } @@ -370,47 +368,45 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } $content = json_encode($properties); - $this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json, - $error) use - ( - &$player - ) { - if ($error) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); - return; - } - $data = json_decode($json); - if (!$data) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); - return; - } + $this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json, $error) use ( + &$player + ) { + if ($error) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); + return; + } + $data = json_decode($json); + if (!$data) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); + return; + } - if ($data->success) { - // Fetch averages if it's for the whole server - if (!$player) { - $this->mxKarma['voteCount'] = $data->data->votecount; - $this->mxKarma['voteAverage'] = $data->data->voteaverage; - $this->mxKarma['modeVoteCount'] = $data->data->modevotecount; - $this->mxKarma['modeVoteAverage'] = $data->data->modevoteaverage; - } + if ($data->success) { + // Fetch averages if it's for the whole server + if (!$player) { + $this->mxKarma['voteCount'] = $data->data->votecount; + $this->mxKarma['voteAverage'] = $data->data->voteaverage; + $this->mxKarma['modeVoteCount'] = $data->data->modevotecount; + $this->mxKarma['modeVoteAverage'] = $data->data->modevoteaverage; + } - foreach ($data->data->votes as $votes) { - $this->mxKarma['votes'][$votes->login] = $votes->vote; - } + foreach ($data->data->votes as $votes) { + $this->mxKarma['votes'][$votes->login] = $votes->vote; + } - $this->updateManialink = true; - $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_KARMA_MXUPDATED, $this->mxKarma); - Logger::logInfo('MX-Karma Votes successfully fetched!'); - } else { - // Problem occurred - Logger::logError('Error while fetching votes: ' . $data->data->message); - if ($data->data->message === 'invalid session') { - unset($this->mxKarma['session']); - } else { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('fetch error', $data->data->message, self::MX_KARMA_GET_MAP_RATING, $this->mxKarma['session']); - } - } - }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); + $this->updateManialink = true; + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_KARMA_MXUPDATED, $this->mxKarma); + Logger::logInfo('MX-Karma Votes successfully fetched!'); + } else { + // Problem occurred + Logger::logError('Error while fetching votes: ' . $data->data->message); + if ($data->data->message === 'invalid session') { + unset($this->mxKarma['session']); + } else { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('fetch error', $data->data->message, self::MX_KARMA_GET_MAP_RATING, $this->mxKarma['session']); + } + } + }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); } /** @@ -487,29 +483,28 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $content = json_encode($properties); - $this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json, - $error) { - if ($error) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); - return; - } - $data = json_decode($json); - if (!$data) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); - return; - } - if ($data->success) { - Logger::logInfo('Votes successfully submitted!'); - } else { - // Problem occurred - Logger::logError("Error while updating votes: '{$data->data->message}'"); - if ($data->data->message === "invalid session") { - unset($this->mxKarma['session']); - } else { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('saving error', $data->data->message, self::MX_KARMA_SAVE_VOTES, $this->mxKarma['session']); - } - } - }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); + $this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json, $error) { + if ($error) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); + return; + } + $data = json_decode($json); + if (!$data) { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); + return; + } + if ($data->success) { + Logger::logInfo('Votes successfully submitted!'); + } else { + // Problem occurred + Logger::logError("Error while updating votes: '{$data->data->message}'"); + if ($data->data->message === "invalid session") { + unset($this->mxKarma['session']); + } else { + $this->maniaControl->getErrorHandler()->triggerDebugNotice('saving error', $data->data->message, self::MX_KARMA_SAVE_VOTES, $this->mxKarma['session']); + } + } + }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); } /** @@ -595,9 +590,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } // Calculate actual voting - $vote -= $voteLow; + $vote -= $voteLow; $voteHigh -= $voteLow; - $vote /= $voteHigh; + $vote /= $voteHigh; // Save vote $map = $this->maniaControl->getMapManager()->getCurrentMap(); @@ -754,13 +749,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $karmaSettingName = self::buildKarmaSettingName($serverLogin); switch ($setting->setting) { - case $karmaSettingName: - { + case $karmaSettingName: { $this->mxKarmaOpenSession(); break; } - case self::SETTING_WIDGET_ENABLE: - { + case self::SETTING_WIDGET_ENABLE: { if ($setting->value) { $this->updateManialink = true; $this->handle1Second(time()); @@ -803,8 +796,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $voteCount = $votes['count']; } - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) { // Build karma manialink $this->buildManialink(); @@ -893,7 +885,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $count = 0; while ($vote = $result->fetch_object()) { $votes[$vote->vote] = $vote; - $count += $vote->count; + $count += $vote->count; } $votes['count'] = $count; $result->free(); @@ -968,13 +960,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { * @param Map $map */ public function importMxKarmaVotes(Map $map) { - if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) - ) { + if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) { return; } - if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING) - ) { + if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING)) { return; } @@ -1039,8 +1029,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { * Save Mx Karma Votes at MapEnd */ public function sendMxKarmaVotes(Map $map) { - if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) - ) { + if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) { return; } From be99324441bc0fdd0ed5fd86685ba3975112492b Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 13:59:11 +0200 Subject: [PATCH 37/73] enabeled dev mode again --- ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ManiaControl.php b/ManiaControl.php index 2fbfe8ae..0b4e7035 100644 --- a/ManiaControl.php +++ b/ManiaControl.php @@ -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 From f83640179d15a2d2f71c1def3fbbcdca3bc597f9 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 19:44:55 +0200 Subject: [PATCH 38/73] add UsageInformation Interface to every class which can be used by Plugin Authors --- core/Admin/ActionsMenu.php | 9 ++- core/Admin/AdminLists.php | 6 +- core/Admin/AuthCommands.php | 6 +- core/Admin/AuthenticationManager.php | 6 +- core/Bills/BillManager.php | 6 +- core/Callbacks/CallbackManager.php | 6 +- core/Callbacks/EchoManager.php | 6 +- core/Callbacks/Listening.php | 9 ++- core/Callbacks/TimerListening.php | 17 +++-- core/Callbacks/TimerManager.php | 6 +- core/Chat.php | 6 +- core/Commands/CommandManager.php | 8 +- core/Communication/Communication.php | 2 +- core/Communication/CommunicationManager.php | 9 ++- core/Files/AsyncHttpRequest.php | 7 +- core/Files/AsynchronousFileReader.php | 6 +- core/Logger.php | 5 +- core/ManiaExchange/ManiaExchangeManager.php | 6 +- core/ManiaExchange/ManiaExchangeMapSearch.php | 11 ++- core/Manialinks/CustomUIManager.php | 6 +- core/Manialinks/IconManager.php | 6 +- core/Manialinks/ManialinkManager.php | 6 +- core/Manialinks/StyleManager.php | 9 ++- core/Maps/Map.php | 6 +- core/Maps/MapActions.php | 6 +- core/Maps/MapManager.php | 8 +- core/Maps/MapQueue.php | 6 +- core/Players/Player.php | 8 +- core/Players/PlayerActions.php | 6 +- core/Players/PlayerDataManager.php | 20 +++-- core/Players/PlayerManager.php | 6 +- core/Script/ModeScriptEventManager.php | 14 +++- core/Script/ScriptManager.php | 6 +- core/Server/Directory.php | 6 +- core/Server/RankingManager.php | 6 +- core/Server/Server.php | 6 +- core/Server/VoteRatiosMenu.php | 2 +- core/Settings/Setting.php | 30 ++++---- core/Settings/SettingManager.php | 6 +- core/Statistics/StatisticManager.php | 6 +- core/Utils/ColorUtil.php | 10 ++- core/Utils/CommandLineHelper.php | 10 ++- core/Utils/Formatter.php | 73 ++++++++++++------- core/Utils/WebReader.php | 13 ++-- 44 files changed, 300 insertions(+), 118 deletions(-) diff --git a/core/Admin/ActionsMenu.php b/core/Admin/ActionsMenu.php index ead9b954..7b6fbd90 100644 --- a/core/Admin/ActionsMenu.php +++ b/core/Admin/ActionsMenu.php @@ -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; } diff --git a/core/Admin/AdminLists.php b/core/Admin/AdminLists.php index e2b2df6f..d035ec3d 100644 --- a/core/Admin/AdminLists.php +++ b/core/Admin/AdminLists.php @@ -13,6 +13,8 @@ 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; @@ -25,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 */ diff --git a/core/Admin/AuthCommands.php b/core/Admin/AuthCommands.php index caa9354c..49618967 100644 --- a/core/Admin/AuthCommands.php +++ b/core/Admin/AuthCommands.php @@ -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 */ diff --git a/core/Admin/AuthenticationManager.php b/core/Admin/AuthenticationManager.php index 8b7094c5..343d4417 100644 --- a/core/Admin/AuthenticationManager.php +++ b/core/Admin/AuthenticationManager.php @@ -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 */ diff --git a/core/Bills/BillManager.php b/core/Bills/BillManager.php index 6113acaf..1bbe9d7c 100644 --- a/core/Bills/BillManager.php +++ b/core/Bills/BillManager.php @@ -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 */ diff --git a/core/Callbacks/CallbackManager.php b/core/Callbacks/CallbackManager.php index e8ac4295..023dd85f 100644 --- a/core/Callbacks/CallbackManager.php +++ b/core/Callbacks/CallbackManager.php @@ -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 */ diff --git a/core/Callbacks/EchoManager.php b/core/Callbacks/EchoManager.php index 49af62db..841120d2 100644 --- a/core/Callbacks/EchoManager.php +++ b/core/Callbacks/EchoManager.php @@ -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 */ diff --git a/core/Callbacks/Listening.php b/core/Callbacks/Listening.php index ab56e5ff..09f0668b 100644 --- a/core/Callbacks/Listening.php +++ b/core/Callbacks/Listening.php @@ -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 diff --git a/core/Callbacks/TimerListening.php b/core/Callbacks/TimerListening.php index 19ba27d3..539e00ae 100644 --- a/core/Callbacks/TimerListening.php +++ b/core/Callbacks/TimerListening.php @@ -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); } diff --git a/core/Callbacks/TimerManager.php b/core/Callbacks/TimerManager.php index 6abea5b1..a33984d5 100644 --- a/core/Callbacks/TimerManager.php +++ b/core/Callbacks/TimerManager.php @@ -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 */ diff --git a/core/Chat.php b/core/Chat.php index e023df79..f50e542c 100644 --- a/core/Chat.php +++ b/core/Chat.php @@ -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 */ diff --git a/core/Commands/CommandManager.php b/core/Commands/CommandManager.php index 49ab7faf..9cb27c53 100644 --- a/core/Commands/CommandManager.php +++ b/core/Commands/CommandManager.php @@ -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]; } } diff --git a/core/Communication/Communication.php b/core/Communication/Communication.php index c9e228ab..76b20b33 100644 --- a/core/Communication/Communication.php +++ b/core/Communication/Communication.php @@ -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 * @copyright 2014-2017 ManiaControl Team diff --git a/core/Communication/CommunicationManager.php b/core/Communication/CommunicationManager.php index c26ab919..cf59cfe0 100644 --- a/core/Communication/CommunicationManager.php +++ b/core/Communication/CommunicationManager.php @@ -1,9 +1,12 @@ 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]; diff --git a/core/Files/AsyncHttpRequest.php b/core/Files/AsyncHttpRequest.php index e0fd3268..0826a234 100644 --- a/core/Files/AsyncHttpRequest.php +++ b/core/Files/AsyncHttpRequest.php @@ -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,7 +15,8 @@ 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 */ @@ -183,7 +186,7 @@ class AsyncHttpRequest { * @return $this */ public function setHeaders($headers) { - if(is_array($headers)){ + if (is_array($headers)) { $this->headers = $headers; } return $this; diff --git a/core/Files/AsynchronousFileReader.php b/core/Files/AsynchronousFileReader.php index a671df32..712077df 100644 --- a/core/Files/AsynchronousFileReader.php +++ b/core/Files/AsynchronousFileReader.php @@ -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 */ diff --git a/core/Logger.php b/core/Logger.php index a915d4f0..ac9f8006 100644 --- a/core/Logger.php +++ b/core/Logger.php @@ -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 diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index 6743289a..d7e78d06 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -3,6 +3,8 @@ namespace ManiaControl\ManiaExchange; use ManiaControl\Files\AsynchronousFileReader; +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 diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index a37f311c..a2ccd979 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -1,7 +1,10 @@ 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, ManiaExchangeManager::SETTING_MX_KEY)) { $this->url .= "&key=" . $key; } @@ -228,7 +233,7 @@ class ManiaExchangeMapSearch { } $mxMapList = $mxMapList->results; - + if ($mxMapList === null) { trigger_error('Cannot decode searched JSON data'); return; diff --git a/core/Manialinks/CustomUIManager.php b/core/Manialinks/CustomUIManager.php index 959ed128..5f310030 100644 --- a/core/Manialinks/CustomUIManager.php +++ b/core/Manialinks/CustomUIManager.php @@ -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 */ diff --git a/core/Manialinks/IconManager.php b/core/Manialinks/IconManager.php index cfdea67e..2ec6e99c 100644 --- a/core/Manialinks/IconManager.php +++ b/core/Manialinks/IconManager.php @@ -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 */ diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 0de72303..c90cfcfb 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -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,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 ManialinkManager implements ManialinkPageAnswerListener, CallbackListener { +class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index bcfa9378..e936733e 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -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,8 +166,7 @@ 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); } diff --git a/core/Maps/Map.php b/core/Maps/Map.php index f1215e7a..28c6a8b8 100644 --- a/core/Maps/Map.php +++ b/core/Maps/Map.php @@ -4,6 +4,8 @@ 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; @@ -14,8 +16,8 @@ use ManiaControl\Utils\Formatter; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Map implements Dumpable { - use DumpTrait; +class Map implements Dumpable, UsageInformationAble { + use DumpTrait, UsageInformationTrait; /* * Public properties diff --git a/core/Maps/MapActions.php b/core/Maps/MapActions.php index 8e537cad..d7c40d3a 100644 --- a/core/Maps/MapActions.php +++ b/core/Maps/MapActions.php @@ -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 */ diff --git a/core/Maps/MapManager.php b/core/Maps/MapManager.php index 652f345b..cf331d33 100644 --- a/core/Maps/MapManager.php +++ b/core/Maps/MapManager.php @@ -10,6 +10,8 @@ use ManiaControl\Communication\CommunicationAnswer; use ManiaControl\Communication\CommunicationListener; use ManiaControl\Communication\CommunicationMethods; use ManiaControl\Files\FileUtil; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\ManiaExchange\ManiaExchangeList; @@ -33,7 +35,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 */ @@ -427,7 +431,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; } diff --git a/core/Maps/MapQueue.php b/core/Maps/MapQueue.php index 2958c218..5f0eceb0 100644 --- a/core/Maps/MapQueue.php +++ b/core/Maps/MapQueue.php @@ -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 */ diff --git a/core/Players/Player.php b/core/Players/Player.php index 77767131..3460dc16 100644 --- a/core/Players/Player.php +++ b/core/Players/Player.php @@ -4,6 +4,8 @@ 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; @@ -16,8 +18,8 @@ use Maniaplanet\DedicatedServer\Structures\LadderStats; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Player implements Dumpable { - use DumpTrait; +class Player implements Dumpable, UsageInformationAble { + use DumpTrait, UsageInformationTrait; /* * Public Properties @@ -349,7 +351,7 @@ class Player implements Dumpable { } return false; } - + /** * Var_Dump the Players Cache */ diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index b6e9f5cb..98af0152 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -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 */ diff --git a/core/Players/PlayerDataManager.php b/core/Players/PlayerDataManager.php index 4673c29b..cff16b90 100644 --- a/core/Players/PlayerDataManager.php +++ b/core/Players/PlayerDataManager.php @@ -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); diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 82277dde..f8ab429d 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -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 */ diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index 3644c685..898d541f 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -6,11 +6,16 @@ * @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 { +class ModeScriptEventManager implements UsageInformationAble { + use UsageInformationTrait; + const API_VERSION = "2.0.0"; /** @var ManiaControl $maniaControl */ @@ -49,19 +54,20 @@ class ModeScriptEventManager { * @param string $responseId * Triggers a Callback List Callback */ - public function getCallbacksList($responseId = "DefaultResponseId"){ + public function getCallbacksList($responseId = "DefaultResponseId") { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList', array($responseId)); } /** * Sets the Api Version + * * @param string $version */ - public function setApiVersion($version = self::API_VERSION){ + public function setApiVersion($version = self::API_VERSION) { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.SetApiVersion', array($version)); } - public function getAllApiVersions($responseId = "DefaultResponseId"){ + public function getAllApiVersions($responseId = "DefaultResponseId") { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetAllApiVersions', array($responseId)); } } \ No newline at end of file diff --git a/core/Script/ScriptManager.php b/core/Script/ScriptManager.php index a069943a..9619d66f 100644 --- a/core/Script/ScriptManager.php +++ b/core/Script/ScriptManager.php @@ -2,6 +2,8 @@ namespace ManiaControl\Script; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; @@ -13,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 ScriptManager { +class ScriptManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ diff --git a/core/Server/Directory.php b/core/Server/Directory.php index bdb3cc59..29a48b4b 100644 --- a/core/Server/Directory.php +++ b/core/Server/Directory.php @@ -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 */ diff --git a/core/Server/RankingManager.php b/core/Server/RankingManager.php index 8ff4f22a..de6123b3 100644 --- a/core/Server/RankingManager.php +++ b/core/Server/RankingManager.php @@ -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 */ diff --git a/core/Server/Server.php b/core/Server/Server.php index ad628f17..eddbaf5a 100644 --- a/core/Server/Server.php +++ b/core/Server/Server.php @@ -5,6 +5,8 @@ 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; @@ -19,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 */ diff --git a/core/Server/VoteRatiosMenu.php b/core/Server/VoteRatiosMenu.php index 7c85698c..2d0a8ffc 100644 --- a/core/Server/VoteRatiosMenu.php +++ b/core/Server/VoteRatiosMenu.php @@ -118,7 +118,7 @@ class VoteRatiosMenu implements CallbackListener, ConfiguratorMenu, TimerListene } /** - * @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_VOTE_RATIOS) diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index b56c3749..4677933d 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -2,6 +2,8 @@ namespace ManiaControl\Settings; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Utils\ClassUtil; /** @@ -11,7 +13,9 @@ use ManiaControl\Utils\ClassUtil; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Setting { +class Setting implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ @@ -26,13 +30,13 @@ class Setting { /* * Public properties */ - public $index = null; - public $class = null; - public $setting = null; - public $type = null; - public $value = null; - public $default = null; - public $set = null; + public $index = null; + public $class = null; + public $setting = null; + public $type = null; + public $value = null; + public $default = null; + public $set = null; public $fetchTime = null; /** @@ -54,7 +58,7 @@ class Setting { } else { // Created by Values $this->class = ClassUtil::getClass($object); - $this->setting = (string)$settingName; + $this->setting = (string) $settingName; $this->type = self::getValueType($defaultValue); if ($this->type === self::TYPE_SET) { // Save Set and use first Value as Default @@ -79,16 +83,16 @@ class Setting { $type = self::getValueType($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_SET) { return explode(self::VALUE_DELIMITER, $value); diff --git a/core/Settings/SettingManager.php b/core/Settings/SettingManager.php index ba53cbd2..3aa63552 100644 --- a/core/Settings/SettingManager.php +++ b/core/Settings/SettingManager.php @@ -4,6 +4,8 @@ namespace ManiaControl\Settings; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Plugins\PluginManager; use ManiaControl\Utils\ClassUtil; @@ -15,7 +17,9 @@ use ManiaControl\Utils\ClassUtil; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class SettingManager implements CallbackListener { +class SettingManager implements CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Statistics/StatisticManager.php b/core/Statistics/StatisticManager.php index e2759a57..034c41f6 100644 --- a/core/Statistics/StatisticManager.php +++ b/core/Statistics/StatisticManager.php @@ -2,6 +2,8 @@ namespace ManiaControl\Statistics; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; @@ -12,7 +14,9 @@ use ManiaControl\Players\Player; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class StatisticManager { +class StatisticManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Utils/ColorUtil.php b/core/Utils/ColorUtil.php index 5e607f6f..d6e8d458 100644 --- a/core/Utils/ColorUtil.php +++ b/core/Utils/ColorUtil.php @@ -2,6 +2,9 @@ namespace ManiaControl\Utils; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + /** * Utility Class offering Methods to convert and use ManiaPlanet Colors * @@ -9,7 +12,8 @@ namespace ManiaControl\Utils; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class ColorUtil { +abstract class ColorUtil implements UsageInformationAble { + use UsageInformationTrait; /** * Convert the given float value to a color code from red to green @@ -47,9 +51,9 @@ abstract class ColorUtil { $value = 1.; } $value *= 15.; - $value = (int)round($value); + $value = (int) round($value); if ($value < 10) { - return (string)$value; + return (string) $value; } $codes = array(10 => 'a', 11 => 'b', 12 => 'c', 13 => 'd', 14 => 'e', 15 => 'f'); return $codes[$value]; diff --git a/core/Utils/CommandLineHelper.php b/core/Utils/CommandLineHelper.php index c0bc0eb1..ded80d00 100644 --- a/core/Utils/CommandLineHelper.php +++ b/core/Utils/CommandLineHelper.php @@ -2,6 +2,9 @@ namespace ManiaControl\Utils; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + /** * Command Line Helper Class * @@ -9,7 +12,8 @@ namespace ManiaControl\Utils; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CommandLineHelper { +class CommandLineHelper implements UsageInformationAble { + use UsageInformationTrait; /** * Get the command line parameter value with the given name @@ -18,7 +22,7 @@ class CommandLineHelper { * @return string */ public static function getParameter($paramName) { - $paramName = (string)$paramName; + $paramName = (string) $paramName; $params = self::getAllParameters(); foreach ($params as $param) { $parts = explode('=', $param, 2); @@ -40,6 +44,6 @@ class CommandLineHelper { */ public static function getAllParameters() { global $argv; - return (array)$argv; + return (array) $argv; } } diff --git a/core/Utils/Formatter.php b/core/Utils/Formatter.php index a5e70f62..35d36d4a 100644 --- a/core/Utils/Formatter.php +++ b/core/Utils/Formatter.php @@ -2,6 +2,8 @@ namespace ManiaControl\Utils; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; /** @@ -11,7 +13,8 @@ use ManiaControl\Logger; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class Formatter { +abstract class Formatter implements UsageInformationAble { + use UsageInformationTrait; /** * Return the given Text with Escaping around it @@ -31,47 +34,42 @@ abstract class Formatter { */ public static function formatTime($time) { // TODO: use gmdate() - $time = (int)$time; + $time = (int) $time; $milliseconds = $time % 1000; $seconds = floor($time / 1000); $minutes = floor($seconds / 60); $hours = floor($minutes / 60); - $minutes -= $hours * 60; - $seconds -= $hours * 60 + $minutes * 60; - $format = ($hours > 0 ? $hours . ':' : ''); - $format .= ($hours > 0 && $minutes < 10 ? '0' : '') . $minutes . ':'; - $format .= ($seconds < 10 ? '0' : '') . $seconds . ':'; - $format .= ($milliseconds < 100 ? '0' : '') . ($milliseconds < 10 ? '0' : '') . $milliseconds; + $minutes -= $hours * 60; + $seconds -= $hours * 60 + $minutes * 60; + $format = ($hours > 0 ? $hours . ':' : ''); + $format .= ($hours > 0 && $minutes < 10 ? '0' : '') . $minutes . ':'; + $format .= ($seconds < 10 ? '0' : '') . $seconds . ':'; + $format .= ($milliseconds < 100 ? '0' : '') . ($milliseconds < 10 ? '0' : '') . $milliseconds; return $format; } /** * Format an elapsed time String (2 days ago...) by a given timestamp * - * @param int $time Input time + * @param int $time Input time * @param boolean $short Short version * @return string Formatted elapsed time string */ public static function timeElapsedString($time, $short = false) { $elapsedTime = time() - $time; - $second = $short ? 'sec.' : 'second'; - $minute = $short ? 'min.' : 'minute'; - $hour = $short ? 'h' : 'hour'; - $day = $short ? 'd' : 'day'; - $month = $short ? 'm' : 'month'; - $year = $short ? 'y' : 'year'; + $second = $short ? 'sec.' : 'second'; + $minute = $short ? 'min.' : 'minute'; + $hour = $short ? 'h' : 'hour'; + $day = $short ? 'd' : 'day'; + $month = $short ? 'm' : 'month'; + $year = $short ? 'y' : 'year'; if ($elapsedTime < 1) { return $short ? '0 sec.' : '0 seconds'; } - $calculateSeconds = array(12 * 30 * 24 * 60 * 60 => $year, - 30 * 24 * 60 * 60 => $month, - 24 * 60 * 60 => $day, - 60 * 60 => $hour, - 60 => $minute, - 1 => $second); + $calculateSeconds = array(12 * 30 * 24 * 60 * 60 => $year, 30 * 24 * 60 * 60 => $month, 24 * 60 * 60 => $day, 60 * 60 => $hour, 60 => $minute, 1 => $second); foreach ($calculateSeconds as $secs => $str) { $d = $elapsedTime / $secs; @@ -159,10 +157,35 @@ abstract class Formatter { * @return string */ public static function mapCountry($country) { - $nations = array('Afghanistan' => 'AFG', 'Albania' => 'ALB', 'Algeria' => 'ALG', 'Andorra' => 'AND', 'Angola' => 'ANG', 'Argentina' => 'ARG', 'Armenia' => 'ARM', 'Aruba' => 'ARU', 'Australia' => 'AUS', 'Austria' => 'AUT', 'Azerbaijan' => 'AZE', 'Bahamas' => 'BAH', 'Bahrain' => 'BRN', 'Bangladesh' => 'BAN', 'Barbados' => 'BAR', 'Belarus' => 'BLR', 'Belgium' => 'BEL', 'Belize' => 'BIZ', 'Benin' => 'BEN', 'Bermuda' => 'BER', 'Bhutan' => 'BHU', 'Bolivia' => 'BOL', 'Bosnia&Herzegovina' => 'BIH', 'Botswana' => 'BOT', 'Brazil' => 'BRA', 'Brunei' => 'BRU', 'Bulgaria' => 'BUL', 'Burkina Faso' => 'BUR', 'Burundi' => 'BDI', 'Cambodia' => 'CAM', 'Cameroon' => 'CAR', // actually CMR - 'Canada' => 'CAN', 'Cape Verde' => 'CPV', 'Central African Republic' => 'CAF', 'Chad' => 'CHA', 'Chile' => 'CHI', 'China' => 'CHN', 'Chinese Taipei' => 'TPE', 'Colombia' => 'COL', 'Congo' => 'CGO', 'Costa Rica' => 'CRC', 'Croatia' => 'CRO', 'Cuba' => 'CUB', 'Cyprus' => 'CYP', 'Czech Republic' => 'CZE', 'Czech republic' => 'CZE', 'DR Congo' => 'COD', 'Denmark' => 'DEN', 'Djibouti' => 'DJI', 'Dominica' => 'DMA', 'Dominican Republic' => 'DOM', 'Ecuador' => 'ECU', 'Egypt' => 'EGY', 'El Salvador' => 'ESA', 'Eritrea' => 'ERI', 'Estonia' => 'EST', 'Ethiopia' => 'ETH', 'Fiji' => 'FIJ', 'Finland' => 'FIN', 'France' => 'FRA', 'Gabon' => 'GAB', 'Gambia' => 'GAM', 'Georgia' => 'GEO', 'Germany' => 'GER', 'Ghana' => 'GHA', 'Greece' => 'GRE', 'Grenada' => 'GRN', 'Guam' => 'GUM', 'Guatemala' => 'GUA', 'Guinea' => 'GUI', 'Guinea-Bissau' => 'GBS', 'Guyana' => 'GUY', 'Haiti' => 'HAI', 'Honduras' => 'HON', 'Hong Kong' => 'HKG', 'Hungary' => 'HUN', 'Iceland' => 'ISL', 'India' => 'IND', 'Indonesia' => 'INA', 'Iran' => 'IRI', 'Iraq' => 'IRQ', 'Ireland' => 'IRL', 'Israel' => 'ISR', 'Italy' => 'ITA', 'Ivory Coast' => 'CIV', 'Jamaica' => 'JAM', 'Japan' => 'JPN', 'Jordan' => 'JOR', 'Kazakhstan' => 'KAZ', 'Kenya' => 'KEN', 'Kiribati' => 'KIR', 'Korea' => 'KOR', 'Kuwait' => 'KUW', 'Kyrgyzstan' => 'KGZ', 'Laos' => 'LAO', 'Latvia' => 'LAT', 'Lebanon' => 'LIB', 'Lesotho' => 'LES', 'Liberia' => 'LBR', 'Libya' => 'LBA', 'Liechtenstein' => 'LIE', 'Lithuania' => 'LTU', 'Luxembourg' => 'LUX', 'Macedonia' => 'MKD', 'Malawi' => 'MAW', 'Malaysia' => 'MAS', 'Mali' => 'MLI', 'Malta' => 'MLT', 'Mauritania' => 'MTN', 'Mauritius' => 'MRI', 'Mexico' => 'MEX', 'Moldova' => 'MDA', 'Monaco' => 'MON', 'Mongolia' => 'MGL', 'Montenegro' => 'MNE', 'Morocco' => 'MAR', 'Mozambique' => 'MOZ', 'Myanmar' => 'MYA', 'Namibia' => 'NAM', 'Nauru' => 'NRU', 'Nepal' => 'NEP', 'Netherlands' => 'NED', 'New Zealand' => 'NZL', 'Nicaragua' => 'NCA', 'Niger' => 'NIG', 'Nigeria' => 'NGR', 'Norway' => 'NOR', 'Oman' => 'OMA', 'Other Countries' => 'OTH', 'Pakistan' => 'PAK', 'Palau' => 'PLW', 'Palestine' => 'PLE', 'Panama' => 'PAN', 'Paraguay' => 'PAR', 'Peru' => 'PER', 'Philippines' => 'PHI', 'Poland' => 'POL', 'Portugal' => 'POR', 'Puerto Rico' => 'PUR', 'Qatar' => 'QAT', 'Romania' => 'ROM', // actually ROU - 'Russia' => 'RUS', 'Rwanda' => 'RWA', 'Samoa' => 'SAM', 'San Marino' => 'SMR', 'Saudi Arabia' => 'KSA', 'Senegal' => 'SEN', 'Serbia' => 'SCG', // actually SRB - 'Sierra Leone' => 'SLE', 'Singapore' => 'SIN', 'Slovakia' => 'SVK', 'Slovenia' => 'SLO', 'Somalia' => 'SOM', 'South Africa' => 'RSA', 'Spain' => 'ESP', 'Sri Lanka' => 'SRI', 'Sudan' => 'SUD', 'Suriname' => 'SUR', 'Swaziland' => 'SWZ', 'Sweden' => 'SWE', 'Switzerland' => 'SUI', 'Syria' => 'SYR', 'Taiwan' => 'TWN', 'Tajikistan' => 'TJK', 'Tanzania' => 'TAN', 'Thailand' => 'THA', 'Togo' => 'TOG', 'Tonga' => 'TGA', 'Trinidad and Tobago' => 'TRI', 'Tunisia' => 'TUN', 'Turkey' => 'TUR', 'Turkmenistan' => 'TKM', 'Tuvalu' => 'TUV', 'Uganda' => 'UGA', 'Ukraine' => 'UKR', 'United Arab Emirates' => 'UAE', 'United Kingdom' => 'GBR', 'United States of America' => 'USA', 'Uruguay' => 'URU', 'Uzbekistan' => 'UZB', 'Vanuatu' => 'VAN', 'Venezuela' => 'VEN', 'Vietnam' => 'VIE', 'Yemen' => 'YEM', 'Zambia' => 'ZAM', 'Zimbabwe' => 'ZIM'); + $nations = array('Afghanistan' => 'AFG', 'Albania' => 'ALB', 'Algeria' => 'ALG', 'Andorra' => 'AND', 'Angola' => 'ANG', 'Argentina' => 'ARG', 'Armenia' => 'ARM', 'Aruba' => 'ARU', + 'Australia' => 'AUS', 'Austria' => 'AUT', 'Azerbaijan' => 'AZE', 'Bahamas' => 'BAH', 'Bahrain' => 'BRN', 'Bangladesh' => 'BAN', 'Barbados' => 'BAR', + 'Belarus' => 'BLR', 'Belgium' => 'BEL', 'Belize' => 'BIZ', 'Benin' => 'BEN', 'Bermuda' => 'BER', 'Bhutan' => 'BHU', 'Bolivia' => 'BOL', + 'Bosnia&Herzegovina' => 'BIH', 'Botswana' => 'BOT', 'Brazil' => 'BRA', 'Brunei' => 'BRU', 'Bulgaria' => 'BUL', 'Burkina Faso' => 'BUR', 'Burundi' => 'BDI', + 'Cambodia' => 'CAM', 'Cameroon' => 'CAR', // actually CMR + 'Canada' => 'CAN', 'Cape Verde' => 'CPV', 'Central African Republic' => 'CAF', 'Chad' => 'CHA', 'Chile' => 'CHI', 'China' => 'CHN', + 'Chinese Taipei' => 'TPE', 'Colombia' => 'COL', 'Congo' => 'CGO', 'Costa Rica' => 'CRC', 'Croatia' => 'CRO', 'Cuba' => 'CUB', 'Cyprus' => 'CYP', + 'Czech Republic' => 'CZE', 'Czech republic' => 'CZE', 'DR Congo' => 'COD', 'Denmark' => 'DEN', 'Djibouti' => 'DJI', 'Dominica' => 'DMA', + 'Dominican Republic' => 'DOM', 'Ecuador' => 'ECU', 'Egypt' => 'EGY', 'El Salvador' => 'ESA', 'Eritrea' => 'ERI', 'Estonia' => 'EST', 'Ethiopia' => 'ETH', + 'Fiji' => 'FIJ', 'Finland' => 'FIN', 'France' => 'FRA', 'Gabon' => 'GAB', 'Gambia' => 'GAM', 'Georgia' => 'GEO', 'Germany' => 'GER', 'Ghana' => 'GHA', + 'Greece' => 'GRE', 'Grenada' => 'GRN', 'Guam' => 'GUM', 'Guatemala' => 'GUA', 'Guinea' => 'GUI', 'Guinea-Bissau' => 'GBS', 'Guyana' => 'GUY', + 'Haiti' => 'HAI', 'Honduras' => 'HON', 'Hong Kong' => 'HKG', 'Hungary' => 'HUN', 'Iceland' => 'ISL', 'India' => 'IND', 'Indonesia' => 'INA', + 'Iran' => 'IRI', 'Iraq' => 'IRQ', 'Ireland' => 'IRL', 'Israel' => 'ISR', 'Italy' => 'ITA', 'Ivory Coast' => 'CIV', 'Jamaica' => 'JAM', 'Japan' => 'JPN', + 'Jordan' => 'JOR', 'Kazakhstan' => 'KAZ', 'Kenya' => 'KEN', 'Kiribati' => 'KIR', 'Korea' => 'KOR', 'Kuwait' => 'KUW', 'Kyrgyzstan' => 'KGZ', 'Laos' => 'LAO', + 'Latvia' => 'LAT', 'Lebanon' => 'LIB', 'Lesotho' => 'LES', 'Liberia' => 'LBR', 'Libya' => 'LBA', 'Liechtenstein' => 'LIE', 'Lithuania' => 'LTU', + 'Luxembourg' => 'LUX', 'Macedonia' => 'MKD', 'Malawi' => 'MAW', 'Malaysia' => 'MAS', 'Mali' => 'MLI', 'Malta' => 'MLT', 'Mauritania' => 'MTN', + 'Mauritius' => 'MRI', 'Mexico' => 'MEX', 'Moldova' => 'MDA', 'Monaco' => 'MON', 'Mongolia' => 'MGL', 'Montenegro' => 'MNE', 'Morocco' => 'MAR', + 'Mozambique' => 'MOZ', 'Myanmar' => 'MYA', 'Namibia' => 'NAM', 'Nauru' => 'NRU', 'Nepal' => 'NEP', 'Netherlands' => 'NED', 'New Zealand' => 'NZL', + 'Nicaragua' => 'NCA', 'Niger' => 'NIG', 'Nigeria' => 'NGR', 'Norway' => 'NOR', 'Oman' => 'OMA', 'Other Countries' => 'OTH', 'Pakistan' => 'PAK', + 'Palau' => 'PLW', 'Palestine' => 'PLE', 'Panama' => 'PAN', 'Paraguay' => 'PAR', 'Peru' => 'PER', 'Philippines' => 'PHI', 'Poland' => 'POL', + 'Portugal' => 'POR', 'Puerto Rico' => 'PUR', 'Qatar' => 'QAT', 'Romania' => 'ROM', // actually ROU + 'Russia' => 'RUS', 'Rwanda' => 'RWA', 'Samoa' => 'SAM', 'San Marino' => 'SMR', 'Saudi Arabia' => 'KSA', 'Senegal' => 'SEN', 'Serbia' => 'SCG', + // actually SRB + 'Sierra Leone' => 'SLE', 'Singapore' => 'SIN', 'Slovakia' => 'SVK', 'Slovenia' => 'SLO', 'Somalia' => 'SOM', 'South Africa' => 'RSA', 'Spain' => 'ESP', + 'Sri Lanka' => 'SRI', 'Sudan' => 'SUD', 'Suriname' => 'SUR', 'Swaziland' => 'SWZ', 'Sweden' => 'SWE', 'Switzerland' => 'SUI', 'Syria' => 'SYR', + 'Taiwan' => 'TWN', 'Tajikistan' => 'TJK', 'Tanzania' => 'TAN', 'Thailand' => 'THA', 'Togo' => 'TOG', 'Tonga' => 'TGA', 'Trinidad and Tobago' => 'TRI', + 'Tunisia' => 'TUN', 'Turkey' => 'TUR', 'Turkmenistan' => 'TKM', 'Tuvalu' => 'TUV', 'Uganda' => 'UGA', 'Ukraine' => 'UKR', 'United Arab Emirates' => 'UAE', + 'United Kingdom' => 'GBR', 'United States of America' => 'USA', 'Uruguay' => 'URU', 'Uzbekistan' => 'UZB', 'Vanuatu' => 'VAN', 'Venezuela' => 'VEN', + 'Vietnam' => 'VIE', 'Yemen' => 'YEM', 'Zambia' => 'ZAM', 'Zimbabwe' => 'ZIM'); if (array_key_exists($country, $nations)) { return $nations[$country]; } diff --git a/core/Utils/WebReader.php b/core/Utils/WebReader.php index 5ca98395..89eb2d47 100644 --- a/core/Utils/WebReader.php +++ b/core/Utils/WebReader.php @@ -9,6 +9,7 @@ use ManiaControl\ManiaControl; /** * Reader Utility Class for efficient Web Requests * + * @see \ManiaControl\Files\AsyncHttpRequest For Asynchron Requests * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 @@ -51,12 +52,12 @@ abstract class WebReader { protected static function newRequest($url) { $request = new Request($url); $options = $request->getOptions(); - $options->set(CURLOPT_TIMEOUT, 5) // timeout - ->set(CURLOPT_HEADER, false) // don't display response header - ->set(CURLOPT_CRLF, true) // linux line feed - ->set(CURLOPT_ENCODING, '') // accept encoding - ->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) // user-agent - ->set(CURLOPT_RETURNTRANSFER, true) // return instead of output content + $options->set(CURLOPT_TIMEOUT, 5)// timeout + ->set(CURLOPT_HEADER, false)// don't display response header + ->set(CURLOPT_CRLF, true)// linux line feed + ->set(CURLOPT_ENCODING, '')// accept encoding + ->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION)// user-agent + ->set(CURLOPT_RETURNTRANSFER, true)// return instead of output content ->set(CURLOPT_AUTOREFERER, true); // follow redirects return $request; } From 8e664879d58491e20583840f7c6f2970df1371f1 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 19:51:22 +0200 Subject: [PATCH 39/73] added new exception --- core/Maps/MapManager.php | 7 +++++-- libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/Maps/MapManager.php b/core/Maps/MapManager.php index cf331d33..2b36daa2 100644 --- a/core/Maps/MapManager.php +++ b/core/Maps/MapManager.php @@ -37,7 +37,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnavailableFeatureException; */ class MapManager implements CallbackListener, CommunicationListener, UsageInformationAble { use UsageInformationTrait; - + /* * Constants */ @@ -455,8 +455,11 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform $this->maniaControl->getChat()->sendException($exception, $login); 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(); diff --git a/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php b/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php index a1bf7b68..f5924b6d 100755 --- a/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php +++ b/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php @@ -63,6 +63,7 @@ class FaultException extends Exception { case 'Map not complete.': case 'Map corrupted.': case 'Map lightmap is not up to date.': + case 'Map lightmap is not up to date. (will still load for now)': case 'The map doesn\'t match the server packmask.': return new InvalidMapException($faultString, $faultCode); case 'Ladder mode unknown.': From da94e8c5886dfd0582b1b9fa1a0d092672b22a34 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 20:21:23 +0200 Subject: [PATCH 40/73] updated to HttpAsyncRequest Structure --- core/Maps/MapManager.php | 1 + core/Server/UsageReporter.php | 10 +++++++-- plugins/MCTeam/KarmaPlugin.php | 37 +++++++++++++++++++++++++--------- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/core/Maps/MapManager.php b/core/Maps/MapManager.php index 2b36daa2..41e53be8 100644 --- a/core/Maps/MapManager.php +++ b/core/Maps/MapManager.php @@ -469,6 +469,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform // 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!'); diff --git a/core/Server/UsageReporter.php b/core/Server/UsageReporter.php index 88cb21aa..3c310370 100644 --- a/core/Server/UsageReporter.php +++ b/core/Server/UsageReporter.php @@ -3,6 +3,7 @@ namespace ManiaControl\Server; use ManiaControl\Callbacks\TimerListener; +use ManiaControl\Files\AsyncHttpRequest; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Utils\Formatter; @@ -81,11 +82,16 @@ class UsageReporter implements TimerListener { $usageReport = json_encode($properties); $url = ManiaControl::URL_WEBSERVICE . 'usagereport'; - $this->maniaControl->getFileReader()->postData($url, function ($response, $error) { + + $asyncRequest = new AsyncHttpRequest($this->maniaControl, $url); + $asyncRequest->setContent($usageReport); + $asyncRequest->setCallable(function ($response, $error) { $response = json_decode($response); if ($error || !$response) { Logger::logError('Error while Sending data: ' . print_r($error, true)); } - }, $usageReport); + }); + + $asyncRequest->postData(); } } diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index 1796a32f..309bf1dc 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -12,6 +12,7 @@ use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Files\AsynchronousFileReader; +use ManiaControl\Files\AsyncHttpRequest; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Maps\Map; @@ -368,16 +369,23 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } $content = json_encode($properties); - $this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json, $error) use ( + + $url = self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey); + + $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $url); + $asyncHttpRequest->setContent($content); + $asyncHttpRequest->setContentType($asyncHttpRequest::CONTENT_TYPE_JSON); + + $asyncHttpRequest->setCallable(function ($json, $error) use ( &$player ) { if ($error) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error' . $error); return; } $data = json_decode($json); if (!$data) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error' . $json); return; } @@ -403,10 +411,12 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { if ($data->data->message === 'invalid session') { unset($this->mxKarma['session']); } else { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('fetch error', $data->data->message, self::MX_KARMA_GET_MAP_RATING, $this->mxKarma['session']); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('fetch error ' . $data->data->message . self::MX_KARMA_GET_MAP_RATING . $this->mxKarma['session']); } } - }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); + }); + + $asyncHttpRequest->postData(); } /** @@ -483,14 +493,19 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $content = json_encode($properties); - $this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json, $error) { + $url = self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey); + + $asyncRequest = new AsyncHttpRequest($this->maniaControl, $url); + $asyncRequest->setContent($content); + $asyncRequest->setContentType($asyncRequest::CONTENT_TYPE_JSON); + $asyncRequest->setCallable(function ($json, $error) { if ($error) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error ' . $error); return; } $data = json_decode($json); if (!$data) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error ' . $json); return; } if ($data->success) { @@ -501,10 +516,12 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { if ($data->data->message === "invalid session") { unset($this->mxKarma['session']); } else { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('saving error', $data->data->message, self::MX_KARMA_SAVE_VOTES, $this->mxKarma['session']); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('saving error ' . $data->data->message . self::MX_KARMA_SAVE_VOTES . $this->mxKarma['session']); } } - }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); + }); + + $asyncRequest->postData(); } /** From 4f94fe02755e38baef43e25fb764f89adaca85ba Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 26 Mar 2017 21:21:19 +0200 Subject: [PATCH 41/73] updated communication usage doc --- core/Communication/usage_documentation.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Communication/usage_documentation.txt b/core/Communication/usage_documentation.txt index 39070787..454df701 100644 --- a/core/Communication/usage_documentation.txt +++ b/core/Communication/usage_documentation.txt @@ -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 From 5a7ee1c9bec90c1be95440cf9e8ec13b790a9f9c Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 27 Mar 2017 22:21:59 +0200 Subject: [PATCH 42/73] finished first version of shootmania callbacks --- core/Callbacks/ShootManiaCallbacks.php | 21 +++++ .../Structures/ShootMania/Models/Landmark.php | 14 ++- .../ShootMania/Models/PlayerScore.php | 89 +++++++++++++++++- .../Structures/ShootMania/Models/Position.php | 15 ++- .../ShootMania/Models/TeamScore.php | 15 ++- .../OnActionCustomEventStructure.php | 91 +++++++++++++++++++ .../Structures/ShootMania/OnActionEvent.php | 58 ++++++++++++ .../ShootMania/OnCustomEventStructure.php | 14 --- .../ShootMania/OnPlayerObjectStructure.php | 80 ++++++++++++++++ .../OnPlayerRequestActionChange.php | 58 ++++++++++++ .../OnPlayerRequestRespawnStructure.php | 1 - .../OnPlayerTriggersSectorStructure.php | 59 ++++++++++++ .../ShootMania/OnScoresStructure.php | 25 +++-- 13 files changed, 510 insertions(+), 30 deletions(-) create mode 100644 core/Callbacks/Structures/ShootMania/OnActionCustomEventStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/OnActionEvent.php delete mode 100644 core/Callbacks/Structures/ShootMania/OnCustomEventStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/OnPlayerObjectStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php create mode 100644 core/Callbacks/Structures/ShootMania/OnPlayerTriggersSectorStructure.php diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 4a7f2d21..3062f4db 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -4,11 +4,16 @@ 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\OnCaptureStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnHitNearMissArmorEmptyStructure; +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\OnShootStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnShotDenyStructure; use ManiaControl\ManiaControl; @@ -88,6 +93,22 @@ class ShootManiaCallbacks implements CallbackListener { $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': diff --git a/core/Callbacks/Structures/ShootMania/Models/Landmark.php b/core/Callbacks/Structures/ShootMania/Models/Landmark.php index af562863..79c0847e 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Landmark.php +++ b/core/Callbacks/Structures/ShootMania/Models/Landmark.php @@ -3,7 +3,19 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; -class Landmark { +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + +/** + * Landmark Model + * + * @author ManiaControl Team + * @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 = ""; diff --git a/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php b/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php index 7e4aeedf..8e695dbc 100644 --- a/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php +++ b/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php @@ -2,7 +2,92 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; -//TODO describtion -class PlayerScore { +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; +use ManiaControl\Players\Player; +/** + * PlayerScore Model + * + * @author ManiaControl Team + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class PlayerScore implements UsageInformationAble { + use UsageInformationTrait; + + private $player; + private $rank; + private $roundPoints; + private $mapPoints; + + /** + * Returns the Player + * + * @return 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; + } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/Models/Position.php b/core/Callbacks/Structures/ShootMania/Models/Position.php index 7fa88c3c..0fe28187 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Position.php +++ b/core/Callbacks/Structures/ShootMania/Models/Position.php @@ -3,8 +3,19 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; -//TODO describtion -class Position { +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + +/** + * Position Model + * + * @author ManiaControl Team + * @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; diff --git a/core/Callbacks/Structures/ShootMania/Models/TeamScore.php b/core/Callbacks/Structures/ShootMania/Models/TeamScore.php index a300aea0..b1557bb5 100644 --- a/core/Callbacks/Structures/ShootMania/Models/TeamScore.php +++ b/core/Callbacks/Structures/ShootMania/Models/TeamScore.php @@ -2,8 +2,19 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; -//TODO describtion -class TeamScore { +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + +/** + * TeamScore Model + * + * @author ManiaControl Team + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class TeamScore implements UsageInformationAble { + use UsageInformationTrait; + private $id; private $name; private $roundPoints; diff --git a/core/Callbacks/Structures/ShootMania/OnActionCustomEventStructure.php b/core/Callbacks/Structures/ShootMania/OnActionCustomEventStructure.php new file mode 100644 index 00000000..25a28022 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnActionCustomEventStructure.php @@ -0,0 +1,91 @@ + + * @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; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnActionEvent.php b/core/Callbacks/Structures/ShootMania/OnActionEvent.php new file mode 100644 index 00000000..badad2f0 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnActionEvent.php @@ -0,0 +1,58 @@ + + * @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; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnCustomEventStructure.php b/core/Callbacks/Structures/ShootMania/OnCustomEventStructure.php deleted file mode 100644 index 7137f8d6..00000000 --- a/core/Callbacks/Structures/ShootMania/OnCustomEventStructure.php +++ /dev/null @@ -1,14 +0,0 @@ - + * @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; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php new file mode 100644 index 00000000..8e0e8a28 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php @@ -0,0 +1,58 @@ + + * @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; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php index 4419e9c5..a9ea16a3 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php @@ -27,7 +27,6 @@ class OnPlayerRequestRespawnStructure extends BaseStructure { $this->time = $this->getPlainJsonObject()->time; $this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login); - $this->getUsage(); } /** diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerTriggersSectorStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayerTriggersSectorStructure.php new file mode 100644 index 00000000..8f9b9824 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnPlayerTriggersSectorStructure.php @@ -0,0 +1,59 @@ + + * @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; + } + + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php index 5f171665..a759d015 100644 --- a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php @@ -4,6 +4,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; use ManiaControl\Callbacks\Structures\BaseStructure; +use ManiaControl\Callbacks\Structures\ShootMania\Models\PlayerScore; use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore; use ManiaControl\ManiaControl; @@ -20,8 +21,8 @@ class OnScoresStructure extends BaseStructure { private $useTeams; private $winnerTeam; private $winnerPlayer; - private $teamScores = array(); - private $players; //TODO implement + private $teamScores = array(); + private $playerScores = array(); //TODO test public function __construct(ManiaControl $maniaControl, $data) { @@ -47,7 +48,16 @@ class OnScoresStructure extends BaseStructure { $this->teamScores[$team->id] = $teamScore; //TODO verify that different teams have different ids } - //TODO implement player + 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; + } + } /** @@ -105,12 +115,11 @@ class OnScoresStructure extends BaseStructure { } /** - * Get The Player Scores + * Get the Player Scores * - * @return mixed + * @return PlayerScore[] */ - public function getPlayers() { - //TODO proper implementation - return $this->players; + public function getPlayerScores() { + return $this->playerScores; } } \ No newline at end of file From a90b307bac71aa8e5eee40c37efe354f59990725 Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 27 Mar 2017 22:45:40 +0200 Subject: [PATCH 43/73] implements all shootmania and common methods --- core/Callbacks/ShootManiaCallbacks.php | 5 ++ core/Script/ModeScriptEventManager.php | 103 ++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-) diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 3062f4db..73db33ed 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -14,6 +14,7 @@ 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; @@ -65,6 +66,10 @@ class ShootManiaCallbacks implements CallbackListener { } 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; diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index 898d541f..3b6d60fa 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -40,7 +40,7 @@ class ModeScriptEventManager implements UsageInformationAble { $this->getAllApiVersions(); - $this->getCallbacksList(); //TODO verify why this does not work + $this->getCallbacksList(); } /** @@ -51,13 +51,52 @@ class ModeScriptEventManager implements UsageInformationAble { } /** + * Request a list of all available callbacks. This method will trigger the "XmlRpc.CallbacksList" callback. + * * @param string $responseId - * Triggers a Callback List Callback */ 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 * @@ -67,7 +106,67 @@ class ModeScriptEventManager implements UsageInformationAble { $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)); + } } \ No newline at end of file From c318f26d682acae3db393e94dc063fbb4ffbef39 Mon Sep 17 00:00:00 2001 From: Jocy Date: Tue, 28 Mar 2017 15:03:37 +0200 Subject: [PATCH 44/73] Fixed z-values and MX-Icon design problem (issue 71) --- core/Maps/MapList.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 778451c3..78b91c29 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -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); @@ -160,12 +161,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $frame->addChild($label); $label->setText('Clear Map-Queue'); $label->setTextSize(1); - $label->setPosition($width / 2 - 8, -$height / 2 + 9); + $label->setPosition($width / 2 - 8, $buttonY, 0.1); $label->setHorizontalAlign($label::RIGHT); $quad = new Quad_BgsPlayerCard(); $frame->addChild($quad); - $quad->setPosition($width / 2 - 5, -$height / 2 + 9, 0.01); + $quad->setPosition($width / 2 - 5, $buttonY, 0.01); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); $quad->setHorizontalAlign($quad::RIGHT); $quad->setSize(29, 4); @@ -174,29 +175,34 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { 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->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->setWidth(30); $label->setHorizontalAlign($label::RIGHT); + $quad = new Quad_BgsPlayerCard(); $frame->addChild($quad); - $quad->setPosition($width / 2 - 37, -$height / 2 + 9, 0.01); + $quad->setPosition($mxCheckForUpdatesX, $buttonY, 0.01); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); $quad->setHorizontalAlign($quad::RIGHT); - $quad->setSize(35, 4); + $quad->setSize($buttonWidth, 4); $quad->setAction(self::ACTION_CHECK_UPDATE); $mxQuad = new Quad(); $frame->addChild($mxQuad); - $mxQuad->setSize(3, 3); + $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($width / 2 - 67, -$height / 2 + 9); - $mxQuad->setZ(0.01); + $mxQuad->setPosition($mxCheckForUpdatesX - $buttonWidth + 3, $buttonY); + $mxQuad->setZ(0.02); $mxQuad->setAction(self::ACTION_CHECK_UPDATE); } @@ -205,13 +211,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { // Directory browser $browserButton = new Label_Button(); $frame->addChild($browserButton); - $browserButton->setPosition($width / -2 + 20, -$height / 2 + 9, 0.01); + $browserButton->setPosition($width / -2 + 20, $buttonY, 0.01); $browserButton->setTextSize(1); $browserButton->setText('Directory Browser'); $browserQuad = new Quad_BgsPlayerCard(); $frame->addChild($browserQuad); - $browserQuad->setPosition($width / -2 + 20, -$height / 2 + 9, 0.01); + $browserQuad->setPosition($width / -2 + 20, $buttonY, 0.01); $browserQuad->setSubStyle($browserQuad::SUBSTYLE_BgPlayerCardBig); $browserQuad->setSize(35, 4); $browserQuad->setAction(DirectoryBrowser::ACTION_SHOW); From fa9e9a0f5ce7b97ad85494fd931874d014dde76c Mon Sep 17 00:00:00 2001 From: Jocy Date: Tue, 28 Mar 2017 16:00:40 +0200 Subject: [PATCH 45/73] Fixed z-values for playerlist Fixed advanced actions in playerslist Added z value to the labelline --- core/Manialinks/ManialinkManager.php | 5 +- core/Players/PlayerList.php | 91 +++++++++++++++------------- 2 files changed, 53 insertions(+), 43 deletions(-) diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index c90cfcfb..6275c11a 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -27,7 +27,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; */ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble { use UsageInformationTrait; - + /* * Constants */ @@ -377,6 +377,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, $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(); @@ -394,6 +395,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, $frame->addChild($label); $label->setHorizontalAlign($hAlign); $label->setX($x); + $label->setZ($posZ); $label->setStyle($style); $label->setTextSize($textSize); $label->setText($texts[$key]); @@ -411,6 +413,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, $frame->addChild($label); $label->setHorizontalAlign($hAlign); $label->setX($x); + $label->setZ($posZ); $label->setStyle($style); $label->setTextSize($textSize); $label->setText($text); diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index 45e33bbf..0f370d37 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -155,6 +155,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $posX = -$width / 2; $posY = $height / 2; + // Define z-values + $foregroundZ = 1; + $backgroundZ = 0.5; + // Predefine Description Label $descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel(); $frame->addChild($descriptionLabel); @@ -192,12 +196,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $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); @@ -206,7 +210,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $currentQuad = new Quad_Icons64x64_1(); $playerFrame->addChild($currentQuad); $currentQuad->setX($posX + 3.5); - $currentQuad->setZ(0.2); + $currentQuad->setZ($foregroundZ); $currentQuad->setSize(4, 4); $currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue); } @@ -217,7 +221,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $teamQuad = new Quad_Emblems(); $playerFrame->addChild($teamQuad); $teamQuad->setX($posX + 10); - $teamQuad->setZ(0.1); + $teamQuad->setZ($foregroundZ); $teamQuad->setSize(3.8, 3.8); switch ($listPlayer->teamId) { @@ -233,7 +237,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $specQuad = new Quad_BgRaceScore2(); $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); } @@ -245,7 +249,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $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); @@ -255,14 +259,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $rightQuad = new Quad_BgRaceScore2(); $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->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'); @@ -274,7 +278,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $playerQuad = new Quad_Icons64x64_1(); $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); @@ -285,7 +289,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $playerQuad = new Quad_UIConstruction_Buttons(); $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 . '$>'; @@ -296,7 +300,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $playerQuad = new Quad_UIConstruction_Buttons(); $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); @@ -310,7 +314,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $playerQuad = new Quad_Icons64x64_1(); $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); @@ -326,7 +330,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $redQuad = new Quad_Emblems(); $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); @@ -339,7 +343,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $blueQuad = new Quad_Emblems(); $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); @@ -353,7 +357,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $kickQuad = new Quad_UIConstruction_Buttons(); $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); @@ -367,7 +371,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $playQuad = new Quad_Emblems(); $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); @@ -382,7 +386,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $spectatorQuad = new Quad_BgRaceScore2(); $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); @@ -395,7 +399,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $spectatorQuad = new Quad_BgRaceScore2(); $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); @@ -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; @@ -450,7 +453,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Add Close Quad (X) $closeQuad = new Quad_Icons64x64_1(); $frame->addChild($closeQuad); - $closeQuad->setPosition($width * 0.4, $height * 0.43, 3); + $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); @@ -459,16 +462,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $backgroundQuad = new Quad(); $frame->addChild($backgroundQuad); $backgroundQuad->setSize($width, $height); - $backgroundQuad->setImageUrl('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->addChild($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(); @@ -481,26 +476,38 @@ 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->addChild($label); - $label->setHorizontalAlign($label::LEFT); - $label->setX(0); - $label->setY($height / 2 - 8); + $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->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->addChild($label); $label->setX(0); @@ -518,7 +525,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer } // Warn Player - $posY -= 5; + $posY -= $buttonSpacing; $quad = clone $quad; $frame->addChild($quad); $quad->setY($posY); @@ -530,7 +537,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $label->setText('Warn'); $label->setTextColor($textColor); - $posY -= 5; + $posY -= $buttonSpacing; // Show Kick $quad = clone $quad; @@ -544,7 +551,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $label->setText('Kick'); $label->setTextColor('f90'); - $posY -= 5; + $posY -= $buttonSpacing; // Show Ban $quad = clone $quad; $frame->addChild($quad); @@ -557,7 +564,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $label->setText('Ban'); $label->setTextColor('700'); - $posY -= 10; + $posY -= $buttonSpacing * 2; // Show Add as Master-Admin $quad = clone $quad; $frame->addChild($quad); @@ -570,7 +577,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $label->setText('Set SuperAdmin'); $label->setTextColor($textColor); - $posY -= 5; + $posY -= $buttonSpacing; // Show Add as Admin $quad = clone $quad; $frame->addChild($quad); @@ -583,7 +590,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $label->setText('Set Admin'); $label->setTextColor($textColor); - $posY -= 5; + $posY -= $buttonSpacing; // Show Add as Moderator $quad = clone $quad; $frame->addChild($quad); @@ -599,7 +606,7 @@ 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->addChild($quad); From 654bf539c9565b91dd4a1635c716cb58cf221162 Mon Sep 17 00:00:00 2001 From: Jocy Date: Tue, 28 Mar 2017 16:03:05 +0200 Subject: [PATCH 46/73] Fixed z-values for playerlist Fixed advanced actions in playerslist Added z value to the labelline --- core/Players/PlayerList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index 0f370d37..355c8a02 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -448,7 +448,7 @@ 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(); From e0102e20ed43905ab8b29debe0f4a0c64bdb761d Mon Sep 17 00:00:00 2001 From: Jocy Date: Tue, 28 Mar 2017 16:13:05 +0200 Subject: [PATCH 47/73] Fixed Statslist z-values --- core/Statistics/SimpleStatsList.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/Statistics/SimpleStatsList.php b/core/Statistics/SimpleStatsList.php index a3715854..4ba456da 100644 --- a/core/Statistics/SimpleStatsList.php +++ b/core/Statistics/SimpleStatsList.php @@ -132,7 +132,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $frame = new Frame(); $maniaLink->addChild($frame); $frame->setSize($width, $height); - $frame->setPosition(0, 0, 10); + $frame->setPosition(0, 0, ManialinkManager::MAIN_MANIALINK_Z_VALUE); // Background $backgroundQuad = new Quad(); @@ -165,6 +165,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $headFrame = new Frame(); $frame->addChild($headFrame); $headFrame->setY($posY - 5); + $headFrame->setZ(1); $posX = $xStart; $array['$oId'] = $posX + 5; @@ -222,13 +223,13 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $playerFrame = new Frame(); $frame->addChild($playerFrame); + $playerFrame->setZ(1); // Show current Player Arrow if ($playerId == $player->index) { $currentQuad = new Quad_Icons64x64_1(); $playerFrame->addChild($currentQuad); $currentQuad->setX($xStart + 3.5); - $currentQuad->setZ(0.2); $currentQuad->setSize(4, 4); $currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue); } @@ -272,7 +273,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $playerFrame->addChild($lineQuad); $lineQuad->setSize($width, 4); $lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig); - $lineQuad->setZ(0.001); + $lineQuad->setZ(-0.5); } $index++; From 95d55836de802b53cc6265fe65e63d61ac495959 Mon Sep 17 00:00:00 2001 From: Jocy Date: Tue, 28 Mar 2017 16:44:41 +0200 Subject: [PATCH 48/73] Fixed Adminmenu, Playermenu Corrected background size of Donation menu and customvotes menu Fixed bug directory browser and removed the default value for tooltip (was always shown) --- core/Admin/ActionsMenu.php | 10 ++++------ core/Maps/DirectoryBrowser.php | 4 ++-- plugins/MCTeam/CustomVotesPlugin.php | 2 +- plugins/MCTeam/DonationPlugin.php | 30 +++++++++++----------------- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/core/Admin/ActionsMenu.php b/core/Admin/ActionsMenu.php index 7b6fbd90..06c2b06c 100644 --- a/core/Admin/ActionsMenu.php +++ b/core/Admin/ActionsMenu.php @@ -156,7 +156,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag // Admin Menu Description $descriptionLabel = new Label(); $manialink->addChild($descriptionLabel); - $descriptionLabel->setPosition($posX - count($this->adminMenuItems) * $itemSize * 1.15 - 6, $posY); + $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); @@ -167,14 +167,13 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag $manialink->addChild($popoutFrame); $popoutFrame->setPosition($posX - $itemSize * 0.5, $posY); $popoutFrame->setHorizontalAlign($popoutFrame::RIGHT); - $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); $popoutFrame->setVisible(false); $backgroundQuad = new Quad(); $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); @@ -220,7 +219,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag // Player Menu Description $descriptionLabel = new Label(); $manialink->addChild($descriptionLabel); - $descriptionLabel->setPosition($posX - count($this->playerMenuItems) * $itemSize * 1.15 - 6, $posY - $itemSize * $itemMarginFactorY); + $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); @@ -231,14 +230,13 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag $manialink->addChild($popoutFrame); $popoutFrame->setPosition($posX - $itemSize * 0.5, $posY - $itemSize * $itemMarginFactorY); $popoutFrame->setHorizontalAlign($popoutFrame::RIGHT); - $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); $popoutFrame->setVisible(false); $backgroundQuad = new Quad(); $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); diff --git a/core/Maps/DirectoryBrowser.php b/core/Maps/DirectoryBrowser.php index 76904651..4fed78f8 100644 --- a/core/Maps/DirectoryBrowser.php +++ b/core/Maps/DirectoryBrowser.php @@ -157,7 +157,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener { $tooltipLabel = new Label(); $frame->addChild($tooltipLabel); - $tooltipLabel->setPosition($width * -0.48, $height * -0.44)->setSize($width * 0.8, 5)->setHorizontalAlign($tooltipLabel::LEFT)->setTextSize(1)->setText('tooltip'); + $tooltipLabel->setPosition($width * -0.48, $height * -0.44)->setSize($width * 0.8, 5)->setHorizontalAlign($tooltipLabel::LEFT)->setTextSize(1); $mapFiles = $this->scanMapFiles($folderPath); @@ -178,7 +178,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener { $pageFrame = new Frame(); $frame->addChild($pageFrame); $posY = $height / 2 - 10; - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); } // Map Frame diff --git a/plugins/MCTeam/CustomVotesPlugin.php b/plugins/MCTeam/CustomVotesPlugin.php index 492e9551..ba6b69c7 100644 --- a/plugins/MCTeam/CustomVotesPlugin.php +++ b/plugins/MCTeam/CustomVotesPlugin.php @@ -347,7 +347,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $popoutFrame->addChild($backgroundQuad); $backgroundQuad->setHorizontalAlign($backgroundQuad::RIGHT); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); - $backgroundQuad->setSize($menuEntries * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY); + $backgroundQuad->setSize($menuEntries * $itemSize * 1.05 + 2, $itemSize * $itemMarginFactorY); $itemQuad->addToggleFeature($popoutFrame); diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index d1de33d1..6d487398 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -135,8 +135,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { * Display the widget */ public function displayWidget() { - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { $this->displayDonateWidget(); } } @@ -159,8 +158,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $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; } @@ -194,16 +192,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $maniaLink->addChild($popoutFrame); $popoutFrame->setPosition($posX - $itemSize * 0.5, $posY); $popoutFrame->setHorizontalAlign($popoutFrame::RIGHT); - $popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY); $popoutFrame->setVisible(false); - $quad = new Quad(); - $popoutFrame->addChild($quad); - $quad->setHorizontalAlign($quad::RIGHT); - $quad->setStyles($quadStyle, $quadSubstyle); - $quad->setSize(strlen($values) * 2 + count($valueArray) * 1, $itemSize * $itemMarginFactorY); - - $popoutFrame->addChild($quad); $itemQuad->addToggleFeature($popoutFrame); // Description Label @@ -237,6 +227,13 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $posX -= strlen($value) * 2 + 1.7; } + //Popout background + $quad = new Quad(); + $popoutFrame->addChild($quad); + $quad->setHorizontalAlign($quad::RIGHT); + $quad->setStyles($quadStyle, $quadSubstyle); + $quad->setSize((2 - $posX), $itemSize * $itemMarginFactorY); + // Send manialink $this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $login); } @@ -328,8 +325,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { */ public function handlePlayerConnect(Player $player) { // Display Map Widget - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED) - ) { + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { $this->displayDonateWidget($player->login); } } @@ -381,8 +377,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { * @param Player $player */ public function command_Pay(array $chatCallback, 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; } @@ -439,8 +434,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { * @param Player $player */ public function command_GetPlanets(array $chatCallback, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } From 69c5fdc2a6d69f7da5f9f282f8ae014a23ae5a55 Mon Sep 17 00:00:00 2001 From: Jocy Date: Tue, 28 Mar 2017 16:46:40 +0200 Subject: [PATCH 49/73] small fix at customvotes widget --- plugins/MCTeam/CustomVotesPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/CustomVotesPlugin.php b/plugins/MCTeam/CustomVotesPlugin.php index ba6b69c7..d28e9b2d 100644 --- a/plugins/MCTeam/CustomVotesPlugin.php +++ b/plugins/MCTeam/CustomVotesPlugin.php @@ -325,7 +325,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $menuEntries = count($this->voteMenuItems); $descriptionFrame = new Frame(); $maniaLink->addChild($descriptionFrame); - $descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.15 - 6, $posY); + $descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.05 - 5, $posY); $descriptionLabel = new Label(); $descriptionFrame->addChild($descriptionLabel); From 6ab53508fbcc0be3e0fde5b97a4ae1d89e6ddfcb Mon Sep 17 00:00:00 2001 From: Jocy Date: Tue, 28 Mar 2017 19:09:36 +0200 Subject: [PATCH 50/73] Fixed pagination in Helpmanager --- core/Commands/HelpManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Commands/HelpManager.php b/core/Commands/HelpManager.php index f7fbda38..becde057 100644 --- a/core/Commands/HelpManager.php +++ b/core/Commands/HelpManager.php @@ -182,7 +182,7 @@ class HelpManager implements CommandListener, CallbackListener { $pageFrame = new Frame(); $frame->addChild($pageFrame); $posY = $height / 2 - 10; - $paging->addPage($pageFrame); //TODO @Jocy + $paging->addPageControl($pageFrame); //TODO @Jocy } $playerFrame = new Frame(); From 498237491fe42d72bd2c49913eff1833d216073d Mon Sep 17 00:00:00 2001 From: W1lla van den Munckhof Date: Wed, 29 Mar 2017 13:28:32 +0200 Subject: [PATCH 51/73] First Batch TM Callbacks Gonna work on the others --- core/Callbacks/Callbacks.php | 21 ++- core/Callbacks/LibXmlRpcCallbacks.php | 1 - core/Callbacks/Models/RecordCallback.php | 18 ++- .../TrackMania/Models/PlayerScore.php | 134 ++++++++++++++++++ .../TrackMania/Models/TeamScore.php | 93 ++++++++++++ .../TrackMania/OnEventStartLineStructure.php | 44 ++++++ .../TrackMania/OnEventWayPointStructure.php | 92 ++++++++++++ .../TrackMania/OnScoresStructure.php | 125 ++++++++++++++++ core/Callbacks/TrackManiaCallbacks.php | 43 +++++- 9 files changed, 554 insertions(+), 17 deletions(-) create mode 100644 core/Callbacks/Structures/TrackMania/Models/PlayerScore.php create mode 100644 core/Callbacks/Structures/TrackMania/Models/TeamScore.php create mode 100644 core/Callbacks/Structures/TrackMania/OnEventStartLineStructure.php create mode 100644 core/Callbacks/Structures/TrackMania/OnEventWayPointStructure.php create mode 100644 core/Callbacks/Structures/TrackMania/OnScoresStructure.php diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index b997a1f9..82a0c142 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -81,9 +81,24 @@ interface Callbacks { const SM_ONPLAYERTHROWSOBJECT = "Shootmania.Event.OnPlayerThrowsObject"; const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange"; - - const TM_ONEVENTDEFAULT = "Trackmania.Event.Default"; - + // 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'; diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 5f2adfc7..caf6242b 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -44,7 +44,6 @@ class LibXmlRpcCallbacks implements CallbackListener { * @param mixed $data */ public function handleScriptCallback($name, $data) { - var_dump($name); if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) { //return; //Leave that disabled while testing/implementing Callbacks } diff --git a/core/Callbacks/Models/RecordCallback.php b/core/Callbacks/Models/RecordCallback.php index 371489b2..4c5815fa 100644 --- a/core/Callbacks/Models/RecordCallback.php +++ b/core/Callbacks/Models/RecordCallback.php @@ -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; } diff --git a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php new file mode 100644 index 00000000..7de096fb --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php @@ -0,0 +1,134 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class PlayerScore implements UsageInformationAble { + use UsageInformationTrait; + + private $player; + private $rank; + private $roundPoints; + private $mapPoints; + private $matchPoints; + private $bestraceTime; + private $bestlapTime; + private $stuntScore; + + /** + * Returns the Player + * + * @return 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; + } + + /** + * Gets the bestRaceTime + * + * @param int $bestraceTime + */ + public function getbestraceTime(){ + return $this->bestraceTime; + } + + /** + * 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; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/Models/TeamScore.php b/core/Callbacks/Structures/TrackMania/Models/TeamScore.php new file mode 100644 index 00000000..07fe30a3 --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/Models/TeamScore.php @@ -0,0 +1,93 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class TeamScore 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; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnEventStartLineStructure.php b/core/Callbacks/Structures/TrackMania/OnEventStartLineStructure.php new file mode 100644 index 00000000..0532b73f --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/OnEventStartLineStructure.php @@ -0,0 +1,44 @@ + + * @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; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnEventWayPointStructure.php b/core/Callbacks/Structures/TrackMania/OnEventWayPointStructure.php new file mode 100644 index 00000000..0aac25eb --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/OnEventWayPointStructure.php @@ -0,0 +1,92 @@ + + * @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; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php new file mode 100644 index 00000000..fafcdf1f --- /dev/null +++ b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php @@ -0,0 +1,125 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnScoresStructure extends BaseStructure { + private $responseId; + private $section; + private $useTeams; + private $winnerTeam; + private $winnerPlayer; + private $teamScores = array(); + private $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) { + $teamScore = new 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 + } + + 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; + } + + } + + /** + * 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 PlayerScore[] + */ + public function getPlayerScores() { + return $this->playerScores; + } +} \ No newline at end of file diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index 8c5090ef..298bbe2e 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -4,6 +4,10 @@ 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; @@ -21,6 +25,7 @@ class TrackManiaCallbacks implements CallbackListener { /** @var ManiaControl $maniaControl */ private $maniaControl = null; + /** * Create a new TrackMania Callbacks Instance * @@ -32,12 +37,6 @@ class TrackManiaCallbacks implements CallbackListener { // Register for script callbacks $callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks'); - - - // 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'); } /** @@ -52,9 +51,41 @@ class TrackManiaCallbacks implements CallbackListener { } 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; } } From 4e546f64041708e5b73dc81e9aabe95d9cc9b81a Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 29 Mar 2017 18:29:02 +0200 Subject: [PATCH 52/73] cb fix --- .../ShootMania/OnHitNearMissArmorEmptyStructure.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php index 740e9c6b..f0b56e2c 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php @@ -43,7 +43,6 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { $jsonObj = $this->getPlainJsonObject(); $this->time = $jsonObj->time; $this->weapon = $jsonObj->weapon; - $this->damage = $jsonObj->damage; //TODO does only exist on onhit -> make baseclass $this->shooterPosition = new Position(); $this->shooterPosition->setX($jsonObj->shooterposition->x); @@ -59,6 +58,10 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { $this->distance = $this->getPlainJsonObject()->distance; } + if (property_exists($this->getPlainJsonObject(), 'damage')) { + $this->damage = $this->getPlainJsonObject()->damage; + } + $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); } From 5654d968e2f5449cdaf44a799d119c5ccd76bb01 Mon Sep 17 00:00:00 2001 From: Jocy Date: Wed, 29 Mar 2017 19:54:50 +0200 Subject: [PATCH 53/73] Added mp4 filter to mx-list --- core/ManiaExchange/ManiaExchangeList.php | 74 ++++++++++++++++--- core/ManiaExchange/ManiaExchangeMapSearch.php | 25 +++++-- core/Maps/MapCommands.php | 33 +++------ 3 files changed, 96 insertions(+), 36 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index 7c991aee..47051b3c 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -2,6 +2,7 @@ namespace ManiaControl\ManiaExchange; +use FML\Components\CheckBox; use FML\Controls\Entry; use FML\Controls\Frame; use FML\Controls\Gauge; @@ -40,7 +41,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 +65,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 +87,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 +105,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 +135,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 +164,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener }); } + /** * Display the Mania Exchange List * @@ -176,7 +197,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $headFrame = new Frame(); $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); $index = 0; @@ -205,7 +227,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener } $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); + $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); @@ -223,8 +246,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $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->addChild($addQuad); $addQuad->setX($posX + 53); @@ -311,10 +333,11 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $quad = new Quad_BgsPlayerCard(); $frame->addChild($quad); - $quad->setPosition(-$width / 2 + 63, $height / 2 - 5, 0.01); + $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(); @@ -325,15 +348,46 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $quad = new Quad_BgsPlayerCard(); $frame->addChild($quad); - $quad->setPosition(-$width / 2 + 82, $height / 2 - 5, 0.01); + $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 * diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index a2ccd979..b2766c5e 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -2,7 +2,7 @@ namespace ManiaControl\ManiaExchange; -use ManiaControl\Files\AsynchronousFileReader; +use ManiaControl\Files\AsyncHttpRequest; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; @@ -17,7 +17,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; */ 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; @@ -84,6 +84,7 @@ class ManiaExchangeMapSearch implements UsageInformationAble { private $envMix = null; private $ghostBlocks = null; private $embeddedObjects = null; + private $key = null; /** @var ManiaControl $maniaControl */ private $maniaControl = null; @@ -104,7 +105,7 @@ class ManiaExchangeMapSearch implements UsageInformationAble { $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; } @@ -218,8 +219,13 @@ class ManiaExchangeMapSearch implements UsageInformationAble { 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; @@ -247,7 +253,9 @@ class ManiaExchangeMapSearch implements UsageInformationAble { } call_user_func($function, $maps); - }, AsynchronousFileReader::CONTENT_TYPE_JSON); + }); + + $asyncHttpRequest->getData(); } @@ -444,4 +452,11 @@ class ManiaExchangeMapSearch implements UsageInformationAble { public function setMapLimit($mapLimit) { $this->mapLimit = $mapLimit; } + + /** + * @param null $key + */ + public function setKey($key) { + $this->key = $key; + } } \ No newline at end of file diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index e063ab18..0d84c9da 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -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); } } From 6eef55df6dfa89d0ac0ee2183ad5ed269bac6345 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 29 Mar 2017 20:38:46 +0200 Subject: [PATCH 54/73] small fixes --- .../ShootMania/OnPlayerRequestActionChange.php | 2 +- core/Files/AsyncHttpRequest.php | 1 + core/Maps/MapManager.php | 16 ++++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php index 8e0e8a28..cd43dcfb 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php @@ -22,7 +22,7 @@ class OnPlayerRequestActionChange extends BaseStructure { parent::__construct($maniaControl, $data); $this->time = $this->getPlainJsonObject()->time; - $this->actionChange = $this->getPlainJsonObject()->actionChange; + $this->actionChange = $this->getPlainJsonObject()->actionchange; $this->player = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->login); } diff --git a/core/Files/AsyncHttpRequest.php b/core/Files/AsyncHttpRequest.php index 0826a234..a9e69542 100644 --- a/core/Files/AsyncHttpRequest.php +++ b/core/Files/AsyncHttpRequest.php @@ -21,6 +21,7 @@ class AsyncHttpRequest implements UsageInformationAble { * Constants */ const CONTENT_TYPE_JSON = 'application/json'; + const CONTENT_TYPE_UTF8 = 'UTF-8'; /* * Private properties diff --git a/core/Maps/MapManager.php b/core/Maps/MapManager.php index 41e53be8..fd3cabba 100644 --- a/core/Maps/MapManager.php +++ b/core/Maps/MapManager.php @@ -9,6 +9,7 @@ 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; @@ -360,12 +361,14 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform $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) { @@ -376,7 +379,9 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform return; } $this->processMapFile($file, $mapInfo, $login, $update); - }, 'UTF-8', 0, array("X-ManiaPlanet-ServerLogin: " . $this->maniaControl->getServer()->login)); + }); + + $asyncHttpRequest->getData(); }); } return; @@ -455,7 +460,6 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform $this->maniaControl->getChat()->sendException($exception, $login); return; } catch (InvalidMapException $exception) { - $this->maniaControl->getChat()->sendException($exception, $login); if ($exception->getMessage() != 'Map lightmap is not up to date. (will still load for now)') { return; From c0e3df972df524d3d89101adadaeaf16894bdb13 Mon Sep 17 00:00:00 2001 From: Jocy Date: Wed, 29 Mar 2017 21:08:58 +0200 Subject: [PATCH 55/73] Updated Donationsplugin with default tooltip --- plugins/MCTeam/DonationPlugin.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index 6d487398..20313226 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -199,19 +199,18 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { // Description Label $descriptionFrame = new Frame(); $maniaLink->addChild($descriptionFrame); - $descriptionFrame->setPosition($posX - 50, $posY - 5); $descriptionFrame->setHorizontalAlign($descriptionFrame::RIGHT); $descriptionLabel = new Label(); $descriptionFrame->addChild($descriptionLabel); - $descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP); + $descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP); $descriptionLabel->setSize(40, 4); - $descriptionLabel->setTextSize(2); + $descriptionLabel->setTextSize(1); $descriptionLabel->setVisible(true); - $descriptionLabel->setTextColor('0f0'); // Add items - $posX = -2; + $origPosX = $posX; + $posX = -2; foreach (array_reverse($valueArray) as $value) { $label = new Label_Text(); $popoutFrame->addChild($label); @@ -227,6 +226,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $posX -= strlen($value) * 2 + 1.7; } + $descriptionFrame->setPosition($origPosX + $posX - $width + $itemMarginFactorX, $posY); + //Popout background $quad = new Quad(); $popoutFrame->addChild($quad); From 8dc2c358afd17a6f458ab4c8916796d303be236b Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 29 Mar 2017 21:31:28 +0200 Subject: [PATCH 56/73] typo fixes --- core/Callbacks/Structures/TrackMania/OnScoresStructure.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php index fafcdf1f..1ce1bb14 100644 --- a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php @@ -30,10 +30,10 @@ class OnScoresStructure extends BaseStructure { $jsonObj = $this->getPlainJsonObject(); - $this->responseId = $jsonObj->responseId; + $this->responseId = $jsonObj->responseid; $this->section = $jsonObj->section; - $this->useTeams = $jsonObj->useTeams; - $this->winnerTeam = $jsonObj->winnerTeam; + $this->useTeams = $jsonObj->useteams; + $this->winnerTeam = $jsonObj->winnerteam; $this->winnerPlayer = $this->maniaControl->getPlayerManager()->getPlayer($jsonObj->winnerplayer); From cfc3694835c14a15d9db4dd86d625ab8c13335cb Mon Sep 17 00:00:00 2001 From: Jocy Date: Wed, 29 Mar 2017 22:25:50 +0200 Subject: [PATCH 57/73] Moved LabelLine to own class --- core/Manialinks/LabelLine.php | 145 +++++++++++++++++++++++++++ core/Manialinks/ManialinkManager.php | 48 +++------ 2 files changed, 160 insertions(+), 33 deletions(-) create mode 100644 core/Manialinks/LabelLine.php diff --git a/core/Manialinks/LabelLine.php b/core/Manialinks/LabelLine.php new file mode 100644 index 00000000..6e782420 --- /dev/null +++ b/core/Manialinks/LabelLine.php @@ -0,0 +1,145 @@ +frame = $frame; + } + + /** + * Create a new text label + * + * @param $labelText + * @param $posX + * @param int $width + */ + public function addLabelEntryText($labelText, $posX, $width = 0) { + $label = new Label_Text(); + $label->setText($labelText); + $label->setX($posX); + if ($width) { + $label->setWidth($width); + } + $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); + + $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; + } +} \ No newline at end of file diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 6275c11a..9e2df899 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -376,10 +376,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])) { @@ -391,42 +400,15 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, } foreach ($positions as $key => $x) { - $label = new Label_Text(); - $frame->addChild($label); - $label->setHorizontalAlign($hAlign); - $label->setX($x); - $label->setZ($posZ); - $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->addChild($label); - $label->setHorizontalAlign($hAlign); - $label->setX($x); - $label->setZ($posZ); - $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(); } } From 6a703f7311eb1ce926cec77917be77981993a832 Mon Sep 17 00:00:00 2001 From: Jocy Date: Wed, 29 Mar 2017 23:26:03 +0200 Subject: [PATCH 58/73] Updated MXlist with new Labelline --- core/ManiaExchange/ManiaExchangeList.php | 29 ++++++++++++++---- core/Manialinks/LabelLine.php | 39 +++++++++++++++++++++--- core/Manialinks/ManialinkManager.php | 2 ++ 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index 47051b3c..d242c17b 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -18,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; @@ -201,6 +202,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener '$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; @@ -226,12 +238,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $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); diff --git a/core/Manialinks/LabelLine.php b/core/Manialinks/LabelLine.php index 6e782420..b894818f 100644 --- a/core/Manialinks/LabelLine.php +++ b/core/Manialinks/LabelLine.php @@ -8,6 +8,13 @@ use FML\Controls\Labels\Label_Text; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; +/** + * Class providing easy labels in a line + * + * @author ManiaControl Team + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ class LabelLine implements UsageInformationAble { use UsageInformationTrait; @@ -19,23 +26,30 @@ class LabelLine implements UsageInformationAble { 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 $labelText + * @param $posX + * @param int $width + * @param string $action */ - public function addLabelEntryText($labelText, $posX, $width = 0) { + 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); } @@ -54,6 +68,7 @@ class LabelLine implements UsageInformationAble { /** * Adds the labels to your frame */ + public function render() { /** @var Label $entry */ foreach ($this->entries as $entry) { @@ -62,6 +77,7 @@ class LabelLine implements UsageInformationAble { $entry->setTextSize($this->textSize); $entry->setTextColor($this->textColor); $entry->setZ($this->posZ); + $entry->setTextPrefix($this->prefix); $this->frame->addChild($entry); } @@ -122,6 +138,7 @@ class LabelLine implements UsageInformationAble { public function setTextColor($textColor) { $this->textColor = $textColor; } + /** * @return int */ @@ -142,4 +159,18 @@ class LabelLine implements UsageInformationAble { public function getEntries() { return $this->entries; } + + /** + * @return string + */ + public function getPrefix() { + return $this->prefix; + } + + /** + * @param string $prefix + */ + public function setPrefix($prefix) { + $this->prefix = $prefix; + } } \ No newline at end of file diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 9e2df899..9ce12b8a 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -369,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 From 769ee7262a120d44a7b05cbfb90104b26f57fb31 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 16:10:29 +0200 Subject: [PATCH 59/73] fixed errror --- .../TrackMania/Models/PlayerScore.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php index 7de096fb..0eb07753 100644 --- a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php +++ b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php @@ -5,7 +5,7 @@ namespace ManiaControl\Callbacks\Structures\TrackMania\Models; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; use ManiaControl\Players\Player; - +//TODO proper return descriptions on getter methods /** * PlayerScore Model * @@ -103,14 +103,15 @@ class PlayerScore implements UsageInformationAble { public function getbestraceTime(){ return $this->bestraceTime; } - + + /** - * Gets the bestRaceTime - * - * @param int $bestraceTime - */ - public function getbestraceTime(){ - return $this->bestraceTime; + * Gets the MapPoints + * + * @return int + */ + public function getMatchPoints(){ + return $this->matchPoints; } /** From 63ee8a9ae4dc2f476c7618428f5ff738ccb0bcf9 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 16:25:54 +0200 Subject: [PATCH 60/73] labelline fix --- core/ManiaExchange/ManiaExchangeList.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index d242c17b..ebd06122 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -240,9 +240,10 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $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($map->author, $posX + 59,-1,self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author); //FIXME with > 1 disables the ml $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)); @@ -250,6 +251,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $labelLine->setPrefix('$s'); $labelLine->render(); + $mapFrame->setY($posY); $mxQuad = new Quad(); From e39b903ebdfefbc51dfbd55c02a5a79e3955d193 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 17:11:27 +0200 Subject: [PATCH 61/73] fixed labelline + FML control update --- core/ManiaExchange/ManiaExchangeList.php | 3 +- core/Manialinks/LabelLine.php | 1 + libs/FML/Controls/Control.php | 1740 +++++++++++----------- 3 files changed, 888 insertions(+), 856 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index ebd06122..0c385801 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -243,7 +243,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $labelLine->addLabelEntryText($map->id, $posX + 3.5, 9); $labelLine->addLabelEntryText($map->name, $posX + 12.5, 38.5); - $labelLine->addLabelEntryText($map->author, $posX + 59,-1,self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author); //FIXME with > 1 disables the ml + $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)); @@ -251,7 +251,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $labelLine->setPrefix('$s'); $labelLine->render(); - $mapFrame->setY($posY); $mxQuad = new Quad(); diff --git a/core/Manialinks/LabelLine.php b/core/Manialinks/LabelLine.php index b894818f..cdfad8b8 100644 --- a/core/Manialinks/LabelLine.php +++ b/core/Manialinks/LabelLine.php @@ -52,6 +52,7 @@ class LabelLine implements UsageInformationAble { } if ($width) { $label->setWidth($width); + $label->setHeight(5); //TODO verify if 5 is ok for everywhere } $this->addLabel($label); } diff --git a/libs/FML/Controls/Control.php b/libs/FML/Controls/Control.php index d9600db4..60fc589d 100644 --- a/libs/FML/Controls/Control.php +++ b/libs/FML/Controls/Control.php @@ -27,859 +27,891 @@ use FML\UniqueID; abstract class Control implements Identifiable, Renderable, ScriptFeatureable { - /* - * Constants - */ - const CENTER = 'center'; - const CENTER2 = 'center2'; - const TOP = 'top'; - const RIGHT = 'right'; - const BOTTOM = 'bottom'; - const LEFT = 'left'; - - /** - * @var string $controlId Control Id - */ - protected $controlId = null; - - /** - * @var float $posX X position - */ - protected $posX = 0.; - - /** - * @var float $posY Y position - */ - protected $posY = 0.; - - /** - * @var float $posZ Z position - */ - protected $posZ = 0.; - - /** - * @var float $width Width - */ - protected $width = -1.; - - /** - * @var float $height Height - */ - protected $height = -1.; - - /** - * @var string $horizontalAlign Horizontal alignment - */ - protected $horizontalAlign = self::CENTER; - - /** - * @var string $verticalAlign Vertical alignment - */ - protected $verticalAlign = self::CENTER2; - - /** - * @var float $scale Scale - */ - protected $scale = 1.; - - /** - * @var bool $visible Visibility - */ - protected $visible = true; - - /** - * @var float $rotation Rotation - */ - protected $rotation = 0.; - - /** - * @var string[] $classes Style classes - */ - protected $classes = array(); - - /** - * @var mixed[] $dataAttributes Data attributes - */ - protected $dataAttributes = array(); - - /** - * @var ScriptFeature[] $scriptFeatures Script Features - */ - protected $scriptFeatures = array(); - - /** - * Create a new Control - * - * @api - * @param string $controlId (optional) Control Id - * @return static - */ - public static function create($controlId = null) - { - return new static($controlId); - } - - /** - * Construct a new Control - * - * @api - * @param string $controlId (optional) Control Id - */ - public function __construct($controlId = null) - { - if ($controlId) { - $this->setId($controlId); - } - } - - /** - * @see Identifiable::getId() - */ - public function getId() - { - return $this->controlId; - } - - /** - * @see Identifiable::setId() - */ - public function setId($controlId) - { - $this->controlId = (string)$controlId; - return $this; - } - - /** - * @see Identifiable::checkId() - */ - public function checkId() - { - return UniqueID::check($this); - } - - /** - * Get the X position - * - * @api - * @return float - */ - public function getX() - { - return $this->posX; - } - - /** - * Set the X position - * - * @api - * @param float $posX Horizontal position - * @return static - */ - public function setX($posX) - { - $this->posX = (float)$posX; - return $this; - } - - /** - * Get the Y position - * - * @api - * @return float - */ - public function getY() - { - return $this->posY; - } - - /** - * Set the Y position - * - * @api - * @param float $posY Vertical position - * @return static - */ - public function setY($posY) - { - $this->posY = (float)$posY; - return $this; - } - - /** - * Get the Z position - * - * @api - * @return float - */ - public function getZ() - { - return $this->posZ; - } - - /** - * Set the Z position - * - * @api - * @param float $posZ Depth - * @return static - */ - public function setZ($posZ) - { - $this->posZ = (float)$posZ; - return $this; - } - - /** - * Set the Control position - * - * @api - * @param float $posX Horizontal position - * @param float $posY Vertical position - * @param float $posZ (optional) Depth - * @return static - */ - public function setPosition($posX, $posY, $posZ = null) - { - $this->setX($posX) - ->setY($posY); - if ($posZ !== null) { - $this->setZ($posZ); - } - return $this; - } - - /** - * Get the width - * - * @api - * @return float - */ - public function getWidth() - { - return $this->width; - } - - /** - * Set the width - * - * @api - * @param float $width Control width - * @return static - */ - public function setWidth($width) - { - $this->width = (float)$width; - return $this; - } - - /** - * Get the height - * - * @api - * @return float - */ - public function getHeight() - { - return $this->height; - } - - /** - * Set the height - * - * @api - * @param float $height Control height - * @return static - */ - public function setHeight($height) - { - $this->height = (float)$height; - return $this; - } - - /** - * Set the size - * - * @api - * @param float $width Control width - * @param float $height Control height - * @return static - */ - public function setSize($width, $height) - { - return $this->setWidth($width) - ->setHeight($height); - } - - /** - * Get the horizontal alignment - * - * @api - * @return string - */ - public function getHorizontalAlign() - { - return $this->horizontalAlign; - } - - /** - * Set the horizontal alignment - * - * @api - * @param string $horizontalAlign Horizontal alignment - * @return static - * @deprecated Use setHorizontalAlign() instead - */ - public function setHAlign($horizontalAlign) - { - return $this->setHorizontalAlign($horizontalAlign); - } - - /** - * Set the horizontal alignment - * - * @api - * @param string $horizontalAlign Horizontal alignment - * @return static - */ - public function setHorizontalAlign($horizontalAlign) - { - $this->horizontalAlign = (string)$horizontalAlign; - return $this; - } - - /** - * Get the vertical alignment - * - * @api - * @return string - */ - public function getVerticalAlign() - { - return $this->verticalAlign; - } - - /** - * Set the vertical alignment - * - * @api - * @param string $verticalAlign Vertical alignment - * @return static - * @deprecated - */ - public function setVAlign($verticalAlign) - { - return $this->setVerticalAlign($verticalAlign); - } - - /** - * Set the vertical alignment - * - * @api - * @param string $verticalAlign Vertical alignment - * @return static - */ - public function setVerticalAlign($verticalAlign) - { - $this->verticalAlign = (string)$verticalAlign; - return $this; - } - - /** - * Set the horizontal and the vertical alignment - * - * @api - * @param string $horizontalAlign Horizontal alignment - * @param string $verticalAlign Vertical alignment - * @return static - */ - public function setAlign($horizontalAlign, $verticalAlign) - { - return $this->setHorizontalAlign($horizontalAlign) - ->setVerticalAlign($verticalAlign); - } - - /** - * Center the alignment - * - * @api - * @return static - */ - public function centerAlign() - { - return $this->setAlign(self::CENTER, self::CENTER2); - } - - /** - * Clear the alignment - * - * @api - * @return static - */ - public function clearAlign() - { - $this->horizontalAlign = null; - $this->verticalAlign = null; - return $this; - } - - /** - * Get the scale - * - * @api - * @return float - */ - public function getScale() - { - return $this->scale; - } - - /** - * Set the scale - * - * @api - * @param float $scale Control scale - * @return static - */ - public function setScale($scale) - { - $this->scale = (float)$scale; - return $this; - } - - /** - * Get the visibility - * - * @api - * @return bool - */ - public function getVisible() - { - return $this->visible; - } - - /** - * Set the visibility - * - * @api - * @param bool $visible If the Control should be visible - * @return static - */ - public function setVisible($visible) - { - $this->visible = $visible; - return $this; - } - - /** - * Get the rotation - * - * @api - * @return float - */ - public function getRotation() - { - return $this->rotation; - } - - /** - * Set the rotation - * - * @api - * @param float $rotation Control rotation - * @return static - */ - public function setRotation($rotation) - { - $this->rotation = (float)$rotation; - return $this; - } - - /** - * Get style classes - * - * @api - * @return string[] - */ - public function getClasses() - { - return $this->classes; - } - - /** - * Add a new style class - * - * @api - * @param string $class Style class - * @return static - */ - public function addClass($class) - { - $class = (string)$class; - if (!in_array($class, $this->classes)) { - array_push($this->classes, $class); - } - return $this; - } - - /** - * Add new style classes - * - * @api - * @param string[] $classes Style classes - * @return static - */ - public function addClasses(array $classes) - { - foreach ($classes as $class) { - $this->addClass($class); - } - return $this; - } - - /** - * Remove all style classes - * - * @api - * @return static - */ - public function removeAllClasses() - { - $this->classes = array(); - return $this; - } - - /** - * Check if a data attribute is set - * - * @api - * @param string $name Name - * @return bool - */ - public function hasDataAttribute($name) - { - return isset($this->dataAttributes[$name]); - } - - /** - * Get data attribute - * - * @api - * @param string $name Name - * @return mixed - */ - public function getDataAttribute($name) - { - if (isset($this->dataAttributes[$name])) { - return $this->dataAttributes[$name]; - } - return null; - } - - /** - * Get data attributes - * - * @api - * @return mixed[] - */ - public function getDataAttributes() - { - return $this->dataAttributes; - } - - /** - * Add data attribute - * - * @api - * @param string $name Name - * @param mixed $value Value - * @return static - */ - public function addDataAttribute($name, $value) - { - $this->dataAttributes[$name] = $value; - return $this; - } - - /** - * Add multiple data attributes - * - * @api - * @param mixed[] $dataAttributes Data attributes - * @return static - */ - public function addDataAttributes(array $dataAttributes) - { - foreach ($dataAttributes as $name => $value) { - $this->addDataAttribute($name, $value); - } - return $this; - } - - /** - * Set data attributes (replacing all previous attributes) - * - * @api - * @param mixed[] $dataAttributes Data attributes - * @return static - */ - public function setDataAttributes(array $dataAttributes) - { - return $this->removeAllDataAttributes() - ->addDataAttributes($dataAttributes); - } - - /** - * Remove data attribute - * - * @api - * @param string $name Name - * @return static - */ - public function removeDataAttribute($name) - { - unset($this->dataAttributes[$name]); - return $this; - } - - /** - * Remove all data attributes - * - * @api - * @return static - */ - public function removeAllDataAttributes() - { - $this->dataAttributes = array(); - return $this; - } - - /** - * @see ScriptFeatureable::getScriptFeatures() - */ - public function getScriptFeatures() - { - return $this->scriptFeatures; - } - - /** - * Add a new Script Feature - * - * @api - * @param ScriptFeature $scriptFeature Script Feature - * @return static - */ - public function addScriptFeature(ScriptFeature $scriptFeature) - { - if (!in_array($scriptFeature, $this->scriptFeatures, true)) { - array_push($this->scriptFeatures, $scriptFeature); - } - return $this; - } - - /** - * Remove all Script Features - * - * @api - * @return static - * @deprecated use removeAllScriptFeatures() instead - */ - public function removeScriptFeatures() - { - return $this->removeAllScriptFeatures(); - } - - /** - * Remove all Script Features - * - * @api - * @return static - */ - public function removeAllScriptFeatures() - { - $this->scriptFeatures = array(); - return $this; - } - - /** - * Add a dynamic Action Trigger - * - * @api - * @param string $actionName Action to trigger - * @param string $eventLabel (optional) Event on which the action is triggered - * @return static - */ - public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) - { - $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel); - $this->addScriptFeature($actionTrigger); - return $this; - } - - /** - * Add a dynamic Feature opening the current map info - * - * @api - * @param string $eventLabel (optional) Event on which the map info will be opened - * @return static - */ - public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) - { - $mapInfo = new MapInfo($this, $eventLabel); - $this->addScriptFeature($mapInfo); - return $this; - } - - /** - * Add a dynamic Feature to open a specific player profile - * - * @api - * @param string $login Login of the player - * @param string $eventLabel (optional) Event on which the player profile will be opened - * @return static - */ - public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) - { - $playerProfile = new PlayerProfile($login, $this, $eventLabel); - $this->addScriptFeature($playerProfile); - return $this; - } - - /** - * Add a dynamic Feature playing a UISound - * - * @api - * @param string $soundName UISound name - * @param int $variant (optional) Sound variant - * @param string $eventLabel (optional) Event on which the sound will be played - * @return static - */ - public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) - { - $uiSound = new UISound($soundName, $this, $variant, $eventLabel); - $this->addScriptFeature($uiSound); - return $this; - } - - /** - * Add a dynamic Feature toggling another Control - * - * @api - * @param Control $toggledControl Toggled Control - * @param string $labelName (optional) Script label name - * @param bool $onlyShow (optional) If it should only show the Control but not toggle - * @param bool $onlyHide (optional) If it should only hide the Control but not toggle - * @return static - */ - public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) - { - $toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide); - $this->addScriptFeature($toggle); - return $this; - } - - /** - * Add a dynamic Feature showing a Tooltip on hovering - * - * @api - * @param Control $tooltipControl Tooltip Control - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @return static - */ - public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) - { - $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert); - $this->addScriptFeature($tooltip); - return $this; - } - - /** - * Add a dynamic Feature showing a Tooltip on hovering - * - * @api - * @param Label $tooltipLabel Tooltip Label - * @param string $text Text to display on the Tooltip Label - * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click - * @param bool $invert (optional) Whether the visibility toggling should be inverted - * @return static - */ - public function addTooltipLabelFeature(Label $tooltipLabel, $text, $stayOnClick = false, $invert = false) - { - $tooltip = new Tooltip($this, $tooltipLabel, $stayOnClick, $invert, $text); - $this->addScriptFeature($tooltip); - return $this; - } - - /** - * Add a custom Control Script text part - * - * @api - * @param string $scriptText Script text - * @param string $label (optional) Script label name - * @return static - */ - public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) - { - $customText = new ControlScript($this, $scriptText, $label); - $this->addScriptFeature($customText); - return $this; - } - - /** - * @see Renderable::render() - */ - public function render(\DOMDocument $domDocument) - { - $domElement = $domDocument->createElement($this->getTagName()); - if ($this->controlId) { - $domElement->setAttribute("id", $this->controlId); - } - if ($this->posX || $this->posY || $this->posZ) { - $domElement->setAttribute("posn", "{$this->posX} {$this->posY} {$this->posZ}"); - } - if ($this->posZ) { - $domElement->setAttribute("z-index", $this->posZ); - } - if ($this->width >= 0. || $this->height >= 0.) { - $domElement->setAttribute("sizen", "{$this->width} {$this->height}"); - } - if ($this->horizontalAlign) { - $domElement->setAttribute("halign", $this->horizontalAlign); - } - if ($this->verticalAlign) { - $domElement->setAttribute("valign", $this->verticalAlign); - } - if ($this->scale != 1.) { - $domElement->setAttribute("scale", $this->scale); - } - if (!$this->visible) { - $domElement->setAttribute("hidden", "1"); - } - if ($this->rotation) { - $domElement->setAttribute("rot", $this->rotation); - } - if (!empty($this->classes)) { - $classes = implode(" ", $this->classes); - $domElement->setAttribute("class", $classes); - } - foreach ($this->dataAttributes as $dataAttributeName => $dataAttributeValue) { - $domElement->setAttribute("data-" . $dataAttributeName, $dataAttributeValue); - } - return $domElement; - } - - /** - * Get the tag name of the Control - * - * @return string - */ - abstract public function getTagName(); - - /** - * Get the ManiaScript class of the Control - * - * @return string - */ - abstract public function getManiaScriptClass(); + /* + * Constants + */ + const CENTER = 'center'; + const CENTER2 = 'center2'; + const TOP = 'top'; + const RIGHT = 'right'; + const BOTTOM = 'bottom'; + const LEFT = 'left'; + + /** + * @var string $controlId Control Id + */ + protected $controlId = null; + + /** + * @var float $posX X position + */ + protected $posX = 0.; + + /** + * @var float $posY Y position + */ + protected $posY = 0.; + + /** + * @var float $posZ Z position + */ + protected $posZ = 0.; + + /** + * @var float $width Width + */ + protected $width = -1.; + + /** + * @var float $height Height + */ + protected $height = -1.; + + /** + * @var string $horizontalAlign Horizontal alignment + */ + protected $horizontalAlign = self::CENTER; + + /** + * @var string $verticalAlign Vertical alignment + */ + protected $verticalAlign = self::CENTER2; + + /** + * @var float $scale Scale + */ + protected $scale = 1.; + + /** + * @var bool $visible Visibility + */ + protected $visible = true; + + /** + * @var float $rotation Rotation + */ + protected $rotation = 0.; + + /** + * @var string[] $classes Style classes + */ + protected $classes = array(); + + /** + * @var mixed[] $dataAttributes Data attributes + */ + protected $dataAttributes = array(); + + /** + * @var ScriptFeature[] $scriptFeatures Script Features + */ + protected $scriptFeatures = array(); + + /** + * Create a new Control + * + * @api + * @param string $controlId (optional) Control Id + * @return static + */ + public static function create($controlId = null) + { + return new static($controlId); + } + + /** + * Construct a new Control + * + * @api + * @param string $controlId (optional) Control Id + */ + public function __construct($controlId = null) + { + if ($controlId) { + $this->setId($controlId); + } + } + + /** + * @see Identifiable::getId() + */ + public function getId() + { + return $this->controlId; + } + + /** + * @see Identifiable::setId() + */ + public function setId($controlId) + { + $this->controlId = (string)$controlId; + return $this; + } + + /** + * @see Identifiable::checkId() + */ + public function checkId() + { + return UniqueID::check($this); + } + + /** + * Get the X position + * + * @api + * @return float + */ + public function getX() + { + return $this->posX; + } + + /** + * Set the X position + * + * @api + * @param float $posX Horizontal position + * @return static + */ + public function setX($posX) + { + $this->posX = (float)$posX; + return $this; + } + + /** + * Get the Y position + * + * @api + * @return float + */ + public function getY() + { + return $this->posY; + } + + /** + * Set the Y position + * + * @api + * @param float $posY Vertical position + * @return static + */ + public function setY($posY) + { + $this->posY = (float)$posY; + return $this; + } + + /** + * Get the Z position + * + * @api + * @return float + */ + public function getZ() + { + return $this->posZ; + } + + /** + * Set the Z position + * + * @api + * @param float $posZ Depth + * @return static + */ + public function setZ($posZ) + { + $this->posZ = (float)$posZ; + return $this; + } + + /** + * Set the Control position + * + * @api + * @param float $posX Horizontal position + * @param float $posY Vertical position + * @param float $posZ (optional) Depth + * @return static + */ + public function setPosition($posX, $posY, $posZ = null) + { + $this->setX($posX) + ->setY($posY); + if ($posZ !== null) { + $this->setZ($posZ); + } + return $this; + } + + /** + * Get the width + * + * @api + * @return float + */ + public function getWidth() + { + return $this->width; + } + + /** + * Set the width + * + * @api + * @param float $width Control width + * @return static + */ + public function setWidth($width) + { + $this->width = (float)$width; + return $this; + } + + /** + * Get the height + * + * @api + * @return float + */ + public function getHeight() + { + return $this->height; + } + + /** + * Set the height + * + * @api + * @param float $height Control height + * @return static + */ + public function setHeight($height) + { + $this->height = (float)$height; + return $this; + } + + /** + * Set the size + * + * @api + * @param float $width Control width + * @param float $height Control height + * @return static + */ + public function setSize($width, $height) + { + return $this->setWidth($width) + ->setHeight($height); + } + + /** + * Get the horizontal alignment + * + * @api + * @return string + */ + public function getHorizontalAlign() + { + return $this->horizontalAlign; + } + + /** + * Set the horizontal alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @return static + * @deprecated Use setHorizontalAlign() + * @see Control::setHorizontalAlign() + */ + public function setHAlign($horizontalAlign) + { + return $this->setHorizontalAlign($horizontalAlign); + } + + /** + * Set the horizontal alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @return static + */ + public function setHorizontalAlign($horizontalAlign) + { + $this->horizontalAlign = (string)$horizontalAlign; + return $this; + } + + /** + * Get the vertical alignment + * + * @api + * @return string + */ + public function getVerticalAlign() + { + return $this->verticalAlign; + } + + /** + * Set the vertical alignment + * + * @api + * @param string $verticalAlign Vertical alignment + * @return static + * @deprecated Use setVerticalAlign() + * @see Control::setVerticalAlign() + */ + public function setVAlign($verticalAlign) + { + return $this->setVerticalAlign($verticalAlign); + } + + /** + * Set the vertical alignment + * + * @api + * @param string $verticalAlign Vertical alignment + * @return static + */ + public function setVerticalAlign($verticalAlign) + { + $this->verticalAlign = (string)$verticalAlign; + return $this; + } + + /** + * Set the horizontal and the vertical alignment + * + * @api + * @param string $horizontalAlign Horizontal alignment + * @param string $verticalAlign Vertical alignment + * @return static + */ + public function setAlign($horizontalAlign, $verticalAlign) + { + return $this->setHorizontalAlign($horizontalAlign) + ->setVerticalAlign($verticalAlign); + } + + /** + * Center the alignment + * + * @api + * @return static + */ + public function centerAlign() + { + return $this->setAlign(self::CENTER, self::CENTER2); + } + + /** + * Clear the alignment + * + * @api + * @return static + */ + public function clearAlign() + { + $this->horizontalAlign = null; + $this->verticalAlign = null; + return $this; + } + + /** + * Get the scale + * + * @api + * @return float + */ + public function getScale() + { + return $this->scale; + } + + /** + * Set the scale + * + * @api + * @param float $scale Control scale + * @return static + */ + public function setScale($scale) + { + $this->scale = (float)$scale; + return $this; + } + + /** + * Get the visibility + * + * @api + * @return bool + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set the visibility + * + * @api + * @param bool $visible If the Control should be visible + * @return static + */ + public function setVisible($visible) + { + $this->visible = $visible; + return $this; + } + + /** + * Get the rotation + * + * @api + * @return float + */ + public function getRotation() + { + return $this->rotation; + } + + /** + * Set the rotation + * + * @api + * @param float $rotation Control rotation + * @return static + */ + public function setRotation($rotation) + { + $this->rotation = (float)$rotation; + return $this; + } + + /** + * Get style classes + * + * @api + * @return string[] + */ + public function getClasses() + { + return $this->classes; + } + + /** + * Add a new style class + * + * @api + * @param string $class Style class + * @return static + */ + public function addClass($class) + { + $class = (string)$class; + if (!in_array($class, $this->classes)) { + array_push($this->classes, $class); + } + return $this; + } + + /** + * Add new style classes + * + * @api + * @param string[] $classes Style classes + * @return static + */ + public function addClasses(array $classes) + { + foreach ($classes as $class) { + $this->addClass($class); + } + return $this; + } + + /** + * Remove all style classes + * + * @api + * @return static + */ + public function removeAllClasses() + { + $this->classes = array(); + return $this; + } + + /** + * Check if a data attribute is set + * + * @api + * @param string $name Name + * @return bool + */ + public function hasDataAttribute($name) + { + return isset($this->dataAttributes[$name]); + } + + /** + * Get data attribute + * + * @api + * @param string $name Name + * @return mixed + */ + public function getDataAttribute($name) + { + if (isset($this->dataAttributes[$name])) { + return $this->dataAttributes[$name]; + } + return null; + } + + /** + * Get data attributes + * + * @api + * @return mixed[] + */ + public function getDataAttributes() + { + return $this->dataAttributes; + } + + /** + * Add data attribute + * + * @api + * @param string $name Name + * @param mixed $value Value + * @return static + */ + public function addDataAttribute($name, $value) + { + $this->dataAttributes[$name] = $value; + return $this; + } + + /** + * Add multiple data attributes + * + * @api + * @param mixed[] $dataAttributes Data attributes + * @return static + */ + public function addDataAttributes(array $dataAttributes) + { + foreach ($dataAttributes as $name => $value) { + $this->addDataAttribute($name, $value); + } + return $this; + } + + /** + * Set data attributes (replacing all previous attributes) + * + * @api + * @param mixed[] $dataAttributes Data attributes + * @return static + */ + public function setDataAttributes(array $dataAttributes) + { + return $this->removeAllDataAttributes() + ->addDataAttributes($dataAttributes); + } + + /** + * Remove data attribute + * + * @api + * @param string $name Name + * @return static + */ + public function removeDataAttribute($name) + { + unset($this->dataAttributes[$name]); + return $this; + } + + /** + * Remove all data attributes + * + * @api + * @return static + */ + public function removeAllDataAttributes() + { + $this->dataAttributes = array(); + return $this; + } + + /** + * @see ScriptFeatureable::getScriptFeatures() + */ + public function getScriptFeatures() + { + return $this->scriptFeatures; + } + + /** + * Add a new Script Feature + * + * @api + * @param ScriptFeature $scriptFeature Script Feature + * @return static + */ + public function addScriptFeature(ScriptFeature $scriptFeature) + { + if (!in_array($scriptFeature, $this->scriptFeatures, true)) { + array_push($this->scriptFeatures, $scriptFeature); + } + return $this; + } + + /** + * Add new Script Features + * + * @api + * @param ScriptFeature[] $scriptFeatures Script Features + * @return static + */ + public function addScriptFeatures(array $scriptFeatures) + { + foreach ($scriptFeatures as $scriptFeature) { + $this->addScriptFeature($scriptFeature); + } + return $this; + } + + /** + * Remove all Script Features + * + * @api + * @return static + * @deprecated Use removeAllScriptFeatures() + * @see Control::removeAllScriptFeatures() + */ + public function removeScriptFeatures() + { + return $this->removeAllScriptFeatures(); + } + + /** + * Remove all Script Features + * + * @api + * @return static + */ + public function removeAllScriptFeatures() + { + $this->scriptFeatures = array(); + return $this; + } + + /** + * Add a dynamic Action Trigger + * + * @api + * @param string $actionName Action to trigger + * @param string $eventLabel (optional) Event on which the action is triggered + * @return static + */ + public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) + { + $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel); + $this->addScriptFeature($actionTrigger); + return $this; + } + + /** + * Add a dynamic Feature opening the current map info + * + * @api + * @param string $eventLabel (optional) Event on which the map info will be opened + * @return static + */ + public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) + { + $mapInfo = new MapInfo($this, $eventLabel); + $this->addScriptFeature($mapInfo); + return $this; + } + + /** + * Add a dynamic Feature to open a specific player profile + * + * @api + * @param string $login Login of the player + * @param string $eventLabel (optional) Event on which the player profile will be opened + * @return static + */ + public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) + { + $playerProfile = new PlayerProfile($login, $this, $eventLabel); + $this->addScriptFeature($playerProfile); + return $this; + } + + /** + * Add a dynamic Feature playing a UISound + * + * @api + * @param string $soundName UISound name + * @param int $variant (optional) Sound variant + * @param string $eventLabel (optional) Event on which the sound will be played + * @return static + */ + public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) + { + $uiSound = new UISound($soundName, $this, $variant, $eventLabel); + $this->addScriptFeature($uiSound); + return $this; + } + + /** + * Add a dynamic Feature toggling another Control + * + * @api + * @param Control $toggledControl Toggled Control + * @param string $labelName (optional) Script label name + * @param bool $onlyShow (optional) If it should only show the Control but not toggle + * @param bool $onlyHide (optional) If it should only hide the Control but not toggle + * @return static + */ + public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) + { + $toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide); + $this->addScriptFeature($toggle); + return $this; + } + + /** + * Add a dynamic Feature showing a Tooltip on hovering + * + * @api + * @param Control $tooltipControl Tooltip Control + * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click + * @param bool $invert (optional) Whether the visibility toggling should be inverted + * @return static + */ + public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) + { + $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert); + $this->addScriptFeature($tooltip); + return $this; + } + + /** + * Add a dynamic Feature showing a Tooltip on hovering + * + * @api + * @param Label $tooltipLabel Tooltip Label + * @param string $text Text to display on the Tooltip Label + * @param bool $stayOnClick (optional) Whether the Tooltip should stay on click + * @param bool $invert (optional) Whether the visibility toggling should be inverted + * @return static + */ + public function addTooltipLabelFeature(Label $tooltipLabel, $text, $stayOnClick = false, $invert = false) + { + $tooltip = new Tooltip($this, $tooltipLabel, $stayOnClick, $invert, $text); + $this->addScriptFeature($tooltip); + return $this; + } + + /** + * Add a custom Control Script text part + * + * @api + * @param string $scriptText Script text + * @param string $label (optional) Script label name + * @return static + */ + public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) + { + $customText = new ControlScript($this, $scriptText, $label); + $this->addScriptFeature($customText); + return $this; + } + + /** + * @see Renderable::render() + */ + public function render(\DOMDocument $domDocument) + { + $domElement = $domDocument->createElement($this->getTagName()); + if ($this->controlId) { + $domElement->setAttribute("id", $this->controlId); + } + if ($this->posX || $this->posY) { + $domElement->setAttribute("pos", "{$this->posX} {$this->posY}"); + } + if ($this->posX || $this->posY || $this->posZ) { + // backwards-compatibility + $domElement->setAttribute("posn", "{$this->posX} {$this->posY} {$this->posZ}"); + } + if ($this->posZ) { + $domElement->setAttribute("z-index", $this->posZ); + } + if ($this->width >= 0. || $this->height >= 0.) { + $domElement->setAttribute("size", "{$this->width} {$this->height}"); + // backwards-compatibility + $domElement->setAttribute("sizen", "{$this->width} {$this->height}"); + if ($this->width >= 0.) { + // backwards-compatibility + $domElement->setAttribute("width", $this->width); + } + if ($this->height >= 0.) { + // backwards-compatibility + $domElement->setAttribute("height", $this->height); + } + } + if ($this->horizontalAlign) { + $domElement->setAttribute("halign", $this->horizontalAlign); + } + if ($this->verticalAlign) { + $domElement->setAttribute("valign", $this->verticalAlign); + } + if ($this->scale != 1.) { + $domElement->setAttribute("scale", $this->scale); + } + if (!$this->visible) { + $domElement->setAttribute("hidden", "1"); + } + if ($this->rotation) { + $domElement->setAttribute("rot", $this->rotation); + } + if ($this->classes) { + $classes = implode(" ", $this->classes); + $domElement->setAttribute("class", $classes); + } + foreach ($this->dataAttributes as $dataAttributeName => $dataAttributeValue) { + $domElement->setAttribute("data-" . $dataAttributeName, $dataAttributeValue); + } + return $domElement; + } + + /** + * Get the tag name of the Control + * + * @return string + */ + abstract public function getTagName(); + + /** + * Get the ManiaScript class of the Control + * + * @return string + */ + abstract public function getManiaScriptClass(); } From e6afd274401ef39da4a2d764322312abc5559c6e Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 17:58:04 +0200 Subject: [PATCH 62/73] labelline height default --- core/Manialinks/LabelLine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Manialinks/LabelLine.php b/core/Manialinks/LabelLine.php index cdfad8b8..d562dc23 100644 --- a/core/Manialinks/LabelLine.php +++ b/core/Manialinks/LabelLine.php @@ -52,7 +52,7 @@ class LabelLine implements UsageInformationAble { } if ($width) { $label->setWidth($width); - $label->setHeight(5); //TODO verify if 5 is ok for everywhere + $label->setHeight(0); //TODO verify if 5 is ok for everywhere } $this->addLabel($label); } From ee2facb427d683c9c29e6a7638445edc92009f01 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 19:02:18 +0200 Subject: [PATCH 63/73] split onHit / onNearMiss / onArmorEmpty (with common base) --- core/Callbacks/ShootManiaCallbacks.php | 10 +++--- .../ShootMania/OnArmorEmptyStructure.php | 14 ++++++++ ... OnHitNearMissArmorEmptyBaseStructure.php} | 31 ++--------------- .../Structures/ShootMania/OnHitStructure.php | 33 +++++++++++++++++++ .../ShootMania/OnNearMissStructure.php | 32 ++++++++++++++++++ 5 files changed, 88 insertions(+), 32 deletions(-) create mode 100644 core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php rename core/Callbacks/Structures/ShootMania/{OnHitNearMissArmorEmptyStructure.php => OnHitNearMissArmorEmptyBaseStructure.php} (77%) create mode 100644 core/Callbacks/Structures/ShootMania/OnHitStructure.php create mode 100644 core/Callbacks/Structures/ShootMania/OnNearMissStructure.php diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 73db33ed..93ccbba7 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -6,10 +6,12 @@ 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\OnHitNearMissArmorEmptyStructure; +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; @@ -77,13 +79,13 @@ class ShootManiaCallbacks implements CallbackListener { $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 OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + $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 OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + $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 OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + $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)); diff --git a/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php new file mode 100644 index 00000000..e6dd43e1 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php @@ -0,0 +1,14 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure { + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php similarity index 77% rename from core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php rename to core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php index f0b56e2c..d100f84e 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php @@ -10,17 +10,15 @@ use ManiaControl\Players\Player; /** - * Structure Class for the OnHit Structure Callback + * Structure Base Class for the OnHit/OnNearMiss/OnArmorEmpty Structure Callback * * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class OnHitNearMissArmorEmptyStructure extends BaseStructure { +class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure { private $time; private $weapon; - private $damage; - private $distance = 0; //Note no distance on the OnHit and ArmorEmpty yet private $shooterPosition; private $victimPosition; @@ -54,14 +52,6 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { $this->victimPosition->setY($jsonObj->victimposition->y); $this->victimPosition->setZ($jsonObj->victimposition->z); - if (property_exists($this->getPlainJsonObject(), 'distance')) { - $this->distance = $this->getPlainJsonObject()->distance; - } - - if (property_exists($this->getPlainJsonObject(), 'damage')) { - $this->damage = $this->getPlainJsonObject()->damage; - } - $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); } @@ -85,16 +75,6 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { return $this->weapon; } - /** - * < Amount of Damage done by the hit (only on onHit) - * TODO base class and extend properties) - * - * @return int - */ - public function getDamage() { - return $this->damage; - } - /** * < Position of the Shooter at the time * @@ -131,11 +111,6 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { return $this->victim; } - /** - * @return mixed - */ - public function getDistance() { - return $this->distance; - } + } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnHitStructure.php b/core/Callbacks/Structures/ShootMania/OnHitStructure.php new file mode 100644 index 00000000..94395dea --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnHitStructure.php @@ -0,0 +1,33 @@ + + * @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; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php b/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php new file mode 100644 index 00000000..4f74bd28 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php @@ -0,0 +1,32 @@ + + * @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; + } +} \ No newline at end of file From e9ed9d910cc76952d659db12f28d56c5742ab40b Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 19:39:23 +0200 Subject: [PATCH 64/73] refactored Scores Structure --- .../Common/CommonScoresStructure.php | 119 ++++++++++++++++++ .../Common/Models/CommonPlayerScore.php | 88 +++++++++++++ .../Common/Models/CommonTeamScore.php | 93 ++++++++++++++ .../ShootMania/Models/PlayerScore.php | 82 +----------- .../ShootMania/Models/TeamScore.php | 84 +------------ .../ShootMania/OnScoresStructure.php | 86 +------------ .../TrackMania/Models/PlayerScore.php | 110 +++++----------- .../TrackMania/Models/TeamScore.php | 84 +------------ .../TrackMania/OnScoresStructure.php | 86 +------------ 9 files changed, 353 insertions(+), 479 deletions(-) create mode 100644 core/Callbacks/Structures/Common/CommonScoresStructure.php create mode 100644 core/Callbacks/Structures/Common/Models/CommonPlayerScore.php create mode 100644 core/Callbacks/Structures/Common/Models/CommonTeamScore.php diff --git a/core/Callbacks/Structures/Common/CommonScoresStructure.php b/core/Callbacks/Structures/Common/CommonScoresStructure.php new file mode 100644 index 00000000..60cec626 --- /dev/null +++ b/core/Callbacks/Structures/Common/CommonScoresStructure.php @@ -0,0 +1,119 @@ + + * @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; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/Common/Models/CommonPlayerScore.php b/core/Callbacks/Structures/Common/Models/CommonPlayerScore.php new file mode 100644 index 00000000..2b575184 --- /dev/null +++ b/core/Callbacks/Structures/Common/Models/CommonPlayerScore.php @@ -0,0 +1,88 @@ +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; + } + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/Common/Models/CommonTeamScore.php b/core/Callbacks/Structures/Common/Models/CommonTeamScore.php new file mode 100644 index 00000000..362e5d04 --- /dev/null +++ b/core/Callbacks/Structures/Common/Models/CommonTeamScore.php @@ -0,0 +1,93 @@ + + * @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; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php b/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php index 8e695dbc..0b03101d 100644 --- a/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php +++ b/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php @@ -2,9 +2,8 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; -use ManiaControl\General\UsageInformationAble; -use ManiaControl\General\UsageInformationTrait; -use ManiaControl\Players\Player; +use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore; + /** * PlayerScore Model @@ -13,81 +12,6 @@ use ManiaControl\Players\Player; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PlayerScore implements UsageInformationAble { - use UsageInformationTrait; +class PlayerScore extends CommonPlayerScore { - private $player; - private $rank; - private $roundPoints; - private $mapPoints; - - /** - * Returns the Player - * - * @return 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; - } } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/Models/TeamScore.php b/core/Callbacks/Structures/ShootMania/Models/TeamScore.php index b1557bb5..e1e1a80b 100644 --- a/core/Callbacks/Structures/ShootMania/Models/TeamScore.php +++ b/core/Callbacks/Structures/ShootMania/Models/TeamScore.php @@ -2,92 +2,14 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; -use ManiaControl\General\UsageInformationAble; -use ManiaControl\General\UsageInformationTrait; +use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore; /** - * TeamScore Model + * Shootmania TeamScore Model * * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class TeamScore 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; - } +class TeamScore extends CommonTeamScore { } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php index a759d015..1a396224 100644 --- a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php @@ -3,41 +3,28 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; -use ManiaControl\Callbacks\Structures\BaseStructure; +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 OnScores Structure Callback + * Structure Class for the Shootmania OnScores Structure Callback * * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class OnScoresStructure extends BaseStructure { - private $responseId; - private $section; - private $useTeams; - private $winnerTeam; - private $winnerPlayer; - private $teamScores = array(); - private $playerScores = array(); +class OnScoresStructure extends CommonScoresStructure { - //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 OnScoresStructure) $teamScore = new TeamScore(); $teamScore->setId($team->id); $teamScore->setName($team->name); @@ -59,67 +46,4 @@ class OnScoresStructure extends BaseStructure { } } - - /** - * 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 PlayerScore[] - */ - public function getPlayerScores() { - return $this->playerScores; - } } \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php index 0eb07753..c955172c 100644 --- a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php +++ b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php @@ -2,10 +2,10 @@ namespace ManiaControl\Callbacks\Structures\TrackMania\Models; -use ManiaControl\General\UsageInformationAble; -use ManiaControl\General\UsageInformationTrait; +use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore; + use ManiaControl\Players\Player; -//TODO proper return descriptions on getter methods +//TODO proper return descriptions on getter methods -> use autogenerate for setter/getter + docs /** * PlayerScore Model * @@ -13,33 +13,12 @@ use ManiaControl\Players\Player; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PlayerScore implements UsageInformationAble { - use UsageInformationTrait; +class PlayerScore extends CommonPlayerScore { - private $player; - private $rank; - private $roundPoints; - private $mapPoints; - private $matchPoints; - private $bestraceTime; - private $bestlapTime; + private $bestRaceTime; + private $bestLapTime; private $stuntScore; - /** - * Returns the Player - * - * @return Player - */ - public function getPlayer() { - return $this->player; - } - - /** - * @param \ManiaControl\Players\Player $player - */ - public function setPlayer(Player $player) { - $this->player = $player; - } /** * Returns the Rank @@ -59,68 +38,24 @@ class PlayerScore implements UsageInformationAble { $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; - } - /** * Gets the bestRaceTime * * @param int $bestraceTime */ - public function getbestraceTime(){ - return $this->bestraceTime; + public function getBestraceTime(){ + return $this->bestRaceTime; } - - /** - * Gets the MapPoints - * - * @return int - */ - public function getMatchPoints(){ - return $this->matchPoints; - } - /** * Gets the bestlapTime * * @param int $bestlapTime */ - public function getbestlapTime(){ - return $this->bestlapTime; + public function getBestlapTime(){ + return $this->bestLapTime; } /** @@ -128,8 +63,29 @@ class PlayerScore implements UsageInformationAble { * * @param int $bestraceTime */ - public function getstuntScore(){ + 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; + } + } \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/Models/TeamScore.php b/core/Callbacks/Structures/TrackMania/Models/TeamScore.php index 07fe30a3..756721b9 100644 --- a/core/Callbacks/Structures/TrackMania/Models/TeamScore.php +++ b/core/Callbacks/Structures/TrackMania/Models/TeamScore.php @@ -2,92 +2,14 @@ namespace ManiaControl\Callbacks\Structures\TrackMania\Models; -use ManiaControl\General\UsageInformationAble; -use ManiaControl\General\UsageInformationTrait; +use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore; /** - * TeamScore Model + * Shootmania TeamScore Model * * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class TeamScore 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; - } +class TeamScore extends CommonTeamScore { } \ No newline at end of file diff --git a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php index 1ce1bb14..fac4ad5f 100644 --- a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php @@ -2,41 +2,25 @@ namespace ManiaControl\Callbacks\Structures\TrackMania; - -use ManiaControl\Callbacks\Structures\BaseStructure; +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 OnScores Structure Callback + * Structure Class for the Trackmania OnScores Structure Callback * * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class OnScoresStructure extends BaseStructure { - private $responseId; - private $section; - private $useTeams; - private $winnerTeam; - private $winnerPlayer; - private $teamScores = array(); - private $playerScores = array(); +class OnScoresStructure extends CommonScoresStructure { - //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) { $teamScore = new TeamScore(); $teamScore->setId($team->id); @@ -54,72 +38,14 @@ class OnScoresStructure extends BaseStructure { $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; } } - /** - * 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 PlayerScore[] - */ - public function getPlayerScores() { - return $this->playerScores; - } } \ No newline at end of file From 191235b2462ac006e475b47405caac0fe941bca7 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 19:40:10 +0200 Subject: [PATCH 65/73] refactored scoressstructures --- .../Structures/ShootMania/OnScoresStructure.php | 12 ------------ .../Structures/TrackMania/OnScoresStructure.php | 13 +------------ 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php index 1a396224..53334379 100644 --- a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php @@ -23,18 +23,6 @@ class OnScoresStructure extends CommonScoresStructure { $jsonObj = $this->getPlainJsonObject(); - foreach ($jsonObj->teams as $team) { - //if($this instanceof OnScoresStructure) - $teamScore = new 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 - } - foreach ($jsonObj->players as $jsonPlayer) { $playerScore = new PlayerScore(); $playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login)); diff --git a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php index fac4ad5f..edb1ab66 100644 --- a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php @@ -20,18 +20,7 @@ class OnScoresStructure extends CommonScoresStructure { parent::__construct($maniaControl, $data); $jsonObj = $this->getPlainJsonObject(); - - foreach ($jsonObj->teams as $team) { - $teamScore = new 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 - } - + foreach ($jsonObj->players as $jsonPlayer) { $playerScore = new PlayerScore(); $playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login)); From 1369aab4011ff6d67bddec1978bbb88af41b1d46 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 19:49:45 +0200 Subject: [PATCH 66/73] moved basestructure + changed namespace --- core/Callbacks/Structures/{ => Common}/BaseStructure.php | 2 +- core/Callbacks/Structures/Common/CommonScoresStructure.php | 1 - core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php | 2 +- core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php | 2 +- .../Structures/ShootMania/OnActionCustomEventStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnActionEvent.php | 2 +- core/Callbacks/Structures/ShootMania/OnCaptureStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnCommandStructure.php | 2 +- .../Callbacks/Structures/ShootMania/OnDefaultEventStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php | 2 +- .../ShootMania/OnHitNearMissArmorEmptyBaseStructure.php | 2 +- .../Callbacks/Structures/ShootMania/OnPlayerObjectStructure.php | 2 +- .../Structures/ShootMania/OnPlayerRequestActionChange.php | 2 +- .../Structures/ShootMania/OnPlayerRequestRespawnStructure.php | 2 +- .../Structures/ShootMania/OnPlayerTriggersSectorStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnShootStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php | 2 +- core/Callbacks/Structures/TrackMania/OnCommandStructure.php | 2 +- .../Callbacks/Structures/TrackMania/OnDefaultEventStructure.php | 2 +- .../Structures/TrackMania/OnEventStartLineStructure.php | 2 +- .../Structures/TrackMania/OnEventWayPointStructure.php | 2 +- core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php | 2 +- 22 files changed, 21 insertions(+), 22 deletions(-) rename core/Callbacks/Structures/{ => Common}/BaseStructure.php (94%) diff --git a/core/Callbacks/Structures/BaseStructure.php b/core/Callbacks/Structures/Common/BaseStructure.php similarity index 94% rename from core/Callbacks/Structures/BaseStructure.php rename to core/Callbacks/Structures/Common/BaseStructure.php index 4596c962..109c2c6f 100644 --- a/core/Callbacks/Structures/BaseStructure.php +++ b/core/Callbacks/Structures/Common/BaseStructure.php @@ -1,6 +1,6 @@ Date: Thu, 30 Mar 2017 20:27:57 +0200 Subject: [PATCH 67/73] updated async http requests --- core/ManiaExchange/ManiaExchangeManager.php | 20 ++++++++++++----- core/Plugins/PluginManager.php | 8 ++++++- core/Server/UsageReporter.php | 1 + core/Update/PluginUpdateManager.php | 14 ++++++++++-- core/Update/UpdateManager.php | 25 ++++++++++++--------- plugins/MCTeam/KarmaPlugin.php | 24 +++++++++++++------- 6 files changed, 65 insertions(+), 27 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index d7e78d06..55bf4c5f 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -2,7 +2,7 @@ namespace ManiaControl\ManiaExchange; -use ManiaControl\Files\AsynchronousFileReader; +use ManiaControl\Files\AsyncHttpRequest; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; @@ -18,7 +18,7 @@ use ManiaControl\Maps\MapManager; */ class ManiaExchangeManager implements UsageInformationAble { use UsageInformationTrait; - + /* * Constants * @deprecated SEARCH Constants @@ -170,7 +170,9 @@ class ManiaExchangeManager implements UsageInformationAble { $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; @@ -196,7 +198,9 @@ class ManiaExchangeManager implements UsageInformationAble { } $this->updateMapObjectsWithManiaExchangeIds($maps); - }, AsynchronousFileReader::CONTENT_TYPE_JSON); + }); + + $asyncHttpRequest->getData(); } /** @@ -267,7 +271,9 @@ class ManiaExchangeManager implements UsageInformationAble { $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); @@ -280,7 +286,9 @@ class ManiaExchangeManager implements UsageInformationAble { } } call_user_func($function, $mxMapInfo); - }, AsynchronousFileReader::CONTENT_TYPE_JSON); + }); + + $asyncHttpRequest->getData(); } /** diff --git a/core/Plugins/PluginManager.php b/core/Plugins/PluginManager.php index 2afdda4a..6445b350 100644 --- a/core/Plugins/PluginManager.php +++ b/core/Plugins/PluginManager.php @@ -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(); } } diff --git a/core/Server/UsageReporter.php b/core/Server/UsageReporter.php index 3c310370..e008aa42 100644 --- a/core/Server/UsageReporter.php +++ b/core/Server/UsageReporter.php @@ -84,6 +84,7 @@ class UsageReporter implements TimerListener { $url = ManiaControl::URL_WEBSERVICE . 'usagereport'; $asyncRequest = new AsyncHttpRequest($this->maniaControl, $url); + $asyncRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); $asyncRequest->setContent($usageReport); $asyncRequest->setCallable(function ($response, $error) { $response = json_decode($response); diff --git a/core/Update/PluginUpdateManager.php b/core/Update/PluginUpdateManager.php index cfe5dfae..dead77fd 100644 --- a/core/Update/PluginUpdateManager.php +++ b/core/Update/PluginUpdateManager.php @@ -6,6 +6,7 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; +use ManiaControl\Files\AsyncHttpRequest; use ManiaControl\Files\BackupUtil; use ManiaControl\Files\FileUtil; use ManiaControl\Logger; @@ -240,7 +241,9 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis * @param bool $update */ private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) { - $this->maniaControl->getFileReader()->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use ( + $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $pluginUpdateData->url); + $asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); + $asyncHttpRequest->setCallable(function ($updateFileContent, $error) use ( &$pluginUpdateData, &$player, &$update ) { if (!$updateFileContent || $error) { @@ -320,6 +323,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis } } }); + + $asyncHttpRequest->getData(); } /** @@ -355,7 +360,10 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis $pluginId = substr($actionId, strlen(InstallMenu::ACTION_PREFIX_INSTALL_PLUGIN)); $url = ManiaControl::URL_WEBSERVICE . 'plugins/' . $pluginId; - $this->maniaControl->getFileReader()->loadFile($url, function ($data, $error) use (&$player) { + + $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $url); + $asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); + $asyncHttpRequest->setCallable(function ($data, $error) use (&$player) { if ($error || !$data) { $message = "Error loading Plugin Install Data! {$error}"; $this->maniaControl->getChat()->sendError($message, $player); @@ -372,6 +380,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis $pluginUpdateData = new PluginUpdateData($data); $this->installPlugin($pluginUpdateData, $player); }); + + $asyncHttpRequest->getData(); } } diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index 385d07d7..376c4fc7 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -6,6 +6,7 @@ use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; +use ManiaControl\Files\AsyncHttpRequest; use ManiaControl\Files\BackupUtil; use ManiaControl\Files\FileUtil; use ManiaControl\Logger; @@ -143,7 +144,9 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener $updateChannel = $this->getCurrentUpdateChannelSetting(); $url = ManiaControl::URL_WEBSERVICE . 'versions?current=1&channel=' . $updateChannel; - $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) { if ($error) { Logger::logError('Error on UpdateCheck: ' . $error); return; @@ -156,6 +159,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener call_user_func($function, $updateData); } }); + + $asyncHttpRequest->getData(); } /** @@ -284,8 +289,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener // No update available return; } - if ($this->maniaControl->getPlayerManager()->getPlayerCount(false) > 0 - ) { + if ($this->maniaControl->getPlayerManager()->getPlayerCount(false) > 0) { // Server not empty return; } @@ -331,7 +335,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener } $updateData = $this->coreUpdateData; - $this->maniaControl->getFileReader()->loadFile($updateData->url, function ($updateFileContent, $error) use ( + + $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $updateData->url); + $asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); + $asyncHttpRequest->setCallable(function ($updateFileContent, $error) use ( $updateData, &$player ) { if (!$updateFileContent || $error) { @@ -393,6 +400,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener $this->maniaControl->restart(); }); + $asyncHttpRequest->getData(); return true; } @@ -419,8 +427,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener return; } // Announce available update - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATE) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATE)) { return; } @@ -447,8 +454,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener * @param Player $player */ public function handle_CheckUpdate(array $chatCallback, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATECHECK) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATECHECK)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } @@ -492,8 +498,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener * @param Player $player */ public function handle_CoreUpdate(array $chatCallback, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATE) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATE)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index 309bf1dc..b635d5fa 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -252,7 +252,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $this->mxKarma['connectionInProgress'] = true; - $this->maniaControl->getFileReader()->loadFile($query, function ($json, $error) use ($mxKarmaCode) { + $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $query); + $asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); + $asyncHttpRequest->setCallable(function ($json, $error) use ($mxKarmaCode) { $this->mxKarma['connectionInProgress'] = false; if ($error) { $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error: ' . $error); @@ -260,7 +262,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } $data = json_decode($json); if (!$data) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $json, $data); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error' . $json); return; } if ($data->success) { @@ -272,7 +274,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message); $this->mxKarma['connectionInProgress'] = false; } - }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); + }); + + $asyncHttpRequest->getData(1000); } /** @@ -287,15 +291,17 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $query .= '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey); $query .= '&activationHash=' . urlencode($hash); - $this->maniaControl->getFileReader()->loadFile($query, function ($json, $error) use ($query) { + $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $query); + $asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); + $asyncHttpRequest->setCallable(function ($json, $error) use ($query) { $this->mxKarma['connectionInProgress'] = false; if ($error) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error' . $error); return; } $data = json_decode($json); if (!$data) { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error' . $json); return; } if ($data->success && $data->data->activated) { @@ -308,12 +314,14 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $permission = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS); $this->maniaControl->getChat()->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission); } else { - $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message, $query); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error' . $data->data->message . $query); } Logger::logError("Error while activating Mania-Exchange Karma Session: " . $data->data->message); unset($this->mxKarma['session']); } - }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); + }); + + $asyncHttpRequest->getData(1000); } /** From 868c2d524bcfd38b10fae3c2e6187d821846f846 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 20:38:03 +0200 Subject: [PATCH 68/73] fixed cntent types --- core/ManiaControl.php | 2 +- core/Update/PluginUpdateManager.php | 1 - core/Update/UpdateManager.php | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index eb158f05..f1821fa1 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -52,7 +52,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.200'; + const VERSION = '0.201'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-03-23_18_00'; const SCRIPT_TIMEOUT = 10; diff --git a/core/Update/PluginUpdateManager.php b/core/Update/PluginUpdateManager.php index dead77fd..a6613f9f 100644 --- a/core/Update/PluginUpdateManager.php +++ b/core/Update/PluginUpdateManager.php @@ -242,7 +242,6 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis */ private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) { $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $pluginUpdateData->url); - $asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); $asyncHttpRequest->setCallable(function ($updateFileContent, $error) use ( &$pluginUpdateData, &$player, &$update ) { diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index 376c4fc7..185bc265 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -337,7 +337,6 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener $updateData = $this->coreUpdateData; $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $updateData->url); - $asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON); $asyncHttpRequest->setCallable(function ($updateFileContent, $error) use ( $updateData, &$player ) { From 25fe6f1df63d45a0fec0caac3fd8c9ae7cf9fd74 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 30 Mar 2017 22:04:29 +0200 Subject: [PATCH 69/73] small fixes --- core/Callbacks/Structures/Common/CommonScoresStructure.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/Callbacks/Structures/Common/CommonScoresStructure.php b/core/Callbacks/Structures/Common/CommonScoresStructure.php index 752a2c5a..33e3a138 100644 --- a/core/Callbacks/Structures/Common/CommonScoresStructure.php +++ b/core/Callbacks/Structures/Common/CommonScoresStructure.php @@ -29,10 +29,10 @@ class CommonScoresStructure extends BaseStructure { $jsonObj = $this->getPlainJsonObject(); - $this->responseId = $jsonObj->responseId; + $this->responseId = $jsonObj->responseid; $this->section = $jsonObj->section; - $this->useTeams = $jsonObj->useTeams; - $this->winnerTeam = $jsonObj->winnerTeam; + $this->useTeams = $jsonObj->useteams; + $this->winnerTeam = $jsonObj->winnerteam; $this->winnerPlayer = $this->maniaControl->getPlayerManager()->getPlayer($jsonObj->winnerplayer); From 7b6c6af73e033f534bbd6eda18c4452486c50cbf Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 31 Mar 2017 21:30:34 +0200 Subject: [PATCH 70/73] updated maniaplanet api --- .../Maniaplanet/DedicatedServer/Connection.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libs/Maniaplanet/DedicatedServer/Connection.php b/libs/Maniaplanet/DedicatedServer/Connection.php index e7962782..c2a3d53e 100755 --- a/libs/Maniaplanet/DedicatedServer/Connection.php +++ b/libs/Maniaplanet/DedicatedServer/Connection.php @@ -746,6 +746,24 @@ class Connection return $this->execute(ucfirst(__FUNCTION__).'ToLogin', array($logins, $link, $linkType), $multicall); } + /** + * Prior to loading next map, execute SendToServer url '#qjoin=login@title' + * Only available to Admin. + * Available since ManiaPlanet 4 + * @param $link + * @param bool $multicall + * @return bool + * @throws InvalidArgumentException + */ + function sendToServerAfterMatchEnd($link, $multicall = false){ + if(!is_string($link)) + throw new InvalidArgumentException('link = '.print_r($link, true)); + + $link = str_replace("maniaplanet://", "", $link); + + return $this->execute(ucfirst(__FUNCTION__), array($link), $multicall); + } + /** * Kick the player with the specified login, with an optional message. * Only available to Admin. From bd5e4b922efc2249f567ca7d80b18a7fa35483db Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 31 Mar 2017 22:07:00 +0200 Subject: [PATCH 71/73] updated statisticcollector --- .../OnHitNearMissArmorEmptyBaseStructure.php | 2 +- core/Statistics/StatisticCollector.php | 189 ++++++++++++++---- .../DedicatedServer/Connection.php | 2 +- 3 files changed, 154 insertions(+), 39 deletions(-) diff --git a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php index 3b7e24b9..d2786476 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php @@ -72,7 +72,7 @@ class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure { * @return int */ public function getWeapon() { - return $this->weapon; + return intval($this->weapon); } /** diff --git a/core/Statistics/StatisticCollector.php b/core/Statistics/StatisticCollector.php index d368d1ad..b3701733 100644 --- a/core/Statistics/StatisticCollector.php +++ b/core/Statistics/StatisticCollector.php @@ -5,6 +5,13 @@ namespace ManiaControl\Statistics; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\Callbacks\Structures\ShootMania\Models\Weapons; +use ManiaControl\Callbacks\Structures\ShootMania\OnArmorEmptyStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnHitStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnNearMissStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; @@ -16,7 +23,7 @@ use ManiaControl\Players\PlayerManager; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class StatisticCollector implements CallbackListener { +class StatisticCollector implements CallbackListener { //TODO remove old callbacks later /* * Constants */ @@ -47,11 +54,6 @@ class StatisticCollector implements CallbackListener { const SPECIAL_STAT_KILL_DEATH_RATIO = 'Kill / Death'; - const WEAPON_LASER = 1; - const WEAPON_ROCKET = 2; - const WEAPON_NUCLEUS = 3; - const WEAPON_ARROW = 5; - /* * Private properties */ @@ -73,6 +75,11 @@ class StatisticCollector implements CallbackListener { $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit'); $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'onPlayerDisconnect'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::SM_ONHIT, $this, 'onHitCallback'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::SM_ONSHOOT, $this, 'onShootCallback'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::SM_ONNEARMISS, $this, 'onNearMissCallback'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::SM_ONCAPTURE, $this, 'onCaptureCallback'); + // Settings $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLLECT_STATS_ENABLED, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS, 4); @@ -104,6 +111,118 @@ class StatisticCollector implements CallbackListener { $this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ARROW_SHOT); } + /** + * Checks if the Collecting is Enabled + * + * @return boolean + */ + public function isCollectingEnabled() { + return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED); + } + + + /** + * Check for the Minimum Amount of Players to collect + * + * @return bool + */ + public function checkForMinimumPlayers() { + // Check for Minimum PlayerCount + return ($this->maniaControl->getPlayerManager()->getPlayerCount() < $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)); + } + + /** + * Handles the onHitCallback + * + * @param \ManiaControl\Callbacks\Structures\ShootMania\OnHitStructure $structure + */ + public function onHitCallback(OnHitStructure $structure) { + if (!$this->isCollectingEnabled() || !$this->checkForMinimumPlayers()) { + return; + } + + if ($structure->getShooter()) { + $this->maniaControl->getStatisticManager()->incrementStat($this->getWeaponStat($structure->getWeapon(), false), $structure->getShooter()); + $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_HIT, $structure->getShooter()); + } + if ($structure->getVictim()) { + $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_GOT_HIT, $structure->getVictim()); + } + } + + /** + * Handles the onShoot Callback + * + * @param \ManiaControl\Callbacks\Structures\ShootMania\OnShootStructure $structure + */ + public function onShootCallback(OnShootStructure $structure) { + if (!$this->isCollectingEnabled() || !$this->checkForMinimumPlayers()) { + return; + } + + $this->handleOnShoot($structure->getShooter()->login, $structure->getWeapon()); + } + + /** + * Handles the OnNearMiss Callback + * + * @param \ManiaControl\Callbacks\Structures\ShootMania\OnNearMissStructure $structure + */ + public function onNearMissCallback(OnNearMissStructure $structure) { + if (!$this->isCollectingEnabled() || !$this->checkForMinimumPlayers()) { + return; + } + + $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_NEARMISS, $structure->getShooter()); + } + + + /** + * Handles the OnCapture Callback + * + * @param \ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure $structure + */ + public function onCaptureCallback(OnCaptureStructure $structure) { + if (!$this->isCollectingEnabled() || !$this->checkForMinimumPlayers()) { + return; + } + + foreach ($structure->getPlayerArray() as $player) { + $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_CAPTURE, $player); + } + } + + /** + * Handles the OnArmorEmpty Callback + * + * @param \ManiaControl\Callbacks\Structures\ShootMania\OnArmorEmptyStructure $structure + */ + public function onArmorEmptyCallback(OnArmorEmptyStructure $structure) { + if (!$this->isCollectingEnabled() || !$this->checkForMinimumPlayers()) { + return; + } + if ($structure->getShooter()) { + $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_KILL, $structure->getShooter()); + } + if ($structure->getVictim()) { + $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_DEATH, $structure->getVictim()); + } + } + + /** + * Handles the OnPlayerRequestRespawn Callback + * + * @param \ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure $structure + */ + public function onPlayerRequestRespawnCallback(OnPlayerRequestRespawnStructure $structure) { + if (!$this->isCollectingEnabled() || !$this->checkForMinimumPlayers()) { + return; + } + + $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_PLAYER_REQUEST_RESPAWN, $structure->getPlayer()); + } + + /** * Handle EndMap * @@ -111,8 +230,7 @@ class StatisticCollector implements CallbackListener { */ public function onEndMap(array $callback) { //Check for Minimum PlayerCount - if ($this->maniaControl->getPlayerManager()->getPlayerCount() < $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS) - ) { + if ($this->maniaControl->getPlayerManager()->getPlayerCount() < $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) { return; } @@ -131,8 +249,7 @@ class StatisticCollector implements CallbackListener { */ public function onPlayerDisconnect(Player $player) { // Check if Stat Collecting is enabled - if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED) - ) { + if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) { return; } @@ -153,19 +270,18 @@ class StatisticCollector implements CallbackListener { public function handleCallbacks(array $callback) { //TODO survivals // Check if Stat Collecting is enabled - if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED) - ) { + if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) { return; } // Check for Minimum PlayerCount - if ($this->maniaControl->getPlayerManager()->getPlayerCount() < $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS) - ) { + if ($this->maniaControl->getPlayerManager()->getPlayerCount() < $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) { return; } $callbackName = $callback[1][0]; + //TODO remove later switch ($callbackName) { case 'LibXmlRpc_OnShoot': $this->handleOnShoot($callback[1][1][0], $callback[1][1][1]); @@ -236,7 +352,7 @@ class StatisticCollector implements CallbackListener { case 'OnHit': $paramsObject = json_decode($callback[1][1]); if ($paramsObject && isset($paramsObject->Event)) { - $weapon = (int)$paramsObject->Event->WeaponNum; + $weapon = (int) $paramsObject->Event->WeaponNum; if (isset($paramsObject->Event->Shooter)) { $shooter = $this->maniaControl->getPlayerManager()->getPlayer($paramsObject->Event->Shooter->Login); if ($shooter) { @@ -262,7 +378,6 @@ class StatisticCollector implements CallbackListener { if ($shooter) { $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_KILL, $shooter); } - $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_KILL, $shooter); } } break; @@ -273,10 +388,10 @@ class StatisticCollector implements CallbackListener { $this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_PLAYER_REQUEST_RESPAWN, $player); } break; - case 'EndTurn': //TODO make it for other modes working + case 'EndTurn': //TODO make it for other modes working //TODO also not available in MP4 atm $paramsObject = json_decode($callback[1][1]); if ($paramsObject && is_array($paramsObject->ScoresTable)) { - $durationTime = (int)(($paramsObject->EndTime - $paramsObject->StartTime) / 1000); + $durationTime = (int) (($paramsObject->EndTime - $paramsObject->StartTime) / 1000); foreach ($paramsObject->ScoresTable as $score) { $player = $this->maniaControl->getPlayerManager()->getPlayer($score->Login); $this->maniaControl->getStatisticManager()->insertStat(self::STAT_PLAYTIME, $player, -1, $durationTime); @@ -293,8 +408,9 @@ class StatisticCollector implements CallbackListener { * @param int $weaponNumber */ private function handleOnShoot($login, $weaponNumber) { + //TODO update to player in MP4 if (!isset($this->onShootArray[$login])) { - $this->onShootArray[$login] = array(self::WEAPON_ROCKET => 0, self::WEAPON_ARROW => 0, self::WEAPON_NUCLEUS => 0, self::WEAPON_LASER => 0); + $this->onShootArray[$login] = array(Weapons::ROCKET => 0, Weapons::ARROW => 0, Weapons::NUCLEUS => 0, Weapons::LASER => 0); } if (!isset($this->onShootArray[$login][$weaponNumber])) { $this->onShootArray[$login][$weaponNumber] = 0; @@ -302,30 +418,29 @@ class StatisticCollector implements CallbackListener { $this->onShootArray[$login][$weaponNumber]++; //Write Shoot Data into database - if (array_sum($this->onShootArray[$login]) > $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ON_SHOOT_PRESTORE) - ) { + if (array_sum($this->onShootArray[$login]) > $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ON_SHOOT_PRESTORE)) { $player = $this->maniaControl->getPlayerManager()->getPlayer($login); - $rocketShots = $this->onShootArray[$login][self::WEAPON_ROCKET]; - $laserShots = $this->onShootArray[$login][self::WEAPON_LASER]; - $arrowShots = $this->onShootArray[$login][self::WEAPON_ARROW]; - $nucleusShots = $this->onShootArray[$login][self::WEAPON_NUCLEUS]; + $rocketShots = $this->onShootArray[$login][Weapons::ROCKET]; + $laserShots = $this->onShootArray[$login][Weapons::LASER]; + $arrowShots = $this->onShootArray[$login][Weapons::ARROW]; + $nucleusShots = $this->onShootArray[$login][Weapons::NUCLEUS]; if ($rocketShots > 0) { $this->maniaControl->getStatisticManager()->insertStat(self::STAT_ROCKET_SHOT, $player, $this->maniaControl->getServer()->index, $rocketShots); - $this->onShootArray[$login][self::WEAPON_ROCKET] = 0; + $this->onShootArray[$login][Weapons::ROCKET] = 0; } if ($laserShots > 0) { $this->maniaControl->getStatisticManager()->insertStat(self::STAT_LASER_SHOT, $player, $this->maniaControl->getServer()->index, $laserShots); - $this->onShootArray[$login][self::WEAPON_LASER] = 0; + $this->onShootArray[$login][Weapons::LASER] = 0; } if ($arrowShots > 0) { $this->maniaControl->getStatisticManager()->insertStat(self::STAT_ARROW_SHOT, $player, $this->maniaControl->getServer()->index, $arrowShots); - $this->onShootArray[$login][self::WEAPON_ARROW] = 0; + $this->onShootArray[$login][Weapons::ARROW] = 0; } if ($nucleusShots > 0) { $this->maniaControl->getStatisticManager()->insertStat(self::STAT_NUCLEUS_SHOT, $player, $this->maniaControl->getServer()->index, $nucleusShots); - $this->onShootArray[$login][self::WEAPON_NUCLEUS] = 0; + $this->onShootArray[$login][Weapons::NUCLEUS] = 0; } $this->maniaControl->getStatisticManager()->insertStat(self::STAT_ON_SHOOT, $player, $this->maniaControl->getServer()->index, $rocketShots + $laserShots + $arrowShots + $nucleusShots); @@ -342,26 +457,26 @@ class StatisticCollector implements CallbackListener { private function getWeaponStat($weaponNumber, $shot = true) { if ($shot) { switch ($weaponNumber) { - case self::WEAPON_ROCKET: + case Weapons::ROCKET: return self::STAT_ROCKET_SHOT; - case self::WEAPON_LASER: + case Weapons::LASER: return self::STAT_LASER_SHOT; - case self::WEAPON_ARROW: + case Weapons::ARROW: return self::STAT_ARROW_SHOT; - case self::WEAPON_NUCLEUS: + case Weapons::NUCLEUS: return self::STAT_NUCLEUS_SHOT; default: return -1; } } else { switch ($weaponNumber) { - case self::WEAPON_ROCKET: + case Weapons::ROCKET: return self::STAT_ROCKET_HIT; - case self::WEAPON_LASER: + case Weapons::LASER: return self::STAT_LASER_HIT; - case self::WEAPON_ARROW: + case Weapons::ARROW: return self::STAT_ARROW_HIT; - case self::WEAPON_NUCLEUS: + case Weapons::NUCLEUS: return self::STAT_NUCLEUS_HIT; default: return -1; diff --git a/libs/Maniaplanet/DedicatedServer/Connection.php b/libs/Maniaplanet/DedicatedServer/Connection.php index c2a3d53e..00adf71b 100755 --- a/libs/Maniaplanet/DedicatedServer/Connection.php +++ b/libs/Maniaplanet/DedicatedServer/Connection.php @@ -763,7 +763,7 @@ class Connection return $this->execute(ucfirst(__FUNCTION__), array($link), $multicall); } - + /** * Kick the player with the specified login, with an optional message. * Only available to Admin. From a0639c477aa85204ff5a327b473b20b742344027 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 31 Mar 2017 22:32:12 +0200 Subject: [PATCH 72/73] added min and max plugin version in plugin install / update --- core/Update/PluginUpdateData.php | 5 +++++ core/Update/PluginUpdateManager.php | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/core/Update/PluginUpdateData.php b/core/Update/PluginUpdateData.php index 879a4f7f..266e3f5b 100644 --- a/core/Update/PluginUpdateData.php +++ b/core/Update/PluginUpdateData.php @@ -21,6 +21,8 @@ class PluginUpdateData { public $version = null; public $zipfile = null; public $url = null; + public $minManiaControlVersion = null; + public $maxManiaControlVersion = null; /** * Construct new plugin update data instance @@ -37,6 +39,9 @@ class PluginUpdateData { $this->version = $updateData->currentVersion->version; $this->zipfile = $updateData->currentVersion->zipfile; $this->url = $updateData->currentVersion->url; + + $this->minManiaControlVersion = $updateData->currentVersion->min_mc_version; + $this->maxManiaControlVersion = $updateData->currentVersion->max_mc_version; } } diff --git a/core/Update/PluginUpdateManager.php b/core/Update/PluginUpdateManager.php index a6613f9f..38b14501 100644 --- a/core/Update/PluginUpdateManager.php +++ b/core/Update/PluginUpdateManager.php @@ -55,8 +55,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis * @param Player $player */ public function handle_CheckPluginsUpdate(array $chatCallback, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATECHECK) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATECHECK)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } @@ -151,8 +150,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis * @param Player $player */ public function handle_PluginsUpdate(array $chatCallback, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATE) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATE)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } @@ -241,6 +239,24 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis * @param bool $update */ private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) { + if (ManiaControl::VERSION < $pluginUpdateData->minManiaControlVersion) { + $message = "Your ManiaControl Version v" . ManiaControl::VERSION . " is too old for this Plugin (min Required Version): ' . {$pluginUpdateData->minManiaControlVersion}!"; + if ($player) { + $this->maniaControl->getChat()->sendError($message, $player); + } + Logger::logError($message); + return; + } + + if ($pluginUpdateData->maxManiaControlVersion != -1 && ManiaControl::VERSION > $pluginUpdateData->maxManiaControlVersion) { + $message = "Your ManiaControl Version v" . ManiaControl::VERSION . " is too new for this Plugin (max Version of the Plugin: ' . {$pluginUpdateData->minManiaControlVersion}!"; + if ($player) { + $this->maniaControl->getChat()->sendError($message, $player); + } + Logger::logError($message); + return; + } + $asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $pluginUpdateData->url); $asyncHttpRequest->setCallable(function ($updateFileContent, $error) use ( &$pluginUpdateData, &$player, &$update From 8f4d164c466226be8c4565040dfa1e13e2f52d02 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 31 Mar 2017 22:39:35 +0200 Subject: [PATCH 73/73] finished libxmlrpc methods (also trackmania) --- core/Script/ModeScriptEventManager.php | 71 ++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index 3b6d60fa..7d3a5a9f 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -37,10 +37,6 @@ class ModeScriptEventManager implements UsageInformationAble { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true')); $this->setApiVersion(self::API_VERSION); - - $this->getAllApiVersions(); - - $this->getCallbacksList(); } /** @@ -169,4 +165,71 @@ class ModeScriptEventManager implements UsageInformationAble { 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'); + } } \ No newline at end of file