folderstructure change

This commit is contained in:
kremsy
2014-02-18 15:54:02 +01:00
committed by Steffen Schröder
parent 043c85fa97
commit 570b32fff8
109 changed files with 1 additions and 0 deletions

View File

@ -0,0 +1,311 @@
<?php
namespace FML\Stylesheet;
// Warning: The mood class isn't fully supported yet!
// Missing attributes: LDir1..
/**
* Class representing a Stylesheets Mood
*
* @author steeffeen
*/
class Mood {
/*
* Protected Properties
*/
protected $tagName = 'mood';
protected $lAmbient_LinearRgb = '';
protected $cloudsRgbMinLinear = '';
protected $cloudsRgbMaxLinear = '';
protected $lDir0_LinearRgb = '';
protected $lDir0_Intens = 1.;
protected $lDir0_DirPhi = 0.;
protected $lDir0_DirTheta = 0.;
protected $lBall_LinearRgb = '';
protected $lBall_Intensity = 1.;
protected $lBall_Radius = 0.;
protected $fogColorSrgb = '';
protected $selfIllumColor = '';
protected $skyGradientV_Scale = 1.;
protected $skyGradientKeys = array();
/**
* Create a new Mood Object
*
* @return \FML\Elements\Mood
*/
public static function create() {
$mood = new Mood();
return $mood;
}
/**
* Construct a new Mood Object
*/
public function __construct() {
}
/**
* 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 \FML\Stylesheet\Mood
*/
public function setLightAmbientColor($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$this->lAmbient_LinearRgb = "{$red} {$green} {$blue}";
return $this;
}
/**
* 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 \FML\Stylesheet\Mood
*/
public function setCloudsColorMin($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$this->cloudsRgbMinLinear = "{$red} {$green} {$blue}";
return $this;
}
/**
* 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 \FML\Stylesheet\Mood
*/
public function setCloudsColorMax($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$this->cloudsRgbMaxLinear = "{$red} {$green} {$blue}";
return $this;
}
/**
* 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 \FML\Stylesheet\Mood
*/
public function setLight0Color($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$this->lDir0_LinearRgb = "{$red} {$green} {$blue}";
return $this;
}
/**
* Set Intensity of Light Source 0
*
* @param float $intensity Light Intensity
* @return \FML\Stylesheet\Mood
*/
public function setLight0Intensity($intensity) {
$this->lDir0_Intens = (float) $intensity;
return $this;
}
/**
* Set Phi-Angle of Light Source 0
*
* @param float $phiAngle Phi-Angle
* @return \FML\Stylesheet\Mood
*/
public function setLight0PhiAngle($phiAngle) {
$this->lDir0_DirPhi = (float) $phiAngle;
return $this;
}
/**
* Set Theta-Angle of Light Source 0
*
* @param float $thetaAngle Theta-Angle
* @return \FML\Stylesheet\Mood
*/
public function setLight0ThetaAngle($thetaAngle) {
$this->lDir0_DirTheta = (float) $thetaAngle;
return $this;
}
/**
* Set Light Ball Color
*
* @param float $red Red Color Value
* @param float $green Green Color Value
* @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood
*/
public function setLightBallColor($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$this->lBall_LinearRgb = "{$red} {$green} {$blue}";
return $this;
}
/**
* Set Light Ball Intensity
*
* @param float $intensity Light Ball Intensity
* @return \FML\Stylesheet\Mood
*/
public function setLightBallIntensity($intensity) {
$this->lBall_Intens = (float) $intensity;
return $this;
}
/**
* Set Light Ball Radius
*
* @param float $radius Light Ball Radius
* @return \FML\Stylesheet\Mood
*/
public function setLightBallRadius($radius) {
$this->lBall_Radius = (float) $radius;
return $this;
}
/**
* Set Fog Color
*
* @param float $red Red Color Value
* @param float $green Green Color Value
* @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood
*/
public function setFogColor($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$this->fogColorSrgb = "{$red} {$green} {$blue}";
return $this;
}
/**
* Set Self Illumination Color
*
* @param float $red Red Color Value
* @param float $green Green Color Value
* @param float $blue Blue Color Value
* @return \FML\Stylesheet\Mood
*/
public function setSelfIllumColor($red, $green, $blue) {
$red = (float) $red;
$green = (float) $green;
$blue = (float) $blue;
$this->selfIllumColor = "{$red} {$green} {$blue}";
return $this;
}
/**
* Set Sky Gradient Scale
*
* @param float $vScale Gradient Scale Scale
* @return \FML\Stylesheet\Mood
*/
public function setSkyGradientScale($scale) {
$this->skyGradientV_Scale = (float) $scale;
return $this;
}
/**
* Add a Key for the SkyGradient
*
* @param float $x Scale Value
* @param string $color Gradient Color
* @return \FML\Stylesheet\Mood
*/
public function addSkyGradientKey($x, $color) {
$x = (float) $x;
$color = (string) $color;
$gradientKey = array('x' => $x, 'color' => $color);
array_push($this->skyGradientKeys, $gradientKey);
return $this;
}
/**
* Remove all SkyGradient Keys
*
* @return \FML\Stylesheet\Mood
*/
public function removeSkyGradientKeys() {
$this->skyGradientKeys = array();
return $this;
}
/**
* 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_Intens) {
$moodXml->setAttribute('LBall_Intens', $this->lBall_Intens);
}
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;
}
}

View File

@ -0,0 +1,245 @@
<?php
namespace FML\Stylesheet;
/**
* Class representing a specific Style3d
*
* @author steeffeen
*/
class Style3d {
/*
* Constants
*/
const MODEL_Box = 'Box';
const MODEL_Button = 'Button';
const MODEL_ButtonH = 'ButtonH';
const MODEL_Title = 'Title';
const MODEL_Window = 'Window';
/*
* Protected Properties
*/
protected $tagName = 'style3d';
protected $id = '';
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.;
/**
* Create a new Style3d Object
*
* @return \FML\Elements\Style3d
*/
public static function create() {
$style3d = new Style3d();
return $style3d;
}
/**
* Construct a new Style3d Object
*
* @param string $id (optional) Style Id
*/
public function __construct($id = null) {
if ($id !== null) {
$this->setId($id);
}
}
/**
* Set Style Id
*
* @param string $id Style Id
* @return \FML\Stylesheet\Style3d
*/
public function setId($id) {
$this->id = (string) $id;
return $this;
}
/**
* Check for Id and assign one if necessary
*
* @return \FML\Stylesheet\Style3d
*/
public function checkId() {
if (!$this->id) {
$this->id = uniqid();
}
return $this;
}
/**
* Get Style Id
*
* @return string
*/
public function getId() {
return $this->id;
}
/**
* Set Model
*
* @param string $model Style Model
* @return \FML\Stylesheet\Style3d
*/
public function setModel($model) {
$this->model = (string) $model;
return $this;
}
/**
* Set Thickness
*
* @param float $thickness Style Thickness
* @return \FML\Stylesheet\Style3d
*/
public function setThickness($thickness) {
$this->thickness = (float) $thickness;
return $this;
}
/**
* Set Color
*
* @param string $color Style Color
* @return \FML\Stylesheet\Style3d
*/
public function setColor($color) {
$this->color = (string) $color;
return $this;
}
/**
* Set Focus Color
*
* @param string $focusColor Style Focus Color
* @return \FML\Stylesheet\Style3d
*/
public function setFocusColor($focusColor) {
$this->focusColor = (string) $focusColor;
return $this;
}
/**
* Set Light Color
*
* @param string $lightColor Light Color
* @return \FML\Stylesheet\Style3d
*/
public function setLightColor($lightColor) {
$this->lightColor = (string) $lightColor;
return $this;
}
/**
* Set Focus Light Color
*
* @param string $focusLightColor Focus Light Color
* @return \FML\Stylesheet\Style3d
*/
public function setFocusLightColor($focusLightColor) {
$this->focusLightColor = (string) $focusLightColor;
return $this;
}
/**
* Set Y-Offset
*
* @param flaot $yOffset Y-Offset
* @return \FML\Stylesheet\Style3d
*/
public function setYOffset($yOffset) {
$this->yOffset = (float) $yOffset;
return $this;
}
/**
* Set Focus Y-Offset
*
* @param float $focusYOffset Focus Y-Offset
* @return \FML\Stylesheet\Style3d
*/
public function setFocusYOffset($focusYOffset) {
$this->focusYOffset = (float) $focusYOffset;
return $this;
}
/**
* Set Z-Offset
*
* @param float $zOffset Z-Offset
* @return \FML\Stylesheet\Style3d
*/
public function setZOffset($zOffset) {
$this->zOffset = (float) $zOffset;
return $this;
}
/**
* Set Focus Z-Offset
*
* @param float $focusZOffset Focus Z-Offset
* @return \FML\Stylesheet\Style3d
*/
public function setFocusZOffset($focusZOffset) {
$this->focusZOffset = (float) $focusZOffset;
return $this;
}
/**
* 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->id) {
$style3dXml->setAttribute('id', $this->id);
}
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;
}
}

View File

@ -0,0 +1,103 @@
<?php
namespace FML\Stylesheet;
/**
* Class representing the ManiaLinks Stylesheet
*
* @author steeffeen
*/
class Stylesheet {
/*
* Protected Properties
*/
protected $tagName = 'stylesheet';
protected $styles3d = array();
protected $mood = null;
/**
* Create a new Stylesheet Object
*
* @return \FML\Elements\Stylesheet
*/
public static function create() {
$stylesheet = new Stylesheet();
return $stylesheet;
}
/**
* Construct a new Stylesheet Object
*/
public function __construct() {
}
/**
* Add a new Style3d
*
* @param Style3d $style3d The Style3d to add
* @return \FML\Stylesheet\Frame3dStyles
*/
public function addStyle3d(Style3d $style3d) {
if (!in_array($style3d, $this->styles3d, true)) {
array_push($this->styles3d, $style3d);
}
return $this;
}
/**
* Remove all Styles
*
* @return \FML\Stylesheet\Frame3dStyles
*/
public function removeStyles() {
$this->styles3d = array();
return $this;
}
/**
* Set the Mood Object of the Stylesheet
*
* @param Mood $mood Mood Object
* @return \FML\Stylesheet\Stylesheet
*/
public function setMood(Mood $mood) {
$this->mood = $mood;
return $this;
}
/**
* Get the Mood Object
*
* @param bool $createIfEmpty (optional) Whether the Mood Object should be created if it's not set yet
* @return \FML\Stylesheet\Mood
*/
public function getMood($createIfEmpty = true) {
if (!$this->mood && $createIfEmpty) {
$this->mood = new Mood();
}
return $this->mood;
}
/**
* 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;
}
}