namespace SHNDecryptHK { using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; public class ItemEditor : Form { private Button btnSearch; private Button button1; private int BuyIndex; private int canTradeIndex; private CheckBox chkNoTradeOnly; private ComboBox cmbCanTrade; private IContainer components; private int FameIndex; private GroupBox groupBox1; private GroupBox groupBox2; private Dictionary items = new Dictionary(); private Label label1; private Label label2; private Label label3; private Label label4; private Label label5; private Label label6; private Label label7; private Label label8; private int LevelIndex; private int lnxNameIndex; private ListBox lstItems; private frmMain main; private int maxLotIndex; private int NameIndex; private NumericUpDown nmrBuyPrice; private NumericUpDown nmrFamePrice; private NumericUpDown nmrLevel; private NumericUpDown nmrMaxLot; private NumericUpDown nmrSellPrice; private int SellIndex; private StatusStrip statusStrip1; private TextBox txtFullName; private Label txtitemName; private TextBox txtSearch; private ToolStripStatusLabel txtStatus; public ItemEditor(frmMain form) { this.InitializeComponent(); this.main = form; this.init(); } private void btnSearch_Click(object sender, EventArgs e) { if (this.items.Count != 0) { this.lstItems.Items.Clear(); foreach (KeyValuePair pair in this.items) { if (pair.Value.InxName.ToLower().Contains(this.txtSearch.Text.ToLower())) { this.lstItems.Items.Add(pair.Key); } } } } private void button1_Click(object sender, EventArgs e) { if (!this.items.ContainsKey(this.txtitemName.Text)) { MessageBox.Show(this.txtitemName.Text + " not found in item dictionary"); } else { try { int rowIndex = this.items[this.txtitemName.Text].rowIndex; this.main.file.table.Rows[rowIndex][this.lnxNameIndex] = this.txtFullName.Text; this.main.file.table.Rows[rowIndex][this.LevelIndex] = (int) this.nmrLevel.Value; this.main.file.table.Rows[rowIndex][this.SellIndex] = (int) this.nmrSellPrice.Value; this.main.file.table.Rows[rowIndex][this.BuyIndex] = (int) this.nmrBuyPrice.Value; this.main.file.table.Rows[rowIndex][this.FameIndex] = (int) this.nmrFamePrice.Value; this.main.file.table.Rows[rowIndex][this.maxLotIndex] = (int) this.nmrMaxLot.Value; this.main.file.table.Rows[rowIndex][this.canTradeIndex] = (byte) this.cmbCanTrade.SelectedIndex; this.txtStatus.Text = this.txtitemName.Text + " saved!"; } catch (Exception exception) { MessageBox.Show(exception.Message); } } } private void chkNoTradeOnly_CheckedChanged(object sender, EventArgs e) { this.lstItems.Items.Clear(); if (this.chkNoTradeOnly.Checked) { foreach (KeyValuePair pair in this.items) { if (pair.Value.noTrade) { this.lstItems.Items.Add(pair.Key); } } } else { foreach (KeyValuePair pair2 in this.items) { this.lstItems.Items.Add(pair2.Key); } } this.txtStatus.Text = this.lstItems.Items.Count + " items"; } protected override void Dispose(bool disposing) { if (disposing && (this.components != null)) { this.components.Dispose(); } base.Dispose(disposing); } private void groupBox2_Enter(object sender, EventArgs e) { } private void init() { if (this.main.file != null) { this.lnxNameIndex = this.main.file.getColIndex("InxName"); this.NameIndex = this.main.file.getColIndex("Name"); this.LevelIndex = this.main.file.getColIndex("DemandLv"); this.BuyIndex = this.main.file.getColIndex("BuyPrice"); this.SellIndex = this.main.file.getColIndex("SellPrice"); this.FameIndex = this.main.file.getColIndex("BuyFame"); this.canTradeIndex = this.main.file.getColIndex("NoTrade"); this.maxLotIndex = this.main.file.getColIndex("MaxLot"); int errors = 0; for (int i = 0; i < this.main.file.table.Rows.Count; i++) { try { Item item = new Item { rowIndex = i, ID = Convert.ToUInt16(this.main.file.table.Rows[i][0]), InxName = this.main.file.table.Rows[i][this.lnxNameIndex].ToString(), name = this.main.file.table.Rows[i][this.NameIndex].ToString(), level = Convert.ToByte(this.main.file.table.Rows[i][this.LevelIndex]), buyPrice = Convert.ToInt32(this.main.file.table.Rows[i][this.BuyIndex]), sellPrice = Convert.ToInt32(this.main.file.table.Rows[i][this.SellIndex]), famePrice = Convert.ToInt32(this.main.file.table.Rows[i][this.FameIndex]), noTrade = Convert.ToBoolean(this.main.file.table.Rows[i][this.canTradeIndex]), maxLot = Convert.ToInt32(this.main.file.table.Rows[i][this.maxLotIndex]) }; this.items.Add(item.InxName, item); } catch { errors++; } } this.ShowList(errors); } } private void InitializeComponent() { ComponentResourceManager manager = new ComponentResourceManager(typeof(ItemEditor)); this.groupBox1 = new GroupBox(); this.btnSearch = new Button(); this.txtSearch = new TextBox(); this.chkNoTradeOnly = new CheckBox(); this.lstItems = new ListBox(); this.statusStrip1 = new StatusStrip(); this.txtStatus = new ToolStripStatusLabel(); this.groupBox2 = new GroupBox(); this.txtitemName = new Label(); this.button1 = new Button(); this.nmrMaxLot = new NumericUpDown(); this.label7 = new Label(); this.nmrFamePrice = new NumericUpDown(); this.nmrBuyPrice = new NumericUpDown(); this.nmrSellPrice = new NumericUpDown(); this.cmbCanTrade = new ComboBox(); this.label6 = new Label(); this.label5 = new Label(); this.label4 = new Label(); this.label3 = new Label(); this.nmrLevel = new NumericUpDown(); this.label2 = new Label(); this.txtFullName = new TextBox(); this.label1 = new Label(); this.label8 = new Label(); this.groupBox1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.nmrMaxLot.BeginInit(); this.nmrFamePrice.BeginInit(); this.nmrBuyPrice.BeginInit(); this.nmrSellPrice.BeginInit(); this.nmrLevel.BeginInit(); base.SuspendLayout(); this.groupBox1.Controls.Add(this.btnSearch); this.groupBox1.Controls.Add(this.txtSearch); this.groupBox1.Controls.Add(this.chkNoTradeOnly); this.groupBox1.Controls.Add(this.lstItems); this.groupBox1.Location = new Point(7, 10); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new Size(0xbd, 0x1b0); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Items"; this.btnSearch.Location = new Point(0x94, 0x12); this.btnSearch.Name = "btnSearch"; this.btnSearch.Size = new Size(0x1b, 0x18); this.btnSearch.TabIndex = 5; this.btnSearch.Text = "..."; this.btnSearch.UseVisualStyleBackColor = true; this.btnSearch.Click += new EventHandler(this.btnSearch_Click); this.txtSearch.Location = new Point(13, 0x13); this.txtSearch.Name = "txtSearch"; this.txtSearch.Size = new Size(0x7f, 20); this.txtSearch.TabIndex = 4; this.chkNoTradeOnly.AutoSize = true; this.chkNoTradeOnly.Location = new Point(11, 0x199); this.chkNoTradeOnly.Name = "chkNoTradeOnly"; this.chkNoTradeOnly.Size = new Size(150, 0x11); this.chkNoTradeOnly.TabIndex = 3; this.chkNoTradeOnly.Text = "Show NoTrade Items Only"; this.chkNoTradeOnly.UseVisualStyleBackColor = true; this.lstItems.FormattingEnabled = true; this.lstItems.Location = new Point(11, 0x2d); this.lstItems.Name = "lstItems"; this.lstItems.Size = new Size(0xa5, 0x163); this.lstItems.TabIndex = 0; this.lstItems.SelectedIndexChanged += new EventHandler(this.lstItems_SelectedIndexChanged); this.statusStrip1.Items.AddRange(new ToolStripItem[] { this.txtStatus }); this.statusStrip1.Location = new Point(0, 0x1c1); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new Size(0x220, 0x16); this.statusStrip1.TabIndex = 1; this.statusStrip1.Text = "statusStrip1"; this.txtStatus.Name = "txtStatus"; this.txtStatus.Size = new Size(0x7a, 0x11); this.txtStatus.Text = "Ready to server you :3"; this.groupBox2.Controls.Add(this.txtitemName); this.groupBox2.Controls.Add(this.button1); this.groupBox2.Controls.Add(this.nmrMaxLot); this.groupBox2.Controls.Add(this.label7); this.groupBox2.Controls.Add(this.nmrFamePrice); this.groupBox2.Controls.Add(this.nmrBuyPrice); this.groupBox2.Controls.Add(this.nmrSellPrice); this.groupBox2.Controls.Add(this.cmbCanTrade); this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.label5); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.nmrLevel); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Controls.Add(this.txtFullName); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Location = new Point(210, 0x11); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new Size(320, 0x16c); this.groupBox2.TabIndex = 3; this.groupBox2.TabStop = false; this.groupBox2.Text = "Info"; this.groupBox2.Enter += new EventHandler(this.groupBox2_Enter); this.txtitemName.AutoSize = true; this.txtitemName.Location = new Point(0x79, 0x14b); this.txtitemName.Name = "txtitemName"; this.txtitemName.RightToLeft = RightToLeft.Yes; this.txtitemName.Size = new Size(12, 13); this.txtitemName.TabIndex = 15; this.txtitemName.Text = "/"; this.button1.Location = new Point(20, 0x141); this.button1.Name = "button1"; this.button1.Size = new Size(0x5f, 0x21); this.button1.TabIndex = 14; this.button1.Text = "Apply Changes"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new EventHandler(this.button1_Click); this.nmrMaxLot.Location = new Point(0x5e, 0x5e); this.nmrMaxLot.Name = "nmrMaxLot"; this.nmrMaxLot.Size = new Size(50, 20); this.nmrMaxLot.TabIndex = 13; this.label7.AutoSize = true; this.label7.Location = new Point(0x11, 0x60); this.label7.Name = "label7"; this.label7.Size = new Size(0x30, 13); this.label7.TabIndex = 12; this.label7.Text = "Max Lot:"; this.nmrFamePrice.Location = new Point(0x5e, 0xae); this.nmrFamePrice.Name = "nmrFamePrice"; this.nmrFamePrice.Size = new Size(0x54, 20); this.nmrFamePrice.TabIndex = 11; this.nmrBuyPrice.Location = new Point(0x5e, 0x94); this.nmrBuyPrice.Name = "nmrBuyPrice"; this.nmrBuyPrice.Size = new Size(0x54, 20); this.nmrBuyPrice.TabIndex = 10; this.nmrSellPrice.Location = new Point(0x5e, 120); this.nmrSellPrice.Name = "nmrSellPrice"; this.nmrSellPrice.Size = new Size(0x54, 20); this.nmrSellPrice.TabIndex = 9; this.cmbCanTrade.DropDownStyle = ComboBoxStyle.DropDownList; this.cmbCanTrade.FormattingEnabled = true; this.cmbCanTrade.Location = new Point(0x5e, 0xe8); this.cmbCanTrade.Name = "cmbCanTrade"; this.cmbCanTrade.Size = new Size(50, 0x15); this.cmbCanTrade.TabIndex = 8; this.label6.AutoSize = true; this.label6.Location = new Point(0x11, 0xec); this.label6.Name = "label6"; this.label6.Size = new Size(0x31, 13); this.label6.TabIndex = 7; this.label6.Text = "NoTrade"; this.label5.AutoSize = true; this.label5.Location = new Point(0x11, 0xb0); this.label5.Name = "label5"; this.label5.Size = new Size(0x3e, 13); this.label5.TabIndex = 6; this.label5.Text = "Fame price:"; this.label4.AutoSize = true; this.label4.Location = new Point(0x11, 0x94); this.label4.Name = "label4"; this.label4.Size = new Size(0x37, 13); this.label4.TabIndex = 5; this.label4.Text = "Buy Price:"; this.label3.AutoSize = true; this.label3.Location = new Point(0x10, 0x7a); this.label3.Name = "label3"; this.label3.Size = new Size(0x36, 13); this.label3.TabIndex = 4; this.label3.Text = "Sell Price:"; this.nmrLevel.Location = new Point(0x3b, 0x34); int[] bits = new int[4]; bits[0] = 150; this.nmrLevel.Maximum = new decimal(bits); this.nmrLevel.Name = "nmrLevel"; this.nmrLevel.Size = new Size(0x2b, 20); this.nmrLevel.TabIndex = 3; this.label2.AutoSize = true; this.label2.Location = new Point(0x11, 0x36); this.label2.Name = "label2"; this.label2.Size = new Size(0x24, 13); this.label2.TabIndex = 2; this.label2.Text = "Level:"; this.txtFullName.Location = new Point(0x4d, 0x17); this.txtFullName.Name = "txtFullName"; this.txtFullName.Size = new Size(0xd9, 20); this.txtFullName.TabIndex = 1; this.label1.AutoSize = true; this.label1.Location = new Point(14, 0x17); this.label1.Name = "label1"; this.label1.Size = new Size(0x39, 13); this.label1.TabIndex = 0; this.label1.Text = "Full Name:"; this.label8.AutoSize = true; this.label8.Location = new Point(0xd6, 0x182); this.label8.Name = "label8"; this.label8.Size = new Size(0x13d, 13); this.label8.TabIndex = 4; this.label8.Text = "Multitip: Enter a value int the box & press \"...\" to search for a value."; base.AutoScaleDimensions = new SizeF(6f, 13f); base.AutoScaleMode = AutoScaleMode.Font; base.ClientSize = new Size(0x220, 0x1d7); base.Controls.Add(this.label8); base.Controls.Add(this.groupBox2); base.Controls.Add(this.statusStrip1); base.Controls.Add(this.groupBox1); base.Icon = (Icon) manager.GetObject("$this.Icon"); base.MaximizeBox = false; base.Name = "ItemEditor"; this.Text = "ItemEditor"; base.Load += new EventHandler(this.ItemEditor_Load); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.nmrMaxLot.EndInit(); this.nmrFamePrice.EndInit(); this.nmrBuyPrice.EndInit(); this.nmrSellPrice.EndInit(); this.nmrLevel.EndInit(); base.ResumeLayout(false); base.PerformLayout(); } private void ItemEditor_Load(object sender, EventArgs e) { } private void lstItems_SelectedIndexChanged(object sender, EventArgs e) { if (this.lstItems.Items.Count != 0) { try { Item item = this.items[this.lstItems.Items[this.lstItems.SelectedIndex].ToString()]; this.cmbCanTrade.SelectedIndex = item.noTrade ? 1 : 0; this.txtFullName.Text = item.name; this.nmrLevel.Value = item.level; this.nmrBuyPrice.Value = item.buyPrice; this.nmrSellPrice.Value = item.sellPrice; this.nmrFamePrice.Value = item.famePrice; this.nmrMaxLot.Value = item.maxLot; this.txtitemName.Text = item.InxName; } catch { } } } public void ShowList(int errors) { foreach (KeyValuePair pair in this.items) { this.lstItems.Items.Add(pair.Key); } this.nmrSellPrice.Maximum = 2147483647M; this.nmrBuyPrice.Maximum = 2147483647M; this.nmrFamePrice.Maximum = 2147483647M; this.nmrMaxLot.Maximum = 2147483647M; this.cmbCanTrade.Items.Clear(); this.cmbCanTrade.Items.Add("False"); this.cmbCanTrade.Items.Add("True"); this.txtStatus.Text = string.Concat(new object[] { this.items.Count, " items loaded! Outspark fucked up ", errors, " duplicate items" }); } } }