Added help button to player actions menu
This commit is contained in:
parent
be76e54148
commit
9ab81d0614
@ -4,6 +4,7 @@ namespace ManiaControl\Commands;
|
|||||||
|
|
||||||
use FML\Controls\Frame;
|
use FML\Controls\Frame;
|
||||||
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
||||||
|
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use FML\Script\Features\Paging;
|
use FML\Script\Features\Paging;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
@ -11,6 +12,7 @@ use ManiaControl\Callbacks\Callbacks;
|
|||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\LabelLine;
|
use ManiaControl\Manialinks\LabelLine;
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +22,10 @@ use ManiaControl\Players\Player;
|
|||||||
* @copyright 2014-2017 ManiaControl Team
|
* @copyright 2014-2017 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class HelpManager implements CommandListener, CallbackListener {
|
class HelpManager implements CommandListener, CallbackListener, ManialinkPageAnswerListener {
|
||||||
|
|
||||||
|
const ACTION_OPEN_HELP_ALL = 'Helpmanager.OpenHelpall';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
@ -37,6 +42,14 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
|
// Action Open StatsList
|
||||||
|
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_HELP_ALL, $this, 'maniaLink_helpAll');
|
||||||
|
|
||||||
|
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Help);
|
||||||
|
$itemQuad->setAction(self::ACTION_OPEN_HELP_ALL);
|
||||||
|
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, true, 16, 'Available commands');
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||||
}
|
}
|
||||||
@ -95,13 +108,23 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
$this->parseHelpList($this->playerCommands, true, $player);
|
$this->parseHelpList($this->playerCommands, true, $player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a ManiaLink
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
* @param \ManiaControl\Players\Player $player
|
||||||
|
*/
|
||||||
|
public function maniaLink_helpAll(array $callback, Player $player) {
|
||||||
|
$this->parseHelpList($this->playerCommands, true, $player);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse list with commands from array
|
* Parse list with commands from array
|
||||||
*
|
*
|
||||||
* @param array $commands
|
* @param array $commands
|
||||||
* @param bool $isHelpAll
|
* @param bool $isHelpAll
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return string|void
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function parseHelpList(array $commands, $isHelpAll = false, Player $player = null) {
|
private function parseHelpList(array $commands, $isHelpAll = false, Player $player = null) {
|
||||||
$showCommands = array();
|
$showCommands = array();
|
||||||
@ -186,7 +209,7 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->addChild($pageFrame);
|
$frame->addChild($pageFrame);
|
||||||
$posY = $height / 2 - 10;
|
$posY = $height / 2 - 10;
|
||||||
$paging->addPageControl($pageFrame); //TODO @Jocy
|
$paging->addPageControl($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
$playerFrame = new Frame();
|
$playerFrame = new Frame();
|
||||||
|
Loading…
Reference in New Issue
Block a user