/** * @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() { 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() { 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() { $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; }
/** * 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}"; }
/** * 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; }