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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -184,7 +184,7 @@ class CustomUI {
*
* @return array
*/
private function getSettings() {
protected function getSettings() {
$settings = array();
$settings['challenge_info'] = $this->challengeInfoVisible;
$settings['chat'] = $this->chatVisible;

View File

@ -45,7 +45,6 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable {
/**
*
* @see \FML\Types\BgColorable::setBgColor()
* @return \FML\Elements\Format
*/
public function setBgColor($bgColor) {
$this->bgColor = (string) $bgColor;
@ -55,7 +54,6 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable {
/**
*
* @see \FML\Types\Styleable::setStyle()
* @return \FML\Elements\Format
*/
public function setStyle($style) {
$this->style = (string) $style;
@ -65,7 +63,6 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable {
/**
*
* @see \FML\Types\TextFormatable::setTextSize()
* @return \FML\Elements\Format
*/
public function setTextSize($textSize) {
$this->textSize = (int) $textSize;
@ -75,7 +72,6 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable {
/**
*
* @see \FML\Types\TextFormatable::setTextColor()
* @return \FML\Elements\Format
*/
public function setTextColor($textColor) {
$this->textColor = (string) $textColor;
@ -85,7 +81,6 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable {
/**
*
* @see \FML\Types\TextFormatable::setAreaColor()
* @return \FML\Elements\Format
*/
public function setAreaColor($areaColor) {
$this->focusAreaColor1 = (string) $areaColor;
@ -95,7 +90,6 @@ class Format implements BgColorable, Renderable, Styleable, TextFormatable {
/**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @return \FML\Elements\Format
*/
public function setAreaFocusColor($areaFocusColor) {
$this->focusAreaColor2 = (string) $areaFocusColor;

View File

@ -57,7 +57,6 @@ class FrameModel implements Container, Renderable {
/**
*
* @see \FML\Types\Container::add()
* @return \FML\Elements\FrameModel
*/
public function add(Control $childControl) {
if (!in_array($childControl, $this->children, true)) {
@ -69,7 +68,6 @@ class FrameModel implements Container, Renderable {
/**
*
* @see \FML\Types\Container::removeChildren()
* @return \FML\Elements\FrameModel
*/
public function removeChildren() {
$this->children = array();
@ -79,7 +77,6 @@ class FrameModel implements Container, Renderable {
/**
*
* @see \FML\Types\Container::setFormat()
* @return \FML\Elements\FrameModel
*/
public function setFormat(Format $format) {
$this->format = $format;

View File

@ -13,7 +13,6 @@ use FML\ManiaCode\InstallReplay;
use FML\ManiaCode\InstallScript;
use FML\ManiaCode\InstallSkin;
use FML\ManiaCode\JoinServer;
use FML\ManiaCode\Message;
use FML\ManiaCode\PlayMap;
use FML\ManiaCode\PlayReplay;
use FML\ManiaCode\ShowMessage;

View File

@ -34,6 +34,7 @@ class InstallMacroblock implements Element {
* Construct a new InstallMacroblock Element
*
* @param string $name (optional) Macroblock Name
* @param string $file (optional) Macroblock File
* @param string $url (optional) Macroblock Url
*/
public function __construct($name = null, $file = null, $url = null) {
@ -69,7 +70,7 @@ class InstallMacroblock implements Element {
$this->file = (string) $file;
return $this;
}
/**
* Set the Url of the Macroblock
*

View File

@ -6,6 +6,7 @@ use FML\Elements\Dico;
use FML\Script\Script;
use FML\Stylesheet\Stylesheet;
use FML\Types\Renderable;
use FML\Types\ScriptFeatureable;
/**
* Class representing a ManiaLink
@ -32,7 +33,7 @@ class ManiaLink {
protected $id = '';
protected $version = 1;
protected $background = '';
protected $navigable3d = 0;
protected $navigable3d = 1;
protected $timeout = 0;
protected $children = array();
protected $dico = null;
@ -85,7 +86,7 @@ class ManiaLink {
/**
* Get ManiaLink Id
*
*
* @return string
*/
public function getId() {
@ -128,6 +129,7 @@ class ManiaLink {
/**
* Add an Element to the ManiaLink
*
* @param Renderable $child Child Element to add
* @return \FML\ManiaLink
*/
public function add(Renderable $child) {
@ -245,30 +247,37 @@ class ManiaLink {
if (strlen($this->background) > 0) {
$maniaLink->setAttribute('background', $this->background);
}
if ($this->navigable3d) {
// TODO: check default value
if (!$this->navigable3d) {
$maniaLink->setAttribute('navigable3d', $this->navigable3d);
}
if ($this->timeout) {
$timeoutXml = $domDocument->createElement('timeout', $this->timeout);
$maniaLink->appendChild($timeoutXml);
}
foreach ($this->children as $child) {
$childXml = $child->render($domDocument);
$maniaLink->appendChild($childXml);
}
if ($this->dico) {
$dicoXml = $this->dico->render($domDocument);
$maniaLink->appendChild($dicoXml);
}
$scriptFeatures = array();
foreach ($this->children as $child) {
$childXml = $child->render($domDocument, $this->getScript());
$maniaLink->appendChild($childXml);
if ($child instanceof ScriptFeatureable) {
$scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures());
}
}
if ($scriptFeatures) {
$this->getScript()->loadFeatures($scriptFeatures);
}
if ($this->stylesheet) {
$stylesheetXml = $this->stylesheet->render($domDocument);
$maniaLink->appendChild($stylesheetXml);
}
if ($this->script) {
if ($this->script->needsRendering()) {
$scriptXml = $this->script->render($domDocument);
$maniaLink->appendChild($scriptXml);
}
$this->script->resetGenericScriptLabels();
if ($isChild) {
return $maniaLink;
}

View File

@ -16,9 +16,13 @@ abstract class Builder {
*
* @param string $labelName Name of the Label
* @param string $implementationCode Label Implementation Coding (without declaration)
* @param bool $isolate Whether the Code should be isolated in an own Block
* @return string
*/
public static function getLabelImplementationBlock($labelName, $implementationCode) {
public static function getLabelImplementationBlock($labelName, $implementationCode, $isolate = true) {
if ($isolate) {
$implementationCode = 'if(True){' . $implementationCode . '}';
}
$labelText = PHP_EOL . "***{$labelName}***" . PHP_EOL . "***{$implementationCode}***" . PHP_EOL;
return $labelText;
}
@ -27,13 +31,16 @@ abstract class Builder {
* Escape dangerous Characters in the given Text
*
* @param string $text Text to escape
* @param bool $addApostrophes (optional) Whether to add Apostrophes before and after the Text
* @return string
*/
public static function escapeText($text) {
$escapedText = $text;
public static function escapeText($text, $addApostrophes = false) {
$dangers = array('\\', '"', "\n");
$replacements = array('\\\\', '\\"', '\n');
$escapedText = str_ireplace($dangers, $replacements, $escapedText);
$replacements = array('\\\\', '\\"', '\\n');
$escapedText = str_ireplace($dangers, $replacements, $text);
if ($addApostrophes) {
$escapedText = '"' . $escapedText . '"';
}
return $escapedText;
}
@ -46,13 +53,15 @@ abstract class Builder {
public static function getReal($value) {
$value = (float) $value;
$stringVal = (string) $value;
if (!fmod($value, 1)) $stringVal .= '.';
if (!fmod($value, 1)) {
$stringVal .= '.';
}
return $stringVal;
}
/**
* Get the Boolean String-Representation of the given Value
*
*
* @param bool $value The Value to convert to a ManiaScript Boolean
* @return string
*/
@ -63,4 +72,67 @@ abstract class Builder {
}
return "False";
}
/**
* Get the String-Representation of the given Array
*
* @param array $array Array to convert to a ManiaScript Array
* @param bool $associative (optional) Whether the Array should be associative
* @return string
*/
public static function getArray(array $array, $associative = false) {
$arrayText = '[';
$index = 0;
$count = count($array);
foreach ($array as $key => $value) {
if ($associative) {
if (is_string($key)) {
$arrayText .= '"' . self::escapeText($key) . '"';
}
else {
$arrayText .= $key;
}
$arrayText .= ' => ';
}
if (is_string($value)) {
$arrayText .= '"' . self::escapeText($value) . '"';
}
else {
$arrayText .= $value;
}
if ($index < $count - 1) {
$arrayText .= ', ';
$index++;
}
}
$arrayText .= ']';
return $arrayText;
}
/**
* Get the Include Command for the given File and Namespace
*
* @param string $file Include File
* @param string $namespace Include Namespace
* @return string
*/
public static function getInclude($file, $namespace) {
$includeText = "#Include \"{$file}\" as {$namespace}" . PHP_EOL;
return $includeText;
}
/**
* Get the Constant Command for the given Name and Value
*
* @param string $name Constant Name
* @param string $value Constant Value
* @return string
*/
public static function getConstant($name, $value) {
if (is_string($value)) {
$value = '"' . $value . '"';
}
$constantText = "#Const {$name} {$value}" . PHP_EOL;
return $constantText;
}
}

View File

@ -1,45 +0,0 @@
<?php
namespace FML\Script;
/**
* Class for EUISound Variants
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class EUISound {
/*
* Constants
*/
const SOUND_Bonus = 'Bonus';
const SOUND_Capture = 'Capture';
const SOUND_Checkpoint = 'Checkpoint';
const SOUND_Combo = 'Combo';
const SOUND_Custom1 = 'Custom1';
const SOUND_Custom2 = 'Custom2';
const SOUND_Custom3 = 'Custom3';
const SOUND_Custom4 = 'Custom4';
const SOUND_Default = 'Default';
const SOUND_EndMatch = 'EndMatch';
const SOUND_EndRound = 'EndRound';
const SOUND_Finish = 'Finish';
const SOUND_FirstHit = 'FirstHit';
const SOUND_Notice = 'Notice';
const SOUND_PhaseChange = 'PhaseChange';
const SOUND_PlayerEliminated = 'PlayerEliminated';
const SOUND_PlayerHit = 'PlayerHit';
const SOUND_PlayersRemaining = 'PlayersRemaining';
const SOUND_RankChange = 'RankChange';
const SOUND_Record = 'Record';
const SOUND_ScoreProgress = 'ScoreProgress';
const SOUND_Silence = 'Silence';
const SOUND_StartMatch = 'StartMatch';
const SOUND_StartRound = 'StartRound';
const SOUND_TieBreakPoint = 'TieBreakPoint';
const SOUND_TiePoint = 'TiePoint';
const SOUND_TimeOut = 'TimeOut';
const SOUND_VictoryPoint = 'VictoryPoint';
const SOUND_Warning = 'Warning';
}

View File

@ -0,0 +1,105 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature for triggering a Page Action
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ActionTrigger extends ScriptFeature {
/*
* Protected Properties
*/
protected $actionName = null;
protected $control = null;
protected $labelName = null;
/**
* Construct a new Action Trigger Feature
*
* @param string $actionName (optional) Triggered Action
* @param Control $control (optional) Action Control
* @param string $labelName (optional) Script Label Name
*/
public function __construct($actionName = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
$this->setActionName($actionName);
$this->setControl($control);
$this->setLabelName($labelName);
}
/**
* Set the Action to trigger
*
* @param string $actionName
* @return \FML\Script\Features\ActionTrigger
*/
public function setActionName($actionName) {
$this->actionName = $actionName;
return $this;
}
/**
* Set the Control
*
* @param Control $control Action Control
* @return \FML\Script\Features\ActionTrigger
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\ActionTrigger
*/
public function setLabelName($labelName) {
$this->labelName = $labelName;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
$actionName = Builder::escapeText($this->actionName);
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
TriggerPageAction(\"{$actionName}\");
}";
}
else {
// Other
$scriptText = "
TriggerPageAction(\"{$actionName}\");";
}
return $scriptText;
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace FML\Script\Features;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Controls\Label;
use FML\Script\ScriptInclude;
/**
* Script Feature showing the current Time on a Label
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Clock extends ScriptFeature {
/*
* Protected Properties
*/
protected $label = null;
protected $showSeconds = null;
protected $showFullDate = null;
/**
* Construct a new Clock Feature
*
* @param Label $label (optional) Clock Label
* @param bool $showSeconds (optional) Whether the Seconds should be shown
* @param bool $showFullDate (optional) Whether the Date should be shown
*/
public function __construct(Label $label = null, $showSeconds = true, $showFullDate = false) {
$this->setLabel($label);
$this->setShowSeconds($showSeconds);
$this->setShowFullDate($showFullDate);
}
/**
* Set the Label
*
* @param Label $label Clock Label
* @return \FML\Script\Features\Clock
*/
public function setLabel(Label $label) {
$label->checkId();
$this->label = $label;
return $this;
}
/**
* Set whether the Seconds should be shown
*
* @param bool $showSeconds Whether the Seconds should be shown
* @return \FML\Script\Features\Clock
*/
public function setShowSeconds($showSeconds) {
$this->showSeconds = (bool) $showSeconds;
return $this;
}
/**
* Set whether the Full Date should be shown
*
* @param bool $showFullDate Whether the Full Date should be shown
* @return \FML\Script\Features\Clock
*/
public function setShowFullDate($showFullDate) {
$this->showFullDate = (bool) $showFullDate;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$script->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true);
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
$controlId = $this->label->getId(true);
$scriptText = "
declare ClockLabel <=> (Page.GetFirstChild(\"{$controlId}\") as CMlLabel);
declare TimeText = CurrentLocalDateText;";
if (!$this->showSeconds) {
$scriptText .= "
TimeText = TextLib::SubText(TimeText, 0, 16);";
}
if (!$this->showFullDate) {
$scriptText .= "
TimeText = TextLib::SubText(TimeText, 11, 9);";
}
$scriptText .= "
ClockLabel.Value = TimeText;";
return $scriptText;
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace FML\Script\Features;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
use FML\Controls\Entry;
use FML\Script\ScriptInclude;
/**
* Script Feature for submitting an Entry
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class EntrySubmit extends ScriptFeature {
/*
* Protected Properties
*/
protected $entry = null;
protected $url = null;
/**
* Construct a new Entry Submit Feature
*
* @param Entry $entry (optional) Entry Control
* @param string $url (optional) Submit Url
*/
public function __construct(Entry $entry = null, $url = null) {
$this->setEntry($entry);
$this->setUrl($url);
}
/**
* Set the Entry
*
* @param Entry $entry Entry Control
* @return \FML\Script\Features\EntrySubmit
*/
public function setEntry(Entry $entry) {
$entry->checkId();
$entry->setScriptEvents(true);
$this->entry = $entry;
return $this;
}
/**
* Set the Submit Url
*
* @param string $url Submit Url
* @return \FML\Script\Features\EntrySubmit
*/
public function setUrl($url) {
$this->url = (string) $url;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$script->appendGenericScriptLabel(ScriptLabel::ENTRYSUBMIT, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
$controlId = $this->entry->getId(true);
$url = $this->buildCompatibleUrl();
$entryName = Builder::escapeText($this->entry->getName());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
declare Entry <=> (Event.Control as CMlEntry);
declare Value = TextLib::URLEncode(Entry.Value);
OpenLink(\"{$url}{$entryName}=\"^Value, CMlScript::LinkType::Goto);
}";
return $scriptText;
}
/**
* Build the Submit Url compatible for the Entry Parameter
*
* @return string
*/
protected function buildCompatibleUrl() {
$url = $this->url;
$paramsBegin = stripos($url, '?');
if (!is_int($paramsBegin) || $paramsBegin < 0) {
$url .= '?';
}
else {
$url .= '&';
}
return $url;
}
}

View File

@ -0,0 +1,90 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature for opening the Map Info
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MapInfo extends ScriptFeature {
/*
* Protected Properties
*/
protected $control = null;
protected $labelName = null;
/**
* Construct a new Map Info Feature
*
* @param Control $control (optional) Map Info Control
* @param string $labelName (optional) Script Label Name
*/
public function __construct(Control $control, $labelName = ScriptLabel::MOUSECLICK) {
$this->setControl($control);
$this->setLabelName($labelName);
}
/**
* Set the Control
*
* @param Control $control Action Control
* @return \FML\Script\Features\ActionTrigger
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\ActionTrigger
*/
public function setLabelName($labelName) {
$this->labelName = $labelName;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
ShowCurChallengeCard();
}";
}
else {
// Other
$scriptText = "
ShowCurChallengeCard();";
}
return $scriptText;
}
}

View File

@ -0,0 +1,138 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature realising a Menu showing specific Controls for the different Item Controls
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Menu extends ScriptFeature {
/*
* Constants
*/
const FUNCTION_UPDATE_MENU = 'FML_UpdateMenu';
/*
* Protected Properties
*/
protected $elements = array();
protected $startElement = null;
/**
* Construct a new Menu Feature
*
* @param Control $item (optional) Item Control in the Menu Bar
* @param Control $control (optional) Toggled Menu Control
*/
public function __construct(Control $item = null, Control $control = null) {
if ($item && $control) {
$this->addNewElement($item, $control);
}
}
/**
* Add a new Element to the Menu
*
* @param Control $item Item Control in the Menu Bar
* @param Control $control Toggled Menu Control
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
* @return \FML\Script\Features\Menu
*/
public function addElement(Control $item, Control $control, $isStartElement = false) {
$menuElement = new MenuElement($item, $control);
$this->appendElement($menuElement, $isStartElement);
return $this;
}
/**
* Append an Element to the Menu
*
* @param MenuElement $menuElement Menu Element
* @param bool $isStartElement (optional) Whether the Menu should start with this Element
* @return \FML\Script\Features\Menu
*/
public function appendElement(MenuElement $menuElement, $isStartElement = false) {
array_push($this->elements, $menuElement);
if ($isStartElement) {
$this->setStartElement($menuElement);
}
else if (count($this->elements) > 1) {
$menuElement->getControl()->setVisible(false);
}
return $this;
}
/**
* Set the Element to start with
*
* @param MenuElement $startElement Starting Element
* @return \FML\Script\Features\Menu
*/
public function setStartElement(MenuElement $startElement) {
$this->startElement = $startElement;
if (!in_array($startElement, $this->elements, true)) {
array_push($this->elements, $startElement);
}
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$updateFunctionName = self::FUNCTION_UPDATE_MENU;
$elementsArrayText = $this->getElementsArrayText();
// OnInit
if ($this->startElement) {
$startControlId = $this->startElement->getControl()->getId(true);
$initScriptText = "
{$updateFunctionName}({$elementsArrayText}, \"{$startControlId}\");";
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
}
// MouseClick
$scriptText = "
declare MenuElements = {$elementsArrayText};
if (MenuElements.existskey(Event.Control.ControlId)) {
declare ShownControlId = MenuElements[Event.Control.ControlId];
{$updateFunctionName}(MenuElements, ShownControlId);
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true);
// Update menu function
$updateFunctionText = "
Void {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {
foreach (ItemId => ControlId in _Elements) {
declare Control <=> (Page.GetFirstChild(ControlId));
Control.Visible = (ControlId == _ShownControlId);
}
}";
$script->addScriptFunction($updateFunctionName, $updateFunctionText);
return $this;
}
/**
* Build the Array Text for the Elements
*
* @return string
*/
protected function getElementsArrayText() {
$elements = array();
foreach ($this->elements as $element) {
$elements[$element->getItem()->getId()] = $element->getControl()->getId();
}
return Builder::getArray($elements, true);
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
/**
* An Element for the Menu Feature
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class MenuElement {
/*
* Protected Properties
*/
protected $item = null;
protected $control = null;
/**
* Create a new Menu Element
*
* @param Control $item (optional) Item Control in the Menu Bar
* @param Control $control (optional) Toggled Menu Control
*/
public function __construct(Control $item = null, Control $control = null) {
$this->setItem($item);
$this->setControl($control);
}
/**
* Set the Item Control
*
* @param Control $item Item Control in the Menu Bar
* @return \FML\Script\Features\MenuElement
*/
public function setItem(Control $item) {
$item->checkId();
$item->setScriptEvents(true);
$this->item = $item;
return $this;
}
/**
* Get the Item Control
*
* @return \FML\Controls\Control
*/
public function getItem() {
return $this->item;
}
/**
* Set the Menu Control
*
* @param Control $control Toggled Menu Control
* @return \FML\Script\Features\MenuElement
*/
public function setControl(Control $control) {
$control->checkId();
$this->control = $control;
return $this;
}
/**
* Get the Menu Control
*
* @return \FML\Controls\Control
*/
public function getControl() {
return $this->control;
}
}

View File

@ -0,0 +1,326 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
use FML\Controls\Label;
use FML\Script\ScriptInclude;
/**
* Script Feature realising a Mechanism for browsing through Pages
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Paging extends ScriptFeature {
/*
* Constants
*/
const VAR_CURRENT_PAGE = 'FML_Paging_CurrentPage';
const FUNCTION_UPDATE_CURRENT_PAGE = 'FML_UpdateCurrentPage';
/*
* Protected Properties
*/
protected $pages = array();
protected $buttons = array();
protected $label = null;
protected $customMinPageNumber = null;
protected $customMaxPageNumber = null;
protected $previousChunkAction = null;
protected $nextChunkAction = null;
protected $chunkActionAppendsPageNumber = null;
/**
* Construct a new Paging Script Feature
*
* @param Label $label (optional) Page Number Label
*/
public function __construct(Label $label = null) {
if ($label) {
$this->setLabel($label);
}
}
/**
* Add a new Page Control
*
* @param Control $pageControl Page Control
* @param string $pageNumber (optional) Page Number
* @return \FML\Script\Features\Paging
*/
public function addPage(Control $pageControl, $pageNumber = null) {
if ($pageNumber === null) {
$pageNumber = count($this->pages) + 1;
}
$page = new PagingPage($pageControl, $pageNumber);
$this->appendPage($page);
return $this;
}
/**
* Append a Page
*
* @param PagingPage $page Paging Page
* @return \FML\Script\Features\Paging
*/
public function appendPage(PagingPage $page) {
array_push($this->pages, $page);
return $this;
}
/**
* Add a new Button to browse through the Pages
*
* @param Control $buttonControl Button used for Browsing
* @param int $browseAction (optional) Number of browsed Pages per Click
* @return \FML\Script\Features\Paging
*/
public function addButton(Control $buttonControl, $browseAction = null) {
if ($browseAction === null) {
$buttonCount = count($this->buttons);
if ($buttonCount % 2 === 0) {
$browseAction = $buttonCount / 2 + 1;
}
else {
$browseAction = $buttonCount / -2 - 1;
}
}
$button = new PagingButton($buttonControl, $browseAction);
$this->appendButton($button);
return $this;
}
/**
* Append a Button to browse through Pages
*
* @param PagingButton $button Paging Button
* @return \FML\Script\Features\Paging
*/
public function appendButton(PagingButton $button) {
array_push($this->buttons, $button);
return $this;
}
/**
* Set the Label showing the Page Number
*
* @param Label $label Page Number Label
* @return \FML\Script\Features\Paging
*/
public function setLabel(Label $label) {
$label->checkId();
$this->label = $label;
return $this;
}
/**
* Set a custom Minimum Page Number for using Chunks
*
* @param int $minPageNumber Custom Minimum Page Number
* @return \FML\Script\Features\Paging
*/
public function setCustomMinPageNumber($minPageNumber) {
$this->customMinPageNumber = (int) $minPageNumber;
return $this;
}
/**
* Set a custom Maximum Page Number for using Chunks
*
* @param int $maxPageNumber Custom Maximum Page Number
* @return \FML\Script\Features\Paging
*/
public function setCustomMaxPageNumber($maxPageNumber) {
$this->customMaxPageNumber = (int) $maxPageNumber;
return $this;
}
/**
* Set the Action triggered when the previous Chunk is needed
*
* @param string $previousChunkAction Triggered Action
* @return \FML\Script\Features\Paging
*/
public function setPreviousChunkAction($previousChunkAction) {
$this->previousChunkAction = (string) $previousChunkAction;
return $this;
}
/**
* Set the Action triggered when the next Chunk is needed
*
* @param string $nextChunkAction Triggered Action
* @return \FML\Script\Features\Paging
*/
public function setNextChunkAction($nextChunkAction) {
$this->nextChunkAction = (string) $nextChunkAction;
return $this;
}
/**
* Set if the Chunk Action should get the needed Page Number appended
*
* @param bool $appendPageNumber Whether to append the needed Page Number
* @return \FML\Script\Features\Paging
*
*/
public function setChunkActionAppendsPageNumber($appendPageNumber) {
$this->chunkActionAppendsPageNumber = (bool) $appendPageNumber;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->setScriptInclude(ScriptInclude::TEXTLIB);
$currentPageVariable = self::VAR_CURRENT_PAGE;
$updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE;
$minPage = $this->getMinPage();
$startPageNumber = $minPage->getPageNumber();
$minPageNumber = $startPageNumber;
if (is_int($this->customMinPageNumber)) {
$minPageNumber = $this->customMinPageNumber;
}
$maxPage = $this->getMaxPage();
$maxPageNumber = $maxPage->getPageNumber();
if (is_int($this->customMaxPageNumber)) {
$maxPageNumber = $this->customMaxPageNumber;
}
$pagingId = $minPage->getControl()->getId(true);
$pageLabelId = $this->label->getId(true);
$pagesArrayText = $this->getPagesArrayText();
$pageButtonsArrayText = $this->getPageButtonsArrayText();
$previousChunkAction = Builder::escapeText($this->previousChunkAction);
$nextChunkAction = Builder::escapeText($this->nextChunkAction);
$chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
// Init
$initScriptText = "
declare {$currentPageVariable} for This = Integer[Text];
{$currentPageVariable}[\"{$pagingId}\"] = {$startPageNumber};
{$updatePageFunction}(\"{$pagingId}\", \"{$pageLabelId}\", 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, \"{$previousChunkAction}\", \"{$nextChunkAction}\", {$chunkActionAppendsPageNumber});";
$script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
// MouseClick
$clickScriptText = "
declare PageButtons = {$pageButtonsArrayText};
if (PageButtons.existskey(Event.Control.ControlId)) {
declare BrowseAction = PageButtons[Event.Control.ControlId];
{$updatePageFunction}(\"{$pagingId}\", \"{$pageLabelId}\", BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, \"{$previousChunkAction}\", \"{$nextChunkAction}\", {$chunkActionAppendsPageNumber});
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true);
// Update function
$functionText = "
Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAction, Integer _MinPageNumber, Integer _MaxPageNumber, Text[Integer] _Pages, Text _PreviousChunkAction, Text _NextChunkAction, Boolean _ChunkActionAppendPageNumber) {
declare {$currentPageVariable} for This = Integer[Text];
if (!{$currentPageVariable}.existskey(_PagingId)) return;
declare CurrentPage = {$currentPageVariable}[_PagingId] + _BrowseAction;
if (CurrentPage < _MinPageNumber) {
CurrentPage = _MinPageNumber;
} else if (CurrentPage > _MaxPageNumber) {
CurrentPage = _MaxPageNumber;
}
{$currentPageVariable}[_PagingId] = CurrentPage;
declare PageFound = False;
foreach (PageNumber => PageId in _Pages) {
declare PageControl <=> Page.GetFirstChild(PageId);
PageControl.Visible = (CurrentPage == PageNumber);
if (PageControl.Visible) {
PageFound = True;
}
}
if (!PageFound && _BrowseAction != 0) {
declare Text ChunkAction;
if (_BrowseAction < 0) {
ChunkAction = _PreviousChunkAction;
} else {
ChunkAction = _NextChunkAction;
}
if (_ChunkActionAppendPageNumber) {
ChunkAction ^= CurrentPage;
}
TriggerPageAction(ChunkAction);
}
declare PageLabel <=> (Page.GetFirstChild(_PageLabelId) as CMlLabel);
if (PageLabel == Null) return;
PageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber;
}";
$script->addScriptFunction($updatePageFunction, $functionText);
return $this;
}
/**
* Get the minimum Page
*
* @return \FML\Script\Features\PagingPage
*/
protected function getMinPage() {
$minPageNumber = null;
$minPage = null;
foreach ($this->pages as $page) {
$pageNumber = $page->getPageNumber();
if ($minPageNumber === null || $pageNumber < $minPageNumber) {
$minPageNumber = $pageNumber;
$minPage = $page;
}
}
return $minPage;
}
/**
* Get the maximum Page
*
* @return \FML\Script\Features\PagingPage
*/
protected function getMaxPage() {
$maxPageNumber = null;
$maxPage = null;
foreach ($this->pages as $page) {
$pageNumber = $page->getPageNumber();
if ($maxPageNumber === null || $pageNumber > $maxPageNumber) {
$maxPageNumber = $pageNumber;
$maxPage = $page;
}
}
return $maxPage;
}
/**
* Build the Array Text for the Pages
*
* @return string
*/
protected function getPagesArrayText() {
$pages = array();
foreach ($this->pages as $page) {
$pages[$page->getPageNumber()] = $page->getControl()->getId();
}
return Builder::getArray($pages, true);
}
/**
* Build the Array Text for the Page Buttons
*
* @return string
*/
protected function getPageButtonsArrayText() {
$pageButtons = array();
foreach ($this->buttons as $pageButton) {
$pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction();
}
return Builder::getArray($pageButtons, true);
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
/**
* A Button for browsing through Pages
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PagingButton {
/*
* Protected Properties
*/
protected $control = null;
protected $browseAction = null;
/**
* Construct a new Paging Button
*
* @param Control $control (optional) Browse Control
* @param int $browseAction (optional) Number of browsed Pages per Click
*/
public function __construct(Control $control = null, $browseAction = null) {
$this->setControl($control);
$this->setBrowseAction($browseAction);
}
/**
* Set the Button Control
*
* @param Control $control Browse Control
* @return \FML\Script\Features\PagingButton
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Get the Button Control
*
* @return \FML\Controls\Control
*/
public function getControl() {
return $this->control;
}
/**
* Set the Browse Action
*
* @param int $browseAction Number of browsed Pages per Click
* @return \FML\Script\Features\PagingButton
*/
public function setBrowseAction($browseAction) {
$this->browseAction = (int) $browseAction;
return $this;
}
/**
* Get the Browse Action
*
* @return int
*/
public function getBrowseAction() {
return $this->browseAction;
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
/**
* A Page Control
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PagingPage {
/*
* Protected Properties
*/
protected $control = null;
protected $number = null;
/**
* Construct a new Paging Page
*
* @param Control $control (optional) Page Control
* @param int $pageNumber (optional) Number of the Page
*/
public function __construct(Control $control = null, $pageNumber = 1) {
$this->setControl($control);
$this->setPageNumber($pageNumber);
}
/**
* Set the Page Control
*
* @param Control $control Page Control
* @return \FML\Script\Features\PagingPage
*/
public function setControl(Control $control) {
$control->checkId();
$this->control = $control;
return $this;
}
/**
* Get the Page Control
*
* @return \FML\Controls\Control
*/
public function getControl() {
return $this->control;
}
/**
* Set the Page Number
*
* @param int $pageNumber Number of the Page
* @return \FML\Script\Features\PagingPage
*/
public function setPageNumber($pageNumber) {
$this->number = (int) $pageNumber;
return $this;
}
/**
* Get the Page Number
*
* @return int
*/
public function getPageNumber() {
return $this->number;
}
}

View File

@ -0,0 +1,104 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature for opening a Player Profile
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class PlayerProfile extends ScriptFeature {
/*
* Protected Properties
*/
protected $login = null;
protected $control = null;
protected $labelName = null;
/**
* Construct a new Player Profile Feature
*
* @param string $login (optional) Player Login
* @param Control $control (optional) Action Control
* @param string $labelName (optional) Script Label Name
*/
public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) {
$this->setLogin($login);
$this->setControl($control);
$this->setLabelName($labelName);
}
/**
* Set the Login of the Player
*
* @param string $login Player Login
* @return \FML\Script\Features\PlayerProfile
*/
public function setLogin($login) {
$this->login = $login;
return $this;
}
/**
* Set the Control
*
* @param Control $control Profile Control
* @return \FML\Script\Features\PlayerProfile
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\PlayerProfile
*/
public function setLabelName($labelName) {
$this->labelName = $labelName;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
$login = Builder::escapeText($this->login);
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
ShowProfile(\"{$login}\");
}";
}
else {
// Other
$scriptText = "
ShowProfile(\"{$login}\");";
}
return $scriptText;
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace FML\Script\Features;
use FML\Script\Script;
/**
* ManiaLink Script Feature Class
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
abstract class ScriptFeature {
/**
* Prepare the given Script for Rendering by adding the needed Labels, etc.
*
* @param Script $script Script to prepare
* @return \FML\Script\Features\ScriptFeature
*/
public abstract function prepare(Script $script);
}

View File

@ -0,0 +1,133 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
/**
* Script Feature for toggling Controls
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Toggle extends ScriptFeature {
/*
* Protected Properties
*/
protected $togglingControl = null;
protected $toggledControl = null;
protected $labelName = null;
protected $onlyShow = null;
protected $onlyHide = null;
/**
* Construct a new Toggle Feature
*
* @param Control $togglingControl (optional) Toggling Control
* @param Control $toggledControl (optional) Toggled Control
* @param string $labelName (optional) Script Label Name
* @param bool $onlyShow (optional) Whether it should only Show the Control but not toggle
* @param bool $onlyHide (optional) Whether it should only Hide the Control but not toggle
*/
public function __construct(Control $togglingControl = null, Control $toggledControl = null, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false) {
$this->setTogglingControl($togglingControl);
$this->setToggledControl($toggledControl);
$this->setLabelName($labelName);
$this->setOnlyShow($onlyShow);
$this->setOnlyHide($onlyHide);
}
/**
* Set the Toggling Control
*
* @param Control $control Toggling Control
* @return \FML\Script\Features\Toggle
*/
public function setTogglingControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->togglingControl = $control;
return $this;
}
/**
* Set the Toggled Control
*
* @param Control $control Toggling Control
* @return \FML\Script\Features\Toggle
*/
public function setToggledControl(Control $control) {
$control->checkId();
$this->toggledControl = $control;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\Toggle
*/
public function setLabelName($labelName) {
$this->labelName = (string) $labelName;
return $this;
}
/**
* Set only Show
*
* @param bool $onlyShow Whether it should only Show the Control but not toggle
* @return \FML\Script\Features\Toggle
*/
public function setOnlyShow($onlyShow) {
$this->onlyShow = (bool) $onlyShow;
return $this;
}
/**
* Set only Hide
*
* @param bool $onlyHide Whether it should only Hide the Control but not toggle
* @return \FML\Script\Features\Toggle
*/
public function setOnlyHide($onlyHide) {
$this->onlyHide = (bool) $onlyHide;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
$togglingControlId = $this->togglingControl->getId(true);
$toggledControlId = $this->toggledControl->getId(true);
$visibility = '!ToggleControl.Visible';
if ($this->onlyShow) {
$visibility = 'True';
}
else if ($this->onlyHide) {
$visibility = 'False';
}
$scriptText = "
if (Event.Control.ControlId == \"{$togglingControlId}\") {
declare ToggleControl = Page.GetFirstChild(\"{$toggledControlId}\");
ToggleControl.Visible = {$visibility};
}";
return $scriptText;
}
}

View File

@ -0,0 +1,156 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
use FML\Controls\Label;
/**
* Script Feature for Showing Tooltips
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Tooltip extends ScriptFeature {
/*
* Protected Properties
*/
protected $hoverControl = null;
protected $tooltipControl = null;
protected $stayOnClick = null;
protected $invert = null;
protected $text = null;
/**
* Construct a new Tooltip Feature
*
* @param Control $hoverControl (optional) Hover Control
* @param Control $tooltipControl (optional) Tooltip Control
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @param string $text (optional) The Text to display if the TooltipControl is a Label
*/
public function __construct(Control $hoverControl = null, Control $tooltipControl = null, $stayOnClick = false, $invert = false, $text = null) {
$this->setHoverControl($hoverControl);
$this->setTooltipControl($tooltipControl);
$this->setStayOnClick($stayOnClick);
$this->setInvert($invert);
$this->setText($text);
}
/**
* Set the Hover Control
*
* @param Control $hoverControl Hover Control
* @return \FML\Script\Features\Tooltip
*/
public function setHoverControl(Control $hoverControl) {
$hoverControl->checkId();
$hoverControl->setScriptEvents(true);
$this->hoverControl = $hoverControl;
return $this;
}
/**
* Set the Tooltip Control
*
* @param Control $tooltipControl Tooltip Control
* @return \FML\Script\Features\Tooltip
*/
public function setTooltipControl(Control $tooltipControl) {
$tooltipControl->checkId();
$tooltipControl->setVisible(false);
$this->tooltipControl = $tooltipControl;
return $this;
}
/**
* Set only Show
*
* @param bool $stayOnClick (optional) Whether the Tooltip should stay on Click
* @return \FML\Script\Features\Tooltip
*/
public function setStayOnClick($stayOnClick) {
$this->stayOnClick = (bool) $stayOnClick;
return $this;
}
/**
* Set only Hide
*
* @param bool $invert (optional) Whether the Visibility Toggling should be inverted
* @return \FML\Script\Features\Tooltip
*/
public function setInvert($invert) {
$this->invert = (bool) $invert;
return $this;
}
/**
* Set Text
*
* @param string $text (optional) The Text to display if the TooltipControl is a Label
* @return \FML\Script\Features\Tooltip
*/
public function setText($text) {
$this->text = $text;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$hoverControlId = $this->hoverControl->getId(true);
$tooltipControlId = $this->tooltipControl->getId(true);
// MouseOver
$visibility = ($this->invert ? 'False' : 'True');
$scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") {
declare TooltipControl = Page.GetFirstChild(\"{$tooltipControlId}\");
TooltipControl.Visible = {$visibility};";
if (is_string($this->text) && ($this->tooltipControl instanceof Label)) {
$tooltipText = Builder::escapeText($this->text);
$scriptText .= "
declare TooltipLabel = (TooltipControl as CMlLabel);
TooltipLabel.Value = \"{$tooltipText}\";";
}
$scriptText .= "
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText);
// MouseOut
$visibility = ($this->invert ? 'True' : 'False');
$scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") {
declare TooltipControl = Page.GetFirstChild(\"{$tooltipControlId}\");";
if ($this->stayOnClick) {
$scriptText .= "
declare FML_Clicked for Event.Control = False;
if (!FML_Clicked) ";
}
$scriptText .= "
TooltipControl.Visible = {$visibility};
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText);
// MouseClick
if ($this->stayOnClick) {
$scriptText = "
if (Event.Control.ControlId == \"{$hoverControlId}\") {
declare FML_Clicked for Event.Control = False;
FML_Clicked = !FML_Clicked;
}";
$script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText);
}
return $this;
}
}

View File

@ -0,0 +1,162 @@
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
use FML\Script\Script;
use FML\Script\ScriptLabel;
use FML\Script\Builder;
/**
* Script Feature for playing an UI Sound
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class UISound extends ScriptFeature {
/*
* Constants
*/
const Bonus = 'Bonus';
const Capture = 'Capture';
const Checkpoint = 'Checkpoint';
const Combo = 'Combo';
const Custom1 = 'Custom1';
const Custom2 = 'Custom2';
const Custom3 = 'Custom3';
const Custom4 = 'Custom4';
const Default_ = 'Default';
const EndMatch = 'EndMatch';
const EndRound = 'EndRound';
const Finish = 'Finish';
const FirstHit = 'FirstHit';
const Notice = 'Notice';
const PhaseChange = 'PhaseChange';
const PlayerEliminated = 'PlayerEliminated';
const PlayerHit = 'PlayerHit';
const PlayersRemaining = 'PlayersRemaining';
const RankChange = 'RankChange';
const Record = 'Record';
const ScoreProgress = 'ScoreProgress';
const Silence = 'Silence';
const StartMatch = 'StartMatch';
const StartRound = 'StartRound';
const TieBreakPoint = 'TieBreakPoint';
const TiePoint = 'TiePoint';
const TimeOut = 'TimeOut';
const VictoryPoint = 'VictoryPoint';
const Warning = 'Warning';
/*
* Protected Properties
*/
protected $soundName = null;
protected $control = null;
protected $variant = 0;
protected $volume = 1.;
protected $labelName = null;
/**
* Construct a new UISound Feature
*
* @param string $soundName (optional) Played Sound
* @param Control $control (optional) Action Control
* @param int $variant (optional) Sound Variant
* @param string $labelName (optional) Script Label Name
*/
public function __construct($soundName = null, Control $control = null, $variant = 0, $labelName = ScriptLabel::MOUSECLICK) {
$this->setSoundName($soundName);
$this->setControl($control);
$this->setVariant($variant);
$this->setLabelName($labelName);
}
/**
* Set the Sound to play
*
* @param string $soundName Sound Name
* @return \FML\Script\Features\UISound
*/
public function setSoundName($soundName) {
$this->soundName = (string) $soundName;
return $this;
}
/**
* Set the Control
*
* @param Control $control Action Control
* @return \FML\Script\Features\UISound
*/
public function setControl(Control $control) {
$control->checkId();
$control->setScriptEvents(true);
$this->control = $control;
return $this;
}
/**
* Set the Sound Variant
*
* @param int $variant Sound Variant
* @return \FML\Script\Features\UISound
*/
public function setVariant($variant) {
$this->variant = (int) $variant;
return $this;
}
/**
* Set the Volume
*
* @param float $volume Sound Volume
* @return \FML\Script\Features\UISound
*/
public function setVolume($volume) {
$this->volume = (float) $volume;
return $this;
}
/**
* Set the Label Name
*
* @param string $labelName Script Label Name
* @return \FML\Script\Features\UISound
*/
public function setLabelName($labelName) {
$this->labelName = (string) $labelName;
return $this;
}
/**
*
* @see \FML\Script\Features\ScriptFeature::prepare()
*/
public function prepare(Script $script) {
$script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
return $this;
}
/**
* Get the Script Text
*
* @return string
*/
protected function getScriptText() {
if ($this->control) {
// Control event
$controlId = Builder::escapeText($this->control->getId());
$scriptText = "
if (Event.Control.ControlId == \"{$controlId}\") {
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});
}";
}
else {
// Other
$scriptText = "
PlayUiSound(CMlScriptIngame::EUISound::{$this->soundName}, {$this->variant}, {$this->volume});";
}
return $scriptText;
}
}

View File

@ -1,4 +0,0 @@
/*********************************
* FancyManiaLinks by steeffeen *
* http://fml.steeffeen.com *
*********************************/

View File

@ -1,34 +0,0 @@
Void Dummy() {}
main() {
declare FML_ScriptStart = Now;
+++OnInit+++
declare FML_LoopCounter = 0;
declare FML_LastTick = 0;
while (True) {
yield;
foreach (Event in PendingEvents) {
switch (Event.Type) {
case CMlEvent::Type::EntrySubmit: {
+++EntrySubmit+++
}
case CMlEvent::Type::KeyPress: {
+++KeyPress+++
}
case CMlEvent::Type::MouseClick: {
+++MouseClick+++
}
case CMlEvent::Type::MouseOut: {
+++MouseOut+++
}
case CMlEvent::Type::MouseOver: {
+++MouseOver+++
}
}
}
FML_LoopCounter += 1;
+++Loop+++
if (FML_LastTick + 250 > Now) continue;
FML_LastTick = Now;
+++Tick+++
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
<?php
namespace FML\Script;
/**
* Class representing a Constant of the ManiaLink Script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptConstant {
/*
* Protected Properties
*/
protected $name = null;
protected $value = null;
/**
* Construct a new Script Constant
*
* @param string $name (optional) Constant Name
* @param string $value (optional) Constant Value
*/
public function __construct($name = null, $value = null) {
$this->setName($name);
$this->setValue($value);
}
/**
* Set the Name
*
* @param string $name Constant Name
* @return \FML\Script\ScriptConstant
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* Set the Value
*
* @param string $value Constant Value
* @return \FML\Script\ScriptConstant
*/
public function setValue($value) {
$this->value = $value;
return $this;
}
/**
* Build the Script Constant Text
*
* @return string
*/
public function __toString() {
$scriptText = Builder::getConstant($this->name, $this->value);
return $scriptText;
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace FML\Script;
/**
* Class representing a Function of the ManiaLink Script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptFunction {
/*
* Protected Properties
*/
protected $name = null;
protected $text = null;
/**
* Construct a new Script Function
*
* @param string $name (optional) Function Name
* @param string $text (optional) Function Text
*/
public function __construct($name = null, $text = null) {
$this->setName($name);
$this->setText($text);
}
/**
* Set the Name
*
* @param string $name Function Name
* @return \FML\Script\ScriptFunction
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Text
*
* @param string $text Function Text
* @return \FML\Script\ScriptFunction
*/
public function setText($text) {
$this->text = (string) $text;
return $this;
}
/**
* Get the Script Function Text
*
* @return string
*/
public function __toString() {
return $this->text;
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace FML\Script;
/**
* Class representing an Include of the ManiaLink Script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptInclude {
/*
* Constants
*/
const MATHLIB = 'MathLib';
const TEXTLIB = 'TextLib';
/*
* Protected Properties
*/
protected $file = null;
protected $namespace = null;
/**
* Construct a new Script Include
*
* @param string $file (optional) Include File
* @param string $namespace (optional) Include Namespace
*/
public function __construct($file = null, $namespace = null) {
$this->setFile($file);
if ($namespace) {
$this->setNamespace($namespace);
}
else {
$fileParts = explode('.', $file);
if (count($fileParts) === 1) {
$this->setNamespace($file);
}
}
}
/**
* Set the File
*
* @param string $file Include File
* @return \FML\Script\ScriptInclude
*/
public function setFile($file) {
$this->file = $file;
return $this;
}
/**
* Set the Namespace
*
* @param string $namespace Include Namespace
* @return \FML\Script\ScriptInclude
*/
public function setNamespace($namespace) {
$this->namespace = $namespace;
return $this;
}
/**
* Get the Namespace
*
* @return string
*/
public function getNamespace() {
return $this->namespace;
}
/**
* Build the Script Include Text
*
* @return string
*/
public function __toString() {
$scriptText = Builder::getInclude($this->file, $this->namespace);
return $scriptText;
}
}

View File

@ -0,0 +1,87 @@
<?php
namespace FML\Script;
/**
* Class representing a Part of the ManiaLink Script
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class ScriptLabel {
/*
* Constants
*/
const ONINIT = 'FML_OnInit';
const LOOP = 'FML_Loop';
const TICK = 'FML_Tick';
const ENTRYSUBMIT = 'FML_EntrySubmit';
const KEYPRESS = 'FML_KeyPress';
const MOUSECLICK = 'FML_MouseClick';
const MOUSEOUT = 'FML_MouseOut';
const MOUSEOVER = 'FML_MouseOver';
/*
* Protected Properties
*/
protected $name = null;
protected $text = null;
protected $isolated = null;
/**
* Construct a new ScriptLabel
*
* @param string $name (optional) Label Name
* @param string $text (optional) Script Text
* @param bool $isolated (optional) Isolate the Label Script
*/
public function __construct($name = self::LOOP, $text = '', $isolated = false) {
$this->setName($name);
$this->setText($text);
$this->setIsolated($isolated);
}
/**
* Set the Name
*
* @param string $name Label Name
* @return \FML\Script\ScriptLabel
*/
public function setName($name) {
$this->name = (string) $name;
return $this;
}
/**
* Set the Text
*
* @param string $text Script Text
* @return \FML\Script\ScriptLabel
*/
public function setText($text) {
$this->text = (string) $text;
return $this;
}
/**
* Set Isolation
*
* @param bool $isolated Whether the Code should be isolated in an own Block
* @return \FML\Script\ScriptLabel
*/
public function setIsolated($isolated) {
$this->isolated = (bool) $isolated;
return $this;
}
/**
* Build the full Script Label Text
*
* @return string
*/
public function __toString() {
$scriptText = Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated);
return $scriptText;
}
}

View File

@ -35,7 +35,7 @@ class Mood {
/**
* Create a new Mood Object
*
* @return \FML\Elements\Mood
* @return \FML\Stylesheet\Mood
*/
public static function create() {
$mood = new Mood();
@ -168,7 +168,7 @@ class Mood {
* @return \FML\Stylesheet\Mood
*/
public function setLightBallIntensity($intensity) {
$this->lBall_Intens = (float) $intensity;
$this->lBall_Intensity = (float) $intensity;
return $this;
}
@ -218,7 +218,7 @@ class Mood {
/**
* Set Sky Gradient Scale
*
* @param float $vScale Gradient Scale Scale
* @param float $scale Gradient Scale
* @return \FML\Stylesheet\Mood
*/
public function setSkyGradientScale($scale) {
@ -283,8 +283,8 @@ class Mood {
if ($this->lBall_LinearRgb) {
$moodXml->setAttribute('LBall_LinearRgb', $this->lBall_LinearRgb);
}
if ($this->lBall_Intens) {
$moodXml->setAttribute('LBall_Intens', $this->lBall_Intens);
if ($this->lBall_Intensity) {
$moodXml->setAttribute('LBall_Intens', $this->lBall_Intensity);
}
if ($this->lBall_Radius) {
$moodXml->setAttribute('LBall_Radius', $this->lBall_Radius);

View File

@ -23,27 +23,26 @@ class Style3d {
* Protected Properties
*/
protected $tagName = 'style3d';
protected $id = '';
protected $id = null;
protected $model = self::MODEL_Box;
// TODO: check what happens for negative thickness values + adapt rendering
protected $thickness = null;
protected $color = '';
protected $focusColor = '';
protected $lightColor = '';
protected $focusLightColor = '';
// TODO: check offset value ranges + apapt rendering
protected $yOffset = 0.;
protected $focusYOffset = 0.;
protected $zOffset = 0.;
protected $focusZOffset = 0.;
protected $color = null;
protected $focusColor = null;
protected $lightColor = null;
protected $focusLightColor = null;
protected $yOffset = null;
protected $focusYOffset = null;
protected $zOffset = null;
protected $focusZOffset = null;
/**
* Create a new Style3d Object
*
* @return \FML\Elements\Style3d
* @param string $id (optional) Style Id
* @return \FML\Stylesheet\Style3d
*/
public static function create() {
$style3d = new Style3d();
public static function create($id = null) {
$style3d = new Style3d($id);
return $style3d;
}
@ -159,7 +158,7 @@ class Style3d {
/**
* Set Y-Offset
*
* @param flaot $yOffset Y-Offset
* @param float $yOffset Y-Offset
* @return \FML\Stylesheet\Style3d
*/
public function setYOffset($yOffset) {

View File

@ -20,7 +20,7 @@ class Stylesheet {
/**
* Create a new Stylesheet Object
*
* @return \FML\Elements\Stylesheet
* @return \FML\Stylesheet\Stylesheet
*/
public static function create() {
$stylesheet = new Stylesheet();
@ -37,7 +37,7 @@ class Stylesheet {
* Add a new Style3d
*
* @param Style3d $style3d The Style3d to add
* @return \FML\Stylesheet\Frame3dStyles
* @return \FML\Stylesheet\Stylesheet
*/
public function addStyle3d(Style3d $style3d) {
if (!in_array($style3d, $this->styles3d, true)) {
@ -49,7 +49,7 @@ class Stylesheet {
/**
* Remove all Styles
*
* @return \FML\Stylesheet\Frame3dStyles
* @return \FML\Stylesheet\Stylesheet
*/
public function removeStyles() {
$this->styles3d = array();

View File

@ -0,0 +1,20 @@
<?php
namespace FML\Types;
/**
* Interface for Elements supporting Script Features
*
* @author steeffeen
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
interface ScriptFeatureable {
/**
* Get the assigned Script Features of the Element
*
* @return array
*/
public function getScriptFeatures();
}

View File

@ -4,7 +4,8 @@
* FancyManiaLinks - Automatic ManiaLink Generator Framework
*
* @author steeffeen
* @version 1.0
* @version 1.1
* @link http://github.com/steeffeen/FancyManiaLinks
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
@ -12,7 +13,7 @@ if (!defined('FML_PATH')) {
define('FML_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
}
if (!defined('FML_VERSION')) {
define('FML_VERSION', 1.0);
define('FML_VERSION', 1.1);
}
if (!defined('FML_SIMPLE_CLASSES')) {
define('FML_SIMPLE_CLASSES', false);
@ -34,6 +35,15 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
// Load as simple class name
if (!function_exists('loadSimpleClass')) {
/**
* Load FML Class Files from the given Directory
*
* @param string $className Class to load
* @param string $directory Directory to open
* @param array $excludes File Names to ignore
* @param string $baseNamespace Base Namespace
* @return bool
*/
function loadSimpleClass($className, $directory, $excludes, $baseNamespace) {
if ($dirHandle = opendir($directory)) {
$classParts = explode('\\', $className);