示例#1
0
 /**
  * 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()
 {
     $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});";
 }
示例#3
0
 /**
  * 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";
 }
示例#4
0
 public function testConstant()
 {
     $this->assertEquals("#Const\tTestConstant\tTrue\n", Builder::getConstant("TestConstant", true));
     $this->assertEquals("#Const\tSomeConstant\t1.3\n", Builder::getConstant("SomeConstant", 1.3));
     $this->assertEquals("#Const\tOtherConstant\t\"other-value\"\n", Builder::getConstant("OtherConstant", "other-value"));
 }
示例#5
0
 /**
  * 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}";
 }
示例#6
0
 /**
  * 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()
 {
     $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;
 }
示例#8
0
 /**
  * Build the array text for the Page Buttons
  *
  * @return string
  */
 protected function getPageButtonsArrayText()
 {
     if (empty($this->buttons)) {
         return Builder::getArray(array('' => 0), true);
     }
     $pageButtons = array();
     foreach ($this->buttons as $pageButton) {
         $pageButtons[$pageButton->getControl()->getId()] = $pageButton->getPagingCount();
     }
     return Builder::getArray($pageButtons, true);
 }
 /**
  * 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;
 }
示例#10
0
 /**
  * @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;
 }
示例#11
0
 /**
  * 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;
 }
 /**
  * Build the script text for Quad clicks
  *
  * @return string
  */
 protected function buildClickScriptText()
 {
     $quadId = Builder::getId($this->getQuad());
     return "\nif (Event.ControlId == \"{$quadId}\") {\n\tdeclare Quad_CheckBox <=> (Event.Control as CMlQuad);\n\t" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);\n}";
 }
示例#13
0
 /**
  * Get the script text
  *
  * @return string
  */
 protected function getScriptText()
 {
     $scriptText = "";
     foreach ($this->imageUrls as $imageUrl) {
         $escapedImageUrl = Builder::escapeText($imageUrl);
         $scriptText .= "\nPreloadImage({$escapedImageUrl});";
     }
     return $scriptText;
 }
示例#14
0
 /**
  * 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}";
 }
示例#15
0
 /**
  * Build the array text for the Elements
  *
  * @return string
  */
 protected function getElementsArrayText()
 {
     $elements = array();
     foreach ($this->elements as $element) {
         $elementId = $element->getItem()->getId();
         $elements[$elementId] = $element->getControl()->getId();
     }
     return Builder::getArray($elements, true);
 }
 /**
  * Build the script text for Label clicks
  *
  * @return string
  */
 protected function buildClickScriptText()
 {
     $labelId = Builder::getId($this->label);
     return "\nif (Event.ControlId == \"{$labelId}\") {\n\tdeclare Label_Picker <=> (Event.Control as CMlLabel);\n\t" . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker);\n}";
 }