void OnPopup(object sender, PopupEventArgs e) { lines.Clear(); lines.Add(Item.Name); if (Item.MaxCount == 1) { lines.Add("Unique"); } List <string> classes = WoWHelper.Classes(Item.AllowableClass); if (classes.Count < 9) { lines.Add(Classes(classes)); } size.Width = 0; Size temp; foreach (string line in lines) { temp = TextRenderer.MeasureText(line, Font); if (temp.Width > size.Width) { size = temp; } } size.Height += 2; size.Height *= lines.Count; e.ToolTipSize = size; }
public void GetItemList(string slot, string characterRace, string characterClass, CharacterModel character) { this.slot = slot; searchTextBox.Text = ""; itemsListBox.Items.Clear(); this.character = character; rotation = 0; XmlSerializer serializer = new XmlSerializer(typeof(Items)); using (StreamReader reader = new StreamReader(@"Data\" + ItemsFile(slot))) { items = (Items)serializer.Deserialize(reader.BaseStream); } RaceFilter(characterRace); ClassFilter(characterClass); list.Clear(); list.AddRange(items.Item); list.Sort((x, y) => x.Name.CompareTo(y.Name)); item = new ItemsItem { Name = "None", ID = "0", Quality = -1, Icon = WoWHelper.SlotIcon(slot, characterClass) }; itemsListBox.Items.Add(item); itemsListBox.Items.AddRange(list.ToArray()); itemsListBox.SelectedIndex = 0; }
void EquipOffHand() { if (Gear[17].ID == "0" || (Sheathe && (Gear[17].Sheath == 0 || Gear[17].Sheath == 7))) { components[4].Initialize(); } else { int attachment = Sheathe ? WoWHelper.SheatheAttachment(Gear[17].Sheath, true) : Gear[17].Type == "Shield" ? 0 : 2; ModelBone bone = bones[FindAttachment(attachment).bone]; string type = Gear[17].Type == "Shield" ? @"Shield\" : @"Weapon\"; position = SetVector3D(position, bone.Position.x, bone.Position.y, bone.Position.z); rotation = SetQuaternion(rotation, bone.Rotation.x, bone.Rotation.y, bone.Rotation.z, bone.Rotation.w); rotation = Sheathe ? rotation * WoWHelper.SheatheRotation(Gear[17].Sheath, true) : rotation; scale = SetVector3D(scale, bone.Scale.x, bone.Scale.y, bone.Scale.z); if (Gear[17].ID != components[4].ID) { components[4].Initialize(Gear[17].ID, Gear[17].Models.Left.Replace(".mdx", ".xml"), Gear[17].Textures.Left, objectComponentsPath + type, position, rotation, scale); } else { components[4].Modify(position, rotation, scale); } } }
public void GetItemList(string characterRace, string characterClass) { searchTextBox.Text = ""; itemsListBox.Items.Clear(); XmlSerializer serializer = new XmlSerializer(typeof(Items)); using (StreamReader reader = new StreamReader(@"Data\ReagentItems.xml")) { items = (Items)serializer.Deserialize(reader.BaseStream); } RaceFilter(characterRace); ClassFilter(characterClass); list.Clear(); list.AddRange(items.Item); list.Sort((x, y) => x.Name.CompareTo(y.Name)); item = new ItemsItem { Name = "None", ID = "0", Quality = -1, Icon = WoWHelper.SlotIcon("ammoReagent", characterClass) }; itemsListBox.Items.Add(item); itemsListBox.Items.AddRange(list.ToArray()); itemsListBox.SelectedIndex = 0; }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index >= Items.Count || e.Index <= -1) { return; } ItemsItem item = (ItemsItem)Items[e.Index]; if (item == null) { return; } Graphics graphics = e.Graphics; graphics.FillRectangle((e.State & DrawItemState.Selected) == DrawItemState.Selected ? new SolidBrush(Color.FromArgb(75, 75, 75)) : new SolidBrush(BackColor), e.Bounds); Bitmap icon = new Bitmap(@"Icons\" + item.Icon + ".png"); icon = new Bitmap(icon, e.Bounds.Height, e.Bounds.Height); graphics.FillRectangle(new TextureBrush(icon), e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height); SizeF stringSize = graphics.MeasureString(item.Name, Font); Font font = (e.State & DrawItemState.Selected) == DrawItemState.Selected ? bold : Font; Color color = item.Name == "None" ? Color.White : WoWHelper.QalityColor(item.Quality); graphics.DrawString(item.Name, font, new SolidBrush(color), 15, e.Bounds.Y + (e.Bounds.Height - stringSize.Height) / 2); }
void ClassFilter(string characterClass) { list.Clear(); list.AddRange(items.Item); foreach (ItemsItem item in items.Item) { if (!WoWHelper.ClassMatch(item.AllowableClass, characterClass)) { list.Remove(item); } } items.Item = list.ToArray(); }
void RaceFilter(string characterRace) { list.Clear(); list.AddRange(items.Item); foreach (ItemsItem item in items.Item) { if (!WoWHelper.RaceMatch(item.AllowableRace, characterRace)) { list.Remove(item); } } items.Item = list.ToArray(); }
void SlotFilter() { list.Clear(); list.AddRange(items.Item); foreach (ItemsItem item in items.Item) { if (!WoWHelper.SlotMatch(item.Slot, slot)) { list.Remove(item); } } items.Item = list.ToArray(); }
void typeRadioButton_CheckedChanged(object sender, EventArgs e) { RadioButton radioButton = (RadioButton)sender; if (radioButton.Checked) { if (radioButton.Text == "Polearm" || radioButton.Text == "Staff" || radioButton.Text.Contains("2H")) { character.Gear[17] = new ItemsItem { Name = "None", ID = "0", Quality = -1, Icon = WoWHelper.SlotIcon("offHand", characterClass) }; } else { character.Gear[17] = offHand; } itemsListBox.Items.Clear(); radioButton.Font = new Font(radioButton.Font, FontStyle.Bold); XmlSerializer serializer = new XmlSerializer(typeof(Items)); using (StreamReader reader = new StreamReader(@"Data\" + ItemsFile(radioButton.Text) + "Items.xml")) { items = (Items)serializer.Deserialize(reader.BaseStream); } RaceFilter(); ClassFilter(); SlotFilter(); list.Clear(); list.AddRange(items.Item); list.Sort((x, y) => x.Name.CompareTo(y.Name)); item = new ItemsItem { ID = "0", Name = "None", Type = "", Slot = "", Quality = -1, Icon = WoWHelper.SlotIcon(slot, characterClass) }; itemsListBox.Items.Add(item); itemsListBox.Items.AddRange(list.ToArray()); itemsListBox.SelectedIndex = 0; } else { radioButton.Font = new Font(radioButton.Font, FontStyle.Regular); } }
void itemsListBox_SelectedIndexChanged(object sender, EventArgs e) { selected = (ItemsItem)itemsListBox.SelectedItem; character.Gear[WoWHelper.Slot(slot)] = selected; if (selected.Name == "None") { cosmeticTooltip.Hide(itemsListBox); } else { cosmeticTooltip.Item = selected; cosmeticTooltip.Show(selected.Name, itemsListBox, itemsListBox.Size.Width + 6 + openGLControl.Width, 0); } }
void itemsListBox_SelectedIndexChanged(object sender, EventArgs e) { selected = (ItemsItem)itemsListBox.SelectedItem; character.Gear[WoWHelper.Slot(slot)] = selected; if (shieldRadioButton.Checked) { weaponTooltip.Hide(itemsListBox); heldInOffHandTooltip.Hide(itemsListBox); if (selected.Name == "None") { shieldTooltip.Hide(itemsListBox); } else { shieldTooltip.Item = selected; shieldTooltip.Show(selected.Name, itemsListBox, itemsListBox.Size.Width + 6 + openGLControl.Width, 0); } } else if (heldInOffHandRadioButton.Checked) { weaponTooltip.Hide(itemsListBox); shieldTooltip.Hide(itemsListBox); if (selected.Name == "None") { heldInOffHandTooltip.Hide(itemsListBox); } else { heldInOffHandTooltip.Item = selected; heldInOffHandTooltip.Show(selected.Name, itemsListBox, itemsListBox.Size.Width + 6 + openGLControl.Width, 0); } } else { shieldTooltip.Hide(itemsListBox); heldInOffHandTooltip.Hide(itemsListBox); if (selected.Name == "None") { weaponTooltip.Hide(itemsListBox); } else { weaponTooltip.Item = selected; weaponTooltip.Show(selected.Name, itemsListBox, itemsListBox.Size.Width + 6 + openGLControl.Width, 0); } } }
void OnDraw(object sender, DrawToolTipEventArgs e) { int y = 0; Graphics graphics = e.Graphics; graphics.FillRectangle(new SolidBrush(BackColor), e.Bounds); graphics.DrawRectangle(new Pen(Color.FromArgb(75, 75, 75)), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1)); graphics.DrawString(lines[y], Font, new SolidBrush(WoWHelper.QalityColor(Item.Quality)), new PointF(3, 1 + 14 * y++)); if (Item.MaxCount == 1) { graphics.DrawString(lines[y], Font, new SolidBrush(ForeColor), new PointF(3, 1 + 14 * y++)); } List <string> classes = WoWHelper.Classes(Item.AllowableClass); if (classes.Count < 9) { DrawClasses(lines[y].Split(' '), y, graphics); } }
void DrawClasses(string[] words, int y, Graphics graphics) { int x = 3; graphics.DrawString(words[0], Font, new SolidBrush(ForeColor), new PointF(x, 1 + 14 * y)); Size size = TextRenderer.MeasureText(words[0], Font); x += size.Width - 12; for (int i = 1; i < words.Length - 1; i++) { x += 7; graphics.DrawString(words[i].Replace(",", ""), Font, new SolidBrush(WoWHelper.ClassColor(words[i].Replace(",", ""))), new PointF(x, 1 + 14 * y)); size = TextRenderer.MeasureText(words[i], Font); x += size.Width - 12; graphics.DrawString(", ", Font, new SolidBrush(ForeColor), new PointF(x, 1 + 14 * y)); } x += 7; graphics.DrawString(words[words.Length - 1], Font, new SolidBrush(WoWHelper.ClassColor(words[words.Length - 1])), new PointF(x, 1 + 14 * y++)); }
void EquipMainHand() { if (Gear[16].ID == "0" || (Sheathe && (Gear[16].Sheath == 0 || Gear[16].Sheath == 7))) { components[3].Initialize(); } else { int attachment = Sheathe ? WoWHelper.SheatheAttachment(Gear[16].Sheath, false) : 1; ModelBone bone = bones[FindAttachment(attachment).bone]; position = SetVector3D(position, bone.Position.x, bone.Position.y, bone.Position.z); rotation = SetQuaternion(rotation, bone.Rotation.x, bone.Rotation.y, bone.Rotation.z, bone.Rotation.w); rotation = Sheathe ? rotation * WoWHelper.SheatheRotation(Gear[16].Sheath, false) : rotation; scale = SetVector3D(scale, bone.Scale.x, bone.Scale.y, bone.Scale.z); if (Gear[16].ID != components[3].ID) { components[3].Initialize(Gear[16].ID, Gear[16].Models.Left.Replace(".mdx", ".xml"), Gear[16].Textures.Left, objectComponentsPath + @"Weapon\", position, rotation, scale); } else { components[3].Modify(position, rotation, scale); } } }
//Load and setup model prefab public IEnumerator LoadPrefab(string modelfile, CASCHandler casc) { DestroyImmediate(mesh); if (modelsPath == null) { modelsPath = @"creature\"; } bool done = false; converter = new System.Drawing.ImageConverter(); this.casc = casc; GameObject prefab = Resources.Load <GameObject>($"{modelsPath}{modelfile}_prefab"); mesh = Instantiate(prefab, gameObject.transform); yield return(null); M2Model m2 = GetComponentInChildren <M2Model>(); byte[] data = m2.data.bytes; byte[] skin = m2.skin.bytes; byte[] skel = m2.skel.bytes; loadBinaries = new Thread(() => { Model = m2.LoadModel(data, skin, skel); done = true; }); loadBinaries.Start(); yield return(null); while (loadBinaries.IsAlive) { yield return(null); } if (done) { LoadColors(); textures = new Texture2D[Model.Textures.Length]; Transform[] bones = GetComponentInChildren <SkinnedMeshRenderer>().bones; yield return(null); if (Model.Particles.Length > 0) { GameObject[] particles = new GameObject[Model.Particles.Length]; for (int i = 0; i < particles.Length; i++) { particles[i] = WoWHelper.ParticleEffect(Model.Particles[i]); particles[i].transform.parent = bones[Model.Particles[i].Bone]; particles[i].transform.localPosition = Vector3.zero; particles[i].name = $"Particle{i}"; yield return(null); } } time = new float[Model.TextureAnimations.Length]; frame = new int[Model.TextureAnimations.Length]; for (int i = 0; i < time.Length; i++) { time[i] = 0f; frame[i] = 0; yield return(null); } renderer = GetComponentInChildren <SkinnedMeshRenderer>(); Change = true; Loaded = !loadBinaries.IsAlive; } }
//Load the model from CASC public IEnumerator LoadModel(int file, int texture, CASCHandler casc) { File = file; if (file != 0) { Texture = texture; this.casc = casc; converter = new System.Drawing.ImageConverter(); byte[] bytes; yield return(null); using (BinaryReader reader = new BinaryReader(casc.OpenFile(file))) { bytes = reader.ReadBytes((int)reader.BaseStream.Length); } yield return(null); Model = new M2(); Model.LoadFile(bytes); yield return(null); if (Model.SkelFileID != 0) { using (BinaryReader reader = new BinaryReader(casc.OpenFile(Model.SkelFileID))) { bytes = reader.ReadBytes((int)reader.BaseStream.Length); } } yield return(null); Model.Skeleton.LoadFile(bytes, Model.SkelFileID); yield return(null); using (BinaryReader reader = new BinaryReader(casc.OpenFile(Model.SkinFileID))) { bytes = reader.ReadBytes((int)reader.BaseStream.Length); } yield return(null); Model.Skin.LoadFile(bytes); yield return(null); //Array.Sort(Model.Skin.Textures, (a, b) => Model.Materials[a.Material].Blend.CompareTo(Model.Materials[b.Material].Blend)); LoadColors(); yield return(null); textures = new Texture2D[Model.Textures.Length]; mesh = WoWHelper.Generate3DMesh(Model); mesh.transform.parent = GetComponent <Transform>(); mesh.transform.localPosition = Vector3.zero; mesh.transform.localEulerAngles = Vector3.zero; mesh.transform.localScale = Vector3.one; renderer = GetComponentInChildren <SkinnedMeshRenderer>(); yield return(null); Transform[] bones = GetComponentInChildren <SkinnedMeshRenderer>().bones; if (Model.Particles.Length > 0) { GameObject[] particles = new GameObject[Model.Particles.Length]; for (int i = 0; i < particles.Length; i++) { particles[i] = WoWHelper.ParticleEffect(Model.Particles[i]); particles[i].transform.parent = bones[Model.Particles[i].Bone]; particles[i].transform.localPosition = Vector3.zero; particles[i].name = $"Particle{i}"; yield return(null); } } if (character.Form == 7) { MatchBones(gilnean); } else { MatchBones(character); } time = new float[Model.TextureAnimations.Length]; frame = new int[Model.TextureAnimations.Length]; for (int i = 0; i < time.Length; i++) { time[i] = 0f; frame[i] = 0; yield return(null); } Loaded = true; Change = true; } }