Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AquaNet/src/components/settings/Mai2Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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')],
Expand Down Expand Up @@ -72,6 +73,7 @@
</div>
</div>
{/each}
<GameSettingFields game="mai2"/>
<button class="exportButton" on:click={exportData}>
<Icon icon="bxs:file-export"/>
{t('settings.export')}
Expand Down
2 changes: 2 additions & 0 deletions AquaNet/src/libs/i18n/en_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions AquaNet/src/libs/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '上传',
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/icu/samnyan/aqua/net/db/AquaGameOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class AquaGameOptions(

@SettingField("chu3-matching")
var chusanMatchingReflector: String = "",

@SettingField("mai2")
var enableMusicRank: Boolean = true,
)

interface AquaGameOptionsRepo : JpaRepository<AquaGameOptions, Long>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE aqua_game_options ADD enable_music_rank BIT(1) NOT NULL DEFAULT 1;