Skip to content

Commit 4b089bc

Browse files
committed
release, feat: 更新1.1.2,添加对newest/targetVersion文件夹的支持
1 parent a141d38 commit 4b089bc

9 files changed

Lines changed: 65 additions & 17 deletions

File tree

RandomBuff/BuffPlugin.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal partial class BuffPlugin : BaseUnityPlugin
6060

6161
public const string ModId = "randombuff";
6262

63-
public const string ModVersion = "1.1.1";
63+
public const string ModVersion = "1.1.2";
6464

6565
public static string CacheFolder { get; private set; }
6666

@@ -74,6 +74,8 @@ internal partial class BuffPlugin : BaseUnityPlugin
7474
private static bool isLoaded = false;
7575
private static bool canAccessLog = true;
7676

77+
public static string GameVersion;
78+
7779
#if TESTVERSION
7880
internal static bool DevEnabled => true;
7981
private FStage devVersion;
@@ -87,7 +89,10 @@ public void OnEnable()
8789
LogInstance = this.Logger;
8890
Instance = this;
8991

90-
92+
var replace = File.ReadAllLines("doorstop_config.ini").First(i =>
93+
i.Contains("enabledVersionPath=")).Replace("enabledVersionPath=","");
94+
GameVersion = File.ReadAllText(replace);
95+
9196
try
9297
{
9398
On.RainWorld.OnModsInit += RainWorld_OnModsInit;
@@ -143,9 +148,8 @@ private void OnModsInit()
143148
HookILCursor();
144149

145150
basePath = ModManager.ActiveMods.First(i => i.id == ModId).basePath;
146-
Log($"Version: {ModVersion}, Current save version: {saveVersion}, {DateTime.Now}");
147-
148-
151+
Log($"Version: {ModVersion},Game Version:{GameVersion}," +
152+
$" Current save version: {saveVersion}, {DateTime.Now}");
149153

150154
CheckBuffPluginVersion();
151155

@@ -361,8 +365,8 @@ private void CheckBuffPluginVersion()
361365
}
362366

363367
foreach (var mod in ModManager.ActiveMods.Where(i =>
364-
Directory.Exists(Path.Combine(i.basePath, "buffplugins")) ||
365-
Directory.Exists(Path.Combine(i.basePath, "buffassets"))))
368+
Directory.Exists(Path.Combine(i.BestMatchedPath("buffplugins"), "buffplugins")) ||
369+
Directory.Exists(Path.Combine(i.BestMatchedPath("buffassets"), "buffassets"))))
366370
{
367371
if (lastVersion.TryGetValue(mod.id, out var version))
368372
{
@@ -397,8 +401,8 @@ private void CheckBuffPluginVersion()
397401
foreach (var all in Directory.GetFiles(CacheFolder, $"*"))
398402
File.Delete(all);
399403
File.WriteAllLines(Path.Combine(SaveFolder, "BuffPluginVersion.txt"), ModManager.ActiveMods.Where(i =>
400-
Directory.Exists(Path.Combine(i.basePath, "buffplugins")) ||
401-
Directory.Exists(Path.Combine(i.basePath, "buffassets")))
404+
Directory.Exists(Path.Combine(i.BestMatchedPath("buffplugins"), "buffplugins")) ||
405+
Directory.Exists(Path.Combine(i.BestMatchedPath("buffassets"), "buffassets")))
402406
.Select(i => $"{i.id}|{i.version}")
403407
.ToArray());
404408
}

RandomBuff/Core/BuffMenu/BuffGameMenu.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ void OnDataLoaded()
172172
BuffOptionInterface.Instance.DisableNotifyDialog.Value = true;
173173
BuffOptionInterface.SaveConfig();
174174
}
175+
176+
if (BuffPlugin.GameVersion != "v1.9.15b" && !BuffOptionInterface.Instance.HasShownWarning.Value)
177+
{
178+
testNotification.NewInfoNotification(BuffResourceString.Get("Notification_WatcherVersionWarning_Title"),BuffResourceString.Get("Notification_WatcherVersionWarning_Info"));
179+
BuffOptionInterface.Instance.HasShownWarning.Value = true;
180+
BuffOptionInterface.SaveConfig();
181+
}
175182
if((BuffConfigManager.IsItemLocked(QuestUnlockedType.Cosmetic, "Crown") || BuffPlugin.DevEnabled) && BuffOptionInterface.Instance.ShowUnlockWawaFuncNotification.Value)
176183
{
177184
testNotification.NewInfoNotification(BuffResourceString.Get("Notification_UnlockWawa_Title"), BuffResourceString.Get("Notification_UnlockWawa_Info"));

RandomBuff/Core/Entry/BuffRegister.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,10 @@ internal static void InitAllBuffPlugins()
485485

486486
foreach (var mod in ModManager.ActiveMods)
487487
{
488-
string path = mod.path + Path.DirectorySeparatorChar + "buffplugins";
489-
if (!Directory.Exists(path))
488+
string path = Path.Combine(mod.BestMatchedPath("buffplugins"), "buffplugins");
489+
if(!Directory.Exists(path))
490490
continue;
491+
491492
BuffPlugin.Log($"Find correct path in {mod.id} to load plugins");
492493
DirectoryInfo info = new DirectoryInfo(path);
493494

@@ -840,8 +841,8 @@ private static AssemblyDefinition BuildCachePlugin(ModManager.Mod mod,string fil
840841
{
841842
hasPdb = File.Exists(filePath.Replace(".dll", ".pdb"));
842843
var resolver = new DefaultAssemblyResolver();
843-
resolver.AddSearchDirectory(ModManager.ActiveMods.First(i => i.id == BuffPlugin.ModId).path + "/plugins");
844-
resolver.AddSearchDirectory(ModManager.ActiveMods.First(i => i.id == BuffPlugin.ModId).path + "/buffplugins");
844+
resolver.AddSearchDirectory(ModManager.ActiveMods.First(i => i.id == BuffPlugin.ModId).BestMatchedPath("plugins") + "/plugins");
845+
resolver.AddSearchDirectory(ModManager.ActiveMods.First(i => i.id == BuffPlugin.ModId).BestMatchedPath("buffplugins") + "/buffplugins");
845846

846847
foreach (var modPath in ModManager.ActiveMods.Where(i => mod.requirements.Contains(i.id)
847848
&& i.requirements.Contains(BuffPlugin.ModId)))

RandomBuff/Core/Hooks/CoreHooks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using RandomBuff.Core.SaveData;
2222
using RandomBuff.Core.StaticsScreen;
2323
using RandomBuff.Credit;
24+
using RandomBuff.Render.UI.Notification;
2425
using RandomBuffUtils;
2526
using RWCustom;
2627
using UnityEngine;

RandomBuff/Core/Option/BuffOptionInterface.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public BuffOptionInterface()
5757
DisableCardPocketConflict = config.Bind(nameof(DisableCardPocketConflict), false);
5858
EnableDevChat = config.Bind(nameof(EnableDevChat), false);
5959
ShowUnlockWawaFuncNotification = config.Bind(nameof(ShowUnlockWawaFuncNotification), true);
60+
HasShownWarning = config.Bind(nameof(HasShownWarning), false);
6061
Instance = this;
6162

6263
}
@@ -329,6 +330,8 @@ private void AppendItems(OpTab tab, ref float yIndex, params UIelement[] element
329330
public Configurable<bool> ShowExceptionLog { get; private set; }
330331

331332
public Configurable<bool> CheatAllCards { get; private set; }
333+
334+
public Configurable<bool> HasShownWarning { get; private set; }
332335
public Configurable<bool> CheatAllCosmetics { get; private set; }
333336

334337
public Configurable<bool> EnableExpeditionModExtend { get; private set; }

RandomBuff/Core/SaveData/BuffStaticDataManager.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ internal static void InitBuffPluginInfo()
186186
Futile.atlasManager.LoadImage("buffassets/illustrations/default_thumbnail");
187187
foreach (var mod in ModManager.ActiveMods)
188188
{
189-
string root = Path.Combine(mod.basePath, "buffinfos");
189+
string root = Path.Combine(mod.BestMatchedPath("buffinfos"), "buffinfos");
190190
if (!Directory.Exists(root))
191191
continue;
192192
foreach (var dir in new DirectoryInfo(root).GetDirectories())
@@ -225,7 +225,7 @@ internal static void InitBuffPluginInfo()
225225

226226
private static IEnumerable<string> GetPluginFolder(ModManager.Mod mod, string folderName)
227227
{
228-
string root = Path.Combine(mod.basePath, "buffinfos");
228+
string root = Path.Combine(mod.BestMatchedPath("buffinfos"), "buffinfos");
229229
if (!Directory.Exists(root))
230230
yield break;
231231

@@ -239,9 +239,10 @@ private static IEnumerable<string> GetPluginFolder(ModManager.Mod mod, string fo
239239
}
240240
private static IEnumerable<(string, string)> GetPluginFolderWithId(ModManager.Mod mod, string folderName)
241241
{
242-
string root = Path.Combine(mod.basePath, "buffinfos");
242+
string root = Path.Combine(mod.BestMatchedPath("buffinfos"),"buffinfos");
243243
if (!Directory.Exists(root))
244244
yield break;
245+
245246

246247
foreach (var dir in new DirectoryInfo(root).GetDirectories())
247248
{
@@ -306,7 +307,7 @@ internal static void InitBuffStaticData()
306307
new CustomAttributeArgument(assembly.MainModule.TypeSystem.Boolean, true)));
307308

308309
PluginStaticDataTable.Add(pluginId, new());
309-
LoadInDirectory(new DirectoryInfo(path), new DirectoryInfo(mod.path).FullName, pluginId);
310+
LoadInDirectory(new DirectoryInfo(path), new DirectoryInfo(mod.BestMatchedPath("buffinfo")).FullName, pluginId);
310311

311312
if (CreateStaticDataCache(assembly.MainModule, mod.id, pluginId))
312313
assembly.Write(Path.Combine(BuffPlugin.CacheFolder, $"{mod.id}_{pluginId}_dataCache.dll"));

RandomBuff/Helper.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Collections;
1111
using System.Collections.Generic;
1212
using System.Diagnostics;
13+
using System.IO;
1314
using System.Linq;
1415
using System.Reflection;
1516
using System.Reflection.Emit;
@@ -26,6 +27,32 @@ namespace RandomBuff
2627
/// </summary>
2728
public static class Helper
2829
{
30+
31+
public static string BestMatchedPath(this ModManager.Mod mod)
32+
{
33+
if (mod.hasTargetedVersionFolder)
34+
return mod.TargetedPath;
35+
else if (mod.hasNewestFolder)
36+
return mod.NewestPath;
37+
return mod.path;
38+
}
39+
40+
public static string BestMatchedPath(this ModManager.Mod mod, string withCheck)
41+
{
42+
if (mod.hasTargetedVersionFolder && Directory.Exists(Path.Combine(mod.TargetedPath,withCheck)))
43+
return mod.TargetedPath;
44+
else if (mod.hasNewestFolder && Directory.Exists(Path.Combine(mod.NewestPath,withCheck)))
45+
return mod.NewestPath;
46+
return mod.path;
47+
}
48+
public static IEnumerable<string> SortedPaths(this ModManager.Mod mod)
49+
{
50+
if (mod.hasTargetedVersionFolder)
51+
yield return mod.TargetedPath;
52+
if (mod.hasNewestFolder)
53+
yield return mod.NewestPath;
54+
yield return mod.path;
55+
}
2956
/// <summary>
3057
/// 按键跟踪简化类
3158
/// </summary>

buffassets/resourceStrings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Notification_MissionReward_Unique|Unlock exclusive mission
5656
Notification_CosmeticReward|Unlock cosmetic
5757
Notification_CardReward|Unlock card
5858
Notification_FreePickReward|Unlock free pick count
59+
Notification_WatcherVersionWarning_Title|Unstable Version Warning:
60+
Notification_WatcherVersionWarning_Info|Random Buff may be unstable in the new version and could cause exceptions or game crashes. <LINE>If an exception occurs, please keep an eye on the exception notifications (if enabled) and files below:<LINE>exceptionLog.txt (locate at root path of rainworld)<LINE>buffcore.txt (locate at Rain World\RainWorld_Data\StreamingAssets)
5961
Notification_TooManyMods_Title|Mod amount warning:
6062
Notification_TooManyMods_Info|It seems you have enabled too many mods, be aware that this may cause more exception or crash.<LINE>If an exception occurs, please keep an eye on the exception notifications (if enabled) and files below:<LINE>exceptionLog.txt (locate at root path of rainworld)<LINE>buffcore.txt (locate at Rain World\RainWorld_Data\StreamingAssets)
6163
Notification_UnlockWawa_Title|Hiden function unlocked:

buffassets/resourceStrings_Chinese.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Notification_MissionReward_Unique|解锁专属使命
5757
Notification_CosmeticReward|解锁装饰品
5858
Notification_CardReward|解锁卡牌
5959
Notification_FreePickReward|解锁自由抽卡数
60+
Notification_WatcherVersionWarning_Title|版本不稳定警告:
61+
Notification_WatcherVersionWarning_Info|新版本下卡牌mod暂时还不稳定,可能会有异常或或导致游戏崩溃。<LINE>如果出现异常,请留意 报错提示(如有启用)和 以下文件:<LINE>exceptionLog.txt(位于 雨世界根目录)<LINE>buffcore.txt(位于 Rain World\RainWorld_Data\StreamingAssets)
6062
Notification_TooManyMods_Title|启用mod数量警告:
6163
Notification_TooManyMods_Info|看起来你启用了很多的mod,请注意这有可能会造成更多的异常或游戏崩溃。<LINE>如果出现异常,请留意 报错提示(如有启用)和 以下文件:<LINE>exceptionLog.txt(位于 雨世界根目录)<LINE>buffcore.txt(位于 Rain World\RainWorld_Data\StreamingAssets)
6264
Notification_UnlockWawa_Title|隐藏功能解锁:

0 commit comments

Comments
 (0)