/** * Get the script text * * @return string */ protected function getScriptText() { $url = $this->buildCompatibleUrl(); $entryName = $this->entry->getName(); $link = Builder::escapeText($entryName . $url . "="); return "\ndeclare Value = TextLib::URLEncode(Entry.Value);\nOpenLink({$link}^Value, CMlScript::LinkType::Goto);\n"; }
/** * Get the script text * * @return string */ protected function getScriptText() { if ($this->control) { // Control event $controlId = Builder::escapeText($this->control->getId()); return "\nif (Event.Control.ControlId == {$controlId}) {\n\tPlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});\n}"; } // Other events return "\nPlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});"; }
/** * Get the script text * * @return string */ protected function getScriptText() { $actionName = Builder::escapeText($this->actionName); $key = null; $value = null; if ($this->keyName !== null) { $key = "KeyName"; $value = $this->keyName; } else { if ($this->keyCode !== null) { $key = "KeyCode"; $value = $this->keyCode; } else { if ($this->charPressed !== null) { $key = "CharPressed"; $value = $this->charPressed; } } } $value = Builder::escapeText($value); return "\nif (Event.{$key} == {$value}) {\n\tTriggerPageAction({$actionName});\n}"; }
/** * Get the script text * * @return string */ protected function getScriptText() { $login = Builder::escapeText($this->login); if ($this->control) { // Control event $controlId = Builder::escapeText($this->control->getId()); return "\nif (Event.Control.ControlId == {$controlId}) {\n\tShowProfile({$login});\n}"; } // Other events return "\nShowProfile({$login});"; }
/** * Get the script text * * @return string */ protected function getScriptText() { $actionName = Builder::escapeText($this->actionName); if ($this->control) { // Control event $controlId = Builder::escapeText($this->control->getId()); $scriptText = "\nif (Event.Control.ControlId == {$controlId}) {\n\tTriggerPageAction({$actionName});\n}"; } else { // Other $scriptText = "\nTriggerPageAction({$actionName});"; } return $scriptText; }
public function testEscapeText() { $this->assertEquals("\"some text\"", Builder::escapeText("some text")); $this->assertEquals("some text", Builder::escapeText("some text", false)); $this->assertEquals("\"other\\\"text\"", Builder::escapeText("other\"text")); }
/** * Build the script text for the Control * * @return string */ protected function buildScriptText() { $controlId = Builder::escapeText($this->control->getId()); $scriptText = ''; $closeBlock = false; if (ScriptLabel::isEventLabel($this->labelName)) { $scriptText .= "\nif (Event.ControlId == {$controlId}) {\ndeclare Control <=> Event.Control;"; $closeBlock = true; } else { $scriptText .= "\ndeclare Control <=> Page.GetFirstChild({$controlId});"; } $class = $this->control->getManiaScriptClass(); $name = preg_replace('/^CMl/', '', $class, 1); $scriptText .= "\ndeclare {$name} <=> (Control as {$class});\n"; $scriptText .= $this->scriptText . "\n"; if ($closeBlock) { $scriptText .= "}"; } return $scriptText; }
/** * Get the script text * * @return string */ protected function getScriptText() { if ($this->control) { // Control event $controlId = Builder::escapeText($this->control->getId()); return "\nif (Event.Control.ControlId == {$controlId}) {\n\tShowCurChallengeCard();\n}"; } // Other events return "\nShowCurChallengeCard();"; }
/** * Get the script text * * @return string */ protected function getScriptText() { $controlId = Builder::escapeText($this->label->getId()); $scriptText = "\ndeclare ClockLabel <=> (Page.GetFirstChild({$controlId}) as CMlLabel);\ndeclare TimeText = CurrentLocalDateText;"; if (!$this->showSeconds) { $scriptText .= "\nTimeText = TextLib::SubText(TimeText, 0, 16);"; } if (!$this->showFullDate) { $scriptText .= "\nTimeText = TextLib::SubText(TimeText, 11, 9);"; } $scriptText .= "\nClockLabel.Value = TimeText;"; return $scriptText; }
/** * @see ScriptFeature::prepare() */ public function prepare(Script $script) { if (empty($this->pages)) { return $this; } $script->setScriptInclude(ScriptInclude::TEXTLIB); $currentPageVariable = self::VAR_CURRENT_PAGE; $updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE; $minPageNumber = 1; $startPageNumber = is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber; $maxPage = $this->getMaxPage(); $maxPageNumber = $this->customMaxPageNumber; if (!is_int($maxPageNumber)) { $maxPageNumber = $maxPage->getPageNumber(); } $pagingId = $maxPage->getControl()->getId(true, true); $pagingId = Builder::escapeText($maxPage->getControl()->getId()); $pageLabelId = Builder::EMPTY_STRING; if ($this->label) { $pageLabelId = Builder::escapeText($this->label->getId()); } $pagesArrayText = $this->getPagesArrayText(); $pageButtonsArrayText = $this->getPageButtonsArrayText(); $previousChunkAction = Builder::escapeText($this->previousChunkAction); $nextChunkAction = Builder::escapeText($this->nextChunkAction); $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber); // Init $initScriptText = "\ndeclare {$currentPageVariable} for This = Integer[Text];\n{$currentPageVariable}[{$pagingId}] = {$startPageNumber};\n{$updatePageFunction}({$pagingId}, {$pageLabelId}, 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});"; $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); // MouseClick $clickScriptText = "\ndeclare PageButtons = {$pageButtonsArrayText};\nif (PageButtons.existskey(Event.Control.ControlId)) {\n\tdeclare BrowseAction = PageButtons[Event.Control.ControlId];\n\t{$updatePageFunction}({$pagingId}, {$pageLabelId}, BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});\n}"; $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true); // Update function $functionText = "\nVoid {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAction, Integer _MinPageNumber, Integer _MaxPageNumber, Text[Integer] _Pages, Text _PreviousChunkAction, Text _NextChunkAction, Boolean _ChunkActionAppendPageNumber) {\n\tdeclare {$currentPageVariable} for This = Integer[Text];\n\tif (!{$currentPageVariable}.existskey(_PagingId)) return;\n\tdeclare CurrentPage = {$currentPageVariable}[_PagingId] + _BrowseAction;\n\tif (CurrentPage < _MinPageNumber) {\n\t\tCurrentPage = _MinPageNumber;\n\t} else if (CurrentPage > _MaxPageNumber) {\n\t\tCurrentPage = _MaxPageNumber;\n\t}\n\t{$currentPageVariable}[_PagingId] = CurrentPage;\n\tdeclare PageFound = False;\n\tforeach (PageNumber => PageId in _Pages) {\n\t\tdeclare PageControl <=> Page.GetFirstChild(PageId);\n\t\tPageControl.Visible = (CurrentPage == PageNumber);\n\t\tif (PageControl.Visible) {\n\t\t\tPageFound = True;\n\t\t}\n\t}\n\tif (!PageFound && _BrowseAction != 0) {\n\t\tdeclare Text ChunkAction;\n\t\tif (_BrowseAction < 0) {\n\t\t\tChunkAction = _PreviousChunkAction;\n\t\t} else {\n\t\t\tChunkAction = _NextChunkAction;\n\t\t}\n\t\tif (_ChunkActionAppendPageNumber) {\n\t\t\tChunkAction ^= CurrentPage;\n\t\t}\n\t\tTriggerPageAction(ChunkAction);\n\t}\n\tif (_PageLabelId == " . Builder::EMPTY_STRING . ") return;\n\tdeclare PageLabel <=> (Page.GetFirstChild(_PageLabelId) as CMlLabel);\n\tif (PageLabel == Null) return;\n\tPageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber;\n}"; $script->addScriptFunction($updatePageFunction, $functionText); return $this; }
/** * @see ScriptFeature::prepare() */ public function prepare(Script $script) { $hoverControlId = Builder::escapeText($this->hoverControl->getId()); $tooltipControlId = Builder::escapeText($this->tooltipControl->getId()); // MouseOver $visibility = Builder::getBoolean(!$this->invert); $scriptText = "\nif (Event.Control.ControlId == {$hoverControlId}) {\n\tdeclare TooltipControl = Page.GetFirstChild({$tooltipControlId});\n\tTooltipControl.Visible = {$visibility};"; if (is_string($this->text) && $this->tooltipControl instanceof Label) { $tooltipText = Builder::escapeText($this->text); $scriptText .= "\n\tdeclare TooltipLabel = (TooltipControl as CMlLabel);\n\tTooltipLabel.Value = {$tooltipText};"; } $scriptText .= "\n}"; $script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText); // MouseOut $visibility = Builder::getBoolean($this->invert); $scriptText = "\nif (Event.Control.ControlId == {$hoverControlId}) {\n\tdeclare TooltipControl = Page.GetFirstChild({$tooltipControlId});"; if ($this->stayOnClick) { $scriptText .= "\n\tdeclare FML_Clicked for Event.Control = False;\n\tif (!FML_Clicked) "; } $scriptText .= "\n\tTooltipControl.Visible = {$visibility};\n}"; $script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText); // MouseClick if ($this->stayOnClick) { $scriptText = "\nif (Event.Control.ControlId == {$hoverControlId}) {\n\tdeclare FML_Clicked for Event.Control = False;\n\tFML_Clicked = !FML_Clicked;\n}"; $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText); } return $this; }
/** * Get the script text * * @return string */ protected function getScriptText() { $scriptText = ""; foreach ($this->imageUrls as $imageUrl) { $escapedImageUrl = Builder::escapeText($imageUrl); $scriptText .= "\nPreloadImage({$escapedImageUrl});"; } return $scriptText; }
/** * Get the script text * * @return string */ protected function getScriptText() { $togglingControlId = Builder::escapeText($this->togglingControl->getId()); $toggledControlId = Builder::escapeText($this->toggledControl->getId()); $visibility = "!ToggleControl.Visible"; if ($this->onlyShow) { $visibility = "True"; } else { if ($this->onlyHide) { $visibility = "False"; } } return "\nif (Event.Control.ControlId == {$togglingControlId}) {\n\tdeclare ToggleControl = Page.GetFirstChild({$toggledControlId});\n\tToggleControl.Visible = {$visibility};\n}"; }
/** * @see ScriptFeature::prepare() */ public function prepare(Script $script) { $updateFunctionName = self::FUNCTION_UPDATE_MENU; $elementsArrayText = $this->getElementsArrayText(); // OnInit if ($this->startElement) { $startControlId = Builder::escapeText($this->startElement->getControl()->getId()); $initScriptText = "\n{$updateFunctionName}({$elementsArrayText}, {$startControlId});"; $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true); } // MouseClick $scriptText = "\ndeclare MenuElements = {$elementsArrayText};\nif (MenuElements.existskey(Event.Control.ControlId)) {\n\tdeclare ShownControlId = MenuElements[Event.Control.ControlId];\n\t{$updateFunctionName}(MenuElements, ShownControlId);\n}"; $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true); // Update menu function $updateFunctionText = "\nVoid {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {\n\tforeach (ItemId => ControlId in _Elements) {\n\t\tdeclare Control <=> (Page.GetFirstChild(ControlId));\n\t\tControl.Visible = (ControlId == _ShownControlId);\n\t}\n}"; $script->addScriptFunction($updateFunctionName, $updateFunctionText); return $this; }
/** * Build the init script text * * @return string */ protected function buildInitScriptText() { $labelId = Builder::getId($this->label); $entryId = Builder::EMPTY_STRING; if ($this->entry) { $entryId = Builder::getId($this->entry); } $values = Builder::getArray($this->values); $default = Builder::escapeText($this->getDefault()); return "\ndeclare Label_Picker <=> (Page.GetFirstChild(\"{$labelId}\") as CMlLabel);\ndeclare Text[] " . self::VAR_PICKER_VALUES . " as Values for Label_Picker;\nValues = {$values};\ndeclare Text " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for Label_Picker;\nDefault = {$default};\ndeclare Text " . self::VAR_PICKER_ENTRY_ID . " as EntryId for Label_Picker;\nEntryId = \"{$entryId}\";\n" . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker);\n"; }