This commit is contained in:
Steffen Schröder
2014-04-27 14:44:40 +02:00
parent d814f7e983
commit b75946e048
44 changed files with 2461 additions and 1038 deletions

View File

@ -49,7 +49,6 @@ class Audio extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setData()
* @return \FML\Controls\Audio
*/
public function setData($data) {
$this->data = (string) $data;
@ -59,7 +58,6 @@ class Audio extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setDataId()
* @return \FML\Controls\Audio
*/
public function setDataId($dataId) {
$this->dataId = (string) $dataId;
@ -69,7 +67,6 @@ class Audio extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setPlay()
* @return \FML\Controls\Audio
*/
public function setPlay($play) {
$this->play = ($play ? 1 : 0);
@ -79,7 +76,6 @@ class Audio extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setLooping()
* @return \FML\Controls\Audio
*/
public function setLooping($looping) {
$this->looping = ($looping ? 1 : 0);
@ -89,7 +85,6 @@ class Audio extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setMusic()
* @return \FML\Controls\Audio
*/
public function setMusic($music) {
$this->music = ($music ? 1 : 0);
@ -99,7 +94,6 @@ class Audio extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setVolume()
* @return \FML\Controls\Audio
*/
public function setVolume($volume) {
$this->volume = (float) $volume;
@ -109,7 +103,6 @@ class Audio extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Audio
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);

View File

@ -3,6 +3,16 @@
namespace FML\Controls;
use FML\Types\Renderable;
use FML\Script\Features\ActionTrigger;
use FML\Script\ScriptLabel;
use FML\Types\ScriptFeatureable;
use FML\Script\Features\MapInfo;
use FML\Script\Features\PlayerProfile;
use FML\Script\Features\UISound;
use FML\Script\Builder;
use FML\Script\Features\Toggle;
use FML\Script\Features\Tooltip;
/**
* Base Control
@ -12,7 +22,7 @@ use FML\Types\Renderable;
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class Control implements Renderable {
abstract class Control implements Renderable, ScriptFeatureable {
/*
* Constants
*/
@ -43,6 +53,7 @@ abstract class Control implements Renderable {
protected $scale = 1.;
protected $hidden = 0;
protected $classes = array();
protected $scriptFeatures = array();
/**
* Construct a new Control
@ -58,9 +69,13 @@ abstract class Control implements Renderable {
/**
* Get Control Id
*
* @param bool $escaped (optional) Whether the Id should be escaped for ManiaScript
* @return string
*/
public function getId() {
public function getId($escaped = false) {
if ($escaped) {
return Builder::escapeText($this->id);
}
return $this->id;
}
@ -258,6 +273,110 @@ abstract class Control implements Renderable {
return $this;
}
/**
* Add a dynamic Action Trigger
*
* @param string $actionName Action to trigger
* @param string $eventLabel (optional) Event on which the Action is triggered
* @return \FML\Controls\Control
*/
public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK) {
$actionTrigger = new ActionTrigger($actionName, $this, $eventLabel);
array_push($this->scriptFeatures, $actionTrigger);
return $this;
}
/**
* Add a dynamic Feature opening the current Map Info
*
* @param string $eventLabel (optional) Event on which the Map Info will be opened
* @return \FML\Controls\Control
*/
public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK) {
$mapInfo = new MapInfo($this, $eventLabel);
array_push($this->scriptFeatures, $mapInfo);
return $this;
}
/**
* Add a dynamic Feature to open a specific Player Profile
*
* @param string $login The Login of the Player
* @param string $eventLabel (optional) Event on which the Player Profile will be opened
* @return \FML\Controls\Control
*/
public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) {
$playerProfile = new PlayerProfile($login, $this, $eventLabel);
array_push($this->scriptFeatures, $playerProfile);
return $this;
}
/**
* Add a dynamic Feature playing an UISound
*
* @param string $soundName UISound Name
* @param int $variant (optional) Sound Variant
* @param string $eventLabel (optional) Event on which the Sound will be played
* @return \FML\Controls\Control
*/
public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK) {
$uiSound = new UISound($soundName, $this, $variant, $eventLabel);
array_push($this->scriptFeatures, $uiSound);
return $this;
}
/**
* Add a dynamic Feature toggling another Control
*
* @param Control $toggledControl Toggled Control
* @param string $labelName (optional) Script Label Name
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
* @return \FML\Controls\Control
*/
public function addToggleFeature(Control $toggledControl, $labelName = Scriptlabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
$toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide);
array_push($this->scriptFeatures, $toggle);
return $this;
}
/**
* Add a dynamic Feature showing a Tooltip on hovering
*
* @param Control $tooltipControl Tooltip Control
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @return \FML\Controls\Control
*/
public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false) {
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert);
array_push($this->scriptFeatures, $tooltip);
return $this;
}
/**
* Add a dynamic Feature showing a Tooltip on hovering
*
* @param Label $tooltipControl Tooltip Control
* @param string $text The Text to display on the Tooltip Label
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @return \FML\Controls\Control
*/
public function addTooltipLabelFeature(Label $tooltipControl, $text, $stayOnClick = false, $invert = false) {
$tooltip = new Tooltip($this, $tooltipControl, $stayOnClick, $invert, $text);
array_push($this->scriptFeatures, $tooltip);
return $this;
}
/**
*
* @see \FML\Types\ScriptFeatureable::getScriptFeatures()
*/
public function getScriptFeatures() {
return $this->scriptFeatures;
}
/**
*
* @see \FML\Types\Renderable::render()
@ -286,10 +405,7 @@ abstract class Control implements Renderable {
$xmlElement->setAttribute('hidden', $this->hidden);
}
if (!empty($this->classes)) {
$classes = '';
foreach ($this->classes as $class) {
$classes .= $class . ' ';
}
$classes = implode(' ', $this->classes);
$xmlElement->setAttribute('class', $classes);
}
return $xmlElement;

View File

@ -6,6 +6,7 @@ use FML\Types\NewLineable;
use FML\Types\Scriptable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
use FML\Script\Features\EntrySubmit;
/**
* Entry Control
@ -28,6 +29,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
protected $textSize = -1;
protected $focusAreaColor1 = '';
protected $focusAreaColor2 = '';
protected $autoComplete = null;
/**
* Create a new Entry Control
@ -61,6 +63,15 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
return $this;
}
/**
* Get the Entry Name
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Set Default Value
*
@ -75,7 +86,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
*
* @see \FML\Types\NewLineable::setAutoNewLine()
* @return \FML\Controls\Entry
*/
public function setAutoNewLine($autoNewLine) {
$this->autoNewLine = ($autoNewLine ? 1 : 0);
@ -85,7 +95,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Entry
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
@ -95,7 +104,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
*
* @see \FML\Types\Styleable::setStyle()
* @return \FML\Controls\Entry
*/
public function setStyle($style) {
$this->style = (string) $style;
@ -105,7 +113,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
*
* @see \FML\Types\TextFormatable::setTextColor()
* @return \FML\Controls\Entry
*/
public function setTextColor($textColor) {
$this->textColor = (string) $textColor;
@ -115,7 +122,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
*
* @see \FML\Types\TextFormatable::setTextSize()
* @return \FML\Controls\Entry
*/
public function setTextSize($textSize) {
$this->textSize = (int) $textSize;
@ -125,7 +131,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
*
* @see \FML\Types\TextFormatable::setAreaColor()
* @return \FML\Controls\Entry
*/
public function setAreaColor($areaColor) {
$this->focusAreaColor1 = (string) $areaColor;
@ -135,13 +140,35 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @return \FML\Controls\Entry
*/
public function setAreaFocusColor($areaFocusColor) {
$this->focusAreaColor2 = (string) $areaFocusColor;
return $this;
}
/**
* Set Auto Completion
*
* @param bool $autoComplete Whether the Default Value should be automatically completed based on the current Request Parameters
* @return \FML\Controls\Entry
*/
public function setAutoComplete($autoComplete) {
$this->autoComplete = (bool) $autoComplete;
return $this;
}
/**
* Add a dynamic Feature submitting the Entry
*
* @param string $url Submit Url
* @return \FML\Controls\Entry
*/
public function addSubmitFeature($url) {
$entrySubmit = new EntrySubmit($this, $url);
array_push($this->scriptFeatures, $entrySubmit);
return $this;
}
/**
*
* @see \FML\Control::render()
@ -154,6 +181,18 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
if ($this->default !== null) {
$xmlElement->setAttribute('default', $this->default);
}
else if ($this->autoComplete) {
$value = null;
if (array_key_exists($this->name, $_GET)) {
$value = $_GET[$this->name];
}
else if (array_key_exists($this->name, $_POST)) {
$value = $_POST[$this->name];
}
if ($value) {
$xmlElement->setAttribute('default', $value);
}
}
if ($this->autoNewLine) {
$xmlElement->setAttribute('autonewline', $this->autoNewLine);
}

View File

@ -3,9 +3,10 @@
namespace FML\Controls;
use FML\Types\Container;
use FML\Types\Renderable;
use FML\Elements\Format;
use FML\Elements\FrameModel;
use FML\Types\ScriptFeatureable;
/**
* Frame Control
@ -46,7 +47,6 @@ class Frame extends Control implements Container {
/**
*
* @see \FML\Types\Container::add()
* @return \FML\Controls\Frame
*/
public function add(Control $child) {
if (!in_array($child, $this->children, true)) {
@ -58,7 +58,6 @@ class Frame extends Control implements Container {
/**
*
* @see \FML\Types\Container::removeChildren()
* @return \FML\Controls\Frame
*/
public function removeChildren() {
$this->children = array();
@ -68,7 +67,6 @@ class Frame extends Control implements Container {
/**
*
* @see \FML\Types\Container::setFormat()
* @return \FML\Controls\Frame
*/
public function setFormat(Format $format) {
$this->format = $format;
@ -86,6 +84,20 @@ class Frame extends Control implements Container {
return $this->format;
}
/**
*
* @see \FML\Controls\Control::getScriptFeatures()
*/
public function getScriptFeatures() {
$scriptFeatures = $this->scriptFeatures;
foreach ($this->children as $child) {
if ($child instanceof ScriptFeatureable) {
$scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures());
}
}
return $scriptFeatures;
}
/**
*
* @see \FML\Renderable::render()

View File

@ -62,14 +62,12 @@ class Frame3d extends Frame implements Scriptable {
*/
public function setStyle3d(Style3d $style3d) {
$this->style3d = $style3d;
$this->style = '';
return $this;
}
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Frame3d
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);

View File

@ -3,7 +3,7 @@
namespace FML\Controls;
use FML\Elements\FrameModel;
use FML\Types\Renderable;
/**
* Class representing an Instance of a Frame Model

View File

@ -146,7 +146,6 @@ class Gauge extends Control implements Styleable {
/**
*
* @see \FML\Types\Styleable::setStyle()
* @return \FML\Controls\Gauge
*/
public function setStyle($style) {
$this->style = (string) $style;

View File

@ -8,6 +8,7 @@ use FML\Types\NewLineable;
use FML\Types\Scriptable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
use FML\Script\Features\Clock;
/**
* Label Control
@ -132,7 +133,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\Actionable::setAction()
* @return \FML\Controls\Label
*/
public function setAction($action) {
$this->action = (string) $action;
@ -150,7 +150,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\Actionable::setActionKey()
* @return \FML\Controls\Label
*/
public function setActionKey($actionKey) {
$this->actionKey = (int) $actionKey;
@ -160,7 +159,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\Linkable::setUrl()
* @return \FML\Controls\Label
*/
public function setUrl($url) {
$this->url = (string) $url;
@ -170,7 +168,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\Linkable::setUrlId()
* @return \FML\Controls\Label
*/
public function setUrlId($urlId) {
$this->urlId = (string) $urlId;
@ -180,7 +177,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\Linkable::setManialink()
* @return \FML\Controls\Label
*/
public function setManialink($manialink) {
$this->manialink = (string) $manialink;
@ -190,7 +186,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\Linkable::setManialinkId()
* @return \FML\Controls\Label
*/
public function setManialinkId($manialinkId) {
$this->manialinkId = (string) $manialinkId;
@ -200,7 +195,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\NewLineable::setAutoNewLine()
* @return \FML\Controls\Label
*/
public function setAutoNewLine($autoNewLine) {
$this->autoNewLine = ($autoNewLine ? 1 : 0);
@ -210,7 +204,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Label
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
@ -220,7 +213,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\Styleable::setStyle()
* @return \FML\Controls\Label
*/
public function setStyle($style) {
$this->style = (string) $style;
@ -230,7 +222,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\TextFormatable::setTextSize()
* @return \FML\Controls\Label
*/
public function setTextSize($textSize) {
$this->textSize = (int) $textSize;
@ -240,7 +231,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\TextFormatable::setTextColor()
* @return \FML\Controls\Label
*/
public function setTextColor($textColor) {
$this->textColor = (string) $textColor;
@ -250,7 +240,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\TextFormatable::setAreaColor()
* @return \FML\Controls\Label
*/
public function setAreaColor($areaColor) {
$this->focusAreaColor1 = (string) $areaColor;
@ -260,13 +249,25 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @return \FML\Controls\Label
*/
public function setAreaFocusColor($areaFocusColor) {
$this->focusAreaColor2 = (string) $areaFocusColor;
return $this;
}
/**
* Add a dynamic Feature showing the current Time
*
* @param bool $showSeconds (optional) Whether the Seconds should be shown
* @param bool $showFullDate (optional) Whether the Date should be shown
* @return \FML\Controls\Label
*/
public function addClockFeature($showSeconds = true, $showFullDate = false) {
$clock = new Clock($this, $showSeconds, $showFullDate);
array_push($this->scriptFeatures, $clock);
return $this;
}
/**
*
* @see \FML\Control::render()

View File

@ -141,7 +141,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\Actionable::setAction()
* @return \FML\Controls\Quad
*/
public function setAction($action) {
$this->action = (string) $action;
@ -159,7 +158,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\Actionable::setActionKey()
* @return \FML\Controls\Quad
*/
public function setActionKey($actionKey) {
$this->actionKey = (int) $actionKey;
@ -169,7 +167,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\BgColorable::setBgColor()
* @return \FML\Controls\Quad
*/
public function setBgColor($bgColor) {
$this->bgColor = (string) $bgColor;
@ -179,7 +176,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\Linkable::setUrl()
* @return \FML\Controls\Quad
*/
public function setUrl($url) {
$this->url = (string) $url;
@ -189,7 +185,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\Linkable::setUrlId()
* @return \FML\Controls\Quad
*/
public function setUrlId($urlId) {
$this->urlId = (string) $urlId;
@ -199,7 +194,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\Linkable::setManialink()
* @return \FML\Controls\Quad
*/
public function setManialink($manialink) {
$this->manialink = (string) $manialink;
@ -209,7 +203,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\Linkable::setManialinkId()
* @return \FML\Controls\Quad
*/
public function setManialinkId($manialinkId) {
$this->manialinkId = (string) $manialinkId;
@ -219,7 +212,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Quad
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
@ -229,7 +221,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\Styleable::setStyle()
* @return \FML\Controls\Quad
*/
public function setStyle($style) {
$this->style = (string) $style;
@ -239,7 +230,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\SubStyleable::setSubStyle()
* @return \FML\Controls\Quad
*/
public function setSubStyle($subStyle) {
$this->subStyle = (string) $subStyle;
@ -249,7 +239,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/**
*
* @see \FML\Types\SubStyleable::setStyles()
* @return \FML\Controls\Quad
*/
public function setStyles($style, $subStyle) {
$this->setStyle($style);

View File

@ -49,7 +49,6 @@ class Video extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setData()
* @return \FML\Controls\Video
*/
public function setData($data) {
$this->data = (string) $data;
@ -59,7 +58,6 @@ class Video extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setDataId()
* @return \FML\Controls\Video
*/
public function setDataId($dataId) {
$this->dataId = (string) $dataId;
@ -69,7 +67,6 @@ class Video extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setPlay()
* @return \FML\Controls\Video
*/
public function setPlay($play) {
$this->play = ($play ? 1 : 0);
@ -79,7 +76,6 @@ class Video extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setLooping()
* @return \FML\Controls\Video
*/
public function setLooping($looping) {
$this->looping = ($looping ? 1 : 0);
@ -89,7 +85,6 @@ class Video extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setMusic()
* @return \FML\Controls\Video
*/
public function setMusic($music) {
$this->music = ($music ? 1 : 0);
@ -99,7 +94,6 @@ class Video extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Playable::setVolume()
* @return \FML\Controls\Video
*/
public function setVolume($volume) {
$this->volume = (float) $volume;
@ -109,7 +103,6 @@ class Video extends Control implements Playable, Scriptable {
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Video
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);