Skip to content

Commit

Permalink
修改 GetUserId合并到User类
Browse files Browse the repository at this point in the history
  • Loading branch information
WYH2004-MC committed Oct 12, 2024
1 parent 3f384a9 commit f1733f1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion GUI/ShowVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void OnGUI()
$"Data Version: {Singleton<SystemConfig>.Instance.config.dataVersionInfo.versionNo.versionString} {Singleton<SystemConfig>.Instance.config.dataVersionInfo.versionNo.releaseNoAlphabet}");
VersionText.AppendLine($"Current Title Server: {Server.GetTitleServerUri()}");
VersionText.AppendLine($"Keychip: {AMDaemon.System.KeychipId}");
VersionText.AppendLine($"UserId: {GetUserId.Get(0L)} | {GetUserId.Get(1L)}");
VersionText.AppendLine($"UserId: {User.GetUserIdString(0L)} | {User.GetUserIdString(1L)}");
if (SinmaiAssist.config.ModSetting.SafeMode)
VersionText.AppendLine("Safe Mode");
UnityEngine.GUI.Label(new Rect(10+2, 40+2, 500, 30), VersionText.ToString(), TextShadow);
Expand Down
1 change: 0 additions & 1 deletion Sinmai-Assist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@
<Compile Include="Utils\CipherAES.cs" />
<Compile Include="Common\InputManager.cs" />
<Compile Include="Utils\GameMessageManager.cs" />
<Compile Include="Utils\GetUserId.cs" />
<Compile Include="Utils\Keyboard.cs" />
<Compile Include="Utils\Server.cs" />
<Compile Include="Utils\User.cs" />
Expand Down
24 changes: 0 additions & 24 deletions Utils/GetUserId.cs

This file was deleted.

19 changes: 17 additions & 2 deletions Utils/User.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using MAI2.Util;
using MAI2System;
using Manager;
using MelonLoader.TinyJSON;
using Net.VO.Mai2;
using Path = System.IO.Path;

namespace SinmaiAssist.Utils;

Expand Down Expand Up @@ -86,11 +89,23 @@ public static string GetFavoriteList(UserData userData)
list += "}]";
return list;
}

public static UserData GetUserData(long index)
{
return Singleton<UserDataManager>.Instance.GetUserData(index);
}

public static string GetUserIdString(long index)
{
// 通过方法调用来获取常量值
var guestUserIdBase = GetGuestUserIDBase();
var userId = Singleton<UserDataManager>.Instance.GetUserData(index).Detail.UserID;
return userId == guestUserIdBase ? "Guest" : userId.ToString();
}


[MethodImpl(MethodImplOptions.NoInlining)]
private static ulong GetGuestUserIDBase()
{
return ConstParameter.GuestUserIDBase;
}
}

0 comments on commit f1733f1

Please sign in to comment.