statslist improvements
This commit is contained in:
parent
8fede6f508
commit
2176cb7791
@ -32,6 +32,25 @@ abstract class Formatter {
|
||||
return $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a Time to H:M:S
|
||||
*
|
||||
* @param int $seconds
|
||||
* @return string
|
||||
*/
|
||||
public static function formatTimeHMS($seconds) {
|
||||
$minutes = floor($seconds / 60);
|
||||
$hours = floor($minutes / 60);
|
||||
$minutes -= $hours * 60;
|
||||
$seconds -= ($hours * 3600 + $minutes * 60);
|
||||
|
||||
$hours = ($hours < 10 ? '0' : '') . $hours;
|
||||
$minutes = ($minutes < 10 ? '0' : '') . $minutes;;
|
||||
$seconds = ($seconds < 10 ? '0' : '') . $seconds;;
|
||||
|
||||
return $hours . ":" . $minutes . ":" . $seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatts a Elapset time String (2 days ago...) by a given timestamp
|
||||
*
|
||||
|
@ -529,7 +529,6 @@ class MapManager implements CallbackListener {
|
||||
|
||||
$mapFileName = $downloadDirectory . '/' . $fileName;
|
||||
|
||||
var_dump($mapDir);
|
||||
//Check if it can get locally Written
|
||||
if (is_dir($mapDir)) {
|
||||
// Create download directory if necessary
|
||||
|
@ -15,6 +15,7 @@ use FML\ManiaLink;
|
||||
use FML\Script\Script;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
@ -22,7 +23,7 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
|
||||
class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, CommandListener {
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
@ -52,17 +53,18 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleOnInit(array $callback) {
|
||||
$this->maniaControl->commandManager->registerCommandListener('stats', $this, 'command_ShowStatsList');
|
||||
|
||||
// Action Open StatsList
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_STATSLIST, $this, 'command_ShowStatsList');
|
||||
//TODO command
|
||||
|
||||
|
||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Stats);
|
||||
$itemQuad->setAction(self::ACTION_OPEN_STATSLIST);
|
||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 14, 'Open Statistics');
|
||||
|
||||
//TODO setting if a stat get shown
|
||||
//TODO sort out stats where no player have a point
|
||||
//TODO settings if a stat get shown
|
||||
$this->registerStat(PlayerManager::STAT_SERVERTIME, 10, "ST", 20, StatisticManager::STAT_TYPE_TIME);
|
||||
$this->registerStat(StatisticCollector::STAT_ON_HIT, 20, "H");
|
||||
$this->registerStat(StatisticCollector::STAT_ON_NEARMISS, 30, "NM");
|
||||
@ -155,16 +157,25 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
$x = $xStart + 55;
|
||||
|
||||
//Display Head
|
||||
$statRankings = array();
|
||||
foreach($this->statArray as $key => $stat) {
|
||||
$statRankings[$stat["Name"]] = $this->maniaControl->statisticManager->getStatsRanking($stat["Name"]);
|
||||
foreach($this->statArray as $stat) {
|
||||
$ranking = $this->maniaControl->statisticManager->getStatsRanking($stat["Name"]);
|
||||
if (!empty($ranking)) {
|
||||
$statRankings[$stat["Name"]] = $ranking;
|
||||
$array[$stat['HeadShortCut']] = $x;
|
||||
$x += $stat["Width"];
|
||||
}
|
||||
}
|
||||
|
||||
//TODO description on each
|
||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||
$labels = $this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||
|
||||
//Description Label
|
||||
$i = 2;
|
||||
foreach($this->statArray as $statArray) {
|
||||
$script->addTooltip($labels[$i], $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => '$o ' . $statArray["Name"]));
|
||||
$i++;
|
||||
}
|
||||
|
||||
// define standard properties
|
||||
$hAlign = Control::LEFT;
|
||||
@ -192,11 +203,10 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
if (isset($statRankings[$stat['Name']][$playerId])) {
|
||||
$statValue = $statRankings[$stat['Name']][$playerId];
|
||||
if ($stat['Format'] == StatisticManager::STAT_TYPE_TIME) {
|
||||
$statValue = Formatter::formatTimeH($statValue);
|
||||
$statValue = Formatter::formatTimeHMS($statValue);
|
||||
} else if ($stat['Format'] == StatisticManager::STAT_TYPE_FLOAT) {
|
||||
$statValue = round(floatval($statValue), 2);
|
||||
}
|
||||
|
||||
}
|
||||
$displayArray[$stat['Name']] = array("Value" => strval($statValue), "Width" => $stat['Width']);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user