From fb8dffd5b80a0dd7e8539e068b19d6fb4cf41fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E5=B0=8F=E7=9A=AE-ZengXiaoPi?= <1768506869@qq.com> Date: Wed, 7 Feb 2024 14:28:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E6=A8=A1=E6=8B=9F=E5=99=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MainPage.Designer.cs | 25 ++++++-- src/MainPage.cs | 134 +++++++++++++++++++++++++++++++++++++-- src/MainPage.resx | 30 ++++----- 3 files changed, 166 insertions(+), 23 deletions(-) diff --git a/src/MainPage.Designer.cs b/src/MainPage.Designer.cs index 19efd46..186feb9 100644 --- a/src/MainPage.Designer.cs +++ b/src/MainPage.Designer.cs @@ -34,6 +34,7 @@ private void InitializeComponent() this.tabPage1 = new System.Windows.Forms.TabPage(); this.uiTabControl1 = new Sunny.UI.UITabControl(); this.tabPage8 = new System.Windows.Forms.TabPage(); + this.PersonalButton = new Sunny.UI.UISymbolButton(); this.TipText = new Sunny.UI.UILabel(); this.statu = new Sunny.UI.UILabel(); this.DownloadBar = new Sunny.UI.UIProcessBar(); @@ -180,6 +181,7 @@ private void InitializeComponent() // tabPage8 // this.tabPage8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255))))); + this.tabPage8.Controls.Add(this.PersonalButton); this.tabPage8.Controls.Add(this.TipText); this.tabPage8.Controls.Add(this.statu); this.tabPage8.Controls.Add(this.DownloadBar); @@ -191,6 +193,20 @@ private void InitializeComponent() this.tabPage8.TabIndex = 0; this.tabPage8.Text = "自动安装(推荐)"; // + // PersonalButton + // + this.PersonalButton.Cursor = System.Windows.Forms.Cursors.Hand; + this.PersonalButton.Font = new System.Drawing.Font("微软雅黑", 12F); + this.PersonalButton.Location = new System.Drawing.Point(856, 343); + this.PersonalButton.MinimumSize = new System.Drawing.Size(1, 1); + this.PersonalButton.Name = "PersonalButton"; + this.PersonalButton.Size = new System.Drawing.Size(183, 43); + this.PersonalButton.Symbol = 262682; + this.PersonalButton.TabIndex = 5; + this.PersonalButton.Text = "抽卡模拟器"; + this.PersonalButton.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.PersonalButton.Click += new System.EventHandler(this.PersonalButton_Click); + // // TipText // this.TipText.Font = new System.Drawing.Font("微软雅黑", 12F); @@ -742,7 +758,7 @@ private void InitializeComponent() this.tabPage3.Controls.Add(this.uiGroupBox2); this.tabPage3.Location = new System.Drawing.Point(0, 40); this.tabPage3.Name = "tabPage3"; - this.tabPage3.Size = new System.Drawing.Size(1077, 443); + this.tabPage3.Size = new System.Drawing.Size(200, 60); this.tabPage3.TabIndex = 1; this.tabPage3.Text = "设置"; // @@ -993,7 +1009,7 @@ private void InitializeComponent() this.tabPage4.Controls.Add(this.uiLabel8); this.tabPage4.Location = new System.Drawing.Point(0, 40); this.tabPage4.Name = "tabPage4"; - this.tabPage4.Size = new System.Drawing.Size(200, 60); + this.tabPage4.Size = new System.Drawing.Size(1077, 443); this.tabPage4.TabIndex = 1; this.tabPage4.Text = "关于"; // @@ -1005,7 +1021,7 @@ private void InitializeComponent() this.uiLabel9.Name = "uiLabel9"; this.uiLabel9.Size = new System.Drawing.Size(502, 36); this.uiLabel9.TabIndex = 1; - this.uiLabel9.Text = "LLC_Toolbox 版本0.6.2"; + this.uiLabel9.Text = "LLC_Toolbox 版本0.6.3"; this.uiLabel9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // uiLabel8 @@ -1269,7 +1285,7 @@ private void InitializeComponent() this.Padding = new System.Windows.Forms.Padding(0, 40, 0, 0); this.ShowRect = false; this.ShowTitleIcon = true; - this.Text = "都市零协会模组工具箱 v0.6.2"; + this.Text = "都市零协会模组工具箱 v0.6.3"; this.TitleFont = new System.Drawing.Font("微软雅黑", 12F); this.TitleHeight = 40; this.ZoomScaleRect = new System.Drawing.Rectangle(15, 15, 800, 450); @@ -1374,6 +1390,7 @@ private void InitializeComponent() private System.Windows.Forms.Timer TipTimer; private Sunny.UI.UIButton uiButton1; private Sunny.UI.UILabel uiLabel4; + private Sunny.UI.UISymbolButton PersonalButton; } } diff --git a/src/MainPage.cs b/src/MainPage.cs index 567864e..f2a1fe4 100644 --- a/src/MainPage.cs +++ b/src/MainPage.cs @@ -18,6 +18,7 @@ 6. 没有注释! using SimpleJSON; using Sunny.UI; using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net; @@ -28,14 +29,16 @@ 6. 没有注释! using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; +using static System.Net.Mime.MediaTypeNames; namespace LLC_MOD_Toolbox { public partial class MainPage : UIForm { - public const string VERSION = "0.6.2"; + public const string VERSION = "0.6.3"; private string tipTexts; + private string personalTexts; private readonly string TipsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tips.txt"); // 注册日志系统 private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -136,9 +139,14 @@ private void Init_Toolbox() } } tipTexts = File.ReadAllText(TipsPath); - Application.DoEvents(); + System.Windows.Forms.Application.DoEvents(); TipTimer.Enabled = true; VERY_SECRET_APRIL_FOOL_METHOD(); + personalTexts = GetWikiPersonalText(); + if (personalTexts == null) + { + PersonalButton.Visible = false; + } } /// @@ -544,6 +552,7 @@ private void ControlButton(bool CanUse) uiTabControl.Enabled = true; installButton.Enabled = true; deleteButton.Enabled = true; + PersonalButton.Enabled = true; logger.Info("开启完成。"); } else @@ -552,6 +561,7 @@ private void ControlButton(bool CanUse) uiTabControl.Enabled = false; installButton.Enabled = false; deleteButton.Enabled = false; + PersonalButton.Enabled = false; logger.Info("关闭完成。"); } } @@ -1599,9 +1609,126 @@ private void VERY_SECRET_APRIL_FOOL_METHOD() if (currentDate.Month == 4 && currentDate.Day == 1) { logger.Info("您猜怎么着?今儿四月一!"); + AprilFoolMode = true; + MessageBox.Show("抽卡模拟器的概率发生了一些微妙的变化……", "提示...?", MessageBoxButtons.OK, MessageBoxIcon.Question); } } + #endregion + + #region 抽卡模拟器 + /// + /// 从Wiki获得人格数据库Json + /// + /// 页面原始数据 + public static string GetWikiPersonalText() + { + logger.Info("获取Wiki人格数据。"); + try + { + using WebClient client = new(); + client.Headers.Add("User-Agent", "request"); + string raw = string.Empty; + logger.Info("从Wiki获取原始文本"); + raw = new StreamReader(client.OpenRead(new Uri("https://limbuscompany.huijiwiki.com/w/api.php?action=query&format=json&prop=revisions&rvprop=content&titles=Data:Identitychoose.tabx")), Encoding.UTF8).ReadToEnd(); + var wikitext = JSONNode.Parse(raw).AsObject; + string originText = wikitext["query"]["pages"]["4338"]["revisions"][0]["*"].Value; + string resultText = originText.Replace("\\", ""); + return resultText; + } + catch (Exception ex) + { + logger.Error("出现了问题。\n" + ex.ToString()); + return null; + } + } + /// + /// 点击抽卡模拟器逻辑 + /// + /// + /// + private void PersonalButton_Click(object sender, EventArgs e) + { + int[] PersonalData = PersonalDataGen(AprilFoolMode); + var PersonalObject = JSONNode.Parse(personalTexts).AsObject; + int PersonalCount = PersonalObject["data"].Count; + string[] PersonalList = new string[10]; + int CachePersonal; + Random rand = new Random(); + // 高危代码。如果有问题先看看这里。 + try + { + for (int i = 0; i < PersonalData.Length; i++) + { + while (true) + { + CachePersonal = rand.Next(0, PersonalCount - 1); + if (PersonalObject["data"][CachePersonal][6] == PersonalData[i]) + { + PersonalList[i] = PersonalObject["data"][CachePersonal][6] + "★ | " + PersonalObject["data"][CachePersonal][0]; + break; + } + } + } + string message = "抽卡结果:\n"; + for (int i = 0; i < PersonalData.Length; i++) + { + message += PersonalList[i] + "\n"; + } + message += "下次还抽吗?"; + MessageBox.Show(message, "结果"); + } + catch(Exception ex) + { + logger.Error("出现了问题。\n" + ex.ToString()); + MessageBox.Show("出现了问题\n" + ex.ToString()); + } + } + /// + /// 生成人格品质 + /// + /// 是否为愚人节,若为愚人节,只会生成1。 + /// 一个int[],内含有10个1,2,3,代表人格品质 + public static int[] PersonalDataGen(bool AprilMode) + { + Random random = new Random(); + int[] numbers = new int[10]; + + for (int i = 0; i < numbers.Length; i++) + { + int randomNumber = random.Next(1, 101); + if (!AprilMode) + { + if (i == 9) + { + if (randomNumber <= 3) + { + numbers[i] = 3; + } + else + { + numbers[i] = 2; + } + } + else + { + if (randomNumber <= 13) + { + numbers[i] = 2; + } + else + { + numbers[i] = 1; + } + } + } + else + { + numbers[i] = 1; + } + } + return numbers; + } #endregion private void downloadFile_Click(object sender, EventArgs e) { @@ -1640,8 +1767,6 @@ private void uiButton1_Click(object sender, EventArgs e) MessageBox.Show("开关失败。是否还未安装模组?", "错误"); } } - private bool isWindows10; - private string node = string.Empty; private string limbusCompanyDir; @@ -1657,5 +1782,6 @@ private void uiButton1_Click(object sender, EventArgs e) private bool mirrorGithub = false; private bool useGithub; + private bool AprilFoolMode = false; } } \ No newline at end of file diff --git a/src/MainPage.resx b/src/MainPage.resx index 6e40c0e..f523415 100644 --- a/src/MainPage.resx +++ b/src/MainPage.resx @@ -117,6 +117,21 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 汉化:零协会全体成员 +首席外交官(划掉)LLTT系长:N071(北岚) +LLC部长:Bright1192(奈芙) +汉化补丁作者:Bright1192(奈芙) +BepInEx作者:BepInEx团队 +BepInEx For LLC分支作者:Bright1192(奈芙) +字体贡献者:茜 +安装器原作者&技术支持:Bright1192(奈芙) +工具箱重制:曾小皮-ZengXiaoPi +镜像节点:曾小皮-ZengXiaoPi + +使用 SunnyUI https://gitee.com/yhuse/SunnyUI +最棒的WinForm美化! + @@ -1883,21 +1898,6 @@ /////////4AAAAAAAAAAAAH/////////////gAAAAAAAAAAAAf/////////////AAAAAAAAAAAAD//// //8= - - - 汉化:零协会全体成员 -首席外交官(划掉)LLTT系长:N071(北岚) -LLC部长:Bright1192(奈芙) -汉化补丁作者:Bright1192(奈芙) -BepInEx作者:BepInEx团队 -BepInEx For LLC分支作者:Bright1192(奈芙) -字体贡献者:茜 -安装器原作者&技术支持:Bright1192(奈芙) -工具箱重制:曾小皮-ZengXiaoPi -镜像节点:曾小皮-ZengXiaoPi - -使用 SunnyUI https://gitee.com/yhuse/SunnyUI -最棒的WinForm美化! 17, 17