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### ###v0.253###
#Changes #Changes
- //restart got replaced by //reboot - //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### ###v0.252###
#Additions #Additions
- Ingame-Changelog - Ingame-Changelog
- New customizations for Join&Leave-Messages - new customizations for Join&Leave-Messages
- Symbolic Link resolving in ServerManager - symbolic Link resolving in ServerManager
- Times in Map Widget - Times in Map Widget
#Bug Fixes #Bug Fixes
- GReplay for Dedimania-Records not being sent - GReplay for Dedimania-Records are now being sent
- non-numeric value warning on self-triggered debug notice - solved non-numeric value warning on self-triggered debug notice
###v0.250### ###v0.250###
#Additions #Additions
@ -24,18 +37,19 @@
#Bug Fixes #Bug Fixes
- //delrec can delete every local record (Permission-Setting) - //delrec can delete every local record (Permission-Setting)
- Replaced deprecated code - replaced deprecated code
#Changes #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 - Notification-System of Local Records
###v0.16x### ###v0.16x###
#Additions #Additions
- updated mx links to https - updated mx links to https
#Changes #Changes
- CommunicationMethod SET_SERVER_OPTIONS sets the changed values also in database on call - 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### ###v0.163###
#Additions #Additions

View File

@ -6,6 +6,7 @@ use FML\Controls\Frame;
use FML\Controls\Gauge; use FML\Controls\Gauge;
use FML\Controls\Labels\Label_Button; use FML\Controls\Labels\Label_Button;
use FML\Controls\Labels\Label_Text; use FML\Controls\Labels\Label_Text;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_BgsPlayerCard; use FML\Controls\Quads\Quad_BgsPlayerCard;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Script\Features\Paging; use FML\Script\Features\Paging;
@ -125,6 +126,45 @@ class ElementBuilder {
$this->rowData = array_merge($this->rowData, $rows); $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 * Build Karma Gauge
* @param Map|MXMapInfo $map * @param Map|MXMapInfo $map

View File

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

View File

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

View File

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