This commit is contained in:
Steffen Schröder 2014-05-14 23:24:00 +02:00
parent e61c6f4c11
commit d3e4fd309f
36 changed files with 1275 additions and 599 deletions

View File

@ -0,0 +1,169 @@
<?php
namespace FML\Components;
use FML\Controls\Entry;
use FML\Controls\Frame;
use FML\Controls\Quad;
use FML\Models\CheckBoxDesign;
use FML\Script\Features\CheckBoxFeature;
use FML\Types\Renderable;
use FML\Types\ScriptFeatureable;
/**
* CheckBox Component
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CheckBox implements Renderable, ScriptFeatureable {
/*
* Protected Properties
*/
protected $name = null;
protected $default = null;
protected $hiddenEntryDisabled = null;
protected $feature = null;
/**
* Create a new CheckBox Component
*
* @param string $name (optional) CheckBox Name
* @param bool $default (optional) Default Value
* @param Quad $quad (optional) CheckBox Quad
*/
public function __construct($name = null, $default = null, Quad $quad = null) {
$this->setName($name);
$this->setDefault($default);
$this->feature = new CheckBoxFeature();
$this->feature->setQuad($quad);
}
/**
* Set the Name
*
* @param string $name CheckBox Name
* @return \FML\Components\CheckBox
*/
public function setName($name) {
$this->name = (string)$name;
return $this;
}
/**
* Set the Default Value
*
* @param bool $default Default Value
* @return \FML\Components\CheckBox
*/
public function setDefault($default) {
$this->default = ($default ? 1 : 0);
return $this;
}
/**
* Disable the hidden Entry that's sending the Value on Page Actions
*
* @param bool $disable (optional) Whether to disable or not
* @return \FML\Components\CheckBox
*/
public function disableHiddenEntry($disable = true) {
$this->hiddenEntryDisabled = (bool)$disable;
return $this;
}
/**
* Set the Enabled Design
*
* @param string $style Style Name or Image Url
* @param string $subStyle SubStyle Name
* @return \FML\Components\CheckBox
*/
public function setEnabledDesign($style, $subStyle = null) {
$checkBoxDesign = new CheckBoxDesign($style, $subStyle);
$this->feature->setEnabledDesign($checkBoxDesign);
return $this;
}
/**
* Set the Disabled Design
*
* @param string $style Style Name or Image Url
* @param string $subStyle SubStyle Name
* @return \FML\Components\CheckBox
*/
public function setDisabledDesign($style, $subStyle = null) {
$checkBoxDesign = new CheckBoxDesign($style, $subStyle);
$this->feature->setDisabledDesign($checkBoxDesign);
return $this;
}
/**
* Get the CheckBox Quad
*
* @param bool $createIfEmpty (optional) Create the Quad if it's not set
* @return \FML\Controls\Quad
*/
public function getQuad($createIfEmpty = true) {
if (!$this->feature->getQuad() && $createIfEmpty) {
$quad = new Quad();
$quad->setSize(10, 10);
$quad->setScriptEvents(true);
$this->feature->setQuad($quad);
}
return $this->feature->getQuad();
}
/**
* Set the CheckBox Quad
*
* @param Quad $quad CheckBox Quad
* @return \FML\Components\CheckBox
*/
public function setQuad(Quad $quad) {
$this->feature->setQuad($quad);
return $this;
}
/**
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
*/
public function getScriptFeatures() {
return array($this->feature);
}
/**
* @see \ManiaControl\Types\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$frame = new Frame();
$frame->addScriptFeature($this->feature);
$quad = $this->getQuad();
$frame->add($quad);
if (!$this->hiddenEntryDisabled) {
$entry = $this->buildEntry();
$frame->add($entry);
$this->feature->setEntry($entry);
} else {
$this->feature->setEntry(null);
}
return $frame->render($domDocument);
}
/**
* Build the hidden Entry
*
* @return Entry
*/
protected function buildEntry() {
$entry = new Entry();
$entry->setVisible(false);
$entry->setName($this->name);
$entry->setDefault($this->default);
return $entry;
}
}

View File

