2014-05-04 15:43:16 +02:00
< ? php
2014-05-07 21:42:23 +02:00
2014-05-04 15:43:16 +02:00
namespace TheM ;
use FML\Controls\Frame ;
use FML\Controls\Labels\Label_Button ;
use FML\Controls\Labels\Label_Text ;
use FML\Controls\Quad ;
use FML\Controls\Quads\Quad_Icons64x64_1 ;
use FML\ManiaLink ;
use ManiaControl\Callbacks\CallbackListener ;
use ManiaControl\Callbacks\TimerListener ;
use ManiaControl\Commands\CommandListener ;
use ManiaControl\ManiaControl ;
use ManiaControl\Manialinks\ManialinkManager ;
use ManiaControl\Manialinks\ManialinkPageAnswerListener ;
use ManiaControl\Players\Player ;
use ManiaControl\Plugins\Plugin ;
2014-05-13 16:40:05 +02:00
use ManiaControl\Utils\Formatter ;
2014-05-04 15:43:16 +02:00
/**
* TeamSpeak Info plugin
* Based on the TeamSpeak Info plugin created by undef . de :
* http :// forum . maniaplanet . com / viewtopic . php ? f = 450 & t = 24805
*
* @ author TheM
*/
class TeamSpeakPlugin implements CallbackListener , CommandListener , ManialinkPageAnswerListener , TimerListener , Plugin {
2014-08-02 22:31:46 +02:00
/*
2014-05-04 15:43:16 +02:00
* Constants
*/
const ID = 23 ;
2014-05-04 15:49:18 +02:00
const VERSION = 0.11 ;
2014-05-16 20:26:08 +02:00
const NAME = 'TeamSpeak Plugin' ;
const AUTHOR = 'TheM' ;
2014-05-04 15:43:16 +02:00
const TEAMSPEAK_SID = 'TS Server ID' ;
const TEAMSPEAK_SERVERHOST = 'TS Server host' ;
const TEAMSPEAK_SERVERPORT = 'TS Server port' ;
const TEAMSPEAK_QUERYHOST = 'TS Server Query host' ;
const TEAMSPEAK_QUERYPORT = 'TS Server Query port' ;
const TEAMSPEAK_QUERYUSER = 'TS Server Query user' ;
const TEAMSPEAK_QUERYPASS = 'TS Server Query password' ;
const ACTION_OPEN_TSVIEWER = 'TSViewer.OpenWidget' ;
const TS_ICON = 'Teamspeak.png' ;
const TS_ICON_MOVER = 'Teamspeak_logo_press.png' ;
2014-08-02 22:31:46 +02:00
/*
2014-05-04 15:43:16 +02:00
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null ;
private $serverData = array ();
private $refreshTime = 0 ;
private $refreshInterval = 90 ;
/**
* Prepares the Plugin ( Init Settings )
*
* @ param ManiaControl $maniaControl
* @ return mixed
*/
public static function prepare ( ManiaControl $maniaControl ) {
$maniaControl -> settingManager -> initSetting ( get_class (), self :: TEAMSPEAK_SID , 1 );
$maniaControl -> settingManager -> initSetting ( get_class (), self :: TEAMSPEAK_SERVERHOST , 'ts3.somehoster.com' );
$maniaControl -> settingManager -> initSetting ( get_class (), self :: TEAMSPEAK_SERVERPORT , 9987 );
$maniaControl -> settingManager -> initSetting ( get_class (), self :: TEAMSPEAK_QUERYHOST , '' );
$maniaControl -> settingManager -> initSetting ( get_class (), self :: TEAMSPEAK_QUERYPORT , 10011 );
$maniaControl -> settingManager -> initSetting ( get_class (), self :: TEAMSPEAK_QUERYUSER , '' );
$maniaControl -> settingManager -> initSetting ( get_class (), self :: TEAMSPEAK_QUERYPASS , '' );
}
2014-05-13 16:40:05 +02:00
/**
* Get plugin id
*
* @ return int
*/
public static function getId () {
return self :: ID ;
}
/**
* Get Plugin Name
*
* @ return string
*/
public static function getName () {
2014-05-16 20:26:08 +02:00
return self :: NAME ;
2014-05-13 16:40:05 +02:00
}
/**
* Get Plugin Version
*
* @ return float
*/
public static function getVersion () {
return self :: VERSION ;
}
/**
* Get Plugin Author
*
* @ return string
*/
public static function getAuthor () {
2014-05-16 20:26:08 +02:00
return self :: AUTHOR ;
2014-05-13 16:40:05 +02:00
}
/**
* Get Plugin Description
*
* @ return string
*/
public static function getDescription () {
2014-05-16 20:26:08 +02:00
return 'Plugin offers a Connection with a TeamSpeak Server (via Widgets).' ;
2014-05-13 16:40:05 +02:00
}
2014-05-04 15:43:16 +02:00
/**
* Load the plugin
*
* @ param \ManiaControl\ManiaControl $maniaControl
* @ return bool
*/
public function load ( ManiaControl $maniaControl ) {
$this -> maniaControl = $maniaControl ;
$this -> checkConfig ();
$this -> refreshTime = time ();
2014-08-02 22:31:46 +02:00
$this -> maniaControl -> manialinkManager -> getIconManager () -> addIcon ( self :: TS_ICON );
$this -> maniaControl -> manialinkManager -> getIconManager () -> addIcon ( self :: TS_ICON_MOVER );
2014-05-04 15:43:16 +02:00
$this -> maniaControl -> timerManager -> registerTimerListening ( $this , 'ts3_queryServer' , 1000 );
$this -> addToMenu ();
}
/**
* Function used to check certain configuration options to check if they can be used .
*
* @ throws \Exception
*/
private function checkConfig () {
2014-05-13 16:03:26 +02:00
if ( $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_SERVERHOST ) == 'ts3.somehoster.com' ) {
2014-05-04 15:43:16 +02:00
$error = 'Missing the required serverhost, please set it up before enabling the TeamSpeak plugin!' ;
throw new \Exception ( $error );
}
$this -> ts3_queryServer (); // Get latest information from the TeamSpeak server
if ( ! isset ( $this -> serverData [ 'channels' ]) || count ( $this -> serverData [ 'channels' ]) == 0 ) {
$error = 'Could not make proper connections with the server!' ;
throw new \Exception ( $error );
}
}
/**
2014-05-13 16:40:05 +02:00
* TeamSpeak related functions
* The functions are based upon tsstatus . php from http :// tsstatus . sebastien . me /
* and were optimized by SilentStorm .
* Functions originally from the TeamSpeakInfo plugin made by undef . de for XAseco ( 2 ) and MPAseco .
2014-05-04 15:43:16 +02:00
*/
2014-05-13 16:40:05 +02:00
public function ts3_queryServer () {
if ( time () >= $this -> refreshTime ) {
$this -> refreshTime = ( time () + $this -> refreshInterval );
$queryHost = $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_QUERYHOST );
$host = $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_SERVERHOST );
$host = ( $queryHost != '' ) ? $queryHost : $host ;
$queryPort = $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_QUERYPORT );
$socket = fsockopen ( @ $host , $queryPort , $errno , $errstr , 2 );
if ( $socket ) {
socket_set_timeout ( $socket , 2 );
$is_ts3 = trim ( fgets ( $socket )) == 'TS3' ;
if ( ! $is_ts3 ) {
trigger_error ( '[TeamSpeakPlugin] Server at "' . $host . '" is not a Teamspeak3-Server or you have setup a bad query-port!' , E_USER_WARNING );
}
$queryuser = $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_QUERYUSER );
$querypass = $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_QUERYPASS );
if (( $queryuser != '' ) && ! is_numeric ( $queryuser ) && $queryuser != false && ( $querypass != '' ) && ! is_numeric ( $querypass ) && $querypass != false ) {
$ret = $this -> ts3_sendCommand ( $socket , 'login client_login_name=' . $this -> ts3_escape ( $queryuser ) . ' client_login_password=' . $this -> ts3_escape ( $querypass ));
if ( stripos ( $ret , " error id=0 " ) === false ) {
trigger_error ( " [TeamSpeakPlugin] Failed to authenticate with TS3 Server! Make sure you put the correct username & password in teamspeak.xml " , E_USER_WARNING );
return ;
}
}
$response = '' ;
$response .= $this -> ts3_sendCommand ( $socket , 'use sid=' . $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_SID ));
$this -> ts3_sendCommand ( $socket , 'clientupdate client_nickname=' . $this -> ts3_escape ( 'ManiaControl Viewer' ));
$response .= $this -> ts3_sendCommand ( $socket , 'serverinfo' );
$response .= $this -> ts3_sendCommand ( $socket , 'channellist -topic -flags -voice -limits' );
$response .= $this -> ts3_sendCommand ( $socket , 'clientlist -uid -away -voice -groups' );
2014-05-16 20:26:08 +02:00
fwrite ( $socket , " quit \n " );
2014-05-13 16:40:05 +02:00
fclose ( $socket );
$lines = explode ( " error id=0 msg=ok \n \r " , $response );
if ( count ( $lines ) == 5 ) {
$serverdata = $this -> ts3_parseLine ( $lines [ 1 ]);
$this -> serverData [ 'server' ] = $serverdata [ 0 ];
$this -> serverData [ 'channels' ] = $this -> ts3_parseLine ( $lines [ 2 ]);
$users = $this -> ts3_parseLine ( $lines [ 3 ]);
$this -> serverData [ 'users' ] = array (); // reset userslist
foreach ( $users as $user ) {
if ( $user [ 'client_nickname' ] != 'ManiaControl Viewer' ) {
$this -> serverData [ 'users' ][] = $user ;
}
}
// Subtract reserved slots
$this -> serverData [ 'server' ][ 'virtualserver_maxclients' ] -= $this -> serverData [ 'server' ][ 'virtualserver_reserved_slots' ];
// Make ping value int
$this -> serverData [ 'server' ][ 'virtualserver_total_ping' ] = intval ( $this -> serverData [ 'server' ][ 'virtualserver_total_ping' ]);
// Format the Date of server startup
$this -> serverData [ 'server' ][ 'virtualserver_uptime' ] = date ( 'Y-m-d H:i:s' , ( time () - $this -> serverData [ 'server' ][ 'virtualserver_uptime' ]));
// Always subtract all Query Clients
$this -> serverData [ 'server' ][ 'virtualserver_clientsonline' ] -= $this -> serverData [ 'server' ][ 'virtualserver_queryclientsonline' ];
}
} else {
trigger_error ( " [TeamSpeakPlugin] Failed to connect with TS3 server; socket error: " . $errstr . " [ " . $errno . " ] " , E_USER_WARNING );
}
}
2014-05-04 15:43:16 +02:00
}
/**
2014-05-13 16:40:05 +02:00
* TS Function to send a command to the TeamSpeak server .
*
* @ param resource $socket
* @ param string $cmd
* @ return string
2014-05-04 15:43:16 +02:00
*/
2014-05-13 16:40:05 +02:00
private function ts3_sendCommand ( $socket , $cmd ) {
2014-05-16 20:26:08 +02:00
@ fwrite ( $socket , " $cmd\n " );
2014-05-04 15:43:16 +02:00
2014-05-13 16:40:05 +02:00
$response = '' ;
/* while ( strpos ( $response , 'error id=' ) === false ) {
$response .= fread ( $socket , 8096 );
} */
/* while ( ! feof ( $socket )) {
$response .= fread ( $socket , 8192 );
} */
$info = array ( 'timed_out' => false );
while ( ! feof ( $socket ) && ! $info [ 'timed_out' ] && strpos ( $response , 'error id=' ) === false ) {
$response .= fread ( $socket , 1024 );
$info = stream_get_meta_data ( $socket );
}
return $response ;
2014-05-04 15:43:16 +02:00
}
/**
2014-05-13 16:40:05 +02:00
* TS Function used to escape characters in channelnames .
2014-05-04 15:43:16 +02:00
*
2014-05-13 16:40:05 +02:00
* @ param string $str
* @ return mixed
2014-05-04 15:43:16 +02:00
*/
2014-05-13 16:40:05 +02:00
private function ts3_escape ( $str ) {
return str_replace ( array ( chr ( 92 ), chr ( 47 ), chr ( 32 ), chr ( 124 ), chr ( 7 ), chr ( 8 ), chr ( 12 ), chr ( 10 ), chr ( 3 ), chr ( 9 ), chr ( 11 )), array ( '\\\\' , " \ / " , " \ s " , " \ p " , " \ a " , " \ b " , " \ f " , " \n " , " \r " , " \t " , " \ v " ), $str );
2014-05-04 15:43:16 +02:00
}
/**
2014-05-13 16:40:05 +02:00
* TS Function used to parse lines in the serverresponse .
2014-05-04 15:43:16 +02:00
*
2014-05-13 16:40:05 +02:00
* @ param string $rawLine
* @ return array
2014-05-04 15:43:16 +02:00
*/
2014-05-13 16:40:05 +02:00
private function ts3_parseLine ( $rawLine ) {
$datas = array ();
$rawItems = explode ( '|' , $rawLine );
foreach ( $rawItems as & $rawItem ) {
$rawDatas = explode ( ' ' , $rawItem );
$tempDatas = array ();
foreach ( $rawDatas as & $rawData ) {
$ar = explode ( " = " , $rawData , 2 );
$tempDatas [ $ar [ 0 ]] = isset ( $ar [ 1 ]) ? $this -> ts3_unescape ( $ar [ 1 ]) : '' ;
}
$datas [] = $tempDatas ;
}
unset ( $rawItem , $rawData );
return $datas ;
2014-05-04 15:43:16 +02:00
}
/**
2014-05-13 16:40:05 +02:00
* TS Function used to unescape characters in channelnames .
2014-05-04 15:43:16 +02:00
*
2014-05-13 16:40:05 +02:00
* @ param string $str
* @ return mixed
2014-05-04 15:43:16 +02:00
*/
2014-05-13 16:40:05 +02:00
private function ts3_unescape ( $str ) {
return str_replace ( array ( '\\\\' , " \ / " , " \ s " , " \ p " , " \ a " , " \ b " , " \ f " , " \n " , " \r " , " \t " , " \ v " ), array ( chr ( 92 ), chr ( 47 ), chr ( 32 ), chr ( 124 ), chr ( 7 ), chr ( 8 ), chr ( 12 ), chr ( 10 ), chr ( 3 ), chr ( 9 ), chr ( 11 )), $str );
2014-05-04 15:43:16 +02:00
}
/**
2014-05-13 16:40:05 +02:00
* Function used insert the icon into the menu .
2014-05-04 15:43:16 +02:00
*/
2014-05-13 16:40:05 +02:00
private function addToMenu () {
$this -> maniaControl -> manialinkManager -> registerManialinkPageAnswerListener ( self :: ACTION_OPEN_TSVIEWER , $this , 'command_tsViewer' );
$itemQuad = new Quad ();
2014-08-02 22:31:46 +02:00
$itemQuad -> setImage ( $this -> maniaControl -> manialinkManager -> getIconManager () -> getIcon ( self :: TS_ICON ));
$itemQuad -> setImageFocus ( $this -> maniaControl -> manialinkManager -> getIconManager () -> getIcon ( self :: TS_ICON_MOVER ));
2014-05-13 16:40:05 +02:00
$itemQuad -> setAction ( self :: ACTION_OPEN_TSVIEWER );
$this -> maniaControl -> actionsMenu -> addMenuItem ( $itemQuad , true , 1 , 'Open TeamSpeak Viewer' );
2014-05-04 15:43:16 +02:00
}
/**
2014-05-13 16:40:05 +02:00
* Unload the plugin and its resources
2014-05-04 15:43:16 +02:00
*/
2014-05-13 16:40:05 +02:00
public function unload () {
$this -> serverData = array ();
$this -> maniaControl -> actionsMenu -> removeMenuItem ( 1 , true );
2014-05-04 15:43:16 +02:00
}
/**
* Function handling the pressing of the icon .
*
* @ param array $chatCallback
* @ param Player $player
*/
public function command_tsViewer ( array $chatCallback , Player $player ) {
$this -> showWidget ( $player );
}
/**
* Function showing the TeamSpeak widget to the player .
*
2014-05-13 16:40:05 +02:00
* @ param mixed $player
2014-05-04 15:43:16 +02:00
*/
private function showWidget ( $player ) {
2014-08-02 22:31:46 +02:00
$width = $this -> maniaControl -> manialinkManager -> getStyleManager () -> getListWidgetsWidth ();
$height = $this -> maniaControl -> manialinkManager -> getStyleManager () -> getListWidgetsHeight ();
$quadStyle = $this -> maniaControl -> manialinkManager -> getStyleManager () -> getDefaultMainWindowStyle ();
$quadSubstyle = $this -> maniaControl -> manialinkManager -> getStyleManager () -> getDefaultMainWindowSubStyle ();
2014-05-04 15:43:16 +02:00
$maniaLink = new ManiaLink ( ManialinkManager :: MAIN_MLID );
// Main frame
$frame = new Frame ();
$maniaLink -> add ( $frame );
$frame -> setSize ( $width , $height );
$frame -> setPosition ( 0 , 0 , 10 );
// Background
$backgroundQuad = new Quad ();
$frame -> add ( $backgroundQuad );
$backgroundQuad -> setSize ( $width , $height );
$backgroundQuad -> setStyles ( $quadStyle , $quadSubstyle );
// Close Quad (X)
$closeQuad = new Quad_Icons64x64_1 ();
$frame -> add ( $closeQuad );
$closeQuad -> setPosition ( $width * 0.483 , $height * 0.467 , 3 );
$closeQuad -> setSize ( 6 , 6 );
$closeQuad -> setSubStyle ( Quad_Icons64x64_1 :: SUBSTYLE_QuitRace );
$closeQuad -> setAction ( ManialinkManager :: ACTION_CLOSEWIDGET );
2014-07-17 20:01:40 +02:00
$serverName = new Label_Text ();
$frame -> add ( $serverName );
$serverName -> setY ( $height / 2 - 4 );
$serverName -> setX ( - 70 );
$serverName -> setStyle ( $serverName :: STYLE_TextCardMedium );
$serverName -> setHAlign ( 'left' );
$serverName -> setTextSize ( 1 );
$serverName -> setText ( '$oServername:$o ' . $this -> serverData [ 'server' ][ 'virtualserver_name' ]);
$serverName -> setTextColor ( 'fff' );
$serverVersion = new Label_Text ();
$frame -> add ( $serverVersion );
$serverVersion -> setY ( $height / 2 - 4 );
$serverVersion -> setX ( 2 );
$serverVersion -> setStyle ( $serverVersion :: STYLE_TextCardMedium );
$serverVersion -> setHAlign ( 'left' );
$serverVersion -> setTextSize ( 1 );
$serverVersion -> setText ( '$oServerversion:$o ' . $this -> serverData [ 'server' ][ 'virtualserver_version' ]);
$serverVersion -> setTextColor ( 'fff' );
2014-05-04 15:43:16 +02:00
$clients = new Label_Text ();
$frame -> add ( $clients );
$clients -> setY ( $height / 2 - 7 );
$clients -> setX ( - 70 );
$clients -> setStyle ( $clients :: STYLE_TextCardMedium );
$clients -> setHAlign ( 'left' );
$clients -> setTextSize ( 1 );
$clients -> setText ( '$oConnected clients:$o ' . $this -> serverData [ 'server' ][ 'virtualserver_clientsonline' ] . '/' . $this -> serverData [ 'server' ][ 'virtualserver_maxclients' ]);
$clients -> setTextColor ( 'fff' );
$channels = new Label_Text ();
$frame -> add ( $channels );
$channels -> setY ( $height / 2 - 7 );
$channels -> setX ( 2 );
$channels -> setStyle ( $channels :: STYLE_TextCardMedium );
$channels -> setHAlign ( 'left' );
$channels -> setTextSize ( 1 );
2014-07-17 20:01:40 +02:00
$noChannels = 0 ;
2014-05-13 16:40:05 +02:00
foreach ( $this -> serverData [ 'channels' ] as $channel ) {
2014-05-04 15:43:16 +02:00
if ( $channel [ 'channel_maxclients' ] == 0 || strpos ( $channel [ 'channel_name' ], 'spacer' ) > 0 ) {
continue ;
}
2014-07-17 20:01:40 +02:00
$noChannels ++ ;
2014-05-04 15:43:16 +02:00
}
2014-07-17 20:01:40 +02:00
$channels -> setText ( '$oChannels:$o ' . $noChannels );
2014-05-04 15:43:16 +02:00
$channels -> setTextColor ( 'fff' );
// Join button
2014-07-17 20:01:40 +02:00
$joinButton = new Label_Button ();
$frame -> add ( $joinButton );
$joinButton -> setWidth ( 150 );
$joinButton -> setY ( $height / 2 - 11.5 );
$joinButton -> setStyle ( $joinButton :: STYLE_CardButtonSmallWide );
$joinButton -> setText ( 'Join TeamSpeak: ' . $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_SERVERHOST ) . ':' . $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_SERVERPORT ));
$joinButton -> setTextColor ( 'fff' );
2014-05-13 16:03:26 +02:00
$url = 'ts3server://' . $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_SERVERHOST ) . '/?port=' . $this -> maniaControl -> settingManager -> getSettingValue ( $this , self :: TEAMSPEAK_SERVERPORT ) . '&nickname=' . rawurlencode ( Formatter :: stripCodes ( $player -> nickname ));
2014-07-17 20:01:40 +02:00
$joinButton -> setUrl ( $url );
2014-05-04 15:43:16 +02:00
2014-07-17 20:01:40 +02:00
$leftListQuad = new Quad ();
$frame -> add ( $leftListQuad );
$leftListQuad -> setSize ((( $width / 2 ) - 5 ), ( $height - 18 ));
$leftListQuad -> setX ( - 36 );
$leftListQuad -> setY ( $height / 2 - 46 );
$leftListQuad -> setStyles ( $quadStyle , $quadSubstyle );
2014-05-04 15:43:16 +02:00
$channels = array ();
$users = array ();
2014-07-17 20:01:40 +02:00
$userId = 0 ;
$index = 0 ;
$startX = - 69.5 ;
2014-05-13 16:40:05 +02:00
foreach ( $this -> serverData [ 'channels' ] as $channel ) {
2014-05-04 15:43:16 +02:00
if ( $channel [ 'channel_maxclients' ] == 0 || strpos ( $channel [ 'channel_name' ], 'spacer' ) > 0 ) {
continue ;
}
$channelLabel = new Label_Text ();
$frame -> add ( $channelLabel );
2014-07-17 20:01:40 +02:00
$y = 17.5 + ( $index * 2.5 );
2014-05-13 16:40:05 +02:00
$channelLabel -> setY ( $height / 2 - $y );
2014-07-17 20:01:40 +02:00
$x = $startX ;
2014-05-04 15:43:16 +02:00
if ( $channel [ 'pid' ] != 0 ) {
2014-07-17 20:01:40 +02:00
$x = $startX + 5 ;
2014-05-04 15:43:16 +02:00
}
2014-05-13 16:40:05 +02:00
$channelLabel -> setX ( $x );
$channelLabel -> setStyle ( $channelLabel :: STYLE_TextCardMedium );
$channelLabel -> setHAlign ( 'left' );
$channelLabel -> setTextSize ( 1 );
$channelLabel -> setScale ( 0.9 );
2014-05-04 15:43:16 +02:00
if ( $channel [ 'channel_flag_default' ] == 1 ) {
$channel [ 'total_clients' ] = ( $channel [ 'total_clients' ] - 1 );
} // remove query client
2014-05-13 16:40:05 +02:00
$channelLabel -> setText ( '$o' . $channel [ 'channel_name' ] . '$o (' . $channel [ 'total_clients' ] . ')' );
$channelLabel -> setTextColor ( 'fff' );
2014-05-04 15:43:16 +02:00
2014-07-17 20:01:40 +02:00
$channels [ $index ] = $channelLabel ;
2014-05-04 15:43:16 +02:00
2014-07-17 20:01:40 +02:00
$index ++ ;
2014-05-13 16:40:05 +02:00
foreach ( $this -> serverData [ 'users' ] as $user ) {
2014-05-04 15:43:16 +02:00
if ( $user [ 'cid' ] == $channel [ 'cid' ]) {
2014-05-13 16:40:05 +02:00
$userLabel = new Label_Text ();
2014-05-04 15:43:16 +02:00
$frame -> add ( $userLabel );
2014-07-17 20:01:40 +02:00
$y = 17.5 + ( $index * 2.5 );
2014-05-13 16:40:05 +02:00
$userLabel -> setY ( $height / 2 - $y );
2014-05-04 15:43:16 +02:00
if ( $channel [ 'pid' ] != 0 ) {
2014-07-17 20:01:40 +02:00
$x = $startX + 7 ;
2014-05-04 15:43:16 +02:00
} else {
2014-07-17 20:01:40 +02:00
$x = $startX + 2 ;
2014-05-04 15:43:16 +02:00
}
2014-05-13 16:40:05 +02:00
$userLabel -> setX ( $x );
$userLabel -> setStyle ( $userLabel :: STYLE_TextCardMedium );
$userLabel -> setHAlign ( 'left' );
$userLabel -> setTextSize ( 1 );
$userLabel -> setScale ( 0.9 );
$userLabel -> setText ( $user [ 'client_nickname' ]);
$userLabel -> setTextColor ( 'fff' );
2014-07-17 20:01:40 +02:00
$users [ $userId ] = $userLabel ;
2014-05-04 15:43:16 +02:00
2014-07-17 20:01:40 +02:00
$userId ++ ;
$index ++ ;
2014-05-04 15:43:16 +02:00
2014-07-17 20:01:40 +02:00
if ( $index > 22 ) {
$index = 0 ;
$startX = 2.5 ;
2014-05-04 15:43:16 +02:00
}
}
}
2014-07-17 20:01:40 +02:00
if ( $index > 22 ) {
$index = 0 ;
$startX = 2.5 ;
2014-05-04 15:43:16 +02:00
}
}
$rightlistQuad = new Quad ();
$frame -> add ( $rightlistQuad );
$rightlistQuad -> setSize ((( $width / 2 ) - 5 ), ( $height - 18 ));
$rightlistQuad -> setX ( 36 );
$rightlistQuad -> setY ( $height / 2 - 46 );
$rightlistQuad -> setStyles ( $quadStyle , $quadSubstyle );
$this -> maniaControl -> manialinkManager -> displayWidget ( $maniaLink , $player , 'TSViewer' );
}
2014-05-13 16:40:05 +02:00
}