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,284 +2,531 @@
namespace FML\Stylesheet;
// Warning: The mood class isn't fully supported yet!
// Missing attributes: LDir1..
/**
* Class representing a Stylesheet Mood
* Warning: The mood class isn't fully supported yet - Missing attributes: LDir1 etc.
*
* @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 Mood {
/*
* Protected properties
*/
protected $tagName = 'mood';
protected $lAmbient_LinearRgb = null;
protected $cloudsRgbMinLinear = null;
protected $cloudsRgbMaxLinear = null;
protected $lDir0_LinearRgb = null;
protected $lDir0_Intens = 1.;
protected $lDir0_DirPhi = 0.;
protected $lDir0_DirTheta = 0.;
protected $lBall_LinearRgb = null;
protected $lBall_Intensity = 1.;
protected $lBall_Radius = 0.;
protected $fogColorSrgb = null;
protected $selfIllumColor = null;
protected $skyGradientV_Scale = 1.;
protected $skyGradientKeys = array();
class Mood
{
/**
* Create a new Mood object
*
* @return static
*/
public static function create() {
return new static();
}
/**
* @var string $lightAmbientColor Light ambient color
*/
protected $lightAmbientColor = null;
/**
* Set ambient color in which the Elements reflect the light
*
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setLightAmbientColor($red, $green, $blue) {
$this->lAmbient_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* @var string $cloudsMinimumColor Clouds minimum color
*/
protected $cloudsMinimumColor = null;
/**
* Set minimum value for the background color range
*
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setCloudsColorMin($red, $green, $blue) {
$this->cloudsRgbMinLinear = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* @var string $cloudsMaximumColor Clouds maximum color
*/
protected $cloudsMaximumColor = null;
/**
* Set maximum value for the background color range
*
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setCloudsColorMax($red, $green, $blue) {
$this->cloudsRgbMaxLinear = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* @var string $light0Color Color of light source 0
*/
protected $light0Color = null;
/**
* Set RGB color of light source 0
*
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setLight0Color($red, $green, $blue) {
$this->lDir0_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* @var float $light0Intensity Intensity of light source 0
*/
protected $light0Intensity = 1.;
/**
* Set intensity of light source 0
*
* @param float $intensity Light intensity
* @return static
*/
public function setLight0Intensity($intensity) {
$this->lDir0_Intens = (float)$intensity;
return $this;
}
/**
* @var float $light0PhiAngle Phi angle of light source 0
*/
protected $light0PhiAngle = 0.;
/**
* Set phi angle of light source 0
*
* @param float $phiAngle Phi angle
* @return static
*/
public function setLight0PhiAngle($phiAngle) {
$this->lDir0_DirPhi = (float)$phiAngle;
return $this;
}
/**
* @var float $light0ThetaAngle Theta angle of light source 0
*/
protected $light0ThetaAngle = 0.;
/**
* Set theta angle of light source 0
*
* @param float $thetaAngle Theta angle
* @return static
*/
public function setLight0ThetaAngle($thetaAngle) {
$this->lDir0_DirTheta = (float)$thetaAngle;
return $this;
}
/**
* @var string $lightBallColor Light ball color
*/
protected $lightBallColor = null;
/**
* Set light ball color
*
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setLightBallColor($red, $green, $blue) {
$this->lBall_LinearRgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* @var float $lightBallIntensity Light ball intensity
*/
protected $lightBallIntensity = 1.;
/**
* Set light ball intensity
*
* @param float $intensity Light ball intensity
* @return static
*/
public function setLightBallIntensity($intensity) {
$this->lBall_Intensity = (float)$intensity;
return $this;
}
/**
* @var float $lightBallRadius Light ball radius
*/
protected $lightBallRadius = 0.;
/**
* Set light ball radius
*
* @param float $radius Light ball radius
* @return static
*/
public function setLightBallRadius($radius) {
$this->lBall_Radius = (float)$radius;
return $this;
}
/**
* @var string $fogColor Fog color
*/
protected $fogColor = null;
/**
* Set fog color
*
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setFogColor($red, $green, $blue) {
$this->fogColorSrgb = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* @var float $selfIlluminationColor Self illumination color
*/
protected $selfIlluminationColor = null;
/**
* Set self illumination color
*
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setSelfIllumColor($red, $green, $blue) {
$this->selfIllumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* @var float $skyGradientV_Scale Sky gradient scale
*/
protected $skyGradientScale = 1.;
/**
* Set sky gradient scale
*
* @param float $scale Gradient scale
* @return static
*/
public function setSkyGradientScale($scale) {
$this->skyGradientV_Scale = (float)$scale;
return $this;
}
/**
* @var SkyGradientKey[] $skyGradientKeys Sky Gradient Keys
*/
protected $skyGradientKeys = array();
/**
* Add a sky gradient key
*
* @param float $gradientX Scale value
* @param string $color Gradient color
* @return static
*/
public function addSkyGradientKey($gradientX, $color) {
$gradientX = (float)$gradientX;
$color = (string)$color;
$gradientKey = array('x' => $gradientX, 'color' => $color);
array_push($this->skyGradientKeys, $gradientKey);
return $this;
}
/**
* Create a new Mood
*
* @api
* @return static
*/
public static function create()
{
return new static();
}
/**
* Remove all sky gradient keys
*
* @return static
*/
public function removeSkyGradientKeys() {
$this->skyGradientKeys = array();
return $this;
}
/**
* Get the light ambient color
*
* @api
* @return string
*/
public function getLightAmbientColor()
{
return $this->lightAmbientColor;
}
/**
* Set the ambient color in which elements reflect the light
*
* @api
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setLightAmbientColor($red, $green, $blue)
{
$this->lightAmbientColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* Get the minimum value for the background color range
*
* @api
* @return string
*/
public function getCloudsMinimumColor()
{
return $this->cloudsMinimumColor;
}
/**
* Set the minimum value for the background color range
*
* @api
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setCloudsMinimumColor($red, $green, $blue)
{
$this->cloudsMinimumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* Get the maximum value for the background color range
*
* @api
* @return string
*/
public function getCloudsMaximumColor()
{
return $this->cloudsMaximumColor;
}
/**
* Set the maximum value for the background color range
*
* @api
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setCloudsMaximumColor($red, $green, $blue)
{
$this->cloudsMaximumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* Get the RGB color of light source 0
*
* @api
* @return string
*/
public function getLight0Color()
{
return $this->light0Color;
}
/**
* Set the RGB color of light source 0
*
* @api
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setLight0Color($red, $green, $blue)
{
$this->light0Color = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* Get the intensity of light source 0
*
* @api
* @return float
*/
public function getLight0Intensity()
{
return $this->light0Intensity;
}
/**
* Set the intensity of light source 0
*
* @api
* @param float $intensity Light intensity
* @return static
*/
public function setLight0Intensity($intensity)
{
$this->light0Intensity = (float)$intensity;
return $this;
}
/**
* Get the phi angle of light source 0
*
* @api
* @return float
*/
public function getLight0PhiAngle()
{
return $this->light0PhiAngle;
}
/**
* Set the phi angle of light source 0
*
* @api
* @param float $phiAngle Phi angle
* @return static
*/
public function setLight0PhiAngle($phiAngle)
{
$this->light0PhiAngle = (float)$phiAngle;
return $this;
}
/**
* Get the theta angle of light source 0
*
* @api
* @return float
*/
public function getLight0ThetaAngle()
{
return $this->light0ThetaAngle;
}
/**
* Set the theta angle of light source 0
*
* @api
* @param float $thetaAngle Theta angle
* @return static
*/
public function setLight0ThetaAngle($thetaAngle)
{
$this->light0ThetaAngle = (float)$thetaAngle;
return $this;
}
/**
* Get the light ball color
*
* @api
* @return string
*/
public function getLightBallColor()
{
return $this->lightBallColor;
}
/**
* Set the light ball color
*
* @api
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setLightBallColor($red, $green, $blue)
{
$this->lightBallColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* Get the light ball intensity
*
* @api
* @return float
*/
public function getLightBallIntensity()
{
return $this->lightBallIntensity;
}
/**
* Set the light ball intensity
*
* @api
* @param float $intensity Light ball intensity
* @return static
*/
public function setLightBallIntensity($intensity)
{
$this->lightBallIntensity = (float)$intensity;
return $this;
}
/**
* Get the light ball radius
*
* @api
* @return float
*/
public function getLightBallRadius()
{
return $this->lightBallRadius;
}
/**
* Set the light ball radius
*
* @api
* @param float $radius Light ball radius
* @return static
*/
public function setLightBallRadius($radius)
{
$this->lightBallRadius = (float)$radius;
return $this;
}
/**
* Get the fog color
*
* @api
* @return string
*/
public function getFogColor()
{
return $this->fogColor;
}
/**
* Set the fog color
*
* @api
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setFogColor($red, $green, $blue)
{
$this->fogColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* Get the self illumination color
*
* @api
* @return string
*/
public function getSelfIlluminationColor()
{
return $this->selfIlluminationColor;
}
/**
* Set the self illumination color
*
* @api
* @param float $red Red color value
* @param float $green Green color value
* @param float $blue Blue color value
* @return static
*/
public function setSelfIlluminationColor($red, $green, $blue)
{
$this->selfIlluminationColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
return $this;
}
/**
* Get the sky gradient scale
*
* @api
* @return float
*/
public function getSkyGradientScale()
{
return $this->skyGradientScale;
}
/**
* Set the sky gradient scale
*
* @api
* @param float $skyGradientScale Sky gradient scale
* @return static
*/
public function setSkyGradientScale($skyGradientScale)
{
$this->skyGradientScale = (float)$skyGradientScale;
return $this;
}
/**
* Get Sky Gradient Keys
*
* @api
* @return SkyGradientKey[]
*/
public function getSkyGradientKeys()
{
return $this->skyGradientKeys;
}
/**
* Add a sky gradient key
*
* @api
* @param SkyGradientKey $skyGradientKey Sky Gradient Key
* @return static
*/
public function addSkyGradientKey(SkyGradientKey $skyGradientKey)
{
array_push($this->skyGradientKeys, $skyGradientKey);
return $this;
}
/**
* Add a sky gradient
*
* @api
* @param float $x X value
* @param string $color Color value
* @return static
*/
public function addSkyGradient($x, $color)
{
$skyGradientKey = new SkyGradientKey($x, $color);
return $this->addSkyGradientKey($skyGradientKey);
}
/**
* Remove all Sky Gradient Keys
*
* @api
* @return static
*/
public function removeAllSkyGradientKeys()
{
$this->skyGradientKeys = array();
return $this;
}
/**
* Render the Mood
*
* @param \DOMDocument $domDocument DOMDocument for which the Mood should be rendered
* @return \DOMElement
*/
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("mood");
if ($this->lightAmbientColor) {
$domElement->setAttribute("LAmbient_LinearRgb", $this->lightAmbientColor);
}
if ($this->cloudsMinimumColor) {
$domElement->setAttribute("CloudsRgbMinLinear", $this->cloudsMinimumColor);
}
if ($this->cloudsMaximumColor) {
$domElement->setAttribute("CloudsRgbMaxLinear", $this->cloudsMaximumColor);
}
if ($this->light0Color) {
$domElement->setAttribute("LDir0_LinearRgb", $this->light0Color);
}
if ($this->light0Intensity != 1.) {
$domElement->setAttribute("LDir0_Intens", $this->light0Intensity);
}
if ($this->light0PhiAngle) {
$domElement->setAttribute("LDir0_DirPhi", $this->light0PhiAngle);
}
if ($this->light0ThetaAngle) {
$domElement->setAttribute("LDir0_DirTheta", $this->light0ThetaAngle);
}
if ($this->lightBallColor) {
$domElement->setAttribute("LBall_LinearRgb", $this->lightBallColor);
}
if ($this->lightBallIntensity != 1.) {
$domElement->setAttribute("LBall_Intens", $this->lightBallIntensity);
}
if ($this->lightBallRadius) {
$domElement->setAttribute("LBall_Radius", $this->lightBallRadius);
}
if ($this->fogColor) {
$domElement->setAttribute("FogColorSrgb", $this->fogColor);
}
if ($this->selfIlluminationColor) {
$domElement->setAttribute("SelfIllumColor", $this->selfIlluminationColor);
}
if ($this->skyGradientScale != 1.) {
$domElement->setAttribute("SkyGradientV_Scale", $this->skyGradientScale);
}
if ($this->skyGradientKeys) {
$skyGradientElement = $domDocument->createElement("skygradient");
$domElement->appendChild($skyGradientElement);
foreach ($this->skyGradientKeys as $skyGradientKey) {
$skyGradientKeyElement = $skyGradientKey->render($domDocument);
$skyGradientElement->appendChild($skyGradientKeyElement);
}
}
return $domElement;
}
/**
* Render the Mood XML element
*
* @param \DOMDocument $domDocument DOMDocument for which the Mood XML element should be rendered
* @return \DOMElement
*/
public function render(\DOMDocument $domDocument) {
$moodXml = $domDocument->createElement($this->tagName);
if ($this->lAmbient_LinearRgb) {
$moodXml->setAttribute('LAmbient_LinearRgb', $this->lAmbient_LinearRgb);
}
if ($this->cloudsRgbMinLinear) {
$moodXml->setAttribute('CloudsRgbMinLinear', $this->cloudsRgbMinLinear);
}
if ($this->cloudsRgbMaxLinear) {
$moodXml->setAttribute('CloudsRgbMaxLinear', $this->cloudsRgbMaxLinear);
}
if ($this->lDir0_LinearRgb) {
$moodXml->setAttribute('LDir0_LinearRgb', $this->lDir0_LinearRgb);
}
if ($this->lDir0_Intens) {
$moodXml->setAttribute('LDir0_Intens', $this->lDir0_Intens);
}
if ($this->lDir0_DirPhi) {
$moodXml->setAttribute('LDir0_DirPhi', $this->lDir0_DirPhi);
}
if ($this->lDir0_DirTheta) {
$moodXml->setAttribute('LDir0_DirTheta', $this->lDir0_DirTheta);
}
if ($this->lBall_LinearRgb) {
$moodXml->setAttribute('LBall_LinearRgb', $this->lBall_LinearRgb);
}
if ($this->lBall_Intensity) {
$moodXml->setAttribute('LBall_Intens', $this->lBall_Intensity);
}
if ($this->lBall_Radius) {
$moodXml->setAttribute('LBall_Radius', $this->lBall_Radius);
}
if ($this->fogColorSrgb) {
$moodXml->setAttribute('FogColorSrgb', $this->fogColorSrgb);
}
if ($this->selfIllumColor) {
$moodXml->setAttribute('SelfIllumColor', $this->selfIllumColor);
}
if ($this->skyGradientV_Scale) {
$moodXml->setAttribute('SkyGradientV_Scale', $this->skyGradientV_Scale);
}
if ($this->skyGradientKeys) {
$skyGradientXml = $domDocument->createElement('skygradient');
$moodXml->appendChild($skyGradientXml);
foreach ($this->skyGradientKeys as $gradientKey) {
$keyXml = $domDocument->createElement('key');
$skyGradientXml->appendChild($keyXml);
$keyXml->setAttribute('x', $gradientKey['x']);
$keyXml->setAttribute('color', $gradientKey['color']);
}
}
return $moodXml;
}
}