Updated to ManiaLink v3

This commit is contained in:
Jocy Wolff
2017-03-25 18:40:15 +01:00
parent 1010c1db6b
commit 120a0e2169
133 changed files with 16194 additions and 8949 deletions

View File

@ -2,6 +2,7 @@
namespace FML\Controls;
use FML\Types\Colorable;
use FML\Types\Styleable;
/**
@ -9,152 +10,298 @@ use FML\Types\Styleable;
* (CMlGauge)
*
* @author steeffeen <mail@steeffeen.com>
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Gauge extends Control implements Styleable {
/*
* Constants
*/
const STYLE_BgCard = 'BgCard';
const STYLE_EnergyBar = 'EnergyBar';
const STYLE_ProgressBar = 'ProgressBar';
const STYLE_ProgressBarSmall = 'ProgressBarSmall';
class Gauge extends Control implements Colorable, Styleable
{
/*
* Protected properties
*/
protected $tagName = 'gauge';
protected $ratio = 0.;
protected $grading = 1.;
protected $color = null;
protected $centered = null;
protected $clan = null;
protected $drawBg = 1;
protected $drawBlockBg = 1;
protected $style = null;
/*
* Constants
*/
const STYLE_BgCard = "BgCard";
const STYLE_EnergyBar = "EnergyBar";
const STYLE_ProgressBar = "ProgressBar";
const STYLE_ProgressBarSmall = "ProgressBarSmall";
/**
* @see \FML\Controls\Control::getManiaScriptClass()
*/
public function getManiaScriptClass() {
return 'CMlGauge';
}
/**
* @var float $ratio Ratio
*/
protected $ratio = 0.0;
/**
* Set ratio
*
* @param float $ratio Ratio value
* @return static
*/
public function setRatio($ratio) {
$this->ratio = (float)$ratio;
return $this;
}
/**
* @var float $grading Grading
*/
protected $grading = 1.;
/**
* Set grading
*
* @param float $grading Grading value
* @return static
*/
public function setGrading($grading) {
$this->grading = (float)$grading;
return $this;
}
/**
* @var string $color Color
*/
protected $color = null;
/**
* Set color
*
* @param string $color Gauge color
* @return static
*/
public function setColor($color) {
$this->color = (string)$color;
return $this;
}
/**
* @var bool $centered Centered
*/
protected $centered = null;
/**
* Set centered
*
* @param bool $centered Whether the Gauge is centered
* @return static
*/
public function setCentered($centered) {
$this->centered = ($centered ? 1 : 0);
return $this;
}
/**
* @var int $clan Clan number
*/
protected $clan = null;
/**
* Set clan
*
* @param int $clan Clan number
* @return static
*/
public function setClan($clan) {
$this->clan = (int)$clan;
return $this;
}
/**
* @var bool $drawBackground Draw background
*/
protected $drawBackground = true;
/**
* Set draw background
*
* @param bool $drawBg Whether the Gauges background should be drawn
* @return static
*/
public function setDrawBg($drawBg) {
$this->drawBg = ($drawBg ? 1 : 0);
return $this;
}
/**
* @var bool $drawBlockBackground Draw block background
*/
protected $drawBlockBackground = true;
/**
* Set draw block background
*
* @param bool $drawBlockBg Whether the Gauges block background should be drawn
* @return static
*/
public function setDrawBlockBg($drawBlockBg) {
$this->drawBlockBg = ($drawBlockBg ? 1 : 0);
return $this;
}
/**
* @var string $style Style
*/
protected $style = null;
/**
* @see \FML\Types\Styleable::setStyle()
*/
public function setStyle($style) {
$this->style = (string)$style;
return $this;
}
/**
* Get the ratio
*
* @api
* @return float
*/
public function getRatio()
{
return $this->ratio;
}
/**
* Set the ratio
*
* @api
* @param float $ratio Ratio value
* @return static
*/
public function setRatio($ratio)
{
$this->ratio = (float)$ratio;
return $this;
}
/**
* Get the grading
*
* @api
* @return float
*/
public function getGrading()
{
return $this->grading;
}
/**
* Set the grading
*
* @api
* @param float $grading Grading value
* @return static
*/
public function setGrading($grading)
{
$this->grading = (float)$grading;
return $this;
}
/**
* @see Colorable::getColor
*/
public function getColor()
{
return $this->color;
}
/**
* @see Colorable::setColor
*/
public function setColor($color)
{
$this->color = (string)$color;
return $this;
}
/**
* Get centered
*
* @api
* @return bool
*/
public function getCentered()
{
return $this->centered;
}
/**
* Set centered
*
* @api
* @param bool $centered If the Gauge should be centered
* @return static
*/
public function setCentered($centered)
{
$this->centered = (bool)$centered;
return $this;
}
/**
* Get the clan
*
* @api
* @return int
*/
public function getClan()
{
return $this->clan;
}
/**
* Set the clan
*
* @api
* @param int $clan Clan number
* @return static
*/
public function setClan($clan)
{
$this->clan = (int)$clan;
return $this;
}
/**
* Get draw background
*
* @api
* @return bool
*/
public function getDrawBackground()
{
return $this->drawBackground;
}
/**
* Set draw background
*
* @api
* @param bool $drawBackground If the Gauges background should be drawn
* @return static
* @deprecated use setDrawBackground() instead
*/
public function setDrawBg($drawBackground)
{
return $this->setDrawBackground($drawBackground);
}
/**
* Set draw background
*
* @api
* @param bool $drawBackground If the Gauges background should be drawn
* @return static
*/
public function setDrawBackground($drawBackground)
{
$this->drawBackground = (bool)$drawBackground;
return $this;
}
/**
* Get draw block background
*
* @api
* @return bool
*/
public function getDrawBlockBackground()
{
return $this->drawBlockBackground;
}
/**
* Set draw block background
*
* @api
* @param bool $drawBlockBackground If the Gauges block background should be drawn
* @return static
*/
public function setDrawBlockBackground($drawBlockBackground)
{
$this->drawBlockBackground = (bool)$drawBlockBackground;
return $this;
}
/**
* @see Styleable::getStyle()
*/
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* @see Control::getTagName()
*/
public function getTagName()
{
return "gauge";
}
/**
* @see Control::getManiaScriptClass()
*/
public function getManiaScriptClass()
{
return "CMlGauge";
}
/**
* @see Control::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = parent::render($domDocument);
if ($this->ratio) {
$domElement->setAttribute("ratio", $this->ratio);
}
if ($this->grading != 1.) {
$domElement->setAttribute("grading", $this->grading);
}
if ($this->color) {
$domElement->setAttribute("color", $this->color);
}
if ($this->centered) {
$domElement->setAttribute("centered", 1);
}
if ($this->clan) {
$domElement->setAttribute("clan", $this->clan);
}
if (!$this->drawBackground) {
$domElement->setAttribute("drawbg", 0);
}
if (!$this->drawBlockBackground) {
$domElement->setAttribute("drawblockbg", 0);
}
if ($this->style) {
$domElement->setAttribute("style", $this->style);
}
return $domElement;
}
/**
* @see \FML\Control::render()
*/
public function render(\DOMDocument $domDocument) {
$xmlElement = parent::render($domDocument);
if ($this->ratio) {
$xmlElement->setAttribute('ratio', $this->ratio);
}
if ($this->grading != 1.) {
$xmlElement->setAttribute('grading', $this->grading);
}
if ($this->color) {
$xmlElement->setAttribute('color', $this->color);
}
if ($this->centered) {
$xmlElement->setAttribute('centered', $this->centered);
}
if ($this->clan) {
$xmlElement->setAttribute('clan', $this->clan);
}
if (!$this->drawBg) {
$xmlElement->setAttribute('drawbg', $this->drawBg);
}
if (!$this->drawBlockBg) {
$xmlElement->setAttribute('drawblockbg', $this->drawBlockBg);
}
if ($this->style) {
$xmlElement->setAttribute('style', $this->style);
}
return $xmlElement;
}
}