Fix different interfaces elements positions when changing size settings
This commit is contained in:
@ -107,18 +107,18 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
// Config
|
||||
$pagerSize = 9.;
|
||||
$entryHeight = 5.;
|
||||
$pageMaxCount = floor(($height * 0.70) / $entryHeight);
|
||||
$pageMaxCount = floor(($height - 16) / $entryHeight);
|
||||
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
||||
$pagerPrev->setPosition($width * 0.5 - 12, $height * -0.5 + 5, 2);
|
||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = new Quad_Icons64x64_1();
|
||||
$frame->addChild($pagerNext);
|
||||
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||
$pagerNext->setPosition($width * 0.5 - 5, $height * -0.5 + 5, 2);
|
||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
|
||||
|
||||
@ -128,7 +128,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->addChild($pageCountLabel);
|
||||
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
||||
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
|
||||
$pageCountLabel->setPosition($width * 0.5 - 16, $height * -0.5 + 5, 1);
|
||||
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||
$pageCountLabel->setTextSize(2);
|
||||
|
||||
@ -161,25 +161,34 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
return strcmp($pluginClassA::getName(), $pluginClassB::getName());
|
||||
});
|
||||
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setY(-1);
|
||||
|
||||
$index = 0;
|
||||
$pageFrame = null;
|
||||
foreach ($pluginClasses as $index => $pluginClass) {
|
||||
foreach ($pluginClasses as $pluginClass) {
|
||||
/** @var Plugin $pluginClass */
|
||||
if ($index % $pageMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$posY = $height * 0.41;
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$active = $this->maniaControl->getPluginManager()->isPluginActive($pluginClass);
|
||||
|
||||
$pluginFrame = new Frame();
|
||||
$pageFrame->addChild($pluginFrame);
|
||||
$pluginFrame->setY($posY);
|
||||
$pluginFrame->setY($entryHeight * $index * -1);
|
||||
|
||||
$activeQuad = new Quad_Icons64x64_1();
|
||||
$pluginFrame->addChild($activeQuad);
|
||||
$activeQuad->setPosition($width * -0.45, -0.1, 1);
|
||||
$activeQuad->setPosition(2.5, -0.1, 1);
|
||||
$activeQuad->setSize($entryHeight * 0.9, $entryHeight * 0.9);
|
||||
if ($active) {
|
||||
$activeQuad->setSubStyle($activeQuad::SUBSTYLE_LvlGreen);
|
||||
@ -190,18 +199,18 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$nameLabel = new Label_Text();
|
||||
$pluginFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX($width * -0.4);
|
||||
$nameLabel->setSize($width * 0.5, $entryHeight);
|
||||
$nameLabel->setX(5);
|
||||
$nameLabel->setSize($width - 50, $entryHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setTextSize(2);
|
||||
$nameLabel->setText($pluginClass::getName());
|
||||
|
||||
$descriptionLabel = new Label();
|
||||
$pageFrame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::BOTTOM);
|
||||
$descriptionLabel->setPosition($width * -0.45, $height * -0.45);
|
||||
$descriptionLabel->setSize($width * 0.7, $entryHeight);
|
||||
$descriptionLabel->setTextSize(2);
|
||||
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP);
|
||||
$descriptionLabel->setPosition(3, $height * -1 + 16);
|
||||
$descriptionLabel->setSize($width - 30, 20);
|
||||
$descriptionLabel->setTextSize(1);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
$descriptionLabel->setVisible(false);
|
||||
$descriptionLabel->setMaxLines(5);
|
||||
@ -212,7 +221,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$quad = new Quad_Icons128x32_1();
|
||||
$pluginFrame->addChild($quad);
|
||||
$quad->setSubStyle($quad::SUBSTYLE_Settings);
|
||||
$quad->setX(15);
|
||||
$quad->setX($width - 45);
|
||||
$quad->setZ(1);
|
||||
$quad->setSize(5, 5);
|
||||
$quad->setAction(self::ACTION_PREFIX_SETTINGS . $pluginClass);
|
||||
@ -220,14 +229,12 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$statusChangeButton = new Label_Button();
|
||||
$pluginFrame->addChild($statusChangeButton);
|
||||
$statusChangeButton->setHorizontalAlign($statusChangeButton::RIGHT);
|
||||
$statusChangeButton->setX($width * 0.45);
|
||||
$statusChangeButton->setX($width - 6);
|
||||
$statusChangeButton->setStyle($statusChangeButton::STYLE_CardButtonSmall);
|
||||
if ($active) {
|
||||
$statusChangeButton->setTextPrefix('$f00');
|
||||
$statusChangeButton->setText('Deactivate');
|
||||
$statusChangeButton->setAction(self::ACTION_PREFIX_DISABLEPLUGIN . $pluginClass);
|
||||
} else {
|
||||
$statusChangeButton->setTextPrefix('a');
|
||||
$statusChangeButton->setText('Activate');
|
||||
$statusChangeButton->setAction(self::ACTION_PREFIX_ENABLEPLUGIN . $pluginClass);
|
||||
}
|
||||
@ -236,13 +243,13 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$quadUpdate = new Quad_Icons128x128_1();
|
||||
$pluginFrame->addChild($quadUpdate);
|
||||
$quadUpdate->setSubStyle($quadUpdate::SUBSTYLE_ProfileVehicle);
|
||||
$quadUpdate->setX($width / 2 - 3);
|
||||
$quadUpdate->setX($width - 3.5);
|
||||
$quadUpdate->setZ(2);
|
||||
$quadUpdate->setSize(5, 5);
|
||||
$quadUpdate->setAction(self::ACTION_PREFIX_UPDATEPLUGIN . $pluginClass);
|
||||
}
|
||||
|
||||
$posY -= $entryHeight;
|
||||
$index++;
|
||||
}
|
||||
|
||||
if ($pluginUpdates) {
|
||||
@ -275,18 +282,36 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$settings = $this->maniaControl->getSettingManager()->getSettingsByClass($settingClass);
|
||||
$isunlinkable = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getSettingManager(), SettingManager::SETTING_ALLOW_UNLINK_SERVER);
|
||||
|
||||
$posY = 0;
|
||||
$index = 0;
|
||||
$settingHeight = 5.;
|
||||
$pageSettingsMaxCount = floor(($height * 0.70) / $settingHeight);
|
||||
$pageFrame = null;
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setY(-8.);
|
||||
|
||||
if ($isunlinkable) {
|
||||
$pagesFrame->setX(5.); // move a bit the settings to diplay the padlocks
|
||||
$innerWidth = $width - 6;
|
||||
} else {
|
||||
$pagesFrame->setX(2.);
|
||||
$innerWidth = $width - 3;
|
||||
}
|
||||
|
||||
$innerHeight = $height - 8 - 10;
|
||||
$settingHeight = 5.;
|
||||
$valueWidth = $innerWidth * 0.3;
|
||||
$pageSettingsMaxCount = floor($innerHeight / $settingHeight);
|
||||
$index = 0;
|
||||
|
||||
$pageFrame = null;
|
||||
|
||||
//Headline Label
|
||||
$headLabel = new Label_Text();
|
||||
$frame->addChild($headLabel);
|
||||
$repositionnedFrame->addChild($headLabel);
|
||||
$headLabel->setHorizontalAlign($headLabel::LEFT);
|
||||
$headLabel->setPosition($width * -0.46, $height * 0.41);
|
||||
$headLabel->setSize($width * 0.6, $settingHeight);
|
||||
$headLabel->setPosition(3, -6);
|
||||
$headLabel->setSize($width - 6, $settingHeight);
|
||||
$headLabel->setStyle($headLabel::STYLE_TextCardSmall);
|
||||
$headLabel->setTextSize(3);
|
||||
$headLabel->setText($settingClass);
|
||||
@ -300,38 +325,37 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
foreach ($settings as $setting) {
|
||||
if ($index % $pageSettingsMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$posY = $height * 0.41 - $settingHeight * 1.5;
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$settingFrame = new Frame();
|
||||
$pageFrame->addChild($settingFrame);
|
||||
$settingFrame->setY($posY);
|
||||
$settingFrame->setY($settingHeight * $index * -1);
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$settingFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX($width * -0.46);
|
||||
$nameLabel->setSize($width * 0.6, $settingHeight);
|
||||
$nameLabel->setSize($innerWidth * 0.6, $settingHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setTextSize(2);
|
||||
$nameLabel->setText($setting->setting);
|
||||
$nameLabel->setTextColor('fff');
|
||||
|
||||
$descriptionLabel = new Label_Text();
|
||||
$pageFrame->addChild($descriptionLabel);
|
||||
$repositionnedFrame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
||||
$descriptionLabel->setPosition(-0.45 * $width, $height * -0.38);
|
||||
$descriptionLabel->setSize(0.9 * $width, $settingHeight);
|
||||
$descriptionLabel->setTextSize(2);
|
||||
$descriptionLabel->setPosition(3, $height * -1 + 10);
|
||||
$descriptionLabel->setSize($innerWidth - 6, $settingHeight);
|
||||
$descriptionLabel->setTextSize(1);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
$nameLabel->addTooltipLabelFeature($descriptionLabel, $setting->description);
|
||||
|
||||
if ($isunlinkable) {
|
||||
$quadlink = new Quad();
|
||||
$settingFrame->addChild($quadlink);
|
||||
$quadlink->setPosition(-0.48 * $width, 0.2, -0.01);
|
||||
$quadlink->setPosition(-2, 0.2);
|
||||
$quadlink->setSize(4, 4);
|
||||
$quadlink->setColorize("ccccccaa");
|
||||
$quadlink->setStyle("UICommon64_1");
|
||||
@ -342,15 +366,15 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
if ($setting->type === Setting::TYPE_BOOL) {
|
||||
// Boolean checkbox
|
||||
$quad = new Quad();
|
||||
$quad->setPosition($width * 0.33, 0, -0.01);
|
||||
$quad->setPosition($innerWidth - $valueWidth / 2, 0);
|
||||
$quad->setSize(4, 4);
|
||||
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $setting->index, $setting->value, $quad);
|
||||
$settingFrame->addChild($checkBox);
|
||||
} else if ($setting->type === Setting::TYPE_SET) {
|
||||
// SET value picker
|
||||
$label = new Label_Text();
|
||||
$label->setX($width * 0.33);
|
||||
$label->setSize($width * 0.3, $settingHeight * 0.9);
|
||||
$label->setPosition($innerWidth - $valueWidth / 2, 0);
|
||||
$label->setSize($valueWidth, $settingHeight * 0.9);
|
||||
$label->setStyle($label::STYLE_TextValueSmall);
|
||||
$label->setTextSize(1);
|
||||
$valuePicker = new ValuePicker(self::ACTION_PREFIX_SETTING . $setting->index, $setting->set, $setting->value, $label);
|
||||
@ -359,8 +383,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
// Value entry
|
||||
$entry = new Entry();
|
||||
$settingFrame->addChild($entry);
|
||||
$entry->setX($width * 0.33);
|
||||
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
||||
$entry->setPosition($innerWidth - $valueWidth / 2, 0);
|
||||
$entry->setSize($valueWidth, $settingHeight * 0.9);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setMaxLength(1000);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
@ -368,18 +392,16 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$entry->setDefault($setting->value);
|
||||
}
|
||||
|
||||
$posY -= $settingHeight;
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
$backButton = new Label_Button();
|
||||
$frame->addChild($backButton);
|
||||
$repositionnedFrame->addChild($backButton);
|
||||
$backButton->setStyle($backButton::STYLE_CardMain_Quit);
|
||||
$backButton->setHorizontalAlign($backButton::LEFT);
|
||||
$backButton->setScale(0.5);
|
||||
$backButton->setText('Back');
|
||||
$backButton->setPosition(-$width / 2 + 5, -$height / 2 + 5);
|
||||
$backButton->setPosition(5 , $height * -1 + 5);
|
||||
$backButton->setAction(self::ACTION_BACK_TO_PLUGINS);
|
||||
|
||||
if ($isunlinkable) {
|
||||
@ -389,8 +411,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
5,
|
||||
self::ACTION_PREFIX_MANAGE_SETTING_LINK . $settingClass
|
||||
);
|
||||
$frame->addChild($mapNameButton);
|
||||
$mapNameButton->setPosition(-$width / 2 + 60, $height * -0.45);
|
||||
$repositionnedFrame->addChild($mapNameButton);
|
||||
$mapNameButton->setPosition(60, $height * -1 + 5);
|
||||
}
|
||||
|
||||
return $frame;
|
||||
@ -410,10 +432,21 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
public function getManageSettingsLink(Frame $frame, $width, $height, Paging $paging, Player $player, $settingClass) {
|
||||
$settings = $this->maniaControl->getSettingManager()->getSettingsByClass($settingClass);
|
||||
|
||||
$posY = 0;
|
||||
$index = 0;
|
||||
$settingHeight = 5.;
|
||||
$pageSettingsMaxCount = floor(($height * 0.78) / $settingHeight);
|
||||
$repositionnedFrame = new Frame();
|
||||
$frame->addChild($repositionnedFrame);
|
||||
$repositionnedFrame->setPosition($width * -0.5, $height * 0.5);
|
||||
|
||||
$pagesFrame = new Frame();
|
||||
$repositionnedFrame->addChild($pagesFrame);
|
||||
$pagesFrame->setY(-8.);
|
||||
$pagesFrame->setX(5.);
|
||||
|
||||
$innerWidth = $width - 6;
|
||||
$innerHeight = $height - 8 - 10;
|
||||
$settingHeight = 5.;
|
||||
$pageSettingsMaxCount = floor($innerHeight / $settingHeight);
|
||||
$index = 0;
|
||||
|
||||
$pageFrame = null;
|
||||
|
||||
if (count($settings) > 64) {
|
||||
@ -423,10 +456,10 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
|
||||
//Headline Label
|
||||
$headLabel = new Label_Text();
|
||||
$frame->addChild($headLabel);
|
||||
$repositionnedFrame->addChild($headLabel);
|
||||
$headLabel->setHorizontalAlign($headLabel::LEFT);
|
||||
$headLabel->setPosition($width * -0.46, $height * 0.41);
|
||||
$headLabel->setSize($width * 0.6, $settingHeight);
|
||||
$headLabel->setPosition(3, -6);
|
||||
$headLabel->setSize($width - 6, $settingHeight);
|
||||
$headLabel->setStyle($headLabel::STYLE_TextCardSmall);
|
||||
$headLabel->setTextSize(3);
|
||||
$headLabel->setText($settingClass);
|
||||
@ -435,54 +468,51 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
foreach ($settings as $setting) {
|
||||
if ($index % $pageSettingsMaxCount === 0) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->addChild($pageFrame);
|
||||
$pagesFrame->addChild($pageFrame);
|
||||
$paging->addPageControl($pageFrame);
|
||||
$posY = $height * 0.41 - $settingHeight * 1.5;
|
||||
$index = 1;
|
||||
}
|
||||
|
||||
$settingFrame = new Frame();
|
||||
$pageFrame->addChild($settingFrame);
|
||||
$settingFrame->setY($posY);
|
||||
$settingFrame->setY($settingHeight * $index * -1);
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$settingFrame->addChild($nameLabel);
|
||||
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
||||
$nameLabel->setX($width * -0.46);
|
||||
$nameLabel->setSize($width * 0.6, $settingHeight);
|
||||
$nameLabel->setSize($innerWidth * 0.6, $settingHeight);
|
||||
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
||||
$nameLabel->setTextSize(2);
|
||||
$nameLabel->setText($setting->setting);
|
||||
$nameLabel->setTextColor('fff');
|
||||
|
||||
$descriptionLabel = new Label_Text();
|
||||
$pageFrame->addChild($descriptionLabel);
|
||||
$repositionnedFrame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
||||
$descriptionLabel->setPosition(-0.45 * $width, $height * -0.40);
|
||||
$descriptionLabel->setSize(0.9 * $width, $settingHeight);
|
||||
$descriptionLabel->setTextSize(2);
|
||||
$descriptionLabel->setPosition(3, $height * -1 + 10);
|
||||
$descriptionLabel->setSize($innerWidth - 6, $settingHeight);
|
||||
$descriptionLabel->setTextSize(1);
|
||||
$descriptionLabel->setTranslate(true);
|
||||
$nameLabel->addTooltipLabelFeature($descriptionLabel, $setting->description);
|
||||
|
||||
$quad = new Quad();
|
||||
$quad->setPosition($width * 0.33, 0.2, -0.01);
|
||||
$quad->setPosition($innerWidth - $innerWidth * 0.3 / 2, 0.2);
|
||||
$quad->setSize(4, 4);
|
||||
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING_LINK . $setting->index, $setting->linked, $quad);
|
||||
$checkBox->setEnabledDesign("UICommon64_1", "Padlock_light");
|
||||
$checkBox->setDisabledDesign("UICommon64_1", "Padlock_light");
|
||||
$settingFrame->addChild($checkBox);
|
||||
|
||||
$posY -= $settingHeight;
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
$backButton = new Label_Button();
|
||||
$frame->addChild($backButton);
|
||||
$repositionnedFrame->addChild($backButton);
|
||||
$backButton->setStyle($backButton::STYLE_CardMain_Quit);
|
||||
$backButton->setHorizontalAlign($backButton::LEFT);
|
||||
$backButton->setScale(0.5);
|
||||
$backButton->setText('Back');
|
||||
$backButton->setPosition(-$width / 2 + 5, -$height / 2 + 5);
|
||||
$backButton->setPosition(5 , $height * -1 + 5);
|
||||
$backButton->setAction(self::ACTION_PREFIX_SETTINGS . $settingClass);
|
||||
|
||||
return $frame;
|
||||
|
Reference in New Issue
Block a user