Clean up code

This commit is contained in:
2022-05-21 15:55:26 +08:00
parent e797032216
commit 0d1d15529d

View File

@ -14,16 +14,15 @@
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
**/ **/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using GrasscutterTools.Game; using GrasscutterTools.Game;
using GrasscutterTools.Game.Gacha; using GrasscutterTools.Game.Gacha;
@ -47,7 +46,6 @@ namespace GrasscutterTools.Forms
InitBannerPrefab(); InitBannerPrefab();
InitCheckedListBoxs(); InitCheckedListBoxs();
ShowBanner(new GachaBanner2()); ShowBanner(new GachaBanner2());
} }
@ -57,7 +55,6 @@ namespace GrasscutterTools.Forms
CmbPrefab.Items.AddRange(GameData.GachaBannerPrefabs.Names); CmbPrefab.Items.AddRange(GameData.GachaBannerPrefabs.Names);
} }
private void LnkWeightHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) private void LnkWeightHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{ {
System.Diagnostics.Process.Start("https://github.com/Grasscutters/Grasscutter/pull/639"); System.Diagnostics.Process.Start("https://github.com/Grasscutters/Grasscutter/pull/639");
@ -94,7 +91,6 @@ namespace GrasscutterTools.Forms
ListFallbackItems.Items.Clear(); ListFallbackItems.Items.Clear();
ListFallbackItems.Items.AddRange(avatars.Concat(weapons).ToArray()); ListFallbackItems.Items.AddRange(avatars.Concat(weapons).ToArray());
ListUpItems.BeginUpdate(); ListUpItems.BeginUpdate();
var ua5 = ListUpItems.Groups["GroupUpA5"]; var ua5 = ListUpItems.Groups["GroupUpA5"];
var ua4 = ListUpItems.Groups["GroupUpA4"]; var ua4 = ListUpItems.Groups["GroupUpA4"];
@ -166,11 +162,11 @@ namespace GrasscutterTools.Forms
yield return int.Parse(item.Text); yield return int.Parse(item.Text);
} }
#endregion #endregion - -
#region - - #region - -
struct GachaWeight private struct GachaWeight
{ {
public int Count; public int Count;
public int Weight; public int Weight;
@ -201,7 +197,7 @@ namespace GrasscutterTools.Forms
return JsonConvert.DeserializeObject<int[,]>(weights); return JsonConvert.DeserializeObject<int[,]>(weights);
} }
#endregion #endregion - -
#region - - #region - -
@ -209,20 +205,20 @@ namespace GrasscutterTools.Forms
{ {
try try
{ {
NUDGachaType.Value = banner.GachaType; NUDGachaType.Value = banner.GachaType;
NUDScheduleId.Value = banner.ScheduleId; NUDScheduleId.Value = banner.ScheduleId;
CmbBannerType.SelectedIndex = (int)banner.BannerType; CmbBannerType.SelectedIndex = (int)banner.BannerType;
if (string.IsNullOrEmpty(banner.TitlePath) || !int.TryParse(banner.TitlePath.Substring("UI_GACHA_SHOW_PANEL_A".Length, 3), out int prefabId)) if (string.IsNullOrEmpty(banner.TitlePath) || !int.TryParse(banner.TitlePath.Substring("UI_GACHA_SHOW_PANEL_A".Length, 3), out int prefabId))
CmbPrefab.SelectedIndex = -1; CmbPrefab.SelectedIndex = -1;
else else
CmbPrefab.SelectedIndex = Array.IndexOf(GameData.GachaBannerPrefabs.Ids, prefabId); CmbPrefab.SelectedIndex = Array.IndexOf(GameData.GachaBannerPrefabs.Ids, prefabId);
RbCostItem224.Checked = banner.CostItem == 224; RbCostItem224.Checked = banner.CostItem == 224;
RbCostItem223.Checked = banner.CostItem == 223; RbCostItem223.Checked = banner.CostItem == 223;
DTPBeginTime.Value = DateTimeOffset.FromUnixTimeSeconds(banner.BeginTime).DateTime; DTPBeginTime.Value = DateTimeOffset.FromUnixTimeSeconds(banner.BeginTime).DateTime;
DTPEndTime.Value = DateTimeOffset.FromUnixTimeSeconds(banner.EndTime).DateTime; DTPEndTime.Value = DateTimeOffset.FromUnixTimeSeconds(banner.EndTime).DateTime;
NUDSortId.Value = banner.SortId; NUDSortId.Value = banner.SortId;
NUDEventChance5.Value = banner.EventChance5; NUDEventChance5.Value = banner.EventChance5;
NUDEventChance4.Value = banner.EventChance4; NUDEventChance4.Value = banner.EventChance4;
ChkRemoveC6FormPool.Checked = banner.RemoveC6FromPool; ChkRemoveC6FormPool.Checked = banner.RemoveC6FromPool;
ChkAutoStripRateUpFromFallback.Checked = banner.AutoStripRateUpFromFallback; ChkAutoStripRateUpFromFallback.Checked = banner.AutoStripRateUpFromFallback;
InitItems(banner); InitItems(banner);
@ -248,31 +244,30 @@ namespace GrasscutterTools.Forms
return null; return null;
} }
var prefabId = GameData.GachaBannerPrefabs.Ids[CmbPrefab.SelectedIndex]; var prefabId = GameData.GachaBannerPrefabs.Ids[CmbPrefab.SelectedIndex];
var banner = new GachaBanner2 var banner = new GachaBanner2
{ {
GachaType = (int)NUDGachaType.Value, GachaType = (int)NUDGachaType.Value,
ScheduleId = (int)NUDScheduleId.Value, ScheduleId = (int)NUDScheduleId.Value,
BannerType = (BannerType)CmbBannerType.SelectedIndex, BannerType = (BannerType)CmbBannerType.SelectedIndex,
PrefabPath = $"GachaShowPanel_A{prefabId:000}", PrefabPath = $"GachaShowPanel_A{prefabId:000}",
PreviewPrefabPath = $"UI_Tab_GachaShowPanel_A{prefabId:000}", PreviewPrefabPath = $"UI_Tab_GachaShowPanel_A{prefabId:000}",
TitlePath = $"UI_GACHA_SHOW_PANEL_A{prefabId:000}_TITLE", TitlePath = $"UI_GACHA_SHOW_PANEL_A{prefabId:000}_TITLE",
CostItem = RbCostItem224.Checked ? 224 : 223, CostItem = RbCostItem224.Checked ? 224 : 223,
BeginTime = (int)new DateTimeOffset(DTPBeginTime.Value, TimeSpan.Zero).ToUnixTimeSeconds(), BeginTime = (int)new DateTimeOffset(DTPBeginTime.Value, TimeSpan.Zero).ToUnixTimeSeconds(),
EndTime = (int)new DateTimeOffset(DTPEndTime.Value, TimeSpan.Zero).ToUnixTimeSeconds(), EndTime = (int)new DateTimeOffset(DTPEndTime.Value, TimeSpan.Zero).ToUnixTimeSeconds(),
SortId = (int)NUDSortId.Value, SortId = (int)NUDSortId.Value,
EventChance5 = (int)NUDEventChance5.Value, EventChance5 = (int)NUDEventChance5.Value,
EventChance4 = (int)NUDEventChance4.Value, EventChance4 = (int)NUDEventChance4.Value,
RateUpItems4 = GetCheckedItems(ListUpItems, ListUpItems.Groups["GroupUpA4"]) RateUpItems4 = GetCheckedItems(ListUpItems, ListUpItems.Groups["GroupUpA4"])
.Concat(GetCheckedItems(ListUpItems, ListUpItems.Groups["GroupUpW4"])) .Concat(GetCheckedItems(ListUpItems, ListUpItems.Groups["GroupUpW4"]))
.ToArray(), .ToArray(),
RateUpItems5 = GetCheckedItems(ListUpItems, ListUpItems.Groups["GroupUpA5"]) RateUpItems5 = GetCheckedItems(ListUpItems, ListUpItems.Groups["GroupUpA5"])
.Concat(GetCheckedItems(ListUpItems, ListUpItems.Groups["GroupUpW5"])) .Concat(GetCheckedItems(ListUpItems, ListUpItems.Groups["GroupUpW5"]))
.ToArray(), .ToArray(),
FallbackItems3 = GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupA3"]) FallbackItems3 = GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupA3"])
.Concat(GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupW3"])) .Concat(GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupW3"]))
.ToArray(), .ToArray(),
FallbackItems4Pool1 = GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupA4"]).ToArray(), FallbackItems4Pool1 = GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupA4"]).ToArray(),
@ -280,11 +275,11 @@ namespace GrasscutterTools.Forms
FallbackItems5Pool1 = GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupA5"]).ToArray(), FallbackItems5Pool1 = GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupA5"]).ToArray(),
FallbackItems5Pool2 = GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupW5"]).ToArray(), FallbackItems5Pool2 = GetCheckedItems(ListFallbackItems, ListFallbackItems.Groups["GroupW5"]).ToArray(),
RemoveC6FromPool = ChkRemoveC6FormPool.Checked, RemoveC6FromPool = ChkRemoveC6FormPool.Checked,
AutoStripRateUpFromFallback = ChkAutoStripRateUpFromFallback.Checked, AutoStripRateUpFromFallback = ChkAutoStripRateUpFromFallback.Checked,
Weights4 = GetWeights(TxtWeight4.Text), Weights4 = GetWeights(TxtWeight4.Text),
Weights5 = GetWeights(TxtWeight5.Text), Weights5 = GetWeights(TxtWeight5.Text),
PoolBalanceWeights4 = GetWeights(TxtPoolWeight4.Text), PoolBalanceWeights4 = GetWeights(TxtPoolWeight4.Text),
PoolBalanceWeights5 = GetWeights(TxtPoolWeight5.Text), PoolBalanceWeights5 = GetWeights(TxtPoolWeight5.Text),
}; };
@ -317,7 +312,6 @@ namespace GrasscutterTools.Forms
} }
} }
#endregion #endregion - -
} }
} }