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

View File

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

View File

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

View File

@ -5,7 +5,8 @@ namespace FML\Controls;
use FML\Types\Scriptable;
/**
* Class representing Frame3d Elements (CMlFrame)
* Frame3d Element
* (CMlFrame)
*
* @author steeffeen
*/
@ -19,8 +20,7 @@ class Frame3d extends Frame implements Scriptable {
/**
* Construct a new Frame3d Control
*
* @param string $id
* Control Id
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
@ -30,12 +30,11 @@ class Frame3d extends Frame implements Scriptable {
/**
* Set style3d
*
* @param string $style3d
* 3D Style
* @param string $style3d 3D Style
* @return \FML\Controls\Frame3d
*/
public function setStyle3d($style3d) {
$this->style3d = $style3d;
$this->style3d = (string) $style3d;
return $this;
}
@ -54,13 +53,13 @@ class Frame3d extends Frame implements Scriptable {
* @see \FML\Controls\Frame::render()
*/
public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument);
$xmlElement = parent::render($domDocument);
if ($this->style3d) {
$xml->setAttribute('style3d', $this->style3d);
$xmlElement->setAttribute('style3d', $this->style3d);
}
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;
/**
* Class representing CMlGauge
* Gauge Element
* (CMlGauge)
*
* @author steeffeen
*/
@ -14,6 +15,7 @@ class Gauge extends Control implements Styleable {
* Protected Properties
*/
protected $ratio = 1.;
// TODO: validate grading
protected $grading = 1.;
protected $color = '';
protected $rotation = 0.;
@ -26,8 +28,7 @@ class Gauge extends Control implements Styleable {
/**
* Construct a new Gauge Control
*
* @param string $id
* Control Id
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
@ -37,56 +38,51 @@ class Gauge extends Control implements Styleable {
/**
* Set Ratio
*
* @param float $ratio
* Ratio Value
* @param float $ratio Ratio Value
* @return \FML\Controls\Gauge
*/
public function setRatio($ratio) {
$this->ratio = $ratio;
$this->ratio = (float) $ratio;
return $this;
}
/**
* Set Grading
*
* @param float $grading
* Grading Value
* @param float $grading Grading Value
* @return \FML\Controls\Gauge
*/
public function setGrading($grading) {
$this->grading = $grading;
$this->grading = (float) $grading;
return $this;
}
/**
* Set Color
*
* @param string $color
* Gauge Color
* @param string $color Gauge Color
* @return \FML\Controls\Gauge
*/
public function setColor($color) {
$this->color = $color;
$this->color = (string) $color;
return $this;
}
/**
* Set Rotation
*
* @param float $rotation
* Gauge Rotation
* @param float $rotation Gauge Rotation
* @return \FML\Controls\Gauge
*/
public function setRotation($rotation) {
$this->rotation = $rotation;
$this->rotation = (float) $rotation;
return $this;
}
/**
* Set Centered
*
* @param bool $centered
* If Gauge is centered
* @param bool $centered Whether Gauge is centered
* @return \FML\Controls\Gauge
*/
public function setCentered($centered) {
@ -97,20 +93,18 @@ class Gauge extends Control implements Styleable {
/**
* Set Clan
*
* @param int $clan
* Clan number
* @param int $clan Clan number
* @return \FML\Controls\Gauge
*/
public function setClan($clan) {
$this->clan = $clan;
$this->clan = (int) $clan;
return $this;
}
/**
* Set Draw Background
*
* @param bool $drawBg
* If Gauge Background should be drawn
* @param bool $drawBg Whether Gauge Background should be drawn
* @return \FML\Controls\Gauge
*/
public function setDrawBg($drawBg) {
@ -121,8 +115,7 @@ class Gauge extends Control implements Styleable {
/**
* Set Draw Block Background
*
* @param bool $drawBlockBg
* If Gauge Block Background should be drawn
* @param bool $drawBlockBg Whether Gauge Block Background should be drawn
* @return \FML\Controls\Gauge
*/
public function setDrawBlockBg($drawBlockBg) {
@ -136,7 +129,7 @@ class Gauge extends Control implements Styleable {
* @return \FML\Controls\Gauge
*/
public function setStyle($style) {
$this->style = $style;
$this->style = (string) $style;
return $this;
}
@ -145,26 +138,27 @@ class Gauge extends Control implements Styleable {
* @see \FML\Control::render()
*/
public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument);
$xml->setAttribute('ratio', $this->ratio);
$xml->setAttribute('grading', $this->grading);
$xmlElement = parent::render($domDocument);
// TODO: validate default values
$xmlElement->setAttribute('ratio', $this->ratio);
$xmlElement->setAttribute('grading', $this->grading);
if ($this->color) {
$xml->setAttribute('color', $this->color);
$xmlElement->setAttribute('color', $this->color);
}
if ($this->rotation) {
$xml->setAttribute('rotation', $this->rotation);
$xmlElement->setAttribute('rotation', $this->rotation);
}
if ($this->centered) {
$xml->setAttribute('centered', $this->centered);
$xmlElement->setAttribute('centered', $this->centered);
}
if ($this->clan) {
$xml->setAttribute('clan', $this->clan);
$xmlElement->setAttribute('clan', $this->clan);
}
$xml->setAttribute('drawbg', $this->drawBg);
$xml->setAttribute('drawblockbg', $this->drawBlockBg);
$xmlElement->setAttribute('drawbg', $this->drawBg);
$xmlElement->setAttribute('drawblockbg', $this->drawBlockBg);
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;
/**
* Class representing CMlLabel
* Label Element
* (CMlLabel)
*
* @author steeffeen
*/
@ -22,8 +23,9 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
protected $textPrefix = '';
protected $textEmboss = 0;
protected $translate = 0;
protected $maxLines = 0;
protected $maxLines = -1;
protected $action = '';
protected $actionKey = -1;
protected $url = '';
protected $manialink = '';
protected $autoNewLine = 0;
@ -37,8 +39,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
* Construct a new Label Control
*
* @param string $id
* Control Id
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
@ -49,32 +50,29 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
* Set Text
*
* @param string $text
* Text Value
* @param string $text Text Value
* @return \FML\Controls\Label
*/
public function setText($text) {
$this->text = $text;
$this->text = (string) $text;
return $this;
}
/**
* Set Text Prefix
*
* @param string $textPrefix
* Text Prefix
* @param string $textPrefix Text Prefix
* @return \FML\Controls\Label
*/
public function setTextPrefix($textPrefix) {
$this->textPrefix = $textPrefix;
$this->textPrefix = (string) $textPrefix;
return $this;
}
/**
* Set Text Emboss
*
* @param bool $textEmboss
* If Text should be embossed
* @param bool $textEmboss Whether Text should be embossed
* @return \FML\Controls\Label
*/
public function setTextEmboss($textEmboss) {
@ -85,8 +83,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
* Set Translate
*
* @param bool $translate
* If Text should be translated
* @param bool $translate Whether Text should be translated
* @return \FML\Controls\Label
*/
public function setTranslate($translate) {
@ -97,12 +94,11 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
/**
* Set Max Lines Count
*
* @param int $maxLines
* Max Lines Count
* @param int $maxLines Max Lines Count
* @return \FML\Controls\Label
*/
public function setMaxLines($maxLines) {
$this->maxLines = $maxLines;
$this->maxLines = (int) $maxLines;
return $this;
}
@ -112,7 +108,17 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label
*/
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;
}
@ -122,7 +128,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label
*/
public function setUrl($url) {
$this->url = $url;
$this->url = (string) $url;
return $this;
}
@ -132,7 +138,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label
*/
public function setManialink($manialink) {
$this->manialink = $manialink;
$this->manialink = (string) $manialink;
return $this;
}
@ -162,7 +168,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label
*/
public function setStyle($style) {
$this->style = $style;
$this->style = (string) $style;
return $this;
}
@ -172,7 +178,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label
*/
public function setTextSize($textSize) {
$this->textSize = $textSize;
$this->textSize = (int) $textSize;
return $this;
}
@ -182,7 +188,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label
*/
public function setTextColor($textColor) {
$this->textColor = $textColor;
$this->textColor = (string) $textColor;
return $this;
}
@ -192,7 +198,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label
*/
public function setAreaColor($areaColor) {
$this->areaColor = $areaColor;
$this->areaColor = (string) $areaColor;
return $this;
}
@ -202,7 +208,7 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @return \FML\Controls\Label
*/
public function setAreaFocusColor($areaFocusColor) {
$this->areaFocusColor = $areaFocusColor;
$this->areaFocusColor = (string) $areaFocusColor;
return $this;
}
@ -211,52 +217,55 @@ class Label extends Control implements Actionable, Linkable, NewLineable, Script
* @see \FML\Control::render()
*/
public function render(\DOMDocument $domDocument) {
$xml = parent::render($domDocument);
$xmlElement = parent::render($domDocument);
if ($this->text) {
$xml->setAttribute('text', $this->text);
$xmlElement->setAttribute('text', $this->text);
}
if ($this->textPrefix) {
$xml->setAttribute('textprefix', $this->textPrefix);
$xmlElement->setAttribute('textprefix', $this->textPrefix);
}
if ($this->textEmboss) {
$xml->setAttribute('textemboss', $this->textEmboss);
$xmlElement->setAttribute('textemboss', $this->textEmboss);
}
if ($this->translate) {
$xml->setAttribute('translate', $this->translate);
$xmlElement->setAttribute('translate', $this->translate);
}
if ($this->maxLines) {
$xml->setAttribute('maxlines', $this->maxLines);
if ($this->maxLines >= 0) {
$xmlElement->setAttribute('maxlines', $this->maxLines);
}
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) {
$xml->setAttribute('url', $this->url);
$xmlElement->setAttribute('url', $this->url);
}
if ($this->manialink) {
$xml->setAttribute('manialink', $this->manialink);
$xmlElement->setAttribute('manialink', $this->manialink);
}
if ($this->autoNewLine) {
$xml->setAttribute('autonewline', $this->autoNewLine);
$xmlElement->setAttribute('autonewline', $this->autoNewLine);
}
if ($this->scriptEvents) {
$xml->setAttribute('scriptevents', $this->scriptEvents);
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
}
if ($this->style) {
$xml->setAttribute('style', $this->style);
$xmlElement->setAttribute('style', $this->style);
}
if ($this->textSize >= 0) {
$xml->setAttribute('textsize', $this->textSize);
$xmlElement->setAttribute('textsize', $this->textSize);
}
if ($this->textColor) {
$xml->setAttribute('textcolor', $this->textColor);
$xmlElement->setAttribute('textcolor', $this->textColor);
}
if ($this->areaColor) {
$xml->setAttribute('areacolor', $this->areaColor);
$xmlElement->setAttribute('areacolor', $this->areaColor);
}
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;
/**
* Label class for button styles
* Label Class for Button Styles
*
* @author steeffeen
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,13 @@
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
*/
@ -12,13 +17,97 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable {
* Protected Properties
*/
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()
*/
public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName);
return $xml;
$xmlElement = $domDocument->createElement($this->tagName);
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;
use FML\Types\Renderable;
/**
* Class representing include
* Include Element
*
* @author steeffeen
*/
@ -11,17 +13,16 @@ class Including implements Renderable {
/**
* Protected Properties
*/
protected $url = '';
protected $tagName = 'include';
protected $url = '';
/**
* Set Url
*
* @param string $url
* Include Url
* @param string $url Include Url
*/
public function setUrl($url) {
$this->url = $url;
$this->url = (string) $url;
}
/**
@ -29,10 +30,10 @@ class Including implements Renderable {
* @see \FML\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName);
$xmlElement = $domDocument->createElement($this->tagName);
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;
use FML\Types\Renderable;
/**
* Class representing music
* Music Element
*
* @author steeffeen
*/
@ -11,18 +13,17 @@ class Music implements Renderable {
/**
* Protected Properties
*/
protected $data = '';
protected $tagName = 'music';
protected $data = '';
/**
* Set Data Url
*
* @param string $data
* Media Url
* @param string $data Media Url
* @return \FML\Elements\Music
*/
public function setData($data) {
$this->data = $data;
$this->data = (string) $data;
return $this;
}
@ -31,10 +32,10 @@ class Music implements Renderable {
* @see \FML\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName);
$xmlElement = $domDocument->createElement($this->tagName);
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;
/**
* Class representing a manialink script tag with a simple script text
* Class representing a ManiaLink Script Tag with a simple Script Text
*
* @author steeffeen
*/
@ -19,7 +19,7 @@ class SimpleScript implements Renderable {
/**
* Set Script Text
*
* @param string $text
* @param string $text The Complete Script Text
* @return \FML\Script\Script
*/
public function setText($text) {
@ -32,9 +32,9 @@ class SimpleScript implements Renderable {
* @see \FML\Types\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
$xml = $domDocument->createElement($this->tagName);
$xmlElement = $domDocument->createElement($this->tagName);
$scriptComment = $domDocument->createComment($this->text);
$xml->appendChild($scriptComment);
return $xml;
$xmlElement->appendChild($scriptComment);
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;
/**
* Class representing a Manialink
* Class representing a ManiaLink
*
* @author steeffeen
*/
@ -26,14 +26,12 @@ class ManiaLink implements Container {
protected $script = null;
/**
* Construct a new Manialink
* Create a new ManiaLink
*
* @param string $id Manialink Id
*/
public function __construct($id = null) {
if ($id !== null) {
$this->setId($id);
}
$this->setId($id);
}
/**
@ -43,7 +41,7 @@ class ManiaLink implements Container {
* @return \FML\ManiaLink
*/
public function setXmlEncoding($encoding) {
$this->encoding = $encoding;
$this->encoding = (string) $encoding;
return $this;
}
@ -54,7 +52,7 @@ class ManiaLink implements Container {
* @return \FML\ManiaLink
*/
public function setId($id) {
$this->id = $id;
$this->id = (string) $id;
return $this;
}
@ -65,14 +63,14 @@ class ManiaLink implements Container {
* @return \FML\ManiaLink
*/
public function setBackground($background) {
$this->background = $background;
$this->background = (string) $background;
return $this;
}
/**
* Set Navigable3d
*
* @param bool $navigable3d If the manialink is 3d navigable
* @param bool $navigable3d Whether the manialink should be 3d navigable
* @return \FML\ManiaLink
*/
public function setNavigable3d($navigable3d) {
@ -87,7 +85,7 @@ class ManiaLink implements Container {
* @return \FML\ManiaLink
*/
public function setTimeout($timeout) {
$this->timeout = $timeout;
$this->timeout = (int) $timeout;
return $this;
}
@ -114,7 +112,7 @@ class ManiaLink implements Container {
/**
* Set the Script of the ManiaLink
*
* @param Script $script
* @param Script $script The Script for the ManiaLink
* @return \FML\ManiaLink
*/
public function setScript(Script $script) {
@ -125,7 +123,7 @@ class ManiaLink implements Container {
/**
* 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
*/
public function getScript($createIfEmpty = true) {
@ -138,48 +136,45 @@ class ManiaLink implements Container {
/**
* Render the XML Document
*
* @param bool $echo If the xml should be echoed and the content-type header should be set
* @param \DOMDocument $domDocument
* @param bool (optional) $echo If the XML Text should be echoed and the Content-Type Header should be set
* @param \DOMDocument $domDocument (optional) DOMDocument for which the XML Element should be created
* @return \DOMDocument
*/
public function render($echo = false, $domDocument = null) {
$isChild = false;
if ($domDocument) {
$isChild = true;
}
$isChild = (bool) $domDocument;
if (!$isChild) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
}
$manialink = $domDocument->createElement($this->tagName);
$maniaLink = $domDocument->createElement($this->tagName);
if (!$isChild) {
$domDocument->appendChild($manialink);
$domDocument->appendChild($maniaLink);
}
if ($this->id) {
$manialink->setAttribute('id', $this->id);
if ($this->id !== null) {
$maniaLink->setAttribute('id', $this->id);
}
if ($this->version) {
$manialink->setAttribute('version', $this->version);
if ($this->version !== null) {
$maniaLink->setAttribute('version', $this->version);
}
if ($this->background) {
$manialink->setAttribute('background', $this->background);
if ($this->background !== null) {
$maniaLink->setAttribute('background', $this->background);
}
if ($this->navigable3d) {
$manialink->setAttribute('navigable3d', $this->navigable3d);
if ($this->navigable3d !== null) {
$maniaLink->setAttribute('navigable3d', $this->navigable3d);
}
if ($this->timeout) {
if ($this->timeout !== null) {
$timeoutXml = $domDocument->createElement('timeout', $this->timeout);
$manialink->appendChild($timeoutXml);
$maniaLink->appendChild($timeoutXml);
}
foreach ($this->children as $child) {
$childXml = $child->render($domDocument);
$manialink->appendChild($childXml);
$maniaLink->appendChild($childXml);
}
if ($this->script) {
$scriptXml = $this->script->render($domDocument);
$manialink->appendChild($scriptXml);
$maniaLink->appendChild($scriptXml);
}
if ($isChild) {
return $manialink;
return $maniaLink;
}
if ($echo) {
header('Content-Type: application/xml');

View File

@ -3,7 +3,7 @@
namespace FML;
/**
* Class holding several Manialinks at once
* Class holding several ManiaLinks at once
*
* @author steeffeen
*/
@ -23,7 +23,7 @@ class ManiaLinks {
* @return \FML\ManiaLinks
*/
public function setXmlEncoding($encoding) {
$this->encoding = $encoding;
$this->encoding = (string) $encoding;
return $this;
}
@ -64,20 +64,20 @@ class ManiaLinks {
/**
* 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
*/
public function render($echo = false) {
$domDocument = new \DOMDocument('1.0', $this->encoding);
$manialinks = $domDocument->createElement($this->tagName);
$domDocument->appendChild($manialinks);
$maniaLinks = $domDocument->createElement($this->tagName);
$domDocument->appendChild($maniaLinks);
foreach ($this->children as $child) {
$childXml = $child->render(false, $domDocument);
$manialinks->appendChild($childXml);
$maniaLinks->appendChild($childXml);
}
if ($this->customUI) {
$customUIXml = $this->customUI->render($domDocument);
$manialinks->appendChild($customUIXml);
$maniaLinks->appendChild($customUIXml);
}
if ($echo) {
header('Content-Type: application/xml');

View File

@ -12,8 +12,8 @@ abstract class Builder {
/**
* Build a Label Implementation Block
*
* @param string $labelName
* @param string $implementationCode
* @param string $labelName Name of the Label
* @param string $implementationCode Label Implementation Coding (without declaration)
* @return string
*/
public static function getLabelImplementationBlock($labelName, $implementationCode) {
@ -24,7 +24,7 @@ abstract class Builder {
/**
* 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
*/
public static function getReal($value) {

View File

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

View File

@ -3,17 +3,30 @@
namespace FML\Types;
/**
* Interface for elements that support the action attribute
* Interface for Elements that support the Action Attribute
*
* @author steeffeen
*/
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
* Action Name
* @param string $action Action Name
*/
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;
/**
* Interface for elements with background color attribute
* Interface for Elements with Background Color Attribute
*
* @author steeffeen
*/
@ -12,8 +12,7 @@ interface BgColorable {
/**
* Set Background Color
*
* @param string $bgColor
* Background Color
* @param string $bgColor Background Color
*/
public function setBgColor($bgColor);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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