diff --git a/application/core/Maps/MapCommands.php b/application/core/Maps/MapCommands.php index fdfadb24..529c7092 100644 --- a/application/core/Maps/MapCommands.php +++ b/application/core/Maps/MapCommands.php @@ -343,21 +343,26 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $mapList = array(); foreach($maps as $map) { if($map instanceof Map) { - $votes = $karmaPlugin->getMapVotes($map); - $min = 0; - $plus = 0; - foreach($votes as $vote) { - if(isset($vote->vote)) { - if($vote->vote != 0.5) { - if($vote->vote < 0.5) { - $min = $min+$vote->count; - } else { - $plus = $plus+$vote->count; + if($this->maniaControl->settingManager->getSetting($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) === true) { + $karma = $karmaPlugin->getMapKarma($map); + $map->karma = round($karma * 100.); + } else { + $votes = $karmaPlugin->getMapVotes($map); + $min = 0; + $plus = 0; + foreach($votes as $vote) { + if(isset($vote->vote)) { + if($vote->vote != 0.5) { + if($vote->vote < 0.5) { + $min = $min+$vote->count; + } else { + $plus = $plus+$vote->count; + } } } } + $map->karma = $plus-$min; } - $map->karma = $plus-$min; $mapList[] = $map; } } diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index b102ea26..cecc631c 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -425,20 +425,26 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $karma = $karmaPlugin->getMapKarma($map); $votes = $karmaPlugin->getMapVotes($map); if (is_numeric($karma)) { - $min = 0; - $plus = 0; - foreach($votes as $vote) { - if(isset($vote->vote)) { - if($vote->vote != 0.5) { - if($vote->vote < 0.5) { - $min = $min+$vote->count; - } else { - $plus = $plus+$vote->count; + if($this->maniaControl->settingManager->getSetting($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) === true) { + $endKarma = $karma; + $karmaText = ' ' . round($karma * 100.) . ' (' . $votes['count'] . ')'; + } else { + $min = 0; + $plus = 0; + foreach($votes as $vote) { + if(isset($vote->vote)) { + if($vote->vote != 0.5) { + if($vote->vote < 0.5) { + $min = $min+$vote->count; + } else { + $plus = $plus+$vote->count; + } } } } + $endKarma = $plus-$min; + $karmaText = ' ' . $endKarma . ' (' . $votes['count'] . 'x / ' . round($karma * 100.) . '%)'; } - $endKarma = $plus-$min; $karmaGauge = new Gauge(); $mapFrame->add($karmaGauge); @@ -459,7 +465,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $karmaLabel->setTextSize(0.9); $karmaLabel->setTextColor('000'); $karmaLabel->setAlign(Control::CENTER, Control::CENTER); - $karmaLabel->setText(' ' . $endKarma . ' (' . $votes['count'] . 'x / ' . round($karma * 100.) . '%)'); + $karmaLabel->setText($karmaText); } } diff --git a/application/plugins/Karma.php b/application/plugins/Karma.php index 8089609b..7d029186 100644 --- a/application/plugins/Karma.php +++ b/application/plugins/Karma.php @@ -43,6 +43,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { const SETTING_WIDGET_POSY = 'Widget-Position: Y'; const SETTING_WIDGET_WIDTH = 'Widget-Size: Width'; const SETTING_WIDGET_HEIGHT = 'Widget-Size: Height'; + const SETTING_NEWKARMA = 'Enable "new karma" (percentage), disable = RASP karma'; const STAT_PLAYER_MAPVOTES = 'Voted Maps'; /* @@ -102,6 +103,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_POSY, 90 - 10 - 6); $this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_WIDTH, 25.); $this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.); + $this->maniaControl->settingManager->initSetting($this, self::SETTING_NEWKARMA, true); // Register for callbacks $this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);