script settings fixed for fml update

This commit is contained in:
Steffen Schröder 2013-12-31 13:51:30 +01:00
parent 5a5c422703
commit c69a00aa43
2 changed files with 76 additions and 70 deletions

View File

@ -28,7 +28,6 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
*/ */
const ACTION_PREFIX_SETTING = 'ScriptSetting.'; const ACTION_PREFIX_SETTING = 'ScriptSetting.';
const ACTION_SETTING_BOOL = 'ScriptSetting.ActionBoolSetting'; const ACTION_SETTING_BOOL = 'ScriptSetting.ActionBoolSetting';
const CB_SCRIPTSETTINGS_CHANGED = 'ScriptSettings.SettingsChanged'; const CB_SCRIPTSETTINGS_CHANGED = 'ScriptSettings.SettingsChanged';
/** /**
@ -44,7 +43,9 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
public function __construct(ManiaControl $maniaControl) { public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); // Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswer');
} }
/** /**
@ -105,6 +106,8 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
$pageCountLabel->setStyle('TextTitle1'); $pageCountLabel->setStyle('TextTitle1');
$pageCountLabel->setTextSize(2); $pageCountLabel->setTextSize(2);
$script->addPageLabel($pageCountLabel);
// Setting pages // Setting pages
$pageFrames = array(); $pageFrames = array();
$y = 0.; $y = 0.;
@ -116,11 +119,14 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
if (!isset($pageFrame)) { if (!isset($pageFrame)) {
$pageFrame = new Frame(); $pageFrame = new Frame();
$frame->add($pageFrame); $frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame); array_push($pageFrames, $pageFrame);
$y = $height * 0.41; $y = $height * 0.41;
$script->addPage($pageFrame, count($pageFrames));
} }
$settingFrame = new Frame(); $settingFrame = new Frame();
$pageFrame->add($settingFrame); $pageFrame->add($settingFrame);
$settingFrame->setY($y); $settingFrame->setY($y);
@ -134,13 +140,13 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
$nameLabel->setTextSize($labelTextSize); $nameLabel->setTextSize($labelTextSize);
$nameLabel->setText($settingName); $nameLabel->setText($settingName);
$settingValue = $scriptSettings[$settingName]; $settingValue = $scriptSettings[$settingName];
$substyle = ''; $substyle = '';
if ($settingValue === false) { if ($settingValue === false) {
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlRed; $substyle = Quad_Icons64x64_1::SUBSTYLE_LvlRed;
}else if($settingValue === true){ }
else if ($settingValue === true) {
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen; $substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
} }
@ -153,7 +159,8 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
$quad->setSize(4, 4); $quad->setSize(4, 4);
$quad->setHAlign(Control::CENTER); $quad->setHAlign(Control::CENTER);
$quad->setAction(self::ACTION_SETTING_BOOL . "." . $settingName); $quad->setAction(self::ACTION_SETTING_BOOL . "." . $settingName);
}else{ }
else {
$entry = new Entry(); $entry = new Entry();
$settingFrame->add($entry); $settingFrame->add($entry);
$entry->setStyle(Label_Text::STYLE_TextValueSmall); $entry->setStyle(Label_Text::STYLE_TextValueSmall);
@ -165,7 +172,6 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
$entry->setDefault($settingValue); $entry->setDefault($settingValue);
} }
$descriptionLabel = new Label(); $descriptionLabel = new Label();
$pageFrame->add($descriptionLabel); $pageFrame->add($descriptionLabel);
$descriptionLabel->setHAlign(Control::LEFT); $descriptionLabel->setHAlign(Control::LEFT);
@ -184,8 +190,6 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
} }
} }
//$pages->add(array(-1 => $pagerPrev, 1 => $pagerNext), $pageFrames, $pageCountLabel);
return $frame; return $frame;
} }
@ -230,13 +234,13 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
return; return;
} }
$chatMessage = substr($chatMessage, 0, strlen($chatMessage) - 2); $chatMessage = substr($chatMessage, 0, strlen($chatMessage) - 2);
$chatMessage = str_replace("S_", "", $chatMessage); $chatMessage = str_replace("S_", "", $chatMessage);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($player->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($player->authLevel);
$this->maniaControl->chat->sendInformation('$ff0' . $title . ' $<' . $player->nickname . '$> set Scriptsettings $<' . $chatMessage . '$>!'); $this->maniaControl->chat->sendInformation(
'$ff0' . $title . ' $<' . $player->nickname . '$> set Scriptsettings $<' . $chatMessage . '$>!');
// log console message // log console message
$this->maniaControl->log(Formatter::stripCodes($title . ' ' . $player->nickname . ' set Scriptsettings ' . $chatMessage . '!')); $this->maniaControl->log(Formatter::stripCodes($title . ' ' . $player->nickname . ' set Scriptsettings ' . $chatMessage . '!'));
@ -247,14 +251,14 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
/** /**
* Called on ManialinkPageAnswer * Called on ManialinkPageAnswer
*
* @param array $callback * @param array $callback
*/ */
public function handleManialinkPageAnswer(array $callback) { public function handleManialinkPageAnswer(array $callback) {
$actionId = $callback[1][2]; $actionId = $callback[1][2];
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0); $boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
if(!$boolSetting) if (!$boolSetting) return;
return;
$actionArray = explode(".", $actionId); $actionArray = explode(".", $actionId);
@ -264,6 +268,7 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
/** /**
* Toogle a boolean value setting * Toogle a boolean value setting
*
* @param Player $player * @param Player $player
* @param $setting * @param $setting
*/ */
@ -290,7 +295,8 @@ class ScriptSettings implements ConfiguratorMenu,CallbackListener {
$chatMessage = str_replace("S_", "", $chatMessage); $chatMessage = str_replace("S_", "", $chatMessage);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($player->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($player->authLevel);
$this->maniaControl->chat->sendInformation('$ff0' . $title . ' $<' . $player->nickname . '$> set Scriptsetting $<' . $chatMessage . '$>!'); $this->maniaControl->chat->sendInformation(
'$ff0' . $title . ' $<' . $player->nickname . '$> set Scriptsetting $<' . $chatMessage . '$>!');
// log console message // log console message
$this->maniaControl->log(Formatter::stripCodes($title . ' ' . $player->nickname . ' set Scriptsetting ' . $chatMessage . '!')); $this->maniaControl->log(Formatter::stripCodes($title . ' ' . $player->nickname . ' set Scriptsetting ' . $chatMessage . '!'));

View File

@ -391,7 +391,7 @@ if (Event.Control.HasClass(\"" . self::CLASS_PAGER . "\")) {
foreach (PageControl in Page.GetClassChildren_Result) { foreach (PageControl in Page.GetClassChildren_Result) {
if (!PageControl.HasClass(PagesId)) continue; if (!PageControl.HasClass(PagesId)) continue;
declare PageLabel <=> (PageControl as CMlLabel); declare PageLabel <=> (PageControl as CMlLabel);
PageLabel.Value = (FML_PageNumber[PagesId]+1)^\"/\"^(FML_MaxPageNumber[PagesId]+1); PageLabel.Value = FML_PageNumber[PagesId]^\"/\"^FML_MaxPageNumber[PagesId];
} }
}"; }";
$pagesLabels = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $pagesScript); $pagesLabels = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $pagesScript);