severall improvements and fixes
This commit is contained in:
parent
00813d66d7
commit
fe1f4c6be4
@ -49,7 +49,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSY, -37.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSY, -17.);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
@ -210,7 +210,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
|
|
||||||
// Add items
|
// Add items
|
||||||
$x = -1;
|
$x = -1;
|
||||||
foreach($this->adminMenuItems as $order => $menuItems) {
|
foreach($this->adminMenuItems as $menuItems) {
|
||||||
foreach($menuItems as $menuItem) {
|
foreach($menuItems as $menuItem) {
|
||||||
$menuQuad = $menuItem[0];
|
$menuQuad = $menuItem[0];
|
||||||
/**
|
/**
|
||||||
@ -274,7 +274,6 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
$backgroundQuad->setHAlign(Control::RIGHT);
|
$backgroundQuad->setHAlign(Control::RIGHT);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
$backgroundQuad->setSize(count($this->playerMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
$backgroundQuad->setSize(count($this->playerMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
||||||
|
|
||||||
$script->addToggle($itemQuad, $popoutFrame);
|
$script->addToggle($itemQuad, $popoutFrame);
|
||||||
|
|
||||||
// Add items
|
// Add items
|
||||||
|
@ -61,7 +61,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
const VOTE_FOR_ACTION = '1';
|
const VOTE_FOR_ACTION = '1';
|
||||||
const VOTE_AGAINST_ACTION = '-1';
|
const VOTE_AGAINST_ACTION = '-1';
|
||||||
|
|
||||||
const ACTION_POSITIVE_VOTE = 'CustomVotesPlugin.PositivVote';
|
const ACTION_POSITIVE_VOTE = 'CustomVotesPlugin.PositiveVote';
|
||||||
const ACTION_NEGATIVE_VOTE = 'CustomVotesPlugin.NegativeVote';
|
const ACTION_NEGATIVE_VOTE = 'CustomVotesPlugin.NegativeVote';
|
||||||
const ACTION_START_VOTE = 'CustomVotesPlugin.StartVote.';
|
const ACTION_START_VOTE = 'CustomVotesPlugin.StartVote.';
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
/** @var maniaControl $maniaControl */
|
/** @var maniaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $voteCommands = array();
|
private $voteCommands = array();
|
||||||
|
private $voteMenuItems = array();
|
||||||
private $currentVote = null;
|
private $currentVote = null;
|
||||||
private $currentVoteExpireTime = 0;
|
private $currentVoteExpireTime = 0;
|
||||||
private $playersVoted = array();
|
private $playersVoted = array();
|
||||||
@ -105,7 +106,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
|
|
||||||
//Settings
|
//Settings
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_POSX, 156.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_POSX, 156.);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_POSY, -58.6);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_POSY, -38.6);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_WIDTH, 6);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_WIDTH, 6);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_HEIGHT, 6);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_HEIGHT, 6);
|
||||||
|
|
||||||
@ -147,6 +148,21 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$this->showIcon($player->login);
|
$this->showIcon($player->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new Vote Menu Item
|
||||||
|
*
|
||||||
|
* @param Control $control
|
||||||
|
* @param int $order
|
||||||
|
* @param string $description
|
||||||
|
*/
|
||||||
|
public function addVoteMenuItem(Control $control, $order = 0, $description = null) {
|
||||||
|
if(!isset($this->voteMenuItems[$order])) {
|
||||||
|
$this->voteMenuItems[$order] = array();
|
||||||
|
}
|
||||||
|
array_push($this->voteMenuItems[$order], array($control, $description));
|
||||||
|
krsort($this->voteMenuItems);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chat Vote
|
* Chat Vote
|
||||||
*
|
*
|
||||||
@ -168,6 +184,45 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleOnInit(array $callback) {
|
public function handleOnInit(array $callback) {
|
||||||
|
// Menu RestartMap
|
||||||
|
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Reload);
|
||||||
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'restartmap');
|
||||||
|
$this->addVoteMenuItem($itemQuad, 5, 'Vote for Restart-Map');
|
||||||
|
|
||||||
|
//Check if Pause exists in current gamemode
|
||||||
|
$this->maniaControl->client->query('GetModeScriptInfo');
|
||||||
|
$scriptInfos = $this->maniaControl->client->getResponse();
|
||||||
|
|
||||||
|
$pauseExists = false;
|
||||||
|
foreach($scriptInfos["CommandDescs"] as $param) {
|
||||||
|
if($param['Name'] == "Command_ForceWarmUp") {
|
||||||
|
$pauseExists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Menu Pause
|
||||||
|
if($pauseExists) {
|
||||||
|
$itemQuad = new Quad_Icons128x32_1();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
||||||
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame');
|
||||||
|
$this->addVoteMenuItem($itemQuad, 10, 'Vote for a pause of Current Game');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Menu SkipMap
|
||||||
|
$itemQuad = new Quad_Icons64x64_1();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowFastNext);
|
||||||
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'skipmap');
|
||||||
|
$this->addVoteMenuItem($itemQuad, 15, 'Vote for a Mapskip');
|
||||||
|
|
||||||
|
//Menu TeamBalance
|
||||||
|
$itemQuad = new Quad_Icons128x32_1();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
||||||
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'teambalance');
|
||||||
|
$this->addVoteMenuItem($itemQuad, 20, 'Vote for Team-Balance');
|
||||||
|
|
||||||
|
//Show the Menu's icon
|
||||||
$this->showIcon();
|
$this->showIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,7 +608,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$iconFrame->add($itemQuad);
|
$iconFrame->add($itemQuad);
|
||||||
|
|
||||||
//Define Description Label
|
//Define Description Label
|
||||||
$menuEntries = 4;
|
$menuEntries = count($this->voteMenuItems);
|
||||||
$descriptionFrame = new Frame();
|
$descriptionFrame = new Frame();
|
||||||
$maniaLink->add($descriptionFrame);
|
$maniaLink->add($descriptionFrame);
|
||||||
$descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.15 - 6, $posY);
|
$descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.15 - 6, $posY);
|
||||||
@ -581,71 +636,28 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
|
|
||||||
$script->addToggle($itemQuad, $popoutFrame);
|
$script->addToggle($itemQuad, $popoutFrame);
|
||||||
|
|
||||||
//Menu Items
|
// Add items
|
||||||
$x = -1;
|
$x = -1;
|
||||||
|
foreach($this->voteMenuItems as $menuItems) {
|
||||||
//TODO build dynamically
|
foreach($menuItems as $menuItem) {
|
||||||
//Vote Balance Teams
|
$menuQuad = $menuItem[0];
|
||||||
$itemQuad = new Quad_Icons128x32_1();
|
/**
|
||||||
$popoutFrame->add($itemQuad);
|
*
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
* @var Quad $menuQuad
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'teambalance');
|
*/
|
||||||
$itemQuad->setSize($itemSize, $itemSize);
|
$popoutFrame->add($menuQuad);
|
||||||
$itemQuad->setX($x);
|
$menuQuad->setSize($itemSize, $itemSize);
|
||||||
$itemQuad->setHAlign(Control::RIGHT);
|
$menuQuad->setX($x);
|
||||||
$description = '$s' . 'Vote for Team-Balance';
|
$menuQuad->setHAlign(Control::RIGHT);
|
||||||
$script->addTooltip($itemQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
|
||||||
$x -= $itemSize * 1.05;
|
$x -= $itemSize * 1.05;
|
||||||
|
|
||||||
// Vote SkipMap
|
if($menuItem[1]) {
|
||||||
$itemQuad = new Quad_Icons64x64_1();
|
$description = '$s' . $menuItem[1];
|
||||||
$popoutFrame->add($itemQuad);
|
$script->addTooltip($menuQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowFastNext);
|
}
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'skipmap');
|
|
||||||
$itemQuad->setSize($itemSize, $itemSize);
|
|
||||||
$itemQuad->setX($x);
|
|
||||||
$itemQuad->setHAlign(Control::RIGHT);
|
|
||||||
$description = '$s' . 'Vote for Skip-Map';
|
|
||||||
$script->addTooltip($itemQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
|
||||||
$x -= $itemSize * 1.05;
|
|
||||||
|
|
||||||
//Check if Pause exists in current gamemode
|
|
||||||
$this->maniaControl->client->query('GetModeScriptInfo');
|
|
||||||
$scriptInfos = $this->maniaControl->client->getResponse();
|
|
||||||
|
|
||||||
$pauseExists = false;
|
|
||||||
foreach($scriptInfos["CommandDescs"] as $param) {
|
|
||||||
if($param['Name'] == "Command_ForceWarmUp") {
|
|
||||||
$pauseExists = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($pauseExists) {
|
|
||||||
// Set Pause
|
|
||||||
$itemQuad = new Quad_Icons128x32_1();
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
|
||||||
$popoutFrame->add($itemQuad);
|
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame');
|
|
||||||
$itemQuad->setSize($itemSize, $itemSize);
|
|
||||||
$itemQuad->setX($x);
|
|
||||||
$itemQuad->setHAlign(Control::RIGHT);
|
|
||||||
$description = '$s' . 'Vote for a pause of Current Game';
|
|
||||||
$script->addTooltip($itemQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
|
||||||
$x -= $itemSize * 1.05;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vote RestartMap
|
|
||||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
|
||||||
$popoutFrame->add($itemQuad);
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Reload);
|
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'restartmap');
|
|
||||||
$itemQuad->setSize($itemSize, $itemSize);
|
|
||||||
$itemQuad->setX($x);
|
|
||||||
$itemQuad->setHAlign(Control::RIGHT);
|
|
||||||
$description = '$s' . 'Vote for Restart-Map';
|
|
||||||
$script->addTooltip($itemQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
|
||||||
//$x -= $itemSize * 1.05;
|
|
||||||
|
|
||||||
// Send manialink
|
// Send manialink
|
||||||
$manialinkText = $maniaLink->render()->saveXML();
|
$manialinkText = $maniaLink->render()->saveXML();
|
||||||
|
@ -75,7 +75,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED, true);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_POSX, 156.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_POSX, 156.);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_POSY, -51.4);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_POSY, -31.4);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_WIDTH, 6);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_WIDTH, 6);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_HEIGHT, 6);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATE_WIDGET_HEIGHT, 6);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATION_VALUES, "20,50,100,500,1000,2000");
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATION_VALUES, "20,50,100,500,1000,2000");
|
||||||
|
Loading…
Reference in New Issue
Block a user