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

@ -212,7 +212,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
* @param Frame $frame
* @param array $labelStrings
* @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()) {
// TODO overwrite standard properties with properties from array
@ -225,7 +225,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
$profile = (isset($properties['profile']) ? $properties['profile'] : false);
$script = (isset($properties['script']) ? $properties['script'] : null);
$frames = array();
$labels = array();
foreach($labelStrings as $text => $x) {
$label = new Label_Text();
$frame->add($label);
@ -240,9 +240,9 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
$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) {
return;
}
$this->pid = $rpcInfos['PlayerId'];
$this->login = $rpcInfos['Login'];
$this->nickname = Formatter::stripDirtyCodes($rpcInfos['NickName']);

View File

@ -1,14 +1,83 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 03.01.14
* Time: 16:04
*/
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 {
/**
* 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

@ -47,6 +47,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed';
const SHOWN_MAIN_WINDOW = -1;
/**
* Private properties
@ -59,7 +60,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
private $playersListShown = array();
/**
* Create a new server commands instance
* Create a PlayerList instance
*
* @param ManiaControl $maniaControl
*/
@ -164,11 +165,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$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);
// $properties = array('profile' => $listPlayer->login, 'script' => $script);
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
$frames = $this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
/** @var Label $nicknameLabel */
$nicknameLabel = $frames[1];
$nicknameLabel->setAction(self::ACTION_OPEN_PLAYER_DETAILED . '.' . $listPlayer->login);
$playerFrame->setY($y);
// Team Emblem
@ -576,7 +580,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$adminLogin = $callback[1][1];
$targetLogin = $actionArray[2];
var_dump($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:
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::BLUE_TEAM);
break;

View File

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