local records - only notify driver setting
This commit is contained in:
parent
32624e0946
commit
dae67d9dec
@ -32,11 +32,15 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
const SETTING_WIDGET_WIDTH = 'Widget Width';
|
const SETTING_WIDGET_WIDTH = 'Widget Width';
|
||||||
const SETTING_WIDGET_LINESCOUNT = 'Widget Displayed Lines Count';
|
const SETTING_WIDGET_LINESCOUNT = 'Widget Displayed Lines Count';
|
||||||
const SETTING_WIDGET_LINEHEIGHT = 'Widget Line Height';
|
const SETTING_WIDGET_LINEHEIGHT = 'Widget Line Height';
|
||||||
|
const SETTING_NOTIFY_ONLY_DRIVER = 'Notify only the Driver on New Records';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
/** @var maniaControl $maniaControl */
|
/**
|
||||||
|
*
|
||||||
|
* @var maniaControl $maniaControl
|
||||||
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $updateManialink = false;
|
private $updateManialink = false;
|
||||||
|
|
||||||
@ -55,6 +59,7 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_WIDTH, 40.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_WIDTH, 40.);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINESCOUNT, 25);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINESCOUNT, 25);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINEHEIGHT, 4.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_LINEHEIGHT, 4.);
|
||||||
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NOTIFY_ONLY_DRIVER, false);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
||||||
@ -234,18 +239,31 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
$this->updateManialink = true;
|
$this->updateManialink = true;
|
||||||
|
|
||||||
// Announce record
|
// Announce record
|
||||||
// TODO: setting to send notification only to the player
|
|
||||||
// TODO: setting to send notifications only for x best records
|
|
||||||
$newRecord = $this->getLocalRecord($map, $player);
|
$newRecord = $this->getLocalRecord($map, $player);
|
||||||
if (!$oldRecord || $newRecord->rank < $oldRecord->rank) {
|
$notifyOnlyDriver = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NOTIFY_ONLY_DRIVER);
|
||||||
$improvement = 'gained the';
|
if ($notifyOnlyDriver) {
|
||||||
|
if (!$oldRecord || $newRecord->rank < $oldRecord->rank) {
|
||||||
|
$improvement = 'gained the';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$improvement = 'improved Your';
|
||||||
|
}
|
||||||
|
$message = 'You ' . $improvement . ' $<$o' . $newRecord->rank . '.$> Local Record: ' .
|
||||||
|
Formatter::formatTime($newRecord->time);
|
||||||
|
$this->maniaControl->chat->sendInformation($message, $player->login);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$improvement = 'improved her/his';
|
if (!$oldRecord || $newRecord->rank < $oldRecord->rank) {
|
||||||
|
$improvement = 'gained the';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$improvement = 'improved the';
|
||||||
|
}
|
||||||
|
$message = '$<' . $player->nickname . '$> ' . $improvement . ' $<$o' . $newRecord->rank . '.$> Local Record: ' .
|
||||||
|
Formatter::formatTime($newRecord->time);
|
||||||
|
$this->maniaControl->chat->sendInformation($message);
|
||||||
}
|
}
|
||||||
$message = '$<' . $player->nickname . '$> ' . $improvement . ' $<$o' . $newRecord->rank . '.$> Local Record: ' .
|
// TODO: setting to send notifications only for x best records
|
||||||
Formatter::formatTime($newRecord->time);
|
|
||||||
$this->maniaControl->chat->sendInformation($message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user