added playerdetailed

This commit is contained in:
kremsy 2014-01-03 16:24:35 +01:00
parent d5d3df1e1f
commit c9da02f5bf
5 changed files with 117 additions and 35 deletions

View File

@ -91,7 +91,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
*/ */
public function unregisterManialinkPageAnswerListener(ManialinkPageAnswerListener $listener) { public function unregisterManialinkPageAnswerListener(ManialinkPageAnswerListener $listener) {
$keys = array_keys($this->pageAnswerListeners, $listener); $keys = array_keys($this->pageAnswerListeners, $listener);
foreach ($keys as $key) { foreach($keys as $key) {
unset($this->pageAnswerListeners[$key]); unset($this->pageAnswerListeners[$key]);
} }
@ -112,7 +112,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
return; return;
} }
// Inform page answer listeners // Inform page answer listeners
foreach ($this->pageAnswerListeners[$actionId] as $listener) { foreach($this->pageAnswerListeners[$actionId] as $listener) {
call_user_func(array($listener[0], $listener[1]), $callback, $player); call_user_func(array($listener[0], $listener[1]), $callback, $player);
} }
} }
@ -135,7 +135,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
} }
if(is_array($logins)) { if(is_array($logins)) {
$success = true; $success = true;
foreach ($logins as $login) { foreach($logins as $login) {
$subSuccess = $this->maniaControl->client->query('SendDisplayManialinkPageToLogin', $login, $manialinkText, $timeout, $hideOnClick); $subSuccess = $this->maniaControl->client->query('SendDisplayManialinkPageToLogin', $login, $manialinkText, $timeout, $hideOnClick);
if(!$subSuccess) { if(!$subSuccess) {
$success = false; $success = false;
@ -212,7 +212,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
* @param Frame $frame * @param Frame $frame
* @param array $labelStrings * @param array $labelStrings
* @param array $properties * @param array $properties
* @return array Returns the frames (to add special Properties later) * @return array Returns the labels (to add special Properties later)
*/ */
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) { public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
// TODO overwrite standard properties with properties from array // TODO overwrite standard properties with properties from array
@ -225,8 +225,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
$profile = (isset($properties['profile']) ? $properties['profile'] : false); $profile = (isset($properties['profile']) ? $properties['profile'] : false);
$script = (isset($properties['script']) ? $properties['script'] : null); $script = (isset($properties['script']) ? $properties['script'] : null);
$frames = array(); $labels = array();
foreach ($labelStrings as $text => $x) { foreach($labelStrings as $text => $x) {
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setHAlign($hAlign); $label->setHAlign($hAlign);
@ -240,9 +240,9 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
$script->addProfileButton($label, $profile); $script->addProfileButton($label, $profile);
} }
$frames[] = $frame; // add Frame to the frames array $labels[] = $label; // add Label to the labels array
} }
return $frames; return $labels;
} }
} }

View File

@ -41,6 +41,7 @@ class Player {
if(!$rpcInfos) { if(!$rpcInfos) {
return; return;
} }
$this->pid = $rpcInfos['PlayerId']; $this->pid = $rpcInfos['PlayerId'];
$this->login = $rpcInfos['Login']; $this->login = $rpcInfos['Login'];
$this->nickname = Formatter::stripDirtyCodes($rpcInfos['NickName']); $this->nickname = Formatter::stripDirtyCodes($rpcInfos['NickName']);

View File

@ -1,14 +1,83 @@
<?php <?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 03.01.14
* Time: 16:04
*/
namespace ManiaControl\Players; namespace ManiaControl\Players;
use FML\Controls\Frame;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink;
use FML\Script\Script;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager;
/**
* Player Detailed Page
*
* @author steeffeen & kremsy
*/
class PlayerDetailed { class PlayerDetailed {
/**
* Private properties
*/
private $maniaControl = null;
/**
* Create a new Player Detailed instance
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
/* $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(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
// Update Widget Events
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget'); */
// settings
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
}
public function showPlayerDetailed(Player $player, $targetLogin) {
var_dump($player);
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
// Create script and features
$script = new Script();
$maniaLink->setScript($script);
// 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(ManialinkManager::ACTION_CLOSEWIDGET);
// render and display xml
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
}
} }

View File

@ -33,21 +33,22 @@ 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 SHOWN_MAIN_WINDOW = -1; const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed';
const SHOWN_MAIN_WINDOW = -1;
/** /**
* Private properties * Private properties
*/ */
@ -59,7 +60,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
private $playersListShown = array(); private $playersListShown = array();
/** /**
* Create a new server commands instance * Create a PlayerList instance
* *
* @param ManiaControl $maniaControl * @param ManiaControl $maniaControl
*/ */
@ -164,11 +165,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$lineQuad->setZ(0.001); $lineQuad->setZ(0.001);
} }
// $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 + 18, $listPlayer->login => $x + 60, $path => $x + 91); $array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 60, $path => $x + 91);
// $properties = array('profile' => $listPlayer->login, 'script' => $script); $frames = $this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
/** @var Label $nicknameLabel */
$nicknameLabel = $frames[1];
$nicknameLabel->setAction(self::ACTION_OPEN_PLAYER_DETAILED . '.' . $listPlayer->login);
$playerFrame->setY($y); $playerFrame->setY($y);
// Team Emblem // Team Emblem
@ -576,7 +580,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$adminLogin = $callback[1][1]; $adminLogin = $callback[1][1];
$targetLogin = $actionArray[2]; $targetLogin = $actionArray[2];
var_dump($action);
switch($action) { switch($action) {
case self::ACTION_OPEN_PLAYER_DETAILED:
$player = $this->maniaControl->playerManager->getPlayer($adminLogin);
$this->maniaControl->playerManager->playerDetailed->showPlayerDetailed($player, $targetLogin);
break;
case self::ACTION_FORCE_BLUE: case self::ACTION_FORCE_BLUE:
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::BLUE_TEAM); $this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::BLUE_TEAM);
break; break;

View File

@ -4,6 +4,7 @@ namespace ManiaControl\Players;
require_once __DIR__ . '/Player.php'; require_once __DIR__ . '/Player.php';
require_once __DIR__ . '/PlayerCommands.php'; require_once __DIR__ . '/PlayerCommands.php';
require_once __DIR__ . '/PlayerDetailed.php';
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
@ -33,6 +34,7 @@ class PlayerManager implements CallbackListener {
*/ */
public $playerActions = null; public $playerActions = null;
public $playerCommands = null; public $playerCommands = null;
public $playerDetailed = null;
public $playerList = array(); public $playerList = array();
/** /**
@ -51,6 +53,7 @@ class PlayerManager implements CallbackListener {
$this->playerCommands = new PlayerCommands($maniaControl); $this->playerCommands = new PlayerCommands($maniaControl);
$this->playerActions = new PlayerActions($maniaControl); $this->playerActions = new PlayerActions($maniaControl);
$this->playerDetailed = new PlayerDetailed($maniaControl);
// Init settings // Init settings
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true); $this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);