2013-11-28 03:47:08 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Manialinks;
|
|
|
|
|
2017-04-12 17:56:43 +02:00
|
|
|
use FML\Controls\Entry;
|
2014-01-28 16:54:23 +01:00
|
|
|
use FML\Controls\Frame;
|
2014-01-31 13:40:07 +01:00
|
|
|
use FML\Controls\Label;
|
2017-04-12 17:56:43 +02:00
|
|
|
use FML\Controls\Labels\Label_Button;
|
2014-01-28 19:28:17 +01:00
|
|
|
use FML\Controls\Labels\Label_Text;
|
2014-01-28 16:54:23 +01:00
|
|
|
use FML\Controls\Quad;
|
2013-12-29 10:03:58 +01:00
|
|
|
use FML\Controls\Quads\Quad_BgRaceScore2;
|
2014-07-05 02:47:16 +02:00
|
|
|
use FML\Controls\Quads\Quad_Bgs1InRace;
|
2017-04-12 17:56:43 +02:00
|
|
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
2014-01-28 16:54:23 +01:00
|
|
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
2020-04-21 17:57:36 +02:00
|
|
|
|
2014-04-27 16:22:12 +02:00
|
|
|
use FML\Script\Features\Paging;
|
2014-01-28 19:28:17 +01:00
|
|
|
use FML\Script\Script;
|
2017-03-26 19:44:55 +02:00
|
|
|
use ManiaControl\General\UsageInformationAble;
|
|
|
|
use ManiaControl\General\UsageInformationTrait;
|
2013-11-28 03:47:08 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
|
|
|
|
/**
|
2014-04-12 12:14:37 +02:00
|
|
|
* Class managing default Control Styles
|
2013-11-28 03:47:08 +01:00
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2020-01-22 10:39:35 +01:00
|
|
|
* @copyright 2014-2020 ManiaControl Team
|
2014-05-02 17:50:30 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
2017-03-26 19:44:55 +02:00
|
|
|
class StyleManager implements UsageInformationAble {
|
|
|
|
use UsageInformationTrait;
|
2017-04-01 18:48:36 +02:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2013-11-28 03:47:08 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
2014-01-15 22:07:09 +01:00
|
|
|
const SETTING_LABEL_DEFAULT_STYLE = 'Default Label Style';
|
|
|
|
const SETTING_QUAD_DEFAULT_STYLE = 'Default Quad Style';
|
2013-11-28 03:47:08 +01:00
|
|
|
const SETTING_QUAD_DEFAULT_SUBSTYLE = 'Default Quad SubStyle';
|
2013-12-29 10:03:58 +01:00
|
|
|
|
2014-01-15 22:07:09 +01:00
|
|
|
const SETTING_MAIN_WIDGET_DEFAULT_STYLE = 'Main Widget Default Quad Style';
|
2013-12-29 10:03:58 +01:00
|
|
|
const SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE = 'Main Widget Default Quad SubStyle';
|
2014-01-15 22:07:09 +01:00
|
|
|
const SETTING_LIST_WIDGETS_WIDTH = 'List Widgets Width';
|
|
|
|
const SETTING_LIST_WIDGETS_HEIGHT = 'List Widgets Height';
|
|
|
|
|
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-07-25 16:28:47 +02:00
|
|
|
* Private properties
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
2014-08-02 22:31:46 +02:00
|
|
|
/** @var ManiaControl $maniaControl */
|
2013-11-28 03:47:08 +01:00
|
|
|
private $maniaControl = null;
|
|
|
|
|
|
|
|
/**
|
2014-08-02 22:31:46 +02:00
|
|
|
* Construct a new style manager instance
|
2013-11-28 03:47:08 +01:00
|
|
|
*
|
2014-01-15 22:07:09 +01:00
|
|
|
* @param ManiaControl $maniaControl
|
2013-11-28 03:47:08 +01:00
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2014-01-15 22:07:09 +01:00
|
|
|
|
2014-08-03 01:34:18 +02:00
|
|
|
// Settings
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LABEL_DEFAULT_STYLE, Label_Text::STYLE_TextTitle1);
|
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_QUAD_DEFAULT_STYLE, Quad_Bgs1InRace::STYLE);
|
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE, Quad_Bgs1InRace::SUBSTYLE_BgTitleShadow);
|
2013-12-29 10:03:58 +01:00
|
|
|
|
2014-07-05 02:47:16 +02:00
|
|
|
// Main Widget
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE, Quad_BgRaceScore2::STYLE);
|
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE, Quad_BgRaceScore2::SUBSTYLE_HandleSelectable);
|
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LIST_WIDGETS_WIDTH, 150.);
|
|
|
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LIST_WIDGETS_HEIGHT, 80.);
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the default label style
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDefaultLabelStyle() {
|
2014-08-13 11:05:52 +02:00
|
|
|
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_LABEL_DEFAULT_STYLE);
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the default quad style
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDefaultQuadStyle() {
|
2014-08-13 11:05:52 +02:00
|
|
|
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_QUAD_DEFAULT_STYLE);
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the default quad substyle
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDefaultQuadSubstyle() {
|
2014-08-13 11:05:52 +02:00
|
|
|
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_QUAD_DEFAULT_SUBSTYLE);
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|
2013-12-29 10:03:58 +01:00
|
|
|
|
|
|
|
/**
|
2014-05-02 17:50:30 +02:00
|
|
|
* Gets the Default Description Label
|
2013-12-29 10:03:58 +01:00
|
|
|
*
|
2014-07-05 02:47:16 +02:00
|
|
|
* @return \FML\Controls\Label
|
2013-12-29 10:03:58 +01:00
|
|
|
*/
|
2014-05-02 17:50:30 +02:00
|
|
|
public function getDefaultDescriptionLabel() {
|
|
|
|
$width = $this->getListWidgetsWidth();
|
|
|
|
$height = $this->getListWidgetsHeight();
|
2013-12-29 10:03:58 +01:00
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
// Predefine Description Label
|
|
|
|
$descriptionLabel = new Label();
|
2024-07-13 14:47:11 +02:00
|
|
|
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP)->setPosition($width * -0.5 + 10, $height * -0.5 + 5)->setZ(1)->setSize($width * 0.7, 4)->setTextSize(1)->setVisible(false);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
return $descriptionLabel;
|
2013-12-29 10:03:58 +01:00
|
|
|
}
|
|
|
|
|
2017-05-09 17:04:14 +02:00
|
|
|
|
2017-04-12 17:56:43 +02:00
|
|
|
/**
|
|
|
|
* Gets the default buttons and textbox for a map search
|
|
|
|
*
|
2017-05-09 17:04:14 +02:00
|
|
|
* @param $actionMapNameSearch
|
|
|
|
* @param $actionAuthorSearch
|
|
|
|
* @param null $actionReset
|
2017-04-12 17:56:43 +02:00
|
|
|
* @return \FML\Controls\Frame
|
|
|
|
*/
|
2022-04-13 10:47:50 +02:00
|
|
|
public function getDefaultMapSearch($actionMapNameSearch, $actionAuthorSearch, $actionReset = null, $entryvalue = "") {
|
2017-04-12 17:56:43 +02:00
|
|
|
$width = $this->getListWidgetsWidth();
|
|
|
|
|
|
|
|
$frame = new Frame();
|
|
|
|
|
2023-09-08 12:19:12 +02:00
|
|
|
$posX = -$width / 2 + 5;
|
|
|
|
|
2017-04-12 17:56:43 +02:00
|
|
|
$label = new Label_Text();
|
|
|
|
$frame->addChild($label);
|
2023-09-08 12:19:12 +02:00
|
|
|
$label->setPosition($posX, 0);
|
2017-04-12 17:56:43 +02:00
|
|
|
$label->setHorizontalAlign($label::LEFT);
|
2022-04-14 02:49:42 +02:00
|
|
|
$label->setTextSize(1);
|
2017-04-12 17:56:43 +02:00
|
|
|
$label->setText('Search: ');
|
|
|
|
|
2023-09-08 12:19:12 +02:00
|
|
|
$posX += 10;
|
|
|
|
|
2017-04-12 17:56:43 +02:00
|
|
|
$entry = new Entry();
|
|
|
|
$frame->addChild($entry);
|
|
|
|
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
|
|
|
$entry->setHorizontalAlign($entry::LEFT);
|
2023-09-08 12:19:12 +02:00
|
|
|
$entry->setPosition($posX, 0);
|
2017-04-12 17:56:43 +02:00
|
|
|
$entry->setTextSize(1);
|
2022-04-13 10:47:50 +02:00
|
|
|
$entry->setSize($width * 0.28, 4);
|
2017-04-12 17:56:43 +02:00
|
|
|
$entry->setName('SearchString');
|
2022-04-13 10:47:50 +02:00
|
|
|
$entry->setDefault($entryvalue);
|
2017-04-12 17:56:43 +02:00
|
|
|
|
2023-09-08 12:19:12 +02:00
|
|
|
$posX += $width * 0.28 + 10;
|
|
|
|
|
2017-05-07 20:46:12 +02:00
|
|
|
if ($actionReset) {
|
2020-04-24 18:52:18 +02:00
|
|
|
$quad = new Quad_Icons64x64_1();
|
2017-05-07 20:46:12 +02:00
|
|
|
$frame->addChild($quad);
|
|
|
|
$quad->setSubStyle($quad::SUBSTYLE_QuitRace);
|
|
|
|
$quad->setColorize('aaa');
|
|
|
|
$quad->setSize(5, 5);
|
2023-09-08 12:19:12 +02:00
|
|
|
$quad->setPosition($posX - 12, 0);
|
2017-05-07 20:46:12 +02:00
|
|
|
$quad->setZ(1);
|
|
|
|
$quad->setAction($actionReset);
|
2020-04-24 18:52:18 +02:00
|
|
|
}
|
2017-05-07 20:46:12 +02:00
|
|
|
|
2017-04-12 17:56:43 +02:00
|
|
|
//Search for Map-Name
|
2020-05-07 18:39:27 +02:00
|
|
|
$mapNameButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
|
|
|
|
'MapName',
|
|
|
|
18,
|
|
|
|
5,
|
|
|
|
$actionMapNameSearch
|
|
|
|
);
|
|
|
|
$frame->addChild($mapNameButton);
|
2023-09-08 12:19:12 +02:00
|
|
|
$mapNameButton->setX($posX);
|
|
|
|
|
|
|
|
$posX += 20;
|
2017-04-12 17:56:43 +02:00
|
|
|
|
|
|
|
//Search for Author
|
2020-05-07 18:39:27 +02:00
|
|
|
$authorButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
|
|
|
|
'Author',
|
|
|
|
18,
|
|
|
|
5,
|
|
|
|
$actionAuthorSearch
|
|
|
|
);
|
|
|
|
$frame->addChild($authorButton);
|
2023-09-08 12:19:12 +02:00
|
|
|
$authorButton->setX($posX);
|
2017-04-12 17:56:43 +02:00
|
|
|
|
|
|
|
return $frame;
|
|
|
|
}
|
|
|
|
|
2013-12-29 10:03:58 +01:00
|
|
|
/**
|
2014-05-13 17:59:37 +02:00
|
|
|
* Get the Default List Widgets Width
|
2013-12-29 10:03:58 +01:00
|
|
|
*
|
2014-07-05 02:47:16 +02:00
|
|
|
* @return float
|
2013-12-29 10:03:58 +01:00
|
|
|
*/
|
2014-01-15 22:07:09 +01:00
|
|
|
public function getListWidgetsWidth() {
|
2014-08-13 11:05:52 +02:00
|
|
|
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_LIST_WIDGETS_WIDTH);
|
2013-12-29 10:03:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the default list widget height
|
|
|
|
*
|
2014-07-05 02:47:16 +02:00
|
|
|
* @return float
|
2013-12-29 10:03:58 +01:00
|
|
|
*/
|
2014-01-15 22:07:09 +01:00
|
|
|
public function getListWidgetsHeight() {
|
2014-08-13 11:05:52 +02:00
|
|
|
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_LIST_WIDGETS_HEIGHT);
|
2013-12-29 10:03:58 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 16:54:23 +01:00
|
|
|
/**
|
|
|
|
* Builds the Default List Frame
|
|
|
|
*
|
2014-07-05 02:47:16 +02:00
|
|
|
* @param mixed $script
|
|
|
|
* @param mixed $paging
|
|
|
|
* @return \FML\Controls\Frame
|
2014-01-28 16:54:23 +01:00
|
|
|
*/
|
2014-07-05 02:47:16 +02:00
|
|
|
public function getDefaultListFrame($script = null, $paging = null) {
|
2014-05-02 17:50:30 +02:00
|
|
|
$args = func_get_args();
|
2014-04-27 18:59:21 +02:00
|
|
|
$script = null;
|
|
|
|
$paging = null;
|
|
|
|
foreach ($args as $arg) {
|
|
|
|
if ($arg instanceof Script) {
|
|
|
|
$script = $arg;
|
|
|
|
}
|
|
|
|
if ($arg instanceof Paging) {
|
|
|
|
$paging = $arg;
|
|
|
|
}
|
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-01-28 16:54:23 +01:00
|
|
|
$width = $this->getListWidgetsWidth();
|
|
|
|
$height = $this->getListWidgetsHeight();
|
|
|
|
$quadStyle = $this->getDefaultMainWindowStyle();
|
|
|
|
$quadSubstyle = $this->getDefaultMainWindowSubStyle();
|
|
|
|
|
|
|
|
// mainframe
|
|
|
|
$frame = new Frame();
|
2017-05-09 17:04:14 +02:00
|
|
|
$frame->setSize($width, $height)->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE);
|
2015-02-19 11:24:37 +01:00
|
|
|
|
2014-01-28 16:54:23 +01:00
|
|
|
// Background Quad
|
|
|
|
$backgroundQuad = new Quad();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($backgroundQuad);
|
2014-08-13 11:05:52 +02:00
|
|
|
$backgroundQuad->setZ(-2)->setSize($width, $height)->setStyles($quadStyle, $quadSubstyle);
|
2014-01-28 16:54:23 +01:00
|
|
|
|
|
|
|
// Add Close Quad (X)
|
|
|
|
$closeQuad = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($closeQuad);
|
2017-05-07 19:35:53 +02:00
|
|
|
$closeQuad->setPosition($width / 2 - 3, $height / 2 - 3, 3)->setSize(6, 6)->setSubStyle($closeQuad::SUBSTYLE_QuitRace)->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
2014-01-28 16:54:23 +01:00
|
|
|
|
2014-04-27 18:59:21 +02:00
|
|
|
if ($script) {
|
2014-01-28 19:28:17 +01:00
|
|
|
$pagerSize = 6.;
|
|
|
|
$pagerPrev = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pagerPrev);
|
2024-07-13 14:47:11 +02:00
|
|
|
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
|
|
|
$pagerPrev->setSize($pagerSize, $pagerSize);
|
|
|
|
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
2014-01-28 19:28:17 +01:00
|
|
|
|
|
|
|
$pagerNext = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pagerNext);
|
2024-07-13 14:47:11 +02:00
|
|
|
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
|
|
|
$pagerNext->setSize($pagerSize, $pagerSize);
|
|
|
|
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
2014-01-28 19:28:17 +01:00
|
|
|
|
|
|
|
$pageCountLabel = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pageCountLabel);
|
2024-07-13 14:47:11 +02:00
|
|
|
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
|
|
|
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
|
|
|
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
|
|
|
$pageCountLabel->setTextSize(1);
|
2014-07-05 02:47:16 +02:00
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
if ($paging) {
|
2024-07-13 14:47:11 +02:00
|
|
|
$paging->addButtonControl($pagerNext);
|
|
|
|
$paging->addButtonControl($pagerPrev);
|
|
|
|
$paging->setLabel($pageCountLabel);
|
2014-05-02 17:50:30 +02:00
|
|
|
}
|
2014-01-28 19:28:17 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 16:54:23 +01:00
|
|
|
return $frame;
|
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the default main window style
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDefaultMainWindowStyle() {
|
2014-08-13 11:05:52 +02:00
|
|
|
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAIN_WIDGET_DEFAULT_STYLE);
|
2014-05-02 17:50:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the default main window substyle
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDefaultMainWindowSubStyle() {
|
2014-08-13 11:05:52 +02:00
|
|
|
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAIN_WIDGET_DEFAULT_SUBSTYLE);
|
2014-05-02 17:50:30 +02:00
|
|
|
}
|
2013-11-28 03:47:08 +01:00
|
|
|
}
|