TrackManiaControl/application/core/Configurators/ManiaControlSettings.php

148 lines
3.4 KiB
PHP
Raw Normal View History

2014-01-05 19:00:11 +01:00
<?php
/**
* Class offering a Configurator for Script Settings
*
* @author steeffeen & kremsy
*/
namespace ManiaControl\Configurators;
2014-01-05 19:20:54 +01:00
use FML\Controls\Control;
2014-01-05 19:10:11 +01:00
use FML\Controls\Frame;
2014-01-05 19:20:54 +01:00
use FML\Controls\Label;
use FML\Controls\Labels\Label_Text;
use FML\Controls\Quads\Quad_Icons64x64_1;
2014-01-05 19:00:11 +01:00
use FML\Script\Script;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
class ManiaControlSettings implements ConfiguratorMenu{
/**
* Constants
*/
const TITLE = 'ManiaControl Settings';
/**
* Private Properties
*/
private $maniaControl = null;
/**
* Create a new Script Settings Instance
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
}
/**
* Get the Menu Title
*
* @return string
*/
public function getTitle() {
2014-01-05 19:20:54 +01:00
return self::TITLE;
2014-01-05 19:00:11 +01:00
}
/**
* Get the Configurator Menu Frame
*
* @param float $width
* @param float $height
* @param Script $script
* @return \FML\Controls\Frame
*/
public function getMenu($width, $height, Script $script) {
2014-01-05 19:20:54 +01:00
$pagesId = 'ManiaControlSettingsPages';
2014-01-05 19:10:11 +01:00
$frame = new Frame();
2014-01-05 19:20:54 +01:00
// Config
$pagerSize = 9.;
$settingHeight = 5.;
$labelTextSize = 2;
$pageMaxCount = 13;
//Pagers
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
$pagerPrev->setSize($pagerSize, $pagerSize);
$pagerPrev->setSubStyle(Quad_Icons64x64_1::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);
$script->addPager($pagerPrev, -1, $pagesId);
$script->addPager($pagerNext, 1, $pagesId);
$pageCountLabel = new Label();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign(Control::RIGHT);
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
$pageCountLabel->setStyle('TextTitle1');
$pageCountLabel->setTextSize(2);
$script->addPageLabel($pageCountLabel, $pagesId);
2014-01-05 19:10:11 +01:00
/** @var ManiaControl/SettingManager $this->maniaControl->settingManager */
$settings = $this->maniaControl->settingManager->getSettings();
2014-01-05 19:20:54 +01:00
$pageFrames = array();
$y = 0;
$index = 1;
2014-01-05 19:10:11 +01:00
foreach($settings as $setting){
2014-01-05 19:20:54 +01:00
if (!isset($pageFrame)) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height * 0.41;
$script->addPage($pageFrame, count($pageFrames), $pagesId);
}
$settingFrame = new Frame();
$pageFrame->add($settingFrame);
$settingFrame->setY($y);
$nameLabel = new Label_Text();
$settingFrame->add($nameLabel);
$nameLabel->setHAlign(Control::LEFT);
$nameLabel->setX($width * -0.46);
$nameLabel->setSize($width * 0.4, $settingHeight);
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
$nameLabel->setTextSize($labelTextSize);
$nameLabel->setText($setting->setting);
2014-01-05 19:10:11 +01:00
var_dump($setting);
2014-01-05 19:20:54 +01:00
$y -= $settingHeight;
if ($index % $pageMaxCount == $pageMaxCount - 1) {
unset($pageFrame);
}
2014-01-05 19:10:11 +01:00
2014-01-05 19:20:54 +01:00
$index++;
2014-01-05 19:10:11 +01:00
}
return $frame;
2014-01-05 19:00:11 +01:00
}
/**
* Save the Config Data
*
* @param array $configData
* @param Player $player
*/
public function saveConfigData(array $configData, Player $player) {
// TODO: Implement saveConfigData() method.
}
}