improved: method chaining, phpdoc, constants access, setting value types

This commit is contained in:
steeffeen 2014-07-05 02:47:16 +02:00
parent f037392acf
commit 87f4d10ea4

View File

@ -7,6 +7,7 @@ use FML\Controls\Label;
use FML\Controls\Labels\Label_Text;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_BgRaceScore2;
use FML\Controls\Quads\Quad_Bgs1InRace;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Script\Features\Paging;
use FML\Script\Script;
@ -48,22 +49,22 @@ class StyleManager {
$this->maniaControl = $maniaControl;
// Init settings
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LABEL_DEFAULT_STYLE, 'TextTitle1');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_QUAD_DEFAULT_STYLE, 'Bgs1InRace');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE, 'BgTitleShadow');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LABEL_DEFAULT_STYLE, Label_Text::STYLE_TextTitle1);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_QUAD_DEFAULT_STYLE, Quad_Bgs1InRace::STYLE);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE, Quad_Bgs1InRace::SUBSTYLE_BgTitleShadow);
// Main Widget
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE, Quad_BgRaceScore2::STYLE);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE, Quad_BgRaceScore2::SUBSTYLE_HandleSelectable);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LIST_WIDGETS_WIDTH, '150');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LIST_WIDGETS_HEIGHT, '80');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_ICON_DEFAULT_OFFSET_SM, '20');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LIST_WIDGETS_WIDTH, 150.);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_LIST_WIDGETS_HEIGHT, 80.);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_ICON_DEFAULT_OFFSET_SM, 20.);
}
/**
* Get the default Icon Offset for shootmania
*
* @return string
* @return float
*/
public function getDefaultIconOffsetSM() {
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ICON_DEFAULT_OFFSET_SM);
@ -99,7 +100,7 @@ class StyleManager {
/**
* Gets the Default Description Label
*
* @return Label
* @return \FML\Controls\Label
*/
public function getDefaultDescriptionLabel() {
$width = $this->getListWidgetsWidth();
@ -107,11 +108,11 @@ class StyleManager {
// Predefine Description Label
$descriptionLabel = new Label();
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP);
$descriptionLabel->setPosition(-$width / 2 + 10, -$height / 2 + 5);
$descriptionLabel->setSize($width * 0.7, 4);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setVisible(false);
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP)
->setPosition($width * -0.5 + 10, $height * -0.5 + 5)
->setSize($width * 0.7, 4)
->setTextSize(2)
->setVisible(false);
return $descriptionLabel;
}
@ -119,7 +120,7 @@ class StyleManager {
/**
* Get the Default List Widgets Width
*
* @return string
* @return float
*/
public function getListWidgetsWidth() {
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_LIST_WIDGETS_WIDTH);
@ -128,7 +129,7 @@ class StyleManager {
/**
* Get the default list widget height
*
* @return string
* @return float
*/
public function getListWidgetsHeight() {
return $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_LIST_WIDGETS_HEIGHT);
@ -137,9 +138,11 @@ class StyleManager {
/**
* Builds the Default List Frame
*
* @return Frame $frame
* @param mixed $script
* @param mixed $paging
* @return \FML\Controls\Frame
*/
public function getDefaultListFrame() {
public function getDefaultListFrame($script = null, $paging = null) {
$args = func_get_args();
$script = null;
$paging = null;
@ -159,50 +162,49 @@ class StyleManager {
// mainframe
$frame = new Frame();
$frame->setSize($width, $height);
$frame->setPosition(0, 0, 35); //TODO place before scoreboards
$frame->setSize($width, $height)
->setZ(35); //TODO place before scoreboards
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setZ(-1)
->setSize($width, $height)
->setStyles($quadStyle, $quadSubstyle);
// Add Close Quad (X)
$closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad);
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3);
$closeQuad->setSize(6, 6);
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3)
->setSize(6, 6)
->setSubStyle($closeQuad::SUBSTYLE_QuitRace)
->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
if ($script) {
$pagerSize = 6.;
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2);
$pagerPrev->setSize($pagerSize, $pagerSize);
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2)
->setSize($pagerSize, $pagerSize)
->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
$pagerNext = new Quad_Icons64x64_1();
$frame->add($pagerNext);
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
if ($paging) {
$paging->addButton($pagerNext);
$paging->addButton($pagerPrev);
}
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2)
->setSize($pagerSize, $pagerSize)
->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT);
$pageCountLabel->setPosition($width * 0.40, $height * -0.44, 1);
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
$pageCountLabel->setTextSize(1.3);
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)
->setPosition($width * 0.40, $height * -0.44, 1)
->setStyle($pageCountLabel::STYLE_TextTitle1)
->setTextSize(1.3);
if ($paging) {
$paging->setLabel($pageCountLabel);
$paging->addButton($pagerNext)
->addButton($pagerPrev)
->setLabel($pageCountLabel);
}
}