private Bitmap RenderSetItem(out int picHeight) { Bitmap setBitmap = new Bitmap(261, DefaultPicHeight); Graphics g = Graphics.FromImage(setBitmap); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; picHeight = 10; g.DrawString(this.SetItem.SetItemName, GearGraphics.ItemDetailFont2, GearGraphics.GreenBrush2, 130, 10, format); picHeight += 25; format.Alignment = StringAlignment.Far; Wz_Node characterWz = PluginManager.FindWz(Wz_Type.Character); foreach (var setItemPart in this.SetItem.ItemIDs.Parts) { string itemName = setItemPart.Value.RepresentName; string typeName = setItemPart.Value.TypeName; if (string.IsNullOrEmpty(typeName) && SetItem.Parts) { typeName = "Special"; } ItemBase itemBase = null; bool cash = false; int wonderGrade = 0; if (setItemPart.Value.ItemIDs.Count > 0) { var itemID = setItemPart.Value.ItemIDs.First().Key; switch (itemID / 1000000) { case 0: //avatar case 1: //gear if (characterWz != null) { foreach (Wz_Node typeNode in characterWz.Nodes) { Wz_Node itemNode = typeNode.FindNodeByPath(string.Format("{0:D8}.img", itemID), true); if (itemNode != null) { var gear = Gear.CreateFromNode(itemNode, PluginManager.FindWz); cash = gear.Cash; itemBase = gear; break; } } } break; case 5: //Pet { Wz_Node itemNode = PluginBase.PluginManager.FindWz(string.Format(@"Item\Pet\{0:D7}.img", itemID)); if (itemNode != null) { var item = Item.CreateFromNode(itemNode, PluginManager.FindWz); cash = item.Cash; item.Props.TryGetValue(ItemPropType.wonderGrade, out wonderGrade); itemBase = item; } } break; } } if (string.IsNullOrEmpty(itemName) || string.IsNullOrEmpty(typeName)) { if (setItemPart.Value.ItemIDs.Count > 0) { var itemID = setItemPart.Value.ItemIDs.First().Key; StringResult sr = null;; if (this.StringLinker != null) { if (this.StringLinker.StringEqp.TryGetValue(itemID, out sr)) { itemName = sr.Name; if (typeName == null) { typeName = ItemStringHelper.GetSetItemGearTypeString(Gear.GetGearType(itemID)); } } else if (this.StringLinker.StringItem.TryGetValue(itemID, out sr)) //兼容宠物 { itemName = sr.Name; if (typeName == null) { if (itemID / 10000 == 500) { typeName = "Pet"; } else { typeName = ""; } } } } if (sr == null) { itemName = "(null)"; } } } itemName = itemName ?? string.Empty; typeName = typeName ?? "Equipment"; if (!Regex.IsMatch(typeName, @"^(\(.*\)|(.*))$")) { typeName = "(" + typeName + ")"; } Brush brush = setItemPart.Value.Enabled ? Brushes.White : GearGraphics.GrayBrush2; if (!cash) { g.DrawString(itemName, GearGraphics.ItemDetailFont2, brush, 8, picHeight); g.DrawString(typeName, GearGraphics.ItemDetailFont2, brush, 254, picHeight, format); picHeight += 18; } else { g.FillRectangle(GearGraphics.GearIconBackBrush2, 10, picHeight, 36, 36); g.DrawImage(Resource.Item_shadow, 10 + 2 + 3, picHeight + 2 + 32 - 6); if (itemBase?.IconRaw.Bitmap != null) { var icon = itemBase.IconRaw; g.DrawImage(icon.Bitmap, 10 + 2 - icon.Origin.X, picHeight + 2 + 32 - icon.Origin.Y); } Bitmap cashImg = null; if (wonderGrade > 0) { string resKey = $"CashShop_img_CashItem_label_{wonderGrade + 3}"; cashImg = Resource.ResourceManager.GetObject(resKey) as Bitmap; } if (cashImg == null) //default cashImg { cashImg = Resource.CashItem_0; } g.DrawImage(cashImg, 10 + 2 + 20, picHeight + 2 + 32 - 12); g.DrawString(itemName, GearGraphics.ItemDetailFont2, brush, 50, picHeight); g.DrawString(typeName, GearGraphics.ItemDetailFont2, brush, 254, picHeight, format); picHeight += 40; } } if (!this.SetItem.ExpandToolTip) { picHeight += 5; g.DrawLine(Pens.White, 6, picHeight, 254, picHeight);//分割线 picHeight += 9; RenderEffect(g, ref picHeight); } picHeight += 11; format.Dispose(); g.Dispose(); return(setBitmap); }
public override Bitmap Render() { if (this.item == null) { return(null); } //绘制道具 int picHeight; Bitmap itemBmp = RenderItem(out picHeight); Bitmap recipeInfoBmp = null; Bitmap recipeItemBmp = null; Bitmap setItemBmp = null; //图纸相关 int recipeID; if (this.item.Specs.TryGetValue(ItemSpecType.recipe, out recipeID)) { int recipeSkillID = recipeID / 10000; Recipe recipe = null; //寻找配方 Wz_Node recipeNode = PluginBase.PluginManager.FindWz(string.Format(@"Skill\Recipe_{0}.img\{1}", recipeSkillID, recipeID)); if (recipeNode != null) { recipe = Recipe.CreateFromNode(recipeNode); } //生成配方图像 if (recipe != null) { if (this.LinkRecipeInfo) { recipeInfoBmp = RenderLinkRecipeInfo(recipe); } if (this.LinkRecipeItem) { int itemID = recipe.MainTargetItemID; int itemIDClass = itemID / 1000000; if (itemIDClass == 1) //通过ID寻找装备 { Wz_Node charaWz = PluginManager.FindWz(Wz_Type.Character); if (charaWz != null) { string imgName = itemID.ToString("d8") + ".img"; foreach (Wz_Node node0 in charaWz.Nodes) { Wz_Node imgNode = node0.FindNodeByPath(imgName, true); if (imgNode != null) { Gear gear = Gear.CreateFromNode(imgNode, path => PluginManager.FindWz(path)); if (gear != null) { recipeItemBmp = RenderLinkRecipeGear(gear); } break; } } } } else if (itemIDClass >= 2 && itemIDClass <= 5) //通过ID寻找道具 { Wz_Node itemWz = PluginManager.FindWz(Wz_Type.Item); if (itemWz != null) { string imgClass = (itemID / 10000).ToString("d4") + ".img\\" + itemID.ToString("d8"); foreach (Wz_Node node0 in itemWz.Nodes) { Wz_Node imgNode = node0.FindNodeByPath(imgClass, true); if (imgNode != null) { Item item = Item.CreateFromNode(imgNode, PluginManager.FindWz); if (item != null) { recipeItemBmp = RenderLinkRecipeItem(item); } break; } } } } } } } int setID; if (this.item.Props.TryGetValue(ItemPropType.setItemID, out setID)) { SetItem setItem; if (CharaSimLoader.LoadedSetItems.TryGetValue(setID, out setItem)) { setItemBmp = RenderSetItem(setItem); } } //计算布局 Size totalSize = new Size(itemBmp.Width, picHeight); Point recipeInfoOrigin = Point.Empty; Point recipeItemOrigin = Point.Empty; Point setItemOrigin = Point.Empty; if (recipeItemBmp != null) { recipeItemOrigin.X = totalSize.Width; totalSize.Width += recipeItemBmp.Width; if (recipeInfoBmp != null) { recipeInfoOrigin.X = itemBmp.Width - recipeInfoBmp.Width; recipeInfoOrigin.Y = picHeight; totalSize.Height = Math.Max(picHeight + recipeInfoBmp.Height, recipeItemBmp.Height); } else { totalSize.Height = Math.Max(picHeight, recipeItemBmp.Height); } } else if (recipeInfoBmp != null) { totalSize.Width += recipeInfoBmp.Width; totalSize.Height = Math.Max(picHeight, recipeInfoBmp.Height); recipeInfoOrigin.X = itemBmp.Width; } if (setItemBmp != null) { setItemOrigin = new Point(totalSize.Width, 0); totalSize.Width += setItemBmp.Width; totalSize.Height = Math.Max(totalSize.Height, setItemBmp.Height); } //开始绘制 Bitmap tooltip = new Bitmap(totalSize.Width, totalSize.Height); Graphics g = Graphics.FromImage(tooltip); if (itemBmp != null) { //绘制背景区域 GearGraphics.DrawNewTooltipBack(g, 0, 0, itemBmp.Width, picHeight); //复制图像 g.DrawImage(itemBmp, 0, 0, new Rectangle(0, 0, itemBmp.Width, picHeight), GraphicsUnit.Pixel); //左上角 g.DrawImage(Resource.UIToolTip_img_Item_Frame2_cover, 3, 3); if (this.ShowObjectID) { GearGraphics.DrawGearDetailNumber(g, 3, 3, item.ItemID.ToString("d8"), true); } } //绘制配方 if (recipeInfoBmp != null) { g.DrawImage(recipeInfoBmp, recipeInfoOrigin.X, recipeInfoOrigin.Y, new Rectangle(Point.Empty, recipeInfoBmp.Size), GraphicsUnit.Pixel); } //绘制产出道具 if (recipeItemBmp != null) { g.DrawImage(recipeItemBmp, recipeItemOrigin.X, recipeItemOrigin.Y, new Rectangle(Point.Empty, recipeItemBmp.Size), GraphicsUnit.Pixel); } //绘制套装 if (setItemBmp != null) { g.DrawImage(setItemBmp, setItemOrigin.X, setItemOrigin.Y, new Rectangle(Point.Empty, setItemBmp.Size), GraphicsUnit.Pixel); } if (itemBmp != null) { itemBmp.Dispose(); } if (recipeInfoBmp != null) { recipeInfoBmp.Dispose(); } if (recipeItemBmp != null) { recipeItemBmp.Dispose(); } if (setItemBmp != null) { setItemBmp.Dispose(); } g.Dispose(); return(tooltip); }
private Bitmap RenderSetItem(out int picHeight) { Bitmap setBitmap = new Bitmap(261, DefaultPicHeight); Graphics g = Graphics.FromImage(setBitmap); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; picHeight = 10; g.DrawString(this.SetItem.SetItemName, GearGraphics.ItemDetailFont2, GearGraphics.GreenBrush2, 130, 10, format); picHeight += 25; format.Alignment = StringAlignment.Far; Wz_Node characterWz = PluginManager.FindWz(Wz_Type.Character); foreach (var setItemPart in this.SetItem.ItemIDs.Parts) { string itemName = setItemPart.Value.RepresentName; string typeName = setItemPart.Value.TypeName; Gear gear = null; if (characterWz != null) { foreach (var itemID in setItemPart.Value.ItemIDs) { foreach (Wz_Node typeNode in characterWz.Nodes) { Wz_Node itemNode = typeNode.FindNodeByPath(string.Format("{0:D8}.img", itemID.Key), true); if (itemNode != null) { gear = Gear.CreateFromNode(itemNode, PluginManager.FindWz); break; } } break; } } if (string.IsNullOrEmpty(typeName) && SetItem.Parts) { typeName = "装备"; } if (string.IsNullOrEmpty(itemName) || string.IsNullOrEmpty(typeName)) { foreach (var itemID in setItemPart.Value.ItemIDs) { StringResult sr = null;; if (StringLinker != null) { if (StringLinker.StringEqp.TryGetValue(itemID.Key, out sr)) { itemName = sr.Name; if (typeName == null) { typeName = ItemStringHelper.GetSetItemGearTypeString(Gear.GetGearType(itemID.Key)); } } else if (StringLinker.StringItem.TryGetValue(itemID.Key, out sr)) //兼容宠物 { itemName = sr.Name; if (typeName == null) { if (itemID.Key / 10000 == 500) { typeName = "宠物"; } else { typeName = ""; } } } } if (sr == null) { itemName = "(null)"; } break; } } itemName = itemName ?? string.Empty; typeName = typeName ?? "装备"; if (!Regex.IsMatch(typeName, @"^(\(.*\)|(.*))$")) { typeName = "(" + typeName + ")"; } Brush brush = setItemPart.Value.Enabled ? Brushes.White : GearGraphics.GrayBrush2; if (gear == null || !gear.Cash) { g.DrawString(itemName, GearGraphics.ItemDetailFont2, brush, 8, picHeight); g.DrawString(typeName, GearGraphics.ItemDetailFont2, brush, 254, picHeight, format); picHeight += 18; } else { g.FillRectangle(GearGraphics.GearIconBackBrush2, 10, picHeight, 36, 36); g.DrawImage(Resource.Item_shadow, 10 + 2 + 3, picHeight + 2 + 32 - 6); if (gear != null && gear.IconRaw.Bitmap != null) { g.DrawImage(gear.IconRaw.Bitmap, 10 + 2 - gear.IconRaw.Origin.X, picHeight + 2 + 32 - gear.IconRaw.Origin.Y); } g.DrawImage(Resource.CashItem_0, 10 + 2 + 20, picHeight + 2 + 32 - 12); g.DrawString(itemName, GearGraphics.ItemDetailFont2, brush, 50, picHeight); g.DrawString(typeName, GearGraphics.ItemDetailFont2, brush, 254, picHeight, format); picHeight += 40; } } if (!this.SetItem.ExpandToolTip) { picHeight += 5; g.DrawLine(Pens.White, 6, picHeight, 254, picHeight);//分割线 picHeight += 9; RenderEffect(g, ref picHeight); } picHeight += 11; format.Dispose(); g.Dispose(); return(setBitmap); }