mirror of
https://github.com/kwsch/NHSE.git
synced 2026-06-03 06:24:50 -05:00
Add dropdown for jumping to specific items
This commit is contained in:
parent
4259564162
commit
dc0b2e2fe4
|
|
@ -33,6 +33,7 @@ private void InitializeComponent()
|
|||
this.CLB_Items = new System.Windows.Forms.CheckedListBox();
|
||||
this.B_AllBugs = new System.Windows.Forms.Button();
|
||||
this.B_AllFish = new System.Windows.Forms.Button();
|
||||
this.CB_Item = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// B_Cancel
|
||||
|
|
@ -68,6 +69,7 @@ private void InitializeComponent()
|
|||
this.CLB_Items.Name = "CLB_Items";
|
||||
this.CLB_Items.Size = new System.Drawing.Size(268, 229);
|
||||
this.CLB_Items.TabIndex = 8;
|
||||
this.CLB_Items.SelectedIndexChanged += new System.EventHandler(this.CLB_Items_SelectedIndexChanged);
|
||||
//
|
||||
// B_AllBugs
|
||||
//
|
||||
|
|
@ -91,11 +93,26 @@ private void InitializeComponent()
|
|||
this.B_AllFish.UseVisualStyleBackColor = true;
|
||||
this.B_AllFish.Click += new System.EventHandler(this.B_AllFish_Click);
|
||||
//
|
||||
// CB_Item
|
||||
//
|
||||
this.CB_Item.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CB_Item.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
|
||||
this.CB_Item.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
|
||||
this.CB_Item.DropDownWidth = 322;
|
||||
this.CB_Item.FormattingEnabled = true;
|
||||
this.CB_Item.Location = new System.Drawing.Point(130, 254);
|
||||
this.CB_Item.Name = "CB_Item";
|
||||
this.CB_Item.Size = new System.Drawing.Size(150, 21);
|
||||
this.CB_Item.TabIndex = 13;
|
||||
this.CB_Item.SelectedValueChanged += new System.EventHandler(this.CB_Item_SelectedValueChanged);
|
||||
//
|
||||
// ItemReceivedEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(292, 315);
|
||||
this.Controls.Add(this.CB_Item);
|
||||
this.Controls.Add(this.B_AllFish);
|
||||
this.Controls.Add(this.B_AllBugs);
|
||||
this.Controls.Add(this.CLB_Items);
|
||||
|
|
@ -118,5 +135,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.CheckedListBox CLB_Items;
|
||||
private System.Windows.Forms.Button B_AllBugs;
|
||||
private System.Windows.Forms.Button B_AllFish;
|
||||
private System.Windows.Forms.ComboBox CB_Item;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using NHSE.Core;
|
||||
using NHSE.Core.Structures;
|
||||
|
|
@ -16,20 +15,27 @@ public ItemReceivedEditor(Player player)
|
|||
Player = player;
|
||||
InitializeComponent();
|
||||
FillCheckBoxes();
|
||||
Initialize(GameInfo.Strings.ItemDataSource);
|
||||
CLB_Items.SelectedIndex = 0x50;
|
||||
}
|
||||
|
||||
public void Initialize(List<ComboItem> items)
|
||||
{
|
||||
CB_Item.DisplayMember = nameof(ComboItem.Text);
|
||||
CB_Item.ValueMember = nameof(ComboItem.Value);
|
||||
CB_Item.DataSource = items;
|
||||
}
|
||||
|
||||
private void FillCheckBoxes()
|
||||
{
|
||||
var items = GameInfo.Strings.itemlist.ToArray();
|
||||
items[0] = string.Empty;
|
||||
var items = GameInfo.Strings.itemlistdisplay;
|
||||
|
||||
var ofs = Player.Personal.Offsets.ReceivedItems;
|
||||
var data = Player.Personal.Data;
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
var flag = FlagUtil.GetFlag(data, ofs, i);
|
||||
string value = items[i];
|
||||
if (string.IsNullOrEmpty(value))
|
||||
value = i.ToString();
|
||||
string name = $"0x{i:X3} - {value}";
|
||||
CLB_Items.Items.Add(name, flag);
|
||||
}
|
||||
|
|
@ -54,5 +60,19 @@ private void B_Save_Click(object sender, EventArgs e)
|
|||
FlagUtil.SetFlag(data, ofs, i, CLB_Items.GetItemChecked(i));
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CB_Item_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
var index = WinFormsUtil.GetIndex(CB_Item);
|
||||
if (index >= CLB_Items.Items.Count)
|
||||
index = 0;
|
||||
CLB_Items.SelectedIndex = index;
|
||||
}
|
||||
|
||||
private void CLB_Items_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var index = CLB_Items.SelectedIndex;
|
||||
CB_Item.SelectedValue = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user