private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { string itemextention; string moditemdata; string dir; if (File.Exists(StarboundPath + "\\mods" + listBox1.SelectedItem.ToString())) { itemextention = Path.GetExtension(StarboundPath + "\\mods" + listBox1.SelectedItem.ToString()); moditemdata = File.ReadAllText(StarboundPath + "\\mods" + listBox1.SelectedItem.ToString()); dir = StarboundPath + "\\mods" + listBox1.SelectedItem.ToString(); } else { itemextention = Path.GetExtension(AssetFolder + listBox1.SelectedItem.ToString()); dir = AssetFolder + listBox1.SelectedItem.ToString(); moditemdata = File.ReadAllText(AssetFolder + listBox1.SelectedItem.ToString()); } VanillaItemPath = listBox1.SelectedItem.ToString(); MessageBox.Show(VanillaItemPath); switch (itemextention) { case (".chest"): itemTypebox.Text = "Armour"; AddDefaultTabs(); tabControl1.TabPages.Add(ArmourTab); tabControl1.TabPages.Add(Descriptiontab); ArmourChest chest = JsonConvert.DeserializeObject <ArmourChest>(moditemdata); VanillaItemName = chest.RefrenceName; LoadChest(chest, dir); Update(); break; case (".legs"): AddDefaultTabs(); tabControl1.TabPages.Add(ArmourTab); tabControl1.TabPages.Add(Descriptiontab); ArmourLegs legs = JsonConvert.DeserializeObject <ArmourLegs>(moditemdata); VanillaItemName = legs.RefrenceName; LoadLegs(legs, dir); Update(); break; case (".head"): AddDefaultTabs(); tabControl1.TabPages.Add(ArmourTab); tabControl1.TabPages.Add(Descriptiontab); ArmourHead head = JsonConvert.DeserializeObject <ArmourHead>(moditemdata); VanillaItemName = head.RefrenceName; LoadHead(head, dir); Update(); break; } }
private void LoadHead(ArmourHead head, string p) { string path = Path.GetDirectoryName(p); itemTypebox.Text = "Armour"; try { facemaskpic.Image = Image.FromFile(path + "\\" + head.Mask); }catch (Exception f**k) {} masktxtbox.Text = head.Mask; itemNametxtbox.Text = head.Name; maxstack.Value = head.MaxStack; raritybox.Text = head.Rarity; dropCol1.Text = head.Collisions[0].ToString(); dropCol2.Text = head.Collisions[1].ToString(); dropCol3.Text = head.Collisions[2].ToString(); dropCol4.Text = head.Collisions[3].ToString(); itemTypebox.Text = "Armour"; string[] files = head.IconPath.Split(':'); try { invicopicbox.Image = Image.FromFile(path + "\\" + files[0]); invicotxt.Text = files[0]; typetxt.Text = files[1]; maleframebox.Image = Image.FromFile(path + "\\" + head.MaleFrames); femaleframebox.Image = Image.FromFile(path + "\\" + head.FemaleFrames); } catch (Exception fuck2) { } maleframetxt.Text = head.MaleFrames; femaleframetxt.Text = head.FemaleFrames; this.armourStatusEffects.Rows.Clear(); foreach (JObject se in head.StatusEffectsString) { JToken token = (JToken)se; string kind = (string)token.SelectToken("kind"); int amount = (int)token.SelectToken("amount"); if (token.SelectToken("level") != null) { int level = (int)token.SelectToken("level"); this.armourStatusEffects.Rows.Add(kind, amount, level); } else { this.armourStatusEffects.Rows.Add(kind, amount); } } Update(); ValidateJSON(); MessageBox.Show("Head Loaded"); }
private void ValidateJSON() { validjsonlbl.Text = ""; try { JObject data = JsonConvert.DeserializeObject <JObject>(rawcode.Text); validjsonlbl.Text = "Valid JSON Data!"; jsondata = rawcode.Text; validjsonlbl.ForeColor = Color.LimeGreen; } catch (Exception exc) { Console.Write(exc.ToString()); validjsonlbl.Text = "Invalid JSON Data!"; validjsonlbl.ForeColor = Color.Red; } try { ArmourHead headtest = JsonConvert.DeserializeObject <ArmourHead>(rawcode.Text); if (headtest.Mask == null) { throw new System.ArgumentException("Parameter cannot be null", "original"); } ItemTypeLabel.Text = "Head"; // LoadHead(headtest, ""); ItemTypeLabel.ForeColor = Color.Crimson; itemisalbl.Enabled = true; return; } catch (Exception x) {//Not a head // Console.Clear(); Console.WriteLine(x.ToString()); Console.Write("Not a head"); } try { ArmourChest chesttest = JsonConvert.DeserializeObject <ArmourChest>(rawcode.Text); // LoadChest(chesttest, ""); ItemTypeLabel.Text = "Chest"; ItemTypeLabel.ForeColor = Color.Chocolate; itemisalbl.Enabled = true; return; } catch (Exception l) { Console.Write("Not a chest"); } try { ArmourLegs legtest = JsonConvert.DeserializeObject <ArmourLegs>(rawcode.Text); // LoadLegs(legtest, ""); ItemTypeLabel.Text = "Legs"; ItemTypeLabel.ForeColor = Color.Crimson; itemisalbl.Enabled = true; return; } catch (Exception lol) { Console.Write("Not legs"); Console.WriteLine(lol.ToString()); } }
private void Update() { float[] coll = new float[4]; int i = 1; ArrayList sees = new ArrayList(); ArrayList colors = new ArrayList(); JSONColor co1 = new JSONColor(); JSONColor co2 = new JSONColor(); colors.Add(co1); colors.Add(co2); switch (itemTypebox.Text) { case ("Armour"): switch (typetxt.Text) { case "chest": ArmourChest chest = new ArmourChest(); chest.RefrenceName = VanillaItemName; chest.Name = itemNametxtbox.Text; chest.IconPath = invicotxt.Text; coll[0] = float.Parse(dropCol1.Text); coll[1] = float.Parse(dropCol2.Text); coll[2] = float.Parse(dropCol3.Text); coll[3] = float.Parse(dropCol4.Text); chest.Collisions = coll; chest.MaxStack = Convert.ToInt32(maxstack.Value); chest.Rarity = raritybox.Text; chest.Description = maindesc.Text; chest.InspectionKind = "armor"; Dictionary <string, string> data = new Dictionary <string, string>(); Dictionary <string, string> data2 = new Dictionary <string, string>(); data.Add("body", maleframetxt.Text); data.Add("backSleeve", backmtxt.Text); data.Add("frontSleeve", frontmtxt.Text); chest.MFrames = data; data2.Add("body", femaleframetxt.Text); data2.Add("backSleeve", backftxt.Text); data2.Add("frontSleeve", frontftxt.Text); chest.FFrames = data2; // chest.FFrames = female; // string [] bob = new string[] { "ffca8a", "838383", "e0975c", "555555", "a85636", "383838", "6f2919" , "151515" }; // chest.ColorOptions = colors; foreach (DataGridViewRow se in armourStatusEffects.Rows) { if (se.Cells[0].Value != null && se.Cells[1].Value != null) { se.Cells[0].FormattedValue.ToString(); StatusEffect see = new StatusEffect(); see.Kind = se.Cells[0].Value.ToString(); string str = se.Cells[i].Value.ToString(); see.Amount = Convert.ToInt32(str); // System.Console.Write(str); try { sees.Add(see); } catch (Exception l) { sees.Add(see); } } chest.StatusEffectsString = sees; var json = JsonConvert.SerializeObject(chest, Formatting.Indented); // Console.Write(json); rawcode.Text = json; } break; case "head": ArmourHead ahead = new ArmourHead(); ahead.RefrenceName = VanillaItemName; ahead.Name = itemNametxtbox.Text; ahead.IconPath = invicotxt.Text; ahead.Mask = masktxtbox.Text; coll[0] = float.Parse(dropCol1.Text); coll[1] = float.Parse(dropCol2.Text); coll[2] = float.Parse(dropCol3.Text); coll[3] = float.Parse(dropCol4.Text); ahead.Collisions = coll; ahead.MaxStack = Convert.ToInt32(maxstack.Value); ahead.Rarity = raritybox.Text; ahead.Description = maindesc.Text; ahead.InspectionKind = "armor"; ahead.MaleFrames = maleframetxt.Text; ahead.FemaleFrames = femaleframetxt.Text; // ahead.ColorOptions = colors; foreach (DataGridViewRow se in armourStatusEffects.Rows) { if (se.Cells[0].Value != null && se.Cells[1].Value != null) { se.Cells[0].FormattedValue.ToString(); StatusEffect see = new StatusEffect(); see.Kind = se.Cells[0].Value.ToString(); string str = se.Cells[i].Value.ToString(); see.Amount = Convert.ToInt32(str); // System.Console.Write(str); try { sees.Add(see); } catch (Exception l) { sees.Add(see); } } ahead.StatusEffectsString = sees; var json = JsonConvert.SerializeObject(ahead, Formatting.Indented); // Console.Write(json); rawcode.Text = json; } break; case "pants": ArmourLegs ah = new ArmourLegs(); ah.RefrenceName = VanillaItemName; ah.Name = itemNametxtbox.Text; ah.IconPath = invicotxt.Text; coll[0] = float.Parse(dropCol1.Text); coll[1] = float.Parse(dropCol2.Text); coll[2] = float.Parse(dropCol3.Text); coll[3] = float.Parse(dropCol4.Text); ah.Collisions = coll; ah.MaxStack = Convert.ToInt32(maxstack.Value); ah.Rarity = raritybox.Text; ah.Description = maindesc.Text; ah.InspectionKind = "armor"; ah.MaleFrames = maleframetxt.Text; ah.FemaleFrames = femaleframetxt.Text; // ah.ColorOptions = colors; foreach (DataGridViewRow se in armourStatusEffects.Rows) { if (se.Cells[0].Value != null && se.Cells[1].Value != null) { se.Cells[0].FormattedValue.ToString(); StatusEffect see = new StatusEffect(); see.Kind = se.Cells[0].Value.ToString(); string str = se.Cells[i].Value.ToString(); see.Amount = Convert.ToInt32(str); //System.Console.Write(str); try { sees.Add(see); } catch (Exception l) { sees.Add(see); } } ah.StatusEffectsString = sees; var json = JsonConvert.SerializeObject(ah, Formatting.Indented); // Console.Write(json); rawcode.Text = json; } break; case ("Coin"): break; case ("Generic"): break; case ("Gun"): break; case ("Instrument"): break; case ("Material"): break; case ("Shield"): break; case ("Melee"): break; case ("Throwable"): break; case ("Tool"): break; default: break; } break; } }