mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-06-08 23:19:14 +08:00
DropEditor: Implement multiple selection and display intersection
This commit is contained in:
parent
60e54b1c91
commit
74613a809d
@ -37,6 +37,7 @@
|
|||||||
this.TxtItemFilter = new System.Windows.Forms.TextBox();
|
this.TxtItemFilter = new System.Windows.Forms.TextBox();
|
||||||
this.ListDropData = new System.Windows.Forms.ListBox();
|
this.ListDropData = new System.Windows.Forms.ListBox();
|
||||||
this.GrpDropList = new System.Windows.Forms.GroupBox();
|
this.GrpDropList = new System.Windows.Forms.GroupBox();
|
||||||
|
this.BtnCopyAll = new System.Windows.Forms.Button();
|
||||||
this.BtnClear = new System.Windows.Forms.Button();
|
this.BtnClear = new System.Windows.Forms.Button();
|
||||||
this.BtnPaste = new System.Windows.Forms.Button();
|
this.BtnPaste = new System.Windows.Forms.Button();
|
||||||
this.BtnCopy = new System.Windows.Forms.Button();
|
this.BtnCopy = new System.Windows.Forms.Button();
|
||||||
@ -55,7 +56,6 @@
|
|||||||
this.ListItems = new System.Windows.Forms.ListBox();
|
this.ListItems = new System.Windows.Forms.ListBox();
|
||||||
this.GrpMonsterList = new System.Windows.Forms.GroupBox();
|
this.GrpMonsterList = new System.Windows.Forms.GroupBox();
|
||||||
this.GrpItemList = new System.Windows.Forms.GroupBox();
|
this.GrpItemList = new System.Windows.Forms.GroupBox();
|
||||||
this.BtnCopyAll = new System.Windows.Forms.Button();
|
|
||||||
this.GrpDropList.SuspendLayout();
|
this.GrpDropList.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.NUDMaxWeight)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.NUDMaxWeight)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.NUDMinWeight)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.NUDMinWeight)).BeginInit();
|
||||||
@ -110,6 +110,7 @@
|
|||||||
this.ListMonsters.ItemHeight = 17;
|
this.ListMonsters.ItemHeight = 17;
|
||||||
this.ListMonsters.Location = new System.Drawing.Point(6, 51);
|
this.ListMonsters.Location = new System.Drawing.Point(6, 51);
|
||||||
this.ListMonsters.Name = "ListMonsters";
|
this.ListMonsters.Name = "ListMonsters";
|
||||||
|
this.ListMonsters.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
|
||||||
this.ListMonsters.Size = new System.Drawing.Size(238, 344);
|
this.ListMonsters.Size = new System.Drawing.Size(238, 344);
|
||||||
this.ListMonsters.TabIndex = 4;
|
this.ListMonsters.TabIndex = 4;
|
||||||
this.ListMonsters.SelectedIndexChanged += new System.EventHandler(this.ListMonsters_SelectedIndexChanged);
|
this.ListMonsters.SelectedIndexChanged += new System.EventHandler(this.ListMonsters_SelectedIndexChanged);
|
||||||
@ -176,6 +177,17 @@
|
|||||||
this.GrpDropList.TabStop = false;
|
this.GrpDropList.TabStop = false;
|
||||||
this.GrpDropList.Text = "掉落列表";
|
this.GrpDropList.Text = "掉落列表";
|
||||||
//
|
//
|
||||||
|
// BtnCopyAll
|
||||||
|
//
|
||||||
|
this.BtnCopyAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.BtnCopyAll.Location = new System.Drawing.Point(87, 202);
|
||||||
|
this.BtnCopyAll.Name = "BtnCopyAll";
|
||||||
|
this.BtnCopyAll.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.BtnCopyAll.TabIndex = 22;
|
||||||
|
this.BtnCopyAll.Text = "复制全部";
|
||||||
|
this.BtnCopyAll.UseVisualStyleBackColor = true;
|
||||||
|
this.BtnCopyAll.Click += new System.EventHandler(this.BtnCopyAll_Click);
|
||||||
|
//
|
||||||
// BtnClear
|
// BtnClear
|
||||||
//
|
//
|
||||||
this.BtnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
this.BtnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
@ -410,17 +422,6 @@
|
|||||||
this.GrpItemList.TabStop = false;
|
this.GrpItemList.TabStop = false;
|
||||||
this.GrpItemList.Text = "物品列表";
|
this.GrpItemList.Text = "物品列表";
|
||||||
//
|
//
|
||||||
// BtnCopyAll
|
|
||||||
//
|
|
||||||
this.BtnCopyAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
|
||||||
this.BtnCopyAll.Location = new System.Drawing.Point(87, 202);
|
|
||||||
this.BtnCopyAll.Name = "BtnCopyAll";
|
|
||||||
this.BtnCopyAll.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.BtnCopyAll.TabIndex = 22;
|
|
||||||
this.BtnCopyAll.Text = "复制全部";
|
|
||||||
this.BtnCopyAll.UseVisualStyleBackColor = true;
|
|
||||||
this.BtnCopyAll.Click += new System.EventHandler(this.BtnCopyAll_Click);
|
|
||||||
//
|
|
||||||
// FormDropEditor
|
// FormDropEditor
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
||||||
|
@ -10,14 +10,32 @@ using GrasscutterTools.Properties;
|
|||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||||
|
|
||||||
namespace GrasscutterTools.Forms
|
namespace GrasscutterTools.Forms
|
||||||
{
|
{
|
||||||
public partial class FormDropEditor : Form
|
public partial class FormDropEditor : Form
|
||||||
{
|
{
|
||||||
#region - 成员 -
|
#region - 成员 -
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 掉落池
|
||||||
|
/// Key:怪物ID
|
||||||
|
/// Value:掉落列表
|
||||||
|
/// </summary>
|
||||||
private Dictionary<int, List<DropData>> Banners;
|
private Dictionary<int, List<DropData>> Banners;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 怪物集
|
||||||
|
/// </summary>
|
||||||
|
private readonly string[] Monsters;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前选中项的掉落列表
|
||||||
|
/// (当选中多条时,数据为交集)
|
||||||
|
/// </summary>
|
||||||
|
private readonly List<DropData> DropList = new List<DropData>();
|
||||||
|
|
||||||
#endregion - 成员 -
|
#endregion - 成员 -
|
||||||
|
|
||||||
#region - 构造与窗体事件 -
|
#region - 构造与窗体事件 -
|
||||||
@ -28,7 +46,12 @@ namespace GrasscutterTools.Forms
|
|||||||
|
|
||||||
Icon = Resources.IconGrasscutter;
|
Icon = Resources.IconGrasscutter;
|
||||||
|
|
||||||
ListMonsters.Items.AddRange(GameData.Monsters.Lines);
|
Monsters = new string[GameData.Monsters.Lines.Length + GameData.Animals.Lines.Length];
|
||||||
|
GameData.Monsters.Lines.CopyTo(Monsters, 0);
|
||||||
|
GameData.Animals.Lines.CopyTo(Monsters, GameData.Monsters.Lines.Length);
|
||||||
|
Array.Sort(Monsters);
|
||||||
|
|
||||||
|
ListMonsters.Items.AddRange(Monsters);
|
||||||
ListItems.Items.AddRange(GameData.Items.Lines);
|
ListItems.Items.AddRange(GameData.Items.Lines);
|
||||||
|
|
||||||
Banners = new Dictionary<int, List<DropData>>();
|
Banners = new Dictionary<int, List<DropData>>();
|
||||||
@ -158,7 +181,7 @@ namespace GrasscutterTools.Forms
|
|||||||
var filter = TxtMonsterFilter.Text.Trim();
|
var filter = TxtMonsterFilter.Text.Trim();
|
||||||
ListMonsters.BeginUpdate();
|
ListMonsters.BeginUpdate();
|
||||||
ListMonsters.Items.Clear();
|
ListMonsters.Items.Clear();
|
||||||
ListMonsters.Items.AddRange(GameData.Monsters.Lines.Where(n => n.Contains(filter)).ToArray());
|
ListMonsters.Items.AddRange(Monsters.Where(n => n.Contains(filter)).ToArray());
|
||||||
ListMonsters.EndUpdate();
|
ListMonsters.EndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +190,61 @@ namespace GrasscutterTools.Forms
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ListMonsters_SelectedIndexChanged(object sender, EventArgs e)
|
private void ListMonsters_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var monster = ListMonsters.SelectedItem as string;
|
if (ListMonsters.SelectedItems.Count == 0) return;
|
||||||
if (string.IsNullOrEmpty(monster)) return;
|
|
||||||
var id = int.Parse(monster.Substring(0, monster.IndexOf(':')).Trim());
|
// 掉落物列表标题显示
|
||||||
|
var sp = GrpDropList.Text.IndexOf(" | ");
|
||||||
|
if (sp >= 0) GrpDropList.Text = GrpDropList.Text.Remove(sp);
|
||||||
|
if (ListMonsters.SelectedItems.Count == 1)
|
||||||
|
{
|
||||||
|
var item = ListMonsters.SelectedItem as string;
|
||||||
|
GrpDropList.Text += " | " + item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GrpDropList.Text += " | Monsters x" + ListMonsters.SelectedItems.Count.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取选中项中相同的掉落物集合(仅物品、掉落数量、掉落概率完全一致的显示)
|
||||||
|
DropList.Clear();
|
||||||
|
var first = true;
|
||||||
|
foreach (string item in ListMonsters.SelectedItems)
|
||||||
|
{
|
||||||
|
var monsterId = int.Parse(item.Substring(0, item.IndexOf(':')).Trim());
|
||||||
|
if (Banners.TryGetValue(monsterId, out List<DropData> dropList))
|
||||||
|
{
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
DropList.AddRange(dropList);
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
else if (DropList.Count > 0)
|
||||||
|
{
|
||||||
|
// 仅保留交集
|
||||||
|
var intersect = DropList.Intersect(dropList).ToList();
|
||||||
|
DropList.Clear();
|
||||||
|
DropList.AddRange(intersect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DropList.Clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示到列表
|
||||||
ListDropData.BeginUpdate();
|
ListDropData.BeginUpdate();
|
||||||
ListDropData.Items.Clear();
|
ListDropData.Items.Clear();
|
||||||
if (Banners.TryGetValue(id, out List<DropData> dropList))
|
if (DropList.Count > 0)
|
||||||
ListDropData.Items.AddRange(dropList.ToArray());
|
{
|
||||||
|
ListDropData.Items.AddRange(DropList.Select(it => it.ToString()).ToArray());
|
||||||
|
ListDropData.SelectedIndex = 0;
|
||||||
|
}
|
||||||
ListDropData.EndUpdate();
|
ListDropData.EndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,9 +257,11 @@ namespace GrasscutterTools.Forms
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ListDropData_SelectedIndexChanged(object sender, EventArgs e)
|
private void ListDropData_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var dropData = ListDropData.SelectedItem as DropData;
|
if (ListDropData.SelectedIndex == -1) return;
|
||||||
if (dropData == null) return;
|
|
||||||
TxtItem.Text = $"{dropData.ItemId}: {GameData.Items[dropData.ItemId]}";
|
var dropData = DropList[ListDropData.SelectedIndex];
|
||||||
|
|
||||||
|
TxtItem.Text = $"{dropData.ItemId} : {GameData.Items[dropData.ItemId]}";
|
||||||
NUDMinCount.Value = dropData.MinCount;
|
NUDMinCount.Value = dropData.MinCount;
|
||||||
NUDMaxCount.Value = dropData.MaxCount;
|
NUDMaxCount.Value = dropData.MaxCount;
|
||||||
NUDMinWeight.Value = dropData.MinWeight;
|
NUDMinWeight.Value = dropData.MinWeight;
|
||||||
@ -244,9 +317,7 @@ namespace GrasscutterTools.Forms
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ListItems_SelectedIndexChanged(object sender, EventArgs e)
|
private void ListItems_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var item = ListItems.SelectedItem as string;
|
TxtItem.Text = ListItems.SelectedItem as string;
|
||||||
if (string.IsNullOrEmpty(item)) return;
|
|
||||||
TxtItem.Text = item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion - 物品列表 -
|
#endregion - 物品列表 -
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace GrasscutterTools.Game.Drop
|
namespace GrasscutterTools.Game.Drop
|
||||||
{
|
{
|
||||||
public class DropData
|
public struct DropData
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物品ID
|
/// 物品ID
|
||||||
|
Loading…
Reference in New Issue
Block a user