Compare commits
3 Commits
edbe75c39e
...
cfa24ff67f
Author | SHA1 | Date | |
---|---|---|---|
cfa24ff67f | |||
0420d6b08e | |||
e2b4b29d41 |
@ -25,9 +25,6 @@ use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
|
||||
use ManiaControl\Script\InvokeScriptCallback;
|
||||
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
@ -45,7 +42,7 @@ class MatchManagerAdminUI implements CallbackListener, ManialinkPageAnswerListen
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 174;
|
||||
const PLUGIN_VERSION = 1;
|
||||
const PLUGIN_VERSION = 1.1;
|
||||
const PLUGIN_NAME = 'MatchManager Admin UI';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -132,33 +129,8 @@ class MatchManagerAdminUI implements CallbackListener, ManialinkPageAnswerListen
|
||||
throw new \Exception('MatchManager Core is needed to use ' . self::PLUGIN_NAME);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getPluginManager()->getSavedPluginStatus(self::MATCHMANAGERCORE_PLUGIN)) {
|
||||
// plugin are loaded in alphabetic order, just wait 1 sec before trying to load MatchManager Core
|
||||
$this->maniaControl->getTimerManager()->registerOneTimeListening($this, function () {
|
||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||
if ($this->MatchManagerCore === null) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use ' . self::PLUGIN_NAME . ' plugin.');
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
} else {
|
||||
$this->generateManialink();
|
||||
$this->displayManialink();
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
throw new \Exception('MatchManager Core is needed to use ' . self::PLUGIN_NAME);
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_LOADED, $this, 'handlePluginLoaded');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_UNLOADED, $this, 'handlePluginUnloaded');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTMATCHSTART, $this, 'generateManialink');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_STARTMATCH, $this, 'generateManialink');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_ENDMATCH, $this, 'generateManialink');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_STOPMATCH, $this, 'generateManialink');
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
// All callbacks are loaded in handleAfterInit
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_POSX, 156., "");
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_POSY, 24., "");
|
||||
@ -173,6 +145,37 @@ class MatchManagerAdminUI implements CallbackListener, ManialinkPageAnswerListen
|
||||
$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_ADMINUI_SIDEMENU);
|
||||
}
|
||||
|
||||
/**
|
||||
* handleAfterInit
|
||||
*
|
||||
* Plugins are loaded alphabetically, so we have to we wait they are all loaded before check.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handleAfterInit() {
|
||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||
if ($this->MatchManagerCore === null) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use ' . self::PLUGIN_NAME . ' plugin.');
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->generateManialink();
|
||||
$this->displayManialink();
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_LOADED, $this, 'handlePluginLoaded');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_UNLOADED, $this, 'handlePluginUnloaded');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTMATCHSTART, $this, 'generateManialink');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_STARTMATCH, $this, 'generateManialink');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_ENDMATCH, $this, 'generateManialink');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_STOPMATCH, $this, 'generateManialink');
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Widgets on Setting Changes
|
||||
*
|
||||
|
@ -38,7 +38,7 @@ use ManiaControl\Callbacks\TimerListener; // for pause
|
||||
class MatchManagerCore implements CallbackListener, CommandListener, TimerListener, CommunicationListener, Plugin {
|
||||
|
||||
const PLUGIN_ID = 152;
|
||||
const PLUGIN_VERSION = 5.2;
|
||||
const PLUGIN_VERSION = 5.3;
|
||||
const PLUGIN_NAME = 'MatchManager Core';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -745,6 +745,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
public function resetMatchVariables() {
|
||||
$this->matchStarted = false;
|
||||
$this->matchrecover = false;
|
||||
$this->pauseon = false;
|
||||
$this->pointstorecover = array();
|
||||
$this->currentscore = array();
|
||||
$this->preendroundscore = array();
|
||||
@ -1125,6 +1126,11 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Match stopped by an Admin!');
|
||||
|
||||
// Cancel pause if match stopped during a pause
|
||||
if ($this->pauseon) {
|
||||
$this->unsetNadeoPause();
|
||||
}
|
||||
|
||||
// Load TimeAttack gamemode if possible
|
||||
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_POST_MATCH_MAPLIST);
|
||||
if (is_file($this->maniaControl->getServer()->getDirectory()->getMapsFolder() . $maplist)) {
|
||||
|
@ -42,7 +42,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 171;
|
||||
const PLUGIN_VERSION = 1.2;
|
||||
const PLUGIN_VERSION = 1.3;
|
||||
const PLUGIN_NAME = 'MatchManager Multiple Config Manager';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -224,7 +224,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
case self::ML_ACTION_SAVE_CONFIG:
|
||||
if ($callback[1][3][0]["Value"]) {
|
||||
$this->showConfigListUI(array(), $player);
|
||||
$this->saveConfig($callback[1][3]);
|
||||
$this->saveCurrentConfig($callback[1][3]);
|
||||
$this->showConfigListUI(array(), $player);
|
||||
}
|
||||
break;
|
||||
@ -295,12 +295,12 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
}
|
||||
|
||||
/**
|
||||
* saveConfig
|
||||
* saveCurrentConfig
|
||||
*
|
||||
* @param array $fields
|
||||
* @return void
|
||||
*/
|
||||
public function saveConfig(array $fields) {
|
||||
public function saveCurrentConfig(array $fields) {
|
||||
Logger::log("[MatchManagerMultipleConfigManager] Saving current config");
|
||||
$result = array();
|
||||
$configname = "";
|
||||
@ -331,15 +331,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
return;
|
||||
}
|
||||
|
||||
$config = json_encode($result);
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = $mysqli->prepare('INSERT INTO `' . self::DB_MATCHCONFIG . '` (`name`,`gamemodebase`,`config`) VALUES (?, ?, ?);');
|
||||
$query->bind_param('sss', $configname, $gamemodebase, $config);
|
||||
if (!$query->execute()) {
|
||||
trigger_error('Error executing MySQL query: ' . $query->error);
|
||||
}
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOADCONFIG, $configname);
|
||||
$this->saveConfig($configname, $gamemodebase, json_encode($result));
|
||||
}
|
||||
|
||||
public function getSavedConfigs() {
|
||||
@ -353,6 +345,15 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
return $result->fetch_all(MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
public function saveConfig($configname, $gamemodebase, $config) {
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = $mysqli->prepare('INSERT INTO `' . self::DB_MATCHCONFIG . '` (`name`,`gamemodebase`,`config`) VALUES (?, ?, ?);');
|
||||
$query->bind_param('sss', $configname, $gamemodebase, $config);
|
||||
if (!$query->execute()) {
|
||||
trigger_error('Error executing MySQL query: ' . $query->error);
|
||||
}
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_SAVECONFIG, $configname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a ManiaLink list with the local records.
|
||||
@ -472,7 +473,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
self::ML_ACTION_SAVE_CONFIG_PAGE
|
||||
);
|
||||
$frame->addChild($mapNameButton);
|
||||
$mapNameButton->setPosition(-$width / 2 + 110, -36);
|
||||
$mapNameButton->setPosition(-$width / 2 + 110, -$height / 2 + 6);
|
||||
|
||||
// Render and display xml
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, self::ML_ID);
|
||||
@ -580,13 +581,13 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
self::ML_ACTION_SAVE_CONFIG
|
||||
);
|
||||
$frame->addChild($mapNameButton);
|
||||
$mapNameButton->setPosition(-$width / 2 + 60, -35);
|
||||
$mapNameButton->setPosition(-$width / 2 + 60, -$height / 2 + 5);
|
||||
|
||||
$entry = new Entry();
|
||||
$frame->addChild($entry);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setHorizontalAlign($entry::LEFT);
|
||||
$entry->setPosition(-$width / 2 + 80, -35);
|
||||
$entry->setPosition(-$width / 2 + 80, -$height / 2 + 5);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setSize($width * 0.25, 4);
|
||||
$entry->setName(self::ML_NAME_CONFIGNAME);
|
||||
|
Loading…
Reference in New Issue
Block a user