From 5bc897cf33110e752cac711cda214f6511fea114 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 28 Dec 2013 19:48:06 +0100 Subject: [PATCH] jukebox beginn --- application/core/ManiaControl.php | 1 + application/core/Maps/Jukebox.php | 51 ++++++++++++++++++++++ application/core/Maps/MapList.php | 2 - application/core/Maps/MapManager.php | 18 +++++++- application/core/Players/PlayerManager.php | 5 ++- 5 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 application/core/Maps/Jukebox.php diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 8e2d77f1..cba6cec7 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -35,6 +35,7 @@ require_once __DIR__ . '/Manialinks/ManialinkManager.php'; require_once __DIR__ . '/Maps/Map.php'; require_once __DIR__ . '/Maps/MapManager.php'; require_once __DIR__ . '/Maps/MapList.php'; +require_once __DIR__ . '/Maps/Jukebox.php'; require_once __DIR__ . '/Players/PlayerManager.php'; require_once __DIR__ . '/Players/PlayerActions.php'; require_once __DIR__ . '/Plugins/PluginManager.php'; diff --git a/application/core/Maps/Jukebox.php b/application/core/Maps/Jukebox.php new file mode 100644 index 00000000..e0166a3b --- /dev/null +++ b/application/core/Maps/Jukebox.php @@ -0,0 +1,51 @@ +maniaControl = $maniaControl; + + + } + + public function addMapToJukebox($uid){ + + //Check if the map is already juked + if(array_key_exists($uid, $this->jukedMaps)){ + //TODO message map already juked + return; + } + + //TODO recently maps not able to add to jukebox setting, and management + + $this->jukedMaps[$uid] = $this->maniaControl->mapManager->getMapByUid($uid); + + //TODO Message + + // Trigger callback + $this->maniaControl->callbackManager->triggerCallback(self::CB_JUKEBOX_CHANGED, array('add', $this->jukedMaps[$uid])); + } +} \ No newline at end of file diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 5753454d..56fa39ba 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -54,7 +54,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, @@ -65,7 +64,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $this->height = 80; $this->quadStyle = Quad_BgRaceScore2::STYLE; //TODO add default menu style to style manager $this->quadSubstyle = Quad_BgRaceScore2::SUBSTYLE_HandleSelectable; - } diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index 8dd045a9..5de8ec11 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -9,6 +9,7 @@ use ManiaControl\FileUtil; use ManiaControl\ManiaControl; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; +use ManiaControl\Players\PlayerList; use MXInfoFetcher; @@ -32,6 +33,11 @@ class MapManager implements CallbackListener { private $mapListUids = array(); private $currentMap = null; + /** + * Public Properties + */ + public $jukebox = null; + /** * Construct map manager * @@ -45,11 +51,13 @@ class MapManager implements CallbackListener { // Create map commands instance $this->mapCommands = new MapCommands($maniaControl); + $this->jukebox = new Jukebox($this->maniaControl); // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapListModified'); + } /** @@ -201,12 +209,20 @@ class MapManager implements CallbackListener { } /** - * @return null + * @return currentMap */ public function getCurrentMap(){ return $this->currentMap; } + /** + * Returns map By UID + * @param $uid + * @return mixed + */ + public function getMapByUid($uid){ + return $this->mapListUids[$uid]; + } /** diff --git a/application/core/Players/PlayerManager.php b/application/core/Players/PlayerManager.php index 1d3898e8..afc76f37 100644 --- a/application/core/Players/PlayerManager.php +++ b/application/core/Players/PlayerManager.php @@ -33,7 +33,11 @@ class PlayerManager implements CallbackListener { private $playerCommands = null; private $playerList = array(); + /** + * Public properties + */ public $playerActions = null; + /** * Construct player manager * @@ -44,7 +48,6 @@ class PlayerManager implements CallbackListener { $this->initTables(); $this->playerCommands = new PlayerCommands($maniaControl); - $this->playerActions = new PlayerActions($maniaControl); // Init settings