Updated to ManiaLink v3
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
117
libs/FML/Stylesheet/SkyGradientKey.php
Normal file
117
libs/FML/Stylesheet/SkyGradientKey.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace FML\Stylesheet;
|
||||
|
||||
/**
|
||||
* Class representing a Sky Gradient Key
|
||||
*
|
||||
* @author steeffeen <mail@steeffeen.com>
|
||||
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class SkyGradientKey
|
||||
{
|
||||
|
||||
/**
|
||||
* @var float $x X value
|
||||
*/
|
||||
protected $x = null;
|
||||
|
||||
/**
|
||||
* @var string $color Color value
|
||||
*/
|
||||
protected $color = null;
|
||||
|
||||
/**
|
||||
* Create a new SkyGradientKey
|
||||
*
|
||||
* @api
|
||||
* @param float $x X value
|
||||
* @param string $color Color value
|
||||
* @return static
|
||||
*/
|
||||
public static function create($x = null, $color = null)
|
||||
{
|
||||
return new static($x, $color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new SkyGradientKey
|
||||
*
|
||||
* @api
|
||||
* @param float $x X value
|
||||
* @param string $color Color value
|
||||
*/
|
||||
public function __construct($x = null, $color = null)
|
||||
{
|
||||
if ($x) {
|
||||
$this->setX($x);
|
||||
}
|
||||
if ($color) {
|
||||
$this->setColor($color);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X value
|
||||
*
|
||||
* @api
|
||||
* @return float
|
||||
*/
|
||||
public function getX()
|
||||
{
|
||||
return $this->x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the X value
|
||||
*
|
||||
* @api
|
||||
* @param float $x X value
|
||||
* @return static
|
||||
*/
|
||||
public function setX($x)
|
||||
{
|
||||
$this->x = (float)$x;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Color value
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Color value
|
||||
*
|
||||
* @api
|
||||
* @param string $color Color value
|
||||
* @return static
|
||||
*/
|
||||
public function setColor($color)
|
||||
{
|
||||
$this->color = (string)$color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the SkyGradientKey
|
||||
*
|
||||
* @param \DOMDocument $domDocument DOMDocument for which the Sky Gradient Key should be rendered
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$domElement = $domDocument->createElement("key");
|
||||
$domElement->setAttribute("x", $this->x);
|
||||
$domElement->setAttribute("color", $this->color);
|
||||
return $domElement;
|
||||
}
|
||||
|
||||
}
|
@ -8,240 +8,427 @@ use FML\UniqueID;
|
||||
* Class representing a Style3d
|
||||
*
|
||||
* @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 Style3d {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const MODEL_Box = 'Box';
|
||||
const MODEL_Button = 'Button';
|
||||
const MODEL_ButtonH = 'ButtonH';
|
||||
const MODEL_Title = 'Title';
|
||||
const MODEL_Window = 'Window';
|
||||
class Style3d
|
||||
{
|
||||
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'style3d';
|
||||
protected $styleId = null;
|
||||
protected $model = self::MODEL_Box;
|
||||
protected $thickness = null;
|
||||
protected $color = null;
|
||||
protected $focusColor = null;
|
||||
protected $lightColor = null;
|
||||
protected $focusLightColor = null;
|
||||
protected $yOffset = null;
|
||||
protected $focusYOffset = null;
|
||||
protected $zOffset = null;
|
||||
protected $focusZOffset = null;
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const MODEL_Box = "Box";
|
||||
const MODEL_Button = "Button";
|
||||
const MODEL_ButtonH = "ButtonH";
|
||||
const MODEL_Title = "Title";
|
||||
const MODEL_Window = "Window";
|
||||
|
||||
/**
|
||||
* Create a new Style3d object
|
||||
*
|
||||
* @param string $styleId (optional) Style id
|
||||
* @return static
|
||||
*/
|
||||
public static function create($styleId = null) {
|
||||
return new static($styleId);
|
||||
}
|
||||
/**
|
||||
* @var string $styleId Style ID
|
||||
*/
|
||||
protected $styleId = null;
|
||||
|
||||
/**
|
||||
* Construct a new Style3d object
|
||||
*
|
||||
* @param string $styleId (optional) Style id
|
||||
*/
|
||||
public function __construct($styleId = null) {
|
||||
if ($styleId !== null) {
|
||||
$this->setId($styleId);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @var string $model Style model
|
||||
*/
|
||||
protected $model = self::MODEL_Box;
|
||||
|
||||
/**
|
||||
* Set style id
|
||||
*
|
||||
* @param string $styleId Style id
|
||||
* @return static
|
||||
*/
|
||||
public function setId($styleId) {
|
||||
$this->styleId = (string)$styleId;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var float $thickness Thickness
|
||||
*/
|
||||
protected $thickness = null;
|
||||
|
||||
/**
|
||||
* Check for id and assign one if necessary
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function checkId() {
|
||||
if (!$this->styleId) {
|
||||
$this->setId(new UniqueID());
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $color Color
|
||||
*/
|
||||
protected $color = null;
|
||||
|
||||
/**
|
||||
* Get style id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->styleId;
|
||||
}
|
||||
/**
|
||||
* @var string $focusColor Focus color
|
||||
*/
|
||||
protected $focusColor = null;
|
||||
|
||||
/**
|
||||
* Set model
|
||||
*
|
||||
* @param string $model Style model
|
||||
* @return static
|
||||
*/
|
||||
public function setModel($model) {
|
||||
$this->model = (string)$model;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $lightColor Light color
|
||||
*/
|
||||
protected $lightColor = null;
|
||||
|
||||
/**
|
||||
* Set thickness
|
||||
*
|
||||
* @param float $thickness Style thickness
|
||||
* @return static
|
||||
*/
|
||||
public function setThickness($thickness) {
|
||||
$this->thickness = (float)$thickness;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var string $focusLightColor Focus light color
|
||||
*/
|
||||
protected $focusLightColor = null;
|
||||
|
||||
/**
|
||||
* Set color
|
||||
*
|
||||
* @param string $color Style color
|
||||
* @return static
|
||||
*/
|
||||
public function setColor($color) {
|
||||
$this->color = (string)$color;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var float $yOffset Y-offset
|
||||
*/
|
||||
protected $yOffset = null;
|
||||
|
||||
/**
|
||||
* Set focus color
|
||||
*
|
||||
* @param string $focusColor Style focus color
|
||||
* @return static
|
||||
*/
|
||||
public function setFocusColor($focusColor) {
|
||||
$this->focusColor = (string)$focusColor;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var float $focusYOffset Focus Y-offset
|
||||
*/
|
||||
protected $focusYOffset = null;
|
||||
|
||||
/**
|
||||
* Set light color
|
||||
*
|
||||
* @param string $lightColor Light color
|
||||
* @return static
|
||||
*/
|
||||
public function setLightColor($lightColor) {
|
||||
$this->lightColor = (string)$lightColor;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var float $zOffset Z-offset
|
||||
*/
|
||||
protected $zOffset = null;
|
||||
|
||||
/**
|
||||
* Set focus light color
|
||||
*
|
||||
* @param string $focusLightColor Focus light color
|
||||
* @return static
|
||||
*/
|
||||
public function setFocusLightColor($focusLightColor) {
|
||||
$this->focusLightColor = (string)$focusLightColor;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var float $focusZOffset Focus Z-offset
|
||||
*/
|
||||
protected $focusZOffset = null;
|
||||
|
||||
/**
|
||||
* Set Y-offset
|
||||
*
|
||||
* @param float $yOffset Y-offset
|
||||
* @return static
|
||||
*/
|
||||
public function setYOffset($yOffset) {
|
||||
$this->yOffset = (float)$yOffset;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Create a new Style3d
|
||||
*
|
||||
* @api
|
||||
* @param string $styleId (optional) Style ID
|
||||
* @param string $model (optional) Style model
|
||||
* @return static
|
||||
*/
|
||||
public static function create($styleId = null, $model = null)
|
||||
{
|
||||
return new static($styleId, $model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set focus Y-offset
|
||||
*
|
||||
* @param float $focusYOffset Focus Y-offset
|
||||
* @return static
|
||||
*/
|
||||
public function setFocusYOffset($focusYOffset) {
|
||||
$this->focusYOffset = (float)$focusYOffset;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Construct a new Style3d
|
||||
*
|
||||
* @api
|
||||
* @param string $styleId (optional) Style ID
|
||||
* @param string $model (optional) Style model
|
||||
*/
|
||||
public function __construct($styleId = null, $model = null)
|
||||
{
|
||||
if ($styleId) {
|
||||
$this->setId($styleId);
|
||||
}
|
||||
if ($model) {
|
||||
$this->setModel($model);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Z-offset
|
||||
*
|
||||
* @param float $zOffset Z-offset
|
||||
* @return static
|
||||
*/
|
||||
public function setZOffset($zOffset) {
|
||||
$this->zOffset = (float)$zOffset;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get the Style ID
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->styleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set focus Z-offset
|
||||
*
|
||||
* @param float $focusZOffset Focus Z-offset
|
||||
* @return static
|
||||
*/
|
||||
public function setFocusZOffset($focusZOffset) {
|
||||
$this->focusZOffset = (float)$focusZOffset;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set the Style ID
|
||||
*
|
||||
* @api
|
||||
* @param string $styleId Style ID
|
||||
* @return static
|
||||
*/
|
||||
public function setId($styleId)
|
||||
{
|
||||
$this->styleId = (string)$styleId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the ID and assign one if necessary
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function checkId()
|
||||
{
|
||||
if (!$this->styleId) {
|
||||
$this->setId(new UniqueID());
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the model
|
||||
*
|
||||
* @api
|
||||
* @param string $model Style model
|
||||
* @return static
|
||||
*/
|
||||
public function setModel($model)
|
||||
{
|
||||
$this->model = (string)$model;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thickness
|
||||
*
|
||||
* @api
|
||||
* @return float
|
||||
*/
|
||||
public function getThickness()
|
||||
{
|
||||
return $this->thickness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the thickness
|
||||
*
|
||||
* @api
|
||||
* @param float $thickness Style thickness
|
||||
* @return static
|
||||
*/
|
||||
public function setThickness($thickness)
|
||||
{
|
||||
$this->thickness = (float)$thickness;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color
|
||||
*
|
||||
* @api
|
||||
* @param string $color Style color
|
||||
* @return static
|
||||
*/
|
||||
public function setColor($color)
|
||||
{
|
||||
$this->color = (string)$color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the focus color
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getFocusColor()
|
||||
{
|
||||
return $this->focusColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the focus color
|
||||
*
|
||||
* @api
|
||||
* @param string $focusColor Style focus color
|
||||
* @return static
|
||||
*/
|
||||
public function setFocusColor($focusColor)
|
||||
{
|
||||
$this->focusColor = (string)$focusColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the light color
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getLightColor()
|
||||
{
|
||||
return $this->lightColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the light color
|
||||
*
|
||||
* @api
|
||||
* @param string $lightColor Light color
|
||||
* @return static
|
||||
*/
|
||||
public function setLightColor($lightColor)
|
||||
{
|
||||
$this->lightColor = (string)$lightColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the focus light color
|
||||
*
|
||||
* @api
|
||||
* @return string
|
||||
*/
|
||||
public function getFocusLightColor()
|
||||
{
|
||||
return $this->focusLightColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the focus light color
|
||||
*
|
||||
* @api
|
||||
* @param string $focusLightColor Focus light color
|
||||
* @return static
|
||||
*/
|
||||
public function setFocusLightColor($focusLightColor)
|
||||
{
|
||||
$this->focusLightColor = (string)$focusLightColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y-offset
|
||||
*
|
||||
* @api
|
||||
* @return float
|
||||
*/
|
||||
public function getYOffset()
|
||||
{
|
||||
return $this->yOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Y-offset
|
||||
*
|
||||
* @api
|
||||
* @param float $yOffset Y-offset
|
||||
* @return static
|
||||
*/
|
||||
public function setYOffset($yOffset)
|
||||
{
|
||||
$this->yOffset = (float)$yOffset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the focus Y-offset
|
||||
*
|
||||
* @api
|
||||
* @return float
|
||||
*/
|
||||
public function getFocusYOffset()
|
||||
{
|
||||
return $this->focusYOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the focus Y-offset
|
||||
*
|
||||
* @api
|
||||
* @param float $focusYOffset Focus Y-offset
|
||||
* @return static
|
||||
*/
|
||||
public function setFocusYOffset($focusYOffset)
|
||||
{
|
||||
$this->focusYOffset = (float)$focusYOffset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z-offset
|
||||
*
|
||||
* @api
|
||||
* @return float
|
||||
*/
|
||||
public function getZOffset()
|
||||
{
|
||||
return $this->zOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Z-offset
|
||||
*
|
||||
* @api
|
||||
* @param float $zOffset Z-offset
|
||||
* @return static
|
||||
*/
|
||||
public function setZOffset($zOffset)
|
||||
{
|
||||
$this->zOffset = (float)$zOffset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the focus Z-offset
|
||||
*
|
||||
* @api
|
||||
* @return float
|
||||
*/
|
||||
public function getFocusZOffset()
|
||||
{
|
||||
return $this->focusZOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the focus Z-offset
|
||||
*
|
||||
* @api
|
||||
* @param float $focusZOffset Focus Z-offset
|
||||
* @return static
|
||||
*/
|
||||
public function setFocusZOffset($focusZOffset)
|
||||
{
|
||||
$this->focusZOffset = (float)$focusZOffset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Style3d
|
||||
*
|
||||
* @param \DOMDocument $domDocument DOMDocument for which the Style3d should be rendered
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$style3dXml = $domDocument->createElement("style3d");
|
||||
$this->checkId();
|
||||
if ($this->styleId) {
|
||||
$style3dXml->setAttribute("id", $this->styleId);
|
||||
}
|
||||
if ($this->model) {
|
||||
$style3dXml->setAttribute("model", $this->model);
|
||||
}
|
||||
if ($this->thickness) {
|
||||
$style3dXml->setAttribute("thickness", $this->thickness);
|
||||
}
|
||||
if ($this->color) {
|
||||
$style3dXml->setAttribute("color", $this->color);
|
||||
}
|
||||
if ($this->focusColor) {
|
||||
$style3dXml->setAttribute("fcolor", $this->focusColor);
|
||||
}
|
||||
if ($this->lightColor) {
|
||||
$style3dXml->setAttribute("lightcolor", $this->lightColor);
|
||||
}
|
||||
if ($this->focusLightColor) {
|
||||
$style3dXml->setAttribute("flightcolor", $this->focusLightColor);
|
||||
}
|
||||
if ($this->yOffset) {
|
||||
$style3dXml->setAttribute("yoffset", $this->yOffset);
|
||||
}
|
||||
if ($this->focusYOffset) {
|
||||
$style3dXml->setAttribute("fyoffset", $this->focusYOffset);
|
||||
}
|
||||
if ($this->zOffset) {
|
||||
$style3dXml->setAttribute("zoffset", $this->zOffset);
|
||||
}
|
||||
if ($this->focusZOffset) {
|
||||
$style3dXml->setAttribute("fzoffset", $this->focusZOffset);
|
||||
}
|
||||
return $style3dXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Style3d XML element
|
||||
*
|
||||
* @param \DOMDocument $domDocument DOMDocument for which the Style3d XML element should be rendered
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$style3dXml = $domDocument->createElement($this->tagName);
|
||||
$this->checkId();
|
||||
if ($this->styleId) {
|
||||
$style3dXml->setAttribute('id', $this->styleId);
|
||||
}
|
||||
if ($this->model) {
|
||||
$style3dXml->setAttribute('model', $this->model);
|
||||
}
|
||||
if ($this->thickness) {
|
||||
$style3dXml->setAttribute('thickness', $this->thickness);
|
||||
}
|
||||
if ($this->color) {
|
||||
$style3dXml->setAttribute('color', $this->color);
|
||||
}
|
||||
if ($this->focusColor) {
|
||||
$style3dXml->setAttribute('fcolor', $this->focusColor);
|
||||
}
|
||||
if ($this->lightColor) {
|
||||
$style3dXml->setAttribute('lightcolor', $this->lightColor);
|
||||
}
|
||||
if ($this->focusLightColor) {
|
||||
$style3dXml->setAttribute('flightcolor', $this->focusLightColor);
|
||||
}
|
||||
if ($this->yOffset) {
|
||||
$style3dXml->setAttribute('yoffset', $this->yOffset);
|
||||
}
|
||||
if ($this->focusYOffset) {
|
||||
$style3dXml->setAttribute('fyoffset', $this->focusYOffset);
|
||||
}
|
||||
if ($this->zOffset) {
|
||||
$style3dXml->setAttribute('zoffset', $this->zOffset);
|
||||
}
|
||||
if ($this->focusZOffset) {
|
||||
$style3dXml->setAttribute('fzoffset', $this->focusZOffset);
|
||||
}
|
||||
return $style3dXml;
|
||||
}
|
||||
}
|
||||
|
@ -6,95 +6,133 @@ namespace FML\Stylesheet;
|
||||
* Class representing a ManiaLink Stylesheet
|
||||
*
|
||||
* @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 Stylesheet {
|
||||
/*
|
||||
* Protected properties
|
||||
*/
|
||||
protected $tagName = 'stylesheet';
|
||||
/** @var Style3d[] $styles3d */
|
||||
protected $styles3d = array();
|
||||
/** @var Mood $mood */
|
||||
protected $mood = null;
|
||||
class Stylesheet
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new Stylesheet object
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create() {
|
||||
return new static();
|
||||
}
|
||||
/**
|
||||
* @var Style3d[] $styles3d 3d Styles
|
||||
*/
|
||||
protected $styles3d = array();
|
||||
|
||||
/**
|
||||
* Add a new Style3d
|
||||
*
|
||||
* @param Style3d $style3d Style3d object
|
||||
* @return static
|
||||
*/
|
||||
public function addStyle3d(Style3d $style3d) {
|
||||
if (!in_array($style3d, $this->styles3d, true)) {
|
||||
array_push($this->styles3d, $style3d);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @var Mood $mood Mood
|
||||
*/
|
||||
protected $mood = null;
|
||||
|
||||
/**
|
||||
* Remove all Style3ds
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function removeStyles() {
|
||||
$this->styles3d = array();
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Create a new Stylesheet
|
||||
*
|
||||
* @api
|
||||
* @return static
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Mood object of the Stylesheet
|
||||
*
|
||||
* @param Mood $mood Mood object
|
||||
* @return static
|
||||
*/
|
||||
public function setMood(Mood $mood) {
|
||||
$this->mood = $mood;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get the Styles3d
|
||||
*
|
||||
* @api
|
||||
* @return Style3d[]
|
||||
*/
|
||||
public function getStyles3d()
|
||||
{
|
||||
return $this->styles3d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Mood object
|
||||
*
|
||||
* @param bool $createIfEmpty (optional) Whether the Mood object should be created if it's not set
|
||||
* @return \FML\Stylesheet\Mood
|
||||
*/
|
||||
public function getMood($createIfEmpty = true) {
|
||||
if (!$this->mood && $createIfEmpty) {
|
||||
$this->setMood(new Mood());
|
||||
}
|
||||
return $this->mood;
|
||||
}
|
||||
/**
|
||||
* Add a new Style3d
|
||||
*
|
||||
* @api
|
||||
* @param Style3d $style3d The Style3d to be added
|
||||
* @return static
|
||||
*/
|
||||
public function addStyle3d(Style3d $style3d)
|
||||
{
|
||||
if (!in_array($style3d, $this->styles3d, true)) {
|
||||
array_push($this->styles3d, $style3d);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all Style3ds
|
||||
*
|
||||
* @api
|
||||
* @return static
|
||||
*/
|
||||
public function removeAllStyles3d()
|
||||
{
|
||||
$this->styles3d = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Mood
|
||||
*
|
||||
* @api
|
||||
* @return Mood
|
||||
*/
|
||||
public function getMood()
|
||||
{
|
||||
return $this->mood;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Mood
|
||||
*
|
||||
* @api
|
||||
* @param Mood $mood Mood
|
||||
* @return static
|
||||
*/
|
||||
public function setMood(Mood $mood = null)
|
||||
{
|
||||
$this->mood = $mood;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Mood if necessary
|
||||
*
|
||||
* @api
|
||||
* @return Mood
|
||||
*/
|
||||
public function createMood()
|
||||
{
|
||||
if ($this->mood) {
|
||||
return $this->mood;
|
||||
}
|
||||
$mood = new Mood();
|
||||
$this->setMood($mood);
|
||||
return $this->mood;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Stylesheet
|
||||
*
|
||||
* @param \DOMDocument $domDocument DOMDocument for which the Stylesheet should be rendered
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument)
|
||||
{
|
||||
$stylesheetXml = $domDocument->createElement("stylesheet");
|
||||
if ($this->styles3d) {
|
||||
$stylesXml = $domDocument->createElement("frame3dstyles");
|
||||
$stylesheetXml->appendChild($stylesXml);
|
||||
foreach ($this->styles3d as $style3d) {
|
||||
$style3dXml = $style3d->render($domDocument);
|
||||
$stylesXml->appendChild($style3dXml);
|
||||
}
|
||||
}
|
||||
if ($this->mood) {
|
||||
$moodXml = $this->mood->render($domDocument);
|
||||
$stylesheetXml->appendChild($moodXml);
|
||||
}
|
||||
return $stylesheetXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Stylesheet XML element
|
||||
*
|
||||
* @param \DOMDocument $domDocument DOMDocument for which the Stylesheet XML element should be rendered
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function render(\DOMDocument $domDocument) {
|
||||
$stylesheetXml = $domDocument->createElement($this->tagName);
|
||||
if ($this->styles3d) {
|
||||
$stylesXml = $domDocument->createElement('frame3dstyles');
|
||||
$stylesheetXml->appendChild($stylesXml);
|
||||
foreach ($this->styles3d as $style3d) {
|
||||
$style3dXml = $style3d->render($domDocument);
|
||||
$stylesXml->appendChild($style3dXml);
|
||||
}
|
||||
}
|
||||
if ($this->mood) {
|
||||
$moodXml = $this->mood->render($domDocument);
|
||||
$stylesheetXml->appendChild($moodXml);
|
||||
}
|
||||
return $stylesheetXml;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user