@ -2,16 +2,18 @@
namespace FML\Controls; namespace FML\Controls;
use FML\Types\Renderable; use FML\Script\Builder;
use FML\Script\Features\ActionTrigger; use FML\Script\Features\ActionTrigger;
use FML\Script\ScriptLabel; use FML\Script\Features\ControlScript;
use FML\Types\ScriptFeatureable;
use FML\Script\Features\MapInfo; use FML\Script\Features\MapInfo;
use FML\Script\Features\PlayerProfile; use FML\Script\Features\PlayerProfile;
use FML\Script\Features\UISound; use FML\Script\Features\ScriptFeature;
use FML\Script\Builder;
use FML\Script\Features\Toggle; use FML\Script\Features\Toggle;
use FML\Script\Features\Tooltip; use FML\Script\Features\Tooltip;
use FML\Script\Features\UISound;
use FML\Script\ScriptLabel;
use FML\Types\Renderable;
use FML\Types\ScriptFeatureable;
/** /**
* Base Control * Base Control
@ -92,10 +94,11 @@ abstract class Control implements Renderable, ScriptFeatureable {
/** /**
* Check Id for dangerous Characters and assign a unique Id if necessary * Check Id for dangerous Characters and assign a unique Id if necessary
* *
* @param bool $forceNewId Whether to force setting a newly generated Id
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function checkId() { public function checkId($forceNewId = false) {
if (!$this->getId()) { if ($forceNewId || !$this->getId()) {
$this->setId('FML_ID_' . self::$currentIndex); $this->setId('FML_ID_' . self::$currentIndex);
self::$currentIndex++; self::$currentIndex++;
return $this; return $this;
@ -104,7 +107,9 @@ abstract class Control implements Renderable, ScriptFeatureable {
$idCharacters = str_split($this->getId()); $idCharacters = str_split($this->getId());
$danger = false; $danger = false;
foreach ($idCharacters as $character) { foreach ($idCharacters as $character) {
if (!in_array($character, $dangerousCharacters)) continue; if (!in_array($character, $dangerousCharacters)) {
continue;
}
$danger = true; $danger = true;
break; break;
} }
@ -236,6 +241,26 @@ abstract class Control implements Renderable, ScriptFeatureable {
return $this; return $this;
} }
/**
* Center Alignment
*
* @return \FML\Controls\Control
*/
public function centerAlign() {
$this->setAlign(self::CENTER, self::CENTER2);
return $this;
}
/**
* Reset Alignment
*
* @return \FML\Controls\Control
*/
public function resetAlign() {
$this->setAlign(null, null);
return $this;
}
/** /**
* Set Control Scale * Set Control Scale
* *
@ -253,7 +278,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @param bool $visible Whether Control should be visible * @param bool $visible Whether Control should be visible
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setVisible($visible) { public function setVisible($visible = true) {
$this->hidden = ($visible ? 0 : 1); $this->hidden = ($visible ? 0 : 1);
return $this; return $this;
} }
@ -281,7 +306,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/ */
public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) { public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) {
$actionTrigger = new ActionTrigger($actionName, $this, $eventLabel); $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel);
array_push($this->scriptFeatures, $actionTrigger); $this->addScriptFeature($actionTrigger);
return $this; return $this;
} }
@ -293,7 +318,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/ */
public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) { public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) {
$mapInfo = new MapInfo($this, $eventLabel); $mapInfo = new MapInfo($this, $eventLabel);
array_push($this->scriptFeatures, $mapInfo); $this->addScriptFeature($mapInfo);
return $this; return $this;
} }
@ -306,7 +331,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/ */
public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) { public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) {
$playerProfile = new PlayerProfile($login, $this, $eventLabel); $playerProfile = new PlayerProfile($login, $this, $eventLabel);
array_push($this->scriptFeatures, $playerProfile); $this->addScriptFeature($playerProfile);
return $this; return $this;
} }
@ -320,7 +345,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/ */
public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) { public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) {
$uiSound = new UISound($soundName, $this, $variant, $eventLabel); $uiSound = new UISound($soundName, $this, $variant, $eventLabel);
array_push($this->scriptFeatures, $uiSound); $this->addScriptFeature($uiSound);
return $this; return $this;
} }
@ -335,7 +360,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/ */
public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) { public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
$toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide); $toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide);
array_push($this->scriptFeatures, $toggle); $this->addScriptFeature($toggle);
return $this; return $this;
} }
@ -349,7 +374,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/ */
public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) { public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) {
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert); $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert);
array_push($this->scriptFeatures, $tooltip); $this->addScriptFeature($tooltip);
return $this; return $this;
} }
@ -364,7 +389,32 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/ */
public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) { public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) {
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert, $text); $tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert, $text);
array_push($this->scriptFeatures, $tooltip); $this->addScriptFeature($tooltip);
return $this;
}
/**
* Add a Custom Control Script Text Part
*
* @param string $scriptText Script Text
* @param string $label (optional) Script Label Name
* @param bool $isolated (optional) Whether to isolate the Script Text
* @return \FML\Controls\Control
*/
public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK, $isolated = true) {
$customText = new ControlScript($this, $scriptText, $label, $isolated);
$this->addScriptFeature($customText);
return $this;
}
/**
* Add a Script Feature
*
* @param ScriptFeature $scriptFeature Script Feature
* @return \FML\Controls\Control
*/
public function addScriptFeature(ScriptFeature $scriptFeature) {
array_push($this->scriptFeatures, $scriptFeature);
return $this; return $this;
} }
@ -379,7 +429,6 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
*
* @see \FML\Types\ScriptFeatureable::getScriptFeatures() * @see \FML\Types\ScriptFeatureable::getScriptFeatures()
*/ */
public function getScriptFeatures() { public function getScriptFeatures() {
@ -387,7 +436,6 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
*
* @see \FML\Types\Renderable::render() * @see \FML\Types\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -1,12 +1,13 @@
<?php <?php
// TODO: add entry styles
namespace FML\Controls; namespace FML\Controls;
use FML\Script\Features\EntrySubmit;
use FML\Types\NewLineable; use FML\Types\NewLineable;
use FML\Types\Scriptable; use FML\Types\Scriptable;
use FML\Types\Styleable; use FML\Types\Styleable;
use FML\Types\TextFormatable; use FML\Types\TextFormatable;
use FML\Script\Features\EntrySubmit;
/** /**
* Entry Control * Entry Control
@ -84,7 +85,15 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
* Get the Default Value
* *
* @return mixed
*/
public function getDefault() {
return $this->default;
}
/**
* @see \FML\Types\NewLineable::setAutoNewLine() * @see \FML\Types\NewLineable::setAutoNewLine()
*/ */
public function setAutoNewLine($autoNewLine) { public function setAutoNewLine($autoNewLine) {
@ -93,7 +102,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
*
* @see \FML\Types\Scriptable::setScriptEvents() * @see \FML\Types\Scriptable::setScriptEvents()
*/ */
public function setScriptEvents($scriptEvents) { public function setScriptEvents($scriptEvents) {
@ -102,7 +110,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
*
* @see \FML\Types\Styleable::setStyle() * @see \FML\Types\Styleable::setStyle()
*/ */
public function setStyle($style) { public function setStyle($style) {
@ -111,7 +118,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
*
* @see \FML\Types\TextFormatable::setTextColor() * @see \FML\Types\TextFormatable::setTextColor()
*/ */
public function setTextColor($textColor) { public function setTextColor($textColor) {
@ -120,7 +126,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
*
* @see \FML\Types\TextFormatable::setTextSize() * @see \FML\Types\TextFormatable::setTextSize()
*/ */
public function setTextSize($textSize) { public function setTextSize($textSize) {
@ -129,7 +134,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
*
* @see \FML\Types\TextFormatable::setAreaColor() * @see \FML\Types\TextFormatable::setAreaColor()
*/ */
public function setAreaColor($areaColor) { public function setAreaColor($areaColor) {
@ -138,7 +142,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor() * @see \FML\Types\TextFormatable::setAreaFocusColor()
*/ */
public function setAreaFocusColor($areaFocusColor) { public function setAreaFocusColor($areaFocusColor) {
@ -165,12 +168,11 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
*/ */
public function addSubmitFeature($url) { public function addSubmitFeature($url) {
$entrySubmit = new EntrySubmit($this, $url); $entrySubmit = new EntrySubmit($this, $url);
array_push($this->scriptFeatures, $entrySubmit); $this->addScriptFeature($entrySubmit);
return $this; return $this;
} }
/** /**
*
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
@ -180,13 +182,11 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
if ($this->default !== null) { if ($this->default !== null) {
$xmlElement->setAttribute('default', $this->default); $xmlElement->setAttribute('default', $this->default);
} } else if ($this->autoComplete) {
else if ($this->autoComplete) {
$value = null; $value = null;
if (array_key_exists($this->name, $_GET)) { if (array_key_exists($this->name, $_GET)) {
$value = $_GET[$this->name]; $value = $_GET[$this->name];
} } else if (array_key_exists($this->name, $_POST)) {
else if (array_key_exists($this->name, $_POST)) {
$value = $_POST[$this->name]; $value = $_POST[$this->name];
} }
if ($value) { if ($value) {

View File

@ -2,10 +2,9 @@
namespace FML\Controls; namespace FML\Controls;
use FML\Types\Container;
use FML\Elements\Format; use FML\Elements\Format;
use FML\Types\Container;
use FML\Types\Renderable;
use FML\Types\ScriptFeatureable; use FML\Types\ScriptFeatureable;
/** /**
@ -21,6 +20,7 @@ class Frame extends Control implements Container {
* Protected Properties * Protected Properties
*/ */
protected $children = array(); protected $children = array();
/** @var Format $format */
protected $format = null; protected $format = null;
/** /**
@ -45,10 +45,9 @@ class Frame extends Control implements Container {
} }
/** /**
*
* @see \FML\Types\Container::add() * @see \FML\Types\Container::add()
*/ */
public function add(Control $child) { public function add(Renderable $child) {
if (!in_array($child, $this->children, true)) { if (!in_array($child, $this->children, true)) {
array_push($this->children, $child); array_push($this->children, $child);
} }
@ -56,7 +55,6 @@ class Frame extends Control implements Container {
} }
/** /**
*
* @see \FML\Types\Container::removeChildren() * @see \FML\Types\Container::removeChildren()
*/ */
public function removeChildren() { public function removeChildren() {
@ -65,7 +63,6 @@ class Frame extends Control implements Container {
} }
/** /**
*
* @see \FML\Types\Container::setFormat() * @see \FML\Types\Container::setFormat()
*/ */
public function setFormat(Format $format) { public function setFormat(Format $format) {
@ -74,7 +71,6 @@ class Frame extends Control implements Container {
} }
/** /**
*
* @see \FML\Types\Container::getFormat() * @see \FML\Types\Container::getFormat()
*/ */
public function getFormat($createIfEmpty = true) { public function getFormat($createIfEmpty = true) {
@ -85,7 +81,6 @@ class Frame extends Control implements Container {
} }
/** /**
*
* @see \FML\Controls\Control::getScriptFeatures() * @see \FML\Controls\Control::getScriptFeatures()
*/ */
public function getScriptFeatures() { public function getScriptFeatures() {
@ -99,7 +94,6 @@ class Frame extends Control implements Container {
} }
/** /**
*
* @see \FML\Renderable::render() * @see \FML\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
@ -109,6 +103,7 @@ class Frame extends Control implements Container {
$xmlElement->appendChild($formatXml); $xmlElement->appendChild($formatXml);
} }
foreach ($this->children as $child) { foreach ($this->children as $child) {
/** @var Renderable $child */
$childXmlElement = $child->render($domDocument); $childXmlElement = $child->render($domDocument);
$xmlElement->appendChild($childXmlElement); $xmlElement->appendChild($childXmlElement);
} }

View File

@ -2,8 +2,8 @@
namespace FML\Controls; namespace FML\Controls;
use FML\Types\Scriptable;
use FML\Stylesheet\Style3d; use FML\Stylesheet\Style3d;
use FML\Types\Scriptable;
/** /**
* Frame3d Control * Frame3d Control
@ -14,10 +14,25 @@ use FML\Stylesheet\Style3d;
* @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 Frame3d extends Frame implements Scriptable { class Frame3d extends Frame implements Scriptable {
/*
* Constants
*/
const STYLE_BaseStation = 'BaseStation';
const STYLE_BaseBoxCase = 'BaseBoxCase';
const STYLE_Titlelogo = 'Titlelogo';
const STYLE_ButtonBack = 'ButtonBack';
const STYLE_ButtonNav = 'ButtonNav';
const STYLE_ButtonH = 'ButtonH';
const STYLE_Station3x3 = 'Station3x3';
const STYLE_Title = 'Title';
const STYLE_TitleEditor = 'TitleEditor';
const STYLE_Window = 'Window';
/* /*
* Protected Properties * Protected Properties
*/ */
protected $style3dId = ''; protected $style3dId = '';
/** @var Style3d $style3d */
protected $style3d = null; protected $style3d = null;
protected $scriptEvents = 0; protected $scriptEvents = 0;
@ -66,7 +81,6 @@ class Frame3d extends Frame implements Scriptable {
} }
/** /**
*
* @see \FML\Types\Scriptable::setScriptEvents() * @see \FML\Types\Scriptable::setScriptEvents()
*/ */
public function setScriptEvents($scriptEvents) { public function setScriptEvents($scriptEvents) {
@ -75,7 +89,6 @@ class Frame3d extends Frame implements Scriptable {
} }
/** /**
*
* @see \FML\Controls\Frame::render() * @see \FML\Controls\Frame::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
@ -83,8 +96,7 @@ class Frame3d extends Frame implements Scriptable {
if ($this->style3d) { if ($this->style3d) {
$this->style3d->checkId(); $this->style3d->checkId();
$xmlElement->setAttribute('style3d', $this->style3d->getId()); $xmlElement->setAttribute('style3d', $this->style3d->getId());
} } else if ($this->style3dId) {
else if ($this->style3dId) {
$xmlElement->setAttribute('style3d', $this->style3dId); $xmlElement->setAttribute('style3d', $this->style3dId);
} }
if ($this->scriptEvents) { if ($this->scriptEvents) {

View File

@ -4,7 +4,6 @@ namespace FML\Controls;
use FML\Elements\FrameModel; use FML\Elements\FrameModel;
/** /**
* Class representing an Instance of a Frame Model * Class representing an Instance of a Frame Model
* (CMlFrame) * (CMlFrame)
@ -18,6 +17,7 @@ class FrameInstance extends Control {
* Protected Properties * Protected Properties
*/ */
protected $modelId = ''; protected $modelId = '';
/** @var FrameModel $model */
protected $model = null; protected $model = null;
/** /**
@ -71,7 +71,6 @@ class FrameInstance extends Control {
} }
/** /**
*
* @see \FML\Renderable::render() * @see \FML\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
@ -79,8 +78,7 @@ class FrameInstance extends Control {
if ($this->model) { if ($this->model) {
$this->model->checkId(); $this->model->checkId();
$xmlElement->setAttribute('modelid', $this->model->getId()); $xmlElement->setAttribute('modelid', $this->model->getId());
} } else if ($this->modelId) {
else if ($this->modelId) {
$xmlElement->setAttribute('modelid', $this->modelId); $xmlElement->setAttribute('modelid', $this->modelId);
} }
return $xmlElement; return $xmlElement;

View File

@ -264,7 +264,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
*/ */
public function addClockFeature($showSeconds = true, $showFullDate = false) { public function addClockFeature($showSeconds = true, $showFullDate = false) {
$clock = new Clock($this, $showSeconds, $showFullDate); $clock = new Clock($this, $showSeconds, $showFullDate);
array_push($this->scriptFeatures, $clock); $this->addScriptFeature($clock);
return $this; return $this;
} }

View File

@ -2,6 +2,7 @@
namespace FML\Controls; namespace FML\Controls;
use FML\Models\CheckBoxDesign;
use FML\Types\Actionable; use FML\Types\Actionable;
use FML\Types\BgColorable; use FML\Types\BgColorable;
use FML\Types\Linkable; use FML\Types\Linkable;
@ -139,7 +140,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Actionable::setAction() * @see \FML\Types\Actionable::setAction()
*/ */
public function setAction($action) { public function setAction($action) {
@ -148,7 +148,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Actionable::getAction() * @see \FML\Types\Actionable::getAction()
*/ */
public function getAction() { public function getAction() {
@ -156,7 +155,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Actionable::setActionKey() * @see \FML\Types\Actionable::setActionKey()
*/ */
public function setActionKey($actionKey) { public function setActionKey($actionKey) {
@ -165,7 +163,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\BgColorable::setBgColor() * @see \FML\Types\BgColorable::setBgColor()
*/ */
public function setBgColor($bgColor) { public function setBgColor($bgColor) {
@ -174,7 +171,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Linkable::setUrl() * @see \FML\Types\Linkable::setUrl()
*/ */
public function setUrl($url) { public function setUrl($url) {
@ -183,7 +179,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Linkable::setUrlId() * @see \FML\Types\Linkable::setUrlId()
*/ */
public function setUrlId($urlId) { public function setUrlId($urlId) {
@ -192,7 +187,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Linkable::setManialink() * @see \FML\Types\Linkable::setManialink()
*/ */
public function setManialink($manialink) { public function setManialink($manialink) {
@ -201,7 +195,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Linkable::setManialinkId() * @see \FML\Types\Linkable::setManialinkId()
*/ */
public function setManialinkId($manialinkId) { public function setManialinkId($manialinkId) {
@ -210,7 +203,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Scriptable::setScriptEvents() * @see \FML\Types\Scriptable::setScriptEvents()
*/ */
public function setScriptEvents($scriptEvents) { public function setScriptEvents($scriptEvents) {
@ -219,7 +211,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\Styleable::setStyle() * @see \FML\Types\Styleable::setStyle()
*/ */
public function setStyle($style) { public function setStyle($style) {
@ -228,7 +219,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\SubStyleable::setSubStyle() * @see \FML\Types\SubStyleable::setSubStyle()
*/ */
public function setSubStyle($subStyle) { public function setSubStyle($subStyle) {
@ -237,7 +227,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
*
* @see \FML\Types\SubStyleable::setStyles() * @see \FML\Types\SubStyleable::setStyles()
*/ */
public function setStyles($style, $subStyle) { public function setStyles($style, $subStyle) {
@ -247,7 +236,17 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Apply the given CheckBox Design
* *
* @param CheckBoxDesign $checkBoxDesign CheckBox Design
* @return \FML\Controls\Quad
*/
public function applyCheckBoxDesign(CheckBoxDesign $checkBoxDesign) {
$checkBoxDesign->applyToQuad($this);
return $this;
}
/**
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -131,7 +131,7 @@ class CustomUI {
/** /**
* Set Global Showing * Set Global Showing
* *
* @param bool $visible Wether the UI should be disabled completely * @param bool $visible Whether the UI should be disabled completely
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setGlobalVisible($visible) { public function setGlobalVisible($visible) {
@ -157,7 +157,9 @@ class CustomUI {
} }
$settings = $this->getSettings(); $settings = $this->getSettings();
foreach ($settings as $setting => $value) { foreach ($settings as $setting => $value) {
if ($value === null) continue; if ($value === null) {
continue;
}
$xmlSubElement = $domDocument->createElement($setting); $xmlSubElement = $domDocument->createElement($setting);
$xmlSubElement->setAttribute('visible', ($value ? 1 : 0)); $xmlSubElement->setAttribute('visible', ($value ? 1 : 0));
$xmlElement->appendChild($xmlSubElement); $xmlElement->appendChild($xmlSubElement);

View File

@ -2,7 +2,6 @@
namespace FML\Elements; namespace FML\Elements;
use FML\Controls\Control;
use FML\Types\Container; use FML\Types\Container;
use FML\Types\Renderable; use FML\Types\Renderable;
@ -20,6 +19,7 @@ class FrameModel implements Container, Renderable {
protected $tagName = 'framemodel'; protected $tagName = 'framemodel';
protected $id = ''; protected $id = '';
protected $children = array(); protected $children = array();
/** @var Format $format */
protected $format = null; protected $format = null;
/** /**
@ -55,18 +55,16 @@ class FrameModel implements Container, Renderable {
} }
/** /**
*
* @see \FML\Types\Container::add() * @see \FML\Types\Container::add()
*/ */
public function add(Control $childControl) { public function add(Renderable $childElement) {
if (!in_array($childControl, $this->children, true)) { if (!in_array($childElement, $this->children, true)) {
array_push($this->children, $childControl); array_push($this->children, $childElement);
} }
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\Container::removeChildren() * @see \FML\Types\Container::removeChildren()
*/ */
public function removeChildren() { public function removeChildren() {
@ -75,7 +73,6 @@ class FrameModel implements Container, Renderable {
} }
/** /**
*
* @see \FML\Types\Container::setFormat() * @see \FML\Types\Container::setFormat()
*/ */
public function setFormat(Format $format) { public function setFormat(Format $format) {
@ -84,7 +81,6 @@ class FrameModel implements Container, Renderable {
} }
/** /**
*
* @see \FML\Types\Container::getFormat() * @see \FML\Types\Container::getFormat()
*/ */
public function getFormat($createIfEmpty = true) { public function getFormat($createIfEmpty = true) {
@ -95,7 +91,6 @@ class FrameModel implements Container, Renderable {
} }
/** /**
*
* @see \FML\Types\Renderable::render() * @see \FML\Types\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
@ -107,6 +102,7 @@ class FrameModel implements Container, Renderable {
$xmlElement->appendChild($formatXml); $xmlElement->appendChild($formatXml);
} }
foreach ($this->children as $child) { foreach ($this->children as $child) {
/** @var Renderable $child */
$childElement = $child->render($domDocument); $childElement = $child->render($domDocument);
$xmlElement->appendChild($childElement); $xmlElement->appendChild($childElement);
} }

View File

@ -7,6 +7,7 @@ use FML\ManiaCode\AddFavorite;
use FML\ManiaCode\Element; use FML\ManiaCode\Element;
use FML\ManiaCode\GetSkin; use FML\ManiaCode\GetSkin;
use FML\ManiaCode\Go_To; use FML\ManiaCode\Go_To;
use FML\ManiaCode\InstallMacroblock;
use FML\ManiaCode\InstallMap; use FML\ManiaCode\InstallMap;
use FML\ManiaCode\InstallPack; use FML\ManiaCode\InstallPack;
use FML\ManiaCode\InstallReplay; use FML\ManiaCode\InstallReplay;
@ -17,7 +18,6 @@ use FML\ManiaCode\PlayMap;
use FML\ManiaCode\PlayReplay; use FML\ManiaCode\PlayReplay;
use FML\ManiaCode\ShowMessage; use FML\ManiaCode\ShowMessage;
use FML\ManiaCode\ViewReplay; use FML\ManiaCode\ViewReplay;
use FML\ManiaCode\InstallMacroblock;
/** /**
* Class representing a ManiaCode * Class representing a ManiaCode
@ -304,6 +304,7 @@ class ManiaCode {
$maniaCode->setAttribute('noconfirmation', $this->noConfirmation); $maniaCode->setAttribute('noconfirmation', $this->noConfirmation);
} }
foreach ($this->elements as $element) { foreach ($this->elements as $element) {
/** @var Element $element */
$xmlElement = $element->render($domDocument); $xmlElement = $element->render($domDocument);
$maniaCode->appendChild($xmlElement); $maniaCode->appendChild($xmlElement);
} }

View File

@ -36,8 +36,11 @@ class ManiaLink {
protected $navigable3d = 1; protected $navigable3d = 1;
protected $timeout = 0; protected $timeout = 0;
protected $children = array(); protected $children = array();
/** @var Dico $dico */
protected $dico = null; protected $dico = null;
/** @var Stylesheet $stylesheet */
protected $stylesheet = null; protected $stylesheet = null;
/** @var Script $script */
protected $script = null; protected $script = null;
/** /**
@ -260,6 +263,7 @@ class ManiaLink {
} }
$scriptFeatures = array(); $scriptFeatures = array();
foreach ($this->children as $child) { foreach ($this->children as $child) {
/** @var Renderable $child */
$childXml = $child->render($domDocument, $this->getScript()); $childXml = $child->render($domDocument, $this->getScript());
$maniaLink->appendChild($childXml); $maniaLink->appendChild($childXml);
if ($child instanceof ScriptFeatureable) { if ($child instanceof ScriptFeatureable) {

View File

@ -16,6 +16,7 @@ class ManiaLinks {
protected $encoding = 'utf-8'; protected $encoding = 'utf-8';
protected $tagName = 'manialinks'; protected $tagName = 'manialinks';
protected $children = array(); protected $children = array();
/** @var CustomUI $customUI */
protected $customUI = null; protected $customUI = null;
/** /**
@ -104,6 +105,7 @@ class ManiaLinks {
$maniaLinks = $domDocument->createElement($this->tagName); $maniaLinks = $domDocument->createElement($this->tagName);
$domDocument->appendChild($maniaLinks); $domDocument->appendChild($maniaLinks);
foreach ($this->children as $child) { foreach ($this->children as $child) {
/** @var ManiaLink $child */
$childXml = $child->render(false, $domDocument); $childXml = $child->render(false, $domDocument);
$maniaLinks->appendChild($childXml); $maniaLinks->appendChild($childXml);
} }

View File

@ -0,0 +1,127 @@
<?php
namespace FML\Models;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Script\Builder;
use FML\Types\Styleable;
use FML\Types\SubStyleable;
/**
* Class representing CheckBox Design
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CheckBoxDesign implements Styleable, SubStyleable {
/*
* Protected Properties
*/
protected $url = null;
protected $style = null;
protected $subStyle = null;
/**
* Create the Default Enabled Design
*
* @return \FML\Models\CheckBoxDesign
*/
public static function defaultEnabledDesign() {
$checkBoxDesign = new CheckBoxDesign(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_LvlGreen);
return $checkBoxDesign;
}
/**
* Create the Default Disabled Design
*
* @return \FML\Models\CheckBoxDesign
*/
public static function defaultDisabledDesign() {
$checkBoxDesign = new CheckBoxDesign(Quad_Icons64x64_1::STYLE, Quad_Icons64x64_1::SUBSTYLE_LvlRed);
return $checkBoxDesign;
}
/**
* Create a new CheckBox Design
*
* @param string $style Style Name or Image Url
* @param string $subStyle SubStyle Name
*/
public function __construct($style, $subStyle = null) {
if ($subStyle === null) {
$this->setImageUrl($style);
} else {
$this->setStyle($style);
$this->setSubStyle($subStyle);
}
}
/**
* Set the Image Url
*
* @param string $url Image Url
* @return \FML\Models\CheckBoxDesign
*/
public function setImageUrl($url) {
$this->url = (string)$url;
$this->style = null;
$this->subStyle = null;
return $this;
}
/**
* @see \FML\Types\Styleable::setStyle()
*/
public function setStyle($style) {
$this->style = (string)$style;
$this->url = null;
return $this;
}
/**
* @see \FML\Types\SubStyleable::setSubStyle()
*/
public function setSubStyle($subStyle) {
$this->subStyle = (string)$subStyle;
$this->url = null;
return $this;
}
/**
* @see \FML\Types\SubStyleable::setStyles()
*/
public function setStyles($style, $subStyle) {
$this->setStyle($style);
$this->setSubStyle($subStyle);
return $this;
}
/**
* Apply the Design to the given Quad
*
* @param Quad $quad CheckBox Quad
* @return \FML\Models\CheckBoxDesign
*/
public function applyToQuad(Quad $quad) {
$quad->setImage($this->url);
$quad->setStyles($this->style, $this->subStyle);
return $this;
}
/**
* Get the CheckBox Design String
*
* @param bool $escaped (optional) Whether the String should be escaped for the Script
* @return string
*/
public function getDesignString($escaped = true) {
if ($this->url !== null) {
$string = $this->url;
} else {
$string = $this->style . '|' . $this->subStyle;;
}
return Builder::escapeText($string);
}
}

View File

@ -3,10 +3,10 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Script\Builder;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Script\Builder; use FML\Types\Scriptable;
/** /**
* Script Feature for triggering a Page Action * Script Feature for triggering a Page Action
@ -20,6 +20,7 @@ class ActionTrigger extends ScriptFeature {
* Protected Properties * Protected Properties
*/ */
protected $actionName = null; protected $actionName = null;
/** @var Control $control */
protected $control = null; protected $control = null;
protected $labelName = null; protected $labelName = null;
@ -55,7 +56,9 @@ class ActionTrigger extends ScriptFeature {
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true); $control->setScriptEvents(true);
}
$this->control = $control; $this->control = $control;
return $this; return $this;
} }
@ -72,7 +75,6 @@ class ActionTrigger extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -94,8 +96,7 @@ class ActionTrigger extends ScriptFeature {
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == \"{$controlId}\") {
TriggerPageAction(\"{$actionName}\"); TriggerPageAction(\"{$actionName}\");
}"; }";
} } else {
else {
// Other // Other
$scriptText = " $scriptText = "
TriggerPageAction(\"{$actionName}\");"; TriggerPageAction(\"{$actionName}\");";

View 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;
}
}

View File

@ -2,13 +2,10 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Controls\Label; use FML\Controls\Label;
use FML\Script\Script;
use FML\Script\ScriptInclude; use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel;
/** /**
* Script Feature showing the current Time on a Label * Script Feature showing the current Time on a Label
@ -21,6 +18,7 @@ class Clock extends ScriptFeature {
/* /*
* Protected Properties * Protected Properties
*/ */
/** @var Label $label */
protected $label = null; protected $label = null;
protected $showSeconds = null; protected $showSeconds = null;
protected $showFullDate = null; protected $showFullDate = null;
@ -73,7 +71,6 @@ class Clock extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {

View 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;
}
}

View File

@ -2,14 +2,11 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
use FML\Controls\Entry; use FML\Controls\Entry;
use FML\Script\Builder;
use FML\Script\Script;
use FML\Script\ScriptInclude; use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel;
/** /**
* Script Feature for submitting an Entry * Script Feature for submitting an Entry
@ -22,6 +19,7 @@ class EntrySubmit extends ScriptFeature {
/* /*
* Protected Properties * Protected Properties
*/ */
/** @var Entry $entry */
protected $entry = null; protected $entry = null;
protected $url = null; protected $url = null;
@ -61,7 +59,6 @@ class EntrySubmit extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -98,8 +95,7 @@ if (Event.Control.ControlId == \"{$controlId}\") {
$paramsBegin = stripos($url, '?'); $paramsBegin = stripos($url, '?');
if (!is_int($paramsBegin) || $paramsBegin < 0) { if (!is_int($paramsBegin) || $paramsBegin < 0) {
$url .= '?'; $url .= '?';
} } else {
else {
$url .= '&'; $url .= '&';
} }
return $url; return $url;

View File

@ -2,10 +2,9 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Script\Builder;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Script\Builder;
/** /**
* Script Feature for triggering a Page Action on Key Press * Script Feature for triggering a Page Action on Key Press
@ -84,7 +83,6 @@ class KeyAction extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -104,8 +102,7 @@ class KeyAction extends ScriptFeature {
if ($this->keyCode !== null) { if ($this->keyCode !== null) {
$key = 'KeyCode'; $key = 'KeyCode';
$value = (int)$this->keyCode; $value = (int)$this->keyCode;
} } else if ($this->charPressed !== null) {
else if ($this->charPressed !== null) {
$key = 'CharPressed'; $key = 'CharPressed';
$value = (string)$this->charPressed; $value = (string)$this->charPressed;
} }

View File

@ -3,10 +3,10 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Script\Builder;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Script\Builder; use FML\Types\Scriptable;
/** /**
* Script Feature for opening the Map Info * Script Feature for opening the Map Info
@ -19,6 +19,7 @@ class MapInfo extends ScriptFeature {
/* /*
* Protected Properties * Protected Properties
*/ */
/** @var Control $control */
protected $control = null; protected $control = null;
protected $labelName = null; protected $labelName = null;
@ -36,12 +37,14 @@ class MapInfo extends ScriptFeature {
/** /**
* Set the Control * Set the Control
* *
* @param Control $control Action Control * @param Control $control Map Info Control
* @return \FML\Script\Features\ActionTrigger * @return \FML\Script\Features\MapInfo
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true); $control->setScriptEvents(true);
}
$this->control = $control; $this->control = $control;
return $this; return $this;
} }
@ -50,7 +53,7 @@ class MapInfo extends ScriptFeature {
* Set the Label Name * Set the Label Name
* *
* @param string $labelName Script Label Name * @param string $labelName Script Label Name
* @return \FML\Script\Features\ActionTrigger * @return \FML\Script\Features\MapInfo
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = $labelName; $this->labelName = $labelName;
@ -58,7 +61,6 @@ class MapInfo extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -79,8 +81,7 @@ class MapInfo extends ScriptFeature {
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == \"{$controlId}\") {
ShowCurChallengeCard(); ShowCurChallengeCard();
}"; }";
} } else {
else {
// Other // Other
$scriptText = " $scriptText = "
ShowCurChallengeCard();"; ShowCurChallengeCard();";

View File

@ -3,10 +3,9 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Script\Builder;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Script\Builder;
/** /**
* Script Feature realising a Menu showing specific Controls for the different Item Controls * Script Feature realising a Menu showing specific Controls for the different Item Controls
@ -25,6 +24,7 @@ class Menu extends ScriptFeature {
* Protected Properties * Protected Properties
*/ */
protected $elements = array(); protected $elements = array();
/** @var MenuElement $startElement */
protected $startElement = null; protected $startElement = null;
/** /**
@ -35,7 +35,7 @@ class Menu extends ScriptFeature {
*/ */
public function __construct(Control $item = null, Control $control = null) { public function __construct(Control $item = null, Control $control = null) {
if ($item && $control) { if ($item && $control) {
$this->addNewElement($item, $control); $this->addElement($item, $control);
} }
} }
@ -64,8 +64,7 @@ class Menu extends ScriptFeature {
array_push($this->elements, $menuElement); array_push($this->elements, $menuElement);
if ($isStartElement) { if ($isStartElement) {
$this->setStartElement($menuElement); $this->setStartElement($menuElement);
} } else if (count($this->elements) > 1) {
else if (count($this->elements) > 1) {
$menuElement->getControl()->setVisible(false); $menuElement->getControl()->setVisible(false);
} }
return $this; return $this;
@ -86,7 +85,6 @@ class Menu extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -131,7 +129,9 @@ Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
protected function getElementsArrayText() { protected function getElementsArrayText() {
$elements = array(); $elements = array();
foreach ($this->elements as $element) { 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); return Builder::getArray($elements, true);
} }

View File

@ -3,6 +3,7 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Types\Scriptable;
/** /**
* An Element for the Menu Feature * An Element for the Menu Feature
@ -37,7 +38,9 @@ class MenuElement {
*/ */
public function setItem(Control $item) { public function setItem(Control $item) {
$item->checkId(); $item->checkId();
if ($item instanceof Scriptable) {
$item->setScriptEvents(true); $item->setScriptEvents(true);
}
$this->item = $item; $this->item = $item;
return $this; return $this;
} }

View File

@ -3,11 +3,11 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
use FML\Controls\Label; use FML\Controls\Label;
use FML\Script\Builder;
use FML\Script\Script;
use FML\Script\ScriptInclude; use FML\Script\ScriptInclude;
use FML\Script\ScriptLabel;
/** /**
* Script Feature realising a Mechanism for browsing through Pages * Script Feature realising a Mechanism for browsing through Pages
@ -28,6 +28,7 @@ class Paging extends ScriptFeature {
*/ */
protected $pages = array(); protected $pages = array();
protected $buttons = array(); protected $buttons = array();
/** @var Label $label */
protected $label = null; protected $label = null;
protected $startPageNumber = null; protected $startPageNumber = null;
protected $customMaxPageNumber = null; protected $customMaxPageNumber = null;
@ -85,8 +86,7 @@ class Paging extends ScriptFeature {
$buttonCount = count($this->buttons); $buttonCount = count($this->buttons);
if ($buttonCount % 2 === 0) { if ($buttonCount % 2 === 0) {
$browseAction = $buttonCount / 2 + 1; $browseAction = $buttonCount / 2 + 1;
} } else {
else {
$browseAction = $buttonCount / -2 - 1; $browseAction = $buttonCount / -2 - 1;
} }
} }
@ -178,7 +178,6 @@ class Paging extends ScriptFeature {
* *
* @param bool $appendPageNumber Whether to append the needed Page Number * @param bool $appendPageNumber Whether to append the needed Page Number
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging
*
*/ */
public function setChunkActionAppendsPageNumber($appendPageNumber) { public function setChunkActionAppendsPageNumber($appendPageNumber) {
$this->chunkActionAppendsPageNumber = (bool)$appendPageNumber; $this->chunkActionAppendsPageNumber = (bool)$appendPageNumber;
@ -186,7 +185,6 @@ class Paging extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -284,6 +282,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
$minPageNumber = null; $minPageNumber = null;
$minPage = null; $minPage = null;
foreach ($this->pages as $page) { foreach ($this->pages as $page) {
/** @var PagingPage $page */
$pageNumber = $page->getPageNumber(); $pageNumber = $page->getPageNumber();
if ($minPageNumber === null || $pageNumber < $minPageNumber) { if ($minPageNumber === null || $pageNumber < $minPageNumber) {
$minPageNumber = $pageNumber; $minPageNumber = $pageNumber;
@ -302,6 +301,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
$maxPageNumber = null; $maxPageNumber = null;
$maxPage = null; $maxPage = null;
foreach ($this->pages as $page) { foreach ($this->pages as $page) {
/** @var PagingPage $page */
$pageNumber = $page->getPageNumber(); $pageNumber = $page->getPageNumber();
if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { if ($maxPageNumber === null || $pageNumber > $maxPageNumber) {
$maxPageNumber = $pageNumber; $maxPageNumber = $pageNumber;
@ -319,7 +319,9 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
protected function getPagesArrayText() { protected function getPagesArrayText() {
$pages = array(); $pages = array();
foreach ($this->pages as $page) { 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); return Builder::getArray($pages, true);
} }
@ -335,7 +337,9 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
} }
$pageButtons = array(); $pageButtons = array();
foreach ($this->buttons as $pageButton) { 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); return Builder::getArray($pageButtons, true);
} }

View File

@ -3,6 +3,7 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Types\Scriptable;
/** /**
* A Button for browsing through Pages * A Button for browsing through Pages
@ -37,7 +38,9 @@ class PagingButton {
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true); $control->setScriptEvents(true);
}
$this->control = $control; $this->control = $control;
return $this; return $this;
} }

View File

@ -3,9 +3,10 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Script\Builder;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Script\Builder; use FML\Types\Scriptable;
/** /**
* Script Feature for opening a Player Profile * Script Feature for opening a Player Profile
@ -19,6 +20,7 @@ class PlayerProfile extends ScriptFeature {
* Protected Properties * Protected Properties
*/ */
protected $login = null; protected $login = null;
/** @var Control $control */
protected $control = null; protected $control = null;
protected $labelName = null; protected $labelName = null;
@ -54,7 +56,9 @@ class PlayerProfile extends ScriptFeature {
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true); $control->setScriptEvents(true);
}
$this->control = $control; $this->control = $control;
return $this; return $this;
} }
@ -71,7 +75,6 @@ class PlayerProfile extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -93,8 +96,7 @@ class PlayerProfile extends ScriptFeature {
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == \"{$controlId}\") {
ShowProfile(\"{$login}\"); ShowProfile(\"{$login}\");
}"; }";
} } else {
else {
// Other // Other
$scriptText = " $scriptText = "
ShowProfile(\"{$login}\");"; ShowProfile(\"{$login}\");";

View File

@ -5,7 +5,7 @@ namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Types\Scriptable;
/** /**
* Script Feature for toggling Controls * Script Feature for toggling Controls
@ -18,7 +18,9 @@ class Toggle extends ScriptFeature {
/* /*
* Protected Properties * Protected Properties
*/ */
/** @var Control $togglingControl */
protected $togglingControl = null; protected $togglingControl = null;
/** @var Control $toggledControl */
protected $toggledControl = null; protected $toggledControl = null;
protected $labelName = null; protected $labelName = null;
protected $onlyShow = null; protected $onlyShow = null;
@ -49,7 +51,9 @@ class Toggle extends ScriptFeature {
*/ */
public function setTogglingControl(Control $control) { public function setTogglingControl(Control $control) {
$control->checkId(); $control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true); $control->setScriptEvents(true);
}
$this->togglingControl = $control; $this->togglingControl = $control;
return $this; return $this;
} }
@ -100,7 +104,6 @@ class Toggle extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -119,8 +122,7 @@ class Toggle extends ScriptFeature {
$visibility = '!ToggleControl.Visible'; $visibility = '!ToggleControl.Visible';
if ($this->onlyShow) { if ($this->onlyShow) {
$visibility = 'True'; $visibility = 'True';
} } else if ($this->onlyHide) {
else if ($this->onlyHide) {
$visibility = 'False'; $visibility = 'False';
} }
$scriptText = " $scriptText = "

View File

@ -3,12 +3,11 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Controls\Label;
use FML\Script\Builder;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Script\Builder; use FML\Types\Scriptable;
use FML\Controls\Label;
/** /**
* Script Feature for Showing Tooltips * Script Feature for Showing Tooltips
@ -21,7 +20,9 @@ class Tooltip extends ScriptFeature {
/* /*
* Protected Properties * Protected Properties
*/ */
/** @var Control $hoverControl */
protected $hoverControl = null; protected $hoverControl = null;
/** @var Control $tooltipControl */
protected $tooltipControl = null; protected $tooltipControl = null;
protected $stayOnClick = null; protected $stayOnClick = null;
protected $invert = null; protected $invert = null;
@ -52,7 +53,9 @@ class Tooltip extends ScriptFeature {
*/ */
public function setHoverControl(Control $hoverControl) { public function setHoverControl(Control $hoverControl) {
$hoverControl->checkId(); $hoverControl->checkId();
if ($hoverControl instanceof Scriptable) {
$hoverControl->setScriptEvents(true); $hoverControl->setScriptEvents(true);
}
$this->hoverControl = $hoverControl; $this->hoverControl = $hoverControl;
return $this; return $this;
} }
@ -104,7 +107,6 @@ class Tooltip extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {

View File

@ -3,9 +3,10 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Script\Builder;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\ScriptLabel; use FML\Script\ScriptLabel;
use FML\Script\Builder; use FML\Types\Scriptable;
/** /**
* Script Feature for playing an UI Sound * Script Feature for playing an UI Sound
@ -52,6 +53,7 @@ class UISound extends ScriptFeature {
* Protected Properties * Protected Properties
*/ */
protected $soundName = null; protected $soundName = null;
/** @var Control $control */
protected $control = null; protected $control = null;
protected $variant = 0; protected $variant = 0;
protected $volume = 1.; protected $volume = 1.;
@ -91,7 +93,9 @@ class UISound extends ScriptFeature {
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true); $control->setScriptEvents(true);
}
$this->control = $control; $this->control = $control;
return $this; return $this;
} }
@ -130,7 +134,6 @@ class UISound extends ScriptFeature {
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -151,8 +154,7 @@ class UISound extends ScriptFeature {
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == \"{$controlId}\") {
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume}); PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});
}"; }";
} } else {
else {
// Other // Other
$scriptText = " $scriptText = "
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});"; PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});";

View File

@ -41,11 +41,11 @@ class Script {
public function setScriptInclude($file, $namespace = null) { public function setScriptInclude($file, $namespace = null) {
if (is_object($file) && ($file instanceof ScriptInclude)) { if (is_object($file) && ($file instanceof ScriptInclude)) {
$scriptInclude = $file; $scriptInclude = $file;
} } else {
else {
$scriptInclude = new ScriptInclude($file, $namespace); $scriptInclude = new ScriptInclude($file, $namespace);
} }
$this->includes[$scriptInclude->getNamespace()] = $scriptInclude; $namespace = $scriptInclude->getNamespace();
$this->includes[$namespace] = $scriptInclude;
return $this; return $this;
} }
@ -59,8 +59,7 @@ class Script {
public function addScriptConstant($name, $value = null) { public function addScriptConstant($name, $value = null) {
if (is_object($name) && ($name instanceof ScriptConstant)) { if (is_object($name) && ($name instanceof ScriptConstant)) {
$scriptConstant = $name; $scriptConstant = $name;
} } else {
else {
$scriptConstant = new ScriptConstant($name, $value); $scriptConstant = new ScriptConstant($name, $value);
} }
array_push($this->constants, $scriptConstant); array_push($this->constants, $scriptConstant);
@ -77,8 +76,7 @@ class Script {
public function addScriptFunction($name, $text = null) { public function addScriptFunction($name, $text = null) {
if (is_object($name) && ($name instanceof ScriptFunction)) { if (is_object($name) && ($name instanceof ScriptFunction)) {
$scriptFunction = $name; $scriptFunction = $name;
} } else {
else {
$scriptFunction = new ScriptFunction($name, $text); $scriptFunction = new ScriptFunction($name, $text);
} }
if (!in_array($scriptFunction, $this->functions)) { if (!in_array($scriptFunction, $this->functions)) {
@ -97,8 +95,7 @@ class Script {
public function addCustomScriptLabel($name, $text = null) { public function addCustomScriptLabel($name, $text = null) {
if (is_object($name) && ($name instanceof ScriptLabel)) { if (is_object($name) && ($name instanceof ScriptLabel)) {
$scriptLabel = $name; $scriptLabel = $name;
} } else {
else {
$scriptLabel = new ScriptLabel($name, $text); $scriptLabel = new ScriptLabel($name, $text);
} }
array_push($this->customLabels, $scriptLabel); array_push($this->customLabels, $scriptLabel);
@ -116,8 +113,7 @@ class Script {
public function appendGenericScriptLabel($name, $text = null, $isolated = false) { public function appendGenericScriptLabel($name, $text = null, $isolated = false) {
if (is_object($name) && ($name instanceof ScriptLabel)) { if (is_object($name) && ($name instanceof ScriptLabel)) {
$scriptLabel = $name; $scriptLabel = $name;
} } else {
else {
$scriptLabel = new ScriptLabel($name, $text, $isolated); $scriptLabel = new ScriptLabel($name, $text, $isolated);
} }
array_push($this->genericLabels, $scriptLabel); array_push($this->genericLabels, $scriptLabel);
@ -222,6 +218,7 @@ class Script {
* FancyManiaLinks v' . FML_VERSION . ' by steeffeen * * FancyManiaLinks v' . FML_VERSION . ' by steeffeen *
* http://github.com/steeffeen/FancyManiaLinks * * http://github.com/steeffeen/FancyManiaLinks *
****************************************************/ ****************************************************/
'; ';
return $headerComment; return $headerComment;
} }

View File

@ -15,6 +15,7 @@ class Stylesheet {
*/ */
protected $tagName = 'stylesheet'; protected $tagName = 'stylesheet';
protected $styles3d = array(); protected $styles3d = array();
/** @var Mood $mood */
protected $mood = null; protected $mood = null;
/** /**
@ -92,6 +93,7 @@ class Stylesheet {
$stylesXml = $domDocument->createElement('frame3dstyles'); $stylesXml = $domDocument->createElement('frame3dstyles');
$stylesheetXml->appendChild($stylesXml); $stylesheetXml->appendChild($stylesXml);
foreach ($this->styles3d as $style3d) { foreach ($this->styles3d as $style3d) {
/** @var Style3d $style3d */
$style3dXml = $style3d->render($domDocument); $style3dXml = $style3d->render($domDocument);
$stylesXml->appendChild($style3dXml); $stylesXml->appendChild($style3dXml);
} }

View File

@ -2,7 +2,6 @@
namespace FML\Types; namespace FML\Types;
use FML\Controls\Control;
use FML\Elements\Format; use FML\Elements\Format;
/** /**
@ -15,12 +14,12 @@ use FML\Elements\Format;
interface Container { interface Container {
/** /**
* Add a new Child Control * Add a new Child Element
* *
* @param Control $child The Child Control to add * @param Renderable $child The Child Control to add
* @return \FML\Types\Container * @return \FML\Types\Container
*/ */
public function add(Control $child); public function add(Renderable $child);
/** /**
* Remove all Children * Remove all Children

View File

@ -4,7 +4,7 @@
* FancyManiaLinks - Automatic ManiaLink Generator Framework * FancyManiaLinks - Automatic ManiaLink Generator Framework
* *
* @author steeffeen * @author steeffeen
* @version 1.1 * @version 1.2
* @link http://github.com/steeffeen/FancyManiaLinks * @link http://github.com/steeffeen/FancyManiaLinks
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder * @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
@ -13,7 +13,7 @@ if (!defined('FML_PATH')) {
define('FML_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR); define('FML_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
} }
if (!defined('FML_VERSION')) { if (!defined('FML_VERSION')) {
define('FML_VERSION', 1.1); define('FML_VERSION', '1.2');
} }
if (!defined('FML_SIMPLE_CLASSES')) { if (!defined('FML_SIMPLE_CLASSES')) {
define('FML_SIMPLE_CLASSES', false); define('FML_SIMPLE_CLASSES', false);
@ -30,8 +30,7 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
if (file_exists($filePath)) { if (file_exists($filePath)) {
// Load with FML namespace // Load with FML namespace
require_once $filePath; require_once $filePath;
} } else if (FML_SIMPLE_CLASSES) {
else if (FML_SIMPLE_CLASSES) {
// Load as simple class name // Load as simple class name
if (!function_exists('loadSimpleClass')) { if (!function_exists('loadSimpleClass')) {
@ -58,7 +57,9 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
$subDirectory = $filePath . DIRECTORY_SEPARATOR; $subDirectory = $filePath . DIRECTORY_SEPARATOR;
$namespace = $baseNamespace . $fileName . '\\'; $namespace = $baseNamespace . $fileName . '\\';
$success = loadSimpleClass($className, $subDirectory, $excludes, $namespace); $success = loadSimpleClass($className, $subDirectory, $excludes, $namespace);
if ($success) return true; if ($success) {
return true;
}
continue; continue;
} }
if (is_file($filePath)) { if (is_file($filePath)) {