This commit is contained in:
Steffen Schröder
2014-04-27 14:44:40 +02:00
parent d814f7e983
commit b75946e048
44 changed files with 2461 additions and 1038 deletions

View File

@ -16,9 +16,13 @@ abstract class Builder {
*
* @param string $labelName Name of the Label
* @param string $implementationCode Label Implementation Coding (without declaration)
* @param bool $isolate Whether the Code should be isolated in an own Block
* @return string
*/
public static function getLabelImplementationBlock($labelName, $implementationCode) {
public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true) {
if ($isolate) {
$implementationCode = 'if(True){' . $implementationCode . '}';
}
$labelText = PHP_EOL . "***{$labelName}***" . PHP_EOL . "***{$implementationCode}***" . PHP_EOL;
return $labelText;
}
@ -27,13 +31,16 @@ abstract class Builder {
* Escape dangerous Characters in the given Text
*
* @param string $text Text to escape
* @param bool $addApostrophes (optional) Whether to add Apostrophes before and after the Text
* @return string
*/
public static function escapeText($text) {
$escapedText = $text;
public static function escapeText($text, $addApostrophes = false) {
$dangers = array('\\', '"', "\n");
$replacements = array('\\\\', '\\"', '\n');
$escapedText = str_ireplace($dangers, $replacements, $escapedText);
$replacements = array('\\\\', '\\"', '\\n');
$escapedText = str_ireplace($dangers, $replacements, $text);
if ($addApostrophes) {
$escapedText = '"' . $escapedText . '"';
}
return $escapedText;
}
@ -46,13 +53,15 @@ abstract class Builder {
public static function getReal($value) {
$value = (float) $value;
$stringVal = (string) $value;
if (!fmod($value, 1)) $stringVal .= '.';
if (!fmod($value, 1)) {
$stringVal .= '.';
}
return $stringVal;
}
/**
* Get the Boolean String-Representation of the given Value
*
*
* @param bool $value The Value to convert to a ManiaScript Boolean
* @return string
*/
@ -63,4 +72,67 @@ abstract class Builder {
}
return "False";
}
/**
* Get the String-Representation of the given Array
*
* @param array $array Array to convert to a ManiaScript Array
* @param bool $associative (optional) Whether the Array should be associative
* @return string
*/
public static function getArray(array $array, $associative = false) {
$arrayText = '[';
$index = 0;
$count = count($array);
foreach ($array as $key => $value) {
if ($associative) {
if (is_string($key)) {
$arrayText .= '"' . self::escapeText($key) . '"';
}
else {
$arrayText .= $key;
}
$arrayText .= ' => ';
}
if (is_string($value)) {
$arrayText .= '"' . self::escapeText($value) . '"';
}
else {
$arrayText .= $value;
}
if ($index < $count - 1) {
$arrayText .= ', ';
$index++;
}
}
$arrayText .= ']';
return $arrayText;
}
/**
* Get the Include Command for the given File and Namespace
*
* @param string $file Include File
* @param string $namespace Include Namespace
* @return string
*/
public static function getInclude($file, $namespace) {
$includeText = "#Include \"{$file}\" as {$namespace}" . PHP_EOL;
return $includeText;
}
/**
* Get the Constant Command for the given Name and Value
*
* @param string $name Constant Name
* @param string $value Constant Value
* @return string
*/
public static function getConstant($name, $value) {
if (is_string($value)) {
$value = '"' . $value . '"';
}
$constantText = "#Const {$name} {$value}" . PHP_EOL;
return $constantText;
}
}

View File

@ -1,45 +0,0 @@
<?php
namespace FML\Script;
/**
* Class for EUISound Variants
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class EUISound {
/*
* Constants
*/
const SOUND_Bonus = 'Bonus';
const SOUND_Capture = 'Capture';
const SOUND_Checkpoint = 'Checkpoint';
const SOUND_Combo = 'Combo';
const SOUND_Custom1 = 'Custom1';
const SOUND_Custom2 = 'Custom2';
const SOUND_Custom3 = 'Custom3';
const SOUND_Custom4 = 'Custom4';
const SOUND_Default = 'Default';
const SOUND_EndMatch = 'EndMatch';
const SOUND_EndRound = 'EndRound';
const SOUND_Finish = 'Finish';
const SOUND_FirstHit = 'FirstHit';
const SOUND_Notice = 'Notice';
const SOUND_PhaseChange = 'PhaseChange';
const SOUND_PlayerEliminated = 'PlayerEliminated';
const SOUND_PlayerHit = 'PlayerHit';
const SOUND_PlayersRemaining = 'PlayersRemaining';
const SOUND_RankChange = 'RankChange';
const SOUND_Record = 'Record';
const SOUND_ScoreProgress = 'ScoreProgress';
const SOUND_Silence = 'Silence';
const SOUND_StartMatch = 'StartMatch';
const SOUND_StartRound = 'StartRound';
const SOUND_TieBreakPoint = 'TieBreakPoint';
const SOUND_TiePoint = 'TiePoint';
const SOUND_TimeOut = 'TimeOut';
const SOUND_VictoryPoint = 'VictoryPoint';
const SOUND_Warning = 'Warning';
}

View File

@ -0,0 +1,105 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature for triggering a Page Action
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ActionTrigger extends ScriptFeature {
/*
* Protected Properties
*/
protected $actionName = null;
protected $control = null;
protected $labelName = null;
/**
* Construct a new Action Trigger Feature
*
* @param string $actionName (optional) Triggered Action
* @param Control $control (optional) Action Control
* @param string $labelName (optional) Script Label Name
*/
public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
$this->setActionName($actionName);
$this->setControl($control);
$this->setLabelName($labelName);
}
/**
* Set the Action to trigger
*
* @param string $actionName
* @return \FML\Script\Features\ActionTrigger
*/
public function setActionName($actionName) {
$this->actionName = $actionName;
return $this;
}
/**
* Set the Control
*
* @param Control $control Action Control
* @return \FML\Script\Features\ActionTrigger
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\ActionTrigger
*/
public function setLabelName($labelName) {
$this->labelName = $labelName;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* 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 = "
if (Event.Control.ControlId == \"{$controlId}\") {
TriggerPageAction(\"{$actionName}\");
}";
}
else {
// Other
$scriptText = "
TriggerPageAction(\"{$actionName}\");";
}
return $scriptText;
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace FML\Script\Features;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Controls\Label;
use FML\Script\ScriptInclude;
/**
* Script Feature showing the current Time on a Label
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Clock extends ScriptFeature {
/*
* Protected Properties
*/
protected $label = null;
protected $showSeconds = null;
protected $showFullDate = null;
/**
* Construct a new Clock Feature
*
* @param Label $label (optional) Clock Label
* @param bool $showSeconds (optional) Whether the Seconds should be shown
* @param bool $showFullDate (optional) Whether the Date should be shown
*/
public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) {
$this->setLabel($label);
$this->setShowSeconds($showSeconds);
$this->setShowFullDate($showFullDate);
}
/**
* Set the Label
*
* @param Label $label Clock Label
* @return \FML\Script\Features\Clock
*/
public function setLabel(Label $label) {
$label->checkId();
$this->label = $label;
return $this;
}
/**
* Set whether the Seconds should be shown
*
* @param bool $showSeconds Whether the Seconds should be shown
* @return \FML\Script\Features\Clock
*/
public function setShowSeconds($showSeconds) {
$this->showSeconds = (bool) $showSeconds;
return $this;
}
/**
* Set whether the Full Date should be shown
*
* @param bool $showFullDate Whether the Full Date should be shown
* @return \FML\Script\Features\Clock
*/
public function setShowFullDate($showFullDate) {
$this->showFullDate = (bool) $showFullDate;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$script->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true);
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
$controlId = $this->label->getId(true);
$scriptText = "
declare ClockLabel <=> (Page.GetFirstChild(\"{$controlId}\") as CMlLabel);
declare TimeText = CurrentLocalDateText;";
if (!$this->showSeconds) {
$scriptText .= "
TimeText = TextLib::SubText(TimeText, 0, 16);";
}
if (!$this->showFullDate) {
$scriptText .= "
TimeText = TextLib::SubText(TimeText, 11, 9);";
}
$scriptText .= "
ClockLabel.Value = TimeText;";
return $scriptText;
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace FML\Script\Features;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
use FML\Controls\Entry;
use FML\Script\ScriptInclude;
/**
* Script Feature for submitting an Entry
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class EntrySubmit extends ScriptFeature {
/*
* Protected Properties
*/
protected $entry = null;
protected $url = null;
/**
* Construct a new Entry Submit Feature
*
* @param Entry $entry (optional) Entry Control
* @param string $url (optional) Submit Url
*/
public function __construct(Entry $entry = null, $url = null) {
$this->setEntry($entry);
$this->setUrl($url);
}
/**
* Set the Entry
*
* @param Entry $entry Entry Control
* @return \FML\Script\Features\EntrySubmit
*/
public function setEntry(Entry $entry) {
$entry->checkId();
$entry->setScriptEvents(true);
$this->entry = $entry;
return $this;
}
/**
* Set the Submit Url
*
* @param string $url Submit Url
* @return \FML\Script\Features\EntrySubmit
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$script->appendGenericScriptLabel(ScriptLabel::ENTRYSUBMIT, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
$controlId = $this->entry->getId(true);
$url = $this->buildCompatibleUrl();
$entryName = Builder::escapeText($this->entry->getName());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
declare Entry <=> (Event.Control as CMlEntry);
declare Value = TextLib::URLEncode(Entry.Value);
OpenLink(\"{$url}{$entryName}=\"^Value, CMlScript::LinkType::Goto);
}";
return $scriptText;
}
/**
* Build the Submit Url compatible for the Entry Parameter
*
* @return string
*/
protected function buildCompatibleUrl() {
$url = $this->url;
$paramsBegin = stripos($url, '?');
if (!is_int($paramsBegin) || $paramsBegin < 0) {
$url .= '?';
}
else {
$url .= '&';
}
return $url;
}
}

View File

@ -0,0 +1,90 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature for opening the Map Info
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MapInfo extends ScriptFeature {
/*
* Protected Properties
*/
protected $control = null;
protected $labelName = null;
/**
* Construct a new Map Info Feature
*
* @param Control $control (optional) Map Info Control
* @param string $labelName (optional) Script Label Name
*/
public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) {
$this->setControl($control);
$this->setLabelName($labelName);
}
/**
* Set the Control
*
* @param Control $control Action Control
* @return \FML\Script\Features\ActionTrigger
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\ActionTrigger
*/
public function setLabelName($labelName) {
$this->labelName = $labelName;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
ShowCurChallengeCard();
}";
}
else {
// Other
$scriptText = "
ShowCurChallengeCard();";
}
return $scriptText;
}
}

