finished map widget

This commit is contained in:
kremsy 2013-12-29 23:01:51 +01:00
parent 590fd658e2
commit e1e7ea15a0

View File

@ -25,6 +25,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
const MLID_MAPWIDGET = 'WidgetPlugin.MapWidget'; const MLID_MAPWIDGET = 'WidgetPlugin.MapWidget';
//MapWidget Properties //MapWidget Properties
const SETTING_MAP_WIDGET_ACTIVATED = 'Map Widget Activated';
const SETTING_MAP_WIDGET_POSX = 'Map-Widget-Position: X'; const SETTING_MAP_WIDGET_POSX = 'Map-Widget-Position: X';
const SETTING_MAP_WIDGET_POSY = 'Map-Widget-Position: Y'; const SETTING_MAP_WIDGET_POSY = 'Map-Widget-Position: Y';
const SETTING_MAP_WIDGET_WIDTH = 'Map-Widget-Size: Width'; const SETTING_MAP_WIDGET_WIDTH = 'Map-Widget-Size: Width';
@ -49,6 +50,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_WIDTH, 40); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_WIDTH, 40);
@ -92,13 +94,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
$maniaLink = new ManiaLink(self::MLID_MAPWIDGET); $maniaLink = new ManiaLink(self::MLID_MAPWIDGET);
// Create script and features
/*$script = new Script();
$maniaLink->setScript($script);
$tooltips = new Tooltips();
$script->addFeature($tooltips); */
//mainframe //mainframe
$frame = new Frame(); $frame = new Frame();
$maniaLink->add($frame); $maniaLink->add($frame);
@ -115,7 +110,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setY(1.3); $label->setY(1.5);
$label->setX(0); $label->setX(0);
$label->setAlign(Control::CENTER,Control::CENTER); $label->setAlign(Control::CENTER,Control::CENTER);
$label->setZ(0.2); $label->setZ(0.2);
@ -126,11 +121,12 @@ class WidgetPlugin implements CallbackListener, Plugin {
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setX(0); $label->setX(0);
$label->setY(-1.3); $label->setY(-1.4);
$label->setAlign(Control::CENTER,Control::CENTER); $label->setAlign(Control::CENTER,Control::CENTER);
$label->setZ(0.2); $label->setZ(0.2);
$label->setTextSize(1); $label->setTextSize(1);
$label->setScale(0.8);
$label->setText($map->authorLogin); $label->setText($map->authorLogin);
$label->setTextColor("FFF"); $label->setTextColor("FFF");
@ -147,8 +143,11 @@ class WidgetPlugin implements CallbackListener, Plugin {
* @param array $callback * @param array $callback
*/ */
public function handleOnInit(array $callback) { public function handleOnInit(array $callback) {
//Display Map Widget
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)){
$this->displayMapWidget(); $this->displayMapWidget();
} }
}
/** /**
* Handle PlayerConnect callback * Handle PlayerConnect callback
@ -156,12 +155,11 @@ class WidgetPlugin implements CallbackListener, Plugin {
* @param array $callback * @param array $callback
*/ */
public function handlePlayerConnect(array $callback) { public function handlePlayerConnect(array $callback) {
// $login = $callback[1][0]; $player = $callback[1];
// $player = $this->maniaControl->playerManager->getPlayer($login); //Display Map Widget
// if (!$player) { if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)){
// return; $this->displayMapWidget($player->login);
//} }
// $this->queryManialinkUpdateFor($player);
} }