#pragma warning disable CS1690 public InvEditor() { BackColor = Color.LightGray; hacks = new Hashtable(); HackPanel = new Panel(); ItemSlots = new ItemIcon[HackFunctions.INV_MAX_COUNT]; AltSlots = new AltItemIcon[AltPanelWidth * AltPanelHeight]; SlotsPanel = new Panel(); InitializeComponent(); SlotsPanel.Size = new Size(ItemSlots.Length / 5 * (SlotsWidth + SlotsGap), this.ClientSize.Height); SlotsPanel.Location = new Point(5, 5); this.Controls.Add(SlotsPanel); ContextMenuStrip cms = new ContextMenuStrip(); cms.Items.Add("Copy"); cms.Items.Add("Paste"); cms.ItemClicked += (sender, e) => { switch (e.ClickedItem.Text) { case "Copy": HackFunctions.CopyItem(Selected); RefreshSelected(); break; case "Paste": if (HackFunctions.IsCopiedItem()) { HackFunctions.PasteItem(Selected); } RefreshSelected(); break; } }; for (int i = 0; i < ItemSlots.Length; i++) { int row = (int)Math.Floor((double)(i / 10)); int off = i % 10; ItemSlots[i] = new ItemIcon(i) { Size = new Size(SlotsWidth, SlotsWidth), Location = new Point(off * (SlotsWidth + SlotsGap), row * (SlotsWidth + SlotsGap)), BackColor = Color.CadetBlue, SizeMode = PictureBoxSizeMode.CenterImage }; ItemSlots[i].Click += (sender, e) => { MouseEventArgs mea = (MouseEventArgs)e; ItemIcon ii = (ItemIcon)sender; foreach (var s in ItemSlots) { s.Selected = false; } ((ItemIcon)sender).Selected = true; SlotsPanel.Refresh(); Selected = ((ItemIcon)sender).Number; InitData(Selected); if (mea.Button == MouseButtons.Right) { cms.Show(ii, mea.Location.X, mea.Location.Y); } }; this.SlotsPanel.Controls.Add(ItemSlots[i]); } ContextMenuStrip altCms = new ContextMenuStrip(); altCms.Items.Add("Edit"); altCms.ItemClicked += (sender, e) => { switch (e.ClickedItem.Text) { case "Edit": { Form f = new Form(); TextBox ItemID = new TextBox(); TextBox ItemCount = new TextBox(); ComboBox prefix = new ComboBox(); Button et = new Button(); f.Text = "Edit"; f.StartPosition = FormStartPosition.CenterParent; f.FormBorderStyle = FormBorderStyle.FixedSingle; f.MaximizeBox = false; f.MinimizeBox = false; f.Size = new Size(250, 90); Label tip1 = new Label() { Text = "ItemID", Location = new Point(0, 5), Size = new Size(80, 20) }; f.Controls.Add(tip1); ItemID.Location = new Point(85, 0); ItemID.Size = new Size(95, 20); ItemID.Text = AltSelected.ID.ToString(); ItemID.KeyPress += delegate(object sender1, KeyPressEventArgs e1) { if (!Char.IsNumber(e1.KeyChar) && e1.KeyChar != 8) { e1.Handled = true; } }; f.Controls.Add(ItemID); Label tip2 = new Label() { Text = "ItemStack", Location = new Point(0, 25), Size = new Size(80, 20) }; f.Controls.Add(tip2); ItemCount.Location = new Point(85, 20); ItemCount.Size = new Size(95, 20); ItemCount.Text = AltSelected.Stack.ToString(); ItemCount.KeyPress += delegate(object sender1, KeyPressEventArgs e1) { if (!Char.IsNumber(e1.KeyChar) && e1.KeyChar != 8) { e1.Handled = true; } }; f.Controls.Add(ItemCount); prefix.Location = new Point(85, 40); prefix.Size = new Size(95, 20); prefix.DropDownStyle = ComboBoxStyle.DropDownList; prefix.DropDownHeight = 150; foreach (var o in MainForm.resource.Prefix) { string[] t = o.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries); string v = t[0]; prefix.Items.Add(v); } prefix.SelectedIndex = GetIndexFromPrefix(AltSelected.Prefix); f.Controls.Add(prefix); Label tip3 = new Label() { Text = "ItemPrefix", Location = new Point(0, 45), Size = new Size(80, 20) }; f.Controls.Add(tip3); et.Text = Lang.confirm; et.Size = new Size(65, 60); et.Location = new Point(180, 0); et.Click += delegate(object sender1, EventArgs e1) { AltSelected.ID = Convert.ToInt32(ItemID.Text); AltSelected.Stack = Convert.ToInt32(ItemCount.Text); AltSelected.Prefix = GetPrefixFromIndex(prefix.SelectedIndex); f.Dispose(); var img = MainForm.item_images.Images["Item_" + AltSelected.ID]; if (img != null) { AltSelected.Image = img; } SaveAltItems(); }; f.Controls.Add(et); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(this); } break; } }; AltPanel = new Panel() { Location = new Point(560, 5), Size = new Size(AltPanelWidth, AltPanelHeight) }; Controls.Add(AltPanel); if (!File.Exists("AlternativeItem")) { BinaryWriter bw = new BinaryWriter(File.Open("AlternativeItem", FileMode.OpenOrCreate));//ID Stack Prefix for (int i = 0; i < (AltPanelHeight / AltWidth) * (AltPanelWidth / AltWidth); i++) { bw.Write(0); //ID bw.Write(0); //Stack bw.Write((byte)0); //Prefix } bw.Close(); } BinaryReader br = new BinaryReader(File.Open("AlternativeItem", FileMode.Open));//ID Stack Prefix for (int i = 0; i < AltPanelHeight / AltWidth; i++) { for (int j = 0; j < AltPanelWidth / AltWidth; j++) { int n = i * AltPanelWidth / AltWidth + j; AltSlots[n] = new AltItemIcon() { Size = new Size(AltWidth - AltGap, AltWidth - AltGap), Location = new Point(j * (AltWidth + AltGap), i * (AltWidth + AltGap) + 2), SizeMode = PictureBoxSizeMode.CenterImage, ID = br.ReadInt32(), Stack = br.ReadInt32(), Prefix = br.ReadByte(), }; Image img; if ((img = MainForm.item_images.Images["Item_" + AltSlots[n].ID]) != null) { AltSlots[n].Image = img; } AltSlots[n].BackColor = Color.CadetBlue; AltSlots[n].Click += (sender, e) => { MouseEventArgs mea = (MouseEventArgs)e; AltItemIcon aii = (AltItemIcon)sender; this.AltSelected = aii; if (mea.Button == MouseButtons.Right) { altCms.Show(aii, mea.Location.X, mea.Location.Y); } }; AltSlots[n].DoubleClick += (sender, e) => { for (int h = 0; h < HackFunctions.INV_MAX_COUNT; h++) { if (HackFunctions.getItemType(h) == 0) { HackFunctions.SetItemDefaults(h, AltSelected.ID, AltSelected.Prefix); HackFunctions.setItemStack(h, AltSelected.Stack); break; } } }; AltPanel.Controls.Add(AltSlots[n]); } } br.Close(); HackPanel.Location = new Point(ItemSlots.Length / 5 * (SlotsWidth + SlotsGap) + 105, 5); HackPanel.Size = new Size(350, this.ClientSize.Height); this.Controls.Add(HackPanel); AddTextBox(Lang.itemID, "ItemType", null); AddTextBox(Lang.damage, "ItemDamage", null); AddTextBox(Lang.number, "ItemStack", null); AddTextBox(Lang.knockBack, "ItemKnockBack", null, true); AddTextBox(Lang.crit, "ItemCrit", null); AddTextBox(Lang.buff, "ItemBuffType", null); AddTextBox(Lang.buffTime, "ItemBuffTime", null); AddTextBox(Lang.manaInc, "ItemHealMana", null); AddTextBox(Lang.lifeIncrease, "ItemHealLife", null); AddTextBox(Lang.useCD, "ItemUseTime", null); AddTextBox(Lang.waveCD, "ItemUseAnimation", null); AddTextBox(Lang.scale, "ItemScale", null, true); AddTextBox(Lang.defense, "ItemDefense", null); AddTextBox(Lang.projSpeed, "ItemShootSpeed", null, true); AddTextBox(Lang.projID, "ItemShoot", null); AddTextBox(Lang.dig, "ItemPick", null); AddTextBox(Lang.hag, "ItemAxe", null); AddTextBox(Lang.hammer, "ItemHammer", null); AddTextBox(Lang.digRange, "ItemTileBoost", null); AddTextBox(Lang.tileID, "ItemCreateTile", null); AddTextBox(Lang.placeStyle, "ItemPlaceStyle", null); AddTextBox(Lang.fishingPower, "ItemFishingPole", null); AddTextBox(Lang.baitPower, "ItemBait", null); PrefixComboBox = AddComboBox(Lang.prefix, MainForm.resource.Prefix); AutoReuse = new CheckBox() { Text = Lang.autoReuse, Size = new Size(130, 20), Location = new Point(0, 245) }; HackPanel.Controls.Add(AutoReuse); Equippable = new CheckBox() { Text = Lang.equippable, Size = new Size(130, 20), Location = new Point(135, 245) }; HackPanel.Controls.Add(Equippable); Button OK = new Button(); OK.Click += (sender, e) => { PixelData(Selected); InitData(Selected); RefreshSelected(); }; OK.Text = Lang.confirmHack; OK.Size = new Size(80, 30); OK.Location = new Point(260, 0); HackPanel.Controls.Add(OK); Button Refresh = new Button(); Refresh.Click += (sender, e) => { InitData(Selected); SlotsPanel.Refresh(); }; Refresh.Text = Lang.refresh; Refresh.Size = new Size(80, 30); Refresh.Location = new Point(260, 30); HackPanel.Controls.Add(Refresh); Button SaveInv = new Button(); SaveInv.Click += (sender, e) => { SaveFileDialog sfd = new SaveFileDialog() { Filter = "inv files (*.inv)|*.inv" }; if (sfd.ShowDialog() == DialogResult.OK) { HackFunctions.SaveInv(sfd.FileName); SlotsPanel.Refresh(); } }; SaveInv.Text = Lang.save; SaveInv.Size = new Size(80, 30); SaveInv.Location = new Point(260, 60); HackPanel.Controls.Add(SaveInv); Button LoadInv = new Button(); LoadInv.Click += (sender, e) => { OpenFileDialog ofd = new OpenFileDialog() { Filter = "inv files (*.inv)|*.inv" }; if (ofd.ShowDialog() == DialogResult.OK) { HackFunctions.LoadInv(this, ofd.FileName); SlotsPanel.Refresh(); InitData(Selected); } }; LoadInv.Text = Lang.load; LoadInv.Size = new Size(80, 30); LoadInv.Location = new Point(260, 90); HackPanel.Controls.Add(LoadInv); Button InitItem = new Button(); InitItem.Click += (sender, e) => { HackFunctions.SetItemDefaults(Selected, Convert.ToInt32(((TextBox)hacks["ItemType"]).Text), GetPrefixFromIndex(PrefixComboBox.SelectedIndex)); int stack = Convert.ToInt32(((TextBox)hacks["ItemStack"]).Text); HackFunctions.setItemStack(Selected, stack == 0 ? 1 : stack); RefreshSelected(); InitData(Selected); }; InitItem.Text = Lang.init; InitItem.Size = new Size(80, 30); InitItem.Location = new Point(260, 120); HackPanel.Controls.Add(InitItem); ItemSlots[0].Selected = true; InitData(0); timer = new Timer() { Interval = 500 }; timer.Tick += (sender, e) => { if (this.Enabled) { SlotsPanel.Refresh(); if (LastSelectedID != HackFunctions.getItemType(Selected)) { InitData(Selected); LastSelectedID = HackFunctions.getItemType(Selected); } } }; timer.Start(); }