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;
use FML\Types\Renderable;
use FML\Script\Builder;
use FML\Script\Features\ActionTrigger;
use FML\Script\ScriptLabel;
use FML\Types\ScriptFeatureable;
use FML\Script\Features\ControlScript;
use FML\Script\Features\MapInfo;
use FML\Script\Features\PlayerProfile;
use FML\Script\Features\UISound;
use FML\Script\Builder;
use FML\Script\Features\ScriptFeature;
use FML\Script\Features\Toggle;
use FML\Script\Features\Tooltip;
use FML\Script\Features\UISound;
use FML\Script\ScriptLabel;
use FML\Types\Renderable;
use FML\Types\ScriptFeatureable;
/**
* Base Control
@ -85,17 +87,18 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setId($id) {
$this->id = (string) $id;
$this->id = (string)$id;
return $this;
}
/**
* 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
*/
public function checkId() {
if (!$this->getId()) {
public function checkId($forceNewId = false) {
if ($forceNewId || !$this->getId()) {
$this->setId('FML_ID_' . self::$currentIndex);
self::$currentIndex++;
return $this;
@ -104,7 +107,9 @@ abstract class Control implements Renderable, ScriptFeatureable {
$idCharacters = str_split($this->getId());
$danger = false;
foreach ($idCharacters as $character) {
if (!in_array($character, $dangerousCharacters)) continue;
if (!in_array($character, $dangerousCharacters)) {
continue;
}
$danger = true;
break;
}
@ -123,7 +128,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setX($x) {
$this->x = (float) $x;
$this->x = (float)$x;
return $this;
}
@ -134,7 +139,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setY($y) {
$this->y = (float) $y;
$this->y = (float)$y;
return $this;
}
@ -145,7 +150,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setZ($z) {
$this->z = (float) $z;
$this->z = (float)$z;
return $this;
}
@ -173,7 +178,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setWidth($width) {
$this->width = (float) $width;
$this->width = (float)$width;
return $this;
}
@ -184,7 +189,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setHeight($height) {
$this->height = (float) $height;
$this->height = (float)$height;
return $this;
}
@ -208,7 +213,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setHAlign($hAlign) {
$this->hAlign = (string) $hAlign;
$this->hAlign = (string)$hAlign;
return $this;
}
@ -219,7 +224,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setVAlign($vAlign) {
$this->vAlign = (string) $vAlign;
$this->vAlign = (string)$vAlign;
return $this;
}
@ -236,6 +241,26 @@ abstract class Control implements Renderable, ScriptFeatureable {
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
*
@ -243,7 +268,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function setScale($scale) {
$this->scale = (float) $scale;
$this->scale = (float)$scale;
return $this;
}
@ -253,7 +278,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @param bool $visible Whether Control should be visible
* @return \FML\Controls\Control
*/
public function setVisible($visible) {
public function setVisible($visible = true) {
$this->hidden = ($visible ? 0 : 1);
return $this;
}
@ -265,7 +290,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control
*/
public function addClass($class) {
$class = (string) $class;
$class = (string)$class;
if (!in_array($class, $this->classes)) {
array_push($this->classes, $class);
}
@ -281,7 +306,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/
public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) {
$actionTrigger = new ActionTrigger($actionName, $this, $eventLabel);
array_push($this->scriptFeatures, $actionTrigger);
$this->addScriptFeature($actionTrigger);
return $this;
}
@ -293,7 +318,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/
public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) {
$mapInfo = new MapInfo($this, $eventLabel);
array_push($this->scriptFeatures, $mapInfo);
$this->addScriptFeature($mapInfo);
return $this;
}
@ -306,7 +331,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/
public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) {
$playerProfile = new PlayerProfile($login, $this, $eventLabel);
array_push($this->scriptFeatures, $playerProfile);
$this->addScriptFeature($playerProfile);
return $this;
}
@ -320,7 +345,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/
public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) {
$uiSound = new UISound($soundName, $this, $variant, $eventLabel);
array_push($this->scriptFeatures, $uiSound);
$this->addScriptFeature($uiSound);
return $this;
}
@ -335,7 +360,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/
public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
$toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide);
array_push($this->scriptFeatures, $toggle);
$this->addScriptFeature($toggle);
return $this;
}
@ -349,7 +374,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/
public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) {
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert);
array_push($this->scriptFeatures, $tooltip);
$this->addScriptFeature($tooltip);
return $this;
}
@ -364,7 +389,32 @@ abstract class Control implements Renderable, ScriptFeatureable {
*/
public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) {
$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;
}
@ -379,7 +429,6 @@ abstract class Control implements Renderable, ScriptFeatureable {
}
/**
*
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
*/
public function getScriptFeatures() {
@ -387,7 +436,6 @@ abstract class Control implements Renderable, ScriptFeatureable {
}
/**
*
* @see \FML\Types\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {

View File

@ -1,12 +1,13 @@
<?php
// TODO: add entry styles
namespace FML\Controls;
use FML\Script\Features\EntrySubmit;
use FML\Types\NewLineable;
use FML\Types\Scriptable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
use FML\Script\Features\EntrySubmit;
/**
* Entry Control
@ -59,7 +60,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry
*/
public function setName($name) {
$this->name = (string) $name;
$this->name = (string)$name;
return $this;
}
@ -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()
*/
public function setAutoNewLine($autoNewLine) {
@ -93,7 +102,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
}
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
@ -102,47 +110,42 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
}
/**
*
* @see \FML\Types\Styleable::setStyle()
*/
public function setStyle($style) {
$this->style = (string) $style;
$this->style = (string)$style;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setTextColor()
*/
public function setTextColor($textColor) {
$this->textColor = (string) $textColor;
$this->textColor = (string)$textColor;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setTextSize()
*/
public function setTextSize($textSize) {
$this->textSize = (int) $textSize;
$this->textSize = (int)$textSize;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setAreaColor()
*/
public function setAreaColor($areaColor) {
$this->focusAreaColor1 = (string) $areaColor;
$this->focusAreaColor1 = (string)$areaColor;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor) {
$this->focusAreaColor2 = (string) $areaFocusColor;
$this->focusAreaColor2 = (string)$areaFocusColor;
return $this;
}
@ -153,7 +156,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry
*/
public function setAutoComplete($autoComplete) {
$this->autoComplete = (bool) $autoComplete;
$this->autoComplete = (bool)$autoComplete;
return $this;
}
@ -165,12 +168,11 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
*/
public function addSubmitFeature($url) {
$entrySubmit = new EntrySubmit($this, $url);
array_push($this->scriptFeatures, $entrySubmit);
$this->addScriptFeature($entrySubmit);
return $this;
}
/**
*
* @see \FML\Control::render()
*/
public function render(\DOMDocument $domDocument) {
@ -180,13 +182,11 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
}
if ($this->default !== null) {
$xmlElement->setAttribute('default', $this->default);
}
else if ($this->autoComplete) {
} else if ($this->autoComplete) {
$value = null;
if (array_key_exists($this->name, $_GET)) {
$value = $_GET[$this->name];
}
else if (array_key_exists($this->name, $_POST)) {
} else if (array_key_exists($this->name, $_POST)) {
$value = $_POST[$this->name];
}
if ($value) {

View File

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

View File

@ -2,8 +2,8 @@
namespace FML\Controls;
use FML\Types\Scriptable;
use FML\Stylesheet\Style3d;
use FML\Types\Scriptable;
/**
* Frame3d Control
@ -14,10 +14,25 @@ use FML\Stylesheet\Style3d;
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
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 $style3dId = '';
/** @var Style3d $style3d */
protected $style3d = null;
protected $scriptEvents = 0;
@ -49,7 +64,7 @@ class Frame3d extends Frame implements Scriptable {
* @return \FML\Controls\Frame3d
*/
public function setStyle3dId($style3dId) {
$this->style3dId = (string) $style3dId;
$this->style3dId = (string)$style3dId;
$this->style3d = null;
return $this;
}
@ -66,7 +81,6 @@ class Frame3d extends Frame implements Scriptable {
}
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
@ -75,7 +89,6 @@ class Frame3d extends Frame implements Scriptable {
}
/**
*
* @see \FML\Controls\Frame::render()
*/
public function render(\DOMDocument $domDocument) {
@ -83,8 +96,7 @@ class Frame3d extends Frame implements Scriptable {
if ($this->style3d) {
$this->style3d->checkId();
$xmlElement->setAttribute('style3d', $this->style3d->getId());
}
else if ($this->style3dId) {
} else if ($this->style3dId) {
$xmlElement->setAttribute('style3d', $this->style3dId);
}
if ($this->scriptEvents) {

View File

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

View File

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

View File

@ -2,6 +2,7 @@
namespace FML\Controls;
use FML\Models\CheckBoxDesign;
use FML\Types\Actionable;
use FML\Types\BgColorable;
use FML\Types\Linkable;
@ -68,7 +69,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad
*/
public function setImage($image) {
$this->image = (string) $image;
$this->image = (string)$image;
return $this;
}
@ -79,7 +80,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad
*/
public function setImageId($imageId) {
$this->imageId = (string) $imageId;
$this->imageId = (string)$imageId;
return $this;
}
@ -90,7 +91,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad
*/
public function setImageFocus($imageFocus) {
$this->imageFocus = (string) $imageFocus;
$this->imageFocus = (string)$imageFocus;
return $this;
}
@ -101,7 +102,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad
*/
public function setImageFocusId($imageFocusId) {
$this->imageFocusId = (string) $imageFocusId;
$this->imageFocusId = (string)$imageFocusId;
return $this;
}
@ -112,7 +113,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad
*/
public function setColorize($colorize) {
$this->colorize = (string) $colorize;
$this->colorize = (string)$colorize;
return $this;
}
@ -123,7 +124,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad
*/
public function setModulizeColor($modulizeColor) {
$this->modulizeColor = (string) $modulizeColor;
$this->modulizeColor = (string)$modulizeColor;
return $this;
}
@ -139,16 +140,14 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
}
/**
*
* @see \FML\Types\Actionable::setAction()
*/
public function setAction($action) {
$this->action = (string) $action;
$this->action = (string)$action;
return $this;
}
/**
*
* @see \FML\Types\Actionable::getAction()
*/
public function getAction() {
@ -156,61 +155,54 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
}
/**
*
* @see \FML\Types\Actionable::setActionKey()
*/
public function setActionKey($actionKey) {
$this->actionKey = (int) $actionKey;
$this->actionKey = (int)$actionKey;
return $this;
}
/**
*
* @see \FML\Types\BgColorable::setBgColor()
*/
public function setBgColor($bgColor) {
$this->bgColor = (string) $bgColor;
$this->bgColor = (string)$bgColor;
return $this;
}
/**
*
* @see \FML\Types\Linkable::setUrl()
*/
public function setUrl($url) {
$this->url = (string) $url;
$this->url = (string)$url;
return $this;
}
/**
*
* @see \FML\Types\Linkable::setUrlId()
*/
public function setUrlId($urlId) {
$this->urlId = (string) $urlId;
$this->urlId = (string)$urlId;
return $this;
}
/**
*
* @see \FML\Types\Linkable::setManialink()
*/
public function setManialink($manialink) {
$this->manialink = (string) $manialink;
$this->manialink = (string)$manialink;
return $this;
}
/**
*
* @see \FML\Types\Linkable::setManialinkId()
*/
public function setManialinkId($manialinkId) {
$this->manialinkId = (string) $manialinkId;
$this->manialinkId = (string)$manialinkId;
return $this;
}
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
@ -219,25 +211,22 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
}
/**
*
* @see \FML\Types\Styleable::setStyle()
*/
public function setStyle($style) {
$this->style = (string) $style;
$this->style = (string)$style;
return $this;
}
/**
*
* @see \FML\Types\SubStyleable::setSubStyle()
*/
public function setSubStyle($subStyle) {
$this->subStyle = (string) $subStyle;
$this->subStyle = (string)$subStyle;
return $this;
}
/**
*
* @see \FML\Types\SubStyleable::setStyles()
*/
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()
*/
public function render(\DOMDocument $domDocument) {

View File

@ -47,7 +47,7 @@ class CustomUI {
* @return \FML\CustomUI
*/
public function setXMLEncoding($encoding) {
$this->encoding = (string) $encoding;
$this->encoding = (string)$encoding;
return $this;
}
@ -131,7 +131,7 @@ class CustomUI {
/**
* 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
*/
public function setGlobalVisible($visible) {
@ -146,7 +146,7 @@ class CustomUI {
* @return \DOMDocument
*/
public function render($domDocument = null) {
$isChild = (bool) $domDocument;
$isChild = (bool)$domDocument;
if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
$domDocument->xmlStandalone = true;
@ -157,7 +157,9 @@ class CustomUI {
}
$settings = $this->getSettings();
foreach ($settings as $setting => $value) {
if ($value === null) continue;
if ($value === null) {
continue;
}
$xmlSubElement = $domDocument->createElement($setting);
$xmlSubElement->setAttribute('visible', ($value ? 1 : 0));
$xmlElement->appendChild($xmlSubElement);

View File

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

View File

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

View File

@ -36,8 +36,11 @@ class ManiaLink {
protected $navigable3d = 1;
protected $timeout = 0;
protected $children = array();
/** @var Dico $dico */
protected $dico = null;
/** @var Stylesheet $stylesheet */
protected $stylesheet = null;
/** @var Script $script */
protected $script = null;
/**
@ -69,7 +72,7 @@ class ManiaLink {
* @return \FML\ManiaLink
*/
public function setXmlEncoding($encoding) {
$this->encoding = (string) $encoding;
$this->encoding = (string)$encoding;
return $this;
}
@ -80,7 +83,7 @@ class ManiaLink {
* @return \FML\ManiaLink
*/
public function setId($id) {
$this->id = (string) $id;
$this->id = (string)$id;
return $this;
}
@ -100,7 +103,7 @@ class ManiaLink {
* @return \FML\ManiaLink
*/
public function setBackground($background) {
$this->background = (string) $background;
$this->background = (string)$background;
return $this;
}
@ -122,7 +125,7 @@ class ManiaLink {
* @return \FML\ManiaLink
*/
public function setTimeout($timeout) {
$this->timeout = (int) $timeout;
$this->timeout = (int)$timeout;
return $this;
}
@ -229,7 +232,7 @@ class ManiaLink {
* @return \DOMDocument
*/
public function render($echo = false, $domDocument = null) {
$isChild = (bool) $domDocument;
$isChild = (bool)$domDocument;
if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
$domDocument->xmlStandalone = true;
@ -260,6 +263,7 @@ class ManiaLink {
}
$scriptFeatures = array();
foreach ($this->children as $child) {
/** @var Renderable $child */
$childXml = $child->render($domDocument, $this->getScript());
$maniaLink->appendChild($childXml);
if ($child instanceof ScriptFeatureable) {

View File

@ -16,6 +16,7 @@ class ManiaLinks {
protected $encoding = 'utf-8';
protected $tagName = 'manialinks';
protected $children = array();
/** @var CustomUI $customUI */
protected $customUI = null;
/**
@ -41,7 +42,7 @@ class ManiaLinks {
* @return \FML\ManiaLinks
*/
public function setXmlEncoding($encoding) {
$this->encoding = (string) $encoding;
$this->encoding = (string)$encoding;
return $this;
}
@ -104,6 +105,7 @@ class ManiaLinks {
$maniaLinks = $domDocument->createElement($this->tagName);
$domDocument->appendChild($maniaLinks);
foreach ($this->children as $child) {
/** @var ManiaLink $child */
$childXml = $child->render(false, $domDocument);
$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;
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
@ -20,6 +20,7 @@ class ActionTrigger extends ScriptFeature {
* Protected Properties
*/
protected $actionName = null;
/** @var Control $control */
protected $control = null;
protected $labelName = null;
@ -55,7 +56,9 @@ class ActionTrigger extends ScriptFeature {
*/
public function setControl(Control $control) {
$control->checkId();
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) {
@ -94,8 +96,7 @@ class ActionTrigger extends ScriptFeature {
if (Event.Control.ControlId == \"{$controlId}\") {
TriggerPageAction(\"{$actionName}\");
}";
}
else {
} else {
// Other
$scriptText = "
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;
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
@ -21,6 +18,7 @@ class Clock extends ScriptFeature {
/*
* Protected Properties
*/
/** @var Label $label */
protected $label = null;
protected $showSeconds = null;
protected $showFullDate = null;
@ -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) {

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;
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
@ -22,6 +19,7 @@ class EntrySubmit extends ScriptFeature {
/*
* Protected Properties
*/
/** @var Entry $entry */
protected $entry = null;
protected $url = null;
@ -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) {
@ -98,8 +95,7 @@ if (Event.Control.ControlId == \"{$controlId}\") {
$paramsBegin = stripos($url, '?');
if (!is_int($paramsBegin) || $paramsBegin < 0) {
$url .= '?';
}
else {
} else {
$url .= '&';
}
return $url;

View File

@ -2,10 +2,9 @@
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
@ -46,7 +45,7 @@ class KeyAction extends ScriptFeature {
* @return \FML\Script\Features\KeyAction
*/
public function setActionName($actionName) {
$this->actionName = (string) $actionName;
$this->actionName = (string)$actionName;
return $this;
}
@ -57,7 +56,7 @@ class KeyAction extends ScriptFeature {
* @return \FML\Script\Features\KeyAction
*/
public function setKeyName($keyName) {
$this->keyName = (string) $keyName;
$this->keyName = (string)$keyName;
return $this;
}
@ -84,7 +83,6 @@ class KeyAction extends ScriptFeature {
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
@ -103,11 +101,10 @@ class KeyAction extends ScriptFeature {
$value = $this->keyName;
if ($this->keyCode !== null) {
$key = 'KeyCode';
$value = (int) $this->keyCode;
}
else if ($this->charPressed !== null) {
$value = (int)$this->keyCode;
} else if ($this->charPressed !== null) {
$key = 'CharPressed';
$value = (string) $this->charPressed;
$value = (string)$this->charPressed;
}
$scriptText = "
if (Event.{$key} == \"{$value}\") {

View File

@ -3,10 +3,10 @@
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
@ -19,6 +19,7 @@ class MapInfo extends ScriptFeature {
/*
* Protected Properties
*/
/** @var Control $control */
protected $control = null;
protected $labelName = null;
@ -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();
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) {
@ -79,8 +81,7 @@ class MapInfo extends ScriptFeature {
if (Event.Control.ControlId == \"{$controlId}\") {
ShowCurChallengeCard();
}";
}
else {
} else {
// Other
$scriptText = "
ShowCurChallengeCard();";

View File

@ -3,10 +3,9 @@
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
@ -25,6 +24,7 @@ class Menu extends ScriptFeature {
* Protected Properties
*/
protected $elements = array();
/** @var MenuElement $startElement */
protected $startElement = null;
/**
@ -35,7 +35,7 @@ class Menu extends ScriptFeature {
*/
public function __construct(Control $item = null, Control $control = null) {
if ($item && $control) {
$this->addNewElement($item, $control);
$this->addElement($item, $control);
}
}
@ -64,8 +64,7 @@ class Menu extends ScriptFeature {
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,7 +85,6 @@ class Menu extends ScriptFeature {
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
@ -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);
}

View File

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

View File

@ -3,11 +3,11 @@
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
@ -28,6 +28,7 @@ class Paging extends ScriptFeature {
*/
protected $pages = array();
protected $buttons = array();
/** @var Label $label */
protected $label = null;
protected $startPageNumber = null;
protected $customMaxPageNumber = 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;
}
}
@ -125,7 +125,7 @@ class Paging extends ScriptFeature {
* @return \FML\Script\Features\Paging
*/
public function setStartPageNumber($startPageNumber) {
$this->startPageNumber = (int) $startPageNumber;
$this->startPageNumber = (int)$startPageNumber;
}
/**
@ -135,7 +135,7 @@ class Paging extends ScriptFeature {
* @return \FML\Script\Features\Paging
*/
public function setCustomMaxPageNumber($maxPageNumber) {
$this->customMaxPageNumber = (int) $maxPageNumber;
$this->customMaxPageNumber = (int)$maxPageNumber;
return $this;
}
@ -146,7 +146,7 @@ class Paging extends ScriptFeature {
* @return \FML\Script\Features\Paging
*/
public function setPreviousChunkAction($previousChunkAction) {
$this->previousChunkAction = (string) $previousChunkAction;
$this->previousChunkAction = (string)$previousChunkAction;
return $this;
}
@ -157,7 +157,7 @@ class Paging extends ScriptFeature {
* @return \FML\Script\Features\Paging
*/
public function setNextChunkAction($nextChunkAction) {
$this->nextChunkAction = (string) $nextChunkAction;
$this->nextChunkAction = (string)$nextChunkAction;
return $this;
}
@ -178,15 +178,13 @@ class Paging extends ScriptFeature {
*
* @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) {
@ -284,6 +282,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
$minPageNumber = null;
$minPage = null;
foreach ($this->pages as $page) {
/** @var PagingPage $page */
$pageNumber = $page->getPageNumber();
if ($minPageNumber === null || $pageNumber < $minPageNumber) {
$minPageNumber = $pageNumber;
@ -302,6 +301,7 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
$maxPageNumber = null;
$maxPage = null;
foreach ($this->pages as $page) {
/** @var PagingPage $page */
$pageNumber = $page->getPageNumber();
if ($maxPageNumber === null || $pageNumber > $maxPageNumber) {
$maxPageNumber = $pageNumber;
@ -319,7 +319,9 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
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);
}
@ -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);
}

View File

@ -3,6 +3,7 @@
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Types\Scriptable;
/**
* A Button for browsing through Pages
@ -37,7 +38,9 @@ class PagingButton {
*/
public function setControl(Control $control) {
$control->checkId();
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;
}

View File

@ -3,9 +3,10 @@
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
@ -19,6 +20,7 @@ class PlayerProfile extends ScriptFeature {
* Protected Properties
*/
protected $login = null;
/** @var Control $control */
protected $control = null;
protected $labelName = null;
@ -54,7 +56,9 @@ class PlayerProfile extends ScriptFeature {
*/
public function setControl(Control $control) {
$control->checkId();
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) {
@ -93,8 +96,7 @@ class PlayerProfile extends ScriptFeature {
if (Event.Control.ControlId == \"{$controlId}\") {
ShowProfile(\"{$login}\");
}";
}
else {
} else {
// Other
$scriptText = "
ShowProfile(\"{$login}\");";

View File

@ -5,7 +5,7 @@ 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
@ -18,7 +18,9 @@ class Toggle extends ScriptFeature {
/*
* Protected Properties
*/
/** @var Control $togglingControl */
protected $togglingControl = null;
/** @var Control $toggledControl */
protected $toggledControl = null;
protected $labelName = null;
protected $onlyShow = null;
@ -49,7 +51,9 @@ class Toggle extends ScriptFeature {
*/
public function setTogglingControl(Control $control) {
$control->checkId();
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) {
@ -119,8 +122,7 @@ class Toggle extends ScriptFeature {
$visibility = '!ToggleControl.Visible';
if ($this->onlyShow) {
$visibility = 'True';
}
else if ($this->onlyHide) {
} else if ($this->onlyHide) {
$visibility = 'False';
}
$scriptText = "

View File

@ -3,12 +3,11 @@
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
@ -21,7 +20,9 @@ class Tooltip extends ScriptFeature {
/*
* Protected Properties
*/
/** @var Control $hoverControl */
protected $hoverControl = null;
/** @var Control $tooltipControl */
protected $tooltipControl = null;
protected $stayOnClick = null;
protected $invert = null;
@ -52,7 +53,9 @@ class Tooltip extends ScriptFeature {
*/
public function setHoverControl(Control $hoverControl) {
$hoverControl->checkId();
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,7 +107,6 @@ class Tooltip extends ScriptFeature {
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {

View File

@ -3,9 +3,10 @@
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
@ -52,6 +53,7 @@ class UISound extends ScriptFeature {
* Protected Properties
*/
protected $soundName = null;
/** @var Control $control */
protected $control = null;
protected $variant = 0;
protected $volume = 1.;
@ -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();
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) {
@ -151,8 +154,7 @@ class UISound extends ScriptFeature {
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});";

View File

@ -41,11 +41,11 @@ class 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;
}
@ -59,8 +59,7 @@ class 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);
@ -116,8 +113,7 @@ class 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);
@ -222,6 +218,7 @@ class Script {
* FancyManiaLinks v' . FML_VERSION . ' by steeffeen *
* http://github.com/steeffeen/FancyManiaLinks *
****************************************************/
';
return $headerComment;
}

View File

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

View File

@ -2,8 +2,8 @@
namespace FML\Stylesheet;
// Warning: The mood class isn't fully supported yet!
// Missing attributes: LDir1..
// Warning: The mood class isn't fully supported yet!
// Missing attributes: LDir1..
/**
* Class representing a Stylesheets Mood
@ -57,9 +57,9 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLightAmbientColor($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$red = (float)$red;
$green = (float)$green;
$blue = (float)$blue;
$this->lAmbient_LinearRgb = "{$red} {$green} {$blue}";
return $this;
}
@ -73,9 +73,9 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setCloudsColorMin($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$red = (float)$red;
$green = (float)$green;
$blue = (float)$blue;
$this->cloudsRgbMinLinear = "{$red} {$green} {$blue}";
return $this;
}
@ -89,9 +89,9 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setCloudsColorMax($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$red = (float)$red;
$green = (float)$green;
$blue = (float)$blue;
$this->cloudsRgbMaxLinear = "{$red} {$green} {$blue}";
return $this;
}
@ -105,9 +105,9 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLight0Color($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$red = (float)$red;
$green = (float)$green;
$blue = (float)$blue;
$this->lDir0_LinearRgb = "{$red} {$green} {$blue}";
return $this;
}
@ -119,7 +119,7 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLight0Intensity($intensity) {
$this->lDir0_Intens = (float) $intensity;
$this->lDir0_Intens = (float)$intensity;
return $this;
}
@ -130,7 +130,7 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLight0PhiAngle($phiAngle) {
$this->lDir0_DirPhi = (float) $phiAngle;
$this->lDir0_DirPhi = (float)$phiAngle;
return $this;
}
@ -141,7 +141,7 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLight0ThetaAngle($thetaAngle) {
$this->lDir0_DirTheta = (float) $thetaAngle;
$this->lDir0_DirTheta = (float)$thetaAngle;
return $this;
}
@ -154,9 +154,9 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLightBallColor($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$red = (float)$red;
$green = (float)$green;
$blue = (float)$blue;
$this->lBall_LinearRgb = "{$red} {$green} {$blue}";
return $this;
}
@ -168,7 +168,7 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLightBallIntensity($intensity) {
$this->lBall_Intensity = (float) $intensity;
$this->lBall_Intensity = (float)$intensity;
return $this;
}
@ -179,7 +179,7 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLightBallRadius($radius) {
$this->lBall_Radius = (float) $radius;
$this->lBall_Radius = (float)$radius;
return $this;
}
@ -192,9 +192,9 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setFogColor($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$red = (float)$red;
$green = (float)$green;
$blue = (float)$blue;
$this->fogColorSrgb = "{$red} {$green} {$blue}";
return $this;
}
@ -208,9 +208,9 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setSelfIllumColor($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$red = (float)$red;
$green = (float)$green;
$blue = (float)$blue;
$this->selfIllumColor = "{$red} {$green} {$blue}";
return $this;
}
@ -222,7 +222,7 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setSkyGradientScale($scale) {
$this->skyGradientV_Scale = (float) $scale;
$this->skyGradientV_Scale = (float)$scale;
return $this;
}
@ -234,8 +234,8 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function addSkyGradientKey($x, $color) {
$x = (float) $x;
$color = (string) $color;
$x = (float)$x;
$color = (string)$color;
$gradientKey = array('x' => $x, 'color' => $color);
array_push($this->skyGradientKeys, $gradientKey);
return $this;

View File

@ -64,7 +64,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setId($id) {
$this->id = (string) $id;
$this->id = (string)$id;
return $this;
}
@ -96,7 +96,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setModel($model) {
$this->model = (string) $model;
$this->model = (string)$model;
return $this;
}
@ -107,7 +107,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setThickness($thickness) {
$this->thickness = (float) $thickness;
$this->thickness = (float)$thickness;
return $this;
}
@ -118,7 +118,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setColor($color) {
$this->color = (string) $color;
$this->color = (string)$color;
return $this;
}
@ -129,7 +129,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setFocusColor($focusColor) {
$this->focusColor = (string) $focusColor;
$this->focusColor = (string)$focusColor;
return $this;
}
@ -140,7 +140,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setLightColor($lightColor) {
$this->lightColor = (string) $lightColor;
$this->lightColor = (string)$lightColor;
return $this;
}
@ -151,7 +151,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setFocusLightColor($focusLightColor) {
$this->focusLightColor = (string) $focusLightColor;
$this->focusLightColor = (string)$focusLightColor;
return $this;
}
@ -162,7 +162,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setYOffset($yOffset) {
$this->yOffset = (float) $yOffset;
$this->yOffset = (float)$yOffset;
return $this;
}
@ -173,7 +173,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setFocusYOffset($focusYOffset) {
$this->focusYOffset = (float) $focusYOffset;
$this->focusYOffset = (float)$focusYOffset;
return $this;
}
@ -184,7 +184,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setZOffset($zOffset) {
$this->zOffset = (float) $zOffset;
$this->zOffset = (float)$zOffset;
return $this;
}
@ -195,7 +195,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d
*/
public function setFocusZOffset($focusZOffset) {
$this->focusZOffset = (float) $focusZOffset;
$this->focusZOffset = (float)$focusZOffset;
return $this;
}

View File

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

View File

@ -2,7 +2,6 @@
namespace FML\Types;
use FML\Controls\Control;
use FML\Elements\Format;
/**
@ -15,12 +14,12 @@ use FML\Elements\Format;
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
*/
public function add(Control $child);
public function add(Renderable $child);
/**
* Remove all Children

View File

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