begin playerlist
This commit is contained in:
parent
4428fd183c
commit
5d8ae12755
@ -37,6 +37,7 @@ require_once __DIR__ . '/Maps/MapManager.php';
|
||||
require_once __DIR__ . '/Maps/MapList.php';
|
||||
require_once __DIR__ . '/Players/PlayerManager.php';
|
||||
require_once __DIR__ . '/Plugins/PluginManager.php';
|
||||
require_once __DIR__ . '/Players/PlayerList.php';
|
||||
require_once __DIR__ . '/Server/Server.php';
|
||||
require_once __DIR__ . '/Settings/SettingManager.php';
|
||||
require_once __DIR__ . '/UpdateManager.php';
|
||||
|
@ -30,6 +30,9 @@ use MXInfoSearcher;
|
||||
|
||||
class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
const ACTION_CLOSEWIDGET = 'MapList.CloseWidget';
|
||||
const ACTION_ADD_MAP = 'MapList.AddMap';
|
||||
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
||||
@ -134,7 +137,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$headFrame = new Frame();
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($y - 3);
|
||||
$array = array("Id" => $x + 5, "Name" => $x + 17, "Author" => $x + 70, "Mood" => $x + 90, "Type" => $x + 105);
|
||||
$array = array("Id" => $x + 5, "Name" => $x + 17, "Author" => $x + 65, "Mood" => $x + 100, "Type" => $x + 115);
|
||||
$this->maniaControl->manialinkManager->labelLine($headFrame,$array);
|
||||
|
||||
$i = 0;
|
||||
@ -142,7 +145,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
foreach($maps as $map){
|
||||
$mapFrame = new Frame();
|
||||
$frame->add($mapFrame);
|
||||
$array = array($map->id => $x + 5, $map->name => $x + 17, $map->author => $x + 70, $map->mood => $x + 90, $map->maptype => $x + 105);
|
||||
$array = array($map->id => $x + 5, $map->name => $x + 17, $map->author => $x + 65, $map->mood => $x + 100, $map->maptype => $x + 115);
|
||||
$this->maniaControl->manialinkManager->labelLine($mapFrame,$array);
|
||||
$mapFrame->setY($y);
|
||||
|
||||
|
@ -44,7 +44,7 @@ class MapManager implements CallbackListener {
|
||||
|
||||
// Create map commands instance
|
||||
$this->mapCommands = new MapCommands($maniaControl);
|
||||
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap');
|
||||
|
@ -71,6 +71,20 @@ class Player {
|
||||
return ($this->pid <= 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get province
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProvince() {
|
||||
$pathParts = explode('|', $this->path);
|
||||
if (isset($pathParts[3])) {
|
||||
return $pathParts[3];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get country
|
||||
*
|
||||
|
@ -17,7 +17,7 @@ class PlayerCommands implements CommandListener {
|
||||
* Private properties
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
|
||||
private $playerList = null;
|
||||
/**
|
||||
* Create a new server commands instance
|
||||
*
|
||||
@ -34,8 +34,17 @@ class PlayerCommands implements CommandListener {
|
||||
$this->maniaControl->commandManager->registerCommandListener('forcespectator', $this, 'command_ForceSpectator',true);
|
||||
$this->maniaControl->commandManager->registerCommandListener('forceplay', $this, 'command_ForcePlayer',true);
|
||||
$this->maniaControl->commandManager->registerCommandListener('forceplayer', $this, 'command_ForcePlayer',true);
|
||||
$this->maniaControl->commandManager->registerCommandListener('addbot', $this, 'command_AddFakePlayers',true);
|
||||
$this->maniaControl->commandManager->registerCommandListener('removebot', $this, 'command_RemoveFakePlayers',true);
|
||||
$this->maniaControl->commandManager->registerCommandListener('addbots', $this, 'command_AddFakePlayers',true);
|
||||
$this->maniaControl->commandManager->registerCommandListener('removebots', $this, 'command_RemoveFakePlayers',true);
|
||||
|
||||
// Register for player chat commands
|
||||
$this->maniaControl->commandManager->registerCommandListener('player', $this, 'command_playerList');
|
||||
$this->maniaControl->commandManager->registerCommandListener('players', $this, 'command_playerList');
|
||||
|
||||
$this->playerList = new PlayerList($this->maniaControl);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,4 +221,13 @@ class PlayerCommands implements CommandListener {
|
||||
}
|
||||
$this->maniaControl->chat->sendSuccess('Fake players disconnected!', $player->login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Player list command
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_playerList(array $chatCallback, Player $player) {
|
||||
$this->playerList->showPlayerList($player);
|
||||
}
|
||||
}
|
||||
|
130
application/core/Players/PlayerList.php
Normal file
130
application/core/Players/PlayerList.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Players;
|
||||
|
||||
|
||||
use FML\Controls\Frame;
|
||||
use FML\Controls\Quad;
|
||||
use FML\Controls\Quads\Quad_BgRaceScore2;
|
||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use FML\ManiaLink;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
|
||||
class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
const ACTION_CLOSEWIDGET = 'PlayerList.CloseWidget';
|
||||
|
||||
/**
|
||||
* Private properties
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
private $width;
|
||||
private $height;
|
||||
private $quadStyle;
|
||||
private $quadSubstyle;
|
||||
|
||||
/**
|
||||
* Create a new server commands instance
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET , $this,
|
||||
'closeWidget');
|
||||
/* $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
||||
'handleManialinkPageAnswer');*/
|
||||
|
||||
//settings
|
||||
$this->width = 150;
|
||||
$this->height = 80;
|
||||
$this->quadStyle = Quad_BgRaceScore2::STYLE; //TODO add default menu style to style manager
|
||||
$this->quadSubstyle = Quad_BgRaceScore2::SUBSTYLE_HandleSelectable;
|
||||
|
||||
}
|
||||
|
||||
public function showPlayerList(Player $player){
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
|
||||
//mainframe
|
||||
$frame = new Frame();
|
||||
$maniaLink->add($frame);
|
||||
$frame->setSize($this->width,$this->height);
|
||||
$frame->setPosition(0, 0);
|
||||
|
||||
//Background Quad
|
||||
$backgroundQuad = new Quad();
|
||||
$frame->add($backgroundQuad);
|
||||
$backgroundQuad->setSize($this->width,$this->height);
|
||||
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle);
|
||||
|
||||
// Add Close Quad (X)
|
||||
$closeQuad = new Quad_Icons64x64_1();
|
||||
$frame->add($closeQuad);
|
||||
$closeQuad->setPosition($this->width * 0.483, $this->height * 0.467, 3);
|
||||
$closeQuad->setSize(6, 6);
|
||||
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
||||
$closeQuad->setAction(self::ACTION_CLOSEWIDGET );
|
||||
|
||||
//Start offsets
|
||||
$x = -$this->width / 2;
|
||||
$y = $this->height / 2;
|
||||
|
||||
//Headline
|
||||
$headFrame = new Frame();
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($y - 3);
|
||||
//$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 + 50, "Zone" => $x + 75);
|
||||
$this->maniaControl->manialinkManager->labelLine($headFrame,$array);
|
||||
|
||||
//get PlayerList
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
|
||||
$i = 1;
|
||||
$y -= 10;
|
||||
foreach($players as $listPlayer){
|
||||
//$path = substr($listPlayer->path, 6);
|
||||
$path = $listPlayer->getCountry() . " - " . $listPlayer->getProvince();
|
||||
$playerFrame = new Frame();
|
||||
$frame->add($playerFrame);
|
||||
//$array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $listPlayer->ladderRank => $x + 60, $listPlayer->ladderScore => $x + 70, $path => $x + 85);
|
||||
$array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $path => $x + 75);
|
||||
$this->maniaControl->manialinkManager->labelLine($playerFrame,$array);
|
||||
$playerFrame->setY($y);
|
||||
|
||||
//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);
|
||||
*/
|
||||
$i++;
|
||||
$y -= 4;
|
||||
}
|
||||
|
||||
|
||||
//render and display xml
|
||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the widget
|
||||
* @param array $callback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function closeWidget(array $callback, Player $player) {
|
||||
$this->maniaControl->manialinkManager->closeWidget($player);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user