fml update (1.2 final)
This commit is contained in:
@ -5,7 +5,7 @@ namespace FML\Script;
|
||||
/**
|
||||
* Builder Class offering Methods to build ManiaScript
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
@ -111,11 +111,18 @@ abstract class Builder {
|
||||
* Get the Include Command for the given File and Namespace
|
||||
*
|
||||
* @param string $file Include File
|
||||
* @param string $namespace Include Namespace
|
||||
* @param string $namespace (optional) Include Namespace
|
||||
* @return string
|
||||
*/
|
||||
public static function getInclude($file, $namespace) {
|
||||
$includeText = "#Include \"{$file}\" as {$namespace}" . PHP_EOL;
|
||||
public static function getInclude($file, $namespace = null) {
|
||||
if (!$namespace && stripos($file, '.') === false) {
|
||||
$namespace = $file;
|
||||
}
|
||||
$includeText = "#Include \"{$file}\"";
|
||||
if ($namespace) {
|
||||
$includeText .= " as {$namespace}";
|
||||
}
|
||||
$includeText .= PHP_EOL;
|
||||
return $includeText;
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,14 @@ class CheckBoxFeature extends ScriptFeature {
|
||||
/**
|
||||
* Construct a new CheckBox Feature
|
||||
*
|
||||
* @param Quad $quad (optional) CheckBox Quad
|
||||
* @param Entry $entry (optional) Hidden Entry
|
||||
* @param Quad $quad (optional) CheckBox Quad
|
||||
* @param Entry $entry (optional) Hidden Entry
|
||||
* @param bool $default (optional) Default Value
|
||||
*/
|
||||
public function __construct(Quad $quad = null, Entry $entry = null, $default = null) {
|
||||
$this->setQuad($quad);
|
||||
$this->setEntry($entry);
|
||||
$this->setDefault($default);
|
||||
$this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign());
|
||||
$this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign());
|
||||
}
|
||||
|
@ -44,10 +44,8 @@ class ControlScript extends ScriptFeature {
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
$this->updateScriptEvents();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -70,14 +68,31 @@ class ControlScript extends ScriptFeature {
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = $labelName;
|
||||
$this->updateScriptEvents();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Script Events on the Control if needed
|
||||
*/
|
||||
protected function updateScriptEvents() {
|
||||
if (!$this->control) {
|
||||
return;
|
||||
}
|
||||
if (!ScriptLabel::isEventLabel($this->labelName)) {
|
||||
return;
|
||||
}
|
||||
if ($this->control instanceof Scriptable) {
|
||||
$this->control->setScriptEvents(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
$script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), true);
|
||||
$isolated = !ScriptLabel::isEventLabel($this->labelName);
|
||||
$script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), $isolated);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,8 @@ class EntrySubmit extends ScriptFeature {
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
$script->setScriptInclude(ScriptInclude::TEXTLIB);
|
||||
$script->appendGenericScriptLabel(ScriptLabel::ENTRYSUBMIT, $this->getScriptText());
|
||||
$controlScript = new ControlScript($this->entry, $this->getScriptText(), ScriptLabel::ENTRYSUBMIT);
|
||||
$controlScript->prepare($script);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -73,15 +74,12 @@ class EntrySubmit extends ScriptFeature {
|
||||
* @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);
|
||||
}";
|
||||
declare Value = TextLib::URLEncode(Entry.Value);
|
||||
OpenLink(\"{$url}{$entryName}=\"^Value, CMlScript::LinkType::Goto);
|
||||
";
|
||||
return $scriptText;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ use FML\Types\Scriptable;
|
||||
/**
|
||||
* An Element for the Menu Feature
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ use FML\Script\ScriptLabel;
|
||||
/**
|
||||
* Script Feature realising a Mechanism for browsing through Pages
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ use FML\Types\Scriptable;
|
||||
/**
|
||||
* A Button for browsing through Pages
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -7,7 +7,7 @@ use FML\Controls\Control;
|
||||
/**
|
||||
* A Page Control
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@ use FML\Types\Scriptable;
|
||||
/**
|
||||
* Script Feature for opening a Player Profile
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ use FML\Types\ScriptFeatureable;
|
||||
/**
|
||||
* ManiaLink Script Feature Class
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@ use FML\Types\Scriptable;
|
||||
/**
|
||||
* Script Feature for toggling Controls
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ use FML\Types\Scriptable;
|
||||
/**
|
||||
* Script Feature for Showing Tooltips
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@ use FML\Types\Scriptable;
|
||||
/**
|
||||
* Script Feature for playing an UI Sound
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ use FML\Script\ScriptLabel;
|
||||
/**
|
||||
* Script Feature for creating a ValuePicker Behavior
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
@ -50,29 +50,6 @@ class ValuePickerFeature extends ScriptFeature {
|
||||
$this->setDefault($default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the possible Values
|
||||
*
|
||||
* @param array $values Possible Values
|
||||
* @return \FML\Script\Features\ValuePickerFeature
|
||||
*/
|
||||
public function setValues(array $values) {
|
||||
$this->values = array();
|
||||
foreach ($values as $value) {
|
||||
array_push($this->values, (string)$value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ValuePicker Label
|
||||
*
|
||||
* @return \FML\Controls\Label
|
||||
*/
|
||||
public function getLabel() {
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ValuePicker Label
|
||||
*
|
||||
@ -89,12 +66,12 @@ class ValuePickerFeature extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hidden Entry
|
||||
* Get the ValuePicker Label
|
||||
*
|
||||
* @return \FML\Controls\Entry
|
||||
* @return \FML\Controls\Label
|
||||
*/
|
||||
public function getEntry() {
|
||||
return $this->entry;
|
||||
public function getLabel() {
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,6 +88,54 @@ class ValuePickerFeature extends ScriptFeature {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hidden Entry
|
||||
*
|
||||
* @return \FML\Controls\Entry
|
||||
*/
|
||||
public function getEntry() {
|
||||
return $this->entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the possible Values
|
||||
*
|
||||
* @param array $values Possible Values
|
||||
* @return \FML\Script\Features\ValuePickerFeature
|
||||
*/
|
||||
public function setValues(array $values) {
|
||||
$this->values = array();
|
||||
foreach ($values as $value) {
|
||||
array_push($this->values, (string)$value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default Value
|
||||
*
|
||||
* @param string $default Default Value
|
||||
* @return \FML\Script\Features\ValuePickerFeature
|
||||
*/
|
||||
public function setDefault($default) {
|
||||
$this->default = (string)$default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default Value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefault() {
|
||||
if ($this->default) {
|
||||
return $this->default;
|
||||
}
|
||||
if ($this->values) {
|
||||
return reset($this->values);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
@ -186,31 +211,6 @@ EntryId = \"{$entryId}\";
|
||||
return $scriptText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default Value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefault() {
|
||||
if ($this->default) {
|
||||
return $this->default;
|
||||
}
|
||||
if ($this->values) {
|
||||
return reset($this->values);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default Value
|
||||
*
|
||||
* @param string $default Default Value
|
||||
* @return \FML\Script\Features\ValuePickerFeature
|
||||
*/
|
||||
public function setDefault($default) {
|
||||
$this->default = (string)$default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Script Text for Label Clicks
|
||||
*
|
||||
|
@ -7,7 +7,7 @@ use FML\Script\Features\ScriptFeature;
|
||||
/**
|
||||
* Class representing the ManiaLink Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@ namespace FML\Script;
|
||||
/**
|
||||
* Class representing a Constant of the ManiaLink Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@ namespace FML\Script;
|
||||
/**
|
||||
* Class representing a Function of the ManiaLink Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
@ -30,14 +30,7 @@ class ScriptInclude {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
$this->setNamespace($namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,7 +40,7 @@ class ScriptInclude {
|
||||
* @return \FML\Script\ScriptInclude
|
||||
*/
|
||||
public function setFile($file) {
|
||||
$this->file = $file;
|
||||
$this->file = (string)$file;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -58,7 +51,7 @@ class ScriptInclude {
|
||||
* @return \FML\Script\ScriptInclude
|
||||
*/
|
||||
public function setNamespace($namespace) {
|
||||
$this->namespace = $namespace;
|
||||
$this->namespace = (string)$namespace;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ namespace FML\Script;
|
||||
/**
|
||||
* Class representing a Part of the ManiaLink Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
Reference in New Issue
Block a user