adding check if the mode uses warmup to add the buttons in the menu
This commit is contained in:
parent
0ada7f2a1e
commit
4647299ec8
@ -123,7 +123,9 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
$itemMarginFactorY = 1.2;
|
$itemMarginFactorY = 1.2;
|
||||||
|
|
||||||
// If game is shootmania lower the icons position by 20
|
// If game is shootmania lower the icons position by 20
|
||||||
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() === 'sm') {
|
if ($this->maniaControl->mapManager->getCurrentMap()
|
||||||
|
->getGame() === 'sm'
|
||||||
|
) {
|
||||||
$posY -= $shootManiaOffset;
|
$posY -= $shootManiaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,9 +286,13 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
*/
|
*/
|
||||||
public function removeMenuItem($order, $playerAction = true) {
|
public function removeMenuItem($order, $playerAction = true) {
|
||||||
if ($playerAction) {
|
if ($playerAction) {
|
||||||
unset($this->playerMenuItems[$order]);
|
if ($this->playerMenuItems[$order]) {
|
||||||
|
unset($this->playerMenuItems[$order]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
unset($this->adminMenuItems[$order]);
|
if ($this->playerMenuItems[$order]) {
|
||||||
|
unset($this->adminMenuItems[$order]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->rebuildAndShowMenu();
|
$this->rebuildAndShowMenu();
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,9 @@ class ShootManiaCallbacks implements CallbackListener {
|
|||||||
case 'LibAFK_IsAFK':
|
case 'LibAFK_IsAFK':
|
||||||
$this->triggerAfkStatus($data[0]);
|
$this->triggerAfkStatus($data[0]);
|
||||||
break;
|
break;
|
||||||
|
case 'WarmUp_Status':
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(Callbacks::WARMUPSTATUS, $data[0]);
|
||||||
|
break;
|
||||||
case self::CB_TIMEATTACK_ONCHECKPOINT:
|
case self::CB_TIMEATTACK_ONCHECKPOINT:
|
||||||
$this->handleTimeAttackOnCheckpoint($name, $data);
|
$this->handleTimeAttackOnCheckpoint($name, $data);
|
||||||
break;
|
break;
|
||||||
|
@ -56,6 +56,8 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->timerManager->registerTimerListening($this, 'each5Seconds', 5000);
|
$this->maniaControl->timerManager->registerTimerListening($this, 'each5Seconds', 5000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||||
|
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::WARMUPSTATUS, $this, 'handleWarmUpStatus');
|
||||||
|
|
||||||
|
|
||||||
// Register for commands
|
// Register for commands
|
||||||
$this->maniaControl->commandManager->registerCommandListener('setservername', $this, 'command_SetServerName', true, 'Sets the ServerName.');
|
$this->maniaControl->commandManager->registerCommandListener('setservername', $this, 'command_SetServerName', true, 'Sets the ServerName.');
|
||||||
@ -82,19 +84,9 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CANCEL_VOTE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CANCEL_VOTE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_HANDLE_WARMUP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_HANDLE_WARMUP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
|
|
||||||
// Extend WarmUp
|
//Check if there is WarmUp Enabled in this Mode
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_EXTEND_WARMUP, $this, 'command_extendWarmup');
|
//TODO handle the Modescriptevents + answer by an own callback class (answer via closure or dunno)
|
||||||
$itemQuad = new Quad_BgRaceScore2();
|
$this->maniaControl->client->triggerModeScriptEvent("WarmUp_GetStatus");
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_SendScore);
|
|
||||||
$itemQuad->setAction(self::ACTION_EXTEND_WARMUP);
|
|
||||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 14, 'Extend Warmup');
|
|
||||||
|
|
||||||
// Stop WarmUp
|
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_END_WARMUP, $this, 'command_endWarmup');
|
|
||||||
$itemQuad = new Quad_Icons64x64_1();
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowGreen);
|
|
||||||
$itemQuad->setAction(self::ACTION_END_WARMUP);
|
|
||||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 15, 'End Warmup');
|
|
||||||
|
|
||||||
// Action cancel Vote
|
// Action cancel Vote
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CANCEL_VOTE, $this, 'command_cancelVote');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CANCEL_VOTE, $this, 'command_cancelVote');
|
||||||
@ -126,6 +118,31 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handeling the WarmupStatus Callback, and removes or adds the Menu Items for extending / Stopping warmup
|
||||||
|
*
|
||||||
|
* @param $warmupEnabled
|
||||||
|
*/
|
||||||
|
public function handleWarmUpStatus($warmupEnabled) {
|
||||||
|
if ($warmupEnabled) {
|
||||||
|
// Extend WarmUp
|
||||||
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_EXTEND_WARMUP, $this, 'command_extendWarmup');
|
||||||
|
$itemQuad = new Quad_BgRaceScore2();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_SendScore);
|
||||||
|
$itemQuad->setAction(self::ACTION_EXTEND_WARMUP);
|
||||||
|
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 14, 'Extend Warmup');
|
||||||
|
|
||||||
|
// Stop WarmUp
|
||||||
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_END_WARMUP, $this, 'command_endWarmup');
|
||||||
|
$itemQuad = new Quad_Icons64x64_1();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowGreen);
|
||||||
|
$itemQuad->setAction(self::ACTION_END_WARMUP);
|
||||||
|
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 15, 'End Warmup');
|
||||||
|
} else {
|
||||||
|
$this->maniaControl->actionsMenu->removeMenuItem(14, false);
|
||||||
|
$this->maniaControl->actionsMenu->removeMenuItem(15, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //cancelvote command
|
* Handle //cancelvote command
|
||||||
|
Loading…
Reference in New Issue
Block a user