Compare commits
68 Commits
9a6d7a9284
...
master
Author | SHA1 | Date | |
---|---|---|---|
6913609475
|
|||
a42c12ace8
|
|||
a769fec577
|
|||
271395edfa
|
|||
aefff423f7
|
|||
827e59ff93
|
|||
f15fc201d2
|
|||
7a8d9f2b0b | |||
03a991cd50 | |||
84e7e5fb17 | |||
d8f93a3a31 | |||
7ded2c6ffc | |||
356cab4869 | |||
04a35dc47f | |||
cfa42acd24 | |||
43cc088fa6 | |||
e6444a5a47 | |||
a6875cabc8 | |||
bfa3fdce60 | |||
9331e22a54 | |||
9c114cd13b | |||
c8bbb3d7c6 | |||
3044e466b9 | |||
fb36146cf6 | |||
601e3d7431 | |||
39db992394 | |||
40c33de0c8 | |||
52945ac7f7 | |||
8e6fce3e2b | |||
4d1489ed34 | |||
268e7454a9 | |||
a8ad7492cf | |||
f7b3fb5f71 | |||
996dde826d | |||
e44dfa0ef2 | |||
93423e36af | |||
251988b19b | |||
afe617b642 | |||
4b9ea37217 | |||
c2ff687e29 | |||
c1dea96f27 | |||
6de16109f3 | |||
69bbcfbc40 | |||
4bcbda64d6 | |||
8b3e624d1c | |||
478e842230 | |||
405d6027f7 | |||
02b7b279af | |||
2440de9b92 | |||
d6745370b2 | |||
e0859dfc21 | |||
bf9d80ea9c | |||
bad5ecd70f | |||
bff16f6441 | |||
0f55bff6c2 | |||
d947337c9c | |||
0ad0d06f85 | |||
129053e951 | |||
13965aef03 | |||
8c478084a2 | |||
2b14b6bf7a | |||
7967779492 | |||
9edb5de5c6 | |||
32e00a8051 | |||
cc46f63155 | |||
e0028a7f47 | |||
195e942bd3 | |||
4c78ee9d1d |
10
.gitignore
vendored
10
.gitignore
vendored
@ -8,6 +8,12 @@
|
||||
/logs/
|
||||
/ManiaControl.log
|
||||
/ManiaControl.pid
|
||||
!/plugins/
|
||||
/plugins/*
|
||||
/plugins/
|
||||
!/plugins/MCTeam/
|
||||
/libs/
|
||||
!/libs/curl-easy
|
||||
!/libs/Evenement
|
||||
!/libs/FML
|
||||
!/libs/Maniaplanet
|
||||
!/libs/React
|
||||
!/libs/Symfony
|
@ -28,6 +28,11 @@ if (!ini_get('date.timezone') && function_exists('date_default_timezone_set')) {
|
||||
// Make sure garbage collection is enabled
|
||||
gc_enable();
|
||||
|
||||
// Listen process signals
|
||||
if (extension_loaded('pcntl')) {
|
||||
pcntl_async_signals(true);
|
||||
}
|
||||
|
||||
// Register AutoLoader
|
||||
require_once MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php';
|
||||
\ManiaControl\AutoLoader::register();
|
||||
|
@ -1,3 +1,10 @@
|
||||
###v0.258###
|
||||
#Changes
|
||||
- MC compatibility with MX v2 api
|
||||
###v0.257###
|
||||
#Changes
|
||||
- MC now supports php 8.0 and 8.1
|
||||
|
||||
###v0.255###
|
||||
#Additions
|
||||
- added optional descriptions to Settings (but no MC-settings have descriptions yet)
|
||||
|
@ -37,7 +37,6 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
|
||||
*/
|
||||
const ACTION_OPEN_ADMIN_LIST = 'AdminList.OpenAdminList';
|
||||
const ACTION_REVOKE_RIGHTS = 'AdminList.RevokeRights';
|
||||
const MAX_PLAYERS_PER_PAGE = 15;
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
@ -129,9 +128,10 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
|
||||
$index = 1;
|
||||
$posY -= 10;
|
||||
$pageFrame = null;
|
||||
$pageMaxCount = $this->getPlayersPerPage();
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
|
||||
if ($index % $pageMaxCount === 1) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
|
||||
@ -236,6 +236,16 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of players per page
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPlayersPerPage() {
|
||||
$pageheight = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
return floor(($pageheight - 16) / 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reopen the widget on Map Begin, MapListChanged, etc.
|
||||
*
|
||||
|
@ -56,7 +56,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
|
||||
$text = $chatCallback[1][2];
|
||||
$commandParts = explode(' ', $text);
|
||||
if (!array_key_exists(1, $commandParts)) {
|
||||
if (!array_key_exists(1, $commandParts) || $commandParts[1] === "") {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Usage Example: %s %s',
|
||||
$commandParts[0],
|
||||
@ -68,12 +68,10 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Player %s not found!',
|
||||
$commandParts[1]
|
||||
);
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
return;
|
||||
// It's not needed to save the player, it will be done by the grantAuthLevel function
|
||||
$target = new Player($this->maniaControl, false);
|
||||
$target->login = $commandParts[1];
|
||||
$target->nickname = $commandParts[1];
|
||||
}
|
||||
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, $targetAuthLevel);
|
||||
@ -154,7 +152,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
||||
if ($player !== $target && $target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
||||
$this->maniaControl->getChat()->sendError('You cannot remove rights of a MasterAdmin!', $player);
|
||||
return;
|
||||
}
|
||||
@ -164,7 +162,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($player->authLevel <= $target->authLevel) {
|
||||
if ($player !== $target && $player->authLevel <= $target->authLevel) {
|
||||
$this->maniaControl->getChat()->sendError('You cannot remove rights of a higher privileged player!', $player);
|
||||
return;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ abstract class AutoLoader {
|
||||
* Register the Auto Loader
|
||||
*/
|
||||
public static function register() {
|
||||
spl_autoload_register(array(get_class(), 'autoload'));
|
||||
spl_autoload_register(array(get_called_class(), 'autoload'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,7 +176,7 @@ class CallbackManager implements UsageInformationAble {
|
||||
/**
|
||||
* Remove the Callback Listener from the given Listeners Array
|
||||
*
|
||||
* @param Listening[] $listeningsArray
|
||||
* @param Listening[][] $listeningsArray
|
||||
* @param CallbackListener $listener
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@ use ManiaControl\ManiaControl;
|
||||
*/
|
||||
class StartEndStructure extends BaseTimeStructure {
|
||||
private $count;
|
||||
private $valid;
|
||||
|
||||
/**
|
||||
* StartEndStructure constructor.
|
||||
@ -28,6 +29,7 @@ class StartEndStructure extends BaseTimeStructure {
|
||||
parent::__construct($maniaControl, $data);
|
||||
|
||||
$this->count = $this->getPlainJsonObject()->count;
|
||||
$this->valid = $this->getPlainJsonObject()->valid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,4 +41,14 @@ class StartEndStructure extends BaseTimeStructure {
|
||||
public function getCount() {
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Valid Round Count of this Section
|
||||
*
|
||||
* @api
|
||||
* @return int
|
||||
*/
|
||||
public function getValidRoundCount() {
|
||||
return $this->valid;
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
|
||||
*/
|
||||
class PlayerScore extends CommonPlayerScore {
|
||||
|
||||
private $teamid;
|
||||
private $bestRaceTime;
|
||||
private $bestLapTime;
|
||||
private $stuntScore;
|
||||
@ -28,6 +29,26 @@ class PlayerScore extends CommonPlayerScore {
|
||||
private $prevRaceCheckpoints;
|
||||
private $prevStuntsScore;
|
||||
|
||||
/**
|
||||
* Returns the TeamId
|
||||
*
|
||||
* @api
|
||||
* @return int
|
||||
*/
|
||||
public function getTeamId() {
|
||||
return $this->teamid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the TeamId
|
||||
*
|
||||
* @api
|
||||
* @param int $teamid
|
||||
*/
|
||||
public function setTeamId($teamid) {
|
||||
$this->teamid = $teamid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Rank
|
||||
*
|
||||
|
@ -70,6 +70,13 @@ class OnScoresStructure extends CommonScoresStructure {
|
||||
$playerScore->setPrevStuntsScore($jsonPlayer->prevstuntsscore);
|
||||
}
|
||||
|
||||
// New attribute added in TM2020
|
||||
if (property_exists($jsonPlayer, 'team')) {
|
||||
// player->teamid can be wrong if the mode forced the team, so this is the best value
|
||||
$player->teamId = $jsonPlayer->team;
|
||||
$playerScore->setTeamId($jsonPlayer->team);
|
||||
}
|
||||
|
||||
$this->playerScores[$jsonPlayer->login] = $playerScore;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ class OnWayPointEventStructure extends BasePlayerTimeStructure {
|
||||
private $stuntsScore;
|
||||
private $checkPointInRace;
|
||||
private $checkPointInLap;
|
||||
private $curRaceCheckpoints;
|
||||
private $curLapCheckpoints;
|
||||
private $isInfiniteLaps;
|
||||
private $isIndependentLaps;
|
||||
private $isEndRace;
|
||||
private $isEndLap;
|
||||
private $blockId;
|
||||
@ -37,16 +41,20 @@ class OnWayPointEventStructure extends BasePlayerTimeStructure {
|
||||
public function __construct(ManiaControl $maniaControl, $data) {
|
||||
parent::__construct($maniaControl, $data);
|
||||
|
||||
$this->raceTime = (int) $this->getPlainJsonObject()->racetime;
|
||||
$this->lapTime = (int) $this->getPlainJsonObject()->laptime;
|
||||
$this->stuntsScore = isset($this->getPlainJsonObject()->stuntsscore) ? $this->getPlainJsonObject()->stuntsscore : null;
|
||||
$this->checkPointInRace = (int) $this->getPlainJsonObject()->checkpointinrace;
|
||||
$this->checkPointInLap = (int) $this->getPlainJsonObject()->checkpointinlap;
|
||||
$this->isEndRace = Formatter::parseBoolean($this->getPlainJsonObject()->isendrace);
|
||||
$this->isEndLap = Formatter::parseBoolean($this->getPlainJsonObject()->isendlap);
|
||||
$this->blockId = $this->getPlainJsonObject()->blockid;
|
||||
$this->speed = $this->getPlainJsonObject()->speed;
|
||||
$this->distance = isset($this->getPlainJsonObject()->distance) ? $this->getPlainJsonObject()->distance : null;
|
||||
$this->raceTime = (int) $this->getPlainJsonObject()->racetime;
|
||||
$this->lapTime = (int) $this->getPlainJsonObject()->laptime;
|
||||
$this->stuntsScore = isset($this->getPlainJsonObject()->stuntsscore) ? $this->getPlainJsonObject()->stuntsscore : null;
|
||||
$this->checkPointInRace = (int) $this->getPlainJsonObject()->checkpointinrace;
|
||||
$this->checkPointInLap = (int) $this->getPlainJsonObject()->checkpointinlap;
|
||||
$this->curRaceCheckpoints = isset($this->getPlainJsonObject()->curracecheckpoints) ? $this->getPlainJsonObject()->curracecheckpoints : null;
|
||||
$this->curLapCheckpoints = isset($this->getPlainJsonObject()->curlapcheckpoints) ? $this->getPlainJsonObject()->curlapcheckpoints : null;
|
||||
$this->isInfiniteLaps = isset($this->getPlainJsonObject()->isinfinitelaps) ? Formatter::parseBoolean($this->getPlainJsonObject()->isinfinitelaps) : null;
|
||||
$this->isIndependentLaps = isset($this->getPlainJsonObject()->isindependentlaps) ? Formatter::parseBoolean($this->getPlainJsonObject()->isindependentlaps) : null;
|
||||
$this->isEndRace = Formatter::parseBoolean($this->getPlainJsonObject()->isendrace);
|
||||
$this->isEndLap = Formatter::parseBoolean($this->getPlainJsonObject()->isendlap);
|
||||
$this->blockId = $this->getPlainJsonObject()->blockid;
|
||||
$this->speed = $this->getPlainJsonObject()->speed;
|
||||
$this->distance = isset($this->getPlainJsonObject()->distance) ? $this->getPlainJsonObject()->distance : null;
|
||||
|
||||
if ($this->checkPointInRace > 0) {
|
||||
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
@ -94,6 +102,38 @@ class OnWayPointEventStructure extends BasePlayerTimeStructure {
|
||||
return $this->checkPointInLap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCurRaceCheckpoints() {
|
||||
return $this->curRaceCheckpoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCurLapCheckpoints() {
|
||||
return $this->curLapCheckpoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api
|
||||
* @return bool|null
|
||||
*/
|
||||
public function getIsInfiniteLaps() {
|
||||
return $this->isInfiniteLaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api
|
||||
* @return bool|null
|
||||
*/
|
||||
public function getIsIndependentLaps() {
|
||||
return $this->isIndependentLaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api
|
||||
* @return mixed
|
||||
|
@ -351,6 +351,7 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
*/
|
||||
public function sendMessageToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins($minLevel);
|
||||
if (count($admins) === 0) return false;
|
||||
return $this->sendChat($message, $admins, $prefix);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
namespace ManiaControl\Commands;
|
||||
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Callbacks\Listening;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
@ -18,6 +20,10 @@ use ManiaControl\ManiaControl;
|
||||
*/
|
||||
class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const SETTING_PERMISSION_ADMIN_COMMANDS = "Minimum permissions level to use admin commands";
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
@ -48,6 +54,12 @@ class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handleChatCallback');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
}
|
||||
|
||||
public function handleAfterInit() {
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ADMIN_COMMANDS, AuthenticationManager::AUTH_LEVEL_MODERATOR, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,6 +339,11 @@ class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
$isAdminCommand = true;
|
||||
$commandListenings = $this->adminCommandListenings;
|
||||
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADMIN_COMMANDS)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($command === 'admin') {
|
||||
// Strip 'admin' keyword
|
||||
if (isset($commandArray[1])) {
|
||||
|
@ -161,7 +161,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
* @param Player $player
|
||||
* @return string
|
||||
*/
|
||||
private function parseHelpList(array $commands, $isHelpAll = false, Player $player = null) {
|
||||
private function parseHelpList(array $commands, $isHelpAll = false, ?Player $player = null) {
|
||||
$showCommands = array();
|
||||
$registeredMethods = array();
|
||||
$message = '';
|
||||
@ -238,9 +238,10 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
$index = 1;
|
||||
$posY -= 10;
|
||||
$pageFrame = null;
|
||||
$pageMaxCount = floor($height * 0.80 / 4);
|
||||
|
||||
foreach ($commands as $command) {
|
||||
if ($index % 15 === 1) {
|
||||
if ($index % $pageMaxCount === 1) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$posY = $height / 2 - 10;
|
||||
|
@ -188,7 +188,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
|
||||
* @param Player $player
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
private function buildManialink($menuIdShown = 0, Player $player = null) {
|
||||
private function buildManialink($menuIdShown = 0, ?Player $player = null) {
|
||||
$menuPosX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$menuPosY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSY);
|
||||
$menuWidth = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_WIDTH);
|
||||
|
@ -139,6 +139,20 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
}
|
||||
$statement->close();
|
||||
|
||||
$query = "ALTER TABLE `" . self::TABLE_GAMEMODE_SETTINGS . "` MODIFY `settingValue` VARCHAR(1000);";
|
||||
// Grow the size limit for plugins settings
|
||||
$statement = $mysqli->prepare($query);
|
||||
if ($mysqli->error) {
|
||||
trigger_error($mysqli->error, E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
$statement->execute();
|
||||
if ($statement->error) {
|
||||
trigger_error($statement->error, E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
$statement->close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -319,20 +333,24 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
}
|
||||
|
||||
// Config
|
||||
$innerWidth = $width - 3;
|
||||
$innerHeight = $height - 10;
|
||||
$pagerSize = 9.;
|
||||
$settingHeight = 5.;
|
||||
$valueWidth = $innerWidth * 0.3;
|
||||
$labelTextSize = 2;
|
||||
$pageMaxCount = floor($innerHeight / $settingHeight);
|
||||
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
@ -342,7 +360,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
@ -352,17 +370,24 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
$descriptionLabel = new Label();
|
||||
$frame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
||||
$descriptionLabel->setPosition($width * -0.45, $height * -0.44);
|
||||
$descriptionLabel->setSize($width * 0.7, $settingHeight);
|
||||
$descriptionLabel->setPosition($width * -0.5 + 3, $height * -0.5 + 5);
|
||||
$descriptionLabel->setSize($width - 30, $settingHeight);
|
||||
$descriptionLabel->setText('Changes only apply with map skip/restart');
|
||||
$descriptionLabel->setTextColor('ff0');
|
||||
$descriptionLabel->setTextSize($labelTextSize);
|
||||
$descriptionLabel->setTextSize(1);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
}
|
||||
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setPosition(2, -1);
|
||||
|
||||
// Setting pages
|
||||
$pageFrame = null;
|
||||
$posY = 0.;
|
||||
$index = 0;
|
||||
|
||||
foreach ($scriptParams as $key => $scriptParam) {
|
||||
@ -385,25 +410,28 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
);
|
||||
}
|
||||
|
||||
if ($index % 13 === 0) {
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$posY = 0.41 * $height;
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$settingFrame = new Frame();
|
||||
$pageFrame->addChild($settingFrame);
|
||||
$settingFrame->setY($posY);
|
||||
$settingFrame->setY($settingHeight * $index * -1);
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$settingFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setSize(0.4 * $width, $settingHeight);
|
||||
$nameLabel->setSize($innerWidth * 0.6, $settingHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setText($settingName);
|
||||
$nameLabel->setTextSize($labelTextSize);
|
||||
$nameLabel->setX(-0.46 * $width);
|
||||
$nameLabel->setX(1);
|
||||
if ($scriptParam->desc === self::DESCRIPTION_HIDDEN) {
|
||||
$nameLabel->setTextColor("AAAAAA");
|
||||
}
|
||||
|
||||
if (!$isScriptMode) {
|
||||
if (is_bool($settingValue[0])) {
|
||||
@ -415,18 +443,18 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
} else {
|
||||
$activeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_LvlRed);
|
||||
}
|
||||
$activeQuad->setX(0.1 * $width);
|
||||
$activeQuad->setX($innerWidth - $valueWidth - 2.5);
|
||||
} else {
|
||||
$currentLabel = new Label_Text();
|
||||
$settingFrame->addChild($currentLabel);
|
||||
$currentLabel->setHorizontalAlign(Label_Text::RIGHT);
|
||||
$currentLabel->setSize(0.2 * $width, 0.9 * $settingHeight);
|
||||
$currentLabel->setSize($innerWidth * 0.2, 0.9 * $settingHeight);
|
||||
$currentLabel->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$currentLabel->setText($settingValue[0]);
|
||||
$currentLabel->setTextColor('aaa');
|
||||
$currentLabel->setTextPrefix('$i');
|
||||
$currentLabel->setTextSize(1);
|
||||
$currentLabel->setX(0.11 * $width);
|
||||
$currentLabel->setTextSize(0.5);
|
||||
$currentLabel->setX($innerWidth - $valueWidth);
|
||||
}
|
||||
|
||||
$settingValue = $settingValue[1];
|
||||
@ -436,7 +464,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
// Boolean checkbox
|
||||
$quad = new Quad();
|
||||
$quad->setSize(4, 4);
|
||||
$quad->setX(0.27 * $width);
|
||||
$quad->setPosition($innerWidth - $valueWidth / 2, 0);
|
||||
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $settingName, $settingValue, $quad);
|
||||
$settingFrame->addChild($checkBox);
|
||||
} else {
|
||||
@ -445,24 +473,24 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
$settingFrame->addChild($entry);
|
||||
$entry->setDefault($settingValue);
|
||||
$entry->setName(self::ACTION_PREFIX_SETTING . $settingName);
|
||||
$entry->setSize(0.3 * $width, 0.9 * $settingHeight);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setX(0.275 * $width);
|
||||
$entry->setMaxLength(1000);
|
||||
$entry->setPosition($innerWidth - $valueWidth / 2, 0);
|
||||
$entry->setSize($valueWidth, $settingHeight * 0.9);
|
||||
}
|
||||
|
||||
if ($isScriptMode) {
|
||||
$descriptionLabel = new Label();
|
||||
$pageFrame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
||||
$descriptionLabel->setPosition(-0.45 * $width, -0.44 * $height);
|
||||
$descriptionLabel->setSize(0.7 * $width, $settingHeight);
|
||||
$descriptionLabel->setTextSize($labelTextSize);
|
||||
$descriptionLabel->setPosition(3, $height * -1 + 5);
|
||||
$descriptionLabel->setSize($width - 30, $settingHeight);
|
||||
$descriptionLabel->setTextSize(1);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
$nameLabel->addTooltipLabelFeature($descriptionLabel, $scriptParam->desc);
|
||||
}
|
||||
|
||||
$posY -= $settingHeight;
|
||||
$index++;
|
||||
}
|
||||
|
||||
@ -590,6 +618,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
|
||||
// Trigger own callback
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_GAMEMODESETTING_CHANGED, $settingName, $settingValue);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') changed the gamemode setting "'. $settingName .'" to "'. $settingValue .'"');
|
||||
|
||||
$settingIndex++;
|
||||
}
|
||||
@ -599,7 +628,6 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
||||
|
||||
$chatMessage .= '!';
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ use FML\Script\Script;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Settings\Setting;
|
||||
@ -108,18 +109,18 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$pagerSize = 9.;
|
||||
$settingHeight = 5.;
|
||||
$labelTextSize = 2;
|
||||
$pageMaxCount = 10;
|
||||
$pageMaxCount = floor(($height * 0.78) / $settingHeight);
|
||||
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
@ -129,7 +130,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.35, $height * -0.44);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
@ -226,6 +227,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setMaxLength(1000);
|
||||
$entry->setName($settingName);
|
||||
$entry->setDefault($setting->value);
|
||||
}
|
||||
@ -242,7 +244,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
self::ACTION_PREFIX_SETTINGLINKS . $settingClass
|
||||
);
|
||||
$frame->addChild($mapNameButton);
|
||||
$mapNameButton->setPosition(-$width / 2 + 60, -35);
|
||||
$mapNameButton->setPosition(-$width / 2 + 60, $height * -0.45);
|
||||
}
|
||||
|
||||
return $frame;
|
||||
@ -269,18 +271,18 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$pagerSize = 9.;
|
||||
$settingHeight = 5.;
|
||||
$labelTextSize = 2;
|
||||
$pageMaxCount = 10;
|
||||
$pageMaxCount = floor(($height * 0.78) / $settingHeight);
|
||||
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
@ -290,7 +292,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.35, $height * -0.44);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
@ -386,19 +388,18 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
// Config
|
||||
$pagerSize = 9.;
|
||||
$settingHeight = 5.;
|
||||
$pageMaxCount = 13;
|
||||
$posY = 0;
|
||||
$pageMaxCount = floor(($height - 10) / $settingHeight);
|
||||
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
@ -408,20 +409,24 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
$paging->setLabel($pageCountLabel);
|
||||
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pageFrame = null;
|
||||
$index = 0;
|
||||
foreach ($settingClasses as $settingClass) {
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$posY = $height * 0.41;
|
||||
$repositionnedFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$classLabel = new Label_Text();
|
||||
@ -435,15 +440,14 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
$pageFrame->addChild($classLabel);
|
||||
$classLabel->setHorizontalAlign($classLabel::LEFT);
|
||||
$classLabel->setPosition($width * -0.45, $posY);
|
||||
$classLabel->setSize($width * 0.9, $settingHeight * 0.9);
|
||||
$classLabel->setPosition(2, $settingHeight * $index * -1);
|
||||
$classLabel->setSize($width - 6, $settingHeight * 0.9);
|
||||
$classLabel->setStyle($classLabel::STYLE_TextCardSmall);
|
||||
$classLabel->setTextSize(2);
|
||||
$classLabel->setText($className);
|
||||
$classLabel->setTextColor('fff');
|
||||
$classLabel->setAction(self::ACTION_PREFIX_SETTINGCLASS . $settingClass);
|
||||
|
||||
$posY -= $settingHeight;
|
||||
$index++;
|
||||
}
|
||||
|
||||
@ -525,6 +529,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$setting->value = $settingData['Value'];
|
||||
}
|
||||
$this->maniaControl->getSettingManager()->saveSetting($setting);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') changed the setting "'. $setting->class . '\\\\' . $setting->setting .'" to "'. $setting->value .'"');
|
||||
}
|
||||
|
||||
$this->maniaControl->getChat()->sendSuccess('Settings saved!', $player);
|
||||
|
@ -44,6 +44,9 @@ class Database implements TimerListener {
|
||||
// Enable mysqli Reconnect
|
||||
ini_set('mysqli.reconnect', 'on');
|
||||
|
||||
// Change error report mechanism -> used to set compatibility to php < 8.1
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
|
||||
// Open database connection
|
||||
$this->loadConfig();
|
||||
$this->mysqli = @new \mysqli($this->config->host, $this->config->user, $this->config->pass, null, $this->config->port);
|
||||
@ -220,7 +223,7 @@ class Database implements TimerListener {
|
||||
* Check whether the Database Connection is still open
|
||||
*/
|
||||
public function checkConnection() {
|
||||
if (!$this->getMysqli() || !@$this->getMysqli()->ping()) {
|
||||
if (!$this->getMysqli() || !$this->getMysqli()->query('DO 1')) {
|
||||
$this->maniaControl->quit('The MySQL Server has gone away!', true);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,59 @@ class AsyncHttpRequest implements UsageInformationAble {
|
||||
$this->processRequest($request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Carry out a PatchData Request
|
||||
*/
|
||||
public function patchData() {
|
||||
array_push($this->headers, 'Content-Type: ' . $this->contentType);
|
||||
array_push($this->headers, 'Keep-Alive: timeout=600, max=2000');
|
||||
array_push($this->headers, 'Connection: Keep-Alive');
|
||||
array_push($this->headers, 'Expect:');
|
||||
array_push($this->headers, 'Accept-Charset: utf-8');
|
||||
|
||||
$content = $this->content;
|
||||
if ($this->compression) {
|
||||
$content = gzencode($this->content);
|
||||
array_push($this->headers, 'Content-Encoding: gzip');
|
||||
}
|
||||
|
||||
|
||||
$request = $this->newRequest($this->url, $this->timeout);
|
||||
$request->getOptions()->set(CURLOPT_CUSTOMREQUEST, 'PATCH')// patch method
|
||||
->set(CURLOPT_POSTFIELDS, $content)// post content field
|
||||
->set(CURLOPT_HTTPHEADER, $this->headers) // headers
|
||||
;
|
||||
|
||||
$this->processRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Carry out a PutData Request
|
||||
*/
|
||||
public function putData() {
|
||||
array_push($this->headers, 'Content-Type: ' . $this->contentType);
|
||||
array_push($this->headers, 'Keep-Alive: timeout=600, max=2000');
|
||||
array_push($this->headers, 'Connection: Keep-Alive');
|
||||
array_push($this->headers, 'Expect:');
|
||||
array_push($this->headers, 'Accept-Charset: utf-8');
|
||||
|
||||
$content = $this->content;
|
||||
if ($this->compression) {
|
||||
$content = gzencode($this->content);
|
||||
array_push($this->headers, 'Content-Encoding: gzip');
|
||||
}
|
||||
|
||||
|
||||
$request = $this->newRequest($this->url, $this->timeout);
|
||||
$request->getOptions()->set(CURLOPT_CUSTOMREQUEST, 'PUT')// patch method
|
||||
->set(CURLOPT_POSTFIELDS, $content)// put content field
|
||||
->set(CURLOPT_HTTPHEADER, $this->headers) // headers
|
||||
;
|
||||
|
||||
$this->processRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the Request
|
||||
*
|
||||
|
@ -57,8 +57,9 @@ abstract class FileUtil {
|
||||
public static function getClearedFileName($fileName) {
|
||||
$fileName = Formatter::stripCodes($fileName);
|
||||
$fileName = Formatter::utf8($fileName);
|
||||
$fileName = preg_replace('/[^0-9A-Za-z\-\+\.\_\ ]/', null, $fileName);
|
||||
$fileName = preg_replace('/[^0-9A-Za-z\-\+\.\_\ ]/', '', $fileName);
|
||||
$fileName = preg_replace('/ /', '_', $fileName);
|
||||
$fileName = str_replace(["'", "+"], '', $fileName);
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const VERSION = '0.256';
|
||||
const VERSION = '0.258';
|
||||
const ISTRACKMANIACONTROL = True;
|
||||
const API_VERSION = '2038-01-19';
|
||||
const MIN_DEDIVERSION = '2020-07-01_00_00';
|
||||
@ -299,7 +299,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
|
||||
}
|
||||
|
||||
// Delete client
|
||||
Connection::delete($this->getClient());
|
||||
$this->client = null;
|
||||
}
|
||||
|
||||
@ -548,7 +547,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
|
||||
* @param Player $player
|
||||
*/
|
||||
public function commandVersion(array $chatCallback, Player $player) {
|
||||
$message = 'This server is using TrackManiaControl v' . ManiaControl::VERSION . '!';
|
||||
$message = 'This server is using TrackManiaControl v' . ManiaControl::VERSION . ' with PHP '. phpversion() .'!';
|
||||
$this->getChat()->sendInformation($message, $player);
|
||||
}
|
||||
|
||||
@ -652,6 +651,13 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
|
||||
Logger::log('Starting ManiaControl v' . self::VERSION . '!');
|
||||
|
||||
try {
|
||||
// Manage SIGTERM signal
|
||||
if (extension_loaded('pcntl')) {
|
||||
pcntl_signal(SIGTERM, function() {
|
||||
$this->quit("Stop signal received from the OS.", false);
|
||||
});
|
||||
}
|
||||
|
||||
// Connect to server
|
||||
$this->connect();
|
||||
|
||||
@ -715,7 +721,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
|
||||
Logger::log("Connecting to Server at {$serverConfig->host}:{$serverConfig->port}...");
|
||||
|
||||
try {
|
||||
$this->client = Connection::factory($serverConfig->host, $serverConfig->port, self::SCRIPT_TIMEOUT, $serverConfig->user, $serverConfig->pass, self::API_VERSION);
|
||||
$this->client = new Connection($serverConfig->host, $serverConfig->port, self::SCRIPT_TIMEOUT, $serverConfig->user, $serverConfig->pass, self::API_VERSION);
|
||||
} catch (TransportException $exception) {
|
||||
$message = "Couldn't connect to the server: '{$exception->getMessage()}'";
|
||||
$this->quit($message, true);
|
||||
|
@ -44,7 +44,7 @@ class MXMapInfo {
|
||||
} else {
|
||||
$this->dir = 'maps';
|
||||
$this->id = $mx->MapID;
|
||||
$this->uid = isset($mx->MapUID) ? $mx->MapUID : '';
|
||||
$this->uid = isset($mx->TrackUID) ? $mx->TrackUID : ''; // TODO: fix when migrating to new api; TrackUID is equal to MapUID
|
||||
}
|
||||
|
||||
if (!isset($mx->GbxMapName) || $mx->GbxMapName === '?') {
|
||||
|
@ -71,6 +71,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
$actionId = $callback[1][2];
|
||||
$actionArray = explode('.', $actionId);
|
||||
if (count($actionArray) <= 2) {
|
||||
@ -101,6 +102,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showListCommand(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
$this->mapListShown[$player->login] = true;
|
||||
$params = explode(' ', $chatCallback[1][2]);
|
||||
$searchString = '';
|
||||
@ -141,6 +143,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param string $searchString
|
||||
*/
|
||||
private function getMXMapsAndShowList(Player $player, $author = '', $environment = '', $searchString = '') {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
//TODO do more clean solution
|
||||
if($environment == ""){
|
||||
$titleId = $this->maniaControl->getServer()->titleId;
|
||||
@ -191,6 +194,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @internal param array $chatCallback
|
||||
*/
|
||||
private function showManiaExchangeList(array $maps, Player $player) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
// Start offsets
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
@ -340,6 +344,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param $openedWidget
|
||||
*/
|
||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
//unset when another main widget got opened
|
||||
if ($openedWidget !== 'ManiaExchangeList') {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
@ -355,5 +360,4 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
public function closeWidget(Player $player) {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* Constants
|
||||
* @deprecated SEARCH Constants
|
||||
*/
|
||||
//Search orders (prior parameter) https://api.mania-exchange.com/documents/enums#orderings
|
||||
//Search orders (prior parameter) https://api2.mania.exchange/documents/enums#orderings
|
||||
const SEARCH_ORDER_NONE = -1;
|
||||
const SEARCH_ORDER_TRACK_NAME = 0;
|
||||
const SEARCH_ORDER_AUTHOR = 1;
|
||||
@ -54,6 +54,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $enabled = true;
|
||||
private $mxIdUidVector = array();
|
||||
|
||||
/**
|
||||
@ -67,6 +68,22 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
//$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MX_KEY, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status of the plugin
|
||||
*
|
||||
* @param bool $status
|
||||
*/
|
||||
public function setStatus(bool $status) {
|
||||
$this->enabled = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of the plugin
|
||||
*/
|
||||
public function getStatus() {
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset Map by Mx Id
|
||||
*
|
||||
@ -84,6 +101,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param mixed $maps
|
||||
*/
|
||||
public function fetchManiaExchangeMapInformation($maps = null) {
|
||||
if (!$this->enabled) return;
|
||||
if ($maps) {
|
||||
// Fetch Information for a single map
|
||||
$maps = array($maps);
|
||||
@ -160,7 +178,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param string $string
|
||||
*/
|
||||
public function fetchMaplistByMixedUidIdString($string) {
|
||||
|
||||
if (!$this->enabled) return;
|
||||
// For TM2020
|
||||
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
||||
// Get Title Prefix
|
||||
@ -172,7 +190,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
|
||||
}
|
||||
// compile search URL
|
||||
$url = "https://{$titlePrefix}/api/maps/get_map_info/multi/{$string}";
|
||||
$url = 'https://' . $titlePrefix . "/api/maps/get_map_info/multi/{$string}";
|
||||
|
||||
/*if ($key = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KEY)) {
|
||||
$url .= "&key=" . $key;
|
||||
@ -217,6 +235,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param array $mxMapInfos
|
||||
*/
|
||||
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
||||
if (!$this->enabled) return;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
// Save map data
|
||||
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
||||
@ -269,6 +288,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param callable $function
|
||||
*/
|
||||
public function fetchMapInfo($mapId, callable $function) {
|
||||
if (!$this->enabled) return;
|
||||
// For TM2020
|
||||
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
||||
// Get Title Prefix
|
||||
@ -280,7 +300,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
|
||||
}
|
||||
// compile search URL
|
||||
$url = "https://{$titlePrefix}/api/maps/get_map_info/multi/{$mapId}";
|
||||
$url = 'https://' . $titlePrefix . '/api/maps/get_map_info/multi/' . $mapId;
|
||||
|
||||
/*if ($key = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KEY)) {
|
||||
$url .= "&key=" . $key;
|
||||
@ -335,6 +355,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @see \ManiaControl\ManiaExchange\ManiaExchangeMapSearch
|
||||
*/
|
||||
public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $sortOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) {
|
||||
if (!$this->enabled) return;
|
||||
$mapSearch = new ManiaExchangeMapSearch($this->maniaControl);
|
||||
$mapSearch->setMapName($name);
|
||||
$mapSearch->setAuthorName($author);
|
||||
|
@ -18,7 +18,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
|
||||
class ManiaExchangeMapSearch implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
|
||||
//Search orders (prior parameter) https://api.mania-exchange.com/documents/enums#orderings
|
||||
//Search orders (prior parameter) https://api2.mania.exchange/documents/enums#orderings
|
||||
const SEARCH_ORDER_NONE = -1;
|
||||
const SEARCH_ORDER_TRACK_NAME = 0;
|
||||
const SEARCH_ORDER_AUTHOR = 1;
|
||||
@ -41,7 +41,7 @@ class ManiaExchangeMapSearch implements UsageInformationAble {
|
||||
const SEARCH_ORDER_ONLINE_RATING_LTH = 26;
|
||||
const SEARCH_ORDER_ONLINE_RATING_HTL = 27;
|
||||
|
||||
//Special Search Orders (mode parameter): https://api.mania-exchange.com/documents/enums#modes
|
||||
//Special Search Orders (mode parameter): https://api2.mania.exchange/documents/enums#modes
|
||||
const SEARCH_ORDER_SPECIAL_DEFAULT = 0;
|
||||
const SEARCH_ORDER_SPECIAL_USER_TRACKS = 1;
|
||||
const SEARCH_ORDER_SPECIAL_LATEST_TRACKS = 2;
|
||||
@ -140,6 +140,8 @@ class ManiaExchangeMapSearch implements UsageInformationAble {
|
||||
* @param callable $function
|
||||
*/
|
||||
public function fetchMapsAsync(callable $function) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
|
||||
// compile search URL
|
||||
$parameters = "";
|
||||
|
||||
|
@ -75,7 +75,7 @@ class CustomUIManager implements CallbackListener, TimerListener, UsageInformati
|
||||
*
|
||||
* @param Player $player
|
||||
*/
|
||||
public function updateManialink(Player $player = null) {
|
||||
public function updateManialink(?Player $player = null) {
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->customUI, $player);
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
}
|
||||
} else {
|
||||
$emptyManialink = new ManiaLink($manialinkId);
|
||||
$this->sendManialink($emptyManialink, $logins);
|
||||
$this->sendManialink($emptyManialink, $logins, 0, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ class StyleManager implements UsageInformationAble {
|
||||
|
||||
// Predefine Description Label
|
||||
$descriptionLabel = new Label();
|
||||
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP)->setPosition($width * -0.5 + 10, $height * -0.5 + 5)->setZ(1)->setSize($width * 0.7, 4)->setTextSize(2)->setVisible(false);
|
||||
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP)->setPosition($width * -0.5 + 10, $height * -0.5 + 5)->setZ(1)->setSize($width * 0.7, 4)->setTextSize(1)->setVisible(false);
|
||||
|
||||
return $descriptionLabel;
|
||||
}
|
||||
@ -125,30 +125,36 @@ class StyleManager implements UsageInformationAble {
|
||||
|
||||
$frame = new Frame();
|
||||
|
||||
$posX = -$width / 2 + 5;
|
||||
|
||||
$label = new Label_Text();
|
||||
$frame->addChild($label);
|
||||
$label->setPosition(-$width / 2 + 5, 0);
|
||||
$label->setPosition($posX, 0);
|
||||
$label->setHorizontalAlign($label::LEFT);
|
||||
$label->setTextSize(1);
|
||||
$label->setText('Search: ');
|
||||
|
||||
$posX += 10;
|
||||
|
||||
$entry = new Entry();
|
||||
$frame->addChild($entry);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setHorizontalAlign($entry::LEFT);
|
||||
$entry->setPosition(-$width / 2 + 15, 0);
|
||||
$entry->setPosition($posX, 0);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setSize($width * 0.28, 4);
|
||||
$entry->setName('SearchString');
|
||||
$entry->setDefault($entryvalue);
|
||||
|
||||
$posX += $width * 0.28 + 10;
|
||||
|
||||
if ($actionReset) {
|
||||
$quad = new Quad_Icons64x64_1();
|
||||
$frame->addChild($quad);
|
||||
$quad->setSubStyle($quad::SUBSTYLE_QuitRace);
|
||||
$quad->setColorize('aaa');
|
||||
$quad->setSize(5, 5);
|
||||
$quad->setPosition(-$width / 2 + 20 + $width * 0.25 - 2, 0);
|
||||
$quad->setPosition($posX - 12, 0);
|
||||
$quad->setZ(1);
|
||||
$quad->setAction($actionReset);
|
||||
}
|
||||
@ -161,7 +167,9 @@ class StyleManager implements UsageInformationAble {
|
||||
$actionMapNameSearch
|
||||
);
|
||||
$frame->addChild($mapNameButton);
|
||||
$mapNameButton->setX(-$width / 2 + 68);
|
||||
$mapNameButton->setX($posX);
|
||||
|
||||
$posX += 20;
|
||||
|
||||
//Search for Author
|
||||
$authorButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
|
||||
@ -171,7 +179,7 @@ class StyleManager implements UsageInformationAble {
|
||||
$actionAuthorSearch
|
||||
);
|
||||
$frame->addChild($authorButton);
|
||||
$authorButton->setX(-$width / 2 + 87);
|
||||
$authorButton->setX($posX);
|
||||
|
||||
return $frame;
|
||||
}
|
||||
@ -237,18 +245,27 @@ class StyleManager implements UsageInformationAble {
|
||||
$pagerSize = 6.;
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT)->setPosition($width * 0.40, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(1);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(1);
|
||||
|
||||
if ($paging) {
|
||||
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
|
||||
$paging->addButtonControl($pagerNext);
|
||||
$paging->addButtonControl($pagerPrev);
|
||||
$paging->setLabel($pageCountLabel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
namespace ManiaControl\Maps;
|
||||
|
||||
use finfo;
|
||||
use ZipArchive;
|
||||
use FML\Controls\Frame;
|
||||
use FML\Controls\Label;
|
||||
use FML\Controls\Entry;
|
||||
use FML\Controls\Labels\Label_Button;
|
||||
use FML\Controls\Labels\Label_Text;
|
||||
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
@ -12,6 +15,7 @@ use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||
use FML\Controls\Quads\Quad_UIConstructionBullet_Buttons;
|
||||
use FML\ManiaLink;
|
||||
use FML\Script\Features\Paging;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Files\AsyncHttpRequest;
|
||||
use ManiaControl\Files\FileUtil;
|
||||
use ManiaControl\Logger;
|
||||
@ -41,6 +45,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
const ACTION_INSPECT_FILE = 'MapsDirBrowser.InspectFile.';
|
||||
const ACTION_ADD_FILE = 'MapsDirBrowser.AddFile.';
|
||||
const ACTION_ERASE_FILE = 'MapsDirBrowser.EraseFile.';
|
||||
const ACTION_CREATE_FOLDER = 'MapsDirBrowser.CreateFolder';
|
||||
const ACTION_DOWNLOAD_FILE = 'MapsDirBrowser.DownloadFile';
|
||||
const WIDGET_NAME = 'MapsDirBrowser.Widget';
|
||||
const CACHE_FOLDER_PATH = 'FolderPath';
|
||||
@ -67,6 +72,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_INSPECT_FILE), $this, 'handleInspectFile');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_ADD_FILE), $this, 'handleAddFile');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_ERASE_FILE), $this, 'handleEraseFile');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_CREATE_FOLDER), $this, 'handleCreateFolder');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerRegexListener($this->buildActionRegex(self::ACTION_DOWNLOAD_FILE), $this, 'handleDownloadFile');
|
||||
}
|
||||
|
||||
@ -137,17 +143,31 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
|
||||
$innerWidth = $width - 2;
|
||||
$innerHeigth = $height - 27;
|
||||
|
||||
$lineHeight = 4.;
|
||||
|
||||
$index = 0;
|
||||
$posY = $height / 2 - 10;
|
||||
$pageFrame = null;
|
||||
$pageMaxCount = floor($innerHeigth / 4);
|
||||
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$navigateRootQuad = new Quad_Icons64x64_1();
|
||||
$frame->addChild($navigateRootQuad);
|
||||
$navigateRootQuad->setPosition($width * -0.47, $height * 0.45)->setSize(4, 4)->setSubStyle($navigateRootQuad::SUBSTYLE_ToolRoot);
|
||||
$repositionnedFrame->addChild($navigateRootQuad);
|
||||
$navigateRootQuad->setPosition(5, -5);
|
||||
$navigateRootQuad->setSize(4, 4);
|
||||
$navigateRootQuad->setSubStyle($navigateRootQuad::SUBSTYLE_ToolRoot);
|
||||
|
||||
$navigateUpQuad = new Quad_Icons64x64_1();
|
||||
$frame->addChild($navigateUpQuad);
|
||||
$navigateUpQuad->setPosition($width * -0.44, $height * 0.45)->setSize(4, 4)->setSubStyle($navigateUpQuad::SUBSTYLE_ToolUp);
|
||||
$repositionnedFrame->addChild($navigateUpQuad);
|
||||
$navigateUpQuad->setPosition(9, -5);
|
||||
$navigateUpQuad->setSize(4, 4);
|
||||
$navigateUpQuad->setSubStyle($navigateUpQuad::SUBSTYLE_ToolUp);
|
||||
|
||||
if (!$isInMapsFolder) {
|
||||
$navigateRootQuad->setAction(self::ACTION_NAVIGATE_ROOT);
|
||||
@ -155,111 +175,189 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
}
|
||||
|
||||
$directoryLabel = new Label_Text();
|
||||
$frame->addChild($directoryLabel);
|
||||
$repositionnedFrame->addChild($directoryLabel);
|
||||
$dataFolder = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder();
|
||||
$directoryText = substr($folderPath, strlen($dataFolder));
|
||||
$directoryLabel->setPosition($width * -0.41, $height * 0.45)->setSize($width * 0.85, 4)->setHorizontalAlign($directoryLabel::LEFT)->setText($directoryText)->setTextSize(2);
|
||||
$directoryLabel->setPosition(12, -5);
|
||||
$directoryLabel->setSize($width * 0.85, 4);
|
||||
$directoryLabel->setHorizontalAlign($directoryLabel::LEFT);
|
||||
$directoryLabel->setText($directoryText);
|
||||
$directoryLabel->setTextSize(2);
|
||||
|
||||
$tooltipLabel = new Label();
|
||||
$frame->addChild($tooltipLabel);
|
||||
$tooltipLabel->setPosition($width * -0.48, $height * -0.44)->setSize($width * 0.8, 5)->setHorizontalAlign($tooltipLabel::LEFT)->setTextSize(1);
|
||||
$repositionnedFrame->addChild($tooltipLabel);
|
||||
$tooltipLabel->setPosition(3, $height * -1 + 15);
|
||||
$tooltipLabel->setSize($width * 0.8, 5);
|
||||
$tooltipLabel->setHorizontalAlign($tooltipLabel::LEFT);
|
||||
$tooltipLabel->setTextSize(1);
|
||||
|
||||
// Back button
|
||||
$backButton = new Label_Button();
|
||||
$repositionnedFrame->addChild($backButton);
|
||||
$backButton->setStyle($backButton::STYLE_CardMain_Quit);
|
||||
$backButton->setHorizontalAlign($backButton::LEFT);
|
||||
$backButton->setScale(0.5);
|
||||
$backButton->setText('Back');
|
||||
$backButton->setPosition(3, $height * -1 + 5);
|
||||
$backButton->setSize(5, 10);
|
||||
$backButton->setAction(MapCommands::ACTION_OPEN_MAPLIST);
|
||||
|
||||
// Create folder button
|
||||
$label = new Label_Text();
|
||||
$repositionnedFrame->addChild($label);
|
||||
$label->setPosition($width - 113, $height * -1 + 10);
|
||||
$label->setSize(25, 5);
|
||||
$label->setHorizontalAlign($label::LEFT);
|
||||
$label->setTextSize(1);
|
||||
$label->setText('Create folder: ');
|
||||
$label->setAreaFocusColor("00000000");
|
||||
$label->setAreaColor("00000000");
|
||||
|
||||
$entry = new Entry();
|
||||
$repositionnedFrame->addChild($entry);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setHorizontalAlign($entry::LEFT);
|
||||
$entry->setPosition($width - 95, $height * -1 + 10);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setSize(50, 4);
|
||||
$entry->setName("Name");
|
||||
|
||||
//Search for Map-Name
|
||||
$createFolderButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
|
||||
'Create',
|
||||
18,
|
||||
5,
|
||||
self::ACTION_CREATE_FOLDER
|
||||
);
|
||||
$repositionnedFrame->addChild($createFolderButton);
|
||||
$createFolderButton->setPosition($width - 27 - 18/2, $height * -1 + 10);
|
||||
|
||||
// Download button
|
||||
$label = new Label_Text();
|
||||
$repositionnedFrame->addChild($label);
|
||||
$label->setPosition($width - 122, $height * -1 + 5);
|
||||
$label->setSize(27, 5);
|
||||
$label->setHorizontalAlign($label::LEFT);
|
||||
$label->setTextSize(1);
|
||||
$label->setText('Download from URL: ');
|
||||
$label->setAreaFocusColor("00000000");
|
||||
$label->setAreaColor("00000000");
|
||||
$label->addTooltipLabelFeature($tooltipLabel, 'Support Map.Gbx and Zip files');
|
||||
|
||||
$entry = new Entry();
|
||||
$repositionnedFrame->addChild($entry);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setHorizontalAlign($entry::LEFT);
|
||||
$entry->setPosition($width - 95, $height * -1 + 5);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setSize(50, 4);
|
||||
$entry->setName("URL");
|
||||
|
||||
//Search for Map-Name
|
||||
$downloadButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
|
||||
'Download',
|
||||
18,
|
||||
5,
|
||||
self::ACTION_DOWNLOAD_FILE
|
||||
);
|
||||
$repositionnedFrame->addChild($downloadButton);
|
||||
$downloadButton->setPosition($width - 27 - 18/2, $height * -1 + 5);
|
||||
|
||||
$mapFiles = $this->scanMapFiles($folderPath);
|
||||
|
||||
if (is_array($mapFiles)) {
|
||||
if (empty($mapFiles)) {
|
||||
$emptyLabel = new Label();
|
||||
$frame->addChild($emptyLabel);
|
||||
$emptyLabel->setY(20)->setTextColor('aaa')->setText('No files found.')->setTranslate(true);
|
||||
$repositionnedFrame->addChild($emptyLabel);
|
||||
$emptyLabel->setPosition($innerWidth * 0.5, $innerHeigth * -0.5);
|
||||
$emptyLabel->setTextColor('aaa');
|
||||
$emptyLabel->setText('No files found.');
|
||||
$emptyLabel->setTranslate(true);
|
||||
} else {
|
||||
$canAddMaps = $this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP);
|
||||
$canEraseMaps = $this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setPosition(1, -10);
|
||||
|
||||
foreach ($mapFiles as $filePath => $fileName) {
|
||||
$shortFilePath = substr($filePath, strlen($folderPath));
|
||||
|
||||
if ($index % 15 === 0) {
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
// New Page
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$posY = $height / 2 - 10;
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
// Map Frame
|
||||
$mapFrame = new Frame();
|
||||
$pageFrame->addChild($mapFrame);
|
||||
$mapFrame->setY($posY);
|
||||
$mapFrame->setY($lineHeight * $index * -1);
|
||||
|
||||
if ($index % 2 === 0) {
|
||||
// Striped background line
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$mapFrame->addChild($lineQuad);
|
||||
$lineQuad->setZ(-1)->setSize($width, 4)->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||
$lineQuad->setX($innerWidth / 2);
|
||||
$lineQuad->setZ(-1);
|
||||
$lineQuad->setSize($width, $lineHeight);
|
||||
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||
}
|
||||
|
||||
// File name Label
|
||||
$nameLabel = new Label_Text();
|
||||
$mapFrame->addChild($nameLabel);
|
||||
$nameLabel->setX($width * -0.48)->setSize($width * 0.79, 4)->setHorizontalAlign($nameLabel::LEFT)->setStyle($nameLabel::STYLE_TextCardRaceRank)->setTextSize(1)->setText($fileName);
|
||||
$nameLabel->setX(2);
|
||||
$nameLabel->setSize($innerWidth - 20, $lineHeight);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardRaceRank);
|
||||
$nameLabel->setTextSize(1);
|
||||
$nameLabel->setText($fileName);
|
||||
if (substr($fileName, -1) === DIRECTORY_SEPARATOR) $nameLabel->setTextPrefix(' ');
|
||||
|
||||
if (is_dir($filePath)) {
|
||||
// Folder
|
||||
$nameLabel->setAction(self::ACTION_OPEN_FOLDER . substr($shortFilePath, 0, -1))->addTooltipLabelFeature($tooltipLabel, 'Open folder ' . $fileName);
|
||||
} else {
|
||||
// File
|
||||
$nameLabel->setAction(self::ACTION_INSPECT_FILE . $fileName)->addTooltipLabelFeature($tooltipLabel, 'Inspect file ' . $fileName);
|
||||
$nameLabel->setAction(self::ACTION_INSPECT_FILE . base64_encode($fileName))->addTooltipLabelFeature($tooltipLabel, 'Inspect file ' . $fileName);
|
||||
|
||||
if ($canAddMaps) {
|
||||
// 'Add' button
|
||||
$addButton = new Quad_UIConstructionBullet_Buttons();
|
||||
$mapFrame->addChild($addButton);
|
||||
$addButton->setX($width * 0.42)->setSize(4, 4)->setSubStyle($addButton::SUBSTYLE_NewBullet)->setAction(self::ACTION_ADD_FILE . $fileName)->addTooltipLabelFeature($tooltipLabel, 'Add map ' . $fileName);
|
||||
$addButton->setX($width - 5);
|
||||
$addButton->setSize(4, 4);
|
||||
$addButton->setSubStyle($addButton::SUBSTYLE_NewBullet);
|
||||
$addButton->setAction(self::ACTION_ADD_FILE . base64_encode($fileName));
|
||||
$addButton->addTooltipLabelFeature($tooltipLabel, 'Add map ' . $fileName);
|
||||
}
|
||||
|
||||
if ($canEraseMaps) {
|
||||
// 'Erase' button
|
||||
$eraseButton = new Quad_UIConstruction_Buttons();
|
||||
$mapFrame->addChild($eraseButton);
|
||||
$eraseButton->setX($width * 0.46)->setSize(4, 4)->setSubStyle($eraseButton::SUBSTYLE_Erase)->setAction(self::ACTION_ERASE_FILE . $fileName)->addTooltipLabelFeature($tooltipLabel, 'Erase file ' . $fileName);
|
||||
$eraseButton->setX($width - 10);
|
||||
$eraseButton->setSize(4, 4);
|
||||
$eraseButton->setSubStyle($eraseButton::SUBSTYLE_Erase);
|
||||
$eraseButton->setAction(self::ACTION_ERASE_FILE . base64_encode($fileName));
|
||||
$eraseButton->addTooltipLabelFeature($tooltipLabel, 'Erase file ' . $fileName);
|
||||
}
|
||||
}
|
||||
|
||||
$posY -= 4;
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
$label = new Label_Text();
|
||||
$frame->addChild($label);
|
||||
$label->setPosition(-$width / 2 + 5, -$height / 2 + 8.5);
|
||||
$label->setHorizontalAlign($label::LEFT);
|
||||
$label->setTextSize(1);
|
||||
$label->setText('Download from URL: ');
|
||||
|
||||
$entry = new Entry();
|
||||
$frame->addChild($entry);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setHorizontalAlign($entry::LEFT);
|
||||
$entry->setPosition(-$width / 2 + 35, -$height / 2 + 8.5);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setSize($width * 0.35, 4);
|
||||
$entry->setName('SearchString');
|
||||
|
||||
//Search for Map-Name
|
||||
$mapNameButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
|
||||
'Download',
|
||||
18,
|
||||
5,
|
||||
self::ACTION_DOWNLOAD_FILE
|
||||
);
|
||||
$frame->addChild($mapNameButton);
|
||||
$mapNameButton->setPosition(-$width / 2 + 100, -$height / 2 + 8.5);
|
||||
|
||||
} else {
|
||||
$errorLabel = new Label();
|
||||
$frame->addChild($errorLabel);
|
||||
$errorLabel->setY(20)->setTextColor('f30')->setText('No access to the directory.')->setTranslate(true);
|
||||
$repositionnedFrame->addChild($errorLabel);
|
||||
$errorLabel->setPosition($innerWidth * 0.5, $innerHeigth * -0.5);
|
||||
$errorLabel->setTextColor('f30');
|
||||
$errorLabel->setText('No access to the directory.');
|
||||
$errorLabel->setTranslate(true);
|
||||
}
|
||||
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, self::WIDGET_NAME);
|
||||
@ -295,6 +393,15 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uasort($mapFiles, function ($a, $b) {
|
||||
$aIsDir = (substr($a, -1) === DIRECTORY_SEPARATOR);
|
||||
$bIsDir = (substr($b, -1) === DIRECTORY_SEPARATOR);
|
||||
|
||||
if ($aIsDir && !$bIsDir) return -1;
|
||||
else if (!$aIsDir && $bIsDir) return 1;
|
||||
return 0;
|
||||
});
|
||||
return $mapFiles;
|
||||
}
|
||||
|
||||
@ -351,9 +458,23 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
*/
|
||||
public function handleInspectFile(array $actionCallback, Player $player) {
|
||||
$actionName = $actionCallback[1][2];
|
||||
$fileName = substr($actionName, strlen(self::ACTION_INSPECT_FILE));
|
||||
// TODO: show inspect file view
|
||||
var_dump($fileName);
|
||||
$fileName = base64_decode(substr($actionName, strlen(self::ACTION_INSPECT_FILE)));
|
||||
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||
$filePath = $folderPath . $fileName;
|
||||
|
||||
$mapsFolder = $this->maniaControl->getServer()->getDirectory()->getMapsFolder();
|
||||
$relativeFilePath = substr($filePath, strlen($mapsFolder));
|
||||
|
||||
try {
|
||||
$message = '';
|
||||
$infos = $this->maniaControl->getClient()->getMapInfo($relativeFilePath);
|
||||
foreach ($infos as $key => $value) {
|
||||
$message .= '$<$0c0' . $key .':$> '. $value . PHP_EOL;
|
||||
}
|
||||
$this->maniaControl->getChat()->sendChat($message, $player->login, false);
|
||||
} catch (\Throwable $th) {
|
||||
$this->maniaControl->getChat()->sendError("can't fetch map info: ". $th->getMessage(), $player->login);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -363,8 +484,13 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleAddFile(array $actionCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$actionName = $actionCallback[1][2];
|
||||
$fileName = substr($actionName, strlen(self::ACTION_ADD_FILE));
|
||||
$fileName = base64_decode(substr($actionName, strlen(self::ACTION_ADD_FILE)));
|
||||
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||
$filePath = $folderPath . $fileName;
|
||||
|
||||
@ -409,7 +535,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$map
|
||||
);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
Logger::logInfo($message, true);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') added the map file "'. $filePath .'"');
|
||||
|
||||
// Queue requested Map
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($player, $map);
|
||||
@ -422,16 +548,33 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleEraseFile(array $actionCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ERASE_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$actionName = $actionCallback[1][2];
|
||||
$fileName = substr($actionName, strlen(self::ACTION_ERASE_FILE));
|
||||
$fileName = base64_decode(substr($actionName, strlen(self::ACTION_ERASE_FILE)));
|
||||
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||
$filePath = $folderPath . $fileName;
|
||||
|
||||
$maps = $this->maniaControl->getMapManager()->getMaps();
|
||||
$mapsFolder = $this->maniaControl->getServer()->getDirectory()->getMapsFolder();
|
||||
$filteredMaps = array_filter($maps, function ($item) use ($mapsFolder, $filePath) {
|
||||
return ($mapsFolder . $item->fileName === $filePath);
|
||||
});
|
||||
foreach ($filteredMaps as $map) {
|
||||
Logger::log('Map "'. $filePath .'" loaded by the server, removing it from the playlist before erasing the file');
|
||||
$this->maniaControl->getMapManager()->removeMap($player, $map->uid);
|
||||
}
|
||||
|
||||
if (@unlink($filePath)) {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Erased %s!',
|
||||
$fileName
|
||||
);
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') erased the map file "'. $filePath .'"');
|
||||
$this->showManiaLink($player);
|
||||
} else {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
@ -442,7 +585,38 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle 'CreateFolder' page action
|
||||
*
|
||||
* @param array $actionCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleCreateFolder(array $actionCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$name = trim($actionCallback[1][3][0]["Value"]);
|
||||
|
||||
var_dump($actionCallback);
|
||||
if ($name === "") return;
|
||||
|
||||
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||
if (mkdir($folderPath . $name, 755, true)) {
|
||||
$message = "Successfully created directory ". $name;
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') created the folder "'. $folderPath .'"');
|
||||
|
||||
$this->showManiaLink($player, $name);
|
||||
} else {
|
||||
$message = "Failed to create directory ". $name;
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
Logger::logError(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') encountered an error when creating the folder "'. $folderPath .'".');
|
||||
|
||||
$this->showManiaLink($player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle 'handleDownloadFile' page action
|
||||
@ -451,7 +625,8 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleDownloadFile(array $actionCallback, Player $player) {
|
||||
$url = trim($actionCallback[1][3][0]["Value"]);
|
||||
$url = trim($actionCallback[1][3][1]["Value"]);
|
||||
if ($url === "") return;
|
||||
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||
|
||||
@ -460,96 +635,128 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
if (!$file || $error) {
|
||||
$message = "Impossible to download the file: " . $error;
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
Logger::logError($message);
|
||||
Logger::logError(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') encountered an error during the download of the zip file "'. $url .'": '. $error);
|
||||
return;
|
||||
}
|
||||
$filePath = "";
|
||||
|
||||
$contentdispositionheader = "";
|
||||
foreach ($headers as $key => $value) {
|
||||
if (strtolower($key) === "content-disposition") {
|
||||
$contentdispositionheader = urldecode($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
if ($finfo->buffer($file) === "application/zip") {
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($contentdispositionheader !== "") {
|
||||
$value = $contentdispositionheader;
|
||||
// Create a temporary file
|
||||
$tempFile = tempnam(sys_get_temp_dir(), 'zip');
|
||||
file_put_contents($tempFile, $file);
|
||||
|
||||
if (strpos($value, ';') !== false) {
|
||||
$open = $zip->open($tempFile);
|
||||
|
||||
list($type, $attr_parts) = explode(';', $value, 2);
|
||||
|
||||
$attr_parts = explode(';', $attr_parts);
|
||||
$attributes = array();
|
||||
|
||||
foreach ($attr_parts as $part) {
|
||||
if (strpos($part, '=') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($key, $value) = explode('=', $part, 2);
|
||||
|
||||
$attributes[trim($key)] = trim($value);
|
||||
}
|
||||
|
||||
$attrNames = ['filename*' => true, 'filename' => false];
|
||||
$filename = null;
|
||||
$isUtf8 = false;
|
||||
foreach ($attrNames as $attrName => $utf8) {
|
||||
if (!empty($attributes[$attrName])) {
|
||||
$filename = trim($attributes[$attrName]);
|
||||
$isUtf8 = $utf8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filename !== null) {
|
||||
if ($isUtf8 && strpos($filename, "utf-8''") === 0 && $filename = substr($filename, strlen("utf-8''"))) {
|
||||
$filePath = $folderPath . rawurldecode($filename);
|
||||
}
|
||||
if (substr($filename, 0, 1) === '"' && substr($filename, -1, 1) === '"') {
|
||||
$filePath = $folderPath . substr($filename, 1, -1);
|
||||
} else {
|
||||
$filePath = $folderPath . $filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->isMapFileName($filePath)) {
|
||||
$message = "File is not a map: " . $filename;
|
||||
if ($open === true) {
|
||||
$zip->extractTo($folderPath);
|
||||
$zip->close();
|
||||
$message = "Successfully extracted zip archive from ". $url;
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') downloaded the zip file "'. $url .'"');
|
||||
} else {
|
||||
$message = "Cannot extract archive from ". $url;
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
Logger::logError($message);
|
||||
return;
|
||||
Logger::logError(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') encountered an error when downloading the zip file "'. $url .'": Cannot extract the archive');
|
||||
}
|
||||
// Clean up the temporary file
|
||||
unlink($tempFile);
|
||||
} else {
|
||||
$path = parse_url($url, PHP_URL_PATH);
|
||||
$fileName = "";
|
||||
|
||||
// extracted basename
|
||||
$filePath = $folderPath . basename($path);
|
||||
|
||||
if (!$this->isMapFileName($filePath)) {
|
||||
$filePath .= ".Map.Gbx";
|
||||
}
|
||||
}
|
||||
|
||||
if ($filePath != "") {
|
||||
if (file_exists($filePath)) {
|
||||
$index = 1;
|
||||
while (file_exists(substr($filePath, 0, -8) . "-" . $index . ".Map.Gbx")) {
|
||||
$index++;
|
||||
$contentdispositionheader = "";
|
||||
foreach ($headers as $key => $value) {
|
||||
if (strtolower($key) === "content-disposition") {
|
||||
$contentdispositionheader = urldecode($value);
|
||||
break;
|
||||
}
|
||||
$filePath = substr($filePath, 0, -8) . "-" . $index . ".Map.Gbx";
|
||||
}
|
||||
$bytes = file_put_contents($filePath, $file);
|
||||
if (!$bytes || $bytes <= 0) {
|
||||
$message = "Impossible to determine filename";
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
Logger::logError($message);
|
||||
return;
|
||||
|
||||
if ($contentdispositionheader !== "") {
|
||||
$value = $contentdispositionheader;
|
||||
|
||||
if (strpos($value, ';') !== false) {
|
||||
|
||||
list($type, $attr_parts) = explode(';', $value, 2);
|
||||
|
||||
$attr_parts = explode(';', $attr_parts);
|
||||
$attributes = array();
|
||||
|
||||
foreach ($attr_parts as $part) {
|
||||
if (strpos($part, '=') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($key, $value) = explode('=', $part, 2);
|
||||
|
||||
$attributes[trim($key)] = trim($value);
|
||||
}
|
||||
|
||||
$fileName = null;
|
||||
|
||||
if (array_key_exists('filename*', $attributes)) {
|
||||
$fileName = trim($attributes['filename*']);
|
||||
|
||||
// remove prefix if needed
|
||||
if (strpos(strtolower($fileName), "utf-8''") === 0) {
|
||||
$fileName = substr($fileName, strlen("utf-8''"));
|
||||
}
|
||||
} else if (array_key_exists('filename', $attributes)) {
|
||||
$fileName = trim($attributes['filename']);
|
||||
}
|
||||
|
||||
if ($fileName !== null) {
|
||||
if (substr($fileName, 0, 1) === '"' && substr($fileName, -1, 1) === '"') {
|
||||
$fileName = substr($fileName, 1, -1);
|
||||
}
|
||||
|
||||
$filePath = $folderPath . FileUtil::getClearedFileName($fileName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->isMapFileName($filePath)) {
|
||||
$message = "File is not a map: " . $fileName;
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
Logger::logError(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') encountered an error when downloadeding the map file "'. $fileName .'": File is not a map');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$path = parse_url($url, PHP_URL_PATH);
|
||||
|
||||
// extracted basename
|
||||
$fileName = basename($path);
|
||||
|
||||
if (!$this->isMapFileName($fileName)) {
|
||||
$fileName .= ".Map.Gbx";
|
||||
}
|
||||
$filePath = $folderPath . $fileName;
|
||||
}
|
||||
|
||||
if ($filePath != "") {
|
||||
if (file_exists($filePath)) {
|
||||
$index = 1;
|
||||
while (file_exists(substr($filePath, 0, -8) . "-" . $index . ".Map.Gbx")) {
|
||||
$index++;
|
||||
}
|
||||
$filePath = substr($filePath, 0, -8) . "-" . $index . ".Map.Gbx";
|
||||
}
|
||||
$bytes = file_put_contents($filePath, $file);
|
||||
if (!$bytes || $bytes <= 0) {
|
||||
$message = "Failed to write file " . $filePath;
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
Logger::logError(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') encountered an error when downloadeding the map file "'. $fileName .'": Failed to write the file');
|
||||
return;
|
||||
}
|
||||
|
||||
$message = "Successfully downloaded the map ". $fileName;
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') downloaded the map file "'. $filePath .'"');
|
||||
}
|
||||
}
|
||||
$this->showManiaLink($player, $folderPath);
|
||||
|
||||
$this->showManiaLink($player);
|
||||
});
|
||||
|
||||
$asyncHttpRequest->getData();
|
||||
|
@ -8,6 +8,7 @@ use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
@ -49,7 +50,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
$this->initActionsMenuButtons();
|
||||
|
||||
// Admin commands
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.');
|
||||
@ -68,6 +68,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('xmaps', 'xlist'), $this, 'command_xList', false, 'Shows maps from ManiaExchange.');
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List');
|
||||
@ -75,16 +76,22 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap');
|
||||
}
|
||||
|
||||
public function handleAfterInit() {
|
||||
$this->initActionsMenuButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all Actions Menu Buttons
|
||||
*/
|
||||
private function initActionsMenuButtons() {
|
||||
// Menu Open xList
|
||||
$itemQuad = new Quad();
|
||||
$itemQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
||||
$itemQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
|
||||
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
|
||||
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
|
||||
if ($this->maniaControl->getMapManager()->getMXManager()->getStatus()) {
|
||||
$itemQuad = new Quad();
|
||||
$itemQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
||||
$itemQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
|
||||
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
|
||||
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
|
||||
}
|
||||
|
||||
// Menu Open List
|
||||
$itemQuad = new Quad_Icons64x64_1();
|
||||
@ -207,7 +214,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
return;
|
||||
}
|
||||
|
||||
$params = explode(' ', $chatCallback[1][2], 2);
|
||||
$params = explode(' ', trim($chatCallback[1][2]), 2);
|
||||
if (count($params) < 2) {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Usage example: %s',
|
||||
|
@ -13,6 +13,7 @@ use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||
use FML\ManiaLink;
|
||||
use FML\Script\Features\Paging;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
@ -55,11 +56,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
const ACTION_SEARCH_MAP_NAME = 'MapList.SearchMapName';
|
||||
const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor';
|
||||
const ACTION_RESET = 'MapList.ResetMapList';
|
||||
const MAX_MAPS_PER_PAGE = 13;
|
||||
const MAX_PAGES_PER_CHUNK = 2;
|
||||
const DEFAULT_CUSTOM_VOTE_PLUGIN = 'MCTeam\CustomVotesPlugin';
|
||||
const CACHE_CURRENT_PAGE = 'CurrentPage';
|
||||
const WIDGET_NAME = 'MapList';
|
||||
const SETTING_PERMISSION_MAPLIST = 'Show the Map List';
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
@ -75,6 +76,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_MAPLIST, AuthenticationManager::AUTH_LEVEL_PLAYER, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
@ -111,6 +115,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
*/
|
||||
public function checkUpdates(array $chatCallback, Player $player) {
|
||||
// Update Mx Infos
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) return;
|
||||
|
||||
$this->maniaControl->getMapManager()->getMXManager()->fetchManiaExchangeMapInformation();
|
||||
|
||||
// Reshow the Maplist
|
||||
@ -125,9 +131,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* @param int $pageIndex
|
||||
*/
|
||||
public function showMapList(Player $player, $mapList = null, $pageIndex = -1, $entryvalue = "") {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_MAPLIST)) return;
|
||||
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$buttonY = -$height / 2 + 9;
|
||||
$buttonY = $height * -0.5 + 5;
|
||||
|
||||
if ($pageIndex < 0) {
|
||||
$pageIndex = (int) $player->getCache($this, self::CACHE_CURRENT_PAGE);
|
||||
@ -137,15 +145,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex);
|
||||
$mapsBeginIndex = $this->getChunkMapsBeginIndex($chunkIndex);
|
||||
$pageMaxCount = $this->getMapPerPage();
|
||||
|
||||
// Get Maps
|
||||
if (!is_array($mapList)) {
|
||||
$mapList = $this->maniaControl->getMapManager()->getMaps();
|
||||
}
|
||||
$mapList = array_slice($mapList, $mapsBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE);
|
||||
$mapList = array_slice($mapList, $mapsBeginIndex, self::MAX_PAGES_PER_CHUNK * $pageMaxCount);
|
||||
|
||||
$totalMapsCount = $this->maniaControl->getMapManager()->getMapsCount();
|
||||
$pagesCount = ceil($totalMapsCount / self::MAX_MAPS_PER_PAGE);
|
||||
$pagesCount = ceil($totalMapsCount / $pageMaxCount);
|
||||
|
||||
// Create ManiaLink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@ -169,7 +178,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
self::ACTION_CLEAR_MAPQUEUE
|
||||
);
|
||||
$frame->addChild($clearMapQueueButton);
|
||||
$clearMapQueueButton->setPosition($width/2 - 5 - 30/2, $buttonY);
|
||||
$clearMapQueueButton->setPosition($width * 0.5 - 30/2 - 27, $buttonY);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) {
|
||||
@ -181,7 +190,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN)
|
||||
);
|
||||
$frame->addChild($mxCheckForUpdatesButton);
|
||||
$mxCheckForUpdatesButton->setPosition($width/2 - 5 - 30 - 5 - 36/2, $buttonY);
|
||||
$mxCheckForUpdatesButton->setPosition($width * 0.5 - 36/2 - 57, $buttonY);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
||||
@ -192,7 +201,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
DirectoryBrowser::ACTION_SHOW
|
||||
);
|
||||
$frame->addChild($browserButton);
|
||||
$browserButton->setPosition(-$width/2 + 5 + 36/2, $buttonY);
|
||||
$browserButton->setPosition($width * -0.5 + 36 / 2 + 5, $buttonY);
|
||||
}
|
||||
|
||||
// Headline
|
||||
@ -205,7 +214,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$labelLine->addLabelEntryText('Id', $posX + 5);
|
||||
$labelLine->addLabelEntryText('Mx Id', $posX + 10);
|
||||
$labelLine->addLabelEntryText('Map Name', $posX + 20);
|
||||
$labelLine->addLabelEntryText('Author', $posX + 68);
|
||||
$labelLine->addLabelEntryText('Author', $width / 2 - 56);
|
||||
$labelLine->addLabelEntryText('Actions', $width / 2 - 16);
|
||||
$labelLine->setY(-7);
|
||||
$labelLine->render();
|
||||
@ -215,6 +224,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
// Predefine description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$descriptionLabel->setY($height * -0.5 + 12);
|
||||
$frame->addChild($descriptionLabel);
|
||||
|
||||
$queuedMaps = $this->maniaControl->getMapManager()->getMapQueue()->getQueuedMapsRanking();
|
||||
@ -235,7 +245,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
foreach ($mapList as $map) {
|
||||
/** @var Map $map */
|
||||
if ($index % self::MAX_MAPS_PER_PAGE === 0) {
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$posY = $height / 2 - 16;
|
||||
@ -275,7 +285,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$mxQuad->setSize(3, 3);
|
||||
$mxQuad->setImageUrl($mxIcon);
|
||||
$mxQuad->setImageFocusUrl($mxIconHover);
|
||||
$mxQuad->setX($posX + 65);
|
||||
$mxQuad->setX($width / 2 - 63);
|
||||
$mxQuad->setUrl($map->mx->pageurl);
|
||||
$mxQuad->setZ(0.01);
|
||||
$description = 'View ' . $map->getEscapedName() . ' on Mania-Exchange';
|
||||
@ -287,7 +297,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$mxQuad->setSize(3, 3);
|
||||
$mxQuad->setImageUrl($mxIconGreen);
|
||||
$mxQuad->setImageFocusUrl($mxIconGreenHover);
|
||||
$mxQuad->setX($posX + 62);
|
||||
$mxQuad->setX($width / 2 - 60);
|
||||
$mxQuad->setUrl($map->mx->pageurl);
|
||||
$mxQuad->setZ(0.01);
|
||||
$description = 'Update for ' . $map->getEscapedName() . ' available on Mania-Exchange!';
|
||||
@ -304,12 +314,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$labelLine = new LabelLine($mapFrame);
|
||||
$labelLine->addLabelEntryText($mapListId, $posX + 5, 5);
|
||||
$labelLine->addLabelEntryText($mxId, $posX + 10, 10);
|
||||
$labelLine->addLabelEntryText(Formatter::stripDirtyCodes($map->name), $posX + 20, 42);
|
||||
$labelLine->addLabelEntryText(Formatter::stripDirtyCodes($map->name), $posX + 20, $width - 20 - 56 - 5);
|
||||
|
||||
$label = new Label_Text();
|
||||
$mapFrame->addChild($label);
|
||||
$label->setText($map->authorNick);
|
||||
$label->setX($posX + 68);
|
||||
$label->setX($width / 2 - 56);
|
||||
$label->setSize(47, 0);
|
||||
$label->setAction(MapCommands::ACTION_SHOW_AUTHOR . $map->authorLogin);
|
||||
$description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!';
|
||||
@ -340,7 +350,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$description = $map->getEscapedName() . ' is on Map-Queue Position: ' . $queuedMaps[$map->uid];
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
} else {
|
||||
} else if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_ADD_TO_QUEUE)) {
|
||||
// Map-Queue-Map-Button
|
||||
$queueLabel = new Label_Button();
|
||||
$mapFrame->addChild($queueLabel);
|
||||
@ -445,6 +455,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, self::WIDGET_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of maps per page
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMapPerPage() {
|
||||
$pageheight = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
return floor(($pageheight - 26) / 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Chunk Index with the given Page Index
|
||||
*
|
||||
@ -453,7 +473,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
*/
|
||||
private function getChunkIndexFromPageNumber($pageIndex) {
|
||||
$mapsCount = $this->maniaControl->getMapManager()->getMapsCount();
|
||||
$pagesCount = ceil($mapsCount / self::MAX_MAPS_PER_PAGE);
|
||||
$pagesCount = ceil($mapsCount / $this->getMapPerPage());
|
||||
if ($pageIndex > $pagesCount - 1) {
|
||||
$pageIndex = $pagesCount - 1;
|
||||
}
|
||||
@ -467,7 +487,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* @return int
|
||||
*/
|
||||
private function getChunkMapsBeginIndex($chunkIndex) {
|
||||
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE;
|
||||
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * $this->getMapPerPage();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -584,6 +604,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
break;
|
||||
case self::ACTION_SWITCH_MAP:
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)) return;
|
||||
|
||||
// Don't queue on Map-Change
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
||||
try {
|
||||
|
@ -19,6 +19,8 @@ use ManiaControl\ManiaExchange\ManiaExchangeList;
|
||||
use ManiaControl\ManiaExchange\ManiaExchangeManager;
|
||||
use ManiaControl\ManiaExchange\MXMapInfo;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Settings\Setting;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\AlreadyInListException;
|
||||
@ -56,6 +58,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
const SETTING_AUTOSAVE_MAPLIST = 'Autosave Maplist file';
|
||||
const SETTING_MAPLIST_FILE = 'File to write Maplist in';
|
||||
const SETTING_WRITE_OWN_MAPLIST_FILE = 'Write a own Maplist File for every Server called serverlogin.txt';
|
||||
const SETTING_ENABLE_MX = 'Enable MX features';
|
||||
|
||||
const SEARCH_BY_AUTHOR = 'Author';
|
||||
const SEARCH_BY_MAP_NAME = 'Mapname';
|
||||
@ -116,6 +119,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
|
||||
|
||||
// Permissions
|
||||
@ -131,6 +135,9 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AUTOSAVE_MAPLIST, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIST_FILE, "MatchSettings/tracklist.txt");
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WRITE_OWN_MAPLIST_FILE, false);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ENABLE_MX, true);
|
||||
|
||||
$this->mxManager->setStatus($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ENABLE_MX, true));
|
||||
|
||||
//Initlaize Communication Listenings
|
||||
$this->initalizeCommunicationListenings();
|
||||
@ -188,6 +195,8 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
* @param string $uid
|
||||
*/
|
||||
public function updateMap($admin, $uid) {
|
||||
if ($admin !== null && !$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_ADD_MAP)) return;
|
||||
|
||||
$this->updateMapTimestamp($uid);
|
||||
|
||||
if (!isset($uid) || !isset($this->maps[$uid])) {
|
||||
@ -213,6 +222,19 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Settings
|
||||
*
|
||||
* @param ?Setting $setting
|
||||
*/
|
||||
public function updateSettings(?Setting $setting = null) {
|
||||
if (!isset($setting) || !$setting->belongsToClass($this)) return;
|
||||
|
||||
if ($setting->setting === self::SETTING_ENABLE_MX) {
|
||||
$this->mxManager->setStatus($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ENABLE_MX, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Timestamp of a Map
|
||||
*
|
||||
@ -252,6 +274,8 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
* @return bool
|
||||
*/
|
||||
public function removeMap($admin, $uid, $eraseFile = false, $message = true) {
|
||||
if ($admin !== null && !$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_REMOVE_MAP)) return;
|
||||
|
||||
if (!isset($this->maps[$uid])) {
|
||||
if ($admin) {
|
||||
$this->maniaControl->getChat()->sendError('Map does not exist!', $admin);
|
||||
@ -354,7 +378,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
public function addMapFromMx($mapId, $login, $update = false) {
|
||||
if (is_numeric($mapId)) {
|
||||
// Check if map exists
|
||||
$this->maniaControl->getMapManager()->getMXManager()->fetchMapInfo($mapId, function (MXMapInfo $mapInfo = null) use (
|
||||
$this->maniaControl->getMapManager()->getMXManager()->fetchMapInfo($mapId, function (?MXMapInfo $mapInfo = null) use (
|
||||
&$login, &$update
|
||||
) {
|
||||
if (!$mapInfo || !isset($mapInfo->uploaded)) {
|
||||
@ -733,7 +757,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
$currentIndex = $this->getMapIndex($this->getCurrentMap());
|
||||
|
||||
// No RestructureNeeded
|
||||
if ($currentIndex < Maplist::MAX_MAPS_PER_PAGE - 1) {
|
||||
if ($currentIndex < $this->mapList->getMapPerPage() - 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
const SETTING_MAPLIMIT_ADMIN = 'Maximum maps per admin (Admin+) in the Map-Queue (-1 = unlimited)';
|
||||
const SETTING_MESSAGE_FORMAT = 'Message Format';
|
||||
const SETTING_BUFFERSIZE = 'Size of the Map-Queue buffer (recently played maps)';
|
||||
const SETTING_PERMISSION_ADD_TO_QUEUE = 'Add map to queue';
|
||||
const SETTING_PERMISSION_CLEAR_MAPQUEUE = 'Clear MapQueue';
|
||||
const SETTING_PERMISSION_QUEUE_BUFFER = 'Queue maps in buffer';
|
||||
|
||||
@ -74,6 +75,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10);
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ADD_TO_QUEUE, AuthenticationManager::AUTH_LEVEL_PLAYER, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CLEAR_MAPQUEUE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_QUEUE_BUFFER, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
|
||||
@ -113,7 +115,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
*
|
||||
* @param Player $admin |null
|
||||
*/
|
||||
public function clearMapQueue(Player $admin = null) {
|
||||
public function clearMapQueue(?Player $admin = null) {
|
||||
if ($admin && !$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
@ -283,6 +285,8 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_TO_QUEUE)) return;
|
||||
|
||||
// Check if the Player is muted
|
||||
if ($player->isMuted()) {
|
||||
$this->maniaControl->getChat()->sendError('Muted Players are not allowed to queue a map.', $player);
|
||||
@ -369,6 +373,10 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
if (!isset($this->queuedMaps[$uid])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$queuer = $this->maniaControl->getMapManager()->getMapQueue()->getQueuer($uid);
|
||||
if (($queuer === null || $queuer->login !== $player->login) && !$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) return;
|
||||
|
||||
/** @var Map $map */
|
||||
$map = $this->queuedMaps[$uid][1];
|
||||
unset($this->queuedMaps[$uid]);
|
||||
|
@ -196,6 +196,23 @@ class Player implements Dumpable, UsageInformationAble {
|
||||
return ($this->pid <= 0 || substr($this->login, 0, 1) === '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AccountId from Login
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountId() {
|
||||
if (strlen($this->login) !== 22) return $this->login;
|
||||
|
||||
$login = str_pad($this->login, 24, "=", STR_PAD_RIGHT);
|
||||
|
||||
$login = str_replace("_","/", str_replace("-","+", $login));
|
||||
$login = base64_decode($login);
|
||||
|
||||
return vsprintf("%s%s-%s-%s-%s-%s%s%s", str_split(bin2hex($login), 4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get province
|
||||
*
|
||||
|
@ -47,6 +47,17 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
const SPECTATOR_BUT_KEEP_SELECTABLE = 3;
|
||||
const ECHO_WARN_PLAYER = 'ManiaControl.PlayerManager.WarnPlayer';
|
||||
|
||||
/*
|
||||
* Callback Constants
|
||||
*/
|
||||
const CB_PLAYER_FORCED_TO_PLAY = 'PlayerActions.PlayerForcedToPlay';
|
||||
const CB_PLAYER_FORCED_TO_TEAM = 'PlayerActions.PlayerForcedToTeam';
|
||||
const CB_PLAYER_FORCED_TO_SPEC = 'PlayerActions.PlayerForcedToSpec';
|
||||
const CB_PLAYER_MUTED = 'PlayerActions.PlayerMuted';
|
||||
const CB_PLAYER_WARNED = 'PlayerActions.PlayerWarned';
|
||||
const CB_PLAYER_KICKED = 'PlayerActions.PlayerKicked';
|
||||
const CB_PLAYER_BANNED = 'PlayerActions.PlayerBanned';
|
||||
|
||||
/*
|
||||
* Permission Setting Constants
|
||||
*/
|
||||
@ -201,6 +212,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_FORCED_TO_TEAM, $target, $teamId);
|
||||
|
||||
$message = false;
|
||||
$teamName = '';
|
||||
if ($teamId === self::TEAM_BLUE) {
|
||||
@ -229,7 +242,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
|
||||
if ($message) {
|
||||
$this->maniaControl->getChat()->sendInformation($message);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
Logger::logInfo($message, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -281,6 +294,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
}
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_FORCED_TO_PLAY, $target);
|
||||
|
||||
// Announce force
|
||||
if ($displayAnnouncement) {
|
||||
if ($calledByAdmin) {
|
||||
@ -340,6 +355,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_FORCED_TO_SPEC, $target);
|
||||
|
||||
if ($calledByAdmin) {
|
||||
$title = $admin->getAuthLevelName();
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
@ -460,6 +477,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_MUTED, $target);
|
||||
|
||||
if ($calledByAdmin) {
|
||||
$title = $admin->getAuthLevelName();
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
@ -561,6 +580,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
// Display manialink
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target);
|
||||
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_WARNED, $target);
|
||||
|
||||
if ($calledByAdmin) {
|
||||
$title = $admin->getAuthLevelName();
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
@ -625,6 +646,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
}
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_KICKED, $target);
|
||||
|
||||
if ($calledByAdmin) {
|
||||
$title = $admin->getAuthLevelName();
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
@ -679,6 +702,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_BANNED, $target);
|
||||
|
||||
$title = $admin->getAuthLevelName();
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
"{$title} %s banned %s!",
|
||||
|
@ -62,7 +62,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
const CACHE_CURRENT_PAGE = 'PlayerList.CurrentPage';
|
||||
const DEFAULT_CUSTOM_VOTE_PLUGIN = 'MCTeam\CustomVotesPlugin';
|
||||
const SHOWN_MAIN_WINDOW = -1;
|
||||
const MAX_PLAYERS_PER_PAGE = 15;
|
||||
const MAX_PAGES_PER_CHUNK = 2;
|
||||
|
||||
/*
|
||||
@ -157,8 +156,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$totalPlayersCount = count($players);
|
||||
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount);
|
||||
$playerBeginIndex = $this->getChunkStatsBeginIndex($chunkIndex);
|
||||
|
||||
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
|
||||
$pageMaxCount = $this->getPlayersPerPage();
|
||||
$pagesCount = ceil($totalPlayersCount / $pageMaxCount);
|
||||
|
||||
//create manialink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@ -207,11 +206,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerIndex = 1 + $playerBeginIndex;
|
||||
|
||||
//Slice Array to chunk length
|
||||
$players = array_slice($players, $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE, true);
|
||||
$players = array_slice($players, $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * $pageMaxCount , true);
|
||||
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
|
||||
|
||||
foreach ($players as $listPlayer) {
|
||||
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
|
||||
if ($index % $pageMaxCount === 1) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
|
||||
@ -628,7 +627,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
* @return int
|
||||
*/
|
||||
private function getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount) {
|
||||
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
|
||||
$pagesCount = ceil($totalPlayersCount / $this->getPlayersPerPage());
|
||||
if ($pageIndex > $pagesCount - 1) {
|
||||
$pageIndex = $pagesCount - 1;
|
||||
}
|
||||
@ -642,7 +641,18 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
* @return int
|
||||
*/
|
||||
private function getChunkStatsBeginIndex($chunkIndex) {
|
||||
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE;
|
||||
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * $this->getPlayersPerPage();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get number of players per page
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPlayersPerPage() {
|
||||
$pageheight = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
return floor($pageheight * 0.82 / 4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -600,12 +600,12 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
|
||||
}
|
||||
|
||||
$player = new Player($this->maniaControl, false);
|
||||
$player->index = $row->index;
|
||||
$player->index = intval($row->index);
|
||||
$player->login = $row->login;
|
||||
$player->rawNickname = $row->nickname;
|
||||
$player->nickname = Formatter::stripDirtyCodes($player->rawNickname);
|
||||
$player->path = $row->path;
|
||||
$player->authLevel = $row->authLevel;
|
||||
$player->authLevel = intval($row->authLevel);
|
||||
|
||||
return $player;
|
||||
}
|
||||
@ -715,12 +715,12 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
|
||||
}
|
||||
|
||||
$player = new Player($this->maniaControl, false);
|
||||
$player->index = $playerIndex;
|
||||
$player->index = intval($playerIndex);
|
||||
$player->login = $row->login;
|
||||
$player->rawNickname = $row->nickname;
|
||||
$player->nickname = Formatter::stripDirtyCodes($player->rawNickname);
|
||||
$player->path = $row->path;
|
||||
$player->authLevel = $row->authLevel;
|
||||
$player->authLevel = intval($row->authLevel);
|
||||
|
||||
return $player;
|
||||
}
|
||||
|
@ -79,7 +79,9 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
// Config
|
||||
$pagerSize = 9.;
|
||||
$entryHeight = 5.;
|
||||
$posY = 0.;
|
||||
$innerWidth = $width - 4;
|
||||
$innerHeight = $height - 16;
|
||||
$pageMaxCount = floor($innerHeight / $entryHeight);
|
||||
$pageFrame = null;
|
||||
|
||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||
@ -105,23 +107,41 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = clone $pagerPrev;
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setX($width * 0.45);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSubStyle($pagerPrev::SUBSTYLE_ArrowNext);
|
||||
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT)->setPosition($width * 0.35, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(2);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
|
||||
$paging->addButtonControl($pagerNext);
|
||||
$paging->addButtonControl($pagerPrev);
|
||||
$paging->setLabel($pageCountLabel);
|
||||
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
// Info tooltip
|
||||
$infoTooltipLabel = new Label();
|
||||
$frame->addChild($infoTooltipLabel);
|
||||
$infoTooltipLabel->setAlign($infoTooltipLabel::LEFT, $infoTooltipLabel::TOP)->setPosition($width * -0.45, $height * -0.22)->setSize($width * 0.7, $entryHeight)->setTextSize(1)->setTranslate(true)->setVisible(false)->setAutoNewLine(true)->setMaxLines(5);
|
||||
$repositionnedFrame->addChild($infoTooltipLabel);
|
||||
$infoTooltipLabel->setAlign($infoTooltipLabel::LEFT, $infoTooltipLabel::TOP);
|
||||
$infoTooltipLabel->setPosition(3, $height * -1 + 16);
|
||||
$infoTooltipLabel->setSize($width - 30, 20);
|
||||
$infoTooltipLabel->setTextSize(1);
|
||||
$infoTooltipLabel->setTranslate(true);
|
||||
$infoTooltipLabel->setVisible(false);
|
||||
$infoTooltipLabel->setAutoNewLine(true);
|
||||
$infoTooltipLabel->setMaxLines(5);
|
||||
|
||||
// List plugins
|
||||
foreach ($pluginList as $plugin) {
|
||||
@ -135,21 +155,26 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($index % 10 === 0) {
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
// New page
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$repositionnedFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$posY = $height * 0.41;
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$pluginFrame = new Frame();
|
||||
$pageFrame->addChild($pluginFrame);
|
||||
$pluginFrame->setY($posY);
|
||||
$pluginFrame->setY($entryHeight * $index * -1);
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$pluginFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.62, $entryHeight)->setStyle($nameLabel::STYLE_TextCardSmall)->setTextSize(2)->setText($plugin->name);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX(2);
|
||||
$nameLabel->setSize($innerWidth * 0.6, $entryHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setTextSize(2);
|
||||
$nameLabel->setText($plugin->name);
|
||||
|
||||
$description = "Author: {$plugin->author}\nVersion: {$plugin->currentVersion->version}\nDesc: {$plugin->description}";
|
||||
$infoTooltipLabel->setLineSpacing(1);
|
||||
@ -159,7 +184,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
// Incompatibility label
|
||||
$infoLabel = new Label_Text();
|
||||
$pluginFrame->addChild($infoLabel);
|
||||
$infoLabel->setHorizontalAlign($infoLabel::RIGHT)->setX($width * 0.47)->setSize($width * 0.33, $entryHeight)->setTextSize(1)->setTextColor('f30');
|
||||
$infoLabel->setHorizontalAlign($infoLabel::RIGHT)->setX($innerWidth * 0.47)->setSize($innerWidth * 0.33, $entryHeight)->setTextSize(1)->setTextColor('f30');
|
||||
if ($plugin->currentVersion->min_mc_version > ManiaControl::VERSION) {
|
||||
$infoLabel->setText("Needs at least MC-Version '{$plugin->currentVersion->min_mc_version}'");
|
||||
} else {
|
||||
@ -169,17 +194,24 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
// Install button
|
||||
$installButton = new Label_Button();
|
||||
$pluginFrame->addChild($installButton);
|
||||
$installButton->setHorizontalAlign($installButton::RIGHT)->setX($width * 0.47)->setStyle($installButton::STYLE_CardButtonSmall)->setText('Install')->setTranslate(true)->setAction(self::ACTION_PREFIX_INSTALL_PLUGIN . $plugin->id);
|
||||
$installButton->setHorizontalAlign($installButton::RIGHT);
|
||||
$installButton->setSize($innerWidth * 0.3, $entryHeight);
|
||||
$installButton->setX($innerWidth - 4);
|
||||
$installButton->setStyle($installButton::STYLE_CardButtonSmall);
|
||||
$installButton->setText('Install');
|
||||
$installButton->setTranslate(true);
|
||||
$installButton->setAction(self::ACTION_PREFIX_INSTALL_PLUGIN . $plugin->id);
|
||||
|
||||
if ($plugin->currentVersion->verified > 0) {
|
||||
// Suggested quad
|
||||
$suggestedQuad = new Quad_Icons64x64_1();
|
||||
$pluginFrame->addChild($suggestedQuad);
|
||||
$suggestedQuad->setPosition($width * 0.45, $entryHeight * 0.12, 2)->setSize(4, 4)->setSubStyle($suggestedQuad::SUBSTYLE_StateSuggested);
|
||||
$suggestedQuad->setPosition($innerWidth - 2, $entryHeight * 0.12, 2);
|
||||
$suggestedQuad->setSize(4, 4);
|
||||
$suggestedQuad->setSubStyle($suggestedQuad::SUBSTYLE_StateSuggested);
|
||||
}
|
||||
}
|
||||
|
||||
$posY -= $entryHeight;
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ class PluginManager {
|
||||
return false;
|
||||
}
|
||||
array_push($this->pluginClasses, $pluginClass);
|
||||
sort($this->pluginClasses);
|
||||
natcasesort($this->pluginClasses);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
const ACTION_PREFIX_UPDATEPLUGIN = 'PluginMenu.Update.';
|
||||
const ACTION_UPDATEPLUGINS = 'PluginMenu.Update.All';
|
||||
const SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS = 'Change Plugin Settings';
|
||||
const SETTING_CHECK_UPDATE_WHEN_OPENING = 'Check update when opening the menu';
|
||||
const CACHE_SETTING_CLASS = 'PluginMenuCache.SettingClass';
|
||||
|
||||
/*
|
||||
@ -64,6 +65,9 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CHECK_UPDATE_WHEN_OPENING, true);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_BACK_TO_PLUGINS, $this, 'backToPlugins');
|
||||
@ -103,18 +107,18 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
// Config
|
||||
$pagerSize = 9.;
|
||||
$entryHeight = 5.;
|
||||
$pageMaxCount = 10;
|
||||
$pageMaxCount = floor(($height - 16) / $entryHeight);
|
||||
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
|
||||
|
||||
@ -124,7 +128,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
@ -145,33 +149,66 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
// Display normal Plugin List
|
||||
// Plugin pages
|
||||
$posY = 0.;
|
||||
$pluginUpdates = $this->maniaControl->getUpdateManager()->getPluginUpdateManager()->getPluginsUpdates();
|
||||
|
||||
$pluginUpdates = null;
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CHECK_UPDATE_WHEN_OPENING)) {
|
||||
$pluginUpdates = $this->maniaControl->getUpdateManager()->getPluginUpdateManager()->getPluginsUpdates();
|
||||
}
|
||||
|
||||
usort($pluginClasses, function ($pluginClassA, $pluginClassB) {
|
||||
/** @var Plugin $pluginClassA */
|
||||
/** @var Plugin $pluginClassB */
|
||||
return strcmp($pluginClassA::getName(), $pluginClassB::getName());
|
||||
return strcasecmp($pluginClassA::getName(), $pluginClassB::getName());
|
||||
});
|
||||
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setY(-1);
|
||||
|
||||
$descriptionLabel = new Label();
|
||||
$repositionnedFrame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP);
|
||||
$descriptionLabel->setPosition(3, $height * -1 + 16);
|
||||
$descriptionLabel->setSize($width - 30, 20);
|
||||
$descriptionLabel->setTextSize(1);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
$descriptionLabel->setVisible(false);
|
||||
$descriptionLabel->setMaxLines(5);
|
||||
$descriptionLabel->setLineSpacing(1);
|
||||
|
||||
$tooltip = new Label();
|
||||
$repositionnedFrame->addChild($tooltip);
|
||||
$tooltip->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP);
|
||||
$tooltip->setPosition(3, $height * -1 + 5);
|
||||
$tooltip->setSize($width - 30, 5);
|
||||
$tooltip->setTextSize(1);
|
||||
$tooltip->setTranslate(true);
|
||||
$tooltip->setVisible(false);
|
||||
|
||||
$index = 0;
|
||||
$pageFrame = null;
|
||||
foreach ($pluginClasses as $index => $pluginClass) {
|
||||
foreach ($pluginClasses as $pluginClass) {
|
||||
/** @var Plugin $pluginClass */
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$posY = $height * 0.41;
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$active = $this->maniaControl->getPluginManager()->isPluginActive($pluginClass);
|
||||
|
||||
$pluginFrame = new Frame();
|
||||
$pageFrame->addChild($pluginFrame);
|
||||
$pluginFrame->setY($posY);
|
||||
$pluginFrame->setY($entryHeight * $index * -1);
|
||||
|
||||
$activeQuad = new Quad_Icons64x64_1();
|
||||
$pluginFrame->addChild($activeQuad);
|
||||
$activeQuad->setPosition($width * -0.45, -0.1, 1);
|
||||
$activeQuad->setPosition(5, 0, 1);
|
||||
$activeQuad->setSize($entryHeight * 0.9, $entryHeight * 0.9);
|
||||
if ($active) {
|
||||
$activeQuad->setSubStyle($activeQuad::SUBSTYLE_LvlGreen);
|
||||
@ -182,66 +219,58 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$nameLabel = new Label_Text();
|
||||
$pluginFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX($width * -0.4);
|
||||
$nameLabel->setSize($width * 0.5, $entryHeight);
|
||||
$nameLabel->setX(7.5);
|
||||
$nameLabel->setSize($width - 50, $entryHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setTextSize(2);
|
||||
$nameLabel->setText($pluginClass::getName());
|
||||
|
||||
$descriptionLabel = new Label();
|
||||
$pageFrame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP);
|
||||
$descriptionLabel->setPosition($width * -0.45, $height * -0.22);
|
||||
$descriptionLabel->setSize($width * 0.7, $entryHeight);
|
||||
$descriptionLabel->setTextSize(2);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
$descriptionLabel->setVisible(false);
|
||||
$descriptionLabel->setMaxLines(5);
|
||||
$descriptionLabel->setLineSpacing(1);
|
||||
$description = "Author: {$pluginClass::getAuthor()}\nVersion: {$pluginClass::getVersion()}\nDesc: {$pluginClass::getDescription()}";
|
||||
$nameLabel->addTooltipLabelFeature($descriptionLabel,$description);
|
||||
$nameLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
$quad = new Quad_Icons128x32_1();
|
||||
$pluginFrame->addChild($quad);
|
||||
$quad->setSubStyle($quad::SUBSTYLE_Settings);
|
||||
$quad->setX(15);
|
||||
$quad->setX($width - 37);
|
||||
$quad->setZ(1);
|
||||
$quad->setSize(5, 5);
|
||||
$quad->setAction(self::ACTION_PREFIX_SETTINGS . $pluginClass);
|
||||
$quad->addTooltipLabelFeature($tooltip, "Open settings of ". $pluginClass::getName());
|
||||
|
||||
$statusChangeButton = new Label_Button();
|
||||
$pluginFrame->addChild($statusChangeButton);
|
||||
$statusChangeButton->setHorizontalAlign($statusChangeButton::RIGHT);
|
||||
$statusChangeButton->setX($width * 0.45);
|
||||
$statusChangeButton->setStyle($statusChangeButton::STYLE_CardButtonSmall);
|
||||
$statusChangeButton->setX($width - 6);
|
||||
$statusChangeButton->setStyle($statusChangeButton::STYLE_CardButtonSmallS);
|
||||
if ($active) {
|
||||
$statusChangeButton->setTextPrefix('$f00');
|
||||
$statusChangeButton->setText('Deactivate');
|
||||
$statusChangeButton->setAction(self::ACTION_PREFIX_DISABLEPLUGIN . $pluginClass);
|
||||
$statusChangeButton->addTooltipLabelFeature($tooltip, "Deactivate plugin ". $pluginClass::getName());
|
||||
|
||||
} else {
|
||||
$statusChangeButton->setTextPrefix('a');
|
||||
$statusChangeButton->setText('Activate');
|
||||
$statusChangeButton->setAction(self::ACTION_PREFIX_ENABLEPLUGIN . $pluginClass);
|
||||
$statusChangeButton->addTooltipLabelFeature($tooltip, "Activate plugin ". $pluginClass::getName());
|
||||
}
|
||||
|
||||
if ($pluginUpdates && array_key_exists($pluginClass::getId(), $pluginUpdates)) {
|
||||
$quadUpdate = new Quad_Icons128x128_1();
|
||||
$pluginFrame->addChild($quadUpdate);
|
||||
$quadUpdate->setSubStyle($quadUpdate::SUBSTYLE_ProfileVehicle);
|
||||
$quadUpdate->setX(56);
|
||||
$quadUpdate->setX($width - 3.5);
|
||||
$quadUpdate->setZ(2);
|
||||
$quadUpdate->setSize(5, 5);
|
||||
$quadUpdate->setAction(self::ACTION_PREFIX_UPDATEPLUGIN . $pluginClass);
|
||||
}
|
||||
|
||||
$posY -= $entryHeight;
|
||||
$index++;
|
||||
}
|
||||
|
||||
if ($pluginUpdates) {
|
||||
$updatePluginsButton = new Label_Button();
|
||||
$frame->addChild($updatePluginsButton);
|
||||
$updatePluginsButton->setHorizontalAlign($updatePluginsButton::RIGHT);
|
||||
$updatePluginsButton->setPosition($width * 0.5, -29, 2);
|
||||
$updatePluginsButton->setPosition($width * 0.5, $height * -0.37, 2);
|
||||
$updatePluginsButton->setWidth(10);
|
||||
$updatePluginsButton->setStyle($updatePluginsButton::STYLE_CardButtonSmallS);
|
||||
$updatePluginsButton->setText(count($pluginUpdates) . ' update(s)');
|
||||
@ -267,18 +296,36 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$settings = $this->maniaControl->getSettingManager()->getSettingsByClass($settingClass);
|
||||
$isunlinkable = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getSettingManager(), SettingManager::SETTING_ALLOW_UNLINK_SERVER);
|
||||
|
||||
$pageSettingsMaxCount = 10;
|
||||
$posY = 0;
|
||||
$index = 0;
|
||||
$settingHeight = 5.;
|
||||
$pageFrame = null;
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setY(-8.);
|
||||
|
||||
if ($isunlinkable) {
|
||||
$pagesFrame->setX(5.); // move a bit the settings to diplay the padlocks
|
||||
$innerWidth = $width - 6;
|
||||
} else {
|
||||
$pagesFrame->setX(2.);
|
||||
$innerWidth = $width - 3;
|
||||
}
|
||||
|
||||
$innerHeight = $height - 8 - 10;
|
||||
$settingHeight = 5.;
|
||||
$valueWidth = $innerWidth * 0.3;
|
||||
$pageSettingsMaxCount = floor($innerHeight / $settingHeight);
|
||||
$index = 0;
|
||||
|
||||
$pageFrame = null;
|
||||
|
||||
//Headline Label
|
||||
$headLabel = new Label_Text();
|
||||
$frame->addChild($headLabel);
|
||||
$repositionnedFrame->addChild($headLabel);
|
||||
$headLabel->setHorizontalAlign($headLabel::LEFT);
|
||||
$headLabel->setPosition($width * -0.46, $height * 0.41);
|
||||
$headLabel->setSize($width * 0.6, $settingHeight);
|
||||
$headLabel->setPosition(3, -6);
|
||||
$headLabel->setSize($width - 6, $settingHeight);
|
||||
$headLabel->setStyle($headLabel::STYLE_TextCardSmall);
|
||||
$headLabel->setTextSize(3);
|
||||
$headLabel->setText($settingClass);
|
||||
@ -292,38 +339,37 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
foreach ($settings as $setting) {
|
||||
if ($index % $pageSettingsMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$posY = $height * 0.41 - $settingHeight * 1.5;
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$settingFrame = new Frame();
|
||||
$pageFrame->addChild($settingFrame);
|
||||
$settingFrame->setY($posY);
|
||||
$settingFrame->setY($settingHeight * $index * -1);
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$settingFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX($width * -0.46);
|
||||
$nameLabel->setSize($width * 0.6, $settingHeight);
|
||||
$nameLabel->setSize($innerWidth * 0.6, $settingHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setTextSize(2);
|
||||
$nameLabel->setText($setting->setting);
|
||||
$nameLabel->setTextColor('fff');
|
||||
|
||||
$descriptionLabel = new Label_Text();
|
||||
$pageFrame->addChild($descriptionLabel);
|
||||
$repositionnedFrame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
||||
$descriptionLabel->setPosition(-0.45 * $width, -0.35 * $height);
|
||||
$descriptionLabel->setSize(0.9 * $width, $settingHeight);
|
||||
$descriptionLabel->setTextSize(2);
|
||||
$descriptionLabel->setPosition(3, $height * -1 + 10);
|
||||
$descriptionLabel->setSize($innerWidth - 6, $settingHeight);
|
||||
$descriptionLabel->setTextSize(1);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
$nameLabel->addTooltipLabelFeature($descriptionLabel, $setting->description);
|
||||
|
||||
if ($isunlinkable) {
|
||||
$quadlink = new Quad();
|
||||
$settingFrame->addChild($quadlink);
|
||||
$quadlink->setPosition(-0.48 * $width, 0.2, -0.01);
|
||||
$quadlink->setPosition(-2, 0.2);
|
||||
$quadlink->setSize(4, 4);
|
||||
$quadlink->setColorize("ccccccaa");
|
||||
$quadlink->setStyle("UICommon64_1");
|
||||
@ -334,15 +380,15 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
if ($setting->type === Setting::TYPE_BOOL) {
|
||||
// Boolean checkbox
|
||||
$quad = new Quad();
|
||||
$quad->setPosition($width * 0.33, 0, -0.01);
|
||||
$quad->setPosition($innerWidth - $valueWidth / 2, 0);
|
||||
$quad->setSize(4, 4);
|
||||
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $setting->index, $setting->value, $quad);
|
||||
$settingFrame->addChild($checkBox);
|
||||
} else if ($setting->type === Setting::TYPE_SET) {
|
||||
// SET value picker
|
||||
$label = new Label_Text();
|
||||
$label->setX($width * 0.33);
|
||||
$label->setSize($width * 0.3, $settingHeight * 0.9);
|
||||
$label->setPosition($innerWidth - $valueWidth / 2, 0);
|
||||
$label->setSize($valueWidth, $settingHeight * 0.9);
|
||||
$label->setStyle($label::STYLE_TextValueSmall);
|
||||
$label->setTextSize(1);
|
||||
$valuePicker = new ValuePicker(self::ACTION_PREFIX_SETTING . $setting->index, $setting->set, $setting->value, $label);
|
||||
@ -351,26 +397,25 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
// Value entry
|
||||
$entry = new Entry();
|
||||
$settingFrame->addChild($entry);
|
||||
$entry->setX($width * 0.33);
|
||||
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
||||
$entry->setPosition($innerWidth - $valueWidth / 2, 0);
|
||||
$entry->setSize($valueWidth, $settingHeight * 0.9);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setMaxLength(1000); // Actions are limited to 1024 chars per field
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setName(self::ACTION_PREFIX_SETTING . $setting->index);
|
||||
$entry->setDefault($setting->value);
|
||||
}
|
||||
|
||||
$posY -= $settingHeight;
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
$backButton = new Label_Button();
|
||||
$frame->addChild($backButton);
|
||||
$repositionnedFrame->addChild($backButton);
|
||||
$backButton->setStyle($backButton::STYLE_CardMain_Quit);
|
||||
$backButton->setHorizontalAlign($backButton::LEFT);
|
||||
$backButton->setScale(0.5);
|
||||
$backButton->setText('Back');
|
||||
$backButton->setPosition(-$width / 2 + 5, -$height / 2 + 5);
|
||||
$backButton->setPosition(5 , $height * -1 + 5);
|
||||
$backButton->setAction(self::ACTION_BACK_TO_PLUGINS);
|
||||
|
||||
if ($isunlinkable) {
|
||||
@ -380,8 +425,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
5,
|
||||
self::ACTION_PREFIX_MANAGE_SETTING_LINK . $settingClass
|
||||
);
|
||||
$frame->addChild($mapNameButton);
|
||||
$mapNameButton->setPosition(-$width / 2 + 60, -35);
|
||||
$repositionnedFrame->addChild($mapNameButton);
|
||||
$mapNameButton->setPosition(60, $height * -1 + 5);
|
||||
}
|
||||
|
||||
return $frame;
|
||||
@ -401,10 +446,21 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
public function getManageSettingsLink(Frame $frame, $width, $height, Paging $paging, Player $player, $settingClass) {
|
||||
$settings = $this->maniaControl->getSettingManager()->getSettingsByClass($settingClass);
|
||||
|
||||
$pageSettingsMaxCount = 10;
|
||||
$posY = 0;
|
||||
$index = 0;
|
||||
$settingHeight = 5.;
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setY(-8.);
|
||||
$pagesFrame->setX(5.);
|
||||
|
||||
$innerWidth = $width - 6;
|
||||
$innerHeight = $height - 8 - 10;
|
||||
$settingHeight = 5.;
|
||||
$pageSettingsMaxCount = floor($innerHeight / $settingHeight);
|
||||
$index = 0;
|
||||
|
||||
$pageFrame = null;
|
||||
|
||||
if (count($settings) > 64) {
|
||||
@ -414,10 +470,10 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
|
||||
//Headline Label
|
||||
$headLabel = new Label_Text();
|
||||
$frame->addChild($headLabel);
|
||||
$repositionnedFrame->addChild($headLabel);
|
||||
$headLabel->setHorizontalAlign($headLabel::LEFT);
|
||||
$headLabel->setPosition($width * -0.46, $height * 0.41);
|
||||
$headLabel->setSize($width * 0.6, $settingHeight);
|
||||
$headLabel->setPosition(3, -6);
|
||||
$headLabel->setSize($width - 6, $settingHeight);
|
||||
$headLabel->setStyle($headLabel::STYLE_TextCardSmall);
|
||||
$headLabel->setTextSize(3);
|
||||
$headLabel->setText($settingClass);
|
||||
@ -426,54 +482,51 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
foreach ($settings as $setting) {
|
||||
if ($index % $pageSettingsMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$posY = $height * 0.41 - $settingHeight * 1.5;
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$settingFrame = new Frame();
|
||||
$pageFrame->addChild($settingFrame);
|
||||
$settingFrame->setY($posY);
|
||||
$settingFrame->setY($settingHeight * $index * -1);
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$settingFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX($width * -0.46);
|
||||
$nameLabel->setSize($width * 0.6, $settingHeight);
|
||||
$nameLabel->setSize($innerWidth * 0.6, $settingHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setTextSize(2);
|
||||
$nameLabel->setText($setting->setting);
|
||||
$nameLabel->setTextColor('fff');
|
||||
|
||||
$descriptionLabel = new Label_Text();
|
||||
$pageFrame->addChild($descriptionLabel);
|
||||
$repositionnedFrame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
||||
$descriptionLabel->setPosition(-0.45 * $width, -0.35 * $height);
|
||||
$descriptionLabel->setSize(0.9 * $width, $settingHeight);
|
||||
$descriptionLabel->setTextSize(2);
|
||||
$descriptionLabel->setPosition(3, $height * -1 + 10);
|
||||
$descriptionLabel->setSize($innerWidth - 6, $settingHeight);
|
||||
$descriptionLabel->setTextSize(1);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
$nameLabel->addTooltipLabelFeature($descriptionLabel, $setting->description);
|
||||
|
||||
$quad = new Quad();
|
||||
$quad->setPosition($width * 0.33, 0.2, -0.01);
|
||||
$quad->setPosition($innerWidth - $innerWidth * 0.3 / 2, 0.2);
|
||||
$quad->setSize(4, 4);
|
||||
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING_LINK . $setting->index, $setting->linked, $quad);
|
||||
$checkBox->setEnabledDesign("UICommon64_1", "Padlock_light");
|
||||
$checkBox->setDisabledDesign("UICommon64_1", "Padlock_light");
|
||||
$settingFrame->addChild($checkBox);
|
||||
|
||||
$posY -= $settingHeight;
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
$backButton = new Label_Button();
|
||||
$frame->addChild($backButton);
|
||||
$repositionnedFrame->addChild($backButton);
|
||||
$backButton->setStyle($backButton::STYLE_CardMain_Quit);
|
||||
$backButton->setHorizontalAlign($backButton::LEFT);
|
||||
$backButton->setScale(0.5);
|
||||
$backButton->setText('Back');
|
||||
$backButton->setPosition(-$width / 2 + 5, -$height / 2 + 5);
|
||||
$backButton->setPosition(5 , $height * -1 + 5);
|
||||
$backButton->setAction(self::ACTION_PREFIX_SETTINGS . $settingClass);
|
||||
|
||||
return $frame;
|
||||
@ -583,6 +636,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$setting->value = $settingData['Value'];
|
||||
}
|
||||
$this->maniaControl->getSettingManager()->saveSetting($setting);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') changed the setting "'. $setting->class . '\\\\' . $setting->setting .'" to "'. $setting->value .'"');
|
||||
|
||||
}
|
||||
|
||||
$this->maniaControl->getChat()->sendSuccess('Plugin Settings saved!', $player);
|
||||
|
@ -275,35 +275,50 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT)->setPosition($width * 0.35, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(2);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
|
||||
$paging->addButtonControl($pagerNext);
|
||||
$paging->addButtonControl($pagerPrev);
|
||||
$paging->setLabel($pageCountLabel);
|
||||
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setY(-8.);
|
||||
|
||||
// Pages
|
||||
$posY = 0.;
|
||||
$index = 0;
|
||||
$pageFrame = null;
|
||||
$pageMaxCount = floor(($height - 16) / $optionHeight);
|
||||
|
||||
foreach ($serverOptionsArray as $name => $value) {
|
||||
// Continue on CurrentMaxPlayers...
|
||||
$pos = strpos($name, 'Current'); // TODO: display 'Current...' somewhere
|
||||
if ($pos !== false) {
|
||||
continue;
|
||||
}
|
||||
if (strpos($name, 'Current') !== false) continue; // TODO: display 'Current...' somewhere
|
||||
|
||||
if ($index % 13 === 0) {
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$posY = $height * 0.41;
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$posY = 0.;
|
||||
}
|
||||
|
||||
$optionsFrame = new Frame();
|
||||
@ -312,25 +327,59 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$optionsFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.4, $optionHeight)->setStyle($nameLabel::STYLE_TextCardSmall)->setTextSize($labelTextSize)->setText($name)->setTextColor('fff');
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX(2);
|
||||
$nameLabel->setSize($width * 0.6, $optionHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setTextSize($labelTextSize)->setText($name);
|
||||
$nameLabel->setTextColor('fff');
|
||||
|
||||
if (is_bool($value)) {
|
||||
// Boolean checkbox
|
||||
$quad = new Quad();
|
||||
$quad->setPosition($width * 0.23, 0, -0.01)->setSize(4, 4);
|
||||
$quad->setPosition($width - $width * 0.3 / 2 - 2, 0, -0.01);
|
||||
$quad->setSize(4, 4);
|
||||
$checkBox = new CheckBox(self::ACTION_PREFIX_OPTION . $name, $value, $quad);
|
||||
$optionsFrame->addChild($checkBox);
|
||||
} else {
|
||||
// Other
|
||||
$entry = new Entry();
|
||||
$optionsFrame->addChild($entry);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall)->setX($width * 0.23)->setTextSize(1)->setSize($width * 0.48, $optionHeight * 0.9)->setName(self::ACTION_PREFIX_OPTION . $name)->setDefault($value);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setX($width - $width * 0.3 / 2 - 2);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setSize($width * 0.3, $optionHeight * 0.9);
|
||||
$entry->setName(self::ACTION_PREFIX_OPTION . $name);
|
||||
$entry->setDefault($value);
|
||||
|
||||
if ($name === 'Comment') {
|
||||
$entry->setSize($width * 0.48, $optionHeight * 3. + $optionHeight * 0.9)->setAutoNewLine(true)->setVerticalAlign($entry::TOP)->setY($optionHeight * 1.5 + 2.5);
|
||||
$entry->setSize($width * 0.3, $optionHeight * 3. + $optionHeight * 0.9);
|
||||
$entry->setAutoNewLine(true);
|
||||
$entry->setVerticalAlign($entry::TOP);
|
||||
$entry->setY($optionHeight * 1.5 + 2.5);
|
||||
$optionsFrame->setY($posY - $optionHeight * 1.5);
|
||||
$posY -= $optionHeight * 3.;
|
||||
$index += 3;
|
||||
} else if (strpos($name, 'Password') !== false) {
|
||||
$entry->setTextFormat("Password");
|
||||
$entry->setId($name);
|
||||
|
||||
$quad = new Quad();
|
||||
$quad->setPosition($width - $width * 0.3 - 4, 0, -0.01);
|
||||
$quad->setSize(4, 4);
|
||||
$checkBox = new CheckBox(null, false, $quad);
|
||||
$checkBox->setEnabledDesign("UICommon64_1", "Eye_light");
|
||||
$checkBox->setDisabledDesign("UICommon64_1", "Eye_light");
|
||||
$checkBox->setCustomScript("
|
||||
declare CMlEntry Entry <=> (Quad_CheckBox.Parent.Parent.GetFirstChild(\"$name\") as CMlEntry);
|
||||
if (Entry != Null) {
|
||||
if (Quad_CheckBox.StyleSelected) {
|
||||
Entry.TextFormat = CMlEntry::ETextFormat::Basic;
|
||||
} else {
|
||||
Entry.TextFormat = CMlEntry::ETextFormat::Password;
|
||||
}
|
||||
}");
|
||||
$optionsFrame->addChild($checkBox);
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,6 +418,7 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList
|
||||
$success = $this->applyNewServerOptions($newServerOptions, $player);
|
||||
if ($success) {
|
||||
$this->maniaControl->getChat()->sendSuccess('Server Options saved!', $player);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') changed Server Options');
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError('Server Options saving failed!', $player);
|
||||
}
|
||||
|
@ -166,13 +166,13 @@ class ServerUIPropertiesMenu implements ConfiguratorMenu, CallbackListener, Time
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
@ -182,7 +182,7 @@ class ServerUIPropertiesMenu implements ConfiguratorMenu, CallbackListener, Time
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
|
@ -10,6 +10,7 @@ use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\TimerListener;
|
||||
use ManiaControl\Configurator\ConfiguratorMenu;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Structures\VoteRatio;
|
||||
@ -71,11 +72,20 @@ class VoteRatiosMenu implements CallbackListener, ConfiguratorMenu, TimerListene
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$voteRatioFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.7, $lineHeight)->setTextSize(2)->setTranslate(true)->setText($voteRatioDescription);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX($width * -0.5 + 4);
|
||||
$nameLabel->setSize($width * 0.7, $lineHeight);
|
||||
$nameLabel->setTextSize(2);
|
||||
$nameLabel->setTranslate(true);
|
||||
$nameLabel->setText($voteRatioDescription);
|
||||
|
||||
$entry = new Entry();
|
||||
$voteRatioFrame->addChild($entry);
|
||||
$entry->setX($width * 0.35)->setSize($width * 0.14, $lineHeight * 0.9)->setStyle(Label_Text::STYLE_TextValueSmall)->setTextSize($index === 0 ? 2 : 1)->setName(self::ACTION_PREFIX_VOTE_RATIO . $voteRatioCommand);
|
||||
$entry->setX($width * 0.5 - $width * 0.14 / 2 - 4);
|
||||
$entry->setSize($width * 0.14, $lineHeight * 0.9);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setTextSize($index === 0 ? 2 : 1);
|
||||
$entry->setName(self::ACTION_PREFIX_VOTE_RATIO . $voteRatioCommand);
|
||||
|
||||
$voteRatio = $this->getVoteRatioForCommand($voteRatios, $voteRatioCommand);
|
||||
if ($voteRatio) {
|
||||
@ -157,6 +167,7 @@ class VoteRatiosMenu implements CallbackListener, ConfiguratorMenu, TimerListene
|
||||
$success = $this->maniaControl->getClient()->setCallVoteRatios($newVoteRatios);
|
||||
if ($success) {
|
||||
$this->maniaControl->getChat()->sendSuccess('Vote Ratios saved!', $player);
|
||||
Logger::log(AuthenticationManager::getAuthLevelName($player->authLevel) .' "'. $player->nickname . '" ('. $player->login .') changed the Vote Ratios');
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError('Vote Ratios saving failed!', $player);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class SettingManager implements CallbackListener, UsageInformationAble {
|
||||
|
||||
const SETTING_ALLOW_UNLINK_SERVER = 'Allow to unlink settings with multiple servers';
|
||||
const SETTING_DELETE_UNUSED_SETTING_AT_START = 'Delete unused settings at ManiaControl start';
|
||||
const SETTING_DISABLE_SETTING_CACHE = 'Disable settings cache';
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
@ -36,6 +37,8 @@ class SettingManager implements CallbackListener, UsageInformationAble {
|
||||
private $maniaControl = null;
|
||||
/** @var Setting[] $storedSettings */
|
||||
private $storedSettings = array();
|
||||
/** @var bool $disableCache */
|
||||
private $disableCache = false;
|
||||
|
||||
/**
|
||||
* Construct a new setting manager instance
|
||||
@ -51,6 +54,7 @@ class SettingManager implements CallbackListener, UsageInformationAble {
|
||||
|
||||
$this->initSetting($this, self::SETTING_ALLOW_UNLINK_SERVER, false);
|
||||
$this->initSetting($this, self::SETTING_DELETE_UNUSED_SETTING_AT_START, true);
|
||||
$this->initSetting($this, self::SETTING_DISABLE_SETTING_CACHE, false, "only for not linked settings");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,6 +118,15 @@ class SettingManager implements CallbackListener, UsageInformationAble {
|
||||
trigger_error($mysqli->error, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// Grow the default value
|
||||
$mysqli->query("ALTER TABLE `" . self::TABLE_SETTINGS . "` MODIFY `default` VARCHAR(1000);");
|
||||
if ($mysqli->error) {
|
||||
// If not Duplicate
|
||||
if ($mysqli->errno !== 1060) {
|
||||
trigger_error($mysqli->error, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -121,6 +134,8 @@ class SettingManager implements CallbackListener, UsageInformationAble {
|
||||
* Handle After Init Callback
|
||||
*/
|
||||
public function handleAfterInit() {
|
||||
$this->disableCache = boolval($this->getSettingValue($this, self::SETTING_DISABLE_SETTING_CACHE));
|
||||
if ($this->disableCache) $this->clearStorage();
|
||||
$this->deleteUnusedSettings();
|
||||
}
|
||||
|
||||
@ -225,6 +240,7 @@ class SettingManager implements CallbackListener, UsageInformationAble {
|
||||
* @param Setting $setting
|
||||
*/
|
||||
private function storeSetting(Setting $setting) {
|
||||
if ($this->disableCache && $setting->linked) return;
|
||||
$this->storedSettings[$setting->class . $setting->setting] = $setting;
|
||||
}
|
||||
|
||||
@ -433,7 +449,20 @@ class SettingManager implements CallbackListener, UsageInformationAble {
|
||||
// Trigger Settings Changed Callback
|
||||
if (!$init) {
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_SETTING_CHANGED, $setting);
|
||||
|
||||
// during the init, value = default
|
||||
if ($setting->setting === self::SETTING_DISABLE_SETTING_CACHE) {
|
||||
$this->disableCache = boolval($setting->value);
|
||||
if ($this->disableCache) {
|
||||
$this->clearStorage();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->disableCache && $setting->linked && isset($this->storedSettings[$setting->class . $setting->setting])) {
|
||||
unset($this->storedSettings[$setting->class . $setting->setting]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
const ACTION_OPEN_STATSLIST = 'SimpleStatsList.OpenStatsList';
|
||||
const ACTION_SORT_STATS = 'SimpleStatsList.SortStats';
|
||||
const ACTION_PAGING_CHUNKS = 'SimpleStatsList.PagingChunk';
|
||||
const MAX_PLAYERS_PER_PAGE = 15;
|
||||
const MAX_PAGES_PER_CHUNK = 10;
|
||||
const CACHE_CURRENT_PAGE = 'SimpleStatsList.CurrentPage';
|
||||
|
||||
@ -146,7 +145,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
|
||||
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount);
|
||||
$playerBeginIndex = $this->getChunkStatsBeginIndex($chunkIndex);
|
||||
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
|
||||
$pagesCount = ceil($totalPlayersCount / $this->getPlayersPerPage());
|
||||
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
$width = $this->statsWidth + 60;
|
||||
@ -231,16 +230,17 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$posY -= 10;
|
||||
$pageFrame = null;
|
||||
$playerIndex = 1 + $playerBeginIndex;
|
||||
$pageMaxCount = $this->getPlayersPerPage();
|
||||
|
||||
if (!isset($statRankings[$order])) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Slice Array to chunk length
|
||||
$statRankings[$order] = array_slice($statRankings[$order], $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE, true);
|
||||
$statRankings[$order] = array_slice($statRankings[$order], $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * $pageMaxCount, true);
|
||||
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
|
||||
foreach ($statRankings[$order] as $playerId => $value) {
|
||||
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
|
||||
if ($index % $pageMaxCount === 1) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$pageFrame->setZ(1);
|
||||
@ -314,17 +314,26 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$pagerSize = 6.;
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
||||
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT)->setPosition($width * 0.40, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(1);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(1);
|
||||
|
||||
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
|
||||
$paging->addButtonControl($pagerNext);
|
||||
$paging->addButtonControl($pagerPrev);
|
||||
$paging->setLabel($pageCountLabel);
|
||||
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'SimpleStatsList');
|
||||
}
|
||||
@ -337,7 +346,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
* @return int
|
||||
*/
|
||||
private function getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount) {
|
||||
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
|
||||
$pagesCount = ceil($totalPlayersCount / $this->getPlayersPerPage());
|
||||
if ($pageIndex > $pagesCount - 1) {
|
||||
$pageIndex = $pagesCount - 1;
|
||||
}
|
||||
@ -351,9 +360,20 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
* @return int
|
||||
*/
|
||||
private function getChunkStatsBeginIndex($chunkIndex) {
|
||||
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE;
|
||||
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * $this->getPlayersPerPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of players per page
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPlayersPerPage() {
|
||||
$pageheight = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
return floor($pageheight * 0.82 / 4);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called on ManialinkPageAnswer
|
||||
*
|
||||
|
@ -68,7 +68,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
|
||||
*
|
||||
* @param Player $player
|
||||
*/
|
||||
public function checkPluginsUpdate(Player $player = null) {
|
||||
public function checkPluginsUpdate(?Player $player = null) {
|
||||
$message = 'Checking Plugins for newer Versions...';
|
||||
if ($player) {
|
||||
$this->maniaControl->getChat()->sendInformation($message, $player);
|
||||
@ -119,6 +119,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
|
||||
$message = "Plugins Update Check completed: There are {$updatesCount} Updates available!";
|
||||
if ($player) {
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins($message . " (you can use //pluginsupdate)");
|
||||
}
|
||||
Logger::log($message);
|
||||
}
|
||||
@ -163,7 +165,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
|
||||
*
|
||||
* @param Player $player
|
||||
*/
|
||||
public function performPluginsUpdate(Player $player = null) {
|
||||
public function performPluginsUpdate(?Player $player = null) {
|
||||
$pluginsUpdates = $this->getPluginsUpdates();
|
||||
if (empty($pluginsUpdates)) {
|
||||
$message = 'There are no Plugin Updates available!';
|
||||
@ -239,7 +241,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
|
||||
* @param Player $player
|
||||
* @param bool $update
|
||||
*/
|
||||
private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) {
|
||||
private function installPlugin(PluginUpdateData $pluginUpdateData, ?Player $player = null, $update = false) {
|
||||
if ($player && !$this->maniaControl->getAuthenticationManager()->checkPermission($player, InstallMenu::SETTING_PERMISSION_INSTALL_PLUGINS))
|
||||
{
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
|
@ -64,7 +64,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ENABLE_UPDATECHECK, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AUTO_UPDATE, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AUTO_UPDATE, false);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_UPDATECHECK_INTERVAL, 1);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_UPDATECHECK_CHANNEL, $this->getUpdateChannels());
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PERFORM_BACKUPS, true);
|
||||
@ -130,7 +130,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
*
|
||||
* @param UpdateData $coreUpdateData
|
||||
*/
|
||||
public function setCoreUpdateData(UpdateData $coreUpdateData = null) {
|
||||
public function setCoreUpdateData(?UpdateData $coreUpdateData = null) {
|
||||
$this->coreUpdateData = $coreUpdateData;
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
*
|
||||
* @param UpdateData $updateData
|
||||
*/
|
||||
public function handleUpdateCheck(UpdateData $updateData = null) {
|
||||
public function handleUpdateCheck(?UpdateData $updateData = null) {
|
||||
if (!$this->checkUpdateData($updateData)) {
|
||||
// No new update available
|
||||
return;
|
||||
@ -218,7 +218,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
* @param UpdateData $updateData
|
||||
* @return bool
|
||||
*/
|
||||
public function checkUpdateData(UpdateData $updateData = null) {
|
||||
public function checkUpdateData(?UpdateData $updateData = null) {
|
||||
if (!$updateData || !$updateData->url) {
|
||||
// Data corrupted
|
||||
return false;
|
||||
@ -268,7 +268,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
* @param UpdateData $updateData
|
||||
* @return bool
|
||||
*/
|
||||
public function checkUpdateDataBuildVersion(UpdateData $updateData = null) {
|
||||
public function checkUpdateDataBuildVersion(?UpdateData $updateData = null) {
|
||||
if (!$updateData) {
|
||||
// Data corrupted
|
||||
return false;
|
||||
@ -310,7 +310,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
public function performCoreUpdate(Player $player = null) {
|
||||
public function performCoreUpdate(?Player $player = null) {
|
||||
if (!$this->coreUpdateData) {
|
||||
$message = 'Update failed: No update Data available!';
|
||||
if ($player) {
|
||||
@ -490,7 +490,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
return;
|
||||
}
|
||||
|
||||
$this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$player) {
|
||||
$this->checkCoreUpdateAsync(function (?UpdateData $updateData = null) use (&$player) {
|
||||
if (!$this->checkUpdateData($updateData)) {
|
||||
$this->maniaControl->getChat()->sendInformation('No Update available!', $player);
|
||||
return;
|
||||
@ -516,7 +516,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
);
|
||||
$this->maniaControl->getChat()->sendInformation($message, $player);
|
||||
} else {
|
||||
$message = $this->maniaControl->getChat()->formatMesssage(
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'New Nightly Build (%s) available! (Current Build: %s)',
|
||||
$updateData->releaseDate,
|
||||
$buildDate
|
||||
@ -524,14 +524,14 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
}
|
||||
} else {
|
||||
$message = $this->maniaControl->getChat()->formatMesssage(
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'New Nightly Build (%s) available!',
|
||||
$updateData->releaseDate
|
||||
);
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
}
|
||||
} else {
|
||||
$message = $this->maniaControl->getChat()->formatMesssage(
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Update for Version %s available!',
|
||||
$updateData->version
|
||||
);
|
||||
@ -563,7 +563,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener,
|
||||
* @param null $player
|
||||
*/
|
||||
private function checkAndHandleCoreUpdate($player = null) {
|
||||
$this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$player) {
|
||||
$this->checkCoreUpdateAsync(function (?UpdateData $updateData = null) use (&$player) {
|
||||
if (!$updateData) {
|
||||
if ($player) {
|
||||
$this->maniaControl->getChat()->sendError('Update is currently not possible!', $player);
|
||||
|
@ -89,7 +89,7 @@ abstract class Formatter implements UsageInformationAble {
|
||||
*/
|
||||
public static function formatTimeH($seconds) {
|
||||
$hrs = floor($seconds / 3600);
|
||||
$mins = intval(floor(($seconds / 60) % 60));
|
||||
$mins = intval(floor($seconds / 60) % 60);
|
||||
$sec = intval($seconds % 60);
|
||||
|
||||
$hrs = str_pad($hrs, 2, '0', STR_PAD_LEFT);
|
||||
@ -177,7 +177,7 @@ abstract class Formatter implements UsageInformationAble {
|
||||
'Cambodia' => 'CAM', 'Cameroon' => 'CAR', // actually CMR
|
||||
'Canada' => 'CAN', 'Cape Verde' => 'CPV', 'Central African Republic' => 'CAF', 'Chad' => 'CHA', 'Chile' => 'CHI', 'China' => 'CHN',
|
||||
'Chinese Taipei' => 'TPE', 'Colombia' => 'COL', 'Congo' => 'CGO', 'Costa Rica' => 'CRC', 'Croatia' => 'CRO', 'Cuba' => 'CUB', 'Cyprus' => 'CYP',
|
||||
'Czech Republic' => 'CZE', 'Czech republic' => 'CZE', 'DR Congo' => 'COD', 'Denmark' => 'DEN', 'Djibouti' => 'DJI', 'Dominica' => 'DMA',
|
||||
'Czech Republic' => 'CZE', 'Czech republic' => 'CZE', 'Czechia' => 'CZE', 'DR Congo' => 'COD', 'Denmark' => 'DEN', 'Djibouti' => 'DJI', 'Dominica' => 'DMA',
|
||||
'Dominican Republic' => 'DOM', 'Ecuador' => 'ECU', 'Egypt' => 'EGY', 'El Salvador' => 'ESA', 'Eritrea' => 'ERI', 'Estonia' => 'EST', 'Ethiopia' => 'ETH',
|
||||
'Fiji' => 'FIJ', 'Finland' => 'FIN', 'France' => 'FRA', 'Gabon' => 'GAB', 'Gambia' => 'GAM', 'Georgia' => 'GEO', 'Germany' => 'GER', 'Ghana' => 'GHA',
|
||||
'Greece' => 'GRE', 'Grenada' => 'GRN', 'Guam' => 'GUM', 'Guatemala' => 'GUA', 'Guinea' => 'GUI', 'Guinea-Bissau' => 'GBS', 'Guyana' => 'GUY',
|
||||
|
@ -107,6 +107,16 @@ class SystemUtil {
|
||||
Logger::log($message . 'FOUND!');
|
||||
}
|
||||
|
||||
// Check for Xml
|
||||
$message = 'Checking for installed xml ... ';
|
||||
if (!extension_loaded('SimpleXML')) {
|
||||
Logger::log($message . 'NOT FOUND!');
|
||||
Logger::log(" -- You don't have xml installed! Check: https://www.php.net/manual/en/xml.setup.php");
|
||||
$success = false;
|
||||
} else {
|
||||
Logger::log($message . 'FOUND!');
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
// Missing requirements
|
||||
self::quit();
|
||||
|
@ -22,7 +22,7 @@ abstract class WebReader {
|
||||
* @param callable $function
|
||||
* @return Response
|
||||
*/
|
||||
public static function getUrl($url, callable $function = null) {
|
||||
public static function getUrl($url, ?callable $function = null) {
|
||||
$request = static::newRequest($url);
|
||||
$response = $request->send();
|
||||
if ($function) {
|
||||
@ -73,7 +73,7 @@ abstract class WebReader {
|
||||
* @param callable $function
|
||||
* @return Response
|
||||
*/
|
||||
public static function postUrl($url, $content = null, callable $function = null) {
|
||||
public static function postUrl($url, $content = null, ?callable $function = null) {
|
||||
$request = static::newRequest($url);
|
||||
$request->getOptions()->set(CURLOPT_POST, true); // post method
|
||||
if ($content) {
|
||||
|
@ -38,7 +38,7 @@ class CheckBox implements Renderable, ScriptFeatureable
|
||||
* @param bool $default (optional) Default value
|
||||
* @param Quad $quad (optional) CheckBox quad
|
||||
*/
|
||||
public function __construct($name = null, $default = null, Quad $quad = null)
|
||||
public function __construct($name = null, $default = null, ?Quad $quad = null)
|
||||
{
|
||||
$this->feature = new CheckBoxFeature();
|
||||
if ($name) {
|
||||
@ -143,6 +143,30 @@ class CheckBox implements Renderable, ScriptFeatureable
|
||||
return $this->feature->getDisabledDesign();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set script launched when clicking on the checkbox
|
||||
*
|
||||
* @api
|
||||
* @param string $customScript script
|
||||
* @return static
|
||||
*/
|
||||
public function setCustomScript(string $customScript)
|
||||
{
|
||||
$this->feature->setCustomScript($customScript);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get script launched when clicking on the checkbox
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomScript()
|
||||
{
|
||||
return $this->feature->getCustomScript();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the disabled design
|
||||
*
|
||||
|
@ -39,7 +39,7 @@ class ValuePicker implements Renderable, ScriptFeatureable
|
||||
* @param string $default (optional) Default value
|
||||
* @param Label $label (optional) ValuePicker label
|
||||
*/
|
||||
public function __construct($name = null, array $values = null, $default = null, Label $label = null)
|
||||
public function __construct($name = null, ?array $values = null, $default = null, ?Label $label = null)
|
||||
{
|
||||
$this->feature = new ValuePickerFeature();
|
||||
if ($name) {
|
||||
|
@ -191,7 +191,7 @@ class Audio extends Control implements Playable, Scriptable
|
||||
/**
|
||||
* @see Scriptable::setScriptAction()
|
||||
*/
|
||||
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
|
||||
public function setScriptAction($scriptAction, ?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptAction = (string)$scriptAction;
|
||||
$this->setScriptActionParameters($scriptActionParameters);
|
||||
@ -209,7 +209,7 @@ class Audio extends Control implements Playable, Scriptable
|
||||
/**
|
||||
* @see Scriptable::setScriptActionParameters()
|
||||
*/
|
||||
public function setScriptActionParameters(array $scriptActionParameters = null)
|
||||
public function setScriptActionParameters(?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptActionParameters = $scriptActionParameters;
|
||||
return $this;
|
||||
|
@ -48,6 +48,11 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
*/
|
||||
protected $autoNewLine = null;
|
||||
|
||||
/**
|
||||
* @var string $maxLength Text format
|
||||
*/
|
||||
protected $maxLength = null;
|
||||
|
||||
/**
|
||||
* @var string $textFormat Text format
|
||||
*/
|
||||
@ -192,6 +197,30 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text format
|
||||
*
|
||||
* @api
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxLength()
|
||||
{
|
||||
return $this->maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text format
|
||||
*
|
||||
* @api
|
||||
* @param int $maxLength Max Length
|
||||
* @return static
|
||||
*/
|
||||
public function setMaxLength($maxLength)
|
||||
{
|
||||
$this->maxLength = $maxLength;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text format
|
||||
*
|
||||
@ -244,7 +273,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
/**
|
||||
* @see Scriptable::setScriptAction()
|
||||
*/
|
||||
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
|
||||
public function setScriptAction($scriptAction, ?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptAction = (string)$scriptAction;
|
||||
$this->setScriptActionParameters($scriptActionParameters);
|
||||
@ -262,7 +291,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
/**
|
||||
* @see Scriptable::setScriptActionParameters()
|
||||
*/
|
||||
public function setScriptActionParameters(array $scriptActionParameters = null)
|
||||
public function setScriptActionParameters(?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptActionParameters = $scriptActionParameters;
|
||||
return $this;
|
||||
@ -443,6 +472,9 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
if ($this->selectText) {
|
||||
$domElement->setAttribute("selecttext", 1);
|
||||
}
|
||||
if ($this->maxLength) {
|
||||
$domElement->setAttribute("maxlen", $this->maxLength);
|
||||
}
|
||||
if ($this->autoNewLine) {
|
||||
$domElement->setAttribute("autonewline", 1);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ class Frame extends Control implements Container
|
||||
* @deprecated Use Style
|
||||
* @see Style
|
||||
*/
|
||||
public function setFormat(Format $format = null)
|
||||
public function setFormat(?Format $format = null)
|
||||
{
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
|
@ -138,7 +138,7 @@ class Frame3d extends Frame implements Scriptable
|
||||
/**
|
||||
* @see Scriptable::setScriptAction()
|
||||
*/
|
||||
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
|
||||
public function setScriptAction($scriptAction, ?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptAction = (string)$scriptAction;
|
||||
$this->setScriptActionParameters($scriptActionParameters);
|
||||
@ -156,7 +156,7 @@ class Frame3d extends Frame implements Scriptable
|
||||
/**
|
||||
* @see Scriptable::setScriptActionParameters()
|
||||
*/
|
||||
public function setScriptActionParameters(array $scriptActionParameters = null)
|
||||
public function setScriptActionParameters(?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptActionParameters = $scriptActionParameters;
|
||||
return $this;
|
||||
|
@ -467,7 +467,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, MultiL
|
||||
/**
|
||||
* @see Scriptable::setScriptAction()
|
||||
*/
|
||||
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
|
||||
public function setScriptAction($scriptAction, ?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptAction = (string)$scriptAction;
|
||||
$this->setScriptActionParameters($scriptActionParameters);
|
||||
@ -485,7 +485,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, MultiL
|
||||
/**
|
||||
* @see Scriptable::setScriptActionParameters()
|
||||
*/
|
||||
public function setScriptActionParameters(array $scriptActionParameters = null)
|
||||
public function setScriptActionParameters(?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptActionParameters = $scriptActionParameters;
|
||||
return $this;
|
||||
|
@ -579,7 +579,7 @@ class Quad extends Control implements Actionable, BackgroundColorable, BgColorab
|
||||
/**
|
||||
* @see Scriptable::setScriptAction()
|
||||
*/
|
||||
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
|
||||
public function setScriptAction($scriptAction, ?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptAction = (string)$scriptAction;
|
||||
$this->setScriptActionParameters($scriptActionParameters);
|
||||
@ -597,7 +597,7 @@ class Quad extends Control implements Actionable, BackgroundColorable, BgColorab
|
||||
/**
|
||||
* @see Scriptable::setScriptActionParameters()
|
||||
*/
|
||||
public function setScriptActionParameters(array $scriptActionParameters = null)
|
||||
public function setScriptActionParameters(?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptActionParameters = $scriptActionParameters;
|
||||
return $this;
|
||||
|
@ -26,6 +26,11 @@ class TextEdit extends Control implements MultiLineable, Scriptable, Styleable,
|
||||
const FORMAT_Password = "Password";
|
||||
const FORMAT_NewPassword = "NewPassword";
|
||||
|
||||
/**
|
||||
* @var string $name TextEdit name
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* @var string $default Default value
|
||||
*/
|
||||
@ -276,7 +281,7 @@ class TextEdit extends Control implements MultiLineable, Scriptable, Styleable,
|
||||
/**
|
||||
* @see Scriptable::setScriptAction()
|
||||
*/
|
||||
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
|
||||
public function setScriptAction($scriptAction, ?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptAction = (string)$scriptAction;
|
||||
$this->setScriptActionParameters($scriptActionParameters);
|
||||
@ -294,7 +299,7 @@ class TextEdit extends Control implements MultiLineable, Scriptable, Styleable,
|
||||
/**
|
||||
* @see Scriptable::setScriptActionParameters()
|
||||
*/
|
||||
public function setScriptActionParameters(array $scriptActionParameters = null)
|
||||
public function setScriptActionParameters(?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptActionParameters = $scriptActionParameters;
|
||||
return $this;
|
||||
|
@ -191,7 +191,7 @@ class Video extends Control implements Playable, Scriptable
|
||||
/**
|
||||
* @see Scriptable::setScriptAction()
|
||||
*/
|
||||
public function setScriptAction($scriptAction, array $scriptActionParameters = null)
|
||||
public function setScriptAction($scriptAction, ?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptAction = (string)$scriptAction;
|
||||
$this->setScriptActionParameters($scriptActionParameters);
|
||||
@ -209,7 +209,7 @@ class Video extends Control implements Playable, Scriptable
|
||||
/**
|
||||
* @see Scriptable::setScriptActionParameters()
|
||||
*/
|
||||
public function setScriptActionParameters(array $scriptActionParameters = null)
|
||||
public function setScriptActionParameters(?array $scriptActionParameters = null)
|
||||
{
|
||||
$this->scriptActionParameters = $scriptActionParameters;
|
||||
return $this;
|
||||
|
@ -41,7 +41,7 @@ class FrameModel implements Container, Identifiable, Renderable
|
||||
* @param Renderable[] $children Children
|
||||
* @return static
|
||||
*/
|
||||
public static function create($modelId = null, array $children = null)
|
||||
public static function create($modelId = null, ?array $children = null)
|
||||
{
|
||||
return new static($modelId, $children);
|
||||
}
|
||||
@ -53,7 +53,7 @@ class FrameModel implements Container, Identifiable, Renderable
|
||||
* @param string $modelId Model id
|
||||
* @param Renderable[] $children Children
|
||||
*/
|
||||
public function __construct($modelId = null, array $children = null)
|
||||
public function __construct($modelId = null, ?array $children = null)
|
||||
{
|
||||
if ($modelId) {
|
||||
$this->setId($modelId);
|
||||
@ -176,7 +176,7 @@ class FrameModel implements Container, Identifiable, Renderable
|
||||
* @deprecated Use Style
|
||||
* @see Style
|
||||
*/
|
||||
public function setFormat(Format $format = null)
|
||||
public function setFormat(?Format $format = null)
|
||||
{
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
|
@ -96,7 +96,7 @@ class ManiaLink
|
||||
* @param Renderable[] $children (optional) Children
|
||||
* @return static
|
||||
*/
|
||||
public static function create($maniaLinkId = null, $version = null, $name = null, array $children = null)
|
||||
public static function create($maniaLinkId = null, $version = null, $name = null, ?array $children = null)
|
||||
{
|
||||
return new static($maniaLinkId, $version, $name, $children);
|
||||
}
|
||||
@ -110,7 +110,7 @@ class ManiaLink
|
||||
* @param string $name (optional) Name
|
||||
* @param Renderable[] $children (optional) Children
|
||||
*/
|
||||
public function __construct($maniaLinkId = null, $version = null, $name = null, array $children = null)
|
||||
public function __construct($maniaLinkId = null, $version = null, $name = null, ?array $children = null)
|
||||
{
|
||||
if (is_string($version) && (!$name || is_array($name)) && !$children) {
|
||||
// backwards-compatibility (version has been introduced later, if it's a string it's supposed to be the name)
|
||||
@ -418,7 +418,7 @@ class ManiaLink
|
||||
* @param Dico $dico Dictionary
|
||||
* @return static
|
||||
*/
|
||||
public function setDico(Dico $dico = null)
|
||||
public function setDico(?Dico $dico = null)
|
||||
{
|
||||
$this->dico = $dico;
|
||||
return $this;
|
||||
@ -445,7 +445,7 @@ class ManiaLink
|
||||
* @param Stylesheet $stylesheet Stylesheet
|
||||
* @return static
|
||||
*/
|
||||
public function setStylesheet(Stylesheet $stylesheet = null)
|
||||
public function setStylesheet(?Stylesheet $stylesheet = null)
|
||||
{
|
||||
$this->stylesheet = $stylesheet;
|
||||
return $this;
|
||||
@ -489,7 +489,7 @@ class ManiaLink
|
||||
* @param Script $script Script
|
||||
* @return static
|
||||
*/
|
||||
public function setScript(Script $script = null)
|
||||
public function setScript(?Script $script = null)
|
||||
{
|
||||
$this->script = $script;
|
||||
return $this;
|
||||
|
@ -29,7 +29,7 @@ class ManiaLinks
|
||||
* @param ManiaLink[] $children ManiaLink children
|
||||
* @return static
|
||||
*/
|
||||
public static function create(array $children = null)
|
||||
public static function create(?array $children = null)
|
||||
{
|
||||
return new static($children);
|
||||
}
|
||||
@ -40,7 +40,7 @@ class ManiaLinks
|
||||
* @api
|
||||
* @param ManiaLink[] $children ManiaLink children
|
||||
*/
|
||||
public function __construct(array $children = null)
|
||||
public function __construct(?array $children = null)
|
||||
{
|
||||
if ($children) {
|
||||
$this->setChildren($children);
|
||||
@ -162,7 +162,7 @@ class ManiaLinks
|
||||
* @param CustomUI $customUI CustomUI object
|
||||
* @return static
|
||||
*/
|
||||
public function setCustomUI(CustomUI $customUI = null)
|
||||
public function setCustomUI(?CustomUI $customUI = null)
|
||||
{
|
||||
$this->customUI = $customUI;
|
||||
return $this;
|
||||
|
@ -41,7 +41,7 @@ class ActionTrigger extends ScriptFeature
|
||||
* @param Control $control (optional) Action Control
|
||||
* @param string $labelName (optional) Script label name
|
||||
*/
|
||||
public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK)
|
||||
public function __construct($actionName = null, ?Control $control = null, $labelName = ScriptLabel::MOUSECLICK)
|
||||
{
|
||||
if ($actionName) {
|
||||
$this->setActionName($actionName);
|
||||
@ -96,7 +96,7 @@ class ActionTrigger extends ScriptFeature
|
||||
* @param Control $control Action Control
|
||||
* @return static
|
||||
*/
|
||||
public function setControl(Control $control = null)
|
||||
public function setControl(?Control $control = null)
|
||||
{
|
||||
if ($control) {
|
||||
$control->checkId();
|
||||
|
@ -53,6 +53,11 @@ class CheckBoxFeature extends ScriptFeature
|
||||
*/
|
||||
protected $disabledDesign = null;
|
||||
|
||||
/**
|
||||
* @var string $customScript Script executed when clicking on the checkbox
|
||||
*/
|
||||
protected $customScript = "";
|
||||
|
||||
/**
|
||||
* Construct a new CheckBox Feature
|
||||
*
|
||||
@ -61,7 +66,7 @@ class CheckBoxFeature extends ScriptFeature
|
||||
* @param Entry $entry (optional) Hidden Entry
|
||||
* @param bool $default (optional) Default value
|
||||
*/
|
||||
public function __construct(Quad $quad = null, Entry $entry = null, $default = null)
|
||||
public function __construct(?Quad $quad = null, ?Entry $entry = null, $default = null)
|
||||
{
|
||||
if ($quad) {
|
||||
$this->setQuad($quad);
|
||||
@ -199,6 +204,30 @@ class CheckBoxFeature extends ScriptFeature
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get script launched when clicking on the checkbox
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomScript()
|
||||
{
|
||||
return $this->customScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set script launched when clicking on the checkbox
|
||||
*
|
||||
* @api
|
||||
* @param string $customScript script
|
||||
* @return static
|
||||
*/
|
||||
public function setCustomScript(string $customScript)
|
||||
{
|
||||
$this->customScript = $customScript;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ScriptFeature::prepare()
|
||||
*/
|
||||
@ -290,6 +319,7 @@ EntryId = \"{$entryId}\";
|
||||
if (Event.ControlId == \"{$quadId}\") {
|
||||
declare Quad_CheckBox <=> (Event.Control as CMlQuad);
|
||||
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);
|
||||
" . $this->customScript . "
|
||||
}";
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Clock extends ScriptFeature
|
||||
* @param bool $showSeconds (optional) Show the seconds
|
||||
* @param bool $showFullDate (optional) Show the date
|
||||
*/
|
||||
public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false)
|
||||
public function __construct(?Label $label = null, $showSeconds = true, $showFullDate = false)
|
||||
{
|
||||
if ($label) {
|
||||
$this->setLabel($label);
|
||||
|
@ -41,7 +41,7 @@ class ControlScript extends ScriptFeature
|
||||
* @param string $scriptText (optional) Script text
|
||||
* @param string $labelName (optional) Script Label name
|
||||
*/
|
||||
public function __construct(Control $control = null, $scriptText = null, $labelName = ScriptLabel::MOUSECLICK)
|
||||
public function __construct(?Control $control = null, $scriptText = null, $labelName = ScriptLabel::MOUSECLICK)
|
||||
{
|
||||
if ($control) {
|
||||
$this->setControl($control);
|
||||
|
@ -35,7 +35,7 @@ class EntrySubmit extends ScriptFeature
|
||||
* @param Entry $entry (optional) Entry Control
|
||||
* @param string $url (optional) Submit url
|
||||
*/
|
||||
public function __construct(Entry $entry = null, $url = null)
|
||||
public function __construct(?Entry $entry = null, $url = null)
|
||||
{
|
||||
if ($entry) {
|
||||
$this->setEntry($entry);
|
||||
|
@ -54,7 +54,7 @@ class GraphCurve extends ScriptFeature
|
||||
* @param Graph $graph (optional) Graph
|
||||
* @param array[] $points (optional) Points
|
||||
*/
|
||||
public function __construct(Graph $graph = null, array $points = null)
|
||||
public function __construct(?Graph $graph = null, ?array $points = null)
|
||||
{
|
||||
if ($graph) {
|
||||
$this->setGraph($graph);
|
||||
@ -200,7 +200,7 @@ class GraphCurve extends ScriptFeature
|
||||
* @param float[] $color (optional) Color
|
||||
* @return static
|
||||
*/
|
||||
public function setColor(array $color = null)
|
||||
public function setColor(?array $color = null)
|
||||
{
|
||||
$this->color = $color;
|
||||
return $this;
|
||||
|
@ -38,7 +38,7 @@ class GraphSettings extends ScriptFeature
|
||||
* @api
|
||||
* @param Graph $graph (optional) Graph
|
||||
*/
|
||||
public function __construct(Graph $graph = null)
|
||||
public function __construct(?Graph $graph = null)
|
||||
{
|
||||
if ($graph) {
|
||||
$this->setGraph($graph);
|
||||
|
@ -35,7 +35,7 @@ class MapInfo extends ScriptFeature
|
||||
* @param Control $control (optional) Map Info Control
|
||||
* @param string $labelName (optional) Script Label name
|
||||
*/
|
||||
public function __construct(Control $control = null, $labelName = ScriptLabel::MOUSECLICK)
|
||||
public function __construct(?Control $control = null, $labelName = ScriptLabel::MOUSECLICK)
|
||||
{
|
||||
if ($control) {
|
||||
$this->setControl($control);
|
||||
|
@ -40,7 +40,7 @@ class Menu extends ScriptFeature
|
||||
* @param Control $control (optional) Toggled Menu Control
|
||||
* @param bool $isStartElement (optional) Whether the Menu should start with the given Element
|
||||
*/
|
||||
public function __construct(Control $item = null, Control $control = null, $isStartElement = true)
|
||||
public function __construct(?Control $item = null, ?Control $control = null, $isStartElement = true)
|
||||
{
|
||||
if ($item && $control) {
|
||||
$this->addItem($item, $control, $isStartElement);
|
||||
@ -116,7 +116,7 @@ class Menu extends ScriptFeature
|
||||
* @param MenuElement $startElement Start Element
|
||||
* @return static
|
||||
*/
|
||||
public function setStartElement(MenuElement $startElement = null)
|
||||
public function setStartElement(?MenuElement $startElement = null)
|
||||
{
|
||||
$this->startElement = $startElement;
|
||||
if ($startElement && !in_array($startElement, $this->elements, true)) {
|
||||
|
@ -32,7 +32,7 @@ class MenuElement
|
||||
* @param Control $item (optional) Item Control in the Menu bar
|
||||
* @param Control $control (optional) Toggled Menu Control
|
||||
*/
|
||||
public function __construct(Control $item = null, Control $control = null)
|
||||
public function __construct(?Control $item = null, ?Control $control = null)
|
||||
{
|
||||
if ($item) {
|
||||
$this->setItem($item);
|
||||
|
@ -73,7 +73,7 @@ class Paging extends ScriptFeature
|
||||
* @param PagingPage[] $pages (optional) Pages
|
||||
* @param PagingButton[] $buttons (optional) Pageing Buttons
|
||||
*/
|
||||
public function __construct(Label $label = null, array $pages = null, array $buttons = null)
|
||||
public function __construct(?Label $label = null, ?array $pages = null, ?array $buttons = null)
|
||||
{
|
||||
if ($label) {
|
||||
$this->setLabel($label);
|
||||
|
@ -32,7 +32,7 @@ class PagingButton
|
||||
* @param Control $control (optional) Paging Control
|
||||
* @param int $pagingCount (optional) Number of browsed pages per click
|
||||
*/
|
||||
public function __construct(Control $control = null, $pagingCount = 1)
|
||||
public function __construct(?Control $control = null, $pagingCount = 1)
|
||||
{
|
||||
if ($control) {
|
||||
$this->setControl($control);
|
||||
|
@ -31,7 +31,7 @@ class PagingPage
|
||||
* @param Control $control (optional) Page Control
|
||||
* @param int $pageNumber (optional) Number of the Page
|
||||
*/
|
||||
public function __construct(Control $control = null, $pageNumber = null)
|
||||
public function __construct(?Control $control = null, $pageNumber = null)
|
||||
{
|
||||
if ($control) {
|
||||
$this->setControl($control);
|
||||
|
@ -46,7 +46,7 @@ class PlayerProfile extends ScriptFeature
|
||||
* @param Control $control (optional) Profile Control
|
||||
* @param string $labelName (optional) Script Label name
|
||||
*/
|
||||
public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK, $titleId = "Trackmania")
|
||||
public function __construct($login = null, ?Control $control = null, $labelName = ScriptLabel::MOUSECLICK, $titleId = "Trackmania")
|
||||
{
|
||||
if ($login) {
|
||||
$this->setLogin($login);
|
||||
@ -181,8 +181,8 @@ class PlayerProfile extends ScriptFeature
|
||||
$login = Builder::escapeText($this->login);
|
||||
|
||||
if ($this->titleId == "Trackmania") {
|
||||
$apicall = "declare Text LibTMxSMRaceScoresTable_OpenProfileLogin for ClientUI = \"\";
|
||||
LibTMxSMRaceScoresTable_OpenProfileLogin = {$login};";
|
||||
$apicall = "declare Text TMGame_ScoresTable_OpenProfileUserId for ClientUI = \"\";
|
||||
TMGame_ScoresTable_OpenProfileUserId = {$login};";
|
||||
} else {
|
||||
$apicall = "ShowProfile({$login});";
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class Preload extends ScriptFeature
|
||||
* @api
|
||||
* @param string[] $imageUrls (optional) Image urls
|
||||
*/
|
||||
public function __construct(array $imageUrls = null)
|
||||
public function __construct(?array $imageUrls = null)
|
||||
{
|
||||
if ($imageUrls) {
|
||||
$this->setImageUrls($imageUrls);
|
||||
|
@ -40,7 +40,7 @@ class RadioButtonGroupFeature extends ScriptFeature
|
||||
* @api
|
||||
* @param Entry $entry (optional) Hidden Entry
|
||||
*/
|
||||
public function __construct(Entry $entry = null)
|
||||
public function __construct(?Entry $entry = null)
|
||||
{
|
||||
if ($entry) {
|
||||
$this->setEntry($entry);
|
||||
|
@ -54,8 +54,8 @@ class Toggle extends ScriptFeature
|
||||
* @param bool $onlyHide (optional) If it should only hide the Control but not toggle
|
||||
*/
|
||||
public function __construct(
|
||||
Control $togglingControl = null,
|
||||
Control $toggledControl = null,
|
||||
?Control $togglingControl = null,
|
||||
?Control $toggledControl = null,
|
||||
$labelName = ScriptLabel::MOUSECLICK,
|
||||
$onlyShow = false,
|
||||
$onlyHide = false
|
||||
|
@ -54,7 +54,7 @@ class Tooltip extends ScriptFeature
|
||||
* @param bool $invert (optional) If the visibility toggling should be inverted
|
||||
* @param string $text (optional) Text to display if the TooltipControl is a Label
|
||||
*/
|
||||
public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = null, $invert = null, $text = null)
|
||||
public function __construct(?Control $hoverControl = null, ?Control $tooltipControl = null, $stayOnClick = null, $invert = null, $text = null)
|
||||
{
|
||||
if ($hoverControl) {
|
||||
$this->setHoverControl($hoverControl);
|
||||
|
@ -85,7 +85,7 @@ class UISound extends ScriptFeature
|
||||
* @param int $variant (optional) Sound variant
|
||||
* @param string $labelName (optional) Script Label name
|
||||
*/
|
||||
public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK)
|
||||
public function __construct($soundName = null, ?Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK)
|
||||
{
|
||||
if ($soundName) {
|
||||
$this->setSoundName($soundName);
|
||||
@ -143,7 +143,7 @@ class UISound extends ScriptFeature
|
||||
* @param Control $control (optional) Sound Control
|
||||
* @return static
|
||||
*/
|
||||
public function setControl(Control $control = null)
|
||||
public function setControl(?Control $control = null)
|
||||
{
|
||||
if ($control) {
|
||||
$control->checkId();
|
||||
|
@ -56,7 +56,7 @@ class ValuePickerFeature extends ScriptFeature
|
||||
* @param string[] $values (optional) Possible values
|
||||
* @param string $default (optional) Default value
|
||||
*/
|
||||
public function __construct(Label $label = null, Entry $entry = null, array $values = null, $default = null)
|
||||
public function __construct(?Label $label = null, ?Entry $entry = null, ?array $values = null, $default = null)
|
||||
{
|
||||
if ($label) {
|
||||
$this->setLabel($label);
|
||||
|
@ -150,7 +150,7 @@ class Stylesheet
|
||||
* @param Mood $mood Mood
|
||||
* @return static
|
||||
*/
|
||||
public function setMood(Mood $mood = null)
|
||||
public function setMood(?Mood $mood = null)
|
||||
{
|
||||
$this->mood = $mood;
|
||||
return $this;
|
||||
|
@ -90,6 +90,6 @@ interface Container
|
||||
* @deprecated Use Style
|
||||
* @see Style
|
||||
*/
|
||||
public function setFormat(Format $format = null);
|
||||
public function setFormat(?Format $format = null);
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ interface Scriptable
|
||||
* @param string[] $scriptActionParameters (optional) Script action parameters
|
||||
* @return static
|
||||
*/
|
||||
public function setScriptAction($scriptAction, array $scriptActionParameters = null);
|
||||
public function setScriptAction($scriptAction, ?array $scriptActionParameters = null);
|
||||
|
||||
/**
|
||||
* Get script action parameters
|
||||
@ -62,6 +62,6 @@ interface Scriptable
|
||||
* @param string[] $scriptActionParameters (optional) Script action parameters
|
||||
* @return static
|
||||
*/
|
||||
public function setScriptActionParameters(array $scriptActionParameters = null);
|
||||
public function setScriptActionParameters(?array $scriptActionParameters = null);
|
||||
|
||||
}
|
||||
|
2605
libs/Maniaplanet/DedicatedServer/Connection.php
Executable file → Normal file
2605
libs/Maniaplanet/DedicatedServer/Connection.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@ -9,46 +9,52 @@ namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
abstract class AbstractStructure
|
||||
{
|
||||
static public function fromArray($array)
|
||||
public static function fromArrayOfArray($array)
|
||||
{
|
||||
if(!is_array($array))
|
||||
if (!is_array($array)) {
|
||||
return $array;
|
||||
}
|
||||
|
||||
$object = new static;
|
||||
foreach($array as $key => $value)
|
||||
$object->{lcfirst($key)} = $value;
|
||||
return $object;
|
||||
}
|
||||
|
||||
static public function fromArrayOfArray($array)
|
||||
{
|
||||
if(!is_array($array))
|
||||
return $array;
|
||||
|
||||
$result = array();
|
||||
foreach($array as $key => $value)
|
||||
$result = [];
|
||||
foreach ($array as $key => $value) {
|
||||
$result[$key] = static::fromArray($value);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
static public function getPropertyFromArray($array, $property)
|
||||
public static function fromArray($array)
|
||||
{
|
||||
return array_map(get_called_class().'::extractProperty', $array, array_fill(0, count($array), $property));
|
||||
if (!is_array($array)) {
|
||||
return $array;
|
||||
}
|
||||
|
||||
$object = new static;
|
||||
foreach ($array as $key => $value) {
|
||||
$object->{lcfirst($key)} = $value;
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
static protected function extractProperty($element, $property)
|
||||
public static function getPropertyFromArray($array, $property)
|
||||
{
|
||||
if(!is_a($element, get_called_class()) || !property_exists($element, $property))
|
||||
throw new \InvalidArgumentException('property '.$property.' does not exists in class: '.get_called_class());
|
||||
return array_map(get_called_class() . '::extractProperty', $array, array_fill(0, count($array), $property));
|
||||
}
|
||||
|
||||
protected static function extractProperty($element, $property)
|
||||
{
|
||||
if (!is_a($element, get_called_class()) || !property_exists($element, $property)) {
|
||||
throw new \InvalidArgumentException('property ' . $property . ' does not exists in class: ' . get_called_class());
|
||||
}
|
||||
|
||||
return $element->$property;
|
||||
}
|
||||
|
||||
function toArray()
|
||||
{
|
||||
$out = array();
|
||||
foreach(get_object_vars($this) as $key => $value)
|
||||
$out = [];
|
||||
foreach (get_object_vars($this) as $key => $value) {
|
||||
$out[ucfirst($key)] = $value;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,11 @@ namespace Maniaplanet\DedicatedServer\Structures;
|
||||
class Bill extends AbstractStructure
|
||||
{
|
||||
const STATE_CREATING_TRANSACTION = 1;
|
||||
const STATE_ISSUED = 2;
|
||||
const STATE_VALIDATING_PAYMENT = 3;
|
||||
const STATE_PAYED = 4;
|
||||
const STATE_REFUSED = 5;
|
||||
const STATE_ERROR = 6;
|
||||
const STATE_ISSUED = 2;
|
||||
const STATE_VALIDATING_PAYMENT = 3;
|
||||
const STATE_PAYED = 4;
|
||||
const STATE_REFUSED = 5;
|
||||
const STATE_ERROR = 6;
|
||||
|
||||
/** @var int */
|
||||
public $state;
|
||||
|
@ -12,13 +12,13 @@ class GameInfos extends AbstractStructure
|
||||
/**
|
||||
* Game Modes
|
||||
*/
|
||||
const GAMEMODE_SCRIPT = 0;
|
||||
const GAMEMODE_ROUNDS = 1;
|
||||
const GAMEMODE_SCRIPT = 0;
|
||||
const GAMEMODE_ROUNDS = 1;
|
||||
const GAMEMODE_TIMEATTACK = 2;
|
||||
const GAMEMODE_TEAM = 3;
|
||||
const GAMEMODE_LAPS = 4;
|
||||
const GAMEMODE_CUP = 5;
|
||||
const GAMEMODE_STUNTS = 6;
|
||||
const GAMEMODE_TEAM = 3;
|
||||
const GAMEMODE_LAPS = 4;
|
||||
const GAMEMODE_CUP = 5;
|
||||
const GAMEMODE_STUNTS = 6;
|
||||
|
||||
/** @var int */
|
||||
public $gameMode;
|
||||
|
@ -28,7 +28,7 @@ class NetworkStats extends AbstractStructure
|
||||
/** @var PlayerNetInfo[] */
|
||||
public $playerNetInfos;
|
||||
|
||||
static public function fromArray($array)
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->playerNetInfos = PlayerNetInfo::fromArrayOfArray($object->playerNetInfos);
|
||||
|
1
libs/Maniaplanet/DedicatedServer/Structures/Player.php
Executable file → Normal file
1
libs/Maniaplanet/DedicatedServer/Structures/Player.php
Executable file → Normal file
@ -4,6 +4,7 @@
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Player extends AbstractStructure
|
||||
|
@ -46,10 +46,22 @@ class PlayerDetailedInfo extends Player
|
||||
/** @var string */
|
||||
public $broadcasterLogin;
|
||||
/** @var string[] */
|
||||
public $allies = array();
|
||||
public $allies = [];
|
||||
/** @var string */
|
||||
public $clubLink;
|
||||
|
||||
/**
|
||||
* @return PlayerDetailedInfo
|
||||
*/
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->avatar = FileDesc::fromArray($object->avatar);
|
||||
$object->skins = Skin::fromArrayOfArray($object->skins);
|
||||
$object->ladderStats = LadderStats::fromArray($object->ladderStats);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
@ -57,16 +69,4 @@ class PlayerDetailedInfo extends Player
|
||||
{
|
||||
return explode('|', $this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PlayerDetailedInfo
|
||||
*/
|
||||
static public function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->avatar = FileDesc::fromArray($object->avatar);
|
||||
$object->skins = Skin::fromArrayOfArray($object->skins);
|
||||
$object->ladderStats = LadderStats::fromArray($object->ladderStats);
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
32
libs/Maniaplanet/DedicatedServer/Structures/PlayerInfo.php
Executable file → Normal file
32
libs/Maniaplanet/DedicatedServer/Structures/PlayerInfo.php
Executable file → Normal file
@ -20,7 +20,7 @@ class PlayerInfo extends Player
|
||||
/** @var bool */
|
||||
public $isInOfficialMode;
|
||||
/** @var int */
|
||||
public $ladderScore;
|
||||
public $ladderScore; // TODO CHECK IF EXISTS
|
||||
/** @var int */
|
||||
public $ladderRanking;
|
||||
/** @var int */
|
||||
@ -63,26 +63,26 @@ class PlayerInfo extends Player
|
||||
/**
|
||||
* @return PlayerInfo
|
||||
*/
|
||||
static public function fromArray($array)
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
|
||||
//Detail flags
|
||||
$object->forceSpectator = $object->flags % 10; // 0, 1 or 2
|
||||
$object->isReferee = (bool) (intval($object->flags / 10) % 10);
|
||||
$object->isPodiumReady = (bool) (intval($object->flags / 100) % 10);
|
||||
$object->isUsingStereoscopy = (bool) (intval($object->flags / 1000) % 10);
|
||||
$object->isManagedByAnOtherServer = (bool) (intval($object->flags / 10000) % 10);
|
||||
$object->isServer = (bool) (intval($object->flags / 100000) % 10);
|
||||
$object->hasPlayerSlot = (bool) (intval($object->flags / 1000000) % 10);
|
||||
$object->isBroadcasting = (bool) (intval($object->flags / 10000000) % 10);
|
||||
$object->hasJoinedGame = (bool) (intval($object->flags / 100000000) % 10);
|
||||
$object->forceSpectator = $object->flags % 10; // 0, 1 or 2
|
||||
$object->isReferee = (bool)(intval($object->flags / 10) % 10);
|
||||
$object->isPodiumReady = (bool)(intval($object->flags / 100) % 10);
|
||||
$object->isUsingStereoscopy = (bool)(intval($object->flags / 1000) % 10);
|
||||
$object->isManagedByAnOtherServer = (bool)(intval($object->flags / 10000) % 10);
|
||||
$object->isServer = (bool)(intval($object->flags / 100000) % 10);
|
||||
$object->hasPlayerSlot = (bool)(intval($object->flags / 1000000) % 10);
|
||||
$object->isBroadcasting = (bool)(intval($object->flags / 10000000) % 10);
|
||||
$object->hasJoinedGame = (bool)(intval($object->flags / 100000000) % 10);
|
||||
//Details spectatorStatus
|
||||
$object->spectator = (bool) ($object->spectatorStatus % 10);
|
||||
$object->temporarySpectator = (bool) (intval($object->spectatorStatus / 10) % 10);
|
||||
$object->pureSpectator = (bool) (intval($object->spectatorStatus / 100) % 10);
|
||||
$object->autoTarget = (bool) (intval($object->spectatorStatus / 1000) % 10);
|
||||
$object->currentTargetId = intval($object->spectatorStatus / 10000);
|
||||
$object->spectator = (bool)($object->spectatorStatus % 10);
|
||||
$object->temporarySpectator = (bool)(intval($object->spectatorStatus / 10) % 10);
|
||||
$object->pureSpectator = (bool)(intval($object->spectatorStatus / 100) % 10);
|
||||
$object->autoTarget = (bool)(intval($object->spectatorStatus / 1000) % 10);
|
||||
$object->currentTargetId = intval($object->spectatorStatus / 10000);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ class ScriptInfo extends AbstractStructure
|
||||
/** @var string */
|
||||
public $version;
|
||||
/** @var ScriptSettings[] */
|
||||
public $paramDescs = array();
|
||||
public $paramDescs = [];
|
||||
/** @var Command[] */
|
||||
public $commandDescs = array();
|
||||
public $commandDescs = [];
|
||||
|
||||
/**
|
||||
* @return ScriptInfo
|
||||
|
@ -27,7 +27,7 @@ class ServerOptions extends AbstractStructure
|
||||
* @internal
|
||||
* @return bool
|
||||
*/
|
||||
function isValid()
|
||||
public function isValid(): bool
|
||||
{
|
||||
return is_string($this->name)
|
||||
&& is_string($this->comment)
|
||||
@ -41,15 +41,16 @@ class ServerOptions extends AbstractStructure
|
||||
* @internal
|
||||
* @return mixed[]
|
||||
*/
|
||||
function toSetterArray()
|
||||
public function toSetterArray()
|
||||
{
|
||||
$out = array();
|
||||
foreach(get_object_vars($this) as $key => $value)
|
||||
{
|
||||
if(substr($key, 0, 7) == 'current' || $value === null)
|
||||
$out = [];
|
||||
foreach (get_object_vars($this) as $key => $value) {
|
||||
if (str_starts_with($key, 'current') || $value === null) {
|
||||
continue;
|
||||
if($key == 'nextUseChangingValidationSeed')
|
||||
}
|
||||
if ($key === 'nextUseChangingValidationSeed') {
|
||||
$key = 'useChangingValidationSeed';
|
||||
}
|
||||
$out[ucfirst($key)] = $value;
|
||||
}
|
||||
return $out;
|
||||
|
28
libs/Maniaplanet/DedicatedServer/Structures/ServerPlugin.php
Executable file
28
libs/Maniaplanet/DedicatedServer/Structures/ServerPlugin.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ServerPlugin extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string[] */
|
||||
public $settingsValues;
|
||||
/** @var ScriptSettings[] */
|
||||
public $settingsDesc = array();
|
||||
|
||||
/**
|
||||
* @return ScriptInfo
|
||||
*/
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->settingsDesc = ScriptSettings::fromArrayOfArray($object->paramDescs);
|
||||
return $object;
|
||||
}
|
||||
}
|
@ -9,13 +9,13 @@ namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Status extends AbstractStructure
|
||||
{
|
||||
const UNKNOWN = 0;
|
||||
const WAITING = 1;
|
||||
const LAUNCHING = 2;
|
||||
const UNKNOWN = 0;
|
||||
const WAITING = 1;
|
||||
const LAUNCHING = 2;
|
||||
const SYNCHRONIZATION = 3;
|
||||
const PLAY = 4;
|
||||
const EXITING = 6;
|
||||
const LOCAL = 7;
|
||||
const PLAY = 4;
|
||||
const EXITING = 6;
|
||||
const LOCAL = 7;
|
||||
|
||||
/** @var int */
|
||||
public $code;
|
||||
|
@ -27,7 +27,7 @@ class Vote extends AbstractStructure
|
||||
* @param string $cmdName
|
||||
* @param mixed[] $cmdParam
|
||||
*/
|
||||
function __construct($cmdName='', $cmdParam=array())
|
||||
function __construct($cmdName = '', $cmdParam = [])
|
||||
{
|
||||
$this->cmdName = $cmdName;
|
||||
$this->cmdParam = $cmdParam;
|
||||
|
@ -9,15 +9,15 @@ namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class VoteRatio extends AbstractStructure
|
||||
{
|
||||
const COMMAND_DEFAULT = '*';
|
||||
const COMMAND_DEFAULT = '*';
|
||||
const COMMAND_SCRIPT_SETTINGS = 'SetModeScriptSettingsAndCommands';
|
||||
const COMMAND_NEXT_MAP = 'NextMap';
|
||||
const COMMAND_JUMP_MAP = 'JumpToMapIdent';
|
||||
const COMMAND_SET_NEXT_MAP = 'SetNextMapIdent';
|
||||
const COMMAND_RESTART_MAP = 'RestartMap';
|
||||
const COMMAND_TEAM_BALANCE = 'AutoTeamBalance';
|
||||
const COMMAND_KICK = 'Kick';
|
||||
const COMMAND_BAN = 'Ban';
|
||||
const COMMAND_NEXT_MAP = 'NextMap';
|
||||
const COMMAND_JUMP_MAP = 'JumpToMapIdent';
|
||||
const COMMAND_SET_NEXT_MAP = 'SetNextMapIdent';
|
||||
const COMMAND_RESTART_MAP = 'RestartMap';
|
||||
const COMMAND_TEAM_BALANCE = 'AutoTeamBalance';
|
||||
const COMMAND_KICK = 'Kick';
|
||||
const COMMAND_BAN = 'Ban';
|
||||
|
||||
/** @var string '*' for default */
|
||||
public $command;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user