Unified Creations of round Text-Buttons

This commit is contained in:
Alexander Nell 2020-05-07 18:39:27 +02:00
parent 860678e57f
commit 67c9180f9c
5 changed files with 186 additions and 194 deletions

View File

@ -1,18 +1,31 @@
###v0.254###
#Additions
- added first support of Legacy-Modes
#Bug Fixes
- solved Finish-/Lap-Callback not getting triggered when Waypoint-Callback is not registered
#Changes
- additional Waypoint-Callback on Finish-/Lap-Callback
- renamed all occurrences of Script-Settings to GameMode-Settings
- includes a renamed database
- unified Creations of round Text-Buttons
###v0.253###
#Changes
- //restart got replaced by //reboot
- Unified Creations of a Karma-Gauge in new Manialinks\ElementBuilder
- unified Creations of a Karma-Gauge in new Manialinks\ElementBuilder
###v0.252###
#Additions
- Ingame-Changelog
- New customizations for Join&Leave-Messages
- Symbolic Link resolving in ServerManager
- new customizations for Join&Leave-Messages
- symbolic Link resolving in ServerManager
- Times in Map Widget
#Bug Fixes
- GReplay for Dedimania-Records not being sent
- non-numeric value warning on self-triggered debug notice
- GReplay for Dedimania-Records are now being sent
- solved non-numeric value warning on self-triggered debug notice
###v0.250###
#Additions
@ -24,18 +37,19 @@
#Bug Fixes
- //delrec can delete every local record (Permission-Setting)
- Replaced deprecated code
- replaced deprecated code
#Changes
- Format milliseconds with dot instead of double colon (1:02:375 -> 1:02.375)
- format milliseconds with dot instead of double colon (1:02:375 -> 1:02.375)
- Notification-System of Local Records
###v0.16x###
#Additions
- updated mx links to https
#Changes
- CommunicationMethod SET_SERVER_OPTIONS sets the changed values also in database on call
- Changed Copyright label to 2014-2016
- changed Copyright label to 2014-2016
###v0.163###
#Additions

View File

