Skip to content

Commit

Permalink
添加 ChangeGameSettings(覆写游戏内设置功能)
Browse files Browse the repository at this point in the history
  • Loading branch information
WYH2004-MC committed Oct 16, 2024
1 parent f200d57 commit 5133b68
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 49 deletions.
4 changes: 2 additions & 2 deletions BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace SinmaiAssist {
public static partial class BuildInfo {
public const string CommitHash = "ac87265";
public const string BuildDate = "2024-10-14T22:53:59.7667374+08:00";
public const string CommitHash = "f200d57";
public const string BuildDate = "2024-10-17T02:02:06.5635344+08:00";
}
}
87 changes: 87 additions & 0 deletions Common/ChangeGameSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using DB;
using HarmonyLib;
using Manager;
using MelonLoader;
using Monitor.ModeSelect;
using SinmaiAssist.Utils;
using UnityEngine;

namespace SinmaiAssist.Common;

public class ChangeGameSettings
{
private static readonly List<bool> SettingEnable = new List<bool> { false,false,false,false };
private static readonly List<bool> UserSettingToggleState = new List<bool> { false, false, false, false };

[HarmonyPostfix]
[HarmonyPatch(typeof(ModeSelectMonitor), "Initialize")]
public static void SetSettings(ModeSelectMonitor __instance, int monIndex)
{
try
{
UserData userData = User.GetUserData(monIndex);
InitSettings(userData);
SetUserFlag(userData);
AccessTools.Field(typeof(ModeSelectMonitor), "_isSettingEnable").SetValue(__instance, SettingEnable);
AccessTools.Field(typeof(ModeSelectMonitor), "_isSettingToggleState").SetValue(__instance, UserSettingToggleState);
var nullSetting = (List<GameObject>) AccessTools.Field(typeof(ModeSelectMonitor), "_nullSetting").GetValue(__instance);
var animSetting = (List<Animator>) AccessTools.Field(typeof(ModeSelectMonitor), "_animSetting").GetValue(__instance);
for (int i = 0; i < SettingEnable.Count; i++)
{
nullSetting[i].transform.GetChild(0).GetChild(5).gameObject.SetActive(!SettingEnable[i]);
if (UserSettingToggleState[i])
{
animSetting[i].Play("On_Loop", 0, 0f);
__instance._settingMiniWindow.transform.GetChild(i).GetChild(0).GetChild(0).gameObject.SetActive(value: true);
__instance._settingMiniWindow.transform.GetChild(i).GetChild(0).GetChild(1).gameObject.SetActive(value: false);
}
else
{
animSetting[i].Play("Off_Loop", 0, 0f);
__instance._settingMiniWindow.transform.GetChild(i).GetChild(0).GetChild(0).gameObject.SetActive(value: false);
__instance._settingMiniWindow.transform.GetChild(i).GetChild(0).GetChild(1).gameObject.SetActive(value: true);
}
nullSetting[i].transform.GetChild(0).GetChild(4).GetChild(2).gameObject.SetActive(value: false);
}
}
catch (Exception e)
{
MelonLogger.Error(e);
}
}

private static void InitSettings(UserData userData)
{
SettingEnable[0] = SinmaiAssist.config.Common.ChangeGameSettings.CodeRead;
SettingEnable[1] = SinmaiAssist.config.Common.ChangeGameSettings.IconPhoto;
SettingEnable[2] = SinmaiAssist.config.Common.ChangeGameSettings.CharaSelect;
SettingEnable[3] = SinmaiAssist.config.Common.ChangeGameSettings.UploadPhoto;
UserSettingToggleState[0] = userData.Extend.ExtendContendBit.IsFlagOn(ExtendContentBitID.GotoCodeRead) && SettingEnable[0];
UserSettingToggleState[1] = userData.Extend.ExtendContendBit.IsFlagOn(ExtendContentBitID.GotoIconPhotoShoot) && SettingEnable[1];
UserSettingToggleState[2] = userData.Extend.ExtendContendBit.IsFlagOn(ExtendContentBitID.GotoCharaSelect) && SettingEnable[2];
UserSettingToggleState[3] = userData.Extend.ExtendContendBit.IsFlagOn(ExtendContentBitID.PhotoAgree) && SettingEnable[3];
MelonLogger.Msg("\n[ChangeGameSettings] SettingEnable:" + string.Join(",", SettingEnable) +"\n[ChangeGameSettings] UserSettingToggleState:" + string.Join(",", UserSettingToggleState));
}

private static void SetUserFlag(UserData userData)
{
if (!SettingEnable[0])
{
userData.Extend.ExtendContendBit.SetFlag(ExtendContentBitID.GotoCodeRead, false);
}
if (!SettingEnable[1])
{
userData.Extend.ExtendContendBit.SetFlag(ExtendContentBitID.GotoIconPhotoShoot, false);
}
if (!SettingEnable[2])
{
userData.Extend.ExtendContendBit.SetFlag(ExtendContentBitID.GotoCharaSelect, false);
}
if (!SettingEnable[3])
{
userData.Extend.ExtendContendBit.SetFlag(ExtendContentBitID.PhotoAgree, false);
}
}
}
10 changes: 10 additions & 0 deletions ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class CommonConfig
public CustomVersionTextConfig CustomVersionText { get; set; }
public DummyLoginConfig DummyLogin { get; set; }
public CustomCameraIdConfig CustomCameraId { get; set; }
public ChangeGameSettingsConfig ChangeGameSettings { get; set; }
}