View File

@ -0,0 +1,138 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature realising a Menu showing specific Controls for the different Item Controls
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Menu extends ScriptFeature {
/*
* Constants
*/
const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu';
/*
* Protected Properties
*/
protected $elements = array();
protected $startElement = null;
/**
* Construct a new Menu Feature
*
* @param Control $item (optional) Item Control in the Menu Bar
* @param Control $control (optional) Toggled Menu Control
*/
public function __construct(Control $item = null, Control $control = null) {
if ($item && $control) {
$this->addNewElement($item, $control);
}
}
/**
* Add a new Element to the Menu
*
* @param Control $item Item Control in the Menu Bar
* @param Control $control Toggled Menu Control
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
* @return \FML\Script\Features\Menu
*/
public function addElement(Control $item, Control $control, $isStartElement = false) {
$menuElement = new MenuElement($item, $control);
$this->appendElement($menuElement, $isStartElement);
return $this;
}
/**
* Append an Element to the Menu
*
* @param MenuElement $menuElement Menu Element
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
* @return \FML\Script\Features\Menu
*/
public function appendElement(MenuElement $menuElement, $isStartElement = false) {
array_push($this->elements, $menuElement);
if ($isStartElement) {
$this->setStartElement($menuElement);
}
else if (count($this->elements) > 1) {
$menuElement->getControl()->setVisible(false);
}
return $this;
}
/**
* Set the Element to start with
*
* @param MenuElement $startElement Starting Element
* @return \FML\Script\Features\Menu
*/
public function setStartElement(MenuElement $startElement) {
$this->startElement = $startElement;
if (!in_array($startElement, $this->elements, true)) {
array_push($this->elements, $startElement);
}
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$updateFunctionName = self::FUNCTION_UPDATE_MENU;
$elementsArrayText = $this->getElementsArrayText();
// OnInit
if ($this->startElement) {
$startControlId = $this->startElement->getControl()->getId(true);
$initScriptText = "
{$updateFunctionName}({$elementsArrayText}, \"{$startControlId}\");";
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
}
// MouseClick
$scriptText = "
declare MenuElements = {$elementsArrayText};
if (MenuElements.existskey(Event.Control.ControlId)) {
declare ShownControlId = MenuElements[Event.Control.ControlId];
{$updateFunctionName}(MenuElements, ShownControlId);
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true);
// Update menu function
$updateFunctionText = "
Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
foreach (ItemId => ControlId in _Elements) {
declare Control <=> (Page.GetFirstChild(ControlId));
Control.Visible = (ControlId == _ShownControlId);
}
}";
$script->addScriptFunction($updateFunctionName, $updateFunctionText);
return $this;
}
/**
* Build the Array Text for the Elements
*
* @return string
*/
protected function getElementsArrayText() {
$elements = array();
foreach ($this->elements as $element) {
$elements[$element->getItem()->getId()] = $element->getControl()->getId();
}
return Builder::getArray($elements, true);
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
/**
* An Element for the Menu Feature
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MenuElement {
/*
* Protected Properties
*/
protected $item = null;
protected $control = null;
/**
* Create a new Menu Element
*
* @param Control $item (optional) Item Control in the Menu Bar
* @param Control $control (optional) Toggled Menu Control
*/
public function __construct(Control $item = null, Control $control = null) {
$this->setItem($item);
$this->setControl($control);
}
/**
* Set the Item Control
*
* @param Control $item Item Control in the Menu Bar
* @return \FML\Script\Features\MenuElement
*/
public function setItem(Control $item) {
$item->checkId();
$item->setScriptEvents(true);
$this->item = $item;
return $this;
}
/**
* Get the Item Control
*
* @return \FML\Controls\Control
*/
public function getItem() {
return $this->item;
}
/**
* Set the Menu Control
*
* @param Control $control Toggled Menu Control
* @return \FML\Script\Features\MenuElement
*/
public function setControl(Control $control) {
$control->checkId();
$this->control = $control;
return $this;
}
/**
* Get the Menu Control
*
* @return \FML\Controls\Control
*/
public function getControl() {
return $this->control;
}
}

View File

@ -0,0 +1,326 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
use FML\Controls\Label;
use FML\Script\ScriptInclude;
/**
* Script Feature realising a Mechanism for browsing through Pages
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Paging extends ScriptFeature {
/*
* Constants
*/
const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage';
const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage';
/*
* Protected Properties
*/
protected $pages = array();
protected $buttons = array();
protected $label = null;
protected $customMinPageNumber = null;
protected $customMaxPageNumber = null;
protected $previousChunkAction = null;
protected $nextChunkAction = null;
protected $chunkActionAppendsPageNumber = null;
/**
* Construct a new Paging Script Feature
*
* @param Label $label (optional) Page Number Label
*/
public function __construct(Label $label = null) {
if ($label) {
$this->setLabel($label);
}
}
/**
* Add a new Page Control
*
* @param Control $pageControl Page Control
* @param string $pageNumber (optional) Page Number
* @return \FML\Script\Features\Paging
*/
public function addPage(Control $pageControl, $pageNumber = null) {
if ($pageNumber === null) {
$pageNumber = count($this->pages) + 1;
}
$page = new PagingPage($pageControl, $pageNumber);
$this->appendPage($page);
return $this;
}
/**
* Append a Page
*
* @param PagingPage $page Paging Page
* @return \FML\Script\Features\Paging
*/
public function appendPage(PagingPage $page) {
array_push($this->pages, $page);
return $this;
}
/**
* Add a new Button to browse through the Pages
*
* @param Control $buttonControl Button used for Browsing
* @param int $browseAction (optional) Number of browsed Pages per Click
* @return \FML\Script\Features\Paging
*/
public function addButton(Control $buttonControl, $browseAction = null) {
if ($browseAction === null) {
$buttonCount = count($this->buttons);
if ($buttonCount % 2 === 0) {
$browseAction = $buttonCount / 2 + 1;
}
else {
$browseAction = $buttonCount / -2 - 1;
}
}
$button = new PagingButton($buttonControl, $browseAction);
$this->appendButton($button);
return $this;
}
/**
* Append a Button to browse through Pages
*
* @param PagingButton $button Paging Button
* @return \FML\Script\Features\Paging
*/
public function appendButton(PagingButton $button) {
array_push($this->buttons, $button);
return $this;
}
/**
* Set the Label showing the Page Number
*
* @param Label $label Page Number Label
* @return \FML\Script\Features\Paging
*/
public function setLabel(Label $label) {
$label->checkId();
$this->label = $label;
return $this;
}
/**
* Set a custom Minimum Page Number for using Chunks
*
* @param int $minPageNumber Custom Minimum Page Number
* @return \FML\Script\Features\Paging
*/
public function setCustomMinPageNumber($minPageNumber) {
$this->customMinPageNumber = (int) $minPageNumber;
return $this;
}
/**
* Set a custom Maximum Page Number for using Chunks
*
* @param int $maxPageNumber Custom Maximum Page Number
* @return \FML\Script\Features\Paging
*/
public function setCustomMaxPageNumber($maxPageNumber) {
$this->customMaxPageNumber = (int) $maxPageNumber;
return $this;
}
/**
* Set the Action triggered when the previous Chunk is needed
*
* @param string $previousChunkAction Triggered Action
* @return \FML\Script\Features\Paging
*/
public function setPreviousChunkAction($previousChunkAction) {
$this->previousChunkAction = (string) $previousChunkAction;
return $this;
}
/**
* Set the Action triggered when the next Chunk is needed
*
* @param string $nextChunkAction Triggered Action
* @return \FML\Script\Features\Paging
*/
public function setNextChunkAction($nextChunkAction) {
$this->nextChunkAction = (string) $nextChunkAction;
return $this;
}
/**
* Set if the Chunk Action should get the needed Page Number appended
*
* @param bool $appendPageNumber Whether to append the needed Page Number
* @return \FML\Script\Features\Paging
*
*/
public function setChunkActionAppendsPageNumber($appendPageNumber) {
$this->chunkActionAppendsPageNumber = (bool) $appendPageNumber;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$currentPageVariable = self::VAR_CURRENT_PAGE;
$updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE;
$minPage = $this->getMinPage();
$startPageNumber = $minPage->getPageNumber();
$minPageNumber = $startPageNumber;
if (is_int($this->customMinPageNumber)) {
$minPageNumber = $this->customMinPageNumber;
}
$maxPage = $this->getMaxPage();
$maxPageNumber = $maxPage->getPageNumber();
if (is_int($this->customMaxPageNumber)) {
$maxPageNumber = $this->customMaxPageNumber;
}
$pagingId = $minPage->getControl()->getId(true);
$pageLabelId = $this->label->getId(true);
$pagesArrayText = $this->getPagesArrayText();
$pageButtonsArrayText = $this->getPageButtonsArrayText();
$previousChunkAction = Builder::escapeText($this->previousChunkAction);
$nextChunkAction = Builder::escapeText($this->nextChunkAction);
$chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
// Init
$initScriptText = "
declare {$currentPageVariable} for This = Integer[Text];
{$currentPageVariable}[\"{$pagingId}\"] = {$startPageNumber};
{$updatePageFunction}(\"{$pagingId}\", \"{$pageLabelId}\", 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, \"{$previousChunkAction}\", \"{$nextChunkAction}\", {$chunkActionAppendsPageNumber});";
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
// MouseClick
$clickScriptText = "
declare PageButtons = {$pageButtonsArrayText};
if (PageButtons.existskey(Event.Control.ControlId)) {
declare BrowseAction = PageButtons[Event.Control.ControlId];
{$updatePageFunction}(\"{$pagingId}\", \"{$pageLabelId}\", BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, \"{$previousChunkAction}\", \"{$nextChunkAction}\", {$chunkActionAppendsPageNumber});
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true);
// Update function
$functionText = "
Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAction, Integer _MinPageNumber, Integer _MaxPageNumber, Text[Integer] _Pages, Text _PreviousChunkAction, Text _NextChunkAction, Boolean _ChunkActionAppendPageNumber) {
declare {$currentPageVariable} for This = Integer[Text];
if (!{$currentPageVariable}.existskey(_PagingId)) return;
declare CurrentPage = {$currentPageVariable}[_PagingId] + _BrowseAction;
if (CurrentPage < _MinPageNumber) {
CurrentPage = _MinPageNumber;
} else if (CurrentPage > _MaxPageNumber) {
CurrentPage = _MaxPageNumber;
}
{$currentPageVariable}[_PagingId] = CurrentPage;
declare PageFound = False;
foreach (PageNumber => PageId in _Pages) {
declare PageControl <=> Page.GetFirstChild(PageId);
PageControl.Visible = (CurrentPage == PageNumber);
if (PageControl.Visible) {
PageFound = True;
}
}
if (!PageFound && _BrowseAction != 0) {
declare Text ChunkAction;
if (_BrowseAction < 0) {
ChunkAction = _PreviousChunkAction;
} else {
ChunkAction = _NextChunkAction;
}
if (_ChunkActionAppendPageNumber) {
ChunkAction ^= CurrentPage;
}
TriggerPageAction(ChunkAction);
}
declare PageLabel <=> (Page.GetFirstChild(_PageLabelId) as CMlLabel);
if (PageLabel == Null) return;
PageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber;
}";
$script->addScriptFunction($updatePageFunction, $functionText);
return $this;
}
/**
* Get the minimum Page
*
* @return \FML\Script\Features\PagingPage
*/
protected function getMinPage() {
$minPageNumber = null;
$minPage = null;
foreach ($this->pages as $page) {
$pageNumber = $page->getPageNumber();
if ($minPageNumber === null || $pageNumber < $minPageNumber) {
$minPageNumber = $pageNumber;
$minPage = $page;
}
}
return $minPage;
}
/**
* Get the maximum Page
*
* @return \FML\Script\Features\PagingPage
*/
protected function getMaxPage() {
$maxPageNumber = null;
$maxPage = null;
foreach ($this->pages as $page) {
$pageNumber = $page->getPageNumber();
if ($maxPageNumber === null || $pageNumber > $maxPageNumber) {
$maxPageNumber = $pageNumber;
$maxPage = $page;
}
}
return $maxPage;
}
/**
* Build the Array Text for the Pages
*
* @return string
*/
protected function getPagesArrayText() {
$pages = array();
foreach ($this->pages as $page) {
$pages[$page->getPageNumber()] = $page->getControl()->getId();
}
return Builder::getArray($pages, true);
}
/**
* Build the Array Text for the Page Buttons
*
* @return string
*/
protected function getPageButtonsArrayText() {
$pageButtons = array();
foreach ($this->buttons as $pageButton) {
$pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction();
}
return Builder::getArray($pageButtons, true);
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
/**
* A Button for browsing through Pages
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PagingButton {
/*
* Protected Properties
*/
protected $control = null;
protected $browseAction = null;
/**
* Construct a new Paging Button
*
* @param Control $control (optional) Browse Control
* @param int $browseAction (optional) Number of browsed Pages per Click
*/
public function __construct(Control $control = null, $browseAction = null) {
$this->setControl($control);
$this->setBrowseAction($browseAction);
}
/**
* Set the Button Control
*
* @param Control $control Browse Control
* @return \FML\Script\Features\PagingButton
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Get the Button Control
*
* @return \FML\Controls\Control
*/
public function getControl() {
return $this->control;
}
/**
* Set the Browse Action
*
* @param int $browseAction Number of browsed Pages per Click
* @return \FML\Script\Features\PagingButton
*/
public function setBrowseAction($browseAction) {
$this->browseAction = (int) $browseAction;
return $this;
}
/**
* Get the Browse Action
*
* @return int
*/
public function getBrowseAction() {
return $this->browseAction;
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
/**
* A Page Control
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PagingPage {
/*
* Protected Properties
*/
protected $control = null;
protected $number = null;
/**
* Construct a new Paging Page
*
* @param Control $control (optional) Page Control
* @param int $pageNumber (optional) Number of the Page
*/
public function __construct(Control $control = null, $pageNumber = 1) {
$this->setControl($control);
$this->setPageNumber($pageNumber);
}
/**
* Set the Page Control
*
* @param Control $control Page Control
* @return \FML\Script\Features\PagingPage
*/
public function setControl(Control $control) {
$control->checkId();
$this->control = $control;
return $this;
}
/**
* Get the Page Control
*
* @return \FML\Controls\Control
*/
public function getControl() {
return $this->control;
}
/**
* Set the Page Number
*
* @param int $pageNumber Number of the Page
* @return \FML\Script\Features\PagingPage
*/
public function setPageNumber($pageNumber) {
$this->number = (int) $pageNumber;
return $this;
}
/**
* Get the Page Number
*
* @return int
*/
public function getPageNumber() {
return $this->number;
}
}

View File

@ -0,0 +1,104 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature for opening a Player Profile
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerProfile extends ScriptFeature {
/*
* Protected Properties
*/
protected $login = null;
protected $control = null;
protected $labelName = null;
/**
* Construct a new Player Profile Feature
*
* @param string $login (optional) Player Login
* @param Control $control (optional) Action Control
* @param string $labelName (optional) Script Label Name
*/
public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
$this->setLogin($login);
$this->setControl($control);
$this->setLabelName($labelName);
}
/**
* Set the Login of the Player
*
* @param string $login Player Login
* @return \FML\Script\Features\PlayerProfile
*/
public function setLogin($login) {
$this->login = $login;
return $this;
}
/**
* Set the Control
*
* @param Control $control Profile Control
* @return \FML\Script\Features\PlayerProfile
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\PlayerProfile
*/
public function setLabelName($labelName) {
$this->labelName = $labelName;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* 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());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
ShowProfile(\"{$login}\");
}";
}
else {
// Other
$scriptText = "
ShowProfile(\"{$login}\");";
}
return $scriptText;
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace FML\Script\Features;
use FML\Script\Script;
/**
* ManiaLink Script Feature Class
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class ScriptFeature {
/**
* Prepare the given Script for Rendering by adding the needed Labels, etc.
*
* @param Script $script Script to prepare
* @return \FML\Script\Features\ScriptFeature
*/
public abstract function prepare(Script $script);
}

View File

@ -0,0 +1,133 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
/**
* Script Feature for toggling Controls
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Toggle extends ScriptFeature {
/*
* Protected Properties
*/
protected $togglingControl = null;
protected $toggledControl = null;
protected $labelName = null;
protected $onlyShow = null;
protected $onlyHide = null;
/**
* Construct a new Toggle Feature
*
* @param Control $togglingControl (optional) Toggling Control
* @param Control $toggledControl (optional) Toggled Control
* @param string $labelName (optional) Script Label Name
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
*/
public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
$this->setTogglingControl($togglingControl);
$this->setToggledControl($toggledControl);
$this->setLabelName($labelName);
$this->setOnlyShow($onlyShow);
$this->setOnlyHide($onlyHide);
}
/**
* Set the Toggling Control
*
* @param Control $control Toggling Control
* @return \FML\Script\Features\Toggle
*/
public function setTogglingControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->togglingControl = $control;
return $this;
}
/**
* Set the Toggled Control
*
* @param Control $control Toggling Control
* @return \FML\Script\Features\Toggle
*/
public function setToggledControl(Control $control) {
$control->checkId();
$this->toggledControl = $control;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\Toggle
*/
public function setLabelName($labelName) {
$this->labelName = (string) $labelName;
return $this;
}
/**
* Set only Show
*
* @param bool $onlyShow Whether it should only Show the Control but not toggle
* @return \FML\Script\Features\Toggle
*/
public function setOnlyShow($onlyShow) {
$this->onlyShow = (bool) $onlyShow;
return $this;
}
/**
* Set only Hide
*
* @param bool $onlyHide Whether it should only Hide the Control but not toggle
* @return \FML\Script\Features\Toggle
*/
public function setOnlyHide($onlyHide) {
$this->onlyHide = (bool) $onlyHide;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
$togglingControlId = $this->togglingControl->getId(true);
$toggledControlId = $this->toggledControl->getId(true);
$visibility = '!ToggleControl.Visible';
if ($this->onlyShow) {
$visibility = 'True';
}
else if ($this->onlyHide) {
$visibility = 'False';
}
$scriptText = "
if (Event.Control.ControlId == \"{$togglingControlId}\") {
declare ToggleControl = Page.GetFirstChild(\"{$toggledControlId}\");
ToggleControl.Visible = {$visibility};
}";
return $scriptText;
}
}

View File

@ -0,0 +1,156 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
use FML\Controls\Label;
/**
* Script Feature for Showing Tooltips
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Tooltip extends ScriptFeature {
/*
* Protected Properties
*/
protected $hoverControl = null;
protected $tooltipControl = null;
protected $stayOnClick = null;
protected $invert = null;
protected $text = null;
/**
* Construct a new Tooltip Feature
*
* @param Control $hoverControl (optional) Hover Control
* @param Control $tooltipControl (optional) Tooltip Control
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @param string $text (optional) The Text to display if the TooltipControl is a Label
*/
public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = false, $invert = false, $text = null) {
$this->setHoverControl($hoverControl);
$this->setTooltipControl($tooltipControl);
$this->setStayOnClick($stayOnClick);
$this->setInvert($invert);
$this->setText($text);
}
/**
* Set the Hover Control
*
* @param Control $hoverControl Hover Control
* @return \FML\Script\Features\Tooltip
*/
public function setHoverControl(Control $hoverControl) {
$hoverControl->checkId();
$hoverControl->setScriptEvents(true);
$this->hoverControl = $hoverControl;
return $this;
}
/**
* Set the Tooltip Control
*
* @param Control $tooltipControl Tooltip Control
* @return \FML\Script\Features\Tooltip
*/
public function setTooltipControl(Control $tooltipControl) {
$tooltipControl->checkId();
$tooltipControl->setVisible(false);
$this->tooltipControl = $tooltipControl;
return $this;
}
/**
* Set only Show
*
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @return \FML\Script\Features\Tooltip
*/
public function setStayOnClick($stayOnClick) {
$this->stayOnClick = (bool) $stayOnClick;
return $this;
}
/**
* Set only Hide
*
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @return \FML\Script\Features\Tooltip
*/
public function setInvert($invert) {
$this->invert = (bool) $invert;
return $this;
}
/**
* Set Text
*
* @param string $text (optional) The Text to display if the TooltipControl is a Label
* @return \FML\Script\Features\Tooltip
*/
public function setText($text) {
$this->text = $text;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$hoverControlId = $this->hoverControl->getId(true);
$tooltipControlId = $this->tooltipControl->getId(true);
// MouseOver
$visibility = ($this->invert ? 'False' : 'True');
$scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") {
declare TooltipControl = Page.GetFirstChild(\"{$tooltipControlId}\");
TooltipControl.Visible = {$visibility};";
if (is_string($this->text) && ($this->tooltipControl instanceof Label)) {
$tooltipText = Builder::escapeText($this->text);
$scriptText .= "
declare TooltipLabel = (TooltipControl as CMlLabel);
TooltipLabel.Value = \"{$tooltipText}\";";
}
$scriptText .= "
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText);
// MouseOut
$visibility = ($this->invert ? 'True' : 'False');
$scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") {
declare TooltipControl = Page.GetFirstChild(\"{$tooltipControlId}\");";
if ($this->stayOnClick) {
$scriptText .= "
declare FML_Clicked for Event.Control = False;
if (!FML_Clicked) ";
}
$scriptText .= "
TooltipControl.Visible = {$visibility};
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText);
// MouseClick
if ($this->stayOnClick) {
$scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") {
declare FML_Clicked for Event.Control = False;
FML_Clicked = !FML_Clicked;
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText);
}
return $this;
}
}

View File

@ -0,0 +1,162 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature for playing an UI Sound
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class UISound extends ScriptFeature {
/*
* Constants
*/
const Bonus = 'Bonus';
const Capture = 'Capture';
const Checkpoint = 'Checkpoint';
const Combo = 'Combo';
const Custom1 = 'Custom1';
const Custom2 = 'Custom2';
const Custom3 = 'Custom3';
const Custom4 = 'Custom4';
const Default_ = 'Default';
const EndMatch = 'EndMatch';
const EndRound = 'EndRound';
const Finish = 'Finish';
const FirstHit = 'FirstHit';
const Notice = 'Notice';
const PhaseChange = 'PhaseChange';
const PlayerEliminated = 'PlayerEliminated';
const PlayerHit = 'PlayerHit';
const PlayersRemaining = 'PlayersRemaining';
const RankChange = 'RankChange';
const Record = 'Record';
const ScoreProgress = 'ScoreProgress';
const Silence = 'Silence';
const StartMatch = 'StartMatch';
const StartRound = 'StartRound';
const TieBreakPoint = 'TieBreakPoint';
const TiePoint = 'TiePoint';
const TimeOut = 'TimeOut';
const VictoryPoint = 'VictoryPoint';
const Warning = 'Warning';
/*
* Protected Properties
*/
protected $soundName = null;
protected $control = null;
protected $variant = 0;
protected $volume = 1.;
protected $labelName = null;
/**
* Construct a new UISound Feature
*
* @param string $soundName (optional) Played Sound
* @param Control $control (optional) Action Control
* @param int $variant (optional) Sound Variant
* @param string $labelName (optional) Script Label Name
*/
public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) {
$this->setSoundName($soundName);
$this->setControl($control);
$this->setVariant($variant);
$this->setLabelName($labelName);
}
/**
* Set the Sound to play
*
* @param string $soundName Sound Name
* @return \FML\Script\Features\UISound
*/
public function setSoundName($soundName) {
$this->soundName = (string) $soundName;
return $this;
}
/**
* Set the Control
*
* @param Control $control Action Control
* @return \FML\Script\Features\UISound
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Set the Sound Variant
*
* @param int $variant Sound Variant
* @return \FML\Script\Features\UISound
*/
public function setVariant($variant) {
$this->variant = (int) $variant;
return $this;
}
/**
* Set the Volume
*
* @param float $volume Sound Volume
* @return \FML\Script\Features\UISound
*/
public function setVolume($volume) {
$this->volume = (float) $volume;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\UISound
*/
public function setLabelName($labelName) {
$this->labelName = (string) $labelName;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});
}";
}
else {
// Other
$scriptText = "
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});";
}
return $scriptText;
}
}