@ -6,6 +6,7 @@ use FML\Controls\Frame;
use FML\Controls\Gauge;
use FML\Controls\Labels\Label_Button;
use FML\Controls\Labels\Label_Text;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_BgsPlayerCard;
use FML\ManiaLink;
use FML\Script\Features\Paging;
@ -125,6 +126,45 @@ class ElementBuilder {
$this->rowData = array_merge($this->rowData, $rows);
}
/**
* Build Round Text Button
* @param string $description
* @param float $width
* @param float $height
* @param string $action
* @param string $logoUrl
*/
public function buildRoundTextButton($description, $width, $height, $action, $logoUrl = null) {
$frame = new Frame();
$quad = new Quad_BgsPlayerCard();
$frame->addChild($quad);
$quad->setAction($action);
$quad->setSize($width, $height);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setZ(-1);
$label = new Label_Button();
$frame->addChild($label);
$label->setText($description);
$label->setTextSize($height / 4);
$label->setZ(1);
if ($logoUrl) {
$logoQuad = new Quad();
$frame->addChild($logoQuad);
$logoQuad->setImageUrl($logoUrl);
$logoQuad->setSize(0.75*$height, 0.75*$height);
$logoQuad->setX(-$width/2 + 0.75*$height);
$logoQuad->setZ(1);
$label->setHorizontalAlign($label::RIGHT);
$label->setX($width/2 - 0.5*$height);
}
return $frame;
}
/**
* Build Karma Gauge
* @param Map|MXMapInfo $map

View File

@ -153,37 +153,26 @@ class StyleManager implements UsageInformationAble {
}
//Search for Map-Name
$label = new Label_Button();
$frame->addChild($label);
$label->setPosition(-$width / 2 + 63, 0);
$label->setText('MapName');
$label->setTextSize(1.3);
$quad = new Quad_BgsPlayerCard();
$frame->addChild($quad);
$quad->setPosition(-$width / 2 + 63, 0);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize(18, 5);
$quad->setAction($actionMapNameSearch);
$quad->setZ(-0.1);
$mapNameButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'MapName',
18,
5,
$actionMapNameSearch
);
$frame->addChild($mapNameButton);
$mapNameButton->setX(-$width / 2 + 63);
//Search for Author
$label = new Label_Button();
$frame->addChild($label);
$label->setPosition(-$width / 2 + 82, 0);
$label->setText('Author');
$label->setTextSize(1.3);
$quad = new Quad_BgsPlayerCard();
$frame->addChild($quad);
$quad->setPosition(-$width / 2 + 82, 0);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize(18, 5);
$quad->setAction($actionAuthorSearch);
$quad->setZ(-0.1);
$authorButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'Author',
18,
5,
$actionAuthorSearch
);
$frame->addChild($authorButton);
$authorButton->setX(-$width / 2 + 82);
return $frame;
}
/**

View File

@ -162,67 +162,37 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Admin Buttons
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
// Clear Map-Queue
$label = new Label_Button();
$frame->addChild($label);
$label->setText('Clear Map-Queue');
$label->setTextSize(1);
$label->setPosition($width / 2 - 8, $buttonY, 0.1);
$label->setHorizontalAlign($label::RIGHT);
$quad = new Quad_BgsPlayerCard();
$frame->addChild($quad);
$quad->setPosition($width / 2 - 5, $buttonY, 0.01);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setHorizontalAlign($quad::RIGHT);
$quad->setSize(29, 4);
$quad->setAction(self::ACTION_CLEAR_MAPQUEUE);
$clearMapQueueButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'Clear Map-Queue',
30,
4,
self::ACTION_CLEAR_MAPQUEUE
);
$frame->addChild($clearMapQueueButton);
$clearMapQueueButton->setPosition($width/2 - 5 - 30/2, $buttonY);
}
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) {
$mxCheckForUpdatesX = $width / 2 - 37;
$buttonWidth = 35;
$iconSize = 3;
// Check Update
$label = new Label_Button();
$frame->addChild($label);
$label->setText('Check MX for Updates');
$label->setPosition($mxCheckForUpdatesX - 1.5, $buttonY, 0.02);
$label->setTextSize(1);
$label->setWidth(30);
$label->setHorizontalAlign($label::RIGHT);
$quad = new Quad_BgsPlayerCard();
$frame->addChild($quad);
$quad->setPosition($mxCheckForUpdatesX, $buttonY, 0.01);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setHorizontalAlign($quad::RIGHT);
$quad->setSize($buttonWidth, 4);
$quad->setAction(self::ACTION_CHECK_UPDATE);
$mxQuad = new Quad();
$frame->addChild($mxQuad);
$mxQuad->setSize($iconSize, $iconSize);
$mxQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN));
$mxQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN_MOVER));
$mxQuad->setPosition($mxCheckForUpdatesX - $buttonWidth + 3, $buttonY);
$mxQuad->setZ(0.2);
$mxCheckForUpdatesButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'Check MX for Updates',
36,
4,
self::ACTION_CHECK_UPDATE,
$this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN)
);
$frame->addChild($mxCheckForUpdatesButton);
$mxCheckForUpdatesButton->setPosition($width/2 - 5 - 30 - 5 - 36/2, $buttonY);
}
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
// Directory browser
$browserButton = new Label_Button();
$browserButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'Directory Browser',
36,
4,
DirectoryBrowser::ACTION_SHOW
);
$frame->addChild($browserButton);
$browserButton->setPosition($width / -2 + 20, $buttonY, 0.01);
$browserButton->setTextSize(1);
$browserButton->setText('Directory Browser');
$browserQuad = new Quad_BgsPlayerCard();
$frame->addChild($browserQuad);
$browserQuad->setPosition($width / -2 + 20, $buttonY, 0.01);
$browserQuad->setSubStyle($browserQuad::SUBSTYLE_BgPlayerCardBig);
$browserQuad->setSize(35, 4);
$browserQuad->setAction(DirectoryBrowser::ACTION_SHOW);
$browserButton->setPosition(-$width/2 + 5 + 36/2, $buttonY);
}
// Headline

View File

@ -50,7 +50,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
const ACTION_KICK_PLAYER_VOTE = 'PlayerList.KickPlayerVote';
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
/** @deprecated */
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
const ACTION_ADD_AS_SUPER = 'PlayerList.PlayerAddAsSuper';
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
@ -289,9 +291,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// Level Quad
$rightQuad = new Quad_BgRaceScore2();
$playerFrame->addChild($rightQuad);
$rightQuad->setX($posX + 13);
// TODO colorize to player personally
$rightQuad->setSize(7, 3.5);
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
$rightQuad->setX($posX + 13);
$rightLabel = new Label_Text();
$playerFrame->addChild($rightLabel);
@ -496,8 +499,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$label->setText('Advanced Actions');
$label->setTextColor($textColor);
//Nickname background
// Nickname background
$quad = new Quad();
$frame->addChild($quad);
$quad->setPosition(0, $height / 2 - 10, -0.1);
@ -515,129 +517,105 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$label->setTextColor($textColor);
$label->setHorizontalAlign($label::CENTER);
// Buttons
$buttonHeight = 5;
$buttonSpacing = 6.5;
// Background for Buttons
$buttonWidth = $quadWidth;
$posY = $height / 2 - 20;
$quad = new Quad_BgsPlayerCard();
$frame->addChild($quad);
$quad->setX(0);
$quad->setY($posY);
$quad->setZ(-0.1);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize($quadWidth, 5);
// Mute Button
$label = new Label_Text();
$frame->addChild($label);
$label->setX(0);
$label->setY($posY);
$label->setStyle($label::STYLE_TextCardSmall);
$label->setTextSize($textSize);
$label->setTextColor($textColor);
if (!$player->isMuted()) {
$label->setText('Mute');
$quad->setAction(self::ACTION_MUTE_PLAYER . '.' . $login);
} else {
$label->setText('UnMute');
$quad->setAction(self::ACTION_UNMUTE_PLAYER . '.' . $login);
}
// Warn Player
$posY -= $buttonSpacing;
$quad = clone $quad;
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_WARN_PLAYER . '.' . $login);
$label = clone $label;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Warn');
$label->setTextColor($textColor);
$muteUnmuteButtonDescription = $player->isMuted() ? 'UnMute' : 'Mute';
$muteUnmuteButtonAction = ($player->isMuted() ? self::ACTION_UNMUTE_PLAYER : self::ACTION_MUTE_PLAYER) . '.' . $login;
$muteUnmuteButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
$muteUnmuteButtonDescription,
$buttonWidth,
$buttonHeight,
$muteUnmuteButtonAction
);
$frame->addChild($muteUnmuteButton);
$muteUnmuteButton->setY($posY);
$posY -= $buttonSpacing;
// Show Kick
$quad = clone $quad;
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_KICK_PLAYER . '.' . $login);
$label = clone $label;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Kick');
$label->setTextColor('f90');
$warnButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'Warn',
$buttonWidth,
$buttonHeight,
self::ACTION_WARN_PLAYER . '.' . $login
);
$frame->addChild($warnButton);
$warnButton->setY($posY);
$posY -= $buttonSpacing;
// Show Ban
$quad = clone $quad;
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_BAN_PLAYER . '.' . $login);
$label = clone $label;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Ban');
$label->setTextColor('700');
$posY -= $buttonSpacing * 2;
// Show Add as Master-Admin
$quad = clone $quad;
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_ADD_AS_MASTER . '.' . $login);
$label = clone $label;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Set SuperAdmin');
$label->setTextColor($textColor);
$kickButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'$f90Kick',
$buttonWidth,
$buttonHeight,
self::ACTION_KICK_PLAYER . '.' . $login
);
$frame->addChild($kickButton);
$kickButton->setY($posY);
$posY -= $buttonSpacing;
// Show Add as Admin
$quad = clone $quad;
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_ADD_AS_ADMIN . '.' . $login);
$label = clone $label;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Set Admin');
$label->setTextColor($textColor);
$banButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'$700Kick',
$buttonWidth,
$buttonHeight,
self::ACTION_BAN_PLAYER . '.' . $login
);
$frame->addChild($banButton);
$banButton->setY($posY);
$posY -= 2 * $buttonSpacing;
$superColor = $this->maniaControl->getColorManager()->getColorByLevel(AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
$superButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
"{$superColor}Set SuperAdmin",
$buttonWidth,
$buttonHeight,
self::ACTION_ADD_AS_SUPER . '.' . $login
);
$frame->addChild($superButton);
$superButton->setY($posY);
$posY -= $buttonSpacing;
// Show Add as Moderator
$quad = clone $quad;
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_ADD_AS_MOD . '.' . $login);
$label = clone $label;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Set Moderator');
$label->setTextColor($textColor);
$adminColor = $this->maniaControl->getColorManager()->getColorByLevel(AuthenticationManager::AUTH_LEVEL_ADMIN);
$adminButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
"{$adminColor}Set Admin",
$buttonWidth,
$buttonHeight,
self::ACTION_ADD_AS_ADMIN . '.' . $login
);
$frame->addChild($adminButton);
$adminButton->setY($posY);
$posY -= $buttonSpacing;
$modColor = $this->maniaControl->getColorManager()->getColorByLevel(AuthenticationManager::AUTH_LEVEL_MODERATOR);
$modButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
"{$modColor}Set Moderator",
$buttonWidth,
$buttonHeight,
self::ACTION_ADD_AS_MOD . '.' . $login
);
$frame->addChild($modButton);
$modButton->setY($posY);
if ($player->authLevel > 0
&& $this->maniaControl->getAuthenticationManager()->checkRight($admin, $player->authLevel + 1)
) {
$posY -= $buttonSpacing;
// Revoke Rights
$quad = clone $quad;
$frame->addChild($quad);
$quad->setY($posY);
$quad->setAction(self::ACTION_REVOKE_RIGHTS . '.' . $login);
$label = clone $label;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Revoke Rights');
$label->setTextColor('700');
$revokeButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton(
'$700Revoke Rights',
$buttonWidth,
$buttonHeight,
self::ACTION_REVOKE_RIGHTS . '.' . $login
);
$frame->addChild($revokeButton);
$revokeButton->setY($posY);
}
return $frame;
@ -735,6 +713,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$this->advancedPlayerWidget($admin, $targetLogin);
break;
case self::ACTION_ADD_AS_MASTER:
case self::ACTION_ADD_AS_SUPER:
$this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
break;
case self::ACTION_ADD_AS_ADMIN: