[+] Allow disable music rank for own machine (#110)

* [+] Allow disable music rank for own machine

* fix
pull/111/head
凌莞~(=^▽^=) 2025-01-19 01:43:58 +08:00 committed by GitHub
parent dfee2cd71f
commit 151535139f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 1 deletions

View File

@ -5,6 +5,7 @@
import Icon from "@iconify/svelte";
import StatusOverlays from "../StatusOverlays.svelte";
import { GAME } from "../../libs/sdk";
import GameSettingFields from "./GameSettingFields.svelte";
const profileFields = [
['name', t('settings.mai2.name')],
@ -72,6 +73,7 @@
</div>
</div>
{/each}
<GameSettingFields game="mai2"/>
<button class="exportButton" on:click={exportData}>
<Icon icon="bxs:file-export"/>
{t('settings.export')}

View File

@ -153,6 +153,8 @@ export const EN_REF_SETTINGS = {
'settings.fields.gameUsername.desc': 'Your name shown in game',
'settings.fields.optOutOfLeaderboard.name': 'Opt Out of Leaderboard',
'settings.fields.optOutOfLeaderboard.desc': 'You will still be able to see yourself on the leaderboard after logging in',
'settings.fields.enableMusicRank.name': 'Enable Recommended Music Rank on Your Machine',
'settings.fields.enableMusicRank.desc': 'If you have your own ranking, you can turn this off. It only affects your own machine',
'settings.mai2.name': 'Player Name',
'settings.profile.picture': 'Profile Picture',
'settings.profile.upload-new': 'Upload New',

View File

@ -163,6 +163,8 @@ const zhSettings: typeof EN_REF_SETTINGS = {
'settings.fields.gameUsername.desc': '在游戏中显示的用户名',
'settings.fields.optOutOfLeaderboard.name': '不参与排行榜',
'settings.fields.optOutOfLeaderboard.desc': '登录之后还是可以在排行榜上看到自己',
'settings.fields.enableMusicRank.name': '在你的机台上启用“推荐乐曲排行榜”',
'settings.fields.enableMusicRank.desc': '如果你自己设计了排行榜的话,可以关闭这个。只会影响你自己的机器',
'settings.mai2.name': '玩家名字',
'settings.profile.picture': '头像',
'settings.profile.upload-new': '上传',

View File

@ -43,6 +43,9 @@ class AquaGameOptions(
@SettingField("chu3-matching")
var chusanMatchingReflector: String = "",
@SettingField("mai2")
var enableMusicRank: Boolean = true,
)
interface AquaGameOptionsRepo : JpaRepository<AquaGameOptions, Long>

View File

@ -3,6 +3,7 @@ package icu.samnyan.aqua.sega.maimai2.handler
import com.querydsl.jpa.impl.JPAQueryFactory
import ext.logger
import ext.thread
import icu.samnyan.aqua.sega.allnet.TokenChecker
import icu.samnyan.aqua.sega.general.BaseHandler
import icu.samnyan.aqua.sega.maimai2.model.userdata.QMai2UserPlaylog
import org.springframework.scheduling.annotation.Scheduled
@ -55,7 +56,14 @@ class GetGameRankingHandler(
override fun handle(request: Map<String, Any>): Any = mapOf(
"type" to request["type"],
"gameRankingList" to when(request["type"]) {
1 -> musicRankingCache.map { mapOf("id" to it.musicId, "point" to it.weight, "userName" to "") }
1 -> {
val opts = TokenChecker.getCurrentSession()?.user?.gameOptions
// If is null or true, return the ranking list
if (opts?.enableMusicRank == false)
emptyList()
else
musicRankingCache.map { mapOf("id" to it.musicId, "point" to it.weight, "userName" to "") }
}
else -> emptyList()
}
)

View File

@ -0,0 +1 @@
ALTER TABLE aqua_game_options ADD enable_music_rank BIT(1) NOT NULL DEFAULT 1;