View File

@ -1,4 +0,0 @@
/*********************************
* FancyManiaLinks by steeffeen *
* http://fml.steeffeen.com *
*********************************/

View File

@ -1,34 +0,0 @@
Void Dummy() {}
main() {
declare FML_ScriptStart = Now;
+++OnInit+++
declare FML_LoopCounter = 0;
declare FML_LastTick = 0;
while (True) {
yield;
foreach (Event in PendingEvents) {
switch (Event.Type) {
case CMlEvent::Type::EntrySubmit: {
+++EntrySubmit+++
}
case CMlEvent::Type::KeyPress: {
+++KeyPress+++
}
case CMlEvent::Type::MouseClick: {
+++MouseClick+++
}
case CMlEvent::Type::MouseOut: {
+++MouseOut+++
}
case CMlEvent::Type::MouseOver: {
+++MouseOver+++
}
}
}
FML_LoopCounter += 1;
+++Loop+++
if (FML_LastTick + 250 > Now) continue;
FML_LastTick = Now;
+++Tick+++
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
<?php
namespace FML\Script;
/**
* Class representing a Constant of the ManiaLink Script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptConstant {
/*
* Protected Properties
*/
protected $name = null;
protected $value = null;
/**
* Construct a new Script Constant
*
* @param string $name (optional) Constant Name
* @param string $value (optional) Constant Value
*/
public function __construct($name = null, $value = null) {
$this->setName($name);
$this->setValue($value);
}
/**
* Set the Name
*
* @param string $name Constant Name
* @return \FML\Script\ScriptConstant
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* Set the Value
*
* @param string $value Constant Value
* @return \FML\Script\ScriptConstant
*/
public function setValue($value) {
$this->value = $value;
return $this;
}
/**
* Build the Script Constant Text
*
* @return string
*/
public function __toString() {
$scriptText = Builder::getConstant($this->name, $this->value);
return $scriptText;
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace FML\Script;
/**
* Class representing a Function of the ManiaLink Script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptFunction {
/*
* Protected Properties
*/
protected $name = null;
protected $text = null;
/**
* Construct a new Script Function
*
* @param string $name (optional) Function Name
* @param string $text (optional) Function Text
*/
public function __construct($name = null, $text = null) {
$this->setName($name);
$this->setText($text);
}
/**
* Set the Name
*
* @param string $name Function Name
* @return \FML\Script\ScriptFunction
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Text
*
* @param string $text Function Text
* @return \FML\Script\ScriptFunction
*/
public function setText($text) {
$this->text = (string) $text;
return $this;
}
/**
* Get the Script Function Text
*
* @return string
*/
public function __toString() {
return $this->text;
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace FML\Script;
/**
* Class representing an Include of the ManiaLink Script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptInclude {
/*
* Constants
*/
const MATHLIB = 'MathLib';
const TEXTLIB = 'TextLib';
/*
* Protected Properties
*/
protected $file = null;
protected $namespace = null;
/**
* Construct a new Script Include
*
* @param string $file (optional) Include File
* @param string $namespace (optional) Include Namespace
*/
public function __construct($file = null, $namespace = null) {
$this->setFile($file);
if ($namespace) {
$this->setNamespace($namespace);
}
else {
$fileParts = explode('.', $file);
if (count($fileParts) === 1) {
$this->setNamespace($file);
}
}
}
/**
* Set the File
*
* @param string $file Include File
* @return \FML\Script\ScriptInclude
*/
public function setFile($file) {
$this->file = $file;
return $this;
}
/**
* Set the Namespace
*
* @param string $namespace Include Namespace
* @return \FML\Script\ScriptInclude
*/
public function setNamespace($namespace) {
$this->namespace = $namespace;
return $this;
}
/**
* Get the Namespace
*
* @return string
*/
public function getNamespace() {
return $this->namespace;
}
/**
* Build the Script Include Text
*
* @return string
*/
public function __toString() {
$scriptText = Builder::getInclude($this->file, $this->namespace);
return $scriptText;
}
}

View File

@ -0,0 +1,87 @@
<?php
namespace FML\Script;
/**
* Class representing a Part of the ManiaLink Script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptLabel {
/*
* Constants
*/
const ONINIT = 'FML_OnInit';
const LOOP = 'FML_Loop';
const TICK = 'FML_Tick';
const ENTRYSUBMIT = 'FML_EntrySubmit';
const KEYPRESS = 'FML_KeyPress';
const MOUSECLICK = 'FML_MouseClick';
const MOUSEOUT = 'FML_MouseOut';
const MOUSEOVER = 'FML_MouseOver';
/*
* Protected Properties
*/
protected $name = null;
protected $text = null;
protected $isolated = null;
/**
* Construct a new ScriptLabel
*
* @param string $name (optional) Label Name
* @param string $text (optional) Script Text
* @param bool $isolated (optional) Isolate the Label Script
*/
public function __construct($name = self::LOOP, $text = '', $isolated = false) {
$this->setName($name);
$this->setText($text);
$this->setIsolated($isolated);
}
/**
* Set the Name
*
* @param string $name Label Name
* @return \FML\Script\ScriptLabel
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Text
*
* @param string $text Script Text
* @return \FML\Script\ScriptLabel
*/
public function setText($text) {
$this->text = (string) $text;
return $this;
}
/**
* Set Isolation
*
* @param bool $isolated Whether the Code should be isolated in an own Block
* @return \FML\Script\ScriptLabel
*/
public function setIsolated($isolated) {
$this->isolated = (bool) $isolated;
return $this;
}
/**
* Build the full Script Label Text
*
* @return string
*/
public function __toString() {
$scriptText = Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated);
return $scriptText;
}
}