Display Current- and Next-GameInfos in Configurator

This commit is contained in:
Alexander Nell 2020-04-30 12:04:48 +02:00
parent 4532f2f5e7
commit 2e6dd5efd5

View File

@ -133,11 +133,24 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
return $this->maniaControl->getClient()->getModeScriptSettings(); return $this->maniaControl->getClient()->getModeScriptSettings();
} else { } else {
$gameModeSettings = get_object_vars($this->maniaControl->getClient()->getCurrentGameInfo()); $gameModeSettings = $this->maniaControl->getClient()->getGameInfos();
foreach ($gameModeSettings as $name => $value) {
unset($gameModeSettings[$name]); $currentGameModeSettings = get_object_vars($gameModeSettings['CurrentGameInfos']);
$gameModeSettings[ucfirst($name)] = $value; unset($gameModeSettings['CurrentGameInfos']);
foreach ($currentGameModeSettings as $name => $value) {
unset($currentGameModeSettings[$name]);
$currentGameModeSettings[ucfirst($name)] = $value;
} }
$gameModeSettings[0] = $currentGameModeSettings;
$nextGameModeSettings = get_object_vars($gameModeSettings['NextGameInfos']);
unset($gameModeSettings['NextGameInfos']);
foreach ($nextGameModeSettings as $name => $value) {
unset($nextGameModeSettings[$name]);
$nextGameModeSettings[ucfirst($name)] = $value;
}
$gameModeSettings[1] = $nextGameModeSettings;
return $gameModeSettings; return $gameModeSettings;
} }
} }
@ -176,6 +189,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$gameModeSettings = null; $gameModeSettings = null;
try { try {
$gameModeSettings = $this->getGameModeSettingsArray(); $gameModeSettings = $this->getGameModeSettingsArray();
if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
$gameModeSettings = $gameModeSettings[0];
}
} catch (\Exception $e) { } catch (\Exception $e) {
return false; return false;
} }
@ -239,7 +255,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo(); $scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo();
$scriptParams = $scriptInfo->paramDescs; $scriptParams = $scriptInfo->paramDescs;
} else { } else {
$scriptParams = $gameModeSettings; $scriptParams = $gameModeSettings[0];
} }
} catch (\Exception $e) { } catch (\Exception $e) {
$label = new Label(); $label = new Label();
@ -278,6 +294,18 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$paging->setLabel($pageCountLabel); $paging->setLabel($pageCountLabel);
if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
$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->setText('Changes only apply with map skip/restart');
$descriptionLabel->setTextColor('ff0');
$descriptionLabel->setTextSize($labelTextSize);
$descriptionLabel->setTranslate(true);
}
// Setting pages // Setting pages
$pageFrame = null; $pageFrame = null;
$posY = 0.; $posY = 0.;
@ -285,20 +313,28 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
foreach ($scriptParams as $key => $scriptParam) { foreach ($scriptParams as $key => $scriptParam) {
$settingName = null; $settingName = null;
$settingValue = null;
if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
$settingName = $scriptParam->name; $settingName = $scriptParam->name;
if (!isset($gameModeSettings[$settingName])) {
continue;
}
$settingValue = $gameModeSettings[$settingName];
} else { } else {
$settingName = $key; $settingName = $key;
} if (!isset($gameModeSettings[0][$settingName]) && !isset($gameModeSettings[1][$settingName])) {
continue;
if (!isset($gameModeSettings[$settingName])) { }
continue; $settingValue = array(
0 => $gameModeSettings[0][$settingName],
1 => $gameModeSettings[1][$settingName]
);
} }
if ($index % 13 === 0) { if ($index % 13 === 0) {
$pageFrame = new Frame(); $pageFrame = new Frame();
$frame->addChild($pageFrame); $frame->addChild($pageFrame);
$posY = $height * 0.41; $posY = 0.41 * $height;
$paging->addPageControl($pageFrame); $paging->addPageControl($pageFrame);
} }
@ -309,19 +345,44 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$nameLabel = new Label_Text(); $nameLabel = new Label_Text();
$settingFrame->addChild($nameLabel); $settingFrame->addChild($nameLabel);
$nameLabel->setHorizontalAlign($nameLabel::LEFT); $nameLabel->setHorizontalAlign($nameLabel::LEFT);
$nameLabel->setSize($width * 0.4, $settingHeight); $nameLabel->setSize(0.4 * $width, $settingHeight);
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall); $nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
$nameLabel->setText($settingName); $nameLabel->setText($settingName);
$nameLabel->setTextSize($labelTextSize); $nameLabel->setTextSize($labelTextSize);
$nameLabel->setX($width * -0.46); $nameLabel->setX(-0.46 * $width);
$settingValue = $gameModeSettings[$settingName]; if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
if (is_bool($settingValue[0])) {
$activeQuad = new Quad_Icons64x64_1();
$settingFrame->addChild($activeQuad);
$activeQuad->setSize(0.9 * $settingHeight, 0.9 * $settingHeight);
if ($settingValue[0]) {
$activeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_LvlGreen);
} else {
$activeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_LvlRed);
}
$activeQuad->setX(0.1 * $width);
} else {
$currentLabel = new Label_Text();
$settingFrame->addChild($currentLabel);
$currentLabel->setHorizontalAlign(Label_Text::RIGHT);
$currentLabel->setSize(0.2 * $width, 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);
}
$settingValue = $settingValue[1];
}
if (is_bool($settingValue)) { if (is_bool($settingValue)) {
// Boolean checkbox // Boolean checkbox
$quad = new Quad(); $quad = new Quad();
$quad->setSize(4, 4); $quad->setSize(4, 4);
$quad->setX($width / 2 * 0.545); $quad->setX(0.27 * $width);
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $settingName, $settingValue, $quad); $checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $settingName, $settingValue, $quad);
$settingFrame->addChild($checkBox); $settingFrame->addChild($checkBox);
} else { } else {
@ -330,18 +391,18 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$settingFrame->addChild($entry); $settingFrame->addChild($entry);
$entry->setDefault($settingValue); $entry->setDefault($settingValue);
$entry->setName(self::ACTION_PREFIX_SETTING . $settingName); $entry->setName(self::ACTION_PREFIX_SETTING . $settingName);
$entry->setSize($width * 0.3, $settingHeight * 0.9); $entry->setSize(0.3 * $width, 0.9 * $settingHeight);
$entry->setStyle(Label_Text::STYLE_TextValueSmall); $entry->setStyle(Label_Text::STYLE_TextValueSmall);
$entry->setTextSize(1); $entry->setTextSize(1);
$entry->setX($width / 2 * 0.55); $entry->setX(0.275 * $width);
} }
if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
$descriptionLabel = new Label(); $descriptionLabel = new Label();
$pageFrame->addChild($descriptionLabel); $pageFrame->addChild($descriptionLabel);
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
$descriptionLabel->setPosition($width * -0.45, $height * -0.44); $descriptionLabel->setPosition(-0.45 * $width, -0.44 * $height);
$descriptionLabel->setSize($width * 0.7, $settingHeight); $descriptionLabel->setSize(0.7 * $width, $settingHeight);
$descriptionLabel->setTextSize($labelTextSize); $descriptionLabel->setTextSize($labelTextSize);
$descriptionLabel->setTranslate(true); $descriptionLabel->setTranslate(true);
$nameLabel->addTooltipLabelFeature($descriptionLabel, $scriptParam->desc); $nameLabel->addTooltipLabelFeature($descriptionLabel, $scriptParam->desc);
@ -369,6 +430,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$gameModeSettings = null; $gameModeSettings = null;
try { try {
$gameModeSettings = $this->getGameModeSettingsArray(); $gameModeSettings = $this->getGameModeSettingsArray();
if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
$gameModeSettings = $gameModeSettings[0];
}
} catch (\Exception $e) { } catch (\Exception $e) {
return; return;
} }
@ -518,6 +582,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$gameModeSettings = null; $gameModeSettings = null;
try { try {
$gameModeSettings = $this->getGameModeSettingsArray(); $gameModeSettings = $this->getGameModeSettingsArray();
if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
$gameModeSettings = $gameModeSettings[0];
}
} catch (\Exception $e) { } catch (\Exception $e) {
return new CommunicationAnswer($e->getMessage(), true); return new CommunicationAnswer($e->getMessage(), true);
} }