Huge FML Update

This commit is contained in:
Steffen Schröder 2014-01-12 00:51:46 +01:00
parent 6a6fa56596
commit 345368df39
69 changed files with 2068 additions and 429 deletions

View File

@ -2,30 +2,120 @@
namespace FML\Controls; namespace FML\Controls;
use FML\Types\Playable;
use FML\Types\Scriptable;
/** /**
* Class representing Audio (CMlMediaPlayer) * Audio Element
* (CMlMediaPlayer)
* *
* @author steeffeen * @author steeffeen
*/ */
class Audio extends Control implements Playable, Scriptable { class Audio extends Control implements Playable, Scriptable {
/**
* Protected Properties
*/
protected $data = '';
protected $play = 0;
protected $looping = 0;
protected $music = 0;
protected $volume = 1.;
protected $scriptEvents = 0;
/** /**
* Construct a new Audio Control * Construct a new Audio Control
* *
* @param string $id * @param string $id (optional) Control Id
* Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
$this->tagName = 'audio'; $this->tagName = 'audio';
} }
/**
*
* @see \FML\Types\Playable::setData()
* @return \FML\Controls\Audio
*/
public function setData($data) {
$this->data = (string) $data;
return $this;
}
/**
*
* @see \FML\Types\Playable::setPlay()
* @return \FML\Controls\Audio
*/
public function setPlay($play) {
$this->play = ($play ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Playable::setLooping()
* @return \FML\Controls\Audio
*/
public function setLooping($looping) {
$this->looping = ($looping ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Playable::setMusic()
* @return \FML\Controls\Audio
*/
public function setMusic($music) {
$this->music = ($music ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Playable::setVolume()
* @return \FML\Controls\Audio
*/
public function setVolume($volume) {
$this->volume = (float) $volume;
return $this;
}
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Audio
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
return $this;
}
/** /**
* *
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
return $xml; if ($this->data) {
$xmlElement->setAttribute('data', $this->data);
}
if ($this->play) {
$xmlElement->setAttribute('play', $this->play);
}
if ($this->looping) {
$xmlElement->setAttribute('looping', $this->looping);
}
if ($this->music) {
$xmlElement->setAttribute('music', $this->music);
}
if ($this->volume != 1.) {
$xmlElement->setAttribute('volume', $this->volume);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
}
return $xmlElement;
} }
} }

View File

@ -5,7 +5,8 @@ namespace FML\Controls;
use FML\Types\Renderable; use FML\Types\Renderable;
/** /**
* Class representing CMlControl * Base Control Element
* (CMlControl)
* *
* @author steeffeen * @author steeffeen
*/ */
@ -39,13 +40,11 @@ abstract class Control implements Renderable {
/** /**
* Construct a new Control * Construct a new Control
* *
* @param string $id Control Id * @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
if ($id !== null) {
$this->setId($id); $this->setId($id);
} }
}
/** /**
* Get Control Id * Get Control Id
@ -63,7 +62,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setId($id) { public function setId($id) {
$this->id = $id; $this->id = (string) $id;
return $this; return $this;
} }
@ -100,7 +99,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setX($x) { public function setX($x) {
$this->x = $x; $this->x = (float) $x;
return $this; return $this;
} }
@ -111,7 +110,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setY($y) { public function setY($y) {
$this->y = $y; $this->y = (float) $y;
return $this; return $this;
} }
@ -122,7 +121,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setZ($z) { public function setZ($z) {
$this->z = $z; $this->z = (float) $z;
return $this; return $this;
} }
@ -131,7 +130,7 @@ abstract class Control implements Renderable {
* *
* @param float $x Horizontal Position * @param float $x Horizontal Position
* @param float $y Vertical Position * @param float $y Vertical Position
* @param float $z Depth * @param float $z (optional) Depth
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setPosition($x, $y, $z = null) { public function setPosition($x, $y, $z = null) {
@ -150,7 +149,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setWidth($width) { public function setWidth($width) {
$this->width = $width; $this->width = (float) $width;
return $this; return $this;
} }
@ -161,7 +160,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setHeight($height) { public function setHeight($height) {
$this->height = $height; $this->height = (float) $height;
return $this; return $this;
} }
@ -185,7 +184,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setHAlign($hAlign) { public function setHAlign($hAlign) {
$this->hAlign = $hAlign; $this->hAlign = (string) $hAlign;
return $this; return $this;
} }
@ -196,7 +195,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setVAlign($vAlign) { public function setVAlign($vAlign) {
$this->vAlign = $vAlign; $this->vAlign = (string) $vAlign;
return $this; return $this;
} }
@ -220,14 +219,14 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setScale($scale) { public function setScale($scale) {
$this->scale = $scale; $this->scale = (float) $scale;
return $this; return $this;
} }
/** /**
* Set Visibility * Set Visibility
* *
* @param bool $visible If Control should be visible * @param bool $visible Whether Control should be visible
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function setVisible($visible) { public function setVisible($visible) {
@ -242,6 +241,7 @@ abstract class Control implements Renderable {
* @return \FML\Controls\Control * @return \FML\Controls\Control
*/ */
public function addClass($class) { public function addClass($class) {
$class = (string) $class;
if (!in_array($class, $this->classes)) { if (!in_array($class, $this->classes)) {
array_push($this->classes, $class); array_push($this->classes, $class);
} }
@ -253,35 +253,35 @@ abstract class Control implements Renderable {
* @see \FML\Types\Renderable::render() * @see \FML\Types\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
if ($this->id) { if ($this->id) {
$xml->setAttribute('id', $this->id); $xmlElement->setAttribute('id', $this->id);
} }
if ($this->x !== 0. || $this->y !== 0. || $this->z !== 0.) { if ($this->x != 0. || $this->y != 0. || $this->z != 0.) {
$xml->setAttribute('posn', "{$this->x} {$this->y} {$this->z}"); $xmlElement->setAttribute('posn', "{$this->x} {$this->y} {$this->z}");
} }
if ($this->width >= 0. || $this->height >= 0.) { if ($this->width >= 0. || $this->height >= 0.) {
$xml->setAttribute('sizen', "{$this->width} {$this->height}"); $xmlElement->setAttribute('sizen', "{$this->width} {$this->height}");
} }
if ($this->hAlign) { if ($this->hAlign) {
$xml->setAttribute('halign', $this->hAlign); $xmlElement->setAttribute('halign', $this->hAlign);
} }
if ($this->vAlign) { if ($this->vAlign) {
$xml->setAttribute('valign', $this->vAlign); $xmlElement->setAttribute('valign', $this->vAlign);
} }
if ($this->scale !== 1.) { if ($this->scale != 1.) {
$xml->setAttribute('scale', $this->scale); $xmlElement->setAttribute('scale', $this->scale);
} }
if ($this->hidden) { if ($this->hidden) {
$xml->setAttribute('hidden', $this->hidden); $xmlElement->setAttribute('hidden', $this->hidden);
} }
if (!empty($this->classes)) {
$classes = ''; $classes = '';
foreach ($this->classes as $class) { foreach ($this->classes as $class) {
$classes .= $class . ' '; $classes .= $class . ' ';
} }
if ($classes) { $xmlElement->setAttribute('class', $classes);
$xml->setAttribute('class', $classes);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -8,7 +8,8 @@ use FML\Types\Styleable;
use FML\Types\TextFormatable; use FML\Types\TextFormatable;
/** /**
* Class representing CMlEntry * Entry Element
* (CMlEntry)
* *
* @author steeffeen * @author steeffeen
*/ */
@ -29,7 +30,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/** /**
* Construct a new Entry Control * Construct a new Entry Control
* *
* @param string $id * @param string $id (optional) Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
@ -39,20 +40,18 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
/** /**
* Set Entry Name * Set Entry Name
* *
* @param string $name * @param string $name Entry Name
* Entry Name
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setName($name) { public function setName($name) {
$this->name = $name; $this->name = (string) $name;
return $this; return $this;
} }
/** /**
* Set Default Value * Set Default Value
* *
* @param string $default * @param string $default Default Value
* Default Value
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setDefault($default) { public function setDefault($default) {
@ -86,7 +85,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setStyle($style) { public function setStyle($style) {
$this->style = $style; $this->style = (string) $style;
return $this; return $this;
} }
@ -96,7 +95,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setTextColor($textColor) { public function setTextColor($textColor) {
$this->textColor = $textColor; $this->textColor = (string) $textColor;
return $this; return $this;
} }
@ -106,7 +105,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setTextSize($textSize) { public function setTextSize($textSize) {
$this->textSize = $textSize; $this->textSize = (int) $textSize;
return $this; return $this;
} }
@ -116,7 +115,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setAreaColor($areaColor) { public function setAreaColor($areaColor) {
$this->areaColor = $areaColor; $this->areaColor = (string) $areaColor;
return $this; return $this;
} }
@ -126,7 +125,7 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @return \FML\Controls\Entry * @return \FML\Controls\Entry
*/ */
public function setAreaFocusColor($areaFocusColor) { public function setAreaFocusColor($areaFocusColor) {
$this->areaFocusColor = $areaFocusColor; $this->areaFocusColor = (string) $areaFocusColor;
return $this; return $this;
} }
@ -135,34 +134,34 @@ class Entry extends Control implements NewLineable, Scriptable, Styleable, TextF
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
if ($this->name) { if ($this->name) {
$xml->setAttribute('name', $this->name); $xmlElement->setAttribute('name', $this->name);
} }
if ($this->default !== null) { if ($this->default !== null) {
$xml->setAttribute('default', $this->default); $xmlElement->setAttribute('default', $this->default);
} }
if ($this->autoNewLine) { if ($this->autoNewLine) {
$xml->setAttribute('autonewline', $this->autoNewLine); $xmlElement->setAttribute('autonewline', $this->autoNewLine);
} }
if ($this->scriptEvents) { if ($this->scriptEvents) {
$xml->setAttribute('scriptevents', $this->scriptEvents); $xmlElement->setAttribute('scriptevents', $this->scriptEvents);
} }
if ($this->style) { if ($this->style) {
$xml->setAttribute('style', $this->style); $xmlElement->setAttribute('style', $this->style);
} }
if ($this->textColor) { if ($this->textColor) {
$xml->setAttribute('textcolor', $this->textColor); $xmlElement->setAttribute('textcolor', $this->textColor);
} }
if ($this->textSize >= 0.) { if ($this->textSize >= 0.) {
$xml->setAttribute('textsize', $this->textSize); $xmlElement->setAttribute('textsize', $this->textSize);
} }
if ($this->areaColor) { if ($this->areaColor) {
$xml->setAttribute('areacolor', $this->areaColor); $xmlElement->setAttribute('areacolor', $this->areaColor);
} }
if ($this->areaFocusColor) { if ($this->areaFocusColor) {
$xml->setAttribute('areafocuscolor', $this->areaFocusColor); $xmlElement->setAttribute('areafocuscolor', $this->areaFocusColor);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -16,8 +16,7 @@ class FileEntry extends Entry {
/** /**
* Construct a new FileEntry Control * Construct a new FileEntry Control
* *
* @param string $id * @param string $id (optional) Control Id
* Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
@ -27,12 +26,11 @@ class FileEntry extends Entry {
/** /**
* Set Folder * Set Folder
* *
* @param string $folder * @param string $folder Base Folder
* Base Folder
* @return \FML\Controls\FileEntry * @return \FML\Controls\FileEntry
*/ */
public function setFolder($folder) { public function setFolder($folder) {
$this->folder = $folder; $this->folder = (string) $folder;
return $this; return $this;
} }
@ -41,8 +39,10 @@ class FileEntry extends Entry {
* @see \FML\Entry::render() * @see \FML\Entry::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
$xml->setAttribute('folder', $this->folder); if ($this->folder) {
return $xml; $xmlElement->setAttribute('folder', $this->folder);
}
return $xmlElement;
} }
} }

View File

@ -6,7 +6,8 @@ use FML\Types\Container;
use FML\Types\Renderable; use FML\Types\Renderable;
/** /**
* Class representing CMlFrame * Frame Element
* (CMlFrame)
* *
* @author steeffeen * @author steeffeen
*/ */
@ -19,8 +20,7 @@ class Frame extends Control implements Container {
/** /**
* Construct a new Frame Control * Construct a new Frame Control
* *
* @param string $id * @param string $id (optional) Control Id
* Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
@ -33,7 +33,9 @@ class Frame extends Control implements Container {
* @return \FML\Controls\Frame * @return \FML\Controls\Frame
*/ */
public function add(Renderable $child) { public function add(Renderable $child) {
if (!in_array($child, $this->children)) {
array_push($this->children, $child); array_push($this->children, $child);
}
return $this; return $this;
} }
@ -52,11 +54,11 @@ class Frame extends Control implements Container {
* @see \FML\Renderable::render() * @see \FML\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
foreach ($this->children as $child) { foreach ($this->children as $child) {
$childXml = $child->render($domDocument); $childXmlElement = $child->render($domDocument);
$xml->appendChild($childXml); $xmlElement->appendChild($childXmlElement);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -5,7 +5,8 @@ namespace FML\Controls;
use FML\Types\Scriptable; use FML\Types\Scriptable;
/** /**
* Class representing Frame3d Elements (CMlFrame) * Frame3d Element
* (CMlFrame)
* *
* @author steeffeen * @author steeffeen
*/ */
@ -19,8 +20,7 @@ class Frame3d extends Frame implements Scriptable {
/** /**
* Construct a new Frame3d Control * Construct a new Frame3d Control
* *
* @param string $id * @param string $id (optional) Control Id
* Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
@ -30,12 +30,11 @@ class Frame3d extends Frame implements Scriptable {
/** /**
* Set style3d * Set style3d
* *
* @param string $style3d * @param string $style3d 3D Style
* 3D Style
* @return \FML\Controls\Frame3d * @return \FML\Controls\Frame3d
*/ */
public function setStyle3d($style3d) { public function setStyle3d($style3d) {
$this->style3d = $style3d; $this->style3d = (string) $style3d;
return $this; return $this;
} }
@ -54,13 +53,13 @@ class Frame3d extends Frame implements Scriptable {
* @see \FML\Controls\Frame::render() * @see \FML\Controls\Frame::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
if ($this->style3d) { if ($this->style3d) {
$xml->setAttribute('style3d', $this->style3d); $xmlElement->setAttribute('style3d', $this->style3d);
} }
if ($this->scriptEvents) { if ($this->scriptEvents) {
$xml->setAttribute('scriptevents', $this->scriptEvents); $xmlElement->setAttribute('scriptevents', $this->scriptEvents);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -5,7 +5,8 @@ namespace FML\Controls;
use FML\Types\Styleable; use FML\Types\Styleable;
/** /**
* Class representing CMlGauge * Gauge Element
* (CMlGauge)
* *
* @author steeffeen * @author steeffeen
*/ */
@ -14,6 +15,7 @@ class Gauge extends Control implements Styleable {
* Protected Properties * Protected Properties
*/ */
protected $ratio = 1.; protected $ratio = 1.;
// TODO: validate grading
protected $grading = 1.; protected $grading = 1.;
protected $color = ''; protected $color = '';
protected $rotation = 0.; protected $rotation = 0.;
@ -26,8 +28,7 @@ class Gauge extends Control implements Styleable {
/** /**
* Construct a new Gauge Control * Construct a new Gauge Control
* *
* @param string $id * @param string $id (optional) Control Id
* Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
@ -37,56 +38,51 @@ class Gauge extends Control implements Styleable {
/** /**
* Set Ratio * Set Ratio
* *
* @param float $ratio * @param float $ratio Ratio Value
* Ratio Value
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setRatio($ratio) { public function setRatio($ratio) {
$this->ratio = $ratio; $this->ratio = (float) $ratio;
return $this; return $this;
} }
/** /**
* Set Grading * Set Grading
* *
* @param float $grading * @param float $grading Grading Value
* Grading Value
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setGrading($grading) { public function setGrading($grading) {
$this->grading = $grading; $this->grading = (float) $grading;
return $this; return $this;
} }
/** /**
* Set Color * Set Color
* *
* @param string $color * @param string $color Gauge Color
* Gauge Color
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setColor($color) { public function setColor($color) {
$this->color = $color; $this->color = (string) $color;
return $this; return $this;
} }
/** /**
* Set Rotation * Set Rotation
* *
* @param float $rotation * @param float $rotation Gauge Rotation
* Gauge Rotation
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setRotation($rotation) { public function setRotation($rotation) {
$this->rotation = $rotation; $this->rotation = (float) $rotation;
return $this; return $this;
} }
/** /**
* Set Centered * Set Centered
* *
* @param bool $centered * @param bool $centered Whether Gauge is centered
* If Gauge is centered
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setCentered($centered) { public function setCentered($centered) {
@ -97,20 +93,18 @@ class Gauge extends Control implements Styleable {
/** /**
* Set Clan * Set Clan
* *
* @param int $clan * @param int $clan Clan number
* Clan number
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setClan($clan) { public function setClan($clan) {
$this->clan = $clan; $this->clan = (int) $clan;
return $this; return $this;
} }
/** /**
* Set Draw Background * Set Draw Background
* *
* @param bool $drawBg * @param bool $drawBg Whether Gauge Background should be drawn
* If Gauge Background should be drawn
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setDrawBg($drawBg) { public function setDrawBg($drawBg) {
@ -121,8 +115,7 @@ class Gauge extends Control implements Styleable {
/** /**
* Set Draw Block Background * Set Draw Block Background
* *
* @param bool $drawBlockBg * @param bool $drawBlockBg Whether Gauge Block Background should be drawn
* If Gauge Block Background should be drawn
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setDrawBlockBg($drawBlockBg) { public function setDrawBlockBg($drawBlockBg) {
@ -136,7 +129,7 @@ class Gauge extends Control implements Styleable {
* @return \FML\Controls\Gauge * @return \FML\Controls\Gauge
*/ */
public function setStyle($style) { public function setStyle($style) {
$this->style = $style; $this->style = (string) $style;
return $this; return $this;
} }
@ -145,26 +138,27 @@ class Gauge extends Control implements Styleable {
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
$xml->setAttribute('ratio', $this->ratio); // TODO: validate default values
$xml->setAttribute('grading', $this->grading); $xmlElement->setAttribute('ratio', $this->ratio);
$xmlElement->setAttribute('grading', $this->grading);
if ($this->color) { if ($this->color) {
$xml->setAttribute('color', $this->color); $xmlElement->setAttribute('color', $this->color);
} }
if ($this->rotation) { if ($this->rotation) {
$xml->setAttribute('rotation', $this->rotation); $xmlElement->setAttribute('rotation', $this->rotation);
} }
if ($this->centered) { if ($this->centered) {
$xml->setAttribute('centered', $this->centered); $xmlElement->setAttribute('centered', $this->centered);
} }
if ($this->clan) { if ($this->clan) {
$xml->setAttribute('clan', $this->clan); $xmlElement->setAttribute('clan', $this->clan);
} }
$xml->setAttribute('drawbg', $this->drawBg); $xmlElement->setAttribute('drawbg', $this->drawBg);
$xml->setAttribute('drawblockbg', $this->drawBlockBg); $xmlElement->setAttribute('drawblockbg', $this->drawBlockBg);
if ($this->style) { if ($this->style) {
$xml->setAttribute('style', $this->style); $xmlElement->setAttribute('style', $this->style);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -10,7 +10,8 @@ use FML\Types\Styleable;
use FML\Types\TextFormatable; use FML\Types\TextFormatable;
/** /**
* Class representing CMlLabel * Label Element
* (CMlLabel)
* *
* @author steeffeen * @author steeffeen
*/ */
@ -22,8 +23,9 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
protected $textPrefix = ''; protected $textPrefix = '';
protected $textEmboss = 0; protected $textEmboss = 0;
protected $translate = 0; protected $translate = 0;
protected $maxLines = 0; protected $maxLines = -1;
protected $action = ''; protected $action = '';
protected $actionKey = -1;
protected $url = ''; protected $url = '';
protected $manialink = ''; protected $manialink = '';
protected $autoNewLine = 0; protected $autoNewLine = 0;
@ -37,8 +39,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/** /**
* Construct a new Label Control * Construct a new Label Control
* *
* @param string $id * @param string $id (optional) Control Id
* Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
@ -49,32 +50,29 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/** /**
* Set Text * Set Text
* *
* @param string $text * @param string $text Text Value
* Text Value
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setText($text) { public function setText($text) {
$this->text = $text; $this->text = (string) $text;
return $this; return $this;
} }
/** /**
* Set Text Prefix * Set Text Prefix
* *
* @param string $textPrefix * @param string $textPrefix Text Prefix
* Text Prefix
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setTextPrefix($textPrefix) { public function setTextPrefix($textPrefix) {
$this->textPrefix = $textPrefix; $this->textPrefix = (string) $textPrefix;
return $this; return $this;
} }
/** /**
* Set Text Emboss * Set Text Emboss
* *
* @param bool $textEmboss * @param bool $textEmboss Whether Text should be embossed
* If Text should be embossed
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setTextEmboss($textEmboss) { public function setTextEmboss($textEmboss) {
@ -85,8 +83,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/** /**
* Set Translate * Set Translate
* *
* @param bool $translate * @param bool $translate Whether Text should be translated
* If Text should be translated
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setTranslate($translate) { public function setTranslate($translate) {
@ -97,12 +94,11 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/** /**
* Set Max Lines Count * Set Max Lines Count
* *
* @param int $maxLines * @param int $maxLines Max Lines Count
* Max Lines Count
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setMaxLines($maxLines) { public function setMaxLines($maxLines) {
$this->maxLines = $maxLines; $this->maxLines = (int) $maxLines;
return $this; return $this;
} }
@ -112,7 +108,17 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setAction($action) { public function setAction($action) {
$this->action = $action; $this->action = (string) $action;
return $this;
}
/**
*
* @see \FML\Types\Actionable::setActionKey()
* @return \FML\Controls\Label
*/
public function setActionKey($actionKey) {
$this->actionKey = (int) $actionKey;
return $this; return $this;
} }
@ -122,7 +128,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = $url; $this->url = (string) $url;
return $this; return $this;
} }
@ -132,7 +138,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setManialink($manialink) { public function setManialink($manialink) {
$this->manialink = $manialink; $this->manialink = (string) $manialink;
return $this; return $this;
} }
@ -162,7 +168,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setStyle($style) { public function setStyle($style) {
$this->style = $style; $this->style = (string) $style;
return $this; return $this;
} }
@ -172,7 +178,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setTextSize($textSize) { public function setTextSize($textSize) {
$this->textSize = $textSize; $this->textSize = (int) $textSize;
return $this; return $this;
} }
@ -182,7 +188,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setTextColor($textColor) { public function setTextColor($textColor) {
$this->textColor = $textColor; $this->textColor = (string) $textColor;
return $this; return $this;
} }
@ -192,7 +198,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setAreaColor($areaColor) { public function setAreaColor($areaColor) {
$this->areaColor = $areaColor; $this->areaColor = (string) $areaColor;
return $this; return $this;
} }
@ -202,7 +208,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label * @return \FML\Controls\Label
*/ */
public function setAreaFocusColor($areaFocusColor) { public function setAreaFocusColor($areaFocusColor) {
$this->areaFocusColor = $areaFocusColor; $this->areaFocusColor = (string) $areaFocusColor;
return $this; return $this;
} }
@ -211,52 +217,55 @@ 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) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
if ($this->text) { if ($this->text) {
$xml->setAttribute('text', $this->text); $xmlElement->setAttribute('text', $this->text);
} }
if ($this->textPrefix) { if ($this->textPrefix) {
$xml->setAttribute('textprefix', $this->textPrefix); $xmlElement->setAttribute('textprefix', $this->textPrefix);
} }
if ($this->textEmboss) { if ($this->textEmboss) {
$xml->setAttribute('textemboss', $this->textEmboss); $xmlElement->setAttribute('textemboss', $this->textEmboss);
} }
if ($this->translate) { if ($this->translate) {
$xml->setAttribute('translate', $this->translate); $xmlElement->setAttribute('translate', $this->translate);
} }
if ($this->maxLines) { if ($this->maxLines >= 0) {
$xml->setAttribute('maxlines', $this->maxLines); $xmlElement->setAttribute('maxlines', $this->maxLines);
} }
if ($this->action) { if ($this->action) {
$xml->setAttribute('action', $this->action); $xmlElement->setAttribute('action', $this->action);
}
if ($this->actionKey >= 0) {
$xmlElement->setAttribute('actionkey', $this->actionKey);
} }
if ($this->url) { if ($this->url) {
$xml->setAttribute('url', $this->url); $xmlElement->setAttribute('url', $this->url);
} }
if ($this->manialink) { if ($this->manialink) {
$xml->setAttribute('manialink', $this->manialink); $xmlElement->setAttribute('manialink', $this->manialink);
} }
if ($this->autoNewLine) { if ($this->autoNewLine) {
$xml->setAttribute('autonewline', $this->autoNewLine); $xmlElement->setAttribute('autonewline', $this->autoNewLine);
} }
if ($this->scriptEvents) { if ($this->scriptEvents) {
$xml->setAttribute('scriptevents', $this->scriptEvents); $xmlElement->setAttribute('scriptevents', $this->scriptEvents);
} }
if ($this->style) { if ($this->style) {
$xml->setAttribute('style', $this->style); $xmlElement->setAttribute('style', $this->style);
} }
if ($this->textSize >= 0) { if ($this->textSize >= 0) {
$xml->setAttribute('textsize', $this->textSize); $xmlElement->setAttribute('textsize', $this->textSize);
} }
if ($this->textColor) { if ($this->textColor) {
$xml->setAttribute('textcolor', $this->textColor); $xmlElement->setAttribute('textcolor', $this->textColor);
} }
if ($this->areaColor) { if ($this->areaColor) {
$xml->setAttribute('areacolor', $this->areaColor); $xmlElement->setAttribute('areacolor', $this->areaColor);
} }
if ($this->areaFocusColor) { if ($this->areaFocusColor) {
$xml->setAttribute('areafocuscolor', $this->areaFocusColor); $xmlElement->setAttribute('areafocuscolor', $this->areaFocusColor);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Labels;
use FML\Controls\Label; use FML\Controls\Label;
/** /**
* Label class for button styles * Label Class for Button Styles
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Labels;
use FML\Controls\Label; use FML\Controls\Label;
/** /**
* Label class for text styles * Label Class for Text Styles
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -10,7 +10,8 @@ use FML\Types\Styleable;
use FML\Types\SubStyleable; use FML\Types\SubStyleable;
/** /**
* Class representing CMlQuad * Quad Element
* (CMlQuad)
* *
* @author steeffeen * @author steeffeen
*/ */
@ -22,7 +23,9 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
protected $imageFocus = ''; protected $imageFocus = '';
protected $colorize = ''; protected $colorize = '';
protected $modulizeColor = ''; protected $modulizeColor = '';
protected $autoScale = 1;
protected $action = ''; protected $action = '';
protected $actionKey = -1;
protected $bgColor = ''; protected $bgColor = '';
protected $url = ''; protected $url = '';
protected $manialink = ''; protected $manialink = '';
@ -33,8 +36,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/** /**
* Construct a new Quad Control * Construct a new Quad Control
* *
* @param string $id * @param string $id (optional) Control Id
* Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
@ -45,48 +47,55 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
/** /**
* Set Image Url * Set Image Url
* *
* @param string $image * @param string $image Image Url
* Image Url
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setImage($image) { public function setImage($image) {
$this->image = $image; $this->image = (string) $image;
return $this; return $this;
} }
/** /**
* Set Focus Image Url * Set Focus Image Url
* *
* @param string $imageFocus * @param string $imageFocus Focus Image Url
* Focus Image Url
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setImageFocus($imageFocus) { public function setImageFocus($imageFocus) {
$this->imageFocus = $imageFocus; $this->imageFocus = (string) $imageFocus;
return $this; return $this;
} }
/** /**
* Set Colorization * Set Colorization
* *
* @param string $colorize * @param string $colorize Colorize Value
* Colorize Value
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setColorize($colorize) { public function setColorize($colorize) {
$this->colorize = $colorize; $this->colorize = (string) $colorize;
return $this; return $this;
} }
/** /**
* Set Modulization * Set Modulization
* *
* @param string $modulizeColor * @param string $modulizeColor Modulize Value
* Modulize Value
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setModulizeColor($modulizeColor) { public function setModulizeColor($modulizeColor) {
$this->modulizeColor = $modulizeColor; $this->modulizeColor = (string) $modulizeColor;
return $this;
}
/**
* Disable the automatic Image Scaling
*
* @param bool $autoScale Whether the Image should scale automatically
* @return \FML\Controls\Quad
*/
public function setAutoScale($autoScale) {
$this->autoScale = ($autoScale ? 1 : 0);
return $this; return $this;
} }
@ -96,7 +105,17 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setAction($action) { public function setAction($action) {
$this->action = $action; $this->action = (string) $action;
return $this;
}
/**
*
* @see \FML\Types\Actionable::setActionKey()
* @return \FML\Controls\Quad
*/
public function setActionKey($actionKey) {
$this->actionKey = (int) $actionKey;
return $this; return $this;
} }
@ -106,7 +125,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setBgColor($bgColor) { public function setBgColor($bgColor) {
$this->bgColor = $bgColor; $this->bgColor = (string) $bgColor;
return $this; return $this;
} }
@ -116,7 +135,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = $url; $this->url = (string) $url;
return $this; return $this;
} }
@ -126,7 +145,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setManialink($manialink) { public function setManialink($manialink) {
$this->manialink = $manialink; $this->manialink = (string) $manialink;
return $this; return $this;
} }
@ -146,7 +165,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setStyle($style) { public function setStyle($style) {
$this->style = $style; $this->style = (string) $style;
return $this; return $this;
} }
@ -156,7 +175,7 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @return \FML\Controls\Quad * @return \FML\Controls\Quad
*/ */
public function setSubStyle($subStyle) { public function setSubStyle($subStyle) {
$this->subStyle = $subStyle; $this->subStyle = (string) $subStyle;
return $this; return $this;
} }
@ -176,40 +195,46 @@ class Quad extends Control implements Actionable, BgColorable, Linkable, Scripta
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
if ($this->image) { if ($this->image) {
$xml->setAttribute('image', $this->image); $xmlElement->setAttribute('image', $this->image);
} }
if ($this->imageFocus) { if ($this->imageFocus) {
$xml->setAttribute('imagefocus', $this->imageFocus); $xmlElement->setAttribute('imagefocus', $this->imageFocus);
} }
if ($this->colorize) { if ($this->colorize) {
$xml->setAttribute('colorize', $this->colorize); $xmlElement->setAttribute('colorize', $this->colorize);
} }
if ($this->modulizeColor) { if ($this->modulizeColor) {
$xml->setAttribute('modulizecolor', $this->modulizeColor); $xmlElement->setAttribute('modulizecolor', $this->modulizeColor);
}
if (!$this->autoScale) {
$xmlElement->setAttribute('autoscale', $this->autoScale);
} }
if ($this->action) { if ($this->action) {
$xml->setAttribute('action', $this->action); $xmlElement->setAttribute('action', $this->action);
}
if ($this->actionKey >= 0) {
$xmlElement->setAttribute('actionkey', $this->actionKey);
} }
if ($this->bgColor) { if ($this->bgColor) {
$xml->setAttribute('bgcolor', $this->bgColor); $xmlElement->setAttribute('bgcolor', $this->bgColor);
} }
if ($this->url) { if ($this->url) {
$xml->setAttribute('url', $this->url); $xmlElement->setAttribute('url', $this->url);
} }
if ($this->manialink) { if ($this->manialink) {
$xml->setAttribute('manialink', $this->manialink); $xmlElement->setAttribute('manialink', $this->manialink);
} }
if ($this->scriptEvents) { if ($this->scriptEvents) {
$xml->setAttribute('scriptevents', $this->scriptEvents); $xmlElement->setAttribute('scriptevents', $this->scriptEvents);
} }
if ($this->style) { if ($this->style) {
$xml->setAttribute('style', $this->style); $xmlElement->setAttribute('style', $this->style);
} }
if ($this->subStyle) { if ($this->subStyle) {
$xml->setAttribute('substyle', $this->subStyle); $xmlElement->setAttribute('substyle', $this->subStyle);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style '321Go' * Quad Class for '321Go' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'BgRaceScore2' * Quad Class for 'BgRaceScore2' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Bgs1' * Quad Class for 'Bgs1' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Bgs1InRace' * Quad Class for 'Bgs1InRace' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'BgsChallengeMedals' * Quad Class for 'BgsChallengeMedals' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'BgsPlayerCard' * Quad Class for 'BgsPlayerCard' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Copilot' * Quad Class for 'Copilot' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Emblems' * Quad Class for 'Emblems' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'EnergyBar' * Quad Class for 'EnergyBar' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Hud3dEchelons' * Quad Class for 'Hud3dEchelons' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Icons128x128_1' * Quad Class for 'Icons128x128_1' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Icons128x128_Blink' * Quad Class for 'Icons128x128_Blink' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Icons128x32_1' * Quad Class for 'Icons128x32_1' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Icons64x64_1' * Quad Class for 'Icons64x64_1' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'Icons64x64_2' * Quad Class for 'Icons64x64_2' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'ManiaPlanetLogos' * Quad Class for 'ManiaPlanetLogos' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'ManiaplanetSystem' * Quad Class for 'ManiaplanetSystem' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'MedalsBig' * Quad Class for 'MedalsBig' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'TitleLogos' * Quad Class for 'TitleLogos' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'UIConstruction_Buttons' * Quad Class for 'UIConstruction_Buttons' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -5,7 +5,7 @@ namespace FML\Controls\Quads;
use FML\Controls\Quad; use FML\Controls\Quad;
/** /**
* Quad class for style 'UiSMSpectatorScoreBig' * Quad Class for 'UiSMSpectatorScoreBig' Style
* *
* @author steeffeen * @author steeffeen
*/ */

View File

@ -2,30 +2,120 @@
namespace FML\Controls; namespace FML\Controls;
use FML\Types\Playable;
use FML\Types\Scriptable;
/** /**
* Class representing video (CMlMediaPlayer) * Video Element
* (CMlMediaPlayer)
* *
* @author steeffeen * @author steeffeen
*/ */
class Video extends Control implements Playable, Scriptable { class Video extends Control implements Playable, Scriptable {
/**
* Protected Properties
*/
protected $data = '';
protected $play = 0;
protected $looping = 0;
protected $music = 0;
protected $volume = 1.;
protected $scriptEvents = 0;
/** /**
* Construct a new Video Control * Construct a new Video Control
* *
* @param string $id * @param string $id (optional) Control Id
* Control Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
parent::__construct($id); parent::__construct($id);
$this->tagName = 'video'; $this->tagName = 'video';
} }
/**
*
* @see \FML\Types\Playable::setData()
* @return \FML\Controls\Video
*/
public function setData($data) {
$this->data = (string) $data;
return $this;
}
/**
*
* @see \FML\Types\Playable::setPlay()
* @return \FML\Controls\Video
*/
public function setPlay($play) {
$this->play = ($play ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Playable::setLooping()
* @return \FML\Controls\Video
*/
public function setLooping($looping) {
$this->looping = ($looping ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Playable::setMusic()
* @return \FML\Controls\Video
*/
public function setMusic($music) {
$this->music = ($music ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Playable::setVolume()
* @return \FML\Controls\Video
*/
public function setVolume($volume) {
$this->volume = (float) $volume;
return $this;
}
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Video
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
return $this;
}
/** /**
* *
* @see \FML\Control::render() * @see \FML\Control::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument); $xmlElement = parent::render($domDocument);
return $xml; if ($this->data) {
$xmlElement->setAttribute('data', $this->data);
}
if ($this->play) {
$xmlElement->setAttribute('play', $this->play);
}
if ($this->looping) {
$xmlElement->setAttribute('looping', $this->looping);
}
if ($this->music) {
$xmlElement->setAttribute('music', $this->music);
}
if ($this->volume != 1.) {
$xmlElement->setAttribute('volume', $this->volume);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
}
return $xmlElement;
} }
} }

View File

@ -8,7 +8,6 @@ namespace FML;
* @author steeffeen * @author steeffeen
*/ */
class CustomUI { class CustomUI {
/** /**
* Protected Properties * Protected Properties
*/ */
@ -26,18 +25,18 @@ class CustomUI {
/** /**
* Set XML Encoding * Set XML Encoding
* *
* @param string $encoding * @param string $encoding XML Encoding
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setXMLEncoding($encoding) { public function setXMLEncoding($encoding) {
$this->encoding = $encoding; $this->encoding = (string) $encoding;
return $this; return $this;
} }
/** /**
* Set Showing of Notices * Set Showing of Notices
* *
* @param bool $visible * @param bool $visible Whether Notices should be shown
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setNoticeVisible($visible) { public function setNoticeVisible($visible) {
@ -48,7 +47,7 @@ class CustomUI {
/** /**
* Set Showing of the Challenge Info * Set Showing of the Challenge Info
* *
* @param bool $visible * @param bool $visible Whether the Challenge Info should be shown
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setChallengeInfoVisible($visible) { public function setChallengeInfoVisible($visible) {
@ -59,7 +58,7 @@ class CustomUI {
/** /**
* Set Showing of the Net Infos * Set Showing of the Net Infos
* *
* @param bool $visible * @param bool $visible Whether the Net Infos should be shown
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setNetInfosVisible($visible) { public function setNetInfosVisible($visible) {
@ -70,7 +69,7 @@ class CustomUI {
/** /**
* Set Showing of the Chat * Set Showing of the Chat
* *
* @param bool $visible * @param bool $visible Whether the Chat should be shown
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setChatVisible($visible) { public function setChatVisible($visible) {
@ -81,7 +80,7 @@ class CustomUI {
/** /**
* Set Showing of the Checkpoint List * Set Showing of the Checkpoint List
* *
* @param bool $visible * @param bool $visible Whether the Checkpoint should be shown
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setCheckpointListVisible($visible) { public function setCheckpointListVisible($visible) {
@ -92,7 +91,7 @@ class CustomUI {
/** /**
* Set Showing of Round Scores * Set Showing of Round Scores
* *
* @param bool $visible * @param bool $visible Whether the Round Scores should be shown
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setRoundScoresVisible($visible) { public function setRoundScoresVisible($visible) {
@ -103,7 +102,7 @@ class CustomUI {
/** /**
* Set Showing of the Scoretable * Set Showing of the Scoretable
* *
* @param bool $visible * @param bool $visible Whether the Scoretable should be shown
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setScoretableVisible($visible) { public function setScoretableVisible($visible) {
@ -114,7 +113,7 @@ class CustomUI {
/** /**
* Set Global Showing * Set Global Showing
* *
* @param bool $visible * @param bool $visible Wether the UI should be disabled completely
* @return \FML\CustomUI * @return \FML\CustomUI
*/ */
public function setGlobalVisible($visible) { public function setGlobalVisible($visible) {
@ -125,19 +124,18 @@ class CustomUI {
/** /**
* Render the XML Document * Render the XML Document
* *
* @param \DOMDocument $domDocument * @param \DOMDocument $domDocument (optional) DomDocument for which the XML Element should be rendered
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($domDocument = null) { public function render($domDocument = null) {
$isChild = false; $isChild = (bool) $domDocument;
if ($domDocument) {
$isChild = true;
}
if (!$isChild) { if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding); $domDocument = new \DOMDocument('1.0', $this->encoding);
} }
$xmlElement = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
if (!$isChild) {
$domDocument->appendChild($xmlElement); $domDocument->appendChild($xmlElement);
}
$settings = $this->getSettings(); $settings = $this->getSettings();
foreach ($settings as $setting => $value) { foreach ($settings as $setting => $value) {
if ($value === null) continue; if ($value === null) continue;

View File

@ -2,8 +2,13 @@
namespace FML\Elements; namespace FML\Elements;
use FML\Types\BgColorable;
use FML\Types\Renderable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
/** /**
* Class representing a format * Format Element
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,13 +17,97 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable {
* Protected Properties * Protected Properties
*/ */
protected $tagName = 'format'; protected $tagName = 'format';
protected $bgColor = '';
protected $style = '';
protected $textSize = -1;
protected $textColor = '';
protected $areaColor = '';
protected $areaFocusColor = '';
/**
*
* @see \FML\Types\BgColorable::setBgColor()
* @return \FML\Elements\Format
*/
public function setBgColor($bgColor) {
$this->bgColor = (string) $bgColor;
return $this;
}
/**
*
* @see \FML\Types\Styleable::setStyle()
* @return \FML\Elements\Format
*/
public function setStyle($style) {
$this->style = (string) $style;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setTextSize()
* @return \FML\Elements\Format
*/
public function setTextSize($textSize) {
$this->textSize = (int) $textSize;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setTextColor()
* @return \FML\Elements\Format
*/
public function setTextColor($textColor) {
$this->textColor = (string) $textColor;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setAreaColor()
* @return \FML\Elements\Format
*/
public function setAreaColor($areaColor) {
$this->areaColor = (string) $areaColor;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @return \FML\Elements\Format
*/
public function setAreaFocusColor($areaFocusColor) {
$this->areaFocusColor = (string) $areaFocusColor;
return $this;
}
/** /**
* *
* @see \FML\Renderable::render() * @see \FML\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
return $xml; if ($this->bgColor) {
$xmlElement->setAttribute('bgcolor', $this->bgColor);
}
if ($this->style) {
$xmlElement->setAttribute('style', $this->style);
}
if ($this->textSize >= 0) {
$xmlElement->setAttribute('textsize', $this->textSize);
}
if ($this->textColor) {
$xmlElement->setAttribute('textcolor', $this->textColor);
}
if ($this->areaColor) {
$xmlElement->setAttribute('areacolor', $this->areaColor);
}
if ($this->areaFocusColor) {
$xmlElement->setAttribute('areafocuscolor', $this->areaFocusColor);
}
return $xmlElement;
} }
} }

View File

@ -2,8 +2,10 @@
namespace FML\Elements; namespace FML\Elements;
use FML\Types\Renderable;
/** /**
* Class representing include * Include Element
* *
* @author steeffeen * @author steeffeen
*/ */
@ -11,17 +13,16 @@ class Including implements Renderable {
/** /**
* Protected Properties * Protected Properties
*/ */
protected $url = '';
protected $tagName = 'include'; protected $tagName = 'include';
protected $url = '';
/** /**
* Set Url * Set Url
* *
* @param string $url * @param string $url Include Url
* Include Url
*/ */
public function setUrl($url) { public function setUrl($url) {
$this->url = $url; $this->url = (string) $url;
} }
/** /**
@ -29,10 +30,10 @@ class Including implements Renderable {
* @see \FML\Renderable::render() * @see \FML\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
if ($this->url) { if ($this->url) {
$xml->setAttribute('url', $this->url); $xmlElement->setAttribute('url', $this->url);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -2,8 +2,10 @@
namespace FML\Elements; namespace FML\Elements;
use FML\Types\Renderable;
/** /**
* Class representing music * Music Element
* *
* @author steeffeen * @author steeffeen
*/ */
@ -11,18 +13,17 @@ class Music implements Renderable {
/** /**
* Protected Properties * Protected Properties
*/ */
protected $data = '';
protected $tagName = 'music'; protected $tagName = 'music';
protected $data = '';
/** /**
* Set Data Url * Set Data Url
* *
* @param string $data * @param string $data Media Url
* Media Url
* @return \FML\Elements\Music * @return \FML\Elements\Music
*/ */
public function setData($data) { public function setData($data) {
$this->data = $data; $this->data = (string) $data;
return $this; return $this;
} }
@ -31,10 +32,10 @@ class Music implements Renderable {
* @see \FML\Renderable::render() * @see \FML\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
if ($this->data) { if ($this->data) {
$xml->setAttribute('data', $this->data); $xmlElement->setAttribute('data', $this->data);
} }
return $xml; return $xmlElement;
} }
} }

View File

@ -5,7 +5,7 @@ namespace FML\Elements;
use FML\Types\Renderable; use FML\Types\Renderable;
/** /**
* Class representing a manialink script tag with a simple script text * Class representing a ManiaLink Script Tag with a simple Script Text
* *
* @author steeffeen * @author steeffeen
*/ */
@ -19,7 +19,7 @@ class SimpleScript implements Renderable {
/** /**
* Set Script Text * Set Script Text
* *
* @param string $text * @param string $text The Complete Script Text
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function setText($text) { public function setText($text) {
@ -32,9 +32,9 @@ class SimpleScript implements Renderable {
* @see \FML\Types\Renderable::render() * @see \FML\Types\Renderable::render()
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName); $xmlElement = $domDocument->createElement($this->tagName);
$scriptComment = $domDocument->createComment($this->text); $scriptComment = $domDocument->createComment($this->text);
$xml->appendChild($scriptComment); $xmlElement->appendChild($scriptComment);
return $xml; return $xmlElement;
} }
} }

View File

@ -0,0 +1,294 @@
<?php
namespace FML;
use FML\ManiaCode\Message;
use FML\ManiaCode\Element;
use FML\ManiaCode\ShowMessage;
use FML\ManiaCode\InstallMap;
use FML\ManiaCode\PlayMap;
use FML\ManiaCode\InstallReplay;
use FML\ManiaCode\ViewReplay;
use FML\ManiaCode\PlayReplay;
use FML\ManiaCode\InstallSkin;
use FML\ManiaCode\GetSkin;
use FML\ManiaCode\AddBuddy;
use FML\ManiaCode\Go_To;
use FML\ManiaCode\JoinServer;
use FML\ManiaCode\AddFavorite;
use FML\ManiaCode\InstallScript;
use FML\ManiaCode\InstallPack;
/**
* Class representing a ManiaCode
*
* @author steeffeen
*/
class ManiaCode {
/**
* Protected Properties
*/
protected $encoding = 'utf-8';
protected $tagName = 'maniacode';
protected $noConfirmation = null;
protected $elements = array();
/**
* Set XML Encoding
*
* @param string $encoding XML Encoding
* @return \FML\ManiaCode
*/
public function setXmlEncoding($encoding) {
$this->encoding = (string) $encoding;
return $this;
}
/**
* Disable the Showing of the Confirmation at the End of the ManiaCode
*
* @param bool $disable Whether the Confirmation should be shown
* @return \FML\ManiaCode
*/
public function disableConfirmation($disable) {
$this->noConfirmation = ($disable ? 1 : 0);
return $this;
}
/**
* Show a Message
*
* @param string $message Message Text
* @return \FML\ManiaCode
*/
public function addShowMessage($message) {
$messageElement = new ShowMessage($message);
$this->addElement($messageElement);
return $this;
}
/**
* Install a Map
*
* @param string $name Map Name
* @param string $url Map Url
* @return \FML\ManiaCode
*/
public function addInstallMap($name, $url) {
$mapElement = new InstallMap($name, $url);
$this->addElement($mapElement);
return $this;
}
/**
* Play a Map
*
* @param string $name Map Name
* @param string $url Map Url
* @return \FML\ManiaCode
*/
public function addPlayMap($name, $url) {
$mapElement = new PlayMap($name, $url);
$this->addElement($mapElement);
return $this;
}
/**
* Install a Replay
*
* @param string $name Replay Name
* @param string $url Replay Url
* @return \FML\ManiaCode
*/
public function addInstallReplay($name, $url) {
$replayElement = new InstallReplay($name, $url);
$this->addElement($replayElement);
return $this;
}
/**
* View a Replay
*
* @param string $name Replay Name
* @param string $url Replay Url
* @return \FML\ManiaCode
*/
public function addViewReplay($name, $url) {
$replayElement = new ViewReplay($name, $url);
$this->addElement($replayElement);
return $this;
}
/**
* Play a Replay
*
* @param string $name Replay Name
* @param string $url Replay Url
* @return \FML\ManiaCode
*/
public function addPlayReplay($name, $url) {
$replayElement = new PlayReplay($name, $url);
$this->addElement($replayElement);
return $this;
}
/**
* Install a Skin
*
* @param string $name Skin Name
* @param string $file Skin File
* @param string $url Skin Url
* @return \FML\ManiaCode
*/
public function addInstallSkin($name, $file, $url) {
$skinElement = new InstallSkin($name, $file, $url);
$this->addElement($skinElement);
return $this;
}
/**
* Get a Skin
*
* @param string $name Skin Name
* @param string $file Skin File
* @param string $url Skin Url
* @return \FML\ManiaCode
*/
public function addGetSkin($name, $file, $url) {
$skinElement = new GetSkin($name, $file, $url);
$this->addElement($skinElement);
return $this;
}
/**
* Add a Buddy
*
* @param string $login Buddy Login
* @return \FML\ManiaCode
*/
public function addAddBuddy($login) {
$buddyElement = new AddBuddy($login);
$this->addElement($buddyElement);
return $this;
}
/**
* Go to a Link
*
* @param string $link Goto Link
* @return \FML\ManiaCode
*/
public function addGoto($link) {
$gotoElement = new Go_To($link);
$this->addElement($gotoElement);
return $this;
}
/**
* Join a Server
*
* @param string $login Server Login
* @return \FML\ManiaCode
*/
public function addJoinServer($login) {
$serverElement = new JoinServer($login);
$this->addElement($serverElement);
return $this;
}
/**
* Add a Server as Favorite
*
* @param string $login Server Login
* @return \FML\ManiaCode
*/
public function addAddFavorite($login) {
$favoriteElement = new AddFavorite($login);
$this->addElement($favoriteElement);
return $this;
}
/**
* Install a Script
*
* @param string $name Script Name
* @param string $file Script File
* @param string $url Script Url
* @return \FML\ManiaCode
*/
public function addInstallScript($name, $file, $url) {
$scriptElement = new InstallScript($name, $file, $url);
$this->addElement($scriptElement);
return $this;
}
/**
* Install a Title Pack
*
* @param string $name Pack Name
* @param string $file Pack File
* @param string $url Pack Url
* @return \FML\ManiaCode
*/
public function addInstallPack($name, $file, $url) {
$packElement = new InstallPack($name, $file, $url);
$this->addElement($packElement);
return $this;
}
/**
* Add a ManiaCode Element
*
* @param Element $element The Element to add
* @return \FML\ManiaCode
*/
public function addElement(Element $element) {
array_push($this->elements, $element);
return $this;
}
/**
* Removes all Elements from the ManiaCode
*
* @return \FML\ManiaCode
*/
public function removeElements() {
$this->elements = array();
return $this;
}
/**
* Render the XML Document
*
* @param bool (optional) $echo Whether the XML Text should be echoed and the Content-Type Header should be set
* @return \DOMDocument
*/
public function render($echo = false) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
$maniaCode = $domDocument->createElement($this->tagName);
$domDocument->appendChild($maniaCode);
if ($this->noConfirmation) {
$maniaCode->setAttribute('noconfirmation', $this->noConfirmation);
}
foreach ($this->elements as $element) {
$xmlElement = $element->render($domDocument);
$maniaCode->appendChild($xmlElement);
}
if ($echo) {
header('Content-Type: application/xml');
echo $domDocument->saveXML();
}
return $domDocument;
}
/**
* Get String Representation
*
* @return string
*/
public function __toString() {
$domDocument = $this->render();
$xmlText = $domDocument->saveXML();
return $xmlText;
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element adding a Buddy
*
* @author steeffeen
*/
class AddBuddy implements Element {
/**
* Protected Properties
*/
protected $tagName = 'add_buddy';
protected $login = '';
/**
* Construct a new AddBuddy Element
*
* @param string $login (optional) Buddy Login
*/
public function __construct($login = null) {
if ($login !== null) {
$this->setLogin($login);
}
}
/**
* Set the Buddy Login
*
* @param string $login Buddy Login
* @return \FML\ManiaCode\AddBuddy
*/
public function setLogin($login) {
$this->login = (string) $login;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element adding a Server as Favorite
*
* @author steeffeen
*/
class AddFavorite implements Element {
/**
* Protected Properties
*/
protected $tagName = 'add_favourite';
protected $login = '';
protected $ip = null;
protected $port = null;
/**
* Construct a new AddFavorite Element
*
* @param string $login (optional) Server Login
*/
public function __construct($login = null) {
if ($login !== null) {
$this->setLogin($login);
}
}
/**
* Set the Server Login
*
* @param string $login Server Login
* @return \FML\ManiaCode\AddFavorite
*/
public function setLogin($login) {
$this->login = (string) $login;
$this->ip = null;
$this->port = null;
return $this;
}
/**
* Set the Server Ip and Port
*
* @param string $ip Server Ip
* @param int $port Server Port
* @return \FML\ManiaCode\AddFavorite
*/
public function setIp($ip, $port) {
$this->ip = (string) $ip;
$this->port = (int) $port;
$this->login = null;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
if ($this->ip === null) {
$loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement);
}
else {
$ipElement = $domDocument->createElement('ip', $this->ip . ':' . $this->port);
$xmlElement->appendChild($ipElement);
}
return $xmlElement;
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace FML\ManiaCode;
interface Element {
/**
* Render the ManiaCode Element
*
* @param \DOMDocument $domDocument The DomDocument for which the Element should be rendered
* @return \DOMElement
*/
public function render(\DOMDocument $domDocument);
}

View File

@ -0,0 +1,85 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element getting a Skin
*
* @author steeffeen
*/
class GetSkin implements Element {
/**
* Protected Properties
*/
protected $tagName = 'get_skin';
protected $name = '';
protected $file = '';
protected $url = '';
/**
* Construct a new GetSkin Element
*
* @param string $name (optional) Skin Name
* @param string $file (optional) Skin File
* @param string $url (optional) Skin Url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($file !== null) {
$this->setFile($file);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Skin
*
* @param string $name Skin Name
* @return \FML\ManiaCode\GetSkin
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the File of the Skin
*
* @param string $file Skin File
* @return \FML\ManiaCode\GetSkin
*/
public function setFile($file) {
$this->file = (string) $file;
return $this;
}
/**
* Set the Url of the Skin
*
* @param string $url Skin Url
* @return \FML\ManiaCode\GetSkin
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element going to a Link
*
* @author steeffeen
*/
class Go_To implements Element {
/**
* Protected Properties
*/
protected $tagName = 'goto';
protected $link = '';
/**
* Construct a new Go_To Element
*
* @param string $link (optional) Goto Link
*/
public function __construct($link = null) {
if ($link !== null) {
$this->setLink($link);
}
}
/**
* Set the Goto Link
*
* @param string $link Goto Link
* @return \FML\ManiaCode\Go_To
*/
public function setLink($link) {
$this->link = (string) $link;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$linkElement = $domDocument->createElement('link', $this->link);
$xmlElement->appendChild($linkElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element installing a Map
*
* @author steeffeen
*/
class InstallMap implements Element {
/**
* Protected Properties
*/
protected $tagName = 'install_map';
protected $name = '';
protected $url = '';
/**
* Construct a new InstallMap Element
*
* @param string $name (optional) Map Name
* @param string $url (optional) Map Url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Map
*
* @param string $name Map Name
* @return \FML\ManiaCode\InstallMap
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Url of the Map
*
* @param string $url Map Url
* @return \FML\ManiaCode\InstallMap
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element installing a Title Pack
*
* @author steeffeen
*/
class InstallPack implements Element {
/**
* Protected Properties
*/
protected $tagName = 'install_pack';
protected $name = '';
protected $file = '';
protected $url = '';
/**
* Construct a new InstallPack Element
*
* @param string $name (optional) Pack Name
* @param string $file (optional) Pack File
* @param string $url (optional) Pack Url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($file !== null) {
$this->setFile($file);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Script
*
* @param string $name Pack Name
* @return \FML\ManiaCode\InstallPack
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the File of the Script
*
* @param string $file Pack File
* @return \FML\ManiaCode\InstallPack
*/
public function setFile($file) {
$this->file = (string) $file;
return $this;
}
/**
* Set the Url of the Script
*
* @param string $url Pack Url
* @return \FML\ManiaCode\InstallPack
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element installing a Replay
*
* @author steeffeen
*/
class InstallReplay implements Element {
/**
* Protected Properties
*/
protected $tagName = 'install_replay';
protected $name = '';
protected $url = '';
/**
* Construct a new InstallReplay Element
*
* @param string $name (optional) Replay Name
* @param string $url (optional) Replay Url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Replay
*
* @param string $name Replay Name
* @return \FML\ManiaCode\InstallReplay
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Url of the Replay
*
* @param string $url Replay Url
* @return \FML\ManiaCode\InstallReplay
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element installing a Script
*
* @author steeffeen
*/
class InstallScript implements Element {
/**
* Protected Properties
*/
protected $tagName = 'install_script';
protected $name = '';
protected $file = '';
protected $url = '';
/**
* Construct a new InstallScript Element
*
* @param string $name (optional) Script Name
* @param string $file (optional) Script File
* @param string $url (optional) Script Url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($file !== null) {
$this->setFile($file);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Script
*
* @param string $name Script Name
* @return \FML\ManiaCode\InstallScript
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the File of the Script
*
* @param string $file Script File
* @return \FML\ManiaCode\InstallScript
*/
public function setFile($file) {
$this->file = (string) $file;
return $this;
}
/**
* Set the Url of the Script
*
* @param string $url Script Url
* @return \FML\ManiaCode\InstallScript
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element installing a Skin
*
* @author steeffeen
*/
class InstallSkin implements Element {
/**
* Protected Properties
*/
protected $tagName = 'install_skin';
protected $name = '';
protected $file = '';
protected $url = '';
/**
* Construct a new InstallSkin Element
*
* @param string $name (optional) Skin Name
* @param string $file (optional) Skin File
* @param string $url (optional) Skin Url
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($file !== null) {
$this->setFile($file);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Skin
*
* @param string $name Skin Name
* @return \FML\ManiaCode\InstallSkin
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the File of the Skin
*
* @param string $file Skin File
* @return \FML\ManiaCode\InstallSkin
*/
public function setFile($file) {
$this->file = (string) $file;
return $this;
}
/**
* Set the Url of the Skin
*
* @param string $url Skin Url
* @return \FML\ManiaCode\InstallSkin
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element joining a Server
*
* @author steeffeen
*/
class JoinServer implements Element {
/**
* Protected Properties
*/
protected $tagName = 'join_server';
protected $login = '';
protected $ip = null;
protected $port = null;
/**
* Construct a new JoinServer Element
*
* @param string $login (optional) Server Login
*/
public function __construct($login = null) {
if ($login !== null) {
$this->setLogin($login);
}
}
/**
* Set the Server Login
*
* @param string $login Server Login
* @return \FML\ManiaCode\JoinServer
*/
public function setLogin($login) {
$this->login = (string) $login;
$this->ip = null;
$this->port = null;
return $this;
}
/**
* Set the Server Ip and Port
*
* @param string $ip Server Ip
* @param int $port Server Port
* @return \FML\ManiaCode\JoinServer
*/
public function setIp($ip, $port) {
$this->ip = (string) $ip;
$this->port = (int) $port;
$this->login = null;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
if ($this->ip === null) {
$loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement);
}
else {
$ipElement = $domDocument->createElement('ip', $this->ip . ':' . $this->port);
$xmlElement->appendChild($ipElement);
}
return $xmlElement;
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element playing a Map
*
* @author steeffeen
*/
class PlayMap implements Element {
/**
* Protected Properties
*/
protected $tagName = 'play_map';
protected $name = '';
protected $url = '';
/**
* Construct a new PlayMap Element
*
* @param string $name (optional) Map Name
* @param string $url (optional) Map Url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Map
*
* @param string $name Map Name
* @return \FML\ManiaCode\PlayMap
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Url of the Map
*
* @param string $url Map Url
* @return \FML\ManiaCode\PlayMap
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element playing a Replay
*
* @author steeffeen
*/
class PlayReplay implements Element {
/**
* Protected Properties
*/
protected $tagName = 'play_replay';
protected $name = '';
protected $url = '';
/**
* Construct a new PlayReplay Element
*
* @param string $name (optional) Replay Name
* @param string $url (optional) Replay Url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Replay
*
* @param string $name Replay Name
* @return \FML\ManiaCode\PlayReplay
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Url of the Replay
*
* @param string $url Replay Url
* @return \FML\ManiaCode\PlayReplay
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element showing a Message
*
* @author steeffeen
*/
class ShowMessage implements Element {
/**
* Protected Properties
*/
protected $tagName = 'show_message';
protected $message = '';
/**
* Construct a new ShowMessage Element
*
* @param string $message (optional) Message Text
*/
public function __construct($message = null) {
if ($message !== null) {
$this->setMessage($message);
}
}
/**
* Set the displayed Message Text
*
* @param string $message Message Text
* @return \FML\ManiaCode\ShowMessage
*/
public function setMessage($message) {
$this->message = (string) $message;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$messageElement = $domDocument->createElement('message', $this->message);
$xmlElement->appendChild($messageElement);
return $xmlElement;
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element viewing a Replay
*
* @author steeffeen
*/
class ViewReplay implements Element {
/**
* Protected Properties
*/
protected $tagName = 'view_replay';
protected $name = '';
protected $url = '';
/**
* Construct a new ViewReplay Element
*
* @param string $name (optional) Replay Name
* @param string $url (optional) Replay Url
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Replay
*
* @param string $name Replay Name
* @return \FML\ManiaCode\ViewReplay
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Url of the Replay
*
* @param string $url Replay Url
* @return \FML\ManiaCode\ViewReplay
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = $domDocument->createElement($this->tagName);
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}

View File

@ -7,7 +7,7 @@ use FML\Types\Renderable;
use FML\Script\Script; use FML\Script\Script;
/** /**
* Class representing a Manialink * Class representing a ManiaLink
* *
* @author steeffeen * @author steeffeen
*/ */
@ -26,15 +26,13 @@ class ManiaLink implements Container {
protected $script = null; protected $script = null;
/** /**
* Construct a new Manialink * Create a new ManiaLink
* *
* @param string $id Manialink Id * @param string $id Manialink Id
*/ */
public function __construct($id = null) { public function __construct($id = null) {
if ($id !== null) {
$this->setId($id); $this->setId($id);
} }
}
/** /**
* Set XML Encoding * Set XML Encoding
@ -43,7 +41,7 @@ class ManiaLink implements Container {
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setXmlEncoding($encoding) { public function setXmlEncoding($encoding) {
$this->encoding = $encoding; $this->encoding = (string) $encoding;
return $this; return $this;
} }
@ -54,7 +52,7 @@ class ManiaLink implements Container {
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setId($id) { public function setId($id) {
$this->id = $id; $this->id = (string) $id;
return $this; return $this;
} }
@ -65,14 +63,14 @@ class ManiaLink implements Container {
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setBackground($background) { public function setBackground($background) {
$this->background = $background; $this->background = (string) $background;
return $this; return $this;
} }
/** /**
* Set Navigable3d * Set Navigable3d
* *
* @param bool $navigable3d If the manialink is 3d navigable * @param bool $navigable3d Whether the manialink should be 3d navigable
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setNavigable3d($navigable3d) { public function setNavigable3d($navigable3d) {
@ -87,7 +85,7 @@ class ManiaLink implements Container {
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setTimeout($timeout) { public function setTimeout($timeout) {
$this->timeout = $timeout; $this->timeout = (int) $timeout;
return $this; return $this;
} }
@ -114,7 +112,7 @@ class ManiaLink implements Container {
/** /**
* Set the Script of the ManiaLink * Set the Script of the ManiaLink
* *
* @param Script $script * @param Script $script The Script for the ManiaLink
* @return \FML\ManiaLink * @return \FML\ManiaLink
*/ */
public function setScript(Script $script) { public function setScript(Script $script) {
@ -125,7 +123,7 @@ class ManiaLink implements Container {
/** /**
* Get the current Script of the ManiaLink * Get the current Script of the ManiaLink
* *
* @param string $createIfEmpty * @param string $createIfEmpty (optional) Whether the Script Object should be created if it's not set yet
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function getScript($createIfEmpty = true) { public function getScript($createIfEmpty = true) {
@ -138,48 +136,45 @@ class ManiaLink implements Container {
/** /**
* Render the XML Document * Render the XML Document
* *
* @param bool $echo If the xml should be echoed and the content-type header should be set * @param bool (optional) $echo If the XML Text should be echoed and the Content-Type Header should be set
* @param \DOMDocument $domDocument * @param \DOMDocument $domDocument (optional) DOMDocument for which the XML Element should be created
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($echo = false, $domDocument = null) { public function render($echo = false, $domDocument = null) {
$isChild = false; $isChild = (bool) $domDocument;
if ($domDocument) {
$isChild = true;
}
if (!$isChild) { if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding); $domDocument = new \DOMDocument('1.0', $this->encoding);
} }
$manialink = $domDocument->createElement($this->tagName); $maniaLink = $domDocument->createElement($this->tagName);
if (!$isChild) { if (!$isChild) {
$domDocument->appendChild($manialink); $domDocument->appendChild($maniaLink);
} }
if ($this->id) { if ($this->id !== null) {
$manialink->setAttribute('id', $this->id); $maniaLink->setAttribute('id', $this->id);
} }
if ($this->version) { if ($this->version !== null) {
$manialink->setAttribute('version', $this->version); $maniaLink->setAttribute('version', $this->version);
} }
if ($this->background) { if ($this->background !== null) {
$manialink->setAttribute('background', $this->background); $maniaLink->setAttribute('background', $this->background);
} }
if ($this->navigable3d) { if ($this->navigable3d !== null) {
$manialink->setAttribute('navigable3d', $this->navigable3d); $maniaLink->setAttribute('navigable3d', $this->navigable3d);
} }
if ($this->timeout) { if ($this->timeout !== null) {
$timeoutXml = $domDocument->createElement('timeout', $this->timeout); $timeoutXml = $domDocument->createElement('timeout', $this->timeout);
$manialink->appendChild($timeoutXml); $maniaLink->appendChild($timeoutXml);
} }
foreach ($this->children as $child) { foreach ($this->children as $child) {
$childXml = $child->render($domDocument); $childXml = $child->render($domDocument);
$manialink->appendChild($childXml); $maniaLink->appendChild($childXml);
} }
if ($this->script) { if ($this->script) {
$scriptXml = $this->script->render($domDocument); $scriptXml = $this->script->render($domDocument);
$manialink->appendChild($scriptXml); $maniaLink->appendChild($scriptXml);
} }
if ($isChild) { if ($isChild) {
return $manialink; return $maniaLink;
} }
if ($echo) { if ($echo) {
header('Content-Type: application/xml'); header('Content-Type: application/xml');

View File

@ -3,7 +3,7 @@
namespace FML; namespace FML;
/** /**
* Class holding several Manialinks at once * Class holding several ManiaLinks at once
* *
* @author steeffeen * @author steeffeen
*/ */
@ -23,7 +23,7 @@ class ManiaLinks {
* @return \FML\ManiaLinks * @return \FML\ManiaLinks
*/ */
public function setXmlEncoding($encoding) { public function setXmlEncoding($encoding) {
$this->encoding = $encoding; $this->encoding = (string) $encoding;
return $this; return $this;
} }
@ -64,20 +64,20 @@ class ManiaLinks {
/** /**
* Render the XML Document * Render the XML Document
* *
* @param bool $echo If the XML should be echoed and the Content-Type Header should be set * @param bool (optional) $echo Whether the XML Text should be echoed and the Content-Type Header should be set
* @return \DOMDocument * @return \DOMDocument
*/ */
public function render($echo = false) { public function render($echo = false) {
$domDocument = new \DOMDocument('1.0', $this->encoding); $domDocument = new \DOMDocument('1.0', $this->encoding);
$manialinks = $domDocument->createElement($this->tagName); $maniaLinks = $domDocument->createElement($this->tagName);
$domDocument->appendChild($manialinks); $domDocument->appendChild($maniaLinks);
foreach ($this->children as $child) { foreach ($this->children as $child) {
$childXml = $child->render(false, $domDocument); $childXml = $child->render(false, $domDocument);
$manialinks->appendChild($childXml); $maniaLinks->appendChild($childXml);
} }
if ($this->customUI) { if ($this->customUI) {
$customUIXml = $this->customUI->render($domDocument); $customUIXml = $this->customUI->render($domDocument);
$manialinks->appendChild($customUIXml); $maniaLinks->appendChild($customUIXml);
} }
if ($echo) { if ($echo) {
header('Content-Type: application/xml'); header('Content-Type: application/xml');

View File

@ -12,8 +12,8 @@ abstract class Builder {
/** /**
* Build a Label Implementation Block * Build a Label Implementation Block
* *
* @param string $labelName * @param string $labelName Name of the Label
* @param string $implementationCode * @param string $implementationCode Label Implementation Coding (without declaration)
* @return string * @return string
*/ */
public static function getLabelImplementationBlock($labelName, $implementationCode) { public static function getLabelImplementationBlock($labelName, $implementationCode) {
@ -24,7 +24,7 @@ abstract class Builder {
/** /**
* Get the Real String-Representation of the given Value * Get the Real String-Representation of the given Value
* *
* @param float $value * @param float $value The Float Value to convert to a ManiaScript Real
* @return string * @return string
*/ */
public static function getReal($value) { public static function getReal($value) {

View File

@ -15,7 +15,7 @@ class Script {
/** /**
* Constants * Constants
*/ */
const CLASS_TOOLTIPS = 'FML_Tooltips'; const CLASS_TOOLTIP = 'FML_Tooltip';
const CLASS_MENU = 'FML_Menu'; const CLASS_MENU = 'FML_Menu';
const CLASS_MENUBUTTON = 'FML_MenuButton'; const CLASS_MENUBUTTON = 'FML_MenuButton';
const CLASS_PAGE = 'FML_Page'; const CLASS_PAGE = 'FML_Page';
@ -25,11 +25,12 @@ class Script {
const CLASS_MAPINFO = 'FML_MapInfo'; const CLASS_MAPINFO = 'FML_MapInfo';
const CLASS_SOUND = 'FML_Sound'; const CLASS_SOUND = 'FML_Sound';
const CLASS_TOGGLE = 'FML_Toggle'; const CLASS_TOGGLE = 'FML_Toggle';
const CLASS_SHOW = 'FML_Show'; const CLASS_SPECTATE = 'FML_Spectate';
const CLASS_HIDE = 'FML_Hide'; const OPTION_TOOLTIP_STAYONCLICK = 'FML_StayOnClick_Tooltip';
const OPTION_TOOLTIP_STAYONCLICK = 'FML_Tooltip_StayOnClick'; const OPTION_TOOLTIP_INVERT = 'FML_Invert_Tooltip';
const OPTION_TOOLTIP_INVERT = 'FML_Tooltip_Invert'; const OPTION_TOOLTIP_TEXT = 'FML_Text_Tooltip';
const OPTION_TOOLTIP_TEXT = 'FML_Tooltip_Text'; const OPTION_TOGGLE_SHOW = 'FML_Show_Toggle';
const OPTION_TOGGLE_HIDE = 'FML_Hide_Toggle';
const LABEL_ONINIT = 'OnInit'; const LABEL_ONINIT = 'OnInit';
const LABEL_LOOP = 'Loop'; const LABEL_LOOP = 'Loop';
const LABEL_ENTRYSUBMIT = 'EntrySubmit'; const LABEL_ENTRYSUBMIT = 'EntrySubmit';
@ -38,6 +39,7 @@ class Script {
const LABEL_MOUSEOUT = 'MouseOut'; const LABEL_MOUSEOUT = 'MouseOut';
const LABEL_MOUSEOVER = 'MouseOver'; const LABEL_MOUSEOVER = 'MouseOver';
const CONSTANT_TOOLTIPTEXTS = 'C_FML_TooltipTexts'; const CONSTANT_TOOLTIPTEXTS = 'C_FML_TooltipTexts';
const FUNCTION_GETTOOLTIPCONTROLID = 'FML_GetTooltipControlId';
const FUNCTION_SETTOOLTIPTEXT = 'FML_SetTooltipText'; const FUNCTION_SETTOOLTIPTEXT = 'FML_SetTooltipText';
const FUNCTION_TOGGLE = 'FML_Toggle'; const FUNCTION_TOGGLE = 'FML_Toggle';
@ -56,12 +58,13 @@ class Script {
protected $mapInfo = false; protected $mapInfo = false;
protected $sounds = array(); protected $sounds = array();
protected $toggles = false; protected $toggles = false;
protected $spectate = false;
/** /**
* Set an Include of the Script * Set an Include of the Script
* *
* @param string $namespace * @param string $namespace Namespace used for the Include
* @param string $file * @param string $file Included File Url
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function setInclude($namespace, $file) { public function setInclude($namespace, $file) {
@ -72,8 +75,8 @@ class Script {
/** /**
* Set a Constant of the Script * Set a Constant of the Script
* *
* @param string $name * @param string $name Variable Name of the Constant
* @param string $value * @param string $value Constant Value
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function setConstant($name, $value) { public function setConstant($name, $value) {
@ -84,8 +87,8 @@ class Script {
/** /**
* Set a Function of the Script * Set a Function of the Script
* *
* @param string $name * @param string $name Function Name
* @param string $coding * @param string $coding Complete Function Implementation including Declaration
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function setFunction($name, $coding) { public function setFunction($name, $coding) {
@ -110,8 +113,8 @@ class Script {
$tooltipControl->setVisible(false); $tooltipControl->setVisible(false);
$hoverControl->checkId(); $hoverControl->checkId();
$hoverControl->setScriptEvents(true); $hoverControl->setScriptEvents(true);
$hoverControl->addClass(self::CLASS_TOOLTIPS); $hoverControl->addClass(self::CLASS_TOOLTIP);
$hoverControl->addClass($tooltipControl->getId()); $hoverControl->addClass(self::CLASS_TOOLTIP . '-' . $tooltipControl->getId());
$options = $this->spliceParameters(func_get_args(), 2); $options = $this->spliceParameters(func_get_args(), 2);
foreach ($options as $option => $value) { foreach ($options as $option => $value) {
if ($option == self::OPTION_TOOLTIP_TEXT) { if ($option == self::OPTION_TOOLTIP_TEXT) {
@ -139,9 +142,9 @@ class Script {
/** /**
* Add a Menu Behavior * Add a Menu Behavior
* *
* @param Control $clickControl * @param Control $clickControl The Control showing the Menu
* @param Control $menuControl * @param Control $menuControl The Menu to show
* @param string $menuId * @param string $menuId (optional) An identifier to specify the Menu Group
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function addMenu(Control $clickControl, Control $menuControl, $menuId = null) { public function addMenu(Control $clickControl, Control $menuControl, $menuId = null) {
@ -156,7 +159,6 @@ class Script {
$clickControl->setScriptEvents(true); $clickControl->setScriptEvents(true);
$clickControl->addClass(self::CLASS_MENUBUTTON); $clickControl->addClass(self::CLASS_MENUBUTTON);
$clickControl->addClass($menuId . '-' . $menuControl->getId()); $clickControl->addClass($menuId . '-' . $menuControl->getId());
$this->setInclude('TextLib', 'TextLib');
$this->menus = true; $this->menus = true;
return $this; return $this;
} }
@ -164,9 +166,9 @@ class Script {
/** /**
* Add a Page for a Paging Behavior * Add a Page for a Paging Behavior
* *
* @param Control $pageControl * @param Control $pageControl The Page to display
* @param int $pageNumber * @param int $pageNumber The Number of the Page
* @param string $pagesId * @param string $pagesId (optional) An identifier to specify the Pages Group
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function addPage(Control $pageControl, $pageNumber, $pagesId = null) { public function addPage(Control $pageControl, $pageNumber, $pagesId = null) {
@ -181,9 +183,9 @@ class Script {
/** /**
* Add a Pager Button for a Paging Behavior * Add a Pager Button for a Paging Behavior
* *
* @param Control $pagerControl * @param Control $pagerControl The Control to leaf through the Pages
* @param int $pagingAction * @param int $pagingAction The Number of Pages the Pager leafs
* @param string $pagesId * @param string $pagesId (optional) An identifier to specify the Pages Group
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function addPager(Control $pagerControl, $pagingAction, $pagesId = null) { public function addPager(Control $pagerControl, $pagingAction, $pagesId = null) {
@ -197,7 +199,6 @@ class Script {
$pagerControl->addClass(self::CLASS_PAGER); $pagerControl->addClass(self::CLASS_PAGER);
$pagerControl->addClass(self::CLASS_PAGER . '-I' . $pagesId); $pagerControl->addClass(self::CLASS_PAGER . '-I' . $pagesId);
$pagerControl->addClass(self::CLASS_PAGER . '-A' . $pagingAction); $pagerControl->addClass(self::CLASS_PAGER . '-A' . $pagingAction);
$this->setInclude('TextLib', 'TextLib');
$this->pages = true; $this->pages = true;
return $this; return $this;
} }
@ -205,7 +206,7 @@ class Script {
/** /**
* Add a Label that shows the current Page Number * Add a Label that shows the current Page Number
* *
* @param Label $pageLabel * @param Label $pageLabel The Label showing the Number of the currently displayed Page
* @param string $pagesId * @param string $pagesId
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
@ -218,9 +219,10 @@ class Script {
/** /**
* Add a Button Behavior that will open the Built-In Player Profile * Add a Button Behavior that will open the Built-In Player Profile
* (Works only for Server ManiaLinks)
* *
* @param Control $profileControl * @param Control $profileControl The Control opening a Profile
* @param string $playerLogin * @param string $playerLogin The Player Login
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function addProfileButton(Control $profileControl, $playerLogin) { public function addProfileButton(Control $profileControl, $playerLogin) {
@ -230,18 +232,17 @@ class Script {
} }
$profileControl->setScriptEvents(true); $profileControl->setScriptEvents(true);
$profileControl->addClass(self::CLASS_PROFILE); $profileControl->addClass(self::CLASS_PROFILE);
if ($playerLogin) { $playerLogin = (string) $playerLogin;
$profileControl->addClass(self::CLASS_PROFILE . '-' . $playerLogin); $profileControl->addClass(self::CLASS_PROFILE . '-' . $playerLogin);
}
$this->setInclude('TextLib', 'TextLib');
$this->profile = true; $this->profile = true;
return $this; return $this;
} }
/** /**
* Add a Button Behavior that will open the Built-In Map Info * Add a Button Behavior that will open the Built-In Map Info
* (Works only on a Server)
* *
* @param Control $mapInfoControl * @param Control $mapInfoControl The Control opening the Map Info
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function addMapInfoButton(Control $mapInfoControl) { public function addMapInfoButton(Control $mapInfoControl) {
@ -257,12 +258,13 @@ class Script {
/** /**
* Add a Sound Playing for the Control * Add a Sound Playing for the Control
* (Works only for Server ManiaLinks)
* *
* @param Control $control * @param Control $control The Control playing a Sound
* @param string $soundName * @param string $soundName The Sound to play
* @param int $soundVariant * @param int $soundVariant (optional) Sound Variant
* @param float $soundVolume * @param float $soundVolume (optional) Sound Volume
* @param string $eventLabel * @param string $eventLabel (optional) The Event Label on which the Sound should be played
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function addSound(Control $control, $soundName, $soundVariant = 0, $soundVolume = 1., $eventLabel = self::LABEL_MOUSECLICK) { public function addSound(Control $control, $soundName, $soundVariant = 0, $soundVolume = 1., $eventLabel = self::LABEL_MOUSECLICK) {
@ -286,35 +288,56 @@ class Script {
/** /**
* Add a Toggling Behavior * Add a Toggling Behavior
* *
* @param Control $clickControl * @param Control $clickControl The Control that toggles another Control on Click
* @param Control $toggleControl * @param Control $toggleControl The Control to toggle
* @param string $mode * @param string $mode (optional) Whether the Visibility should be toggled or only en-/disabled
* @return \FML\Script\Script * @return \FML\Script\Script
*/ */
public function addToggle(Control $clickControl, Control $toggleControl, $mode = self::CLASS_TOGGLE) { public function addToggle(Control $clickControl, Control $toggleControl, $option = null) {
if (!($clickControl instanceof Scriptable)) { if (!($clickControl instanceof Scriptable)) {
trigger_error('Scriptable Control needed as ClickControl for Toggles!'); trigger_error('Scriptable Control needed as ClickControl for Toggles!');
return $this; return $this;
} }
$toggleControl->checkId(); $toggleControl->checkId();
if ($mode == self::CLASS_HIDE) { if ($option == self::OPTION_TOGGLE_HIDE) {
$toggleControl->setVisible(true); $toggleControl->setVisible(true);
$clickControl->addClass($option);
} }
else { else if ($option == self::OPTION_TOGGLE_SHOW) {
$toggleControl->setVisible(false); $toggleControl->setVisible(false);
$clickControl->addClass($option);
} }
$clickControl->setScriptEvents(true); $clickControl->setScriptEvents(true);
$clickControl->addClass(self::CLASS_TOGGLE); $clickControl->addClass(self::CLASS_TOGGLE);
$clickControl->addClass($mode); $clickControl->addClass(self::CLASS_TOGGLE . '-' . $toggleControl->getId());
$clickControl->addClass($toggleControl->getId());
$this->toggles = true; $this->toggles = true;
return $this; return $this;
} }
/**
* Add a Spectate Button Behavior
*
* @param Control $clickControl The Control that works as Spectate Button
* @param string $spectateTargetLogin The Login of the Player to Spectate
* @return \FML\Script\Script
*/
public function addSpectateButton(Control $clickControl, $spectateTargetLogin) {
if (!($clickControl instanceof Scriptable)) {
trigger_error('Scriptable Control needed as ClickControl for Spectating!');
return $this;
}
$clickControl->setScriptEvents(true);
$clickControl->addClass(self::CLASS_SPECTATE);
$spectateTargetLogin = (string) $spectateTargetLogin;
$clickControl->addClass(self::CLASS_SPECTATE . '-' . $spectateTargetLogin);
$this->spectate = true;
return $this;
}
/** /**
* Create the Script XML Tag * Create the Script XML Tag
* *
* @param \DOMDocument $domDocument * @param \DOMDocument $domDocument DOMDocument for which the XML Element should be created
* @return \DOMElement * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument) { public function render(\DOMDocument $domDocument) {
@ -343,6 +366,7 @@ class Script {
$scriptText .= $this->getMapInfoLabels(); $scriptText .= $this->getMapInfoLabels();
$scriptText .= $this->getSoundLabels(); $scriptText .= $this->getSoundLabels();
$scriptText .= $this->getToggleLabels(); $scriptText .= $this->getToggleLabels();
$scriptText .= $this->getSpectateLabels();
$scriptText .= $this->getMainFunction(); $scriptText .= $this->getMainFunction();
return $scriptText; return $scriptText;
} }
@ -438,6 +462,7 @@ class Script {
*/ */
private function buildTooltipFunctions() { private function buildTooltipFunctions() {
if (!$this->tooltips) return; if (!$this->tooltips) return;
$this->setInclude('TextLib', 'TextLib');
$setFunctionText = " $setFunctionText = "
Void " . self::FUNCTION_SETTOOLTIPTEXT . "(CMlControl _TooltipControl, CMlControl _HoverControl) { Void " . self::FUNCTION_SETTOOLTIPTEXT . "(CMlControl _TooltipControl, CMlControl _HoverControl) {
if (!_TooltipControl.Visible) return; if (!_TooltipControl.Visible) return;
@ -447,6 +472,13 @@ Void " . self::FUNCTION_SETTOOLTIPTEXT . "(CMlControl _TooltipControl, CMlContro
if (!" . self::CONSTANT_TOOLTIPTEXTS . "[TooltipId].existskey(HoverId)) return; if (!" . self::CONSTANT_TOOLTIPTEXTS . "[TooltipId].existskey(HoverId)) return;
declare Label = (_TooltipControl as CMlLabel); declare Label = (_TooltipControl as CMlLabel);
Label.Value = " . self::CONSTANT_TOOLTIPTEXTS . "[TooltipId][HoverId]; Label.Value = " . self::CONSTANT_TOOLTIPTEXTS . "[TooltipId][HoverId];
}
Text " . self::FUNCTION_GETTOOLTIPCONTROLID . "(Text _ControlClass) {
declare ClassParts = TextLib::Split(\"-\", _ControlClass);
if (ClassParts.count < 2) return \"\”;
if (ClassParts[0] != \"" . self::CLASS_TOOLTIP . "\") return \"\";
return ClassParts[1];
}"; }";
$this->setFunction(self::FUNCTION_SETTOOLTIPTEXT, $setFunctionText); $this->setFunction(self::FUNCTION_SETTOOLTIPTEXT, $setFunctionText);
} }
@ -457,25 +489,29 @@ Void " . self::FUNCTION_SETTOOLTIPTEXT . "(CMlControl _TooltipControl, CMlContro
* @return string * @return string
*/ */
private function getTooltipLabels() { private function getTooltipLabels() {
if (!$this->tooltips) return ""; if (!$this->tooltips) return '';
$mouseOverScript = " $mouseOverScript = "
if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIPS . "\")) { if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIP . "\")) {
declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\"); declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\");
foreach (ControlClass in Event.Control.ControlClasses) { foreach (ControlClass in Event.Control.ControlClasses) {
declare TooltipControl <=> Page.GetFirstChild(ControlClass); declare ControlId = " . self::FUNCTION_GETTOOLTIPCONTROLID . "(ControlClass);
if (ControlId == \"\") continue;
declare TooltipControl <=> Page.GetFirstChild(ControlId);
if (TooltipControl == Null) continue; if (TooltipControl == Null) continue;
TooltipControl.Visible = !Invert; TooltipControl.Visible = !Invert;
" . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control); " . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control);
} }
}"; }";
$mouseOutScript = " $mouseOutScript = "
if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIPS . "\")) { if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIP . "\")) {
declare FML_Clicked for Event.Control = False; declare FML_Clicked for Event.Control = False;
declare StayOnClick = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_STAYONCLICK . "\"); declare StayOnClick = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_STAYONCLICK . "\");
if (!StayOnClick || !FML_Clicked) { if (!StayOnClick || !FML_Clicked) {
declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\"); declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\");
foreach (ControlClass in Event.Control.ControlClasses) { foreach (ControlClass in Event.Control.ControlClasses) {
declare TooltipControl <=> Page.GetFirstChild(ControlClass); declare ControlId = " . self::FUNCTION_GETTOOLTIPCONTROLID . "(ControlClass);
if (ControlId == \"\") continue;
declare TooltipControl <=> Page.GetFirstChild(ControlId);
if (TooltipControl == Null) continue; if (TooltipControl == Null) continue;
TooltipControl.Visible = Invert; TooltipControl.Visible = Invert;
" . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control); " . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control);
@ -483,7 +519,7 @@ if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIPS . "\")) {
} }
}"; }";
$mouseClickScript = " $mouseClickScript = "
if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIPS . "\")) { if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIP . "\")) {
declare Handle = True; declare Handle = True;
declare Show = False; declare Show = False;
declare StayOnClick = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_STAYONCLICK . "\"); declare StayOnClick = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_STAYONCLICK . "\");
@ -501,7 +537,9 @@ if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIPS . "\")) {
if (Handle) { if (Handle) {
declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\"); declare Invert = Event.Control.HasClass(\"" . self::OPTION_TOOLTIP_INVERT . "\");
foreach (ControlClass in Event.Control.ControlClasses) { foreach (ControlClass in Event.Control.ControlClasses) {
declare TooltipControl <=> Page.GetFirstChild(ControlClass); declare ControlId = " . self::FUNCTION_GETTOOLTIPCONTROLID . "(ControlClass);
if (ControlId == \"\") continue;
declare TooltipControl <=> Page.GetFirstChild(ControlId);
if (TooltipControl == Null) continue; if (TooltipControl == Null) continue;
TooltipControl.Visible = Show && !Invert; TooltipControl.Visible = Show && !Invert;
" . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control); " . self::FUNCTION_SETTOOLTIPTEXT . "(TooltipControl, Event.Control);
@ -520,14 +558,15 @@ if (Event.Control.HasClass(\"" . self::CLASS_TOOLTIPS . "\")) {
* @return string * @return string
*/ */
private function getMenuLabels() { private function getMenuLabels() {
if (!$this->menus) return ""; if (!$this->menus) return '';
$this->setInclude('TextLib', 'TextLib');
$mouseClickScript = " $mouseClickScript = "
if (Event.Control.HasClass(\"" . self::CLASS_MENUBUTTON . "\")) { if (Event.Control.HasClass(\"" . self::CLASS_MENUBUTTON . "\")) {
declare Text MenuIdClass; declare Text MenuIdClass;
declare Text MenuControlId; declare Text MenuControlId;
foreach (ControlClass in Event.Control.ControlClasses) { foreach (ControlClass in Event.Control.ControlClasses) {
declare ClassParts = TextLib::Split(\"-\", ControlClass); declare ClassParts = TextLib::Split(\"-\", ControlClass);
if (ClassParts.count <= 1) continue; if (ClassParts.count < 2) continue;
MenuIdClass = ClassParts[0]; MenuIdClass = ClassParts[0];
MenuControlId = ClassParts[1]; MenuControlId = ClassParts[1];
break; break;
@ -549,6 +588,7 @@ if (Event.Control.HasClass(\"" . self::CLASS_MENUBUTTON . "\")) {
*/ */
private function getPagesLabels() { private function getPagesLabels() {
if (!$this->pages) return ""; if (!$this->pages) return "";
$this->setInclude('TextLib', 'TextLib');
$pagesNumberPrefix = self::CLASS_PAGE . '-P'; $pagesNumberPrefix = self::CLASS_PAGE . '-P';
$pagesNumberPrefixLength = strlen($pagesNumberPrefix); $pagesNumberPrefixLength = strlen($pagesNumberPrefix);
$pagesScript = " $pagesScript = "
@ -557,7 +597,7 @@ if (Event.Control.HasClass(\"" . self::CLASS_PAGER . "\")) {
declare Integer PagingAction; declare Integer PagingAction;
foreach (ControlClass in Event.Control.ControlClasses) { foreach (ControlClass in Event.Control.ControlClasses) {
declare ClassParts = TextLib::Split(\"-\", ControlClass); declare ClassParts = TextLib::Split(\"-\", ControlClass);
if (ClassParts.count <= 1) continue; if (ClassParts.count < 2) continue;
if (ClassParts[0] != \"" . self::CLASS_PAGER . "\") continue; if (ClassParts[0] != \"" . self::CLASS_PAGER . "\") continue;
switch (TextLib::SubText(ClassParts[1], 0, 1)) { switch (TextLib::SubText(ClassParts[1], 0, 1)) {
case \"I\": { case \"I\": {
@ -627,14 +667,19 @@ if (Event.Control.HasClass(\"" . self::CLASS_PAGER . "\")) {
*/ */
private function getProfileLabels() { private function getProfileLabels() {
if (!$this->profile) return ""; if (!$this->profile) return "";
$this->setInclude('TextLib', 'TextLib');
$profileScript = " $profileScript = "
if (Event.Control.HasClass(\"" . self::CLASS_PROFILE . "\")) { if (Event.Control.HasClass(\"" . self::CLASS_PROFILE . "\")) {
declare Login = LocalUser.Login; declare Login = LocalUser.Login;
foreach (ControlClass in Event.Control.ControlClasses) { foreach (ControlClass in Event.Control.ControlClasses) {
declare ClassParts = TextLib::Split(\"-\", ControlClass); declare ClassParts = TextLib::Split(\"-\", ControlClass);
if (ClassParts.count <= 1) continue; if (ClassParts.count < 2) continue;
if (ClassParts[0] != \"" . self::CLASS_PROFILE . "\") continue; if (ClassParts[0] != \"" . self::CLASS_PROFILE . "\") continue;
Login = ClassParts[1]; Login = \"\";
for (Index, 1, ClassParts.count - 1) {
Login ^= ClassParts[Index];
if (Index < ClassParts.count - 1) Login ^= \"-\";
}
break; break;
} }
ShowProfile(Login); ShowProfile(Login);
@ -698,18 +743,23 @@ if (Event.Control.HasClass(\"" . self::CLASS_SOUND . "\")) {
*/ */
private function getToggleLabels() { private function getToggleLabels() {
if (!$this->toggles) return ''; if (!$this->toggles) return '';
$this->setInclude('TextLib', 'TextLib');
$toggleScript = " $toggleScript = "
if (Event.Control.HasClass(\"" . self::CLASS_TOGGLE . "\")) { if (Event.Control.HasClass(\"" . self::CLASS_TOGGLE . "\")) {
declare HasShow = Event.Control.HasClass(\"" . self::CLASS_SHOW . "\"); declare HasShow = Event.Control.HasClass(\"" . self::OPTION_TOGGLE_SHOW . "\");
declare HasHide = Event.Control.HasClass(\"" . self::CLASS_HIDE . "\"); declare HasHide = Event.Control.HasClass(\"" . self::OPTION_TOGGLE_HIDE . "\");
declare Toggle = True; declare Toggle = True;
declare Show = True; declare Show = True;
if (HasShow || HasHide) { if (HasShow || HasHide) {
Toggle = False; Toggle = False;
Show = HasShow; Show = HasShow;
} }
declare PrefixLength = TextLib::Length(\"" . self::CLASS_TOGGLE . "\");
foreach (ControlClass in Event.Control.ControlClasses) { foreach (ControlClass in Event.Control.ControlClasses) {
declare ToggleControl <=> Page.GetFirstChild(ControlClass); declare ClassParts = TextLib::Split(\"-\", ControlClass);
if (ClassParts.count < 2) continue;
if (ClassParts[0] != \"" . self::CLASS_TOGGLE . "\") continue;
declare ToggleControl <=> Page.GetFirstChild(ClassParts[1]);
if (ToggleControl == Null) continue; if (ToggleControl == Null) continue;
if (Toggle) { if (Toggle) {
ToggleControl.Visible = !ToggleControl.Visible; ToggleControl.Visible = !ToggleControl.Visible;
@ -722,6 +772,33 @@ if (Event.Control.HasClass(\"" . self::CLASS_TOGGLE . "\")) {
return $toggleScript; return $toggleScript;
} }
/**
* Get the Spectate labels
*
* @return string
*/
private function getSpectateLabels() {
if (!$this->spectate) return '';
$spectateScript = "
if (Event.Control.HasClass(\"" . self::CLASS_SPECTATE . "\")) {
declare Login = \"\";
foreach (ControlClass in Event.Control.ControlClass) {
declare ClassParts = TextLib::Split(\"-\", ControlClass);
if (ClassParts.count < 2) continue;
if (ClassParts[0] != \"" . self::CLASS_SPECTATE . "\") continue;
for (Index, 1, ClassParts.count - 1) {
Login ^= ClassParts[Index];
if (Index < ClassParts.count - 1) Login ^= \"-\";
}
}
if (Login != \"\") {
SetSpectateTarget(Login);
}
}";
$spectateScript = Builder::getLabelImplementationBlock(self::LABEL_MOUSECLICK, $spectateScript);
return $spectateScript;
}
/** /**
* Get the Main Function * Get the Main Function
* *
@ -735,8 +812,8 @@ if (Event.Control.HasClass(\"" . self::CLASS_TOGGLE . "\")) {
/** /**
* Return the Array of additional optional Parameters * Return the Array of additional optional Parameters
* *
* @param array $args * @param array $args The Array of Function Parameters
* @param int $offset * @param int $offset The Number of obligatory Parameters
* @return array * @return array
*/ */
private function spliceParameters(array $params, $offset) { private function spliceParameters(array $params, $offset) {

View File

@ -3,17 +3,30 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements that support the action attribute * Interface for Elements that support the Action Attribute
* *
* @author steeffeen * @author steeffeen
*/ */
interface Actionable { interface Actionable {
/**
* Constants
*/
const ACTIONKEY_F5 = 1;
const ACTIONKEY_F6 = 2;
const ACTIONKEY_F7 = 3;
const ACTIONKEY_F8 = 4;
/** /**
* Set action * Set Action
* *
* @param string $action * @param string $action Action Name
* Action Name
*/ */
public function setAction($action); public function setAction($action);
/**
* Set Action Key
*
* @param int $actionKey Action Key Number
*/
public function setActionKey($actionKey);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements with background color attribute * Interface for Elements with Background Color Attribute
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,8 +12,7 @@ interface BgColorable {
/** /**
* Set Background Color * Set Background Color
* *
* @param string $bgColor * @param string $bgColor Background Color
* Background Color
*/ */
public function setBgColor($bgColor); public function setBgColor($bgColor);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements being able to contain other elements * Interface for Elements being able to contain other Elements
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,8 +12,7 @@ interface Container {
/** /**
* Add a new Child * Add a new Child
* *
* @param Renderable $child * @param Renderable $child The Child Element to add
* The child to add
*/ */
public function add(Renderable $child); public function add(Renderable $child);

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements with url attributes * Interface for Elements with Url Attributes
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,16 +12,14 @@ interface Linkable {
/** /**
* Set Url * Set Url
* *
* @param string $url * @param string $url Link Url
* Link Url
*/ */
public function setUrl($url); public function setUrl($url);
/** /**
* Set Manialink * Set Manialink
* *
* @param string $manialink * @param string $manialink Manialink Name
* Manialink Name
*/ */
public function setManialink($manialink); public function setManialink($manialink);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements with AutoNewLine attribute * Interface for Elements with AutoNewLine Attribute
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,8 +12,7 @@ interface NewLineable {
/** /**
* Set Auto New Line * Set Auto New Line
* *
* @param bool $autoNewLine * @param bool $autoNewLine Whether the Control should insert New Lines automatically
* If the Control should insert New Lines automatically
*/ */
public function setAutoNewLine($autoNewLine); public function setAutoNewLine($autoNewLine);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements with media attributes * Interface for Elements with Media Attributes
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,40 +12,35 @@ interface Playable {
/** /**
* Set Data * Set Data
* *
* @param string $data * @param string $data Media Url
* Media Url
*/ */
public function setData($data); public function setData($data);
/** /**
* Set Play * Set Play
* *
* @param bool $play * @param bool $play Whether the Control should start playing automatically
* If the Control should start playing automatically
*/ */
public function setPlay($play); public function setPlay($play);
/** /**
* Set Looping * Set Looping
* *
* @param bool $looping * @param bool $looping Whether the Control should play looping
* If the Control should playback looping
*/ */
public function setLooping($looping); public function setLooping($looping);
/** /**
* Set Music * Set Music
* *
* @param bool $music * @param bool $music Whether the Control represents Background Music
* If the Control is Background Music
*/ */
public function setMusic($music); public function setMusic($music);
/** /**
* Set Volume * Set Volume
* *
* @param float $volume * @param float $volume Media Volume
* Control Volume
*/ */
public function setVolume($volume); public function setVolume($volume);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for renderable elements * Interface for renderable Elements
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,7 +12,7 @@ interface Renderable {
/** /**
* Render the XML Element * Render the XML Element
* *
* @param \DOMDocument $domDocument * @param \DOMDocument $domDocument DomDocument for which the XML Element should be rendered
* @return \DOMElement * @return \DOMElement
*/ */
public function render(\DOMDocument $domDocument); public function render(\DOMDocument $domDocument);

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements with ScriptEvents attribute * Interface for Elements with ScriptEvents Attribute
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,8 +12,7 @@ interface Scriptable {
/** /**
* Set ScriptEvents * Set ScriptEvents
* *
* @param bool $scriptEvents * @param bool $scriptEvents Whether Script Events should be enabled
* If Script Events should be enabled
*/ */
public function setScriptEvents($scriptEvents); public function setScriptEvents($scriptEvents);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements with style attribute * Interface for Elements with Style Attribute
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,8 +12,7 @@ interface Styleable {
/** /**
* Set Style * Set Style
* *
* @param string $style * @param string $style Style Name
* Style
*/ */
public function setStyle($style); public function setStyle($style);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements with SubStyle attribute * Interface for Elements with SubStyle Attribute
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,18 +12,15 @@ interface SubStyleable {
/** /**
* Set SubStyle * Set SubStyle
* *
* @param string $subStyle * @param string $subStyle SubStyle Name
* Sub-Style
*/ */
public function setSubStyle($subStyle); public function setSubStyle($subStyle);
/** /**
* Set Style and SubStyle * Set Style and SubStyle
* *
* @param string $style * @param string $style Style Name
* Style * @param string $subStyle SubStyle Name
* @param string $subStyle
* Sub-Style
*/ */
public function setStyles($style, $subStyle); public function setStyles($style, $subStyle);
} }

View File

@ -3,7 +3,7 @@
namespace FML\Types; namespace FML\Types;
/** /**
* Interface for elements with Formatable text * Interface for Elements with Formatable Text
* *
* @author steeffeen * @author steeffeen
*/ */
@ -12,32 +12,28 @@ interface TextFormatable {
/** /**
* Set Text Size * Set Text Size
* *
* @param int $textSize * @param int $textSize Text Size
* Text Size
*/ */
public function setTextSize($textSize); public function setTextSize($textSize);
/** /**
* Set Text Color * Set Text Color
* *
* @param string $textColor * @param string $textColor Text Color
* Text Color
*/ */
public function setTextColor($textColor); public function setTextColor($textColor);
/** /**
* Set Area Color * Set Area Color
* *
* @param string $areaColor * @param string $areaColor Area Color
* Area Text Color
*/ */
public function setAreaColor($areaColor); public function setAreaColor($areaColor);
/** /**
* Set Area Focus Color * Set Area Focus Color
* *
* @param string $areaFocusColor * @param string $areaFocusColor Area Focus Color
* Focus Area Color
*/ */
public function setAreaFocusColor($areaFocusColor); public function setAreaFocusColor($areaFocusColor);
} }