FML Improvements
This commit is contained in:
parent
1c4d024f4b
commit
192cb2cb79
@ -7,6 +7,7 @@ use FML\Controls\Frame;
|
||||
use FML\Controls\Quad;
|
||||
use FML\Models\CheckBoxDesign;
|
||||
use FML\Script\Features\CheckBoxFeature;
|
||||
use FML\Script\Features\ScriptFeature;
|
||||
use FML\Types\Renderable;
|
||||
use FML\Types\ScriptFeatureable;
|
||||
|
||||
@ -99,22 +100,6 @@ class CheckBox implements Renderable, ScriptFeatureable {
|
||||
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
|
||||
*
|
||||
@ -130,7 +115,24 @@ class CheckBox implements Renderable, ScriptFeatureable {
|
||||
* @see \FML\Types\ScriptFeatureable::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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,16 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
protected $volume = 1.;
|
||||
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
|
||||
*
|
||||
@ -37,17 +47,13 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Audio Control
|
||||
*
|
||||
* @param string $id (optional) Control Id
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
parent::__construct($id);
|
||||
$this->tagName = 'audio';
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlMediaPlayer';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setData()
|
||||
*/
|
||||
public function setData($data) {
|
||||
@ -56,7 +62,6 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setDataId()
|
||||
*/
|
||||
public function setDataId($dataId) {
|
||||
@ -65,7 +70,6 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setPlay()
|
||||
*/
|
||||
public function setPlay($play) {
|
||||
@ -74,7 +78,6 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setLooping()
|
||||
*/
|
||||
public function setLooping($looping) {
|
||||
@ -83,7 +86,6 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setMusic()
|
||||
*/
|
||||
public function setMusic($music) {
|
||||
@ -92,7 +94,6 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setVolume()
|
||||
*/
|
||||
public function setVolume($volume) {
|
||||
@ -101,7 +102,6 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Scriptable::setScriptEvents()
|
||||
*/
|
||||
public function setScriptEvents($scriptEvents) {
|
||||
@ -110,7 +110,6 @@ class Audio extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Control::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
|
@ -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
|
||||
*
|
||||
@ -121,6 +97,47 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
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
|
||||
*
|
||||
@ -155,19 +172,15 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Control Position
|
||||
* Set Control Size
|
||||
*
|
||||
* @param float $x Horizontal Position
|
||||
* @param float $y Vertical Position
|
||||
* @param float $z (optional) Depth
|
||||
* @param float $width Control Width
|
||||
* @param float $height Control Height
|
||||
* @return \FML\Controls\Control
|
||||
*/
|
||||
public function setPosition($x, $y, $z = null) {
|
||||
$this->setX($x);
|
||||
$this->setY($y);
|
||||
if ($z !== null) {
|
||||
$this->setZ($z);
|
||||
}
|
||||
public function setSize($width, $height) {
|
||||
$this->setWidth($width);
|
||||
$this->setHeight($height);
|
||||
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
|
||||
*/
|
||||
public function setSize($width, $height) {
|
||||
$this->setWidth($width);
|
||||
$this->setHeight($height);
|
||||
public function centerAlign() {
|
||||
$this->setAlign(self::CENTER, self::CENTER2);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -228,29 +251,6 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
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
|
||||
*
|
||||
@ -310,6 +310,17 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
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
|
||||
*
|
||||
@ -398,26 +409,14 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
*
|
||||
* @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);
|
||||
public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK) {
|
||||
$customText = new ControlScript($this, $scriptText, $label);
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all Script Features
|
||||
*
|
||||
@ -467,4 +466,11 @@ abstract class Control implements Renderable, ScriptFeatureable {
|
||||
}
|
||||
return $xmlElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ManiaScript Class of the Control
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public abstract function getManiaScriptClass();
|
||||
}
|
||||
|
@ -32,6 +32,16 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
protected $focusAreaColor2 = '';
|
||||
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
|
||||
*
|
||||
@ -44,13 +54,19 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Entry Control
|
||||
*
|
||||
* @param string $id (optional) Control Id
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
parent::__construct($id);
|
||||
$this->tagName = 'entry';
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlEntry';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
return $this->name;
|
||||
public function getDefault() {
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,15 +100,6 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Default Value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefault() {
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\NewLineable::setAutoNewLine()
|
||||
*/
|
||||
|
@ -16,6 +16,16 @@ class FileEntry extends Entry {
|
||||
*/
|
||||
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
|
||||
*
|
||||
@ -28,13 +38,10 @@ class FileEntry extends Entry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new FileEntry Control
|
||||
*
|
||||
* @param string $id (optional) Control Id
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
parent::__construct($id);
|
||||
$this->tagName = 'fileentry';
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlFileEntry';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +56,6 @@ class FileEntry extends Entry {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Entry::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
|
@ -23,6 +23,16 @@ class Frame extends Control implements Container {
|
||||
/** @var Format $format */
|
||||
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
|
||||
*
|
||||
@ -35,13 +45,10 @@ class Frame extends Control implements Container {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Frame Control
|
||||
*
|
||||
* @param string $id (optional) Control Id
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
parent::__construct($id);
|
||||
$this->tagName = 'frame';
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlFrame';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,14 +69,6 @@ class Frame extends Control implements Container {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::setFormat()
|
||||
*/
|
||||
public function setFormat(Format $format) {
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::getFormat()
|
||||
*/
|
||||
@ -80,6 +79,14 @@ class Frame extends Control implements Container {
|
||||
return $this->format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Container::setFormat()
|
||||
*/
|
||||
public function setFormat(Format $format) {
|
||||
$this->format = $format;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Controls\Control::getScriptFeatures()
|
||||
*/
|
||||
|
@ -20,18 +20,6 @@ class FrameInstance extends Control {
|
||||
/** @var FrameModel $model */
|
||||
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
|
||||
*
|
||||
@ -58,6 +46,25 @@ class FrameInstance extends Control {
|
||||
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
|
||||
*
|
||||
|
@ -34,6 +34,16 @@ class Gauge extends Control implements Styleable {
|
||||
protected $drawBlockBg = 1;
|
||||
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
|
||||
*
|
||||
@ -46,13 +56,10 @@ class Gauge extends Control implements Styleable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Gauge Control
|
||||
*
|
||||
* @param string $id (optional) Control Id
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
parent::__construct($id);
|
||||
$this->tagName = 'gauge';
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlGauge';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +151,6 @@ class Gauge extends Control implements Styleable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Styleable::setStyle()
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
@ -153,7 +159,6 @@ class Gauge extends Control implements Styleable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Control::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace FML\Controls;
|
||||
|
||||
use FML\Script\Features\Clock;
|
||||
use FML\Types\Actionable;
|
||||
use FML\Types\Linkable;
|
||||
use FML\Types\NewLineable;
|
||||
use FML\Types\Scriptable;
|
||||
use FML\Types\Styleable;
|
||||
use FML\Types\TextFormatable;
|
||||
use FML\Script\Features\Clock;
|
||||
|
||||
/**
|
||||
* Label Control
|
||||
@ -42,6 +42,17 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
protected $focusAreaColor1 = '';
|
||||
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
|
||||
*
|
||||
@ -54,14 +65,10 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Label Control
|
||||
*
|
||||
* @param string $id (optional) Control Id
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
parent::__construct($id);
|
||||
$this->tagName = 'label';
|
||||
$this->setZ(1);
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlLabel';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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()
|
||||
*/
|
||||
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()
|
||||
*/
|
||||
public function setActionKey($actionKey) {
|
||||
@ -157,7 +161,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Linkable::setUrl()
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
@ -166,7 +169,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Linkable::setUrlId()
|
||||
*/
|
||||
public function setUrlId($urlId) {
|
||||
@ -175,7 +177,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Linkable::setManialink()
|
||||
*/
|
||||
public function setManialink($manialink) {
|
||||
@ -184,7 +185,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Linkable::setManialinkId()
|
||||
*/
|
||||
public function setManialinkId($manialinkId) {
|
||||
@ -193,7 +193,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\NewLineable::setAutoNewLine()
|
||||
*/
|
||||
public function setAutoNewLine($autoNewLine) {
|
||||
@ -202,7 +201,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Scriptable::setScriptEvents()
|
||||
*/
|
||||
public function setScriptEvents($scriptEvents) {
|
||||
@ -211,7 +209,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Styleable::setStyle()
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
@ -220,7 +217,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setTextSize()
|
||||
*/
|
||||
public function setTextSize($textSize) {
|
||||
@ -229,7 +225,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setTextColor()
|
||||
*/
|
||||
public function setTextColor($textColor) {
|
||||
@ -238,7 +233,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setAreaColor()
|
||||
*/
|
||||
public function setAreaColor($areaColor) {
|
||||
@ -247,7 +241,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\TextFormatable::setAreaFocusColor()
|
||||
*/
|
||||
public function setAreaFocusColor($areaFocusColor) {
|
||||
@ -269,7 +262,6 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Control::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
|
@ -40,6 +40,17 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
protected $style = '';
|
||||
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
|
||||
*
|
||||
@ -52,14 +63,10 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Quad Control
|
||||
*
|
||||
* @param string $id (optional) Control Id
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
parent::__construct($id);
|
||||
$this->tagName = 'quad';
|
||||
$this->setZ(-1);
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlQuad';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,6 +146,13 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Actionable::getAction()
|
||||
*/
|
||||
public function getAction() {
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Actionable::setAction()
|
||||
*/
|
||||
@ -147,13 +161,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Actionable::getAction()
|
||||
*/
|
||||
public function getAction() {
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \FML\Types\Actionable::setActionKey()
|
||||
*/
|
||||
@ -210,6 +217,15 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
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()
|
||||
*/
|
||||
@ -226,15 +242,6 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
|
||||
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
|
||||
*
|
||||
|
@ -25,6 +25,16 @@ class Video extends Control implements Playable, Scriptable {
|
||||
protected $volume = 1.;
|
||||
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
|
||||
*
|
||||
@ -37,17 +47,13 @@ class Video extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Video Control
|
||||
*
|
||||
* @param string $id (optional) Control Id
|
||||
* @see \FML\Controls\Control::getManiaScriptClass()
|
||||
*/
|
||||
public function __construct($id = null) {
|
||||
parent::__construct($id);
|
||||
$this->tagName = 'video';
|
||||
public function getManiaScriptClass() {
|
||||
return 'CMlMediaPlayer';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setData()
|
||||
*/
|
||||
public function setData($data) {
|
||||
@ -56,7 +62,6 @@ class Video extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setDataId()
|
||||
*/
|
||||
public function setDataId($dataId) {
|
||||
@ -65,7 +70,6 @@ class Video extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setPlay()
|
||||
*/
|
||||
public function setPlay($play) {
|
||||
@ -74,7 +78,6 @@ class Video extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setLooping()
|
||||
*/
|
||||
public function setLooping($looping) {
|
||||
@ -83,7 +86,6 @@ class Video extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setMusic()
|
||||
*/
|
||||
public function setMusic($music) {
|
||||
@ -92,7 +94,6 @@ class Video extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Playable::setVolume()
|
||||
*/
|
||||
public function setVolume($volume) {
|
||||
@ -101,7 +102,6 @@ class Video extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Types\Scriptable::setScriptEvents()
|
||||
*/
|
||||
public function setScriptEvents($scriptEvents) {
|
||||
@ -110,7 +110,6 @@ class Video extends Control implements Playable, Scriptable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see \FML\Control::render()
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
|
@ -122,6 +122,9 @@ class CheckBoxDesign implements Styleable, SubStyleable {
|
||||
} else {
|
||||
$string = $this->style . '|' . $this->subStyle;;
|
||||
}
|
||||
if ($escaped) {
|
||||
return Builder::escapeText($string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@ -88,16 +88,14 @@ abstract class Builder {
|
||||
if ($associative) {
|
||||
if (is_string($key)) {
|
||||
$arrayText .= '"' . self::escapeText($key) . '"';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arrayText .= $key;
|
||||
}
|
||||
$arrayText .= ' => ';
|
||||
}
|
||||
if (is_string($value)) {
|
||||
$arrayText .= '"' . self::escapeText($value) . '"';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arrayText .= $value;
|
||||
}
|
||||
if ($index < $count - 1) {
|
||||
|
@ -89,6 +89,15 @@ class CheckBoxFeature extends ScriptFeature {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the managed Entry
|
||||
*
|
||||
* @return \FML\Controls\Entry
|
||||
*/
|
||||
public function getEntry() {
|
||||
return $this->entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Enabled Design
|
||||
*
|
||||
@ -134,6 +143,7 @@ class CheckBoxFeature extends ScriptFeature {
|
||||
Void " . self::FUNCTION_UPDATE_QUAD_DESIGN . "(CMlQuad _Quad) {
|
||||
declare " . self::VAR_CHECKBOX_ENABLED . " as Enabled for _Quad = True;
|
||||
Enabled = !Enabled;
|
||||
_Quad.StyleSelected = Enabled;
|
||||
declare " . self::VAR_CHECKBOX_DESIGNS . " as Designs for _Quad = Text[Boolean];
|
||||
declare Design = Designs[Enabled];
|
||||
declare DesignParts = TextLib::Split(\"|\", Design);
|
||||
|
@ -22,7 +22,6 @@ class ControlScript extends ScriptFeature {
|
||||
protected $control = null;
|
||||
protected $labelName = null;
|
||||
protected $text = null;
|
||||
protected $isolated = null;
|
||||
|
||||
/**
|
||||
* Construct a new Custom Script Text
|
||||
@ -30,13 +29,11 @@ class ControlScript extends ScriptFeature {
|
||||
* @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) {
|
||||
public function __construct(Control $control, $text, $labelName = ScriptLabel::MOUSECLICK) {
|
||||
$this->setControl($control);
|
||||
$this->setText($text);
|
||||
$this->setLabelName($labelName);
|
||||
$this->setIsolated($isolated);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,36 +73,47 @@ class ControlScript extends ScriptFeature {
|
||||
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);
|
||||
$script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), true);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Script Text encapsulated for the Control Event
|
||||
* Build the Script Text for the Control
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEncapsulatedText() {
|
||||
protected function buildScriptText() {
|
||||
$controlId = $this->control->getId(true);
|
||||
$scriptText = "
|
||||
if (Event.ControlId == \"{$controlId}\") {
|
||||
{$this->text}
|
||||
}";
|
||||
$scriptText = '';
|
||||
$closeBlock = false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace FML\Script\Features;
|
||||
|
||||
use FML\Script\Script;
|
||||
use FML\Types\ScriptFeatureable;
|
||||
|
||||
/**
|
||||
* ManiaLink Script Feature Class
|
||||
@ -13,6 +14,26 @@ use FML\Script\Script;
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -75,6 +75,29 @@ class ScriptLabel {
|
||||
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
|
||||
*
|
||||
|
@ -15,9 +15,7 @@ if (!defined('FML_PATH')) {
|
||||
if (!defined('FML_VERSION')) {
|
||||
define('FML_VERSION', '1.2');
|
||||
}
|
||||
if (!defined('FML_SIMPLE_CLASSES')) {
|
||||
define('FML_SIMPLE_CLASSES', false);
|
||||
}
|
||||
//define('FML_SIMPLE_CLASSES', true);
|
||||
|
||||
/*
|
||||
* Autoload Function that loads FML Class Files on Demand
|
||||
@ -30,7 +28,7 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
|
||||
if (file_exists($filePath)) {
|
||||
// Load with FML namespace
|
||||
require_once $filePath;
|
||||
} else if (FML_SIMPLE_CLASSES) {
|
||||
} else if (defined('FML_SIMPLE_CLASSES') && FML_SIMPLE_CLASSES) {
|
||||
// Load as simple class name
|
||||
if (!function_exists('loadSimpleClass')) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user