FML 1.2
This commit is contained in:
@ -3,32 +3,33 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for triggering a Page Action
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ActionTrigger extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $actionName = null;
|
||||
/** @var Control $control */
|
||||
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
|
||||
* @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);
|
||||
@ -49,13 +50,15 @@ class ActionTrigger extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Control
|
||||
*
|
||||
*
|
||||
* @param Control $control Action Control
|
||||
* @return \FML\Script\Features\ActionTrigger
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -72,7 +75,6 @@ class ActionTrigger extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -89,13 +91,12 @@ class ActionTrigger extends ScriptFeature {
|
||||
$actionName = Builder::escapeText($this->actionName);
|
||||
if ($this->control) {
|
||||
// Control event
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
TriggerPageAction(\"{$actionName}\");
|
||||
}";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Other
|
||||
$scriptText = "
|
||||
TriggerPageAction(\"{$actionName}\");";
|
||||
|
203
application/core/Libs/FML/Script/Features/CheckBoxFeature.php
Normal file
203
application/core/Libs/FML/Script/Features/CheckBoxFeature.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Entry;
|
||||
use FML\Controls\Quad;
|
||||
use FML\Models\CheckBoxDesign;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptInclude;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
/**
|
||||
* Script Feature for creating a CheckBox Behavior
|
||||
*
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CheckBoxFeature extends ScriptFeature {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const FUNCTION_UPDATE_QUAD_DESIGN = 'FML_UpdateQuadDesign';
|
||||
const VAR_CHECKBOX_ENABLED = 'FML_CheckBox_Enabled';
|
||||
const VAR_CHECKBOX_DESIGNS = 'FML_CheckBox_Designs';
|
||||
const VAR_CHECKBOX_ENTRY_ID = 'FML_CheckBox_EntryId';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Quad $quad */
|
||||
protected $quad = null;
|
||||
/** @var Entry $entry */
|
||||
protected $entry = null;
|
||||
/** @var CheckBoxDesign $enabledDesign */
|
||||
protected $enabledDesign = null;
|
||||
/** @var CheckBoxDesign $disabledDesign */
|
||||
protected $disabledDesign = null;
|
||||
|
||||
/**
|
||||
* Construct a new CheckBox Feature
|
||||
*
|
||||
* @param Quad $quad (optional) CheckBox Quad
|
||||
* @param Entry $entry (optional) Hidden Entry
|
||||
*/
|
||||
public function __construct(Quad $quad = null, Entry $entry = null) {
|
||||
$this->setQuad($quad);
|
||||
$this->setEntry($entry);
|
||||
$this->setEnabledDesign(CheckBoxDesign::defaultEnabledDesign());
|
||||
$this->setDisabledDesign(CheckBoxDesign::defaultDisabledDesign());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CheckBox Quad
|
||||
*
|
||||
* @param Quad $quad CheckBox Quad
|
||||
* @return \FML\Script\Features\CheckBoxFeature
|
||||
*/
|
||||
public function setQuad(Quad $quad = null) {
|
||||
if ($quad) {
|
||||
$quad->checkId();
|
||||
$quad->setScriptEvents(true);
|
||||
}
|
||||
$this->quad = $quad;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CheckBox Quad
|
||||
*
|
||||
* @return \FML\Controls\Quad
|
||||
*/
|
||||
public function getQuad() {
|
||||
return $this->quad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CheckBox Entry
|
||||
*
|
||||
* @param Entry $entry CheckBox Entry
|
||||
* @return \FML\Script\Features\CheckBoxFeature
|
||||
*/
|
||||
public function setEntry(Entry $entry = null) {
|
||||
if ($entry) {
|
||||
$entry->checkId();
|
||||
}
|
||||
$this->entry = $entry;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Enabled Design
|
||||
*
|
||||
* @param CheckBoxDesign $checkBoxDesign CheckBox Design
|
||||
* @return \FML\Script\Features\CheckBoxFeature
|
||||
*/
|
||||
public function setEnabledDesign(CheckBoxDesign $checkBoxDesign) {
|
||||
$this->enabledDesign = $checkBoxDesign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Disabled Design
|
||||
*
|
||||
* @param CheckBoxDesign $checkBoxDesign CheckBox Design
|
||||
* @return \FML\Script\Features\CheckBoxFeature
|
||||
*/
|
||||
public function setDisabledDesign(CheckBoxDesign $checkBoxDesign) {
|
||||
$this->disabledDesign = $checkBoxDesign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
if ($this->getQuad()) {
|
||||
$script->setScriptInclude(ScriptInclude::TEXTLIB);
|
||||
$script->addScriptFunction(self::FUNCTION_UPDATE_QUAD_DESIGN, $this->buildSetQuadDesignFunction());
|
||||
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true);
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText());
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Function Text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildSetQuadDesignFunction() {
|
||||
$functionText = "
|
||||
Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
|
||||
declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True;
|
||||
Enabled = !Enabled;
|
||||
declare " . self::VAR_CHECKBOX_DESIGNS . " as Designs for _Quad = Text[Boolean];
|
||||
declare Design = Designs[Enabled];
|
||||
declare DesignParts = TextLib::Split(\"|\", Design);
|
||||
if (DesignParts.count > 1) {
|
||||
_Quad.Style = DesignParts[0];
|
||||
_Quad.Substyle = DesignParts[1];
|
||||
} else {
|
||||
_Quad.ImageUrl = Design;
|
||||
}
|
||||
declare " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for _Quad = \"\";
|
||||
if (EntryId != \"\") {
|
||||
declare Value = \"0\";
|
||||
if (Enabled) {
|
||||
Value = \"1\";
|
||||
}
|
||||
declare Entry <=> (Page.GetFirstChild(EntryId) as CMlEntry);
|
||||
Entry.Value = Value;
|
||||
}
|
||||
}";
|
||||
return $functionText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Init Script Text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildInitScriptText() {
|
||||
$quadId = $this->getQuad()->getId(true);
|
||||
$default = true;
|
||||
$entryId = '';
|
||||
if ($this->entry) {
|
||||
$default = $this->entry->getDefault();
|
||||
$entryId = $this->entry->getId(true);
|
||||
}
|
||||
$default = Builder::getBoolean($default);
|
||||
$enabledDesignString = $this->enabledDesign->getDesignString();
|
||||
$disabledDesignString = $this->disabledDesign->getDesignString();
|
||||
$scriptText = "
|
||||
declare Quad_CheckBox <=> (Page.GetFirstChild(\"{$quadId}\") as CMlQuad);
|
||||
declare Text[Boolean] " . self::VAR_CHECKBOX_DESIGNS . " as Designs for Quad_CheckBox;
|
||||
Designs[True] = \"{$enabledDesignString}\";
|
||||
Designs[False] = \"{$disabledDesignString}\";
|
||||
declare Boolean " . self::VAR_CHECKBOX_ENABLED . " as Enabled for Quad_CheckBox;
|
||||
Enabled = {$default};
|
||||
declare Text " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for Quad_CheckBox;
|
||||
EntryId = \"{$entryId}\";
|
||||
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);
|
||||
";
|
||||
return $scriptText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Script Text for Quad Clicks
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildClickScriptText() {
|
||||
$quadId = $this->getQuad()->getId(true);
|
||||
$scriptText = "
|
||||
if (Event.ControlId == \"{$quadId}\") {
|
||||
declare Quad_CheckBox <=> (Event.Control as CMlQuad);
|
||||
" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);
|
||||
}";
|
||||
return $scriptText;
|
||||
}
|
||||
}
|
@ -2,25 +2,23 @@
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
|
||||
use FML\Controls\Label;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptInclude;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
/**
|
||||
* Script Feature showing the current Time on a Label
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Clock extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Label $label */
|
||||
protected $label = null;
|
||||
protected $showSeconds = null;
|
||||
protected $showFullDate = null;
|
||||
@ -28,9 +26,9 @@ class Clock extends ScriptFeature {
|
||||
/**
|
||||
* 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
|
||||
* @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);
|
||||
@ -57,7 +55,7 @@ class Clock extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Clock
|
||||
*/
|
||||
public function setShowSeconds($showSeconds) {
|
||||
$this->showSeconds = (bool) $showSeconds;
|
||||
$this->showSeconds = (bool)$showSeconds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -68,12 +66,11 @@ class Clock extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Clock
|
||||
*/
|
||||
public function setShowFullDate($showFullDate) {
|
||||
$this->showFullDate = (bool) $showFullDate;
|
||||
$this->showFullDate = (bool)$showFullDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -88,7 +85,7 @@ class Clock extends ScriptFeature {
|
||||
* @return string
|
||||
*/
|
||||
protected function getScriptText() {
|
||||
$controlId = $this->label->getId(true);
|
||||
$controlId = $this->label->getId(true);
|
||||
$scriptText = "
|
||||
declare ClockLabel <=> (Page.GetFirstChild(\"{$controlId}\") as CMlLabel);
|
||||
declare TimeText = CurrentLocalDateText;";
|
||||
|
111
application/core/Libs/FML/Script/Features/ControlScript.php
Normal file
111
application/core/Libs/FML/Script/Features/ControlScript.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for a Control-related Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ControlScript extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Control $control */
|
||||
protected $control = null;
|
||||
protected $labelName = null;
|
||||
protected $text = null;
|
||||
protected $isolated = null;
|
||||
|
||||
/**
|
||||
* Construct a new Custom Script Text
|
||||
*
|
||||
* @param Control $control Event Control
|
||||
* @param string $text Script Text
|
||||
* @param string $labelName (optional) Script Label Name
|
||||
* @param bool $isolated (optional) Whether to isolate the Script Text
|
||||
*/
|
||||
public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK, $isolated = true) {
|
||||
$this->setControl($control);
|
||||
$this->setText($text);
|
||||
$this->setLabelName($labelName);
|
||||
$this->setIsolated($isolated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Control
|
||||
*
|
||||
* @param Control $control Custom Control
|
||||
* @return \FML\Script\Features\ControlScript
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Script Text
|
||||
*
|
||||
* @param string $text Script Text
|
||||
* @return \FML\Script\Features\ControlScript
|
||||
*/
|
||||
public function setText($text) {
|
||||
$this->text = (string)$text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Label Name
|
||||
*
|
||||
* @param string $labelName Script Label Name
|
||||
* @return \FML\Script\Features\ControlScript
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = $labelName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the Script should be isolated
|
||||
*
|
||||
* @param bool $isolated Whether to isolate the Script Text
|
||||
* @return \FML\Script\Features\ControlScript
|
||||
*/
|
||||
public function setIsolated($isolated = true) {
|
||||
$this->isolated = (bool)$isolated;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
$script->appendGenericScriptLabel($this->labelName, $this->getEncapsulatedText(), $this->isolated);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Script Text encapsulated for the Control Event
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEncapsulatedText() {
|
||||
$controlId = $this->control->getId(true);
|
||||
$scriptText = "
|
||||
if (Event.ControlId == \"{$controlId}\") {
|
||||
{$this->text}
|
||||
}";
|
||||
return $scriptText;
|
||||
}
|
||||
}
|
@ -2,34 +2,32 @@
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
|
||||
use FML\Controls\Entry;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptInclude;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
/**
|
||||
* Script Feature for submitting an Entry
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class EntrySubmit extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Entry $entry */
|
||||
protected $entry = null;
|
||||
protected $url = null;
|
||||
|
||||
/**
|
||||
* Construct a new Entry Submit Feature
|
||||
*
|
||||
* @param Entry $entry (optional) Entry Control
|
||||
* @param string $url (optional) Submit Url
|
||||
* @param Entry $entry (optional) Entry Control
|
||||
* @param string $url (optional) Submit Url
|
||||
*/
|
||||
public function __construct(Entry $entry = null, $url = null) {
|
||||
$this->setEntry($entry);
|
||||
@ -56,12 +54,11 @@ class EntrySubmit extends ScriptFeature {
|
||||
* @return \FML\Script\Features\EntrySubmit
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
$this->url = (string) $url;
|
||||
$this->url = (string)$url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -76,9 +73,9 @@ class EntrySubmit extends ScriptFeature {
|
||||
* @return string
|
||||
*/
|
||||
protected function getScriptText() {
|
||||
$controlId = $this->entry->getId(true);
|
||||
$url = $this->buildCompatibleUrl();
|
||||
$entryName = Builder::escapeText($this->entry->getName());
|
||||
$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);
|
||||
@ -94,12 +91,11 @@ if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
* @return string
|
||||
*/
|
||||
protected function buildCompatibleUrl() {
|
||||
$url = $this->url;
|
||||
$url = $this->url;
|
||||
$paramsBegin = stripos($url, '?');
|
||||
if (!is_int($paramsBegin) || $paramsBegin < 0) {
|
||||
$url .= '?';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$url .= '&';
|
||||
}
|
||||
return $url;
|
||||
|
@ -2,18 +2,17 @@
|
||||
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
/**
|
||||
* Script Feature for triggering a Page Action on Key Press
|
||||
*
|
||||
* @author steeffeen
|
||||
* @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php
|
||||
*
|
||||
* @author steeffeen
|
||||
* @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class KeyAction extends ScriptFeature {
|
||||
/*
|
||||
@ -26,10 +25,10 @@ class KeyAction extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Construct a new Key Action Feature
|
||||
*
|
||||
* @param string $actionName (optional) Triggered Action
|
||||
* @param string $keyName (optional) Key Name
|
||||
* @param int $keyCode (optional) Key Code
|
||||
*
|
||||
* @param string $actionName (optional) Triggered Action
|
||||
* @param string $keyName (optional) Key Name
|
||||
* @param int $keyCode (optional) Key Code
|
||||
* @param string $charPressed (optional) Pressed Char
|
||||
*/
|
||||
public function __construct($actionName = null, $keyName = null, $keyCode = null, $charPressed = null) {
|
||||
@ -41,29 +40,29 @@ class KeyAction extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Action to trigger
|
||||
*
|
||||
*
|
||||
* @param string $actionName Triggered Action
|
||||
* @return \FML\Script\Features\KeyAction
|
||||
*/
|
||||
public function setActionName($actionName) {
|
||||
$this->actionName = (string) $actionName;
|
||||
$this->actionName = (string)$actionName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Key Name for triggering the Action
|
||||
*
|
||||
*
|
||||
* @param string $keyName Key Name
|
||||
* @return \FML\Script\Features\KeyAction
|
||||
*/
|
||||
public function setKeyName($keyName) {
|
||||
$this->keyName = (string) $keyName;
|
||||
$this->keyName = (string)$keyName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Key Code for triggering the Action
|
||||
*
|
||||
*
|
||||
* @param int $keyCode Key Code
|
||||
* @return \FML\Script\Features\KeyAction
|
||||
*/
|
||||
@ -74,7 +73,7 @@ class KeyAction extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Char to press for triggering the Action
|
||||
*
|
||||
*
|
||||
* @param string $charPressed Pressed Char
|
||||
* @return \FML\Script\Features\KeyAction
|
||||
*/
|
||||
@ -84,7 +83,6 @@ class KeyAction extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -94,20 +92,19 @@ class KeyAction extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Get the Script Text
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getScriptText() {
|
||||
$actionName = Builder::escapeText($this->actionName);
|
||||
$key = 'KeyName';
|
||||
$value = $this->keyName;
|
||||
$key = 'KeyName';
|
||||
$value = $this->keyName;
|
||||
if ($this->keyCode !== null) {
|
||||
$key = 'KeyCode';
|
||||
$value = (int) $this->keyCode;
|
||||
}
|
||||
else if ($this->charPressed !== null) {
|
||||
$key = 'CharPressed';
|
||||
$value = (string) $this->charPressed;
|
||||
$key = 'KeyCode';
|
||||
$value = (int)$this->keyCode;
|
||||
} else if ($this->charPressed !== null) {
|
||||
$key = 'CharPressed';
|
||||
$value = (string)$this->charPressed;
|
||||
}
|
||||
$scriptText = "
|
||||
if (Event.{$key} == \"{$value}\") {
|
||||
|
@ -3,30 +3,31 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for opening the Map Info
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class MapInfo extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Control $control */
|
||||
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
|
||||
* @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);
|
||||
@ -36,12 +37,14 @@ class MapInfo extends ScriptFeature {
|
||||
/**
|
||||
* Set the Control
|
||||
*
|
||||
* @param Control $control Action Control
|
||||
* @return \FML\Script\Features\ActionTrigger
|
||||
* @param Control $control Map Info Control
|
||||
* @return \FML\Script\Features\MapInfo
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -50,7 +53,7 @@ class MapInfo extends ScriptFeature {
|
||||
* Set the Label Name
|
||||
*
|
||||
* @param string $labelName Script Label Name
|
||||
* @return \FML\Script\Features\ActionTrigger
|
||||
* @return \FML\Script\Features\MapInfo
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = $labelName;
|
||||
@ -58,7 +61,6 @@ class MapInfo extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -74,13 +76,12 @@ class MapInfo extends ScriptFeature {
|
||||
protected function getScriptText() {
|
||||
if ($this->control) {
|
||||
// Control event
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
ShowCurChallengeCard();
|
||||
}";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Other
|
||||
$scriptText = "
|
||||
ShowCurChallengeCard();";
|
||||
|
@ -3,48 +3,48 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
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
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @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();
|
||||
/** @var MenuElement $startElement */
|
||||
protected $startElement = null;
|
||||
|
||||
/**
|
||||
* Construct a new Menu Feature
|
||||
*
|
||||
* @param Control $item (optional) Item Control in the Menu Bar
|
||||
* @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);
|
||||
$this->addElement($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
|
||||
* @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) {
|
||||
@ -56,16 +56,15 @@ class Menu extends ScriptFeature {
|
||||
/**
|
||||
* Append an Element to the Menu
|
||||
*
|
||||
* @param MenuElement $menuElement Menu Element
|
||||
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
|
||||
* @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) {
|
||||
} else if (count($this->elements) > 1) {
|
||||
$menuElement->getControl()->setVisible(false);
|
||||
}
|
||||
return $this;
|
||||
@ -86,13 +85,12 @@ class Menu extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
$updateFunctionName = self::FUNCTION_UPDATE_MENU;
|
||||
$elementsArrayText = $this->getElementsArrayText();
|
||||
|
||||
$elementsArrayText = $this->getElementsArrayText();
|
||||
|
||||
// OnInit
|
||||
if ($this->startElement) {
|
||||
$startControlId = $this->startElement->getControl()->getId(true);
|
||||
@ -100,7 +98,7 @@ class Menu extends ScriptFeature {
|
||||
{$updateFunctionName}({$elementsArrayText}, \"{$startControlId}\");";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
|
||||
}
|
||||
|
||||
|
||||
// MouseClick
|
||||
$scriptText = "
|
||||
declare MenuElements = {$elementsArrayText};
|
||||
@ -109,7 +107,7 @@ if (MenuElements.existskey(Event.Control.ControlId)) {
|
||||
{$updateFunctionName}(MenuElements, ShownControlId);
|
||||
}";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true);
|
||||
|
||||
|
||||
// Update menu function
|
||||
$updateFunctionText = "
|
||||
Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
|
||||
@ -119,7 +117,7 @@ Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
|
||||
}
|
||||
}";
|
||||
$script->addScriptFunction($updateFunctionName, $updateFunctionText);
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -131,7 +129,9 @@ Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
|
||||
protected function getElementsArrayText() {
|
||||
$elements = array();
|
||||
foreach ($this->elements as $element) {
|
||||
$elements[$element->getItem()->getId()] = $element->getControl()->getId();
|
||||
/** @var MenuElement $element */
|
||||
$elementId = $element->getItem()->getId();
|
||||
$elements[$elementId] = $element->getControl()->getId();
|
||||
}
|
||||
return Builder::getArray($elements, true);
|
||||
}
|
||||
|
@ -3,13 +3,14 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* An Element for the Menu Feature
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class MenuElement {
|
||||
/*
|
||||
@ -21,7 +22,7 @@ class MenuElement {
|
||||
/**
|
||||
* Create a new Menu Element
|
||||
*
|
||||
* @param Control $item (optional) Item Control in the Menu Bar
|
||||
* @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) {
|
||||
@ -37,7 +38,9 @@ class MenuElement {
|
||||
*/
|
||||
public function setItem(Control $item) {
|
||||
$item->checkId();
|
||||
$item->setScriptEvents(true);
|
||||
if ($item instanceof Scriptable) {
|
||||
$item->setScriptEvents(true);
|
||||
}
|
||||
$this->item = $item;
|
||||
return $this;
|
||||
}
|
||||
|
@ -3,31 +3,32 @@
|
||||
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\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptInclude;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
/**
|
||||
* Script Feature realising a Mechanism for browsing through Pages
|
||||
*
|
||||
* @author steeffeen
|
||||
*
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @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 VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage';
|
||||
const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage';
|
||||
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $pages = array();
|
||||
protected $buttons = array();
|
||||
/** @var Label $label */
|
||||
protected $label = null;
|
||||
protected $startPageNumber = null;
|
||||
protected $customMaxPageNumber = null;
|
||||
@ -37,7 +38,7 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Construct a new Paging Script Feature
|
||||
*
|
||||
*
|
||||
* @param Label $label (optional) Page Number Label
|
||||
*/
|
||||
public function __construct(Label $label = null) {
|
||||
@ -48,9 +49,9 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Add a new Page Control
|
||||
*
|
||||
*
|
||||
* @param Control $pageControl Page Control
|
||||
* @param string $pageNumber (optional) Page Number
|
||||
* @param string $pageNumber (optional) Page Number
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function addPage(Control $pageControl, $pageNumber = null) {
|
||||
@ -64,7 +65,7 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Append a Page
|
||||
*
|
||||
*
|
||||
* @param PagingPage $page Paging Page
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
@ -75,9 +76,9 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param int $browseAction (optional) Number of browsed Pages per Click
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function addButton(Control $buttonControl, $browseAction = null) {
|
||||
@ -85,8 +86,7 @@ class Paging extends ScriptFeature {
|
||||
$buttonCount = count($this->buttons);
|
||||
if ($buttonCount % 2 === 0) {
|
||||
$browseAction = $buttonCount / 2 + 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$browseAction = $buttonCount / -2 - 1;
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Append a Button to browse through Pages
|
||||
*
|
||||
*
|
||||
* @param PagingButton $button Paging Button
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
@ -108,7 +108,7 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Label showing the Page Number
|
||||
*
|
||||
*
|
||||
* @param Label $label Page Number Label
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
@ -120,50 +120,50 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* Set the Start Page Number
|
||||
*
|
||||
*
|
||||
* @param int $startPageNumber Page Number to start with
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
public function setStartPageNumber($startPageNumber) {
|
||||
$this->startPageNumber = (int) $startPageNumber;
|
||||
$this->startPageNumber = (int)$startPageNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
$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;
|
||||
$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;
|
||||
$this->nextChunkAction = (string)$nextChunkAction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Actions triggered when another Chunk is needed
|
||||
*
|
||||
*
|
||||
* @param string $chunkAction Triggered Action
|
||||
* @return \FML\Script\Features\Paging
|
||||
*/
|
||||
@ -175,18 +175,16 @@ class Paging extends ScriptFeature {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
$this->chunkActionAppendsPageNumber = (bool)$appendPageNumber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -194,37 +192,37 @@ class Paging extends ScriptFeature {
|
||||
return $this;
|
||||
}
|
||||
$script->setScriptInclude(ScriptInclude::TEXTLIB);
|
||||
|
||||
|
||||
$currentPageVariable = self::VAR_CURRENT_PAGE;
|
||||
$updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE;
|
||||
|
||||
$minPageNumber = 1;
|
||||
$updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE;
|
||||
|
||||
$minPageNumber = 1;
|
||||
$startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber);
|
||||
$maxPage = $this->getMaxPage();
|
||||
$maxPageNumber = $this->customMaxPageNumber;
|
||||
$maxPage = $this->getMaxPage();
|
||||
$maxPageNumber = $this->customMaxPageNumber;
|
||||
if (!is_int($maxPageNumber)) {
|
||||
$maxPageNumber = $maxPage->getPageNumber();
|
||||
}
|
||||
|
||||
$pagingId = $maxPage->getControl()->getId(true);
|
||||
|
||||
$pagingId = $maxPage->getControl()->getId(true);
|
||||
$pageLabelId = '';
|
||||
if ($this->label) {
|
||||
$pageLabelId = $this->label->getId(true);
|
||||
}
|
||||
$pagesArrayText = $this->getPagesArrayText();
|
||||
$pagesArrayText = $this->getPagesArrayText();
|
||||
$pageButtonsArrayText = $this->getPageButtonsArrayText();
|
||||
|
||||
$previousChunkAction = Builder::escapeText($this->previousChunkAction);
|
||||
$nextChunkAction = Builder::escapeText($this->nextChunkAction);
|
||||
|
||||
$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};
|
||||
@ -233,7 +231,7 @@ if (PageButtons.existskey(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) {
|
||||
@ -277,17 +275,18 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
|
||||
/**
|
||||
* Get the minimum Page
|
||||
*
|
||||
*
|
||||
* @return \FML\Script\Features\PagingPage
|
||||
*/
|
||||
protected function getMinPage() {
|
||||
$minPageNumber = null;
|
||||
$minPage = null;
|
||||
$minPage = null;
|
||||
foreach ($this->pages as $page) {
|
||||
/** @var PagingPage $page */
|
||||
$pageNumber = $page->getPageNumber();
|
||||
if ($minPageNumber === null || $pageNumber < $minPageNumber) {
|
||||
$minPageNumber = $pageNumber;
|
||||
$minPage = $page;
|
||||
$minPage = $page;
|
||||
}
|
||||
}
|
||||
return $minPage;
|
||||
@ -295,17 +294,18 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
|
||||
/**
|
||||
* Get the maximum Page
|
||||
*
|
||||
*
|
||||
* @return \FML\Script\Features\PagingPage
|
||||
*/
|
||||
protected function getMaxPage() {
|
||||
$maxPageNumber = null;
|
||||
$maxPage = null;
|
||||
$maxPage = null;
|
||||
foreach ($this->pages as $page) {
|
||||
/** @var PagingPage $page */
|
||||
$pageNumber = $page->getPageNumber();
|
||||
if ($maxPageNumber === null || $pageNumber > $maxPageNumber) {
|
||||
$maxPageNumber = $pageNumber;
|
||||
$maxPage = $page;
|
||||
$maxPage = $page;
|
||||
}
|
||||
}
|
||||
return $maxPage;
|
||||
@ -313,20 +313,22 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
|
||||
/**
|
||||
* 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();
|
||||
/** @var PagingPage $page */
|
||||
$pageNumber = $page->getPageNumber();
|
||||
$pages[$pageNumber] = $page->getControl()->getId();
|
||||
}
|
||||
return Builder::getArray($pages, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Array Text for the Page Buttons
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPageButtonsArrayText() {
|
||||
@ -335,7 +337,9 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
}
|
||||
$pageButtons = array();
|
||||
foreach ($this->buttons as $pageButton) {
|
||||
$pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction();
|
||||
/** @var PagingButton $pageButton */
|
||||
$pageButtonId = $pageButton->getControl()->getId();
|
||||
$pageButtons[$pageButtonId] = $pageButton->getBrowseAction();
|
||||
}
|
||||
return Builder::getArray($pageButtons, true);
|
||||
}
|
||||
|
@ -3,13 +3,14 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* A Button for browsing through Pages
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class PagingButton {
|
||||
/*
|
||||
@ -21,8 +22,8 @@ class PagingButton {
|
||||
/**
|
||||
* Construct a new Paging Button
|
||||
*
|
||||
* @param Control $control (optional) Browse Control
|
||||
* @param int $browseAction (optional) Number of browsed Pages per Click
|
||||
* @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);
|
||||
@ -37,7 +38,9 @@ class PagingButton {
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -58,7 +61,7 @@ class PagingButton {
|
||||
* @return \FML\Script\Features\PagingButton
|
||||
*/
|
||||
public function setBrowseAction($browseAction) {
|
||||
$this->browseAction = (int) $browseAction;
|
||||
$this->browseAction = (int)$browseAction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -3,31 +3,33 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for opening a Player Profile
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class PlayerProfile extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
protected $login = null;
|
||||
/** @var Control $control */
|
||||
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
|
||||
* @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);
|
||||
@ -54,7 +56,9 @@ class PlayerProfile extends ScriptFeature {
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -71,7 +75,6 @@ class PlayerProfile extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -88,13 +91,12 @@ class PlayerProfile extends ScriptFeature {
|
||||
$login = Builder::escapeText($this->login);
|
||||
if ($this->control) {
|
||||
// Control event
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
ShowProfile(\"{$login}\");
|
||||
}";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Other
|
||||
$scriptText = "
|
||||
ShowProfile(\"{$login}\");";
|
||||
|
@ -5,20 +5,22 @@ namespace FML\Script\Features;
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for toggling Controls
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Toggle extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Control $togglingControl */
|
||||
protected $togglingControl = null;
|
||||
/** @var Control $toggledControl */
|
||||
protected $toggledControl = null;
|
||||
protected $labelName = null;
|
||||
protected $onlyShow = null;
|
||||
@ -28,10 +30,10 @@ class Toggle extends ScriptFeature {
|
||||
* 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
|
||||
* @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);
|
||||
@ -49,7 +51,9 @@ class Toggle extends ScriptFeature {
|
||||
*/
|
||||
public function setTogglingControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->togglingControl = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -73,7 +77,7 @@ class Toggle extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Toggle
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = (string) $labelName;
|
||||
$this->labelName = (string)$labelName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -84,7 +88,7 @@ class Toggle extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Toggle
|
||||
*/
|
||||
public function setOnlyShow($onlyShow) {
|
||||
$this->onlyShow = (bool) $onlyShow;
|
||||
$this->onlyShow = (bool)$onlyShow;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -95,12 +99,11 @@ class Toggle extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Toggle
|
||||
*/
|
||||
public function setOnlyHide($onlyHide) {
|
||||
$this->onlyHide = (bool) $onlyHide;
|
||||
$this->onlyHide = (bool)$onlyHide;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -115,12 +118,11 @@ class Toggle extends ScriptFeature {
|
||||
*/
|
||||
protected function getScriptText() {
|
||||
$togglingControlId = $this->togglingControl->getId(true);
|
||||
$toggledControlId = $this->toggledControl->getId(true);
|
||||
$visibility = '!ToggleControl.Visible';
|
||||
$toggledControlId = $this->toggledControl->getId(true);
|
||||
$visibility = '!ToggleControl.Visible';
|
||||
if ($this->onlyShow) {
|
||||
$visibility = 'True';
|
||||
}
|
||||
else if ($this->onlyHide) {
|
||||
} else if ($this->onlyHide) {
|
||||
$visibility = 'False';
|
||||
}
|
||||
$scriptText = "
|
||||
|
@ -3,25 +3,26 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Controls\Label;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
|
||||
|
||||
use FML\Controls\Label;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for Showing Tooltips
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Tooltip extends ScriptFeature {
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
/** @var Control $hoverControl */
|
||||
protected $hoverControl = null;
|
||||
/** @var Control $tooltipControl */
|
||||
protected $tooltipControl = null;
|
||||
protected $stayOnClick = null;
|
||||
protected $invert = null;
|
||||
@ -30,11 +31,11 @@ class Tooltip extends ScriptFeature {
|
||||
/**
|
||||
* Construct a new Tooltip Feature
|
||||
*
|
||||
* @param Control $hoverControl (optional) Hover Control
|
||||
* @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
|
||||
* @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);
|
||||
@ -52,7 +53,9 @@ class Tooltip extends ScriptFeature {
|
||||
*/
|
||||
public function setHoverControl(Control $hoverControl) {
|
||||
$hoverControl->checkId();
|
||||
$hoverControl->setScriptEvents(true);
|
||||
if ($hoverControl instanceof Scriptable) {
|
||||
$hoverControl->setScriptEvents(true);
|
||||
}
|
||||
$this->hoverControl = $hoverControl;
|
||||
return $this;
|
||||
}
|
||||
@ -77,7 +80,7 @@ class Tooltip extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Tooltip
|
||||
*/
|
||||
public function setStayOnClick($stayOnClick) {
|
||||
$this->stayOnClick = (bool) $stayOnClick;
|
||||
$this->stayOnClick = (bool)$stayOnClick;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -88,7 +91,7 @@ class Tooltip extends ScriptFeature {
|
||||
* @return \FML\Script\Features\Tooltip
|
||||
*/
|
||||
public function setInvert($invert) {
|
||||
$this->invert = (bool) $invert;
|
||||
$this->invert = (bool)$invert;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -104,13 +107,12 @@ class Tooltip extends ScriptFeature {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
$hoverControlId = $this->hoverControl->getId(true);
|
||||
$hoverControlId = $this->hoverControl->getId(true);
|
||||
$tooltipControlId = $this->tooltipControl->getId(true);
|
||||
|
||||
|
||||
// MouseOver
|
||||
$visibility = ($this->invert ? 'False' : 'True');
|
||||
$scriptText = "
|
||||
@ -126,7 +128,7 @@ if (Event.Control.ControlId == \"{$hoverControlId}\") {
|
||||
$scriptText .= "
|
||||
}";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText);
|
||||
|
||||
|
||||
// MouseOut
|
||||
$visibility = ($this->invert ? 'True' : 'False');
|
||||
$scriptText = "
|
||||
@ -141,7 +143,7 @@ if (Event.Control.ControlId == \"{$hoverControlId}\") {
|
||||
TooltipControl.Visible = {$visibility};
|
||||
}";
|
||||
$script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText);
|
||||
|
||||
|
||||
// MouseClick
|
||||
if ($this->stayOnClick) {
|
||||
$scriptText = "
|
||||
|
@ -3,55 +3,57 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Controls\Control;
|
||||
use FML\Script\Builder;
|
||||
use FML\Script\Script;
|
||||
use FML\Script\ScriptLabel;
|
||||
use FML\Script\Builder;
|
||||
use FML\Types\Scriptable;
|
||||
|
||||
/**
|
||||
* Script Feature for playing an UI Sound
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @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 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 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';
|
||||
|
||||
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;
|
||||
/** @var Control $control */
|
||||
protected $control = null;
|
||||
protected $variant = 0;
|
||||
protected $volume = 1.;
|
||||
@ -60,10 +62,10 @@ class UISound extends ScriptFeature {
|
||||
/**
|
||||
* 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
|
||||
* @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);
|
||||
@ -79,7 +81,7 @@ class UISound extends ScriptFeature {
|
||||
* @return \FML\Script\Features\UISound
|
||||
*/
|
||||
public function setSoundName($soundName) {
|
||||
$this->soundName = (string) $soundName;
|
||||
$this->soundName = (string)$soundName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -91,7 +93,9 @@ class UISound extends ScriptFeature {
|
||||
*/
|
||||
public function setControl(Control $control) {
|
||||
$control->checkId();
|
||||
$control->setScriptEvents(true);
|
||||
if ($control instanceof Scriptable) {
|
||||
$control->setScriptEvents(true);
|
||||
}
|
||||
$this->control = $control;
|
||||
return $this;
|
||||
}
|
||||
@ -103,7 +107,7 @@ class UISound extends ScriptFeature {
|
||||
* @return \FML\Script\Features\UISound
|
||||
*/
|
||||
public function setVariant($variant) {
|
||||
$this->variant = (int) $variant;
|
||||
$this->variant = (int)$variant;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -114,7 +118,7 @@ class UISound extends ScriptFeature {
|
||||
* @return \FML\Script\Features\UISound
|
||||
*/
|
||||
public function setVolume($volume) {
|
||||
$this->volume = (float) $volume;
|
||||
$this->volume = (float)$volume;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -125,12 +129,11 @@ class UISound extends ScriptFeature {
|
||||
* @return \FML\Script\Features\UISound
|
||||
*/
|
||||
public function setLabelName($labelName) {
|
||||
$this->labelName = (string) $labelName;
|
||||
$this->labelName = (string)$labelName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Script\Features\ScriptFeature::prepare()
|
||||
*/
|
||||
public function prepare(Script $script) {
|
||||
@ -146,13 +149,12 @@ class UISound extends ScriptFeature {
|
||||
protected function getScriptText() {
|
||||
if ($this->control) {
|
||||
// Control event
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$controlId = Builder::escapeText($this->control->getId());
|
||||
$scriptText = "
|
||||
if (Event.Control.ControlId == \"{$controlId}\") {
|
||||
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});
|
||||
}";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Other
|
||||
$scriptText = "
|
||||
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});";
|
||||
|
@ -7,19 +7,19 @@ use FML\Script\Features\ScriptFeature;
|
||||
/**
|
||||
* Class representing the ManiaLink Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Script {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const TICKINTERVAL = 250;
|
||||
const TICKINTERVAL = 250;
|
||||
const VAR_ScriptStart = 'FML_ScriptStart';
|
||||
const VAR_LoopCounter = 'FML_LoopCounter';
|
||||
const VAR_LastTick = 'FML_LastTick';
|
||||
|
||||
const VAR_LastTick = 'FML_LastTick';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
@ -34,33 +34,32 @@ class Script {
|
||||
/**
|
||||
* Set a Script Include
|
||||
*
|
||||
* @param string $file Include File
|
||||
* @param string $file Include File
|
||||
* @param string $namespace Include Namespace
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function setScriptInclude($file, $namespace = null) {
|
||||
if (is_object($file) && ($file instanceof ScriptInclude)) {
|
||||
$scriptInclude = $file;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptInclude = new ScriptInclude($file, $namespace);
|
||||
}
|
||||
$this->includes[$scriptInclude->getNamespace()] = $scriptInclude;
|
||||
$namespace = $scriptInclude->getNamespace();
|
||||
$this->includes[$namespace] = $scriptInclude;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Script Constant
|
||||
*
|
||||
* @param string $name Constant Name
|
||||
* @param string $name Constant Name
|
||||
* @param string $value Constant Value
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function addScriptConstant($name, $value = null) {
|
||||
if (is_object($name) && ($name instanceof ScriptConstant)) {
|
||||
$scriptConstant = $name;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptConstant = new ScriptConstant($name, $value);
|
||||
}
|
||||
array_push($this->constants, $scriptConstant);
|
||||
@ -77,8 +76,7 @@ class Script {
|
||||
public function addScriptFunction($name, $text = null) {
|
||||
if (is_object($name) && ($name instanceof ScriptFunction)) {
|
||||
$scriptFunction = $name;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptFunction = new ScriptFunction($name, $text);
|
||||
}
|
||||
if (!in_array($scriptFunction, $this->functions)) {
|
||||
@ -97,8 +95,7 @@ class Script {
|
||||
public function addCustomScriptLabel($name, $text = null) {
|
||||
if (is_object($name) && ($name instanceof ScriptLabel)) {
|
||||
$scriptLabel = $name;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptLabel = new ScriptLabel($name, $text);
|
||||
}
|
||||
array_push($this->customLabels, $scriptLabel);
|
||||
@ -108,16 +105,15 @@ class Script {
|
||||
/**
|
||||
* Append a generic Script Text for the next Rendering
|
||||
*
|
||||
* @param string $name Label Name
|
||||
* @param string $text Script Text
|
||||
* @param bool $isolated (optional) Whether to isolate the Label Script
|
||||
* @param string $name Label Name
|
||||
* @param string $text Script Text
|
||||
* @param bool $isolated (optional) Whether to isolate the Label Script
|
||||
* @return \FML\Script\Script
|
||||
*/
|
||||
public function appendGenericScriptLabel($name, $text = null, $isolated = false) {
|
||||
if (is_object($name) && ($name instanceof ScriptLabel)) {
|
||||
$scriptLabel = $name;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scriptLabel = new ScriptLabel($name, $text, $isolated);
|
||||
}
|
||||
array_push($this->genericLabels, $scriptLabel);
|
||||
@ -205,8 +201,8 @@ class Script {
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$this->loadFeatures($this->features);
|
||||
$scriptXml = $domDocument->createElement($this->tagName);
|
||||
$scriptText = $this->buildScriptText();
|
||||
$scriptXml = $domDocument->createElement($this->tagName);
|
||||
$scriptText = $this->buildScriptText();
|
||||
$scriptComment = $domDocument->createComment($scriptText);
|
||||
$scriptXml->appendChild($scriptComment);
|
||||
return $scriptXml;
|
||||
@ -222,6 +218,7 @@ class Script {
|
||||
* FancyManiaLinks v' . FML_VERSION . ' by steeffeen *
|
||||
* http://github.com/steeffeen/FancyManiaLinks *
|
||||
****************************************************/
|
||||
|
||||
';
|
||||
return $headerComment;
|
||||
}
|
||||
@ -262,7 +259,7 @@ class Script {
|
||||
* @return string
|
||||
*/
|
||||
protected function getLabels() {
|
||||
$customLabelsText = implode(PHP_EOL, $this->customLabels);
|
||||
$customLabelsText = implode(PHP_EOL, $this->customLabels);
|
||||
$genericLabelsText = implode(PHP_EOL, $this->genericLabels);
|
||||
return $customLabelsText . $genericLabelsText;
|
||||
}
|
||||
|
@ -5,23 +5,23 @@ namespace FML\Script;
|
||||
/**
|
||||
* Class representing a Part of the ManiaLink Script
|
||||
*
|
||||
* @author steeffeen
|
||||
* @author steeffeen
|
||||
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
* @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 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';
|
||||
|
||||
const KEYPRESS = 'FML_KeyPress';
|
||||
const MOUSECLICK = 'FML_MouseClick';
|
||||
const MOUSEOUT = 'FML_MouseOut';
|
||||
const MOUSEOVER = 'FML_MouseOver';
|
||||
|
||||
/*
|
||||
* Protected Properties
|
||||
*/
|
||||
@ -32,9 +32,9 @@ class ScriptLabel {
|
||||
/**
|
||||
* Construct a new ScriptLabel
|
||||
*
|
||||
* @param string $name (optional) Label Name
|
||||
* @param string $text (optional) Script Text
|
||||
* @param bool $isolated (optional) Isolate the Label Script
|
||||
* @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);
|
||||
@ -49,7 +49,7 @@ class ScriptLabel {
|
||||
* @return \FML\Script\ScriptLabel
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = (string) $name;
|
||||
$this->name = (string)$name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class ScriptLabel {
|
||||
* @return \FML\Script\ScriptLabel
|
||||
*/
|
||||
public function setText($text) {
|
||||
$this->text = (string) $text;
|
||||
$this->text = (string)$text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ class ScriptLabel {
|
||||
* @return \FML\Script\ScriptLabel
|
||||
*/
|
||||
public function setIsolated($isolated) {
|
||||
$this->isolated = (bool) $isolated;
|
||||
$this->isolated = (bool)$isolated;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user