Skip to content
Permalink
Browse files

0.69.4 Add new matchsettings-manager

- Update default colors
- Add confirm dialog component
- Update dependencies
  • Loading branch information...
brakerb committed Jun 14, 2019
1 parent 6bd8a81 commit dc103be306348287054d8ac0bd4d8f4579b27b4c
@@ -8,6 +8,6 @@
"illuminate/pagination" : "^5.6",
"symfony/process" : "^4.2",
"symfony/event-dispatcher" : "^4.2",
"composer/ca-bundle": "^1.1"
"composer/ca-bundle" : "^1.1"
}
}

Large diffs are not rendered by default.

@@ -19,7 +19,7 @@
},
"btn" : {
"primary": "38c",
"default": "555",
"default": "999",
"warning": "e90",
"danger" : "e33"
},
@@ -34,7 +34,7 @@ public static function startSetup(InputInterface $input, OutputInterface $output
self::$output = $output;
self::$helper = $helper;
self::$output->writeln('<fg=cyan>Starting EvoSC Setup.</>');
self::printInfo('<fg=cyan>Starting EvoSC Setup.</>');
self::doServerConfig();
self::doDatabaseConfig();
@@ -91,6 +91,7 @@ private static function doServerConfig()
];
self::askBatch('server', $questions);
self::printInfo('Configuration of server.config.json finished.');
}
private static function doDatabaseConfig()
@@ -119,6 +120,7 @@ private static function doDatabaseConfig()
];
self::askBatch('database', $questions);
self::printInfo('Configuration of database.config.json finished.');
}
private static function doDedimaniaConfig()
@@ -143,6 +145,7 @@ private static function doDedimaniaConfig()
];
self::askBatch('dedimania', $questions);
self::printInfo('Configuration of dedimania.config.json finished.');
ConfigController::saveConfig('dedimania.enabled', true);
}
@@ -166,6 +169,7 @@ private static function doMxKarmaConfig()
self::askBatch('mx-karma', $questions);
ConfigController::saveConfig('mx-karma.enabled', true);
self::printInfo('Configuration of mx-karma.config.json finished.');
}
private static function doMusicConfig()
@@ -185,6 +189,7 @@ private static function doMusicConfig()
];
self::askBatch('music', $questions);
self::printInfo('Configuration of music.config.json finished.');
ConfigController::saveConfig('music.enabled', true);
}
@@ -194,6 +199,11 @@ private static function printError(string $text)
self::$output->writeln("<error>$text</error>");
}
private static function printInfo(string $text)
{
self::$output->writeln("<fg=cyan>$text</>");
}
private static function askEnter(string $questionString, string $default = '', bool $optional = false)
{
$question = new Question('<fg=green>' . $questionString . (empty($default) ? ": " : "[$default]: ") . '</>', $default);
@@ -21,6 +21,6 @@ public function __construct()
public static function testStuff(Player $player = null)
{
TemplateController::loadTemplates();
GearInfo::show($player);
MatchSettingsManagerNew::showOverview($player);
}
}
@@ -27,7 +27,7 @@ public function __construct()
ManiaLinkEvent::add('bound_key_pressed', [self::class, 'keyPressed']);
ManiaLinkEvent::add('update_keybinds', [self::class, 'sendScript']);
QuickButtons::addButton('', 'Keyboard Setup', 'show_key_bind_settings');
QuickButtons::addButton('', 'Keyboard Setup', 'show_key_bind_settings');
}
public static function showSettings(Player $player)
@@ -0,0 +1,100 @@
<?php
namespace esc\Classes;
use esc\Classes\ChatCommand;
use esc\Models\Map;
use esc\Models\Player;
class MatchSettings
{
public $xml;
public $filename;
public $id;
private static $actions = [
'mss' => [self::class, 'updateModeScriptSettings'],
'map' => [self::class, 'updateMap'],
'gameinfo' => [self::class, 'updateGameInfo'],
'filter' => [self::class, 'updateFilter']
];
public function __construct(\SimpleXMLElement $xml, $id, $filename)
{
$this->xml = $xml;
$this->id = $id;
$this->filename = $filename;
}
public function __toString()
{
return sprintf('[%s,%s]', $this->filename, $this->id);
}
public function handle(Player $player, string ...$cmd)
{
$command = array_shift($cmd);
array_unshift($cmd, $player);
if (array_key_exists($command, self::$actions)) {
call_user_func_array(self::$actions[$command], $cmd);
} else {
Log::logAddLine('MatchSettings', sprintf('Unknown update-action: %s [%s]', $command, implode(', ', $cmd)), true);
}
}
public function updateGameInfo(Player $player, string $key, string $value)
{
$this->xml->gameinfos->{$key} = $value;
$this->save();
}
public function updateFilter(Player $player, string $key, string $value)
{
$this->xml->filter->{$key} = $value;
$this->save();
}
public function updateModeScriptSettings(Player $player, string $name, string $type, string $value)
{
foreach ($this->xml->mode_script_settings->setting as $element) {
if ($element['name'] == $name) {
$element['value'] = $value;
}
}
$this->save();
}
public function updateMap(Player $player, string $mapId, string $enabledString)
{
$map = Map::whereId($mapId)->first();
if ($enabledString == '1') {
$mapBranch = $this->xml->addChild('map');
$mapBranch->addChild('file', $map->filename);
$mapBranch->addChild('ident', $map->gbx->MapUid);
infoMessage('Added map ', $map, ' to ', secondary($this->filename))->send($player);
} else {
foreach ($this->xml->map as $mapNode) {
if ($mapNode->ident == $map->gbx->MapUid) {
unset($mapNode[0]);
infoMessage('Removed map ', $map, ' from ', secondary($this->filename))->send($player);
}
}
}
//Set random start index
$this->xml->startindex = rand(1, count($this->xml->map));
$this->save();
}
public function save()
{
$file = Server::getMapsDirectory() . '/MatchSettings/' . $this->filename;
$this->xml->saveXML($file);
}
}
@@ -0,0 +1,120 @@
<?php
namespace esc\Modules;
use esc\Classes\File;
use esc\Classes\Log;
use esc\Classes\ManiaLinkEvent;
use esc\Classes\MatchSettings;
use esc\Classes\Server;
use esc\Classes\Template;
use esc\Classes\ChatCommand;
use esc\Controllers\TemplateController;
use esc\Models\AccessRight;
use esc\Models\Map;
use esc\Models\Player;
use Illuminate\Support\Collection;
class MatchSettingsManagerNew
{
private static $path;
private static $objects;
private static $modes = [
'TimeAttack' => 'timeattack.xml',
'Team' => 'team.xml',
'Rounds' => 'rounds.xml',
'Laps' => 'laps.xml',
'Cup' => 'cup.xml',
'Chase' => 'chase.xml',
];
public function __construct()
{
self::$path = Server::getMapsDirectory() . '/MatchSettings/';
self::$objects = collect();
AccessRight::createIfNonExistent('ms_edit', 'Change match-settings.');
ChatCommand::add('//msm', [self::class, 'showMatchSettingsOverview'], 'Show MatchSettingsManager', 'ms_edit');
ManiaLinkEvent::add('msmn.overview', [self::class, 'showOverview'], 'ms_edit');
ManiaLinkEvent::add('msmn.create', [self::class, 'showCreateMatchsettings'], 'ms_edit');
ManiaLinkEvent::add('msmn.edit', [self::class, 'showEditMatchsettings'], 'ms_edit');
ManiaLinkEvent::add('msmn.duplicate', [self::class, 'duplicateMatchsettings'], 'ms_edit');
ManiaLinkEvent::add('msmn.delete', [self::class, 'deleteMatchsettings'], 'ms_edit');
ManiaLinkEvent::add('msmn.new', [self::class, 'createNewMatchsettings'], 'ms_edit');
if (config('quick-buttons.enabled')) {
QuickButtons::addButton('', 'MatchSetting Manager', 'msm.overview', 'map.edit');
}
}
public static function showOverview(Player $player)
{
$matchsettings = self::getMatchsettings();
Template::show($player, 'matchsettings-manager-new.overview', compact('matchsettings'));
}
public static function showCreateMatchsettings(Player $player)
{
$modes = collect(self::$modes)->keys();
Template::show($player, 'matchsettings-manager-new.create', compact('modes'));
}
public static function showEditMatchsettings(Player $player, string $name)
{
$file = Server::getMapsDirectory() . '/MatchSettings/' . $name . '.txt';
$data = File::get($file);
Template::show($player, 'matchsettings-manager-new.edit', compact('data', 'name'));
}
public static function createNewMatchsettings(Player $player, string $modeName)
{
$modeFile = self::$modes[$modeName];
$modeBaseName = str_replace('.xml', '', $modeFile);
$sourceMatchsettings = __DIR__ . '/MatchSettingsRepo/' . $modeFile;
$matchsettingsDirectory = Server::getMapsDirectory() . '/MatchSettings/';
$i = 0;
do {
$filename = sprintf('%s_%d.txt', $modeBaseName, $i);
$i++;
} while (File::exists($matchsettingsDirectory . $filename));
File::copy($sourceMatchsettings, $matchsettingsDirectory . $filename);
self::showOverview($player);
}
public static function duplicateMatchsettings(Player $player, string $matchsettingsFile)
{
$file = $matchsettingsFile . '.txt';
$targetFile = $matchsettingsFile . '_copy.txt';
$matchsettingsDirectory = Server::getMapsDirectory() . '/MatchSettings/';
File::copy($matchsettingsDirectory . $file, $matchsettingsDirectory . $targetFile);
self::showOverview($player);
}
public static function deleteMatchsettings(Player $player, string $matchsettingsFile)
{
File::delete(Server::getMapsDirectory() . '/MatchSettings/' . $matchsettingsFile . '.txt');
self::showOverview($player);
}
public static function getMatchsettings()
{
$files = File::getDirectoryContents(self::$path, '/\.txt$/')->map(function (String $file) {
return preg_replace('/\.txt$/', '', $file);
});
return $files;
}
}
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<playlist>
<gameinfos>
<game_mode>0</game_mode>
<chat_time>10000</chat_time>
<finishtimeout>1</finishtimeout>
<allwarmupduration>0</allwarmupduration>
<disablerespawn>0</disablerespawn>
<forceshowallopponents>0</forceshowallopponents>
<script_name><![CDATA[Chase.Script.txt]]></script_name>
</gameinfos>
<filter>
<is_lan>1</is_lan>
<is_internet>1</is_internet>
<is_solo>0</is_solo>
<is_hotseat>0</is_hotseat>
<sort_index>1000</sort_index>
<random_map_order>0</random_map_order>
</filter>
<script_settings>
<setting name="S_ChatTime" type="integer" value="10"/>
<setting name="S_UseClublinks" type="boolean" value="0"/>
<setting name="S_UseClublinksSponsors" type="boolean" value="0"/>
<setting name="S_NeutralEmblemUrl" type="text" value=""/>
<setting name="S_ScriptEnvironment" type="text" value="production"/>
<setting name="S_MatchmakingAPIUrl" type="text" value="https://v4.live.maniaplanet.com/ingame/public/matchmaking"/>
<setting name="S_MatchmakingMatchServers" type="text" value=""/>
<setting name="S_MatchmakingMode" type="integer" value="0"/>
<setting name="S_MatchmakingRematchRatio" type="real" value="-1"/>
<setting name="S_MatchmakingRematchNbMax" type="integer" value="2"/>
<setting name="S_MatchmakingVoteForMap" type="boolean" value="0"/>
<setting name="S_MatchmakingProgressive" type="boolean" value="0"/>
<setting name="S_MatchmakingWaitingTime" type="integer" value="20"/>
<setting name="S_LobbyRoundPerMap" type="integer" value="6"/>
<setting name="S_LobbyMatchmakerPerRound" type="integer" value="30"/>
<setting name="S_LobbyMatchmakerWait" type="integer" value="2"/>
<setting name="S_LobbyMatchmakerTime" type="integer" value="8"/>
<setting name="S_LobbyDisplayMasters" type="boolean" value="1"/>
<setting name="S_LobbyDisableUI" type="boolean" value="0"/>
<setting name="S_KickTimedOutPlayers" type="boolean" value="1"/>
<setting name="S_MatchmakingErrorMessage" type="text" value="’An error occured in the matchmaking API. If the problem persist please try to contact this server administrator."/>
<setting name="S_MatchmakingLogAPIError" type="boolean" value="0"/>
<setting name="S_MatchmakingLogAPIDebug" type="boolean" value="0"/>
<setting name="S_MatchmakingLogMiscDebug" type="boolean" value="0"/>
<setting name="S_ProgressiveActivation_WaitingTime" type="integer" value="180000"/>
<setting name="S_ProgressiveActivation_PlayersNbRatio" type="integer" value="1"/>
<setting name="S_AllowRespawn" type="boolean" value="1"/>
<setting name="S_UseLegacyXmlRpcCallbacks" type="boolean" value="1"/>
<setting name="S_TimeLimit" type="integer" value="900"/>
<setting name="S_MapPointsLimit" type="integer" value="3"/>
<setting name="S_RoundPointsLimit" type="integer" value="-5"/>
<setting name="S_RoundPointsGap" type="integer" value="3"/>
<setting name="S_GiveUpMax" type="integer" value="1"/>
<setting name="S_MinPlayersNb" type="integer" value="3"/>
<setting name="S_ForceLapsNb" type="integer" value="10"/>
<setting name="S_FinishTimeout" type="integer" value="-1"/>
<setting name="S_DisplayWarning" type="boolean" value="1"/>
<setting name="S_CompetitiveMode" type="boolean" value="0"/>
<setting name="S_PauseBetweenRound" type="integer" value="15"/>
<setting name="S_WaitingTimeMax" type="integer" value="600"/>
<setting name="S_WaypointEventDelay" type="integer" value="500"/>
<setting name="S_WarmUpNb" type="integer" value="0"/>
<setting name="S_WarmUpDuration" type="integer" value="0"/>
<setting name="S_NbPlayersPerTeamMax" type="integer" value="3"/>
<setting name="S_NbPlayersPerTeamMin" type="integer" value="3"/>
</script_settings>
<startindex>0</startindex>
</playlist>

0 comments on commit dc103be

Please sign in to comment.
You can’t perform that action at this time.