FML Improvements

This commit is contained in:
Steffen Schröder 2014-05-16 22:44:22 +02:00
parent 1c4d024f4b
commit 192cb2cb79
18 changed files with 430 additions and 332 deletions

View File

@ -7,6 +7,7 @@ use FML\Controls\Frame;
use FML\Controls\Quad; use FML\Controls\Quad;
use FML\Models\CheckBoxDesign; use FML\Models\CheckBoxDesign;
use FML\Script\Features\CheckBoxFeature; use FML\Script\Features\CheckBoxFeature;
use FML\Script\Features\ScriptFeature;
use FML\Types\Renderable; use FML\Types\Renderable;
use FML\Types\ScriptFeatureable; use FML\Types\ScriptFeatureable;
@ -99,22 +100,6 @@ class CheckBox implements Renderable, ScriptFeatureable {
return $this; 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 * Set the CheckBox Quad
* *
@ -130,7 +115,24 @@ class CheckBox implements Renderable, ScriptFeatureable {
* @see \FML\Types\ScriptFeatureable::getScriptFeatures() * @see \FML\Types\ScriptFeatureable::getScriptFeatures()
*/ */
public function getScriptFeatures() { public function getScriptFeatures() {
return array($this->feature); return ScriptFeature::collect($this->feature, $this->getQuad(), $this->feature->getEntry());
}
/**
* 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();
} }
/** /**

View File

@ -25,6 +25,16 @@ class Audio extends Control implements Playable, Scriptable {
protected $volume = 1.; protected $volume = 1.;
protected $scriptEvents = 0; protected $scriptEvents = 0;
/**
* Construct a new Audio Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'audio';
}
/** /**
* Create a new Audio Control * Create a new Audio Control
* *
@ -37,17 +47,13 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
* Construct a new Audio Control * @see \FML\Controls\Control::getManiaScriptClass()
*
* @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function getManiaScriptClass() {
parent::__construct($id); return 'CMlMediaPlayer';
$this->tagName = 'audio';
} }
/** /**
*
* @see \FML\Types\Playable::setData() * @see \FML\Types\Playable::setData()
*/ */
public function setData($data) { public function setData($data) {
@ -56,7 +62,6 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setDataId() * @see \FML\Types\Playable::setDataId()
*/ */
public function setDataId($dataId) { public function setDataId($dataId) {
@ -65,7 +70,6 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setPlay() * @see \FML\Types\Playable::setPlay()
*/ */
public function setPlay($play) { public function setPlay($play) {
@ -74,7 +78,6 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setLooping() * @see \FML\Types\Playable::setLooping()
*/ */
public function setLooping($looping) { public function setLooping($looping) {
@ -83,7 +86,6 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setMusic() * @see \FML\Types\Playable::setMusic()
*/ */
public function setMusic($music) { public function setMusic($music) {
@ -92,7 +94,6 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setVolume() * @see \FML\Types\Playable::setVolume()
*/ */
public function setVolume($volume) { public function setVolume($volume) {
@ -101,7 +102,6 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Scriptable::setScriptEvents() * @see \FML\Types\Scriptable::setScriptEvents()
*/ */
public function setScriptEvents($scriptEvents) { public function setScriptEvents($scriptEvents) {
@ -110,7 +110,6 @@ class Audio extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -67,30 +67,6 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
} }
/**
* Get Control Id
*
* @param bool $escaped (optional) Whether the Id should be escaped for ManiaScript
* @return string
*/
public function getId($escaped = false) {
if ($escaped) {
return Builder::escapeText($this->id);
}
return $this->id;
}
/**
* Set Control Id
*
* @param string $id Control Id
* @return \FML\Controls\Control
*/
public function setId($id) {
$this->id = (string)$id;
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
* *
@ -121,6 +97,47 @@ abstract class Control implements Renderable, ScriptFeatureable {
return $this; return $this;
} }
/**
* Get Control Id
*
* @param bool $escaped (optional) Whether the Id should be escaped for ManiaScript
* @return string
*/
public function getId($escaped = false) {
if ($escaped) {
return Builder::escapeText($this->id);
}
return $this->id;
}
/**
* Set Control Id
*
* @param string $id Control Id
* @return \FML\Controls\Control
*/
public function setId($id) {
$this->id = (string)$id;
return $this;
}
/**
* Set Control Position
*
* @param float $x Horizontal Position
* @param float $y Vertical Position
* @param float $z (optional) Depth
* @return \FML\Controls\Control
*/
public function setPosition($x, $y, $z = null) {
$this->setX($x);
$this->setY($y);
if ($z !== null) {
$this->setZ($z);
}
return $this;
}
/** /**
* Set X Position * Set X Position
* *
@ -155,19 +172,15 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Control Position * Set Control Size
* *
* @param float $x Horizontal Position * @param float $width Control Width
* @param float $y Vertical Position * @param float $height Control Height
* @param float $z (optional) Depth
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setPosition($x, $y, $z = null) { public function setSize($width, $height) {
$this->setX($x); $this->setWidth($width);
$this->setY($y); $this->setHeight($height);
if ($z !== null) {
$this->setZ($z);
}
return $this; return $this;
} }
@ -194,15 +207,25 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
/** /**
* Set Control Size * Center Alignment
* *
* @param float $width Control Width
* @param float $height Control Height
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setSize($width, $height) { public function centerAlign() {
$this->setWidth($width); $this->setAlign(self::CENTER, self::CENTER2);
$this->setHeight($height); return $this;
}
/**
* Set Horizontal and Vertical Alignment
*
* @param string $hAlign Horizontal Alignment
* @param string $vAlign Vertical Alignment
* @return \FML\Controls\Control
*/
public function setAlign($hAlign, $vAlign) {
$this->setHAlign($hAlign);
$this->setVAlign($vAlign);
return $this; return $this;
} }
@ -228,29 +251,6 @@ abstract class Control implements Renderable, ScriptFeatureable {
return $this; return $this;
} }
/**
* Set Horizontal and Vertical Alignment
*
* @param string $hAlign Horizontal Alignment
* @param string $vAlign Vertical Alignment
* @return \FML\Controls\Control
*/
public function setAlign($hAlign, $vAlign) {
$this->setHAlign($hAlign);
$this->setVAlign($vAlign);
return $this;
}
/**
* Center Alignment
*
* @return \FML\Controls\Control
*/
public function centerAlign() {
$this->setAlign(self::CENTER, self::CENTER2);
return $this;
}
/** /**
* Reset Alignment * Reset Alignment
* *
@ -310,6 +310,17 @@ abstract class Control implements Renderable, ScriptFeatureable {
return $this; 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;
}
/** /**
* Add a dynamic Feature opening the current Map Info * Add a dynamic Feature opening the current Map Info
* *
@ -398,26 +409,14 @@ abstract class Control implements Renderable, ScriptFeatureable {
* *
* @param string $scriptText Script Text * @param string $scriptText Script Text
* @param string $label (optional) Script Label Name * @param string $label (optional) Script Label Name
* @param bool $isolated (optional) Whether to isolate the Script Text
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK, $isolated = true) { public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) {
$customText = new ControlScript($this, $scriptText, $label, $isolated); $customText = new ControlScript($this, $scriptText, $label);
$this->addScriptFeature($customText); $this->addScriptFeature($customText);
return $this; 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;
}
/** /**
* Remove all Script Features * Remove all Script Features
* *
@ -467,4 +466,11 @@ abstract class Control implements Renderable, ScriptFeatureable {
} }
return $xmlElement; return $xmlElement;
} }
/**
* Get the ManiaScript Class of the Control
*
* @return string
*/
public abstract function getManiaScriptClass();
} }

View File

@ -32,6 +32,16 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
protected $focusAreaColor2 = ''; protected $focusAreaColor2 = '';
protected $autoComplete = null; protected $autoComplete = null;
/**
* Construct a new Entry Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'entry';
}
/** /**
* Create a new Entry Control * Create a new Entry Control
* *
@ -44,13 +54,19 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
* Construct a new Entry Control * @see \FML\Controls\Control::getManiaScriptClass()
*
* @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function getManiaScriptClass() {
parent::__construct($id); return 'CMlEntry';
$this->tagName = 'entry'; }
/**
* Get the Entry Name
*
* @return string
*/
public function getName() {
return $this->name;
} }
/** /**
@ -65,12 +81,12 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
} }
/** /**
* Get the Entry Name * Get the Default Value
* *
* @return string * @return mixed
*/ */
public function getName() { public function getDefault() {
return $this->name; return $this->default;
} }
/** /**
@ -84,15 +100,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
return $this; return $this;
} }
/**
* Get the Default Value
*
* @return mixed
*/
public function getDefault() {
return $this->default;
}
/** /**
* @see \FML\Types\NewLineable::setAutoNewLine() * @see \FML\Types\NewLineable::setAutoNewLine()
*/ */

View File

@ -16,6 +16,16 @@ class FileEntry extends Entry {
*/ */
protected $folder = ''; protected $folder = '';
/**
* Construct a new FileEntry Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'fileentry';
}
/** /**
* Create a new FileEntry Control * Create a new FileEntry Control
* *
@ -28,13 +38,10 @@ class FileEntry extends Entry {
} }
/** /**
* Construct a new FileEntry Control * @see \FML\Controls\Control::getManiaScriptClass()
*
* @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function getManiaScriptClass() {
parent::__construct($id); return 'CMlFileEntry';
$this->tagName = 'fileentry';
} }
/** /**
@ -49,7 +56,6 @@ class FileEntry extends Entry {
} }
/** /**
*
* @see \FML\Entry::render() * @see \FML\Entry::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -23,6 +23,16 @@ class Frame extends Control implements Container {
/** @var Format $format */ /** @var Format $format */
protected $format = null; protected $format = null;
/**
* Construct a new Frame Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'frame';
}
/** /**
* Create a new Frame Control * Create a new Frame Control
* *
@ -35,13 +45,10 @@ class Frame extends Control implements Container {
} }
/** /**
* Construct a new Frame Control * @see \FML\Controls\Control::getManiaScriptClass()
*
* @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function getManiaScriptClass() {
parent::__construct($id); return 'CMlFrame';
$this->tagName = 'frame';
} }
/** /**
@ -62,14 +69,6 @@ class Frame extends Control implements Container {
return $this; return $this;
} }
/**
* @see \FML\Types\Container::setFormat()
*/
public function setFormat(Format $format) {
$this->format = $format;
return $this;
}
/** /**
* @see \FML\Types\Container::getFormat() * @see \FML\Types\Container::getFormat()
*/ */
@ -80,6 +79,14 @@ class Frame extends Control implements Container {
return $this->format; return $this->format;
} }
/**
* @see \FML\Types\Container::setFormat()
*/
public function setFormat(Format $format) {
$this->format = $format;
return $this;
}
/** /**
* @see \FML\Controls\Control::getScriptFeatures() * @see \FML\Controls\Control::getScriptFeatures()
*/ */

View File

@ -20,18 +20,6 @@ class FrameInstance extends Control {
/** @var FrameModel $model */ /** @var FrameModel $model */
protected $model = null; protected $model = null;
/**
* Create a new Frame Instance
*
* @param string $modelId (optional) Frame Model Id
* @param string $controlId (optional) Control Id
* @return \FML\Controls\Frame
*/
public static function create($modelId = null, $controlId = null) {
$frameInstance = new FrameInstance($modelId, $controlId);
return $frameInstance;
}
/** /**
* Construct a new Frame Instance * Construct a new Frame Instance
* *
@ -58,6 +46,25 @@ class FrameInstance extends Control {
return $this; return $this;
} }
/**
* Create a new Frame Instance
*
* @param string $modelId (optional) Frame Model Id
* @param string $controlId (optional) Control Id
* @return \FML\Controls\Frame
*/
public static function create($modelId = null, $controlId = null) {
$frameInstance = new FrameInstance($modelId, $controlId);
return $frameInstance;
}
/**
* @see \FML\Controls\Control::getManiaScriptClass()
*/
public function getManiaScriptClass() {
return 'CMlFrame';
}
/** /**
* Set Frame Model to use * Set Frame Model to use
* *

View File

@ -34,6 +34,16 @@ class Gauge extends Control implements Styleable {
protected $drawBlockBg = 1; protected $drawBlockBg = 1;
protected $style = ''; protected $style = '';
/**
* Construct a new Gauge Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'gauge';
}
/** /**
* Create a new Gauge Control * Create a new Gauge Control
* *
@ -46,13 +56,10 @@ class Gauge extends Control implements Styleable {
} }
/** /**
* Construct a new Gauge Control * @see \FML\Controls\Control::getManiaScriptClass()
*
* @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function getManiaScriptClass() {
parent::__construct($id); return 'CMlGauge';
$this->tagName = 'gauge';
} }
/** /**
@ -144,7 +151,6 @@ class Gauge extends Control implements Styleable {
} }
/** /**
*
* @see \FML\Types\Styleable::setStyle() * @see \FML\Types\Styleable::setStyle()
*/ */
public function setStyle($style) { public function setStyle($style) {
@ -153,7 +159,6 @@ class Gauge extends Control implements Styleable {
} }
/** /**
*
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -2,13 +2,13 @@
namespace FML\Controls; namespace FML\Controls;
use FML\Script\Features\Clock;
use FML\Types\Actionable; use FML\Types\Actionable;
use FML\Types\Linkable; use FML\Types\Linkable;
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\Clock;
/** /**
* Label Control * Label Control
@ -42,6 +42,17 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
protected $focusAreaColor1 = ''; protected $focusAreaColor1 = '';
protected $focusAreaColor2 = ''; protected $focusAreaColor2 = '';
/**
* Construct a new Label Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'label';
$this->setZ(1);
}
/** /**
* Create a new Label Control * Create a new Label Control
* *
@ -54,14 +65,10 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* Construct a new Label Control * @see \FML\Controls\Control::getManiaScriptClass()
*
* @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function getManiaScriptClass() {
parent::__construct($id); return 'CMlLabel';
$this->tagName = 'label';
$this->setZ(1);
} }
/** /**
@ -131,7 +138,13 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
* * @see \FML\Types\Actionable::getAction()
*/
public function getAction() {
return $this->action;
}
/**
* @see \FML\Types\Actionable::setAction() * @see \FML\Types\Actionable::setAction()
*/ */
public function setAction($action) { public function setAction($action) {
@ -140,15 +153,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\Actionable::getAction()
*/
public function getAction() {
return $this->action;
}
/**
*
* @see \FML\Types\Actionable::setActionKey() * @see \FML\Types\Actionable::setActionKey()
*/ */
public function setActionKey($actionKey) { public function setActionKey($actionKey) {
@ -157,7 +161,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\Linkable::setUrl() * @see \FML\Types\Linkable::setUrl()
*/ */
public function setUrl($url) { public function setUrl($url) {
@ -166,7 +169,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\Linkable::setUrlId() * @see \FML\Types\Linkable::setUrlId()
*/ */
public function setUrlId($urlId) { public function setUrlId($urlId) {
@ -175,7 +177,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\Linkable::setManialink() * @see \FML\Types\Linkable::setManialink()
*/ */
public function setManialink($manialink) { public function setManialink($manialink) {
@ -184,7 +185,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\Linkable::setManialinkId() * @see \FML\Types\Linkable::setManialinkId()
*/ */
public function setManialinkId($manialinkId) { public function setManialinkId($manialinkId) {
@ -193,7 +193,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\NewLineable::setAutoNewLine() * @see \FML\Types\NewLineable::setAutoNewLine()
*/ */
public function setAutoNewLine($autoNewLine) { public function setAutoNewLine($autoNewLine) {
@ -202,7 +201,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\Scriptable::setScriptEvents() * @see \FML\Types\Scriptable::setScriptEvents()
*/ */
public function setScriptEvents($scriptEvents) { public function setScriptEvents($scriptEvents) {
@ -211,7 +209,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\Styleable::setStyle() * @see \FML\Types\Styleable::setStyle()
*/ */
public function setStyle($style) { public function setStyle($style) {
@ -220,7 +217,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\TextFormatable::setTextSize() * @see \FML\Types\TextFormatable::setTextSize()
*/ */
public function setTextSize($textSize) { public function setTextSize($textSize) {
@ -229,7 +225,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\TextFormatable::setTextColor() * @see \FML\Types\TextFormatable::setTextColor()
*/ */
public function setTextColor($textColor) { public function setTextColor($textColor) {
@ -238,7 +233,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\TextFormatable::setAreaColor() * @see \FML\Types\TextFormatable::setAreaColor()
*/ */
public function setAreaColor($areaColor) { public function setAreaColor($areaColor) {
@ -247,7 +241,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor() * @see \FML\Types\TextFormatable::setAreaFocusColor()
*/ */
public function setAreaFocusColor($areaFocusColor) { public function setAreaFocusColor($areaFocusColor) {
@ -269,7 +262,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
} }
/** /**
*
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -40,6 +40,17 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
protected $style = ''; protected $style = '';
protected $subStyle = ''; protected $subStyle = '';
/**
* Construct a new Quad Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'quad';
$this->setZ(-1);
}
/** /**
* Create a new Quad Control * Create a new Quad Control
* *
@ -52,14 +63,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
} }
/** /**
* Construct a new Quad Control * @see \FML\Controls\Control::getManiaScriptClass()
*
* @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function getManiaScriptClass() {
parent::__construct($id); return 'CMlQuad';
$this->tagName = 'quad';
$this->setZ(-1);
} }
/** /**
@ -139,6 +146,13 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
return $this; return $this;
} }
/**
* @see \FML\Types\Actionable::getAction()
*/
public function getAction() {
return $this->action;
}
/** /**
* @see \FML\Types\Actionable::setAction() * @see \FML\Types\Actionable::setAction()
*/ */
@ -147,13 +161,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
return $this; return $this;
} }
/**
* @see \FML\Types\Actionable::getAction()
*/
public function getAction() {
return $this->action;
}
/** /**
* @see \FML\Types\Actionable::setActionKey() * @see \FML\Types\Actionable::setActionKey()
*/ */
@ -210,6 +217,15 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
return $this; return $this;
} }
/**
* @see \FML\Types\SubStyleable::setStyles()
*/
public function setStyles($style, $subStyle) {
$this->setStyle($style);
$this->setSubStyle($subStyle);
return $this;
}
/** /**
* @see \FML\Types\Styleable::setStyle() * @see \FML\Types\Styleable::setStyle()
*/ */
@ -226,15 +242,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
return $this; return $this;
} }
/**
* @see \FML\Types\SubStyleable::setStyles()
*/
public function setStyles($style, $subStyle) {
$this->setStyle($style);
$this->setSubStyle($subStyle);
return $this;
}
/** /**
* Apply the given CheckBox Design * Apply the given CheckBox Design
* *

View File

@ -25,6 +25,16 @@ class Video extends Control implements Playable, Scriptable {
protected $volume = 1.; protected $volume = 1.;
protected $scriptEvents = 0; protected $scriptEvents = 0;
/**
* Construct a new Video Control
*
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'video';
}
/** /**
* Create a new Video Control * Create a new Video Control
* *
@ -37,17 +47,13 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
* Construct a new Video Control * @see \FML\Controls\Control::getManiaScriptClass()
*
* @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function getManiaScriptClass() {
parent::__construct($id); return 'CMlMediaPlayer';
$this->tagName = 'video';
} }
/** /**
*
* @see \FML\Types\Playable::setData() * @see \FML\Types\Playable::setData()
*/ */
public function setData($data) { public function setData($data) {
@ -56,7 +62,6 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setDataId() * @see \FML\Types\Playable::setDataId()
*/ */
public function setDataId($dataId) { public function setDataId($dataId) {
@ -65,7 +70,6 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setPlay() * @see \FML\Types\Playable::setPlay()
*/ */
public function setPlay($play) { public function setPlay($play) {
@ -74,7 +78,6 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setLooping() * @see \FML\Types\Playable::setLooping()
*/ */
public function setLooping($looping) { public function setLooping($looping) {
@ -83,7 +86,6 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setMusic() * @see \FML\Types\Playable::setMusic()
*/ */
public function setMusic($music) { public function setMusic($music) {
@ -92,7 +94,6 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Playable::setVolume() * @see \FML\Types\Playable::setVolume()
*/ */
public function setVolume($volume) { public function setVolume($volume) {
@ -101,7 +102,6 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Types\Scriptable::setScriptEvents() * @see \FML\Types\Scriptable::setScriptEvents()
*/ */
public function setScriptEvents($scriptEvents) { public function setScriptEvents($scriptEvents) {
@ -110,7 +110,6 @@ class Video extends Control implements Playable, Scriptable {
} }
/** /**
*
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {

View File

@ -122,6 +122,9 @@ class CheckBoxDesign implements Styleable, SubStyleable {
} else { } else {
$string = $this->style . '|' . $this->subStyle;; $string = $this->style . '|' . $this->subStyle;;
} }
if ($escaped) {
return Builder::escapeText($string); return Builder::escapeText($string);
} }
return $string;
}
} }

View File

@ -88,16 +88,14 @@ abstract class Builder {
if ($associative) { if ($associative) {
if (is_string($key)) { if (is_string($key)) {
$arrayText .= '"' . self::escapeText($key) . '"'; $arrayText .= '"' . self::escapeText($key) . '"';
} } else {
else {
$arrayText .= $key; $arrayText .= $key;
} }
$arrayText .= ' => '; $arrayText .= ' => ';
} }
if (is_string($value)) { if (is_string($value)) {
$arrayText .= '"' . self::escapeText($value) . '"'; $arrayText .= '"' . self::escapeText($value) . '"';
} } else {
else {
$arrayText .= $value; $arrayText .= $value;
} }
if ($index < $count - 1) { if ($index < $count - 1) {

View File

@ -89,6 +89,15 @@ class CheckBoxFeature extends ScriptFeature {
return $this; return $this;
} }
/**
* Get the managed Entry
*
* @return \FML\Controls\Entry
*/
public function getEntry() {
return $this->entry;
}
/** /**
* Set the Enabled Design * Set the Enabled Design
* *
@ -134,6 +143,7 @@ class CheckBoxFeature extends ScriptFeature {
Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) { Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True; declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True;
Enabled = !Enabled; Enabled = !Enabled;
_Quad.StyleSelected = Enabled;
declare " . self::VAR_CHECKBOX_DESIGNS . " as Designs for _Quad = Text[Boolean]; declare " . self::VAR_CHECKBOX_DESIGNS . " as Designs for _Quad = Text[Boolean];
declare Design = Designs[Enabled]; declare Design = Designs[Enabled];
declare DesignParts = TextLib::Split(\"|\", Design); declare DesignParts = TextLib::Split(\"|\", Design);

View File

@ -22,7 +22,6 @@ class ControlScript extends ScriptFeature {
protected $control = null; protected $control = null;
protected $labelName = null; protected $labelName = null;
protected $text = null; protected $text = null;
protected $isolated = null;
/** /**
* Construct a new Custom Script Text * Construct a new Custom Script Text
@ -30,13 +29,11 @@ class ControlScript extends ScriptFeature {
* @param Control $control Event Control * @param Control $control Event Control
* @param string $text Script Text * @param string $text Script Text
* @param string $labelName (optional) Script Label Name * @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) { public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK) {
$this->setControl($control); $this->setControl($control);
$this->setText($text); $this->setText($text);
$this->setLabelName($labelName); $this->setLabelName($labelName);
$this->setIsolated($isolated);
} }
/** /**
@ -76,36 +73,47 @@ class ControlScript extends ScriptFeature {
return $this; 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() * @see \FML\Script\Features\ScriptFeature::prepare()
*/ */
public function prepare(Script $script) { public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getEncapsulatedText(), $this->isolated); $script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), true);
return $this; return $this;
} }
/** /**
* Get the Script Text encapsulated for the Control Event * Build the Script Text for the Control
* *
* @return string * @return string
*/ */
protected function getEncapsulatedText() { protected function buildScriptText() {
$controlId = $this->control->getId(true); $controlId = $this->control->getId(true);
$scriptText = " $scriptText = '';
if (Event.ControlId == \"{$controlId}\") { $closeBlock = false;
{$this->text}
}"; if (ScriptLabel::isEventLabel($this->labelName)) {
$scriptText .= '
if (Event.ControlId == "' . $controlId . '") {
declare Control <=> Event.Control;';
$closeBlock = true;
} else {
$scriptText .= '
declare Control <=> Page.GetFirstChild("' . $controlId . '");';
}
$class = $this->control->getManiaScriptClass();
$name = preg_replace('/^CMl/', '', $class, 1);
$scriptText .= '
declare ' . $name . ' <=> (Control as ' . $class . ');
';
$scriptText .= $this->text . '
';
if ($closeBlock) {
$scriptText .= '}';
}
return $scriptText; return $scriptText;
} }
} }

View File

@ -3,6 +3,7 @@
namespace FML\Script\Features; namespace FML\Script\Features;
use FML\Script\Script; use FML\Script\Script;
use FML\Types\ScriptFeatureable;
/** /**
* ManiaLink Script Feature Class * ManiaLink Script Feature Class
@ -13,6 +14,26 @@ use FML\Script\Script;
*/ */
abstract class ScriptFeature { abstract class ScriptFeature {
/**
* Collect the Script Features of the given Objects
*
* @param object $scriptFeatureable ScriptFeatureable Object
* @param object $_ (optional) Various Amount of additional Objects
* @return array
*/
public static function collect($scriptFeatureable, $_ = null) {
$params = func_get_args();
$scriptFeatures = array();
foreach ($params as $object) {
if ($object instanceof ScriptFeatureable) {
$scriptFeatures = array_merge($scriptFeatures, $object->getScriptFeatures());
} else if ($object instanceof ScriptFeature) {
array_push($scriptFeatures, $object);
}
}
return $scriptFeatures;
}
/** /**
* Prepare the given Script for Rendering by adding the needed Labels, etc. * Prepare the given Script for Rendering by adding the needed Labels, etc.
* *

View File

@ -75,6 +75,29 @@ class ScriptLabel {
return $this; return $this;
} }
/**
* Check if the given Label is an Event Label
*
* @param string $label Label Name
* @return bool
*/
public static function isEventLabel($label) {
$eventLabels = self::getEventLabels();
if (in_array($label, $eventLabels)) {
return true;
}
return false;
}
/**
* Get the possible Event Label Names
*
* @return array
*/
public static function getEventLabels() {
return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER);
}
/** /**
* Build the full Script Label Text * Build the full Script Label Text
* *

View File

@ -15,9 +15,7 @@ if (!defined('FML_PATH')) {
if (!defined('FML_VERSION')) { if (!defined('FML_VERSION')) {
define('FML_VERSION', '1.2'); define('FML_VERSION', '1.2');
} }
if (!defined('FML_SIMPLE_CLASSES')) { //define('FML_SIMPLE_CLASSES', true);
define('FML_SIMPLE_CLASSES', false);
}
/* /*
* Autoload Function that loads FML Class Files on Demand * Autoload Function that loads FML Class Files on Demand
@ -30,7 +28,7 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
if (file_exists($filePath)) { if (file_exists($filePath)) {
// Load with FML namespace // Load with FML namespace
require_once $filePath; require_once $filePath;
} else if (FML_SIMPLE_CLASSES) { } else if (defined('FML_SIMPLE_CLASSES') && FML_SIMPLE_CLASSES) {
// Load as simple class name // Load as simple class name
if (!function_exists('loadSimpleClass')) { if (!function_exists('loadSimpleClass')) {