From 5bcd55c00dc7d62d9039774ce27ef822a96454bc Mon Sep 17 00:00:00 2001 From: pengtaihao Date: Thu, 24 Aug 2023 14:33:32 +0800 Subject: [PATCH] Initial commit --- .gitignore | 41 +++++++++++++++ Cheat.csproj | 70 ++++++++++++++++++++++++++ Cheat.sln | 25 ++++++++++ CheatAdvView.cs | 49 ++++++++++++++++++ CheatListView.cs | 61 +++++++++++++++++++++++ CheatOpeningView.cs | 30 +++++++++++ CheatStoryTypeView.cs | 41 +++++++++++++++ CheatUtil.cs | 108 ++++++++++++++++++++++++++++++++++++++++ EventQuestView.Cheat.cs | 19 +++++++ FreeAdvView.Cheat.cs | 23 +++++++++ MainAdvView.Cheat.cs | 26 ++++++++++ README.md | 2 + 12 files changed, 495 insertions(+) create mode 100644 .gitignore create mode 100644 Cheat.csproj create mode 100644 Cheat.sln create mode 100644 CheatAdvView.cs create mode 100644 CheatListView.cs create mode 100644 CheatOpeningView.cs create mode 100644 CheatStoryTypeView.cs create mode 100644 CheatUtil.cs create mode 100644 EventQuestView.Cheat.cs create mode 100644 FreeAdvView.Cheat.cs create mode 100644 MainAdvView.Cheat.cs create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..33d585e --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# ---> core +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode + +# Rider +.idea + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio 2015 +.vs/ + + +Properties diff --git a/Cheat.csproj b/Cheat.csproj new file mode 100644 index 0000000..e725ecd --- /dev/null +++ b/Cheat.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {5A642931-00E1-4A5C-A6BA-4ECB4A66A2EA} + Library + Properties + Cheat + Cheat + v4.7.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + ..\UnityDLL\UnityEngine.dll + + + ..\UnityDLL\UnityEngine.CoreModule.dll + + + ..\UnityDLL\UnityEngine.IMGUIModule.dll + + + + + + + + + + + + + + + + {9e492ea5-4b91-4385-a199-4c2e340a7008} + Hotfix + + + + \ No newline at end of file diff --git a/Cheat.sln b/Cheat.sln new file mode 100644 index 0000000..382c797 --- /dev/null +++ b/Cheat.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cheat", "Cheat.csproj", "{13FEA5D7-430C-4B36-9626-7A4FD1233A1A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {13FEA5D7-430C-4B36-9626-7A4FD1233A1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13FEA5D7-430C-4B36-9626-7A4FD1233A1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13FEA5D7-430C-4B36-9626-7A4FD1233A1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13FEA5D7-430C-4B36-9626-7A4FD1233A1A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E1886CDA-C6A3-4F72-B9F7-85C7DBC5255F} + EndGlobalSection +EndGlobal diff --git a/CheatAdvView.cs b/CheatAdvView.cs new file mode 100644 index 0000000..18ad4f0 --- /dev/null +++ b/CheatAdvView.cs @@ -0,0 +1,49 @@ + +using System.Collections.Generic; +using UnityEngine; + +namespace Mly.Hotfix +{ + public interface ICheatOpenStage + { + CheatAdvView CheatView { get; set; } + void CheatOpenStagesTo(int id); + } + + public interface ICheatOpenAllStages + { + void CheatOpenAllStages(); + } + + public class CheatAdvView : CheatListView + { + public ICheatOpenStage View; + public LocalAdvChap Chap; + + protected override IList List => Chap?.AdvMapList; + + protected override string GetItemText(LocalAdvMap item) + { + return item.Name1; + } + + protected override void OnClickItem(LocalAdvMap item) + { + View.CheatOpenStagesTo(item.Id); + } + + protected override void UpdateList() + { + base.UpdateList(); + + if (View is ICheatOpenAllStages v) + { + if (GUI.Button(CheatUtil.GetNextRect(), $"All", CheatUtil.GetGUIButtonStyle())) + { + v.CheatOpenAllStages(); + } + CheatUtil.PointToNext(); + } + } + } +} diff --git a/CheatListView.cs b/CheatListView.cs new file mode 100644 index 0000000..f714d88 --- /dev/null +++ b/CheatListView.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace Mly.Hotfix +{ + public abstract class CheatListView : MonoBehaviour + { + /// + /// 按钮列表 + /// + protected abstract IList List { get; } + + protected virtual GUIStyle ItemStyle => CheatUtil.GetGUIButtonStyle(); + + private bool collapse; + + protected virtual void Awake() + { + CheatUtil.AutoScaling(); + } + + protected virtual void OnGUI() + { + UpdateView(); + } + + protected virtual void UpdateView() + { + if (List == null) + return; + + CheatUtil.PointToStart(); + + if (collapse) + UpdateList(); + + if (GUI.Button(CheatUtil.GetNextRect(), collapse ? "收起" : "展开", ItemStyle)) + collapse = !collapse; + } + + protected virtual void UpdateList() + { + CheatUtil.DrawCheatList(List, (item, rect) => + { + if (GUI.Button(rect, GetItemText(item), ItemStyle)) + OnClickItem(item); + }); + } + + /// + /// 按钮文字 + /// + protected abstract string GetItemText(T item); + + /// + /// 按钮点击 + /// + protected abstract void OnClickItem(T item); + } +} + diff --git a/CheatOpeningView.cs b/CheatOpeningView.cs new file mode 100644 index 0000000..ff2e81f --- /dev/null +++ b/CheatOpeningView.cs @@ -0,0 +1,30 @@ + +using UnityEngine; + +namespace Mly.Hotfix +{ + public class CheatOpeningView: MonoBehaviour + { + public bool SkipPrologue; + + void Awake() + { + SkipPrologue = PlayerPrefs.GetInt("Cheat_SkipPrologue", 0) == 1; + + } + public void OnGUI() + { + var style = CheatUtil.GetGUIButtonStyle(); + style.normal.textColor = Color.white; + style.fontSize = 30; + var val = GUI.Toggle(new Rect(10, 100, 300, 100), SkipPrologue, SkipPrologue ? "跳过序章中" : "点击跳过序章", style); + if (val != SkipPrologue) + { + SkipPrologue = val; + PlayerPrefs.SetInt("Cheat_SkipPrologue", SkipPrologue ? 1 : 0); + } + + } + } +} + diff --git a/CheatStoryTypeView.cs b/CheatStoryTypeView.cs new file mode 100644 index 0000000..affeac3 --- /dev/null +++ b/CheatStoryTypeView.cs @@ -0,0 +1,41 @@ + +using UnityEngine; + +namespace Mly.Hotfix +{ + public class CheatStoryTypeView : MonoBehaviour + { + public bool SkipStory; + public bool UnLockAllStory; + private GUIStyle _GUIStyle; + public void Awake() + { + SkipStory = PlayerPrefs.GetInt("SkipStory", 0) == 1; + UnLockAllStory = PlayerPrefs.GetInt("UnLockAllStory", 0) == 1; + + } + + + public void OnGUI() + { + var style = CheatUtil.GetGUIButtonStyle(); + style.normal.textColor = Color.white; + style.fontSize = 30; + + var val = GUI.Toggle(new Rect(10, 100, 300, 100), SkipStory, SkipStory ? "跳过剧情中" : "点击跳过剧情", style); + var val2 = GUI.Toggle(new Rect(10, 300, 300, 100), UnLockAllStory, UnLockAllStory ? "解锁全部剧情中" : "点击解锁全部剧情", style); + if (val != SkipStory) + { + SkipStory = val; + PlayerPrefs.SetInt("SkipStory", SkipStory ? 1 : 0); + } + if (val2 != UnLockAllStory) + { + UnLockAllStory = val2; + PlayerPrefs.SetInt("UnLockAllStory", UnLockAllStory ? 1 : 0); + } + } + } +} + + diff --git a/CheatUtil.cs b/CheatUtil.cs new file mode 100644 index 0000000..6b5e96c --- /dev/null +++ b/CheatUtil.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Mly.Hotfix +{ + public static class CheatUtil + { + public static float StartX = 100; + public static float StartY = 100; + public static float SpaceX = 10; + public static float SpaceY = 10; + public static float W = 110; + public static float H = 30; + public static int Columns = 5; + public static int X; + public static int Y; + + private static float startX; + private static float startY; + private static float spaceX; + private static float spaceY; + + public static void AutoScaling() + { + var wa = Screen.width / 1280f; + var ha = Screen.height / 720f; + startX = StartX * wa; + startY = StartY * ha; + spaceX = SpaceX * wa; + spaceY = SpaceY * ha; + } + + public static void PointToStart() + { + X = Y = 0; + } + + public static void PointToNext() + { + if (++X >= Columns) + { + X = 0; + ++Y; + } + } + + public static void PointToNewLine() + { + if (X > 0) + { + ++Y; + } + X = 0; + } + + public static Rect GetNextRect() + { + return new Rect(startX + X * (W + spaceX), startY + Y * (H + spaceY), W, H); + } + + public static void DrawCheatList(IList list, Action action) + { + for (int i = 0; i < list.Count; i++) + { + var item = list[i]; + action?.Invoke(item, GetNextRect()); + PointToNext(); + } + PointToNewLine(); + } + + public static GUIStyle GetGUIButtonStyle() + { + return GetGUIStyle(GUI.skin.button); + } + + public static GUIStyle GetGUIStyle(GUIStyle style) + { + return new GUIStyle(style); + } + + public static CheatAdvView AddCheatView(ICheatOpenStage view, GameObject go) + { + + + + + var cheat = go.AddComponent(); + cheat.View = view; + return cheat; + } + + + + + public static void Init() + { + CheatInteractor.ActionMap.Add(typeof(EventQuestView), vc => + { + + var cheatV = vc.GameObject.AddComponent(); + //cheatV.View = vc; + }); + } + } +} + diff --git a/EventQuestView.Cheat.cs b/EventQuestView.Cheat.cs new file mode 100644 index 0000000..fbcd9bb --- /dev/null +++ b/EventQuestView.Cheat.cs @@ -0,0 +1,19 @@ +namespace Mly.Hotfix +{ + //public partial class EventQuestView : ICheatOpenStage + //{ + // public CheatAdvView CheatView { get; set; } + //} + + //public partial class EventQuestView + //{ + + // public void SetCheatChap(LocalAdvChap chap) + // { + // if (CheatView != null) + // { + // CheatView.Chap = chap; + // } + // } + //} +} diff --git a/FreeAdvView.Cheat.cs b/FreeAdvView.Cheat.cs new file mode 100644 index 0000000..67d57f7 --- /dev/null +++ b/FreeAdvView.Cheat.cs @@ -0,0 +1,23 @@ +namespace Mly.Hotfix +{ + //public partial class FreeAdvView : ICheatOpenStage + //{ + // public CheatAdvView CheatView { get; set; } + //} + + //public partial class FreeAdvView + //{ + // private void InitCheatView() + // { + // CheatView = CheatUtil.AddCheatView(this, GameObject); + // } + + // private void SetCheatChap(LocalAdvChap chap) + // { + // if (CheatView != null) + // { + // CheatView.Chap = chap; + // } + // } + //} +} diff --git a/MainAdvView.Cheat.cs b/MainAdvView.Cheat.cs new file mode 100644 index 0000000..e493ea9 --- /dev/null +++ b/MainAdvView.Cheat.cs @@ -0,0 +1,26 @@ +namespace Mly.Hotfix +{ + + //public partial class MainAdvView : ICheatOpenStage, ICheatOpenAllStages + //{ + // public CheatAdvView CheatView { get; set; } + //} + + + //public partial class MainAdvView + //{ + // private void InitCheatView() + // { + // CheatView = CheatUtil.AddCheatView(this, GameObject); + + // } + + // private void SetCheatChap() + // { + // if (CheatView != null) + // { + // CheatView.Chap = normal ? normalSSV.AdvChap : hardSSV.AdvChap; + // } + // } + //} +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..fb4ba20 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# mly2023cheat +