TrackManiaControl/application/core/Libs/FML/Script/ScriptLabel.php

88 lines
1.9 KiB
PHP
Raw Normal View History

2014-04-27 14:44:40 +02:00
<?php
namespace FML\Script;
/**
* Class representing a Part of the ManiaLink Script
*
2014-05-14 23:24:00 +02:00
* @author steeffeen
2014-04-27 14:44:40 +02:00
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
2014-05-14 23:24:00 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
2014-04-27 14:44:40 +02:00
*/
class ScriptLabel {
/*
* Constants
*/
2014-05-14 23:24:00 +02:00
const ONINIT = 'FML_OnInit';
const LOOP = 'FML_Loop';
const TICK = 'FML_Tick';
2014-04-27 14:44:40 +02:00
const ENTRYSUBMIT = 'FML_EntrySubmit';
2014-05-14 23:24:00 +02:00
const KEYPRESS = 'FML_KeyPress';
const MOUSECLICK = 'FML_MouseClick';
const MOUSEOUT = 'FML_MouseOut';
const MOUSEOVER = 'FML_MouseOver';
2014-04-27 14:44:40 +02:00
/*
* Protected Properties
*/
protected $name = null;
protected $text = null;
protected $isolated = null;
/**
* Construct a new ScriptLabel
*
2014-05-14 23:24:00 +02:00
* @param string $name (optional) Label Name
* @param string $text (optional) Script Text
* @param bool $isolated (optional) Isolate the Label Script
2014-04-27 14:44:40 +02:00
*/
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) {
2014-05-14 23:24:00 +02:00
$this->name = (string)$name;
2014-04-27 14:44:40 +02:00
return $this;
}
/**
* Set the Text
*
* @param string $text Script Text
* @return \FML\Script\ScriptLabel
*/
public function setText($text) {
2014-05-14 23:24:00 +02:00
$this->text = (string)$text;
2014-04-27 14:44:40 +02:00
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) {
2014-05-14 23:24:00 +02:00
$this->isolated = (bool)$isolated;
2014-04-27 14:44:40 +02:00
return $this;
}
/**
* Build the full Script Label Text
*
* @return string
*/
public function __toString() {
$scriptText = Builder::getLabelImplementationBlock($this->name, $this->text, $this->isolated);
return $scriptText;
}
}