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,35 +2,37 @@
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
* (CMlControl) * (CMlControl)
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
abstract class Control implements Renderable, ScriptFeatureable { abstract class Control implements Renderable, ScriptFeatureable {
/* /*
* Constants * Constants
*/ */
const CENTER = 'center'; const CENTER = 'center';
const CENTER2 = 'center2'; const CENTER2 = 'center2';
const TOP = 'top'; const TOP = 'top';
const RIGHT = 'right'; const RIGHT = 'right';
const BOTTOM = 'bottom'; const BOTTOM = 'bottom';
const LEFT = 'left'; const LEFT = 'left';
/* /*
* Static Properties * Static Properties
@ -85,26 +87,29 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setId($id) { public function setId($id) {
$this->id = (string) $id; $this->id = (string)$id;
return $this; return $this;
} }
/** /**
* 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;
} }
$dangerousCharacters = array(' ', ' ', '.', '|', '-', PHP_EOL); $dangerousCharacters = array(' ', ' ', '.', '|', '-', PHP_EOL);
$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;
} }
@ -123,7 +128,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setX($x) { public function setX($x) {
$this->x = (float) $x; $this->x = (float)$x;
return $this; return $this;
} }
@ -134,7 +139,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setY($y) { public function setY($y) {
$this->y = (float) $y; $this->y = (float)$y;
return $this; return $this;
} }
@ -145,7 +150,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setZ($z) { public function setZ($z) {
$this->z = (float) $z; $this->z = (float)$z;
return $this; return $this;
} }
@ -173,7 +178,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setWidth($width) { public function setWidth($width) {
$this->width = (float) $width; $this->width = (float)$width;
return $this; return $this;
} }
@ -184,14 +189,14 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setHeight($height) { public function setHeight($height) {
$this->height = (float) $height; $this->height = (float)$height;
return $this; return $this;
} }
/** /**
* Set Control Size * Set Control Size
* *
* @param float $width Control Width * @param float $width Control Width
* @param float $height Control Height * @param float $height Control Height
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
@ -208,7 +213,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setHAlign($hAlign) { public function setHAlign($hAlign) {
$this->hAlign = (string) $hAlign; $this->hAlign = (string)$hAlign;
return $this; return $this;
} }
@ -219,7 +224,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setVAlign($vAlign) { public function setVAlign($vAlign) {
$this->vAlign = (string) $vAlign; $this->vAlign = (string)$vAlign;
return $this; return $this;
} }
@ -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
* *
@ -243,7 +268,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setScale($scale) { public function setScale($scale) {
$this->scale = (float) $scale; $this->scale = (float)$scale;
return $this; return $this;
} }
@ -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;
} }
@ -265,7 +290,7 @@ abstract class Control implements Renderable, ScriptFeatureable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function addClass($class) { public function addClass($class) {
$class = (string) $class; $class = (string)$class;
if (!in_array($class, $this->classes)) { if (!in_array($class, $this->classes)) {
array_push($this->classes, $class); array_push($this->classes, $class);
} }
@ -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,34 +318,34 @@ 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;
} }
/** /**
* Add a dynamic Feature to open a specific Player Profile * Add a dynamic Feature to open a specific Player Profile
* *
* @param string $login The Login of the Player * @param string $login The Login of the Player
* @param string $eventLabel (optional) Event on which the Player Profile will be opened * @param string $eventLabel (optional) Event on which the Player Profile will be opened
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
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;
} }
/** /**
* Add a dynamic Feature playing an UISound * Add a dynamic Feature playing an UISound
* *
* @param string $soundName UISound Name * @param string $soundName UISound Name
* @param int $variant (optional) Sound Variant * @param int $variant (optional) Sound Variant
* @param string $eventLabel (optional) Event on which the Sound will be played * @param string $eventLabel (optional) Event on which the Sound will be played
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
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;
} }
@ -328,14 +353,14 @@ abstract class Control implements Renderable, ScriptFeatureable {
* Add a dynamic Feature toggling another Control * Add a dynamic Feature toggling another Control
* *
* @param Control $toggledControl Toggled Control * @param Control $toggledControl Toggled Control
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label Name
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle * @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle * @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
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;
} }
@ -343,28 +368,53 @@ abstract class Control implements Renderable, ScriptFeatureable {
* Add a dynamic Feature showing a Tooltip on hovering * Add a dynamic Feature showing a Tooltip on hovering
* *
* @param Control $tooltipControl Tooltip Control * @param Control $tooltipControl Tooltip Control
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click * @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted * @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
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;
} }
/** /**
* Add a dynamic Feature showing a Tooltip on hovering * Add a dynamic Feature showing a Tooltip on hovering
* *
* @param Label $tooltipControl Tooltip Control * @param Label $tooltipControl Tooltip Control
* @param string $text The Text to display on the Tooltip Label * @param string $text The Text to display on the Tooltip Label
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click * @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted * @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
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,20 +1,21 @@
<?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
* (CMlEntry) * (CMlEntry)
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable { class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable {
/* /*
@ -59,7 +60,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string) $name; $this->name = (string)$name;
return $this; 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() * @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,47 +110,42 @@ 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) {
$this->style = (string) $style; $this->style = (string)$style;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\TextFormatable::setTextColor() * @see \FML\Types\TextFormatable::setTextColor()
*/ */
public function setTextColor($textColor) { public function setTextColor($textColor) {
$this->textColor = (string) $textColor; $this->textColor = (string)$textColor;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\TextFormatable::setTextSize() * @see \FML\Types\TextFormatable::setTextSize()
*/ */
public function setTextSize($textSize) { public function setTextSize($textSize) {
$this->textSize = (int) $textSize; $this->textSize = (int)$textSize;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\TextFormatable::setAreaColor() * @see \FML\Types\TextFormatable::setAreaColor()
*/ */
public function setAreaColor($areaColor) { public function setAreaColor($areaColor) {
$this->focusAreaColor1 = (string) $areaColor; $this->focusAreaColor1 = (string)$areaColor;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor() * @see \FML\Types\TextFormatable::setAreaFocusColor()
*/ */
public function setAreaFocusColor($areaFocusColor) { public function setAreaFocusColor($areaFocusColor) {
$this->focusAreaColor2 = (string) $areaFocusColor; $this->focusAreaColor2 = (string)$areaFocusColor;
return $this; return $this;
} }
@ -153,7 +156,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setAutoComplete($autoComplete) { public function setAutoComplete($autoComplete) {
$this->autoComplete = (bool) $autoComplete; $this->autoComplete = (bool)$autoComplete;
return $this; return $this;
} }
@ -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,25 +2,25 @@
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;
/** /**
* Frame Control * Frame Control
* (CMlFrame) * (CMlFrame)
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Frame extends Control implements Container { 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,22 +2,37 @@
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
* (CMlFrame) * (CMlFrame)
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
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;
@ -49,8 +64,8 @@ class Frame3d extends Frame implements Scriptable {
* @return \FML\Controls\Frame3d * @return \FML\Controls\Frame3d
*/ */
public function setStyle3dId($style3dId) { public function setStyle3dId($style3dId) {
$this->style3dId = (string) $style3dId; $this->style3dId = (string)$style3dId;
$this->style3d = null; $this->style3d = null;
return $this; return $this;
} }
@ -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,26 +4,26 @@ 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)
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class FrameInstance extends Control { class FrameInstance extends Control {
/* /*
* Protected Properties * Protected Properties
*/ */
protected $modelId = ''; protected $modelId = '';
/** @var FrameModel $model */
protected $model = null; protected $model = null;
/** /**
* Create a new Frame Instance * Create a new Frame Instance
* *
* @param string $modelId (optional) Frame Model Id * @param string $modelId (optional) Frame Model Id
* @param string $controlId (optional) Control Id * @param string $controlId (optional) Control Id
* @return \FML\Controls\Frame * @return \FML\Controls\Frame
*/ */
@ -35,7 +35,7 @@ class FrameInstance extends Control {
/** /**
* Construct a new Frame Instance * Construct a new Frame Instance
* *
* @param string $modelId (optional) Frame Model Id * @param string $modelId (optional) Frame Model Id
* @param string $controlId (optional) Control Id * @param string $controlId (optional) Control Id
*/ */
public function __construct($modelId = null, $controlId = null) { public function __construct($modelId = null, $controlId = null) {
@ -53,8 +53,8 @@ class FrameInstance extends Control {
* @return \FML\Controls\FrameInstance * @return \FML\Controls\FrameInstance
*/ */
public function setModelId($modelId) { public function setModelId($modelId) {
$this->modelId = (string) $modelId; $this->modelId = (string)$modelId;
$this->model = null; $this->model = null;
return $this; return $this;
} }
@ -65,13 +65,12 @@ class FrameInstance extends Control {
* @return \FML\Controls\FrameInstance * @return \FML\Controls\FrameInstance
*/ */
public function setModel(FrameModel $frameModel) { public function setModel(FrameModel $frameModel) {
$this->model = $frameModel; $this->model = $frameModel;
$this->modelId = ''; $this->modelId = '';
return $this; return $this;
} }
/** /**
*
* @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;
@ -13,9 +14,9 @@ use FML\Types\SubStyleable;
* Quad Control * Quad Control
* (CMlQuad) * (CMlQuad)
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable { class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable {
/* /*
@ -68,7 +69,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setImage($image) { public function setImage($image) {
$this->image = (string) $image; $this->image = (string)$image;
return $this; return $this;
} }
@ -79,7 +80,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setImageId($imageId) { public function setImageId($imageId) {
$this->imageId = (string) $imageId; $this->imageId = (string)$imageId;
return $this; return $this;
} }
@ -90,7 +91,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setImageFocus($imageFocus) { public function setImageFocus($imageFocus) {
$this->imageFocus = (string) $imageFocus; $this->imageFocus = (string)$imageFocus;
return $this; return $this;
} }
@ -101,7 +102,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setImageFocusId($imageFocusId) { public function setImageFocusId($imageFocusId) {
$this->imageFocusId = (string) $imageFocusId; $this->imageFocusId = (string)$imageFocusId;
return $this; return $this;
} }
@ -112,7 +113,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setColorize($colorize) { public function setColorize($colorize) {
$this->colorize = (string) $colorize; $this->colorize = (string)$colorize;
return $this; return $this;
} }
@ -123,7 +124,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setModulizeColor($modulizeColor) { public function setModulizeColor($modulizeColor) {
$this->modulizeColor = (string) $modulizeColor; $this->modulizeColor = (string)$modulizeColor;
return $this; return $this;
} }
@ -139,16 +140,14 @@ 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) {
$this->action = (string) $action; $this->action = (string)$action;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\Actionable::getAction() * @see \FML\Types\Actionable::getAction()
*/ */
public function getAction() { public function getAction() {
@ -156,61 +155,54 @@ 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) {
$this->actionKey = (int) $actionKey; $this->actionKey = (int)$actionKey;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\BgColorable::setBgColor() * @see \FML\Types\BgColorable::setBgColor()
*/ */
public function setBgColor($bgColor) { public function setBgColor($bgColor) {
$this->bgColor = (string) $bgColor; $this->bgColor = (string)$bgColor;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\Linkable::setUrl() * @see \FML\Types\Linkable::setUrl()
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string) $url; $this->url = (string)$url;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\Linkable::setUrlId() * @see \FML\Types\Linkable::setUrlId()
*/ */
public function setUrlId($urlId) { public function setUrlId($urlId) {
$this->urlId = (string) $urlId; $this->urlId = (string)$urlId;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\Linkable::setManialink() * @see \FML\Types\Linkable::setManialink()
*/ */
public function setManialink($manialink) { public function setManialink($manialink) {
$this->manialink = (string) $manialink; $this->manialink = (string)$manialink;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\Linkable::setManialinkId() * @see \FML\Types\Linkable::setManialinkId()
*/ */
public function setManialinkId($manialinkId) { public function setManialinkId($manialinkId) {
$this->manialinkId = (string) $manialinkId; $this->manialinkId = (string)$manialinkId;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\Scriptable::setScriptEvents() * @see \FML\Types\Scriptable::setScriptEvents()
*/ */
public function setScriptEvents($scriptEvents) { public function setScriptEvents($scriptEvents) {
@ -219,25 +211,22 @@ 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) {
$this->style = (string) $style; $this->style = (string)$style;
return $this; return $this;
} }
/** /**
*
* @see \FML\Types\SubStyleable::setSubStyle() * @see \FML\Types\SubStyleable::setSubStyle()
*/ */
public function setSubStyle($subStyle) { public function setSubStyle($subStyle) {
$this->subStyle = (string) $subStyle; $this->subStyle = (string)$subStyle;
return $this; return $this;
} }
/** /**
*
* @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

@ -5,9 +5,9 @@ namespace FML;
/** /**
* Class representing a Custom_UI * Class representing a Custom_UI
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class CustomUI { class CustomUI {
/* /*
@ -47,7 +47,7 @@ class CustomUI {
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setXMLEncoding($encoding) { public function setXMLEncoding($encoding) {
$this->encoding = (string) $encoding; $this->encoding = (string)$encoding;
return $this; return $this;
} }
@ -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) {
@ -146,9 +146,9 @@ class CustomUI {
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($domDocument = null) { public function render($domDocument = null) {
$isChild = (bool) $domDocument; $isChild = (bool)$domDocument;
if (!$isChild) { if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding); $domDocument = new \DOMDocument('1.0', $this->encoding);
$domDocument->xmlStandalone = true; $domDocument->xmlStandalone = true;
} }
$xmlElement = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
@ -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);
@ -175,7 +177,7 @@ class CustomUI {
*/ */
public function __toString() { public function __toString() {
$domDocument = $this->render(); $domDocument = $this->render();
$xmlText = $domDocument->saveXML(); $xmlText = $domDocument->saveXML();
return $xmlText; return $xmlText;
} }
@ -185,15 +187,15 @@ class CustomUI {
* @return array * @return array
*/ */
protected function getSettings() { protected function getSettings() {
$settings = array(); $settings = array();
$settings['challenge_info'] = $this->challengeInfoVisible; $settings['challenge_info'] = $this->challengeInfoVisible;
$settings['chat'] = $this->chatVisible; $settings['chat'] = $this->chatVisible;
$settings['checkpoint_list'] = $this->checkpointListVisible; $settings['checkpoint_list'] = $this->checkpointListVisible;
$settings['global'] = $this->globalVisible; $settings['global'] = $this->globalVisible;
$settings['net_infos'] = $this->netInfosVisible; $settings['net_infos'] = $this->netInfosVisible;
$settings['notice'] = $this->noticeVisible; $settings['notice'] = $this->noticeVisible;
$settings['round_scores'] = $this->roundScoresVisible; $settings['round_scores'] = $this->roundScoresVisible;
$settings['scoretable'] = $this->scoretableVisible; $settings['scoretable'] = $this->scoretableVisible;
return $settings; return $settings;
} }
} }

View File

@ -2,16 +2,15 @@
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;
/** /**
* Class representing a Frame Model * Class representing a Frame Model
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class FrameModel implements Container, Renderable { class FrameModel implements Container, 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;
/** /**
@ -29,7 +29,7 @@ class FrameModel implements Container, Renderable {
* @return \FML\Elements\FrameModel * @return \FML\Elements\FrameModel
*/ */
public function setId($id) { public function setId($id) {
$this->id = (string) $id; $this->id = (string)$id;
return $this; return $this;
} }
@ -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,14 +18,13 @@ 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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class ManiaCode { class ManiaCode {
/* /*
@ -58,7 +58,7 @@ class ManiaCode {
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function setXmlEncoding($encoding) { public function setXmlEncoding($encoding) {
$this->encoding = (string) $encoding; $this->encoding = (string)$encoding;
return $this; return $this;
} }
@ -90,7 +90,7 @@ class ManiaCode {
* *
* @param string $name Macroblock Name * @param string $name Macroblock Name
* @param string $file Macroblock File * @param string $file Macroblock File
* @param string $url Macroblock Url * @param string $url Macroblock Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addInstallMacroblock($name, $file, $url) { public function addInstallMacroblock($name, $file, $url) {
@ -103,7 +103,7 @@ class ManiaCode {
* Install a Map * Install a Map
* *
* @param string $name Map Name * @param string $name Map Name
* @param string $url Map Url * @param string $url Map Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addInstallMap($name, $url) { public function addInstallMap($name, $url) {
@ -116,7 +116,7 @@ class ManiaCode {
* Play a Map * Play a Map
* *
* @param string $name Map Name * @param string $name Map Name
* @param string $url Map Url * @param string $url Map Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addPlayMap($name, $url) { public function addPlayMap($name, $url) {
@ -129,7 +129,7 @@ class ManiaCode {
* Install a Replay * Install a Replay
* *
* @param string $name Replay Name * @param string $name Replay Name
* @param string $url Replay Url * @param string $url Replay Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addInstallReplay($name, $url) { public function addInstallReplay($name, $url) {
@ -142,7 +142,7 @@ class ManiaCode {
* View a Replay * View a Replay
* *
* @param string $name Replay Name * @param string $name Replay Name
* @param string $url Replay Url * @param string $url Replay Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addViewReplay($name, $url) { public function addViewReplay($name, $url) {
@ -155,7 +155,7 @@ class ManiaCode {
* Play a Replay * Play a Replay
* *
* @param string $name Replay Name * @param string $name Replay Name
* @param string $url Replay Url * @param string $url Replay Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addPlayReplay($name, $url) { public function addPlayReplay($name, $url) {
@ -169,7 +169,7 @@ class ManiaCode {
* *
* @param string $name Skin Name * @param string $name Skin Name
* @param string $file Skin File * @param string $file Skin File
* @param string $url Skin Url * @param string $url Skin Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addInstallSkin($name, $file, $url) { public function addInstallSkin($name, $file, $url) {
@ -183,7 +183,7 @@ class ManiaCode {
* *
* @param string $name Skin Name * @param string $name Skin Name
* @param string $file Skin File * @param string $file Skin File
* @param string $url Skin Url * @param string $url Skin Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addGetSkin($name, $file, $url) { public function addGetSkin($name, $file, $url) {
@ -245,7 +245,7 @@ class ManiaCode {
* *
* @param string $name Script Name * @param string $name Script Name
* @param string $file Script File * @param string $file Script File
* @param string $url Script Url * @param string $url Script Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addInstallScript($name, $file, $url) { public function addInstallScript($name, $file, $url) {
@ -259,7 +259,7 @@ class ManiaCode {
* *
* @param string $name Pack Name * @param string $name Pack Name
* @param string $file Pack File * @param string $file Pack File
* @param string $url Pack Url * @param string $url Pack Url
* @return \FML\ManiaCode * @return \FML\ManiaCode
*/ */
public function addInstallPack($name, $file, $url) { public function addInstallPack($name, $file, $url) {
@ -296,14 +296,15 @@ class ManiaCode {
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($echo = false) { public function render($echo = false) {
$domDocument = new \DOMDocument('1.0', $this->encoding); $domDocument = new \DOMDocument('1.0', $this->encoding);
$domDocument->xmlStandalone = true; $domDocument->xmlStandalone = true;
$maniaCode = $domDocument->createElement($this->tagName); $maniaCode = $domDocument->createElement($this->tagName);
$domDocument->appendChild($maniaCode); $domDocument->appendChild($maniaCode);
if ($this->noConfirmation) { if ($this->noConfirmation) {
$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);
} }
@ -321,7 +322,7 @@ class ManiaCode {
*/ */
public function __toString() { public function __toString() {
$domDocument = $this->render(); $domDocument = $this->render();
$xmlText = $domDocument->saveXML(); $xmlText = $domDocument->saveXML();
return $xmlText; return $xmlText;
} }
} }

View File

@ -11,19 +11,19 @@ use FML\Types\ScriptFeatureable;
/** /**
* Class representing a ManiaLink * Class representing a ManiaLink
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class ManiaLink { class ManiaLink {
/* /*
* Constants * Constants
*/ */
const BACKGROUND_0 = '0'; const BACKGROUND_0 = '0';
const BACKGROUND_1 = '1'; const BACKGROUND_1 = '1';
const BACKGROUND_STARS = 'stars'; const BACKGROUND_STARS = 'stars';
const BACKGROUND_STATIONS = 'stations'; const BACKGROUND_STATIONS = 'stations';
const BACKGROUND_TITLE = 'title'; const BACKGROUND_TITLE = 'title';
/* /*
* Protected Properties * Protected Properties
@ -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;
/** /**
@ -69,7 +72,7 @@ class ManiaLink {
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setXmlEncoding($encoding) { public function setXmlEncoding($encoding) {
$this->encoding = (string) $encoding; $this->encoding = (string)$encoding;
return $this; return $this;
} }
@ -80,7 +83,7 @@ class ManiaLink {
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setId($id) { public function setId($id) {
$this->id = (string) $id; $this->id = (string)$id;
return $this; return $this;
} }
@ -100,7 +103,7 @@ class ManiaLink {
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setBackground($background) { public function setBackground($background) {
$this->background = (string) $background; $this->background = (string)$background;
return $this; return $this;
} }
@ -122,7 +125,7 @@ class ManiaLink {
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setTimeout($timeout) { public function setTimeout($timeout) {
$this->timeout = (int) $timeout; $this->timeout = (int)$timeout;
return $this; return $this;
} }
@ -224,14 +227,14 @@ class ManiaLink {
/** /**
* Render the XML Document * Render the XML Document
* *
* @param bool (optional) $echo If the XML Text should be echoed and the Content-Type Header should be set * @param bool (optional) $echo If the XML Text should be echoed and the Content-Type Header should be set
* @param \DOMDocument $domDocument (optional) DOMDocument for which the XML Element should be created * @param \DOMDocument $domDocument (optional) DOMDocument for which the XML Element should be created
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($echo = false, $domDocument = null) { public function render($echo = false, $domDocument = null) {
$isChild = (bool) $domDocument; $isChild = (bool)$domDocument;
if (!$isChild) { if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding); $domDocument = new \DOMDocument('1.0', $this->encoding);
$domDocument->xmlStandalone = true; $domDocument->xmlStandalone = true;
} }
$maniaLink = $domDocument->createElement($this->tagName); $maniaLink = $domDocument->createElement($this->tagName);
@ -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) {
@ -297,7 +301,7 @@ class ManiaLink {
*/ */
public function __toString() { public function __toString() {
$domDocument = $this->render(); $domDocument = $this->render();
$xmlText = $domDocument->saveXML(); $xmlText = $domDocument->saveXML();
return $xmlText; return $xmlText;
} }
} }

View File

@ -5,9 +5,9 @@ namespace FML;
/** /**
* Class holding several ManiaLinks at once * Class holding several ManiaLinks at once
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class ManiaLinks { class ManiaLinks {
/* /*
@ -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;
/** /**
@ -41,7 +42,7 @@ class ManiaLinks {
* @return \FML\ManiaLinks * @return \FML\ManiaLinks
*/ */
public function setXmlEncoding($encoding) { public function setXmlEncoding($encoding) {
$this->encoding = (string) $encoding; $this->encoding = (string)$encoding;
return $this; return $this;
} }
@ -99,11 +100,12 @@ class ManiaLinks {
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($echo = false) { public function render($echo = false) {
$domDocument = new \DOMDocument('1.0', $this->encoding); $domDocument = new \DOMDocument('1.0', $this->encoding);
$domDocument->xmlStandalone = true; $domDocument->xmlStandalone = true;
$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);
} }
@ -125,7 +127,7 @@ class ManiaLinks {
*/ */
public function __toString() { public function __toString() {
$domDocument = $this->render(); $domDocument = $this->render();
$xmlText = $domDocument->saveXML(); $xmlText = $domDocument->saveXML();
return $xmlText; return $xmlText;
} }
} }

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,32 +3,33 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class ActionTrigger extends ScriptFeature { 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;
/** /**
* Construct a new Action Trigger Feature * Construct a new Action Trigger Feature
* *
* @param string $actionName (optional) Triggered Action * @param string $actionName (optional) Triggered Action
* @param Control $control (optional) Action Control * @param Control $control (optional) Action Control
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label Name
*/ */
public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) { public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
$this->setActionName($actionName); $this->setActionName($actionName);
@ -55,7 +56,9 @@ class ActionTrigger extends ScriptFeature {
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
$control->setScriptEvents(true); if ($control instanceof Scriptable) {
$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) {
@ -89,13 +91,12 @@ class ActionTrigger extends ScriptFeature {
$actionName = Builder::escapeText($this->actionName); $actionName = Builder::escapeText($this->actionName);
if ($this->control) { if ($this->control) {
// Control event // Control event
$controlId = Builder::escapeText($this->control->getId()); $controlId = Builder::escapeText($this->control->getId());
$scriptText = " $scriptText = "
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,25 +2,23 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Clock extends ScriptFeature { 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;
@ -28,9 +26,9 @@ class Clock extends ScriptFeature {
/** /**
* Construct a new Clock Feature * Construct a new Clock Feature
* *
* @param Label $label (optional) Clock Label * @param Label $label (optional) Clock Label
* @param bool $showSeconds (optional) Whether the Seconds should be shown * @param bool $showSeconds (optional) Whether the Seconds should be shown
* @param bool $showFullDate (optional) Whether the Date should be shown * @param bool $showFullDate (optional) Whether the Date should be shown
*/ */
public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) { public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) {
$this->setLabel($label); $this->setLabel($label);
@ -57,7 +55,7 @@ class Clock extends ScriptFeature {
* @return \FML\Script\Features\Clock * @return \FML\Script\Features\Clock
*/ */
public function setShowSeconds($showSeconds) { public function setShowSeconds($showSeconds) {
$this->showSeconds = (bool) $showSeconds; $this->showSeconds = (bool)$showSeconds;
return $this; return $this;
} }
@ -68,12 +66,11 @@ class Clock extends ScriptFeature {
* @return \FML\Script\Features\Clock * @return \FML\Script\Features\Clock
*/ */
public function setShowFullDate($showFullDate) { public function setShowFullDate($showFullDate) {
$this->showFullDate = (bool) $showFullDate; $this->showFullDate = (bool)$showFullDate;
return $this; return $this;
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -88,7 +85,7 @@ class Clock extends ScriptFeature {
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
$controlId = $this->label->getId(true); $controlId = $this->label->getId(true);
$scriptText = " $scriptText = "
declare ClockLabel <=> (Page.GetFirstChild(\"{$controlId}\") as CMlLabel); declare ClockLabel <=> (Page.GetFirstChild(\"{$controlId}\") as CMlLabel);
declare TimeText = CurrentLocalDateText;"; declare TimeText = CurrentLocalDateText;";

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,34 +2,32 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class EntrySubmit extends ScriptFeature { class EntrySubmit extends ScriptFeature {
/* /*
* Protected Properties * Protected Properties
*/ */
/** @var Entry $entry */
protected $entry = null; protected $entry = null;
protected $url = null; protected $url = null;
/** /**
* Construct a new Entry Submit Feature * Construct a new Entry Submit Feature
* *
* @param Entry $entry (optional) Entry Control * @param Entry $entry (optional) Entry Control
* @param string $url (optional) Submit Url * @param string $url (optional) Submit Url
*/ */
public function __construct(Entry $entry = null, $url = null) { public function __construct(Entry $entry = null, $url = null) {
$this->setEntry($entry); $this->setEntry($entry);
@ -56,12 +54,11 @@ class EntrySubmit extends ScriptFeature {
* @return \FML\Script\Features\EntrySubmit * @return \FML\Script\Features\EntrySubmit
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = (string) $url; $this->url = (string)$url;
return $this; return $this;
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -76,9 +73,9 @@ class EntrySubmit extends ScriptFeature {
* @return string * @return string
*/ */
protected function getScriptText() { protected function getScriptText() {
$controlId = $this->entry->getId(true); $controlId = $this->entry->getId(true);
$url = $this->buildCompatibleUrl(); $url = $this->buildCompatibleUrl();
$entryName = Builder::escapeText($this->entry->getName()); $entryName = Builder::escapeText($this->entry->getName());
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == \"{$controlId}\") {
declare Entry <=> (Event.Control as CMlEntry); declare Entry <=> (Event.Control as CMlEntry);
@ -94,12 +91,11 @@ if (Event.Control.ControlId == \"{$controlId}\") {
* @return string * @return string
*/ */
protected function buildCompatibleUrl() { protected function buildCompatibleUrl() {
$url = $this->url; $url = $this->url;
$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,18 +2,17 @@
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
* *
* @author steeffeen * @author steeffeen
* @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php * @link http://destroflyer.mania-community.de/maniascript/keycharid_table.php
* @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
*/ */
class KeyAction extends ScriptFeature { class KeyAction extends ScriptFeature {
/* /*
@ -27,9 +26,9 @@ class KeyAction extends ScriptFeature {
/** /**
* Construct a new Key Action Feature * Construct a new Key Action Feature
* *
* @param string $actionName (optional) Triggered Action * @param string $actionName (optional) Triggered Action
* @param string $keyName (optional) Key Name * @param string $keyName (optional) Key Name
* @param int $keyCode (optional) Key Code * @param int $keyCode (optional) Key Code
* @param string $charPressed (optional) Pressed Char * @param string $charPressed (optional) Pressed Char
*/ */
public function __construct($actionName = null, $keyName = null, $keyCode = null, $charPressed = null) { public function __construct($actionName = null, $keyName = null, $keyCode = null, $charPressed = null) {
@ -46,7 +45,7 @@ class KeyAction extends ScriptFeature {
* @return \FML\Script\Features\KeyAction * @return \FML\Script\Features\KeyAction
*/ */
public function setActionName($actionName) { public function setActionName($actionName) {
$this->actionName = (string) $actionName; $this->actionName = (string)$actionName;
return $this; return $this;
} }
@ -57,7 +56,7 @@ class KeyAction extends ScriptFeature {
* @return \FML\Script\Features\KeyAction * @return \FML\Script\Features\KeyAction
*/ */
public function setKeyName($keyName) { public function setKeyName($keyName) {
$this->keyName = (string) $keyName; $this->keyName = (string)$keyName;
return $this; return $this;
} }
@ -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) {
@ -99,15 +97,14 @@ class KeyAction extends ScriptFeature {
*/ */
protected function getScriptText() { protected function getScriptText() {
$actionName = Builder::escapeText($this->actionName); $actionName = Builder::escapeText($this->actionName);
$key = 'KeyName'; $key = 'KeyName';
$value = $this->keyName; $value = $this->keyName;
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;
} }
$scriptText = " $scriptText = "
if (Event.{$key} == \"{$value}\") { if (Event.{$key} == \"{$value}\") {

View File

@ -3,30 +3,31 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class MapInfo extends ScriptFeature { class MapInfo extends ScriptFeature {
/* /*
* Protected Properties * Protected Properties
*/ */
/** @var Control $control */
protected $control = null; protected $control = null;
protected $labelName = null; protected $labelName = null;
/** /**
* Construct a new Map Info Feature * Construct a new Map Info Feature
* *
* @param Control $control (optional) Map Info Control * @param Control $control (optional) Map Info Control
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label Name
*/ */
public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) { public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) {
$this->setControl($control); $this->setControl($control);
@ -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();
$control->setScriptEvents(true); if ($control instanceof Scriptable) {
$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) {
@ -74,13 +76,12 @@ class MapInfo extends ScriptFeature {
protected function getScriptText() { protected function getScriptText() {
if ($this->control) { if ($this->control) {
// Control event // Control event
$controlId = Builder::escapeText($this->control->getId()); $controlId = Builder::escapeText($this->control->getId());
$scriptText = " $scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") { if (Event.Control.ControlId == \"{$controlId}\") {
ShowCurChallengeCard(); ShowCurChallengeCard();
}"; }";
} } else {
else {
// Other // Other
$scriptText = " $scriptText = "
ShowCurChallengeCard();"; ShowCurChallengeCard();";

View File

@ -3,17 +3,16 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Menu extends ScriptFeature { class Menu extends ScriptFeature {
/* /*
@ -25,26 +24,27 @@ class Menu extends ScriptFeature {
* Protected Properties * Protected Properties
*/ */
protected $elements = array(); protected $elements = array();
/** @var MenuElement $startElement */
protected $startElement = null; protected $startElement = null;
/** /**
* Construct a new Menu Feature * Construct a new Menu Feature
* *
* @param Control $item (optional) Item Control in the Menu Bar * @param Control $item (optional) Item Control in the Menu Bar
* @param Control $control (optional) Toggled Menu Control * @param Control $control (optional) Toggled Menu Control
*/ */
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);
} }
} }
/** /**
* Add a new Element to the Menu * Add a new Element to the Menu
* *
* @param Control $item Item Control in the Menu Bar * @param Control $item Item Control in the Menu Bar
* @param Control $control Toggled Menu Control * @param Control $control Toggled Menu Control
* @param bool $isStartElement (optional) Whether the Menu should start with this Element * @param bool $isStartElement (optional) Whether the Menu should start with this Element
* @return \FML\Script\Features\Menu * @return \FML\Script\Features\Menu
*/ */
public function addElement(Control $item, Control $control, $isStartElement = false) { public function addElement(Control $item, Control $control, $isStartElement = false) {
@ -56,16 +56,15 @@ class Menu extends ScriptFeature {
/** /**
* Append an Element to the Menu * Append an Element to the Menu
* *
* @param MenuElement $menuElement Menu Element * @param MenuElement $menuElement Menu Element
* @param bool $isStartElement (optional) Whether the Menu should start with this Element * @param bool $isStartElement (optional) Whether the Menu should start with this Element
* @return \FML\Script\Features\Menu * @return \FML\Script\Features\Menu
*/ */
public function appendElement(MenuElement $menuElement, $isStartElement = false) { public function appendElement(MenuElement $menuElement, $isStartElement = false) {
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,12 +85,11 @@ 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) {
$updateFunctionName = self::FUNCTION_UPDATE_MENU; $updateFunctionName = self::FUNCTION_UPDATE_MENU;
$elementsArrayText = $this->getElementsArrayText(); $elementsArrayText = $this->getElementsArrayText();
// OnInit // OnInit
if ($this->startElement) { if ($this->startElement) {
@ -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,13 +3,14 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class MenuElement { class MenuElement {
/* /*
@ -21,7 +22,7 @@ class MenuElement {
/** /**
* Create a new Menu Element * Create a new Menu Element
* *
* @param Control $item (optional) Item Control in the Menu Bar * @param Control $item (optional) Item Control in the Menu Bar
* @param Control $control (optional) Toggled Menu Control * @param Control $control (optional) Toggled Menu Control
*/ */
public function __construct(Control $item = null, Control $control = null) { public function __construct(Control $item = null, Control $control = null) {
@ -37,7 +38,9 @@ class MenuElement {
*/ */
public function setItem(Control $item) { public function setItem(Control $item) {
$item->checkId(); $item->checkId();
$item->setScriptEvents(true); if ($item instanceof Scriptable) {
$item->setScriptEvents(true);
}
$this->item = $item; $this->item = $item;
return $this; return $this;
} }

View File

@ -3,24 +3,24 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Paging extends ScriptFeature { class Paging extends ScriptFeature {
/* /*
* Constants * Constants
*/ */
const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage'; const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage';
const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage'; const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage';
/* /*
@ -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;
@ -50,7 +51,7 @@ class Paging extends ScriptFeature {
* Add a new Page Control * Add a new Page Control
* *
* @param Control $pageControl Page Control * @param Control $pageControl Page Control
* @param string $pageNumber (optional) Page Number * @param string $pageNumber (optional) Page Number
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging
*/ */
public function addPage(Control $pageControl, $pageNumber = null) { public function addPage(Control $pageControl, $pageNumber = null) {
@ -77,7 +78,7 @@ class Paging extends ScriptFeature {
* Add a new Button to browse through the Pages * Add a new Button to browse through the Pages
* *
* @param Control $buttonControl Button used for Browsing * @param Control $buttonControl Button used for Browsing
* @param int $browseAction (optional) Number of browsed Pages per Click * @param int $browseAction (optional) Number of browsed Pages per Click
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging
*/ */
public function addButton(Control $buttonControl, $browseAction = null) { public function addButton(Control $buttonControl, $browseAction = 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;
} }
} }
@ -125,7 +125,7 @@ class Paging extends ScriptFeature {
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging
*/ */
public function setStartPageNumber($startPageNumber) { 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 * @return \FML\Script\Features\Paging
*/ */
public function setCustomMaxPageNumber($maxPageNumber) { public function setCustomMaxPageNumber($maxPageNumber) {
$this->customMaxPageNumber = (int) $maxPageNumber; $this->customMaxPageNumber = (int)$maxPageNumber;
return $this; return $this;
} }
@ -146,7 +146,7 @@ class Paging extends ScriptFeature {
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging
*/ */
public function setPreviousChunkAction($previousChunkAction) { public function setPreviousChunkAction($previousChunkAction) {
$this->previousChunkAction = (string) $previousChunkAction; $this->previousChunkAction = (string)$previousChunkAction;
return $this; return $this;
} }
@ -157,7 +157,7 @@ class Paging extends ScriptFeature {
* @return \FML\Script\Features\Paging * @return \FML\Script\Features\Paging
*/ */
public function setNextChunkAction($nextChunkAction) { public function setNextChunkAction($nextChunkAction) {
$this->nextChunkAction = (string) $nextChunkAction; $this->nextChunkAction = (string)$nextChunkAction;
return $this; return $this;
} }
@ -178,15 +178,13 @@ 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;
return $this; return $this;
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -196,26 +194,26 @@ class Paging extends ScriptFeature {
$script->setScriptInclude(ScriptInclude::TEXTLIB); $script->setScriptInclude(ScriptInclude::TEXTLIB);
$currentPageVariable = self::VAR_CURRENT_PAGE; $currentPageVariable = self::VAR_CURRENT_PAGE;
$updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE; $updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE;
$minPageNumber = 1; $minPageNumber = 1;
$startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber); $startPageNumber = (is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber);
$maxPage = $this->getMaxPage(); $maxPage = $this->getMaxPage();
$maxPageNumber = $this->customMaxPageNumber; $maxPageNumber = $this->customMaxPageNumber;
if (!is_int($maxPageNumber)) { if (!is_int($maxPageNumber)) {
$maxPageNumber = $maxPage->getPageNumber(); $maxPageNumber = $maxPage->getPageNumber();
} }
$pagingId = $maxPage->getControl()->getId(true); $pagingId = $maxPage->getControl()->getId(true);
$pageLabelId = ''; $pageLabelId = '';
if ($this->label) { if ($this->label) {
$pageLabelId = $this->label->getId(true); $pageLabelId = $this->label->getId(true);
} }
$pagesArrayText = $this->getPagesArrayText(); $pagesArrayText = $this->getPagesArrayText();
$pageButtonsArrayText = $this->getPageButtonsArrayText(); $pageButtonsArrayText = $this->getPageButtonsArrayText();
$previousChunkAction = Builder::escapeText($this->previousChunkAction); $previousChunkAction = Builder::escapeText($this->previousChunkAction);
$nextChunkAction = Builder::escapeText($this->nextChunkAction); $nextChunkAction = Builder::escapeText($this->nextChunkAction);
$chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber); $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
// Init // Init
@ -282,12 +280,13 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
*/ */
protected function getMinPage() { protected function getMinPage() {
$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;
$minPage = $page; $minPage = $page;
} }
} }
return $minPage; return $minPage;
@ -300,12 +299,13 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
*/ */
protected function getMaxPage() { protected function getMaxPage() {
$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;
$maxPage = $page; $maxPage = $page;
} }
} }
return $maxPage; return $maxPage;
@ -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,13 +3,14 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class PagingButton { class PagingButton {
/* /*
@ -21,8 +22,8 @@ class PagingButton {
/** /**
* Construct a new Paging Button * Construct a new Paging Button
* *
* @param Control $control (optional) Browse Control * @param Control $control (optional) Browse Control
* @param int $browseAction (optional) Number of browsed Pages per Click * @param int $browseAction (optional) Number of browsed Pages per Click
*/ */
public function __construct(Control $control = null, $browseAction = null) { public function __construct(Control $control = null, $browseAction = null) {
$this->setControl($control); $this->setControl($control);
@ -37,7 +38,9 @@ class PagingButton {
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
$control->setScriptEvents(true); if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
}
$this->control = $control; $this->control = $control;
return $this; return $this;
} }
@ -58,7 +61,7 @@ class PagingButton {
* @return \FML\Script\Features\PagingButton * @return \FML\Script\Features\PagingButton
*/ */
public function setBrowseAction($browseAction) { public function setBrowseAction($browseAction) {
$this->browseAction = (int) $browseAction; $this->browseAction = (int)$browseAction;
return $this; return $this;
} }

View File

@ -3,31 +3,33 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class PlayerProfile extends ScriptFeature { 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;
/** /**
* Construct a new Player Profile Feature * Construct a new Player Profile Feature
* *
* @param string $login (optional) Player Login * @param string $login (optional) Player Login
* @param Control $control (optional) Action Control * @param Control $control (optional) Action Control
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label Name
*/ */
public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) { public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
$this->setLogin($login); $this->setLogin($login);
@ -54,7 +56,9 @@ class PlayerProfile extends ScriptFeature {
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
$control->setScriptEvents(true); if ($control instanceof Scriptable) {
$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) {
@ -88,13 +91,12 @@ class PlayerProfile extends ScriptFeature {
$login = Builder::escapeText($this->login); $login = Builder::escapeText($this->login);
if ($this->control) { if ($this->control) {
// Control event // Control event
$controlId = Builder::escapeText($this->control->getId()); $controlId = Builder::escapeText($this->control->getId());
$scriptText = " $scriptText = "
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,20 +5,22 @@ 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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Toggle extends ScriptFeature { 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;
@ -28,10 +30,10 @@ class Toggle extends ScriptFeature {
* Construct a new Toggle Feature * Construct a new Toggle Feature
* *
* @param Control $togglingControl (optional) Toggling Control * @param Control $togglingControl (optional) Toggling Control
* @param Control $toggledControl (optional) Toggled Control * @param Control $toggledControl (optional) Toggled Control
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label Name
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle * @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle * @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
*/ */
public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) { public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
$this->setTogglingControl($togglingControl); $this->setTogglingControl($togglingControl);
@ -49,7 +51,9 @@ class Toggle extends ScriptFeature {
*/ */
public function setTogglingControl(Control $control) { public function setTogglingControl(Control $control) {
$control->checkId(); $control->checkId();
$control->setScriptEvents(true); if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
}
$this->togglingControl = $control; $this->togglingControl = $control;
return $this; return $this;
} }
@ -73,7 +77,7 @@ class Toggle extends ScriptFeature {
* @return \FML\Script\Features\Toggle * @return \FML\Script\Features\Toggle
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = (string) $labelName; $this->labelName = (string)$labelName;
return $this; return $this;
} }
@ -84,7 +88,7 @@ class Toggle extends ScriptFeature {
* @return \FML\Script\Features\Toggle * @return \FML\Script\Features\Toggle
*/ */
public function setOnlyShow($onlyShow) { public function setOnlyShow($onlyShow) {
$this->onlyShow = (bool) $onlyShow; $this->onlyShow = (bool)$onlyShow;
return $this; return $this;
} }
@ -95,12 +99,11 @@ class Toggle extends ScriptFeature {
* @return \FML\Script\Features\Toggle * @return \FML\Script\Features\Toggle
*/ */
public function setOnlyHide($onlyHide) { public function setOnlyHide($onlyHide) {
$this->onlyHide = (bool) $onlyHide; $this->onlyHide = (bool)$onlyHide;
return $this; return $this;
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -115,12 +118,11 @@ class Toggle extends ScriptFeature {
*/ */
protected function getScriptText() { protected function getScriptText() {
$togglingControlId = $this->togglingControl->getId(true); $togglingControlId = $this->togglingControl->getId(true);
$toggledControlId = $this->toggledControl->getId(true); $toggledControlId = $this->toggledControl->getId(true);
$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,25 +3,26 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Tooltip extends ScriptFeature { 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;
@ -30,11 +31,11 @@ class Tooltip extends ScriptFeature {
/** /**
* Construct a new Tooltip Feature * Construct a new Tooltip Feature
* *
* @param Control $hoverControl (optional) Hover Control * @param Control $hoverControl (optional) Hover Control
* @param Control $tooltipControl (optional) Tooltip Control * @param Control $tooltipControl (optional) Tooltip Control
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click * @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted * @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @param string $text (optional) The Text to display if the TooltipControl is a Label * @param string $text (optional) The Text to display if the TooltipControl is a Label
*/ */
public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = false, $invert = false, $text = null) { public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = false, $invert = false, $text = null) {
$this->setHoverControl($hoverControl); $this->setHoverControl($hoverControl);
@ -52,7 +53,9 @@ class Tooltip extends ScriptFeature {
*/ */
public function setHoverControl(Control $hoverControl) { public function setHoverControl(Control $hoverControl) {
$hoverControl->checkId(); $hoverControl->checkId();
$hoverControl->setScriptEvents(true); if ($hoverControl instanceof Scriptable) {
$hoverControl->setScriptEvents(true);
}
$this->hoverControl = $hoverControl; $this->hoverControl = $hoverControl;
return $this; return $this;
} }
@ -77,7 +80,7 @@ class Tooltip extends ScriptFeature {
* @return \FML\Script\Features\Tooltip * @return \FML\Script\Features\Tooltip
*/ */
public function setStayOnClick($stayOnClick) { public function setStayOnClick($stayOnClick) {
$this->stayOnClick = (bool) $stayOnClick; $this->stayOnClick = (bool)$stayOnClick;
return $this; return $this;
} }
@ -88,7 +91,7 @@ class Tooltip extends ScriptFeature {
* @return \FML\Script\Features\Tooltip * @return \FML\Script\Features\Tooltip
*/ */
public function setInvert($invert) { public function setInvert($invert) {
$this->invert = (bool) $invert; $this->invert = (bool)$invert;
return $this; return $this;
} }
@ -104,11 +107,10 @@ 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) {
$hoverControlId = $this->hoverControl->getId(true); $hoverControlId = $this->hoverControl->getId(true);
$tooltipControlId = $this->tooltipControl->getId(true); $tooltipControlId = $this->tooltipControl->getId(true);
// MouseOver // MouseOver

View File

@ -3,55 +3,57 @@
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
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class UISound extends ScriptFeature { class UISound extends ScriptFeature {
/* /*
* Constants * Constants
*/ */
const Bonus = 'Bonus'; const Bonus = 'Bonus';
const Capture = 'Capture'; const Capture = 'Capture';
const Checkpoint = 'Checkpoint'; const Checkpoint = 'Checkpoint';
const Combo = 'Combo'; const Combo = 'Combo';
const Custom1 = 'Custom1'; const Custom1 = 'Custom1';
const Custom2 = 'Custom2'; const Custom2 = 'Custom2';
const Custom3 = 'Custom3'; const Custom3 = 'Custom3';
const Custom4 = 'Custom4'; const Custom4 = 'Custom4';
const Default_ = 'Default'; const Default_ = 'Default';
const EndMatch = 'EndMatch'; const EndMatch = 'EndMatch';
const EndRound = 'EndRound'; const EndRound = 'EndRound';
const Finish = 'Finish'; const Finish = 'Finish';
const FirstHit = 'FirstHit'; const FirstHit = 'FirstHit';
const Notice = 'Notice'; const Notice = 'Notice';
const PhaseChange = 'PhaseChange'; const PhaseChange = 'PhaseChange';
const PlayerEliminated = 'PlayerEliminated'; const PlayerEliminated = 'PlayerEliminated';
const PlayerHit = 'PlayerHit'; const PlayerHit = 'PlayerHit';
const PlayersRemaining = 'PlayersRemaining'; const PlayersRemaining = 'PlayersRemaining';
const RankChange = 'RankChange'; const RankChange = 'RankChange';
const Record = 'Record'; const Record = 'Record';
const ScoreProgress = 'ScoreProgress'; const ScoreProgress = 'ScoreProgress';
const Silence = 'Silence'; const Silence = 'Silence';
const StartMatch = 'StartMatch'; const StartMatch = 'StartMatch';
const StartRound = 'StartRound'; const StartRound = 'StartRound';
const TieBreakPoint = 'TieBreakPoint'; const TieBreakPoint = 'TieBreakPoint';
const TiePoint = 'TiePoint'; const TiePoint = 'TiePoint';
const TimeOut = 'TimeOut'; const TimeOut = 'TimeOut';
const VictoryPoint = 'VictoryPoint'; const VictoryPoint = 'VictoryPoint';
const Warning = 'Warning'; const Warning = 'Warning';
/* /*
* 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.;
@ -60,10 +62,10 @@ class UISound extends ScriptFeature {
/** /**
* Construct a new UISound Feature * Construct a new UISound Feature
* *
* @param string $soundName (optional) Played Sound * @param string $soundName (optional) Played Sound
* @param Control $control (optional) Action Control * @param Control $control (optional) Action Control
* @param int $variant (optional) Sound Variant * @param int $variant (optional) Sound Variant
* @param string $labelName (optional) Script Label Name * @param string $labelName (optional) Script Label Name
*/ */
public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) { public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) {
$this->setSoundName($soundName); $this->setSoundName($soundName);
@ -79,7 +81,7 @@ class UISound extends ScriptFeature {
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound
*/ */
public function setSoundName($soundName) { public function setSoundName($soundName) {
$this->soundName = (string) $soundName; $this->soundName = (string)$soundName;
return $this; return $this;
} }
@ -91,7 +93,9 @@ class UISound extends ScriptFeature {
*/ */
public function setControl(Control $control) { public function setControl(Control $control) {
$control->checkId(); $control->checkId();
$control->setScriptEvents(true); if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
}
$this->control = $control; $this->control = $control;
return $this; return $this;
} }
@ -103,7 +107,7 @@ class UISound extends ScriptFeature {
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound
*/ */
public function setVariant($variant) { public function setVariant($variant) {
$this->variant = (int) $variant; $this->variant = (int)$variant;
return $this; return $this;
} }
@ -114,7 +118,7 @@ class UISound extends ScriptFeature {
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound
*/ */
public function setVolume($volume) { public function setVolume($volume) {
$this->volume = (float) $volume; $this->volume = (float)$volume;
return $this; return $this;
} }
@ -125,12 +129,11 @@ class UISound extends ScriptFeature {
* @return \FML\Script\Features\UISound * @return \FML\Script\Features\UISound
*/ */
public function setLabelName($labelName) { public function setLabelName($labelName) {
$this->labelName = (string) $labelName; $this->labelName = (string)$labelName;
return $this; return $this;
} }
/** /**
*
* @see \FML\Script\Features\ScriptFeature::prepare() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
@ -146,13 +149,12 @@ class UISound extends ScriptFeature {
protected function getScriptText() { protected function getScriptText() {
if ($this->control) { if ($this->control) {
// Control event // Control event
$controlId = Builder::escapeText($this->control->getId()); $controlId = Builder::escapeText($this->control->getId());
$scriptText = " $scriptText = "
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

@ -7,18 +7,18 @@ use FML\Script\Features\ScriptFeature;
/** /**
* Class representing the ManiaLink Script * Class representing the ManiaLink Script
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Script { class Script {
/* /*
* Constants * Constants
*/ */
const TICKINTERVAL = 250; const TICKINTERVAL = 250;
const VAR_ScriptStart = 'FML_ScriptStart'; const VAR_ScriptStart = 'FML_ScriptStart';
const VAR_LoopCounter = 'FML_LoopCounter'; const VAR_LoopCounter = 'FML_LoopCounter';
const VAR_LastTick = 'FML_LastTick'; const VAR_LastTick = 'FML_LastTick';
/* /*
* Protected Properties * Protected Properties
@ -34,33 +34,32 @@ class Script {
/** /**
* Set a Script Include * Set a Script Include
* *
* @param string $file Include File * @param string $file Include File
* @param string $namespace Include Namespace * @param string $namespace Include Namespace
* @return \FML\Script\Script * @return \FML\Script\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;
} }
/** /**
* Add a Script Constant * Add a Script Constant
* *
* @param string $name Constant Name * @param string $name Constant Name
* @param string $value Constant Value * @param string $value Constant Value
* @return \FML\Script\Script * @return \FML\Script\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);
@ -108,16 +105,15 @@ class Script {
/** /**
* Append a generic Script Text for the next Rendering * Append a generic Script Text for the next Rendering
* *
* @param string $name Label Name * @param string $name Label Name
* @param string $text Script Text * @param string $text Script Text
* @param bool $isolated (optional) Whether to isolate the Label Script * @param bool $isolated (optional) Whether to isolate the Label Script
* @return \FML\Script\Script * @return \FML\Script\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);
@ -205,8 +201,8 @@ class Script {
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$this->loadFeatures($this->features); $this->loadFeatures($this->features);
$scriptXml = $domDocument->createElement($this->tagName); $scriptXml = $domDocument->createElement($this->tagName);
$scriptText = $this->buildScriptText(); $scriptText = $this->buildScriptText();
$scriptComment = $domDocument->createComment($scriptText); $scriptComment = $domDocument->createComment($scriptText);
$scriptXml->appendChild($scriptComment); $scriptXml->appendChild($scriptComment);
return $scriptXml; return $scriptXml;
@ -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;
} }
@ -262,7 +259,7 @@ class Script {
* @return string * @return string
*/ */
protected function getLabels() { protected function getLabels() {
$customLabelsText = implode(PHP_EOL, $this->customLabels); $customLabelsText = implode(PHP_EOL, $this->customLabels);
$genericLabelsText = implode(PHP_EOL, $this->genericLabels); $genericLabelsText = implode(PHP_EOL, $this->genericLabels);
return $customLabelsText . $genericLabelsText; return $customLabelsText . $genericLabelsText;
} }

View File

@ -5,22 +5,22 @@ namespace FML\Script;
/** /**
* Class representing a Part of the ManiaLink Script * Class representing a Part of the ManiaLink Script
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class ScriptLabel { class ScriptLabel {
/* /*
* Constants * Constants
*/ */
const ONINIT = 'FML_OnInit'; const ONINIT = 'FML_OnInit';
const LOOP = 'FML_Loop'; const LOOP = 'FML_Loop';
const TICK = 'FML_Tick'; const TICK = 'FML_Tick';
const ENTRYSUBMIT = 'FML_EntrySubmit'; const ENTRYSUBMIT = 'FML_EntrySubmit';
const KEYPRESS = 'FML_KeyPress'; const KEYPRESS = 'FML_KeyPress';
const MOUSECLICK = 'FML_MouseClick'; const MOUSECLICK = 'FML_MouseClick';
const MOUSEOUT = 'FML_MouseOut'; const MOUSEOUT = 'FML_MouseOut';
const MOUSEOVER = 'FML_MouseOver'; const MOUSEOVER = 'FML_MouseOver';
/* /*
* Protected Properties * Protected Properties
@ -32,9 +32,9 @@ class ScriptLabel {
/** /**
* Construct a new ScriptLabel * Construct a new ScriptLabel
* *
* @param string $name (optional) Label Name * @param string $name (optional) Label Name
* @param string $text (optional) Script Text * @param string $text (optional) Script Text
* @param bool $isolated (optional) Isolate the Label Script * @param bool $isolated (optional) Isolate the Label Script
*/ */
public function __construct($name = self::LOOP, $text = '', $isolated = false) { public function __construct($name = self::LOOP, $text = '', $isolated = false) {
$this->setName($name); $this->setName($name);
@ -49,7 +49,7 @@ class ScriptLabel {
* @return \FML\Script\ScriptLabel * @return \FML\Script\ScriptLabel
*/ */
public function setName($name) { public function setName($name) {
$this->name = (string) $name; $this->name = (string)$name;
return $this; return $this;
} }
@ -60,7 +60,7 @@ class ScriptLabel {
* @return \FML\Script\ScriptLabel * @return \FML\Script\ScriptLabel
*/ */
public function setText($text) { public function setText($text) {
$this->text = (string) $text; $this->text = (string)$text;
return $this; return $this;
} }
@ -71,7 +71,7 @@ class ScriptLabel {
* @return \FML\Script\ScriptLabel * @return \FML\Script\ScriptLabel
*/ */
public function setIsolated($isolated) { public function setIsolated($isolated) {
$this->isolated = (bool) $isolated; $this->isolated = (bool)$isolated;
return $this; return $this;
} }

View File

@ -2,15 +2,15 @@
namespace FML\Stylesheet; namespace FML\Stylesheet;
// Warning: The mood class isn't fully supported yet! // Warning: The mood class isn't fully supported yet!
// Missing attributes: LDir1.. // Missing attributes: LDir1..
/** /**
* Class representing a Stylesheets Mood * Class representing a Stylesheets Mood
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Mood { class Mood {
/* /*
@ -51,15 +51,15 @@ class Mood {
/** /**
* Set Ambient Color in which the Elements reflect the Light * Set Ambient Color in which the Elements reflect the Light
* *
* @param float $red Red Color Value * @param float $red Red Color Value
* @param float $green Green Color Value * @param float $green Green Color Value
* @param float $blue Blue Color Value * @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setLightAmbientColor($red, $green, $blue) { public function setLightAmbientColor($red, $green, $blue) {
$red = (float) $red; $red = (float)$red;
$green = (float) $green; $green = (float)$green;
$blue = (float) $blue; $blue = (float)$blue;
$this->lAmbient_LinearRgb = "{$red} {$green} {$blue}"; $this->lAmbient_LinearRgb = "{$red} {$green} {$blue}";
return $this; return $this;
} }
@ -67,15 +67,15 @@ class Mood {
/** /**
* Set Minimum Value for the Background Color Range * Set Minimum Value for the Background Color Range
* *
* @param float $red Red Color Value * @param float $red Red Color Value
* @param float $green Green Color Value * @param float $green Green Color Value
* @param float $blue Blue Color Value * @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setCloudsColorMin($red, $green, $blue) { public function setCloudsColorMin($red, $green, $blue) {
$red = (float) $red; $red = (float)$red;
$green = (float) $green; $green = (float)$green;
$blue = (float) $blue; $blue = (float)$blue;
$this->cloudsRgbMinLinear = "{$red} {$green} {$blue}"; $this->cloudsRgbMinLinear = "{$red} {$green} {$blue}";
return $this; return $this;
} }
@ -83,15 +83,15 @@ class Mood {
/** /**
* Set Maximum Value for the Background Color Range * Set Maximum Value for the Background Color Range
* *
* @param float $red Red Color Value * @param float $red Red Color Value
* @param float $green Green Color Value * @param float $green Green Color Value
* @param float $blue Blue Color Value * @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setCloudsColorMax($red, $green, $blue) { public function setCloudsColorMax($red, $green, $blue) {
$red = (float) $red; $red = (float)$red;
$green = (float) $green; $green = (float)$green;
$blue = (float) $blue; $blue = (float)$blue;
$this->cloudsRgbMaxLinear = "{$red} {$green} {$blue}"; $this->cloudsRgbMaxLinear = "{$red} {$green} {$blue}";
return $this; return $this;
} }
@ -99,15 +99,15 @@ class Mood {
/** /**
* Set RGB Color of Light Source 0 * Set RGB Color of Light Source 0
* *
* @param float $red Red Color Value * @param float $red Red Color Value
* @param float $green Green Color Value * @param float $green Green Color Value
* @param float $blue Blue Color Value * @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setLight0Color($red, $green, $blue) { public function setLight0Color($red, $green, $blue) {
$red = (float) $red; $red = (float)$red;
$green = (float) $green; $green = (float)$green;
$blue = (float) $blue; $blue = (float)$blue;
$this->lDir0_LinearRgb = "{$red} {$green} {$blue}"; $this->lDir0_LinearRgb = "{$red} {$green} {$blue}";
return $this; return $this;
} }
@ -119,7 +119,7 @@ class Mood {
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setLight0Intensity($intensity) { public function setLight0Intensity($intensity) {
$this->lDir0_Intens = (float) $intensity; $this->lDir0_Intens = (float)$intensity;
return $this; return $this;
} }
@ -130,7 +130,7 @@ class Mood {
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setLight0PhiAngle($phiAngle) { public function setLight0PhiAngle($phiAngle) {
$this->lDir0_DirPhi = (float) $phiAngle; $this->lDir0_DirPhi = (float)$phiAngle;
return $this; return $this;
} }
@ -141,22 +141,22 @@ class Mood {
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setLight0ThetaAngle($thetaAngle) { public function setLight0ThetaAngle($thetaAngle) {
$this->lDir0_DirTheta = (float) $thetaAngle; $this->lDir0_DirTheta = (float)$thetaAngle;
return $this; return $this;
} }
/** /**
* Set Light Ball Color * Set Light Ball Color
* *
* @param float $red Red Color Value * @param float $red Red Color Value
* @param float $green Green Color Value * @param float $green Green Color Value
* @param float $blue Blue Color Value * @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setLightBallColor($red, $green, $blue) { public function setLightBallColor($red, $green, $blue) {
$red = (float) $red; $red = (float)$red;
$green = (float) $green; $green = (float)$green;
$blue = (float) $blue; $blue = (float)$blue;
$this->lBall_LinearRgb = "{$red} {$green} {$blue}"; $this->lBall_LinearRgb = "{$red} {$green} {$blue}";
return $this; return $this;
} }
@ -168,7 +168,7 @@ class Mood {
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setLightBallIntensity($intensity) { public function setLightBallIntensity($intensity) {
$this->lBall_Intensity = (float) $intensity; $this->lBall_Intensity = (float)$intensity;
return $this; return $this;
} }
@ -179,22 +179,22 @@ class Mood {
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setLightBallRadius($radius) { public function setLightBallRadius($radius) {
$this->lBall_Radius = (float) $radius; $this->lBall_Radius = (float)$radius;
return $this; return $this;
} }
/** /**
* Set Fog Color * Set Fog Color
* *
* @param float $red Red Color Value * @param float $red Red Color Value
* @param float $green Green Color Value * @param float $green Green Color Value
* @param float $blue Blue Color Value * @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setFogColor($red, $green, $blue) { public function setFogColor($red, $green, $blue) {
$red = (float) $red; $red = (float)$red;
$green = (float) $green; $green = (float)$green;
$blue = (float) $blue; $blue = (float)$blue;
$this->fogColorSrgb = "{$red} {$green} {$blue}"; $this->fogColorSrgb = "{$red} {$green} {$blue}";
return $this; return $this;
} }
@ -202,15 +202,15 @@ class Mood {
/** /**
* Set Self Illumination Color * Set Self Illumination Color
* *
* @param float $red Red Color Value * @param float $red Red Color Value
* @param float $green Green Color Value * @param float $green Green Color Value
* @param float $blue Blue Color Value * @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setSelfIllumColor($red, $green, $blue) { public function setSelfIllumColor($red, $green, $blue) {
$red = (float) $red; $red = (float)$red;
$green = (float) $green; $green = (float)$green;
$blue = (float) $blue; $blue = (float)$blue;
$this->selfIllumColor = "{$red} {$green} {$blue}"; $this->selfIllumColor = "{$red} {$green} {$blue}";
return $this; return $this;
} }
@ -222,20 +222,20 @@ class Mood {
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function setSkyGradientScale($scale) { public function setSkyGradientScale($scale) {
$this->skyGradientV_Scale = (float) $scale; $this->skyGradientV_Scale = (float)$scale;
return $this; return $this;
} }
/** /**
* Add a Key for the SkyGradient * Add a Key for the SkyGradient
* *
* @param float $x Scale Value * @param float $x Scale Value
* @param string $color Gradient Color * @param string $color Gradient Color
* @return \FML\Stylesheet\Mood * @return \FML\Stylesheet\Mood
*/ */
public function addSkyGradientKey($x, $color) { public function addSkyGradientKey($x, $color) {
$x = (float) $x; $x = (float)$x;
$color = (string) $color; $color = (string)$color;
$gradientKey = array('x' => $x, 'color' => $color); $gradientKey = array('x' => $x, 'color' => $color);
array_push($this->skyGradientKeys, $gradientKey); array_push($this->skyGradientKeys, $gradientKey);
return $this; return $this;

View File

@ -5,19 +5,19 @@ namespace FML\Stylesheet;
/** /**
* Class representing a specific Style3d * Class representing a specific Style3d
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Style3d { class Style3d {
/* /*
* Constants * Constants
*/ */
const MODEL_Box = 'Box'; const MODEL_Box = 'Box';
const MODEL_Button = 'Button'; const MODEL_Button = 'Button';
const MODEL_ButtonH = 'ButtonH'; const MODEL_ButtonH = 'ButtonH';
const MODEL_Title = 'Title'; const MODEL_Title = 'Title';
const MODEL_Window = 'Window'; const MODEL_Window = 'Window';
/* /*
* Protected Properties * Protected Properties
@ -64,7 +64,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setId($id) { public function setId($id) {
$this->id = (string) $id; $this->id = (string)$id;
return $this; return $this;
} }
@ -96,7 +96,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setModel($model) { public function setModel($model) {
$this->model = (string) $model; $this->model = (string)$model;
return $this; return $this;
} }
@ -107,7 +107,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setThickness($thickness) { public function setThickness($thickness) {
$this->thickness = (float) $thickness; $this->thickness = (float)$thickness;
return $this; return $this;
} }
@ -118,7 +118,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setColor($color) { public function setColor($color) {
$this->color = (string) $color; $this->color = (string)$color;
return $this; return $this;
} }
@ -129,7 +129,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setFocusColor($focusColor) { public function setFocusColor($focusColor) {
$this->focusColor = (string) $focusColor; $this->focusColor = (string)$focusColor;
return $this; return $this;
} }
@ -140,7 +140,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setLightColor($lightColor) { public function setLightColor($lightColor) {
$this->lightColor = (string) $lightColor; $this->lightColor = (string)$lightColor;
return $this; return $this;
} }
@ -151,7 +151,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setFocusLightColor($focusLightColor) { public function setFocusLightColor($focusLightColor) {
$this->focusLightColor = (string) $focusLightColor; $this->focusLightColor = (string)$focusLightColor;
return $this; return $this;
} }
@ -162,7 +162,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setYOffset($yOffset) { public function setYOffset($yOffset) {
$this->yOffset = (float) $yOffset; $this->yOffset = (float)$yOffset;
return $this; return $this;
} }
@ -173,7 +173,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setFocusYOffset($focusYOffset) { public function setFocusYOffset($focusYOffset) {
$this->focusYOffset = (float) $focusYOffset; $this->focusYOffset = (float)$focusYOffset;
return $this; return $this;
} }
@ -184,7 +184,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setZOffset($zOffset) { public function setZOffset($zOffset) {
$this->zOffset = (float) $zOffset; $this->zOffset = (float)$zOffset;
return $this; return $this;
} }
@ -195,7 +195,7 @@ class Style3d {
* @return \FML\Stylesheet\Style3d * @return \FML\Stylesheet\Style3d
*/ */
public function setFocusZOffset($focusZOffset) { public function setFocusZOffset($focusZOffset) {
$this->focusZOffset = (float) $focusZOffset; $this->focusZOffset = (float)$focusZOffset;
return $this; return $this;
} }

View File

@ -5,9 +5,9 @@ namespace FML\Stylesheet;
/** /**
* Class representing the ManiaLinks Stylesheet * Class representing the ManiaLinks Stylesheet
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
class Stylesheet { class Stylesheet {
/* /*
@ -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,25 +2,24 @@
namespace FML\Types; namespace FML\Types;
use FML\Controls\Control;
use FML\Elements\Format; use FML\Elements\Format;
/** /**
* Interface for Element being able to contain other Controls * Interface for Element being able to contain other Controls
* *
* @author steeffeen * @author steeffeen
* @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
*/ */
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

@ -3,17 +3,17 @@
/** /**
* 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
*/ */
if (!defined('FML_PATH')) { 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);
@ -26,29 +26,28 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
define('FML_AUTOLOAD_DEFINED', true); define('FML_AUTOLOAD_DEFINED', true);
spl_autoload_register(function ($className) { spl_autoload_register(function ($className) {
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className); $classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className);
$filePath = FML_PATH . $classPath . '.php'; $filePath = FML_PATH . $classPath . '.php';
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')) {
/** /**
* Load FML Class Files from the given Directory * Load FML Class Files from the given Directory
* *
* @param string $className Class to load * @param string $className Class to load
* @param string $directory Directory to open * @param string $directory Directory to open
* @param array $excludes File Names to ignore * @param array $excludes File Names to ignore
* @param string $baseNamespace Base Namespace * @param string $baseNamespace Base Namespace
* @return bool * @return bool
*/ */
function loadSimpleClass($className, $directory, $excludes, $baseNamespace) { function loadSimpleClass($className, $directory, $excludes, $baseNamespace) {
if ($dirHandle = opendir($directory)) { if ($dirHandle = opendir($directory)) {
$classParts = explode('\\', $className); $classParts = explode('\\', $className);
$simpleClassName = end($classParts); $simpleClassName = end($classParts);
$classFileName = $simpleClassName . '.php'; $classFileName = $simpleClassName . '.php';
while ($fileName = readdir($dirHandle)) { while ($fileName = readdir($dirHandle)) {
if (in_array($fileName, $excludes)) { if (in_array($fileName, $excludes)) {
continue; continue;
@ -56,9 +55,11 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
$filePath = $directory . $fileName; $filePath = $directory . $fileName;
if (is_dir($filePath)) { if (is_dir($filePath)) {
$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)) {
@ -75,7 +76,7 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
return false; return false;
} }
} }
$excludes = array('.', '..'); $excludes = array('.', '..');
$baseNamespace = 'FML\\'; $baseNamespace = 'FML\\';
loadSimpleClass($className, FML_PATH . 'FML' . DIRECTORY_SEPARATOR, $excludes, $baseNamespace); loadSimpleClass($className, FML_PATH . 'FML' . DIRECTORY_SEPARATOR, $excludes, $baseNamespace);
} }