public class SinglePlayerConfig
Expand All @@ -94,6 +95,15 @@ public class CustomVersionTextConfig
public string VersionText { get; set; }
}

public class ChangeGameSettingsConfig
{
public bool Enable { get; set; }
public bool CodeRead { get; set; }
public bool IconPhoto { get; set; }
public bool UploadPhoto { get; set; }
public bool CharaSelect { get; set; }
}

public class CheatConfig
{
public bool AutoPlay { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public override void OnInitializeMelon()
if (config.Common.IgnoreAnyGameInformation) Patch(typeof(IgnoreAnyGameInformation));
if (config.Common.ChangeDefaultOption) Patch(typeof(ChangeDefaultOption));
if (config.Common.ChangeFadeStyle) Patch(typeof(ChangeFadeStyle));
if (config.Common.ChangeGameSettings.Enable) Patch(typeof(ChangeGameSettings));

//Fix
if (config.Fix.DisableEncryption) Patch(typeof(DisableEncryption));
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This is a cheat Mod, using by your own risk.
- Skip Fade
- Ignore Information
- Change Default Option
- Change Game Settings
- Fix
- Disable Encryption
- Disable Reboot
Expand Down
1 change: 1 addition & 0 deletions Sinmai-Assist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@
<Compile Include="Common\CustomCameraId.cs" />
<Compile Include="Common\CustomVersionText.cs" />
<Compile Include="Common\DisableBackground.cs" />
<Compile Include="Common\ChangeGameSettings.cs" />
<Compile Include="Common\ForceQuickRetry.cs" />
<Compile Include="Common\SkipFade.cs" />
<Compile Include="Common\DisableMask.cs" />
Expand Down
99 changes: 53 additions & 46 deletions config - zh_CN.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,69 @@
common:
infinityTimer: false #无限计时器
disableMask: false #禁用遮罩
disableBackground: false #禁用背景
showFPS: false #显示FPS
singlePlayer: #单人模式
infinityTimer: false # 无限计时器
disableMask: false # 禁用遮罩
disableBackground: false # 禁用背景
showFPS: false # 显示FPS
singlePlayer: # 单人模式
enable: false # 是否启用
hideSubMonitor: false # 隐藏副屏
forceQuickRetry: false #强制开启Freedom模式的快速重试功能
forwardATouchRegionToButton: false #将触摸区域的操作转发到按钮
skipFade: false #跳过过场动画
skipWarningScreen: false #跳过警告界面
quickBoot: false #快速启动
blockCoin: false #禁用点数消耗
forceQuickRetry: false # 强制开启Freedom模式的快速重试功能
forwardATouchRegionToButton: false # 将触摸区域的操作转发到按钮
skipFade: false # 跳过过场动画
skipWarningScreen: false # 跳过警告界面
quickBoot: false # 快速启动
blockCoin: false # 禁用点数消耗
ignoreAnyGameInformation: false # 忽略之后所有的游戏公告信息提示
changeDefaultOption: false # 覆写游客模式默认设置
networkLogger: #网络日志
enable: false #是否启用
printToConsole: false #是否输出到控制台
customVersionText: #自定义版本文本
enable: false #是否启用
versionText: "" #版本文本
dummyLogin: # 虚拟登录
enable: false #是否启用
defaultUserId: 0 #默认用户ID
customCameraId: #自定义摄像头ID
enable: false #是否启用
chimeCameraId: 0 #Chime摄像头ID
leftQrCameraId: 0 #左侧二维码识别摄像头ID
rightQrCameraId: 0 #右侧二维码识别摄像头ID
photoCameraId: 0 #玩家摄像头ID
changeFadeStyle: false # 切换过场动画的样式(例如BUDDiES开启此选项后会使用BUDDiES PLUS的过场动画,BUDDiES PLUS开启此选项后会使用BUDDiES的过场动画)
networkLogger: # 网络日志
enable: false # 是否启用
printToConsole: false # 是否输出到控制台
customVersionText: # 自定义版本文本
enable: false # 是否启用
versionText: "" # 版本文本
dummyLogin: # 虚拟登录
enable: false # 是否启用
defaultUserId: 0 # 默认用户ID
customCameraId: # 自定义摄像头ID
enable: false # 是否启用
chimeCameraId: 0 # Chime摄像头ID
leftQrCameraId: 0 # 左侧二维码识别摄像头ID
rightQrCameraId: 0 # 右侧二维码识别摄像头ID
photoCameraId: 0 # 玩家摄像头ID
changeGameSettings: # 覆盖游戏的设置
enable: false # 是否启用
codeRead: false # 是否启用二维码识别(DX Pass)
iconPhoto: false # 是否启用拍摄头像功能
uploadPhoto: false # 是否启用拍摄纪念照上传
charaSelect: false # 是否启用角色选择界面


cheat:
autoPlay: false #自动游玩
fastSkip: false #快速跳过
chartTimer: false #铺面计时器(歌曲进度控制)
allCollection: false #解锁全部收藏品
unlockMusic: false #解锁全部歌曲
unlockMaster: false #解锁全部歌曲Master难度
unlockEvent: false #解锁全部活动
resetLoginBonusRecord: false #重置登录奖励记录
forceCurrentIsBest: false #强制当前游玩成绩为新成绩(可能会对Best50造成改动)
autoPlay: false # 自动游玩
fastSkip: false # 快速跳过
chartTimer: false # 铺面计时器(歌曲进度控制)
allCollection: false # 解锁全部收藏品
unlockMusic: false # 解锁全部歌曲
unlockMaster: false # 解锁全部歌曲Master难度
unlockEvent: false # 解锁全部活动
resetLoginBonusRecord: false # 重置登录奖励记录
forceCurrentIsBest: false # 强制当前游玩成绩为新成绩(可能会对Best50造成改动)
setAllCharacterAsSameAndLock: false # 设置5个相同的旅行伙伴并锁定设置(以队长为准)
rewriteLoginBonusStamp: # 重写每日登录奖励记录
enable: false # 是否启用
point: 0 # 登录奖励点数

fix:
disableEncryption: false #禁用加密
disableReboot: false #禁用自动重启
skipVersionCheck: false #登录时跳过版本检查
rewriteNoteJudgeTiming: #重写覆盖游戏音符判定 (如填10,则游戏内+1.0)
enable: false #是否启用
adjustTiming: 0.0 #音频延迟(单位:ms)
judgeTiming: 0.0 #判定延迟(单位:帧)
disableEncryption: false # 禁用加密
disableReboot: false # 禁用自动重启
skipVersionCheck: false # 登录时跳过版本检查
rewriteNoteJudgeTiming: # 重写覆盖游戏音符判定 (如填10,则游戏内+1.0)
enable: false # 是否启用
adjustTiming: 0.0 # 音频延迟(单位:ms)
judgeTiming: 0.0 # 判定延迟(单位:帧)

modSetting:
showInfo: false #显示信息
showPanel: false #显示面板
forceIsChinaBuild: false #强制加载SDGB only的补丁
safeMode: false #启用安全模式
showInfo: false # 显示信息
showPanel: false # 显示面板
forceIsChinaBuild: false # 强制以SDGB版本的方式加载补丁
safeMode: false # 启用安全模式
9 changes: 8 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
blockCoin: false
ignoreAnyGameInformation: false
changeDefaultOption: false
changeFadeStyle: false
networkLogger:
enable: false
printToConsole: false
Expand All @@ -29,7 +30,13 @@
leftQrCameraId: 0
rightQrCameraId: 0
photoCameraId: 0
changeFadeStyle: false
changeGameSettings:
enable: false
codeRead: false
iconPhoto: false
uploadPhoto: false
charaSelect: false


cheat:
autoPlay: false
Expand Down

0 comments on commit 5133b68

Please sign in to comment.