mx improvements
This commit is contained in:
parent
711c20f045
commit
5452b99749
@ -8,7 +8,6 @@ use FML\Controls\Label;
|
|||||||
use FML\Controls\Quad;
|
use FML\Controls\Quad;
|
||||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use FML\Script\EUISound;
|
|
||||||
use FML\Script\Script;
|
use FML\Script\Script;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
@ -25,13 +24,13 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const MLID_MENU = 'ActionsMenu.MLID';
|
const MLID_MENU = 'ActionsMenu.MLID';
|
||||||
const SETTING_MENU_POSX = 'Menu Position: X';
|
const SETTING_MENU_POSX = 'Menu Position: X';
|
||||||
const SETTING_MENU_POSY = 'Menu Position: Y';
|
const SETTING_MENU_POSY = 'Menu Position: Y';
|
||||||
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
|
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
|
||||||
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
|
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
|
||||||
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
|
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
@ -47,30 +46,30 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSY, -37.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSY, -37.);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_ONINIT, $this, 'handleOnInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
|
||||||
|
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Menu Item
|
* Add a new Menu Item
|
||||||
*
|
*
|
||||||
* @param Control $control
|
* @param Control $control
|
||||||
* @param bool $playerAction
|
* @param bool $playerAction
|
||||||
* @param int $order
|
* @param int $order
|
||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
public function addMenuItem(Control $control, $playerAction = true, $order = 0, $description = null) {
|
public function addMenuItem(Control $control, $playerAction = true, $order = 0, $description = null) {
|
||||||
if ($playerAction) {
|
if($playerAction) {
|
||||||
$this->addPlayerMenuItem($control, $order, $description);
|
$this->addPlayerMenuItem($control, $order, $description);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$this->addAdminMenuItem($control, $order, $description);
|
$this->addAdminMenuItem($control, $order, $description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,11 +78,11 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
* Add a new Player Menu Item
|
* Add a new Player Menu Item
|
||||||
*
|
*
|
||||||
* @param Control $control
|
* @param Control $control
|
||||||
* @param int $order
|
* @param int $order
|
||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
public function addPlayerMenuItem(Control $control, $order = 0, $description = null) {
|
public function addPlayerMenuItem(Control $control, $order = 0, $description = null) {
|
||||||
if (!isset($this->playerMenuItems[$order])) {
|
if(!isset($this->playerMenuItems[$order])) {
|
||||||
$this->playerMenuItems[$order] = array();
|
$this->playerMenuItems[$order] = array();
|
||||||
}
|
}
|
||||||
array_push($this->playerMenuItems[$order], array($control, $description));
|
array_push($this->playerMenuItems[$order], array($control, $description));
|
||||||
@ -95,11 +94,11 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
* Add a new Admin Menu Item
|
* Add a new Admin Menu Item
|
||||||
*
|
*
|
||||||
* @param Control $control
|
* @param Control $control
|
||||||
* @param int $order
|
* @param int $order
|
||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
public function addAdminMenuItem(Control $control, $order = 0, $description = null) {
|
public function addAdminMenuItem(Control $control, $order = 0, $description = null) {
|
||||||
if (!isset($this->adminMenuItems[$order])) {
|
if(!isset($this->adminMenuItems[$order])) {
|
||||||
$this->adminMenuItems[$order] = array();
|
$this->adminMenuItems[$order] = array();
|
||||||
}
|
}
|
||||||
array_push($this->adminMenuItems[$order], array($control, $description));
|
array_push($this->adminMenuItems[$order], array($control, $description));
|
||||||
@ -121,11 +120,13 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
* Build and show the menus to everyone (if a menu get made after the init)
|
* Build and show the menus to everyone (if a menu get made after the init)
|
||||||
*/
|
*/
|
||||||
public function rebuildAndShowMenu() {
|
public function rebuildAndShowMenu() {
|
||||||
if (!$this->initCompleted) return;
|
if(!$this->initCompleted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO: Render only once
|
// TODO: Render only once
|
||||||
$players = $this->maniaControl->playerManager->getPlayers();
|
$players = $this->maniaControl->playerManager->getPlayers();
|
||||||
foreach ($players as $player) {
|
foreach($players as $player) {
|
||||||
$manialink = $this->buildMenuIconsManialink($player);
|
$manialink = $this->buildMenuIconsManialink($player);
|
||||||
$manialinkText = $manialink->render()->saveXML();
|
$manialinkText = $manialink->render()->saveXML();
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
|
||||||
}
|
}
|
||||||
@ -137,7 +138,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerJoined(array $callback) {
|
public function handlePlayerJoined(array $callback) {
|
||||||
$player = $callback[1];
|
$player = $callback[1];
|
||||||
$manialinkText = $this->buildMenuIconsManialink($player)->render()->saveXML();
|
$manialinkText = $this->buildMenuIconsManialink($player)->render()->saveXML();
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
|
||||||
}
|
}
|
||||||
@ -149,68 +150,68 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
* @return ManiaLink
|
* @return ManiaLink
|
||||||
*/
|
*/
|
||||||
private function buildMenuIconsManialink(Player $player) {
|
private function buildMenuIconsManialink(Player $player) {
|
||||||
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
|
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
|
||||||
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
|
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
|
||||||
$itemSize = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_ITEMSIZE);
|
$itemSize = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_ITEMSIZE);
|
||||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
|
||||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
||||||
$itemMarginFactorX = 1.3;
|
$itemMarginFactorX = 1.3;
|
||||||
$itemMarginFactorY = 1.2;
|
$itemMarginFactorY = 1.2;
|
||||||
|
|
||||||
$manialink = new ManiaLink(self::MLID_MENU);
|
$manialink = new ManiaLink(self::MLID_MENU);
|
||||||
$script = new Script();
|
$script = new Script();
|
||||||
$manialink->setScript($script);
|
$manialink->setScript($script);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Admin Menu
|
* Admin Menu
|
||||||
*/
|
*/
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
// Admin Menu Icon Frame
|
// Admin Menu Icon Frame
|
||||||
$iconFrame = new Frame();
|
$iconFrame = new Frame();
|
||||||
$manialink->add($iconFrame);
|
$manialink->add($iconFrame);
|
||||||
$iconFrame->setPosition($posX, $posY);
|
$iconFrame->setPosition($posX, $posY);
|
||||||
|
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$iconFrame->add($backgroundQuad);
|
$iconFrame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
|
||||||
$itemQuad = new Quad_Icons64x64_1();
|
$itemQuad = new Quad_Icons64x64_1();
|
||||||
$iconFrame->add($itemQuad);
|
$iconFrame->add($itemQuad);
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconServers);
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconServers);
|
||||||
$itemQuad->setSize($itemSize, $itemSize);
|
$itemQuad->setSize($itemSize, $itemSize);
|
||||||
|
|
||||||
// Admin Menu Description Label
|
// Admin Menu Description Label
|
||||||
$descriptionFrame = new Frame();
|
$descriptionFrame = new Frame();
|
||||||
$manialink->add($descriptionFrame);
|
$manialink->add($descriptionFrame);
|
||||||
$descriptionFrame->setPosition($posX - count($this->adminMenuItems) * $itemSize * 1.15 - 6, $posY);
|
$descriptionFrame->setPosition($posX - count($this->adminMenuItems) * $itemSize * 1.15 - 6, $posY);
|
||||||
|
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
$descriptionFrame->add($descriptionLabel);
|
$descriptionFrame->add($descriptionLabel);
|
||||||
$descriptionLabel->setAlign(Control::RIGHT, Control::TOP);
|
$descriptionLabel->setAlign(Control::RIGHT, Control::TOP);
|
||||||
$descriptionLabel->setSize(40, 4);
|
$descriptionLabel->setSize(40, 4);
|
||||||
$descriptionLabel->setTextSize(1.4);
|
$descriptionLabel->setTextSize(1.4);
|
||||||
$descriptionLabel->setTextColor('fff');
|
$descriptionLabel->setTextColor('fff');
|
||||||
|
|
||||||
// Admin Menu
|
// Admin Menu
|
||||||
$popoutFrame = new Frame();
|
$popoutFrame = new Frame();
|
||||||
$manialink->add($popoutFrame);
|
$manialink->add($popoutFrame);
|
||||||
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY);
|
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY);
|
||||||
$popoutFrame->setHAlign(Control::RIGHT);
|
$popoutFrame->setHAlign(Control::RIGHT);
|
||||||
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||||
|
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$popoutFrame->add($backgroundQuad);
|
$popoutFrame->add($backgroundQuad);
|
||||||
$backgroundQuad->setHAlign(Control::RIGHT);
|
$backgroundQuad->setHAlign(Control::RIGHT);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
$backgroundQuad->setSize(count($this->adminMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
$backgroundQuad->setSize(count($this->adminMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
||||||
|
|
||||||
$script->addToggle($itemQuad, $popoutFrame);
|
$script->addToggle($itemQuad, $popoutFrame);
|
||||||
|
|
||||||
// Add items
|
// Add items
|
||||||
$x = -1;
|
$x = -1;
|
||||||
foreach ($this->adminMenuItems as $order => $menuItems) {
|
foreach($this->adminMenuItems as $order => $menuItems) {
|
||||||
foreach ($menuItems as $menuItem) {
|
foreach($menuItems as $menuItem) {
|
||||||
$menuQuad = $menuItem[0];
|
$menuQuad = $menuItem[0];
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -221,15 +222,15 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
$menuQuad->setX($x);
|
$menuQuad->setX($x);
|
||||||
$menuQuad->setHAlign(Control::RIGHT);
|
$menuQuad->setHAlign(Control::RIGHT);
|
||||||
$x -= $itemSize * 1.05;
|
$x -= $itemSize * 1.05;
|
||||||
|
|
||||||
if ($menuItem[1]) {
|
if($menuItem[1]) {
|
||||||
$description = '$s' . $menuItem[1];
|
$description = '$s' . $menuItem[1];
|
||||||
$script->addTooltip($menuQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
$script->addTooltip($menuQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Player Menu
|
* Player Menu
|
||||||
*/
|
*/
|
||||||
@ -237,48 +238,48 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
$iconFrame = new Frame();
|
$iconFrame = new Frame();
|
||||||
$manialink->add($iconFrame);
|
$manialink->add($iconFrame);
|
||||||
$iconFrame->setPosition($posX, $posY - $itemSize * $itemMarginFactorY);
|
$iconFrame->setPosition($posX, $posY - $itemSize * $itemMarginFactorY);
|
||||||
|
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$iconFrame->add($backgroundQuad);
|
$iconFrame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
|
||||||
$itemQuad = new Quad_Icons64x64_1();
|
$itemQuad = new Quad_Icons64x64_1();
|
||||||
$iconFrame->add($itemQuad);
|
$iconFrame->add($itemQuad);
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconPlayers);
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconPlayers);
|
||||||
$itemQuad->setSize($itemSize, $itemSize);
|
$itemQuad->setSize($itemSize, $itemSize);
|
||||||
|
|
||||||
// Player Menu Description Frame
|
// Player Menu Description Frame
|
||||||
$descriptionFrame = new Frame();
|
$descriptionFrame = new Frame();
|
||||||
$manialink->add($descriptionFrame);
|
$manialink->add($descriptionFrame);
|
||||||
$descriptionFrame->setPosition($posX - count($this->playerMenuItems) * $itemSize * 1.15 - 6, $posY - $itemSize * $itemMarginFactorY);
|
$descriptionFrame->setPosition($posX - count($this->playerMenuItems) * $itemSize * 1.15 - 6, $posY - $itemSize * $itemMarginFactorY);
|
||||||
|
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
$descriptionFrame->add($descriptionLabel);
|
$descriptionFrame->add($descriptionLabel);
|
||||||
$descriptionLabel->setAlign(Control::RIGHT, Control::TOP);
|
$descriptionLabel->setAlign(Control::RIGHT, Control::TOP);
|
||||||
$descriptionLabel->setSize(40, 4);
|
$descriptionLabel->setSize(40, 4);
|
||||||
$descriptionLabel->setTextSize(1.4);
|
$descriptionLabel->setTextSize(1.4);
|
||||||
$descriptionLabel->setTextColor('fff');
|
$descriptionLabel->setTextColor('fff');
|
||||||
|
|
||||||
// Player Menu
|
// Player Menu
|
||||||
$popoutFrame = new Frame();
|
$popoutFrame = new Frame();
|
||||||
$manialink->add($popoutFrame);
|
$manialink->add($popoutFrame);
|
||||||
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY - $itemSize * $itemMarginFactorY);
|
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY - $itemSize * $itemMarginFactorY);
|
||||||
$popoutFrame->setHAlign(Control::RIGHT);
|
$popoutFrame->setHAlign(Control::RIGHT);
|
||||||
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||||
|
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$popoutFrame->add($backgroundQuad);
|
$popoutFrame->add($backgroundQuad);
|
||||||
$backgroundQuad->setHAlign(Control::RIGHT);
|
$backgroundQuad->setHAlign(Control::RIGHT);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
$backgroundQuad->setSize(count($this->playerMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
$backgroundQuad->setSize(count($this->playerMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
||||||
|
|
||||||
$script->addToggle($itemQuad, $popoutFrame);
|
$script->addToggle($itemQuad, $popoutFrame);
|
||||||
|
|
||||||
// Add items
|
// Add items
|
||||||
$x = -1;
|
$x = -1;
|
||||||
foreach ($this->playerMenuItems as $menuItems) {
|
foreach($this->playerMenuItems as $menuItems) {
|
||||||
foreach ($menuItems as $menuItem) {
|
foreach($menuItems as $menuItem) {
|
||||||
$menuQuad = $menuItem[0];
|
$menuQuad = $menuItem[0];
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -290,13 +291,13 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
$menuQuad->setHAlign(Control::RIGHT);
|
$menuQuad->setHAlign(Control::RIGHT);
|
||||||
$x -= $itemSize * 1.05;
|
$x -= $itemSize * 1.05;
|
||||||
|
|
||||||
if ($menuItem[1]) {
|
if($menuItem[1]) {
|
||||||
$description = '$s' . $menuItem[1];
|
$description = '$s' . $menuItem[1];
|
||||||
$script->addTooltip($menuQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
$script->addTooltip($menuQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $manialink;
|
return $manialink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ use ManiaControl\Callbacks\CallbackManager;
|
|||||||
use ManiaControl\ColorUtil;
|
use ManiaControl\ColorUtil;
|
||||||
use ManiaControl\Formatter;
|
use ManiaControl\Formatter;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
use ManiaControl\Manialinks\IconManager;
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
@ -113,7 +114,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search for matching maps
|
// search for matching maps
|
||||||
$maps = $this->maniaControl->mapManager->mxInfoSearcher->getMaps($searchString, $author, $environment, self::MAX_MX_MAPS_PER_PAGE);
|
$maps = $this->maniaControl->mapManager->mxInfoSearcher->getMaps($searchString, $author, $environment);
|
||||||
|
|
||||||
// check if there are any results
|
// check if there are any results
|
||||||
if($maps == null) {
|
if($maps == null) {
|
||||||
@ -124,6 +125,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
$frame = $this->buildMainFrame();
|
$frame = $this->buildMainFrame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
|
$frame->setZ(10);
|
||||||
|
|
||||||
// Create script and features
|
// Create script and features
|
||||||
$script = new Script();
|
$script = new Script();
|
||||||
@ -135,21 +137,79 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$x = -$width / 2;
|
$x = -$width / 2;
|
||||||
$y = $height / 2;
|
$y = $height / 2;
|
||||||
|
|
||||||
|
// Pagers
|
||||||
|
// Config
|
||||||
|
$pagerSize = 6.;
|
||||||
|
$pagesId = 'MapListPages';
|
||||||
|
|
||||||
|
$pagerPrev = new Quad_Icons64x64_1();
|
||||||
|
$frame->add($pagerPrev);
|
||||||
|
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2);
|
||||||
|
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||||
|
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
|
||||||
|
|
||||||
|
$pagerNext = new Quad_Icons64x64_1();
|
||||||
|
$frame->add($pagerNext);
|
||||||
|
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||||
|
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||||
|
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
|
||||||
|
|
||||||
|
$script->addPager($pagerPrev, -1, $pagesId);
|
||||||
|
$script->addPager($pagerNext, 1, $pagesId);
|
||||||
|
|
||||||
|
$pageCountLabel = new Label_Text();
|
||||||
|
$frame->add($pageCountLabel);
|
||||||
|
$pageCountLabel->setHAlign(Control::RIGHT);
|
||||||
|
$pageCountLabel->setPosition($width * 0.40, $height * -0.44, 1);
|
||||||
|
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||||
|
$pageCountLabel->setTextSize(1.3);
|
||||||
|
$script->addPageLabel($pageCountLabel, $pagesId);
|
||||||
|
|
||||||
|
// Predefine Description Label
|
||||||
|
$descriptionLabel = new Label();
|
||||||
|
$frame->add($descriptionLabel);
|
||||||
|
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
||||||
|
$descriptionLabel->setPosition($x + 10, -$height / 2 + 5);
|
||||||
|
$descriptionLabel->setSize($width * 0.7, 4);
|
||||||
|
$descriptionLabel->setTextSize(2);
|
||||||
|
$descriptionLabel->setVisible(false);
|
||||||
|
|
||||||
// Headline
|
// Headline
|
||||||
$headFrame = new Frame();
|
$headFrame = new Frame();
|
||||||
$frame->add($headFrame);
|
$frame->add($headFrame);
|
||||||
$headFrame->setY($y - 5);
|
$headFrame->setY($y - 5);
|
||||||
$array = array('Id' => $x + 5, 'Name' => $x + 17, 'Author' => $x + 65, 'Type' => $x + 100, 'Mood' => $x + 115, 'Last Update' => $x + 130);
|
$array = array('Mx Id' => $x + 5, 'Name' => $x + 17, 'Author' => $x + 65, 'Type' => $x + 100, 'Mood' => $x + 115, 'Last Update' => $x + 130);
|
||||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$y -= 10;
|
$y -= 10;
|
||||||
foreach($maps as $map) { //TODO pagers, click on nickname...
|
$pageFrames = array();
|
||||||
|
foreach($maps as $map) { //TODO pagers, order possabilities
|
||||||
|
if(!isset($pageFrame)) {
|
||||||
|
$pageFrame = new Frame();
|
||||||
|
$frame->add($pageFrame);
|
||||||
|
if(!empty($pageFrames)) {
|
||||||
|
$pageFrame->setVisible(false);
|
||||||
|
}
|
||||||
|
array_push($pageFrames, $pageFrame);
|
||||||
|
$y = $height / 2 - 10;
|
||||||
|
$script->addPage($pageFrame, count($pageFrames), $pagesId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map Frame
|
||||||
|
$mapFrame = new Frame();
|
||||||
|
$pageFrame->add($mapFrame);
|
||||||
|
|
||||||
|
if($i % 2 == 0) {
|
||||||
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
|
$mapFrame->add($lineQuad);
|
||||||
|
$lineQuad->setSize($width, 4);
|
||||||
|
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||||
|
$lineQuad->setZ(0.001);
|
||||||
|
}
|
||||||
|
|
||||||
/** @var MxMapInfo $map */
|
/** @var MxMapInfo $map */
|
||||||
$time = Formatter::time_elapsed_string(strtotime($map->updated));
|
$time = Formatter::time_elapsed_string(strtotime($map->updated));
|
||||||
|
|
||||||
$mapFrame = new Frame();
|
|
||||||
$frame->add($mapFrame);
|
|
||||||
$array = array($map->id => $x + 5, $map->name => $x + 17, $map->author => $x + 65, str_replace("Arena", "", $map->maptype) => $x + 100, $map->mood => $x + 115, $time => $x + 130);
|
$array = array($map->id => $x + 5, $map->name => $x + 17, $map->author => $x + 65, str_replace("Arena", "", $map->maptype) => $x + 100, $map->mood => $x + 115, $time => $x + 130);
|
||||||
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
||||||
/** @var Label_Text $authorLabel */
|
/** @var Label_Text $authorLabel */
|
||||||
@ -158,6 +218,32 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
$mapFrame->setY($y);
|
$mapFrame->setY($y);
|
||||||
|
|
||||||
|
|
||||||
|
$mxQuad = new Quad();
|
||||||
|
$mapFrame->add($mxQuad);
|
||||||
|
$mxQuad->setSize(3, 3);
|
||||||
|
$mxQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON));
|
||||||
|
$mxQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER));
|
||||||
|
$mxQuad->setX($x + 62);
|
||||||
|
$mxQuad->setUrl($map->pageurl);
|
||||||
|
$mxQuad->setZ(0.01);
|
||||||
|
$script->addTooltip($mxQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View " . $map->name . " on Mania-Exchange"));
|
||||||
|
|
||||||
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||||
|
// TODO: SET as setting who can add maps Add-Map-Button
|
||||||
|
$addQuad = new Quad_Icons64x64_1();
|
||||||
|
$mapFrame->add($addQuad);
|
||||||
|
$addQuad->setX($x + 59);
|
||||||
|
$addQuad->setZ(-0.1);
|
||||||
|
$addQuad->setSubStyle($addQuad::SUBSTYLE_Add);
|
||||||
|
$addQuad->setSize(4, 4);
|
||||||
|
$addQuad->setAction(self::ACTION_ADD_MAP . '.' . $map->id);
|
||||||
|
$addQuad->setZ(0.01);
|
||||||
|
|
||||||
|
$script->addTooltip($addQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => 'Add-Map: $<' . $map->name . '$>'));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Award
|
||||||
if($map->awards > 0) {
|
if($map->awards > 0) {
|
||||||
$awardQuad = new Quad_Icons64x64_1();
|
$awardQuad = new Quad_Icons64x64_1();
|
||||||
$mapFrame->add($awardQuad);
|
$mapFrame->add($awardQuad);
|
||||||
@ -173,33 +259,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$awardLabel->setTextSize(1.3);
|
$awardLabel->setTextSize(1.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
|
||||||
// TODO: SET as setting who can add maps Add-Map-Button
|
|
||||||
$addQuad = new Quad_Icons64x64_1();
|
|
||||||
$mapFrame->add($addQuad);
|
|
||||||
$addQuad->setX($x + 15);
|
|
||||||
$addQuad->setZ(-0.1);
|
|
||||||
$addQuad->setSubStyle($addQuad::SUBSTYLE_Add);
|
|
||||||
$addQuad->setSize(4, 4);
|
|
||||||
$addQuad->setAction(self::ACTION_ADD_MAP . '.' . $map->id);
|
|
||||||
|
|
||||||
// Description Label
|
|
||||||
$descriptionLabel = new Label();
|
|
||||||
$frame->add($descriptionLabel);
|
|
||||||
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
|
||||||
$descriptionLabel->setPosition($x + 10, -$height / 2 + 5);
|
|
||||||
$descriptionLabel->setSize($width * 0.7, 4);
|
|
||||||
$descriptionLabel->setTextSize(2);
|
|
||||||
$descriptionLabel->setVisible(false);
|
|
||||||
$descriptionLabel->setText('Add-Map: $<' . Formatter::stripDirtyCodes($map->name) . '$>');
|
|
||||||
$script->addTooltip($addQuad, $descriptionLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$i++;
|
$i++;
|
||||||
if($i == self::MAX_MX_MAPS_PER_PAGE) {
|
if($i % self::MAX_MX_MAPS_PER_PAGE == 0) {
|
||||||
break;
|
unset($pageFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,20 +300,17 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
//Search for Author
|
//Search for Author
|
||||||
$label = new Label_Button();
|
$label = new Label_Button();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setPosition(-$width / 2 + 85, -$height / 2 + 10);
|
$label->setPosition(-$width / 2 + 82, -$height / 2 + 10);
|
||||||
$label->setText("Author");
|
$label->setText("Author");
|
||||||
$label->setTextSize(1.3);
|
$label->setTextSize(1.3);
|
||||||
|
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = new Quad_BgsPlayerCard();
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setPosition(-$width / 2 + 85, -$height / 2 + 10, 0.01);
|
$quad->setPosition(-$width / 2 + 82, -$height / 2 + 10, 0.01);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
||||||
$quad->setSize(18, 5);
|
$quad->setSize(18, 5);
|
||||||
$quad->setAction(self::ACTION_SEARCH_AUTHOR);
|
$quad->setAction(self::ACTION_SEARCH_AUTHOR);
|
||||||
|
|
||||||
|
|
||||||
// TODO add MX info screen
|
|
||||||
|
|
||||||
// render and display xml
|
// render and display xml
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||||
}
|
}
|
||||||
@ -305,6 +365,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
$frame = $this->buildMainFrame();
|
$frame = $this->buildMainFrame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
|
$frame->setZ(10);
|
||||||
|
|
||||||
// Create script and features
|
// Create script and features
|
||||||
$script = new Script();
|
$script = new Script();
|
||||||
|
@ -32,24 +32,24 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ACTION_FORCE_RED = 'PlayerList.ForceRed';
|
const ACTION_FORCE_RED = 'PlayerList.ForceRed';
|
||||||
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
|
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
|
||||||
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
|
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
|
||||||
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
|
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
|
||||||
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
|
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
|
||||||
const ACTION_MUTE_PLAYER = 'PlayerList.MutePlayer';
|
const ACTION_MUTE_PLAYER = 'PlayerList.MutePlayer';
|
||||||
const ACTION_UNMUTE_PLAYER = 'PlayerList.UnMutePlayer';
|
const ACTION_UNMUTE_PLAYER = 'PlayerList.UnMutePlayer';
|
||||||
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
|
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
|
||||||
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
|
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
|
||||||
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
|
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
|
||||||
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
|
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
|
||||||
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
|
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
|
||||||
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
|
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
|
||||||
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
|
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
|
||||||
const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed';
|
const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed';
|
||||||
const ACTION_SPECTATE_PLAYER = 'PlayerList.SpectatePlayer';
|
const ACTION_SPECTATE_PLAYER = 'PlayerList.SpectatePlayer';
|
||||||
const SHOWN_MAIN_WINDOW = -1;
|
const SHOWN_MAIN_WINDOW = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
@ -63,12 +63,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||||
'handleManialinkPageAnswer');
|
|
||||||
|
|
||||||
// Update Widget Events
|
// Update Widget Events
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
|
||||||
@ -86,26 +85,26 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showPlayerList(Player $player) {
|
public function showPlayerList(Player $player) {
|
||||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
|
|
||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
$script = $maniaLink->getScript();
|
$script = $maniaLink->getScript();
|
||||||
|
|
||||||
// Main frame
|
// Main frame
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
$frame->setSize($width, $height);
|
$frame->setSize($width, $height);
|
||||||
$frame->setPosition(0, 0);
|
$frame->setPosition(0, 0, 10);
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($backgroundQuad);
|
$frame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($width, $height);
|
$backgroundQuad->setSize($width, $height);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
|
||||||
// Close Quad (X)
|
// Close Quad (X)
|
||||||
$closeQuad = new Quad_Icons64x64_1();
|
$closeQuad = new Quad_Icons64x64_1();
|
||||||
$frame->add($closeQuad);
|
$frame->add($closeQuad);
|
||||||
@ -113,11 +112,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$closeQuad->setSize(6, 6);
|
$closeQuad->setSize(6, 6);
|
||||||
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
||||||
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
||||||
|
|
||||||
// Start offsets
|
// Start offsets
|
||||||
$x = -$width / 2;
|
$x = -$width / 2;
|
||||||
$y = $height / 2;
|
$y = $height / 2;
|
||||||
|
|
||||||
// Predefine Description Label
|
// Predefine Description Label
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
@ -126,58 +125,57 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$descriptionLabel->setSize($width * 0.7, 4);
|
$descriptionLabel->setSize($width * 0.7, 4);
|
||||||
$descriptionLabel->setTextSize(2);
|
$descriptionLabel->setTextSize(2);
|
||||||
$descriptionLabel->setVisible(false);
|
$descriptionLabel->setVisible(false);
|
||||||
|
|
||||||
// Headline
|
// Headline
|
||||||
$headFrame = new Frame();
|
$headFrame = new Frame();
|
||||||
$frame->add($headFrame);
|
$frame->add($headFrame);
|
||||||
$headFrame->setY($y - 5);
|
$headFrame->setY($y - 5);
|
||||||
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
|
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101, "Actions" => $x + 135);
|
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101, "Actions" => $x + 135);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101);
|
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101);
|
||||||
}
|
}
|
||||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||||
|
|
||||||
// get PlayerList
|
// get PlayerList
|
||||||
$players = $this->maniaControl->playerManager->getPlayers();
|
$players = $this->maniaControl->playerManager->getPlayers();
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$y -= 10;
|
$y -= 10;
|
||||||
foreach ($players as $listPlayer) {
|
foreach($players as $listPlayer) {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var Player $listPlayer
|
* @var Player $listPlayer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$path = $listPlayer->getProvince();
|
$path = $listPlayer->getProvince();
|
||||||
$playerFrame = new Frame();
|
$playerFrame = new Frame();
|
||||||
$frame->add($playerFrame);
|
$frame->add($playerFrame);
|
||||||
|
|
||||||
if ($i % 2 != 0) {
|
if($i % 2 != 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$playerFrame->add($lineQuad);
|
$playerFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||||
$lineQuad->setZ(0.001);
|
$lineQuad->setZ(0.001);
|
||||||
}
|
}
|
||||||
|
|
||||||
$array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 70, $path => $x + 101);
|
$array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 70, $path => $x + 101);
|
||||||
$frames = $this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
||||||
|
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
|
|
||||||
// Team Emblem
|
// Team Emblem
|
||||||
if ($listPlayer->teamId >= 0) {
|
if($listPlayer->teamId >= 0) {
|
||||||
// Player is in a Team
|
// Player is in a Team
|
||||||
$teamQuad = new Quad_Emblems();
|
$teamQuad = new Quad_Emblems();
|
||||||
$playerFrame->add($teamQuad);
|
$playerFrame->add($teamQuad);
|
||||||
$teamQuad->setX($x + 10);
|
$teamQuad->setX($x + 10);
|
||||||
$teamQuad->setZ(0.1);
|
$teamQuad->setZ(0.1);
|
||||||
$teamQuad->setSize(3.8, 3.8);
|
$teamQuad->setSize(3.8, 3.8);
|
||||||
|
|
||||||
switch ($listPlayer->teamId) {
|
switch($listPlayer->teamId) {
|
||||||
case 0:
|
case 0:
|
||||||
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_1);
|
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_1);
|
||||||
break;
|
break;
|
||||||
@ -185,8 +183,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_2);
|
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if($listPlayer->isSpectator) {
|
||||||
else if ($listPlayer->isSpectator) {
|
|
||||||
// Player is in Spectator Mode
|
// Player is in Spectator Mode
|
||||||
$specQuad = new Quad_BgRaceScore2();
|
$specQuad = new Quad_BgRaceScore2();
|
||||||
$playerFrame->add($specQuad);
|
$playerFrame->add($specQuad);
|
||||||
@ -195,8 +192,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$specQuad->setSubStyle($specQuad::SUBSTYLE_Spectator);
|
$specQuad->setSubStyle($specQuad::SUBSTYLE_Spectator);
|
||||||
$specQuad->setSize(3.8, 3.8);
|
$specQuad->setSize(3.8, 3.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$listPlayer->isFakePlayer()) {
|
if(!$listPlayer->isFakePlayer()) {
|
||||||
// Nation Quad
|
// Nation Quad
|
||||||
$countryQuad = new Quad();
|
$countryQuad = new Quad();
|
||||||
$playerFrame->add($countryQuad);
|
$playerFrame->add($countryQuad);
|
||||||
@ -205,11 +202,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$countryQuad->setX($x + 98);
|
$countryQuad->setX($x + 98);
|
||||||
$countryQuad->setSize(4, 4);
|
$countryQuad->setSize(4, 4);
|
||||||
$countryQuad->setZ(-0.1);
|
$countryQuad->setZ(-0.1);
|
||||||
|
|
||||||
$script->addTooltip($countryQuad, $descriptionLabel,
|
$script->addTooltip($countryQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $listPlayer->nickname . " from " . $listPlayer->path));
|
||||||
array(Script::OPTION_TOOLTIP_TEXT => $listPlayer->nickname . " from " . $listPlayer->path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Level Quad
|
// Level Quad
|
||||||
$rightQuad = new Quad_BgRaceScore2();
|
$rightQuad = new Quad_BgRaceScore2();
|
||||||
$playerFrame->add($rightQuad);
|
$playerFrame->add($rightQuad);
|
||||||
@ -217,18 +213,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$rightQuad->setZ(5);
|
$rightQuad->setZ(5);
|
||||||
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
||||||
$rightQuad->setSize(7, 3.5);
|
$rightQuad->setSize(7, 3.5);
|
||||||
|
|
||||||
$rightLabel = new Label_Text();
|
$rightLabel = new Label_Text();
|
||||||
$playerFrame->add($rightLabel);
|
$playerFrame->add($rightLabel);
|
||||||
$rightLabel->setX($x + 13.9);
|
$rightLabel->setX($x + 13.9);
|
||||||
$rightLabel->setTextSize(0.8);
|
$rightLabel->setTextSize(0.8);
|
||||||
$rightLabel->setZ(10);
|
$rightLabel->setZ(10);
|
||||||
|
|
||||||
$script->addTooltip($rightLabel, $descriptionLabel,
|
$script->addTooltip($rightLabel, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname));
|
||||||
array(
|
|
||||||
Script::OPTION_TOOLTIP_TEXT => $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " .
|
|
||||||
$listPlayer->nickname));
|
|
||||||
|
|
||||||
// Player Statistics
|
// Player Statistics
|
||||||
$playerQuad = new Quad_Icons64x64_1();
|
$playerQuad = new Quad_Icons64x64_1();
|
||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
@ -238,7 +231,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$playerQuad->setSize(2.7, 2.7);
|
$playerQuad->setSize(2.7, 2.7);
|
||||||
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . "." . $listPlayer->login);
|
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . "." . $listPlayer->login);
|
||||||
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View Statistics of " . $listPlayer->nickname));
|
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View Statistics of " . $listPlayer->nickname));
|
||||||
|
|
||||||
// Camera Quad
|
// Camera Quad
|
||||||
$playerQuad = new Quad_UIConstruction_Buttons();
|
$playerQuad = new Quad_UIConstruction_Buttons();
|
||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
@ -248,7 +241,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$playerQuad->setSize(3.8, 3.8);
|
$playerQuad->setSize(3.8, 3.8);
|
||||||
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Spectate " . $listPlayer->nickname));
|
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Spectate " . $listPlayer->nickname));
|
||||||
$playerQuad->setAction(self::ACTION_SPECTATE_PLAYER);
|
$playerQuad->setAction(self::ACTION_SPECTATE_PLAYER);
|
||||||
|
|
||||||
// Player Profile Quad
|
// Player Profile Quad
|
||||||
$playerQuad = new Quad_UIConstruction_Buttons();
|
$playerQuad = new Quad_UIConstruction_Buttons();
|
||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
@ -257,12 +250,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
||||||
$playerQuad->setSize(3.8, 3.8);
|
$playerQuad->setSize(3.8, 3.8);
|
||||||
$script->addProfileButton($playerQuad, $listPlayer->login);
|
$script->addProfileButton($playerQuad, $listPlayer->login);
|
||||||
|
|
||||||
// Description Label
|
// Description Label
|
||||||
$script->addTooltip($playerQuad, $descriptionLabel,
|
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View Player profile of " . $listPlayer->nickname));
|
||||||
array(Script::OPTION_TOOLTIP_TEXT => "View Player profile of " . $listPlayer->nickname));
|
|
||||||
|
switch($listPlayer->authLevel) {
|
||||||
switch ($listPlayer->authLevel) {
|
|
||||||
case authenticationManager::AUTH_LEVEL_MASTERADMIN:
|
case authenticationManager::AUTH_LEVEL_MASTERADMIN:
|
||||||
$rightLabel->setText("MA");
|
$rightLabel->setText("MA");
|
||||||
break;
|
break;
|
||||||
@ -275,10 +267,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
case authenticationManager::AUTH_LEVEL_MODERATOR:
|
case authenticationManager::AUTH_LEVEL_MODERATOR:
|
||||||
$rightLabel->setText("MOD");
|
$rightLabel->setText("MOD");
|
||||||
}
|
}
|
||||||
|
|
||||||
$rightLabel->setTextColor("fff");
|
$rightLabel->setTextColor("fff");
|
||||||
|
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
// Further Player actions Quad
|
// Further Player actions Quad
|
||||||
$playerQuad = new Quad_Icons64x64_1();
|
$playerQuad = new Quad_Icons64x64_1();
|
||||||
$playerFrame->add($playerQuad);
|
$playerFrame->add($playerQuad);
|
||||||
@ -287,11 +279,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
||||||
$playerQuad->setSize(3.8, 3.8);
|
$playerQuad->setSize(3.8, 3.8);
|
||||||
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login);
|
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login);
|
||||||
|
|
||||||
// Description Label
|
// Description Label
|
||||||
$script->addTooltip($playerQuad, $descriptionLabel,
|
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Advanced Player Actions on " . $listPlayer->nickname));
|
||||||
array(Script::OPTION_TOOLTIP_TEXT => "Advanced Player Actions on " . $listPlayer->nickname));
|
|
||||||
|
|
||||||
// Force to Red-Team Quad
|
// Force to Red-Team Quad
|
||||||
$redQuad = new Quad_Emblems();
|
$redQuad = new Quad_Emblems();
|
||||||
$playerFrame->add($redQuad);
|
$playerFrame->add($redQuad);
|
||||||
@ -300,11 +291,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
||||||
$redQuad->setSize(3.8, 3.8);
|
$redQuad->setSize(3.8, 3.8);
|
||||||
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
|
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Red-Team Description Label
|
// Force to Red-Team Description Label
|
||||||
$script->addTooltip($redQuad, $descriptionLabel,
|
$script->addTooltip($redQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Red Team!'));
|
||||||
array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Red Team!'));
|
|
||||||
|
|
||||||
// Force to Blue-Team Quad
|
// Force to Blue-Team Quad
|
||||||
$blueQuad = new Quad_Emblems();
|
$blueQuad = new Quad_Emblems();
|
||||||
$playerFrame->add($blueQuad);
|
$playerFrame->add($blueQuad);
|
||||||
@ -313,11 +303,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
||||||
$blueQuad->setSize(3.8, 3.8);
|
$blueQuad->setSize(3.8, 3.8);
|
||||||
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
|
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Blue-Team Description Label
|
// Force to Blue-Team Description Label
|
||||||
$script->addTooltip($blueQuad, $descriptionLabel,
|
$script->addTooltip($blueQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Blue Team!'));
|
||||||
array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Blue Team!'));
|
|
||||||
|
|
||||||
// Force to Spectator Quad
|
// Force to Spectator Quad
|
||||||
$spectatorQuad = new Quad_BgRaceScore2();
|
$spectatorQuad = new Quad_BgRaceScore2();
|
||||||
$playerFrame->add($spectatorQuad);
|
$playerFrame->add($spectatorQuad);
|
||||||
@ -326,21 +315,20 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||||
$spectatorQuad->setSize(3.8, 3.8);
|
$spectatorQuad->setSize(3.8, 3.8);
|
||||||
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." . $listPlayer->login);
|
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." . $listPlayer->login);
|
||||||
|
|
||||||
// Force to Spectator Description Label
|
// Force to Spectator Description Label
|
||||||
$script->addTooltip($spectatorQuad, $descriptionLabel,
|
$script->addTooltip($spectatorQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Spectator!'));
|
||||||
array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Spectator!'));
|
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show advanced window
|
// Show advanced window
|
||||||
if ($this->playersListShown[$player->login] && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) {
|
if($this->playersListShown[$player->login] && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) {
|
||||||
$frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]);
|
$frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]);
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render and display xml
|
// Render and display xml
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||||
}
|
}
|
||||||
@ -349,12 +337,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* Displays the Advanced Player Window
|
* Displays the Advanced Player Window
|
||||||
*
|
*
|
||||||
* @param Player $caller
|
* @param Player $caller
|
||||||
* @param $login
|
* @param $login
|
||||||
*/
|
*/
|
||||||
public function advancedPlayerWidget(Player $caller, $login) {
|
public function advancedPlayerWidget(Player $caller, $login) {
|
||||||
// Set status to target player login
|
// Set status to target player login
|
||||||
$this->playersListShown[$caller->login] = $login;
|
$this->playersListShown[$caller->login] = $login;
|
||||||
|
|
||||||
// Reopen playerlist
|
// Reopen playerlist
|
||||||
$this->showPlayerList($caller);
|
$this->showPlayerList($caller);
|
||||||
}
|
}
|
||||||
@ -366,27 +354,27 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @return Frame
|
* @return Frame
|
||||||
*/
|
*/
|
||||||
public function showAdvancedPlayerWidget($login) {
|
public function showAdvancedPlayerWidget($login) {
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
|
|
||||||
// TODO: all configurable or as constants
|
// TODO: all configurable or as constants
|
||||||
$x = $width / 2 + 2.5;
|
$x = $width / 2 + 2.5;
|
||||||
$width = 35;
|
$width = 35;
|
||||||
$height = $height * 0.75;
|
$height = $height * 0.75;
|
||||||
$hAlign = Control::LEFT;
|
$hAlign = Control::LEFT;
|
||||||
$style = Label_Text::STYLE_TextCardSmall;
|
$style = Label_Text::STYLE_TextCardSmall;
|
||||||
$textSize = 1.5;
|
$textSize = 1.5;
|
||||||
$textColor = 'FFF';
|
$textColor = 'FFF';
|
||||||
$quadWidth = $width - 7;
|
$quadWidth = $width - 7;
|
||||||
|
|
||||||
// mainframe
|
// mainframe
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$frame->setSize($width, $height);
|
$frame->setSize($width, $height);
|
||||||
$frame->setPosition($x + $width / 2, 0);
|
$frame->setPosition($x + $width / 2, 0);
|
||||||
|
|
||||||
// Add Close Quad (X)
|
// Add Close Quad (X)
|
||||||
$closeQuad = new Quad_Icons64x64_1();
|
$closeQuad = new Quad_Icons64x64_1();
|
||||||
$frame->add($closeQuad);
|
$frame->add($closeQuad);
|
||||||
@ -394,14 +382,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$closeQuad->setSize(6, 6);
|
$closeQuad->setSize(6, 6);
|
||||||
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
||||||
$closeQuad->setAction(self::ACTION_CLOSE_PLAYER_ADV);
|
$closeQuad->setAction(self::ACTION_CLOSE_PLAYER_ADV);
|
||||||
|
|
||||||
// Background Quad
|
// Background Quad
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($backgroundQuad);
|
$frame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($width, $height);
|
$backgroundQuad->setSize($width, $height);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
$backgroundQuad->setZ(0.1);
|
$backgroundQuad->setZ(0.1);
|
||||||
|
|
||||||
// Show headline
|
// Show headline
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
@ -412,7 +400,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setTextSize($textSize);
|
$label->setTextSize($textSize);
|
||||||
$label->setText("Advanced Actions");
|
$label->setText("Advanced Actions");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
// Show Nickname
|
// Show Nickname
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
@ -424,16 +412,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setTextSize($textSize);
|
$label->setTextSize($textSize);
|
||||||
$label->setText($player->nickname);
|
$label->setText($player->nickname);
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
// Mute Player
|
// Mute Player
|
||||||
$y = $height / 2 - 14;
|
$y = $height / 2 - 14;
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = new Quad_BgsPlayerCard();
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setX(0);
|
$quad->setX(0);
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
||||||
$quad->setSize($quadWidth, 5);
|
$quad->setSize($quadWidth, 5);
|
||||||
|
|
||||||
$label = new Label_Button();
|
$label = new Label_Button();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
@ -442,112 +430,111 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setStyle($style);
|
$label->setStyle($style);
|
||||||
$label->setTextSize($textSize);
|
$label->setTextSize($textSize);
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
if (!$this->maniaControl->playerManager->playerActions->isPlayerMuted($login)) {
|
if(!$this->maniaControl->playerManager->playerActions->isPlayerMuted($login)) {
|
||||||
$label->setText("Mute");
|
$label->setText("Mute");
|
||||||
$quad->setAction(self::ACTION_MUTE_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_MUTE_PLAYER . "." . $login);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$label->setText("UnMute");
|
$label->setText("UnMute");
|
||||||
$quad->setAction(self::ACTION_UNMUTE_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_UNMUTE_PLAYER . "." . $login);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn Player
|
// Warn Player
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
$quad = clone $quad;
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
|
||||||
|
|
||||||
$label = clone $label;
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setText("Warn");
|
$label->setText("Warn");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
|
|
||||||
// Show Kick
|
// Show Kick
|
||||||
$quad = clone $quad;
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
|
||||||
|
|
||||||
$label = clone $label;
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setText("Kick");
|
$label->setText("Kick");
|
||||||
$label->setTextColor("F90");
|
$label->setTextColor("F90");
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Ban
|
// Show Ban
|
||||||
$quad = clone $quad;
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setAction(self::ACTION_BAN_PLAYER . "." . $login);
|
$quad->setAction(self::ACTION_BAN_PLAYER . "." . $login);
|
||||||
|
|
||||||
$label = clone $label;
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setText("Ban");
|
$label->setText("Ban");
|
||||||
$label->setTextColor("700");
|
$label->setTextColor("700");
|
||||||
|
|
||||||
$y -= 10;
|
$y -= 10;
|
||||||
// Show Add as Master-Admin
|
// Show Add as Master-Admin
|
||||||
$quad = clone $quad;
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setAction(self::ACTION_ADD_AS_MASTER . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_MASTER . "." . $login);
|
||||||
|
|
||||||
$label = clone $label;
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
|
|
||||||
$label->setText("Set SuperAdmin");
|
$label->setText("Set SuperAdmin");
|
||||||
|
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Add as Admin
|
// Show Add as Admin
|
||||||
$quad = clone $quad;
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setAction(self::ACTION_ADD_AS_ADMIN . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_ADMIN . "." . $login);
|
||||||
|
|
||||||
$label = clone $label;
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setText("Set Admin");
|
$label->setText("Set Admin");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Show Add as Moderator
|
// Show Add as Moderator
|
||||||
$quad = clone $quad;
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setAction(self::ACTION_ADD_AS_MOD . "." . $login);
|
$quad->setAction(self::ACTION_ADD_AS_MOD . "." . $login);
|
||||||
|
|
||||||
$label = clone $label;
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setText("Set Moderator");
|
$label->setText("Set Moderator");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$y -= 5;
|
$y -= 5;
|
||||||
// Revoke Rights
|
// Revoke Rights
|
||||||
$quad = clone $quad;
|
$quad = clone $quad;
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setY($y);
|
$quad->setY($y);
|
||||||
$quad->setAction(self::ACTION_REVOKE_RIGHTS . "." . $login);
|
$quad->setAction(self::ACTION_REVOKE_RIGHTS . "." . $login);
|
||||||
|
|
||||||
$label = clone $label;
|
$label = clone $label;
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setText("Revoke Rights");
|
$label->setText("Revoke Rights");
|
||||||
$label->setTextColor("700");
|
$label->setTextColor("700");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $frame;
|
return $frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +551,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Closes the player advanced widget widget
|
* Closes the player advanced widget widget
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function closePlayerAdvancedWidget(array $callback, Player $player) {
|
public function closePlayerAdvancedWidget(array $callback, Player $player) {
|
||||||
@ -578,15 +565,17 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$actionArray = explode('.', $actionId);
|
$actionArray = explode('.', $actionId);
|
||||||
if (count($actionArray) <= 2) return;
|
if(count($actionArray) <= 2) {
|
||||||
|
return;
|
||||||
$action = $actionArray[0] . "." . $actionArray[1];
|
}
|
||||||
$adminLogin = $callback[1][1];
|
|
||||||
|
$action = $actionArray[0] . "." . $actionArray[1];
|
||||||
|
$adminLogin = $callback[1][1];
|
||||||
$targetLogin = $actionArray[2];
|
$targetLogin = $actionArray[2];
|
||||||
|
|
||||||
switch ($action) {
|
switch($action) {
|
||||||
case self::ACTION_SPECTATE_PLAYER: // TODO not working yet
|
case self::ACTION_SPECTATE_PLAYER: // TODO not working yet
|
||||||
$this->maniaControl->client->query('ForceSpectator', $adminLogin, PlayerActions::SPECTATOR_SPECTATOR);
|
$this->maniaControl->client->query('ForceSpectator', $adminLogin, PlayerActions::SPECTATOR_SPECTATOR);
|
||||||
$this->maniaControl->client->query('ForceSpectatorTarget', $adminLogin, $targetLogin, 1);
|
$this->maniaControl->client->query('ForceSpectatorTarget', $adminLogin, $targetLogin, 1);
|
||||||
@ -603,8 +592,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_RED);
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_RED);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_FORCE_SPEC:
|
case self::ACTION_FORCE_SPEC:
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||||
PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_MUTE_PLAYER:
|
case self::ACTION_MUTE_PLAYER:
|
||||||
$this->maniaControl->playerManager->playerActions->mutePlayer($adminLogin, $targetLogin);
|
$this->maniaControl->playerManager->playerActions->mutePlayer($adminLogin, $targetLogin);
|
||||||
@ -628,15 +616,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->advancedPlayerWidget($admin, $targetLogin);
|
$this->advancedPlayerWidget($admin, $targetLogin);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_MASTER:
|
case self::ACTION_ADD_AS_MASTER:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||||
AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_ADMIN:
|
case self::ACTION_ADD_AS_ADMIN:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ADD_AS_MOD:
|
case self::ACTION_ADD_AS_MOD:
|
||||||
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_REVOKE_RIGHTS:
|
case self::ACTION_REVOKE_RIGHTS:
|
||||||
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
||||||
@ -650,17 +636,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function updateWidget(array $callback) {
|
public function updateWidget(array $callback) {
|
||||||
foreach ($this->playersListShown as $login => $shown) {
|
foreach($this->playersListShown as $login => $shown) {
|
||||||
if ($shown) {
|
if($shown) {
|
||||||
// Check if Shown player still exists
|
// Check if Shown player still exists
|
||||||
if ($shown != self::SHOWN_MAIN_WINDOW && $this->maniaControl->playerManager->getPlayer($shown) == null) {
|
if($shown != self::SHOWN_MAIN_WINDOW && $this->maniaControl->playerManager->getPlayer($shown) == null) {
|
||||||
$this->playersListShown[$login] = false;
|
$this->playersListShown[$login] = false;
|
||||||
}
|
}
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
if ($player != null) {
|
if($player != null) {
|
||||||
$this->showPlayerList($player);
|
$this->showPlayerList($player);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// if player with the open widget disconnected remove him from the shownlist
|
// if player with the open widget disconnected remove him from the shownlist
|
||||||
unset($this->playersListShown[$login]);
|
unset($this->playersListShown[$login]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user