//待機アイコン + テキストを書くルーチン Size Draw(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw) { if (index < 0 || index >= lb.Items.Count) { return(new Size(listbounds.X, listbounds.Y)); } string text = lb.Items[index].ToString(); SolidBrush brush = new SolidBrush(lb.ForeColor); Font normalFont = lb.Font; Rectangle bounds = listbounds; int textmargineY = (ListBoxEx.OWNER_DRAW_ICON_SIZE - (int)lb.Font.Height) / 2; //テキストの先頭にアイコン番号(キャラ番号が入っている. 無駄だが汎用性を考えるとほかに方法がない) uint icon = U.atoh(text); Bitmap bitmap; if (index == 0) { bitmap = ImageUtil.Blank(8, 8); } else { uint typeID = GetTypeID(); if (typeID <= 1) { bitmap = UnitForm.DrawUnitMapFacePicture(icon); } else { bitmap = ClassForm.DrawWaitIcon(icon, 0, true); } } U.MakeTransparent(bitmap); //アイコンを描く. 処理速度を稼ぐためにマップアイコンの方を描画 Rectangle b = bounds; b.Width = ListBoxEx.OWNER_DRAW_ICON_SIZE; b.Height = ListBoxEx.OWNER_DRAW_ICON_SIZE; bounds.X += U.DrawPicture(bitmap, g, isWithDraw, b); bitmap.Dispose(); //テキストを描く. b = bounds; b.Y += textmargineY; bounds.X += U.DrawText(text, g, normalFont, brush, isWithDraw, b); bounds.Y += ListBoxEx.OWNER_DRAW_ICON_SIZE; brush.Dispose(); return(new Size(bounds.X, bounds.Y)); }
public static Bitmap DrawAIUnitsList(uint units_address, int iconSize) { units_address = U.toOffset(units_address); if (!U.isSafetyOffset(units_address)) { return(ImageUtil.BlankDummy()); } int count = 0; uint addr = units_address; while (Program.ROM.u16(addr) != 0x0) { addr += 2; if (!U.isSafetyOffset(addr)) { break; } count++; } if (count <= 0) { return(ImageUtil.BlankDummy()); } Bitmap bitmap = new Bitmap(iconSize * count, iconSize); Rectangle bounds = new Rectangle(0, 0, bitmap.Width, bitmap.Height); using (Graphics g = Graphics.FromImage(bitmap)) { addr = units_address; for (int i = 0; i < count; i++) { uint unit_id = Program.ROM.u8(addr + 0); Bitmap icon = UnitForm.DrawUnitMapFacePicture(unit_id); if (ImageUtil.IsBlankBitmap(icon)) { uint class_id = UnitForm.GetClassID(unit_id); icon = ClassForm.DrawWaitIcon(class_id); } U.MakeTransparent(icon); Rectangle b = bounds; b.Width = iconSize; b.Height = iconSize; bounds.X += U.DrawPicture(icon, g, true, b); addr += 2; } } return(bitmap); }
//Unit + テキストを書く public static Size DrawUnitAndText(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw) { if (index < 0 || index >= lb.Items.Count) { return(new Size(listbounds.X, listbounds.Y)); } string text = lb.Items[index].ToString(); SolidBrush brush = new SolidBrush(lb.ForeColor); Font normalFont = lb.Font; Rectangle bounds = listbounds; int textmargineY = (OWNER_DRAW_ICON_SIZE - (int)lb.Font.Height) / 2; //テキストの先頭にアイコン番号(キャラ番号が入っている. 無駄だが汎用性を考えるとほかに方法がない) uint icon = U.atoh(text); Bitmap bitmap = UnitForm.DrawUnitMapFacePicture(icon); U.MakeTransparent(bitmap); //アイコンを描く. 処理速度を稼ぐためにマップアイコンの方を描画 Rectangle b = bounds; b.Width = OWNER_DRAW_ICON_SIZE; b.Height = OWNER_DRAW_ICON_SIZE; bounds.X += U.DrawPicture(bitmap, g, isWithDraw, b); //テキストを描く. b = bounds; b.Y += textmargineY; bounds.X += U.DrawText(text, g, normalFont, brush, isWithDraw, b); bitmap.Dispose(); brush.Dispose(); bounds.Y += OWNER_DRAW_ICON_SIZE; return(new Size(bounds.X, bounds.Y)); }
private void B0_ValueChanged(object sender, EventArgs e) { uint id = (uint)this.B0.Value; if (AddressList.SelectedIndex <= 0) { X_LINK.Text = TypeIDToString(id); X_LINK_ICON.Image = null; return; } uint typeID = GetTypeID(); if (typeID <= 1) { X_LINK.Text = UnitForm.GetUnitName(id); X_LINK_ICON.Image = UnitForm.DrawUnitMapFacePicture(id); } else { X_LINK.Text = ClassForm.GetClassName(id); X_LINK_ICON.Image = ClassForm.DrawWaitIcon(id, 0); } }
//Uint + テキスト (PARSER) + Class テキストを書くルーチン public static Size DrawUnitAndClassAndText(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw) { if (index < 0 || index >= lb.Items.Count) { return(new Size(listbounds.X, listbounds.Y)); } string text = lb.Items[index].ToString(); SolidBrush brush = new SolidBrush(lb.ForeColor); Font normalFont = lb.Font; Rectangle bounds = listbounds; int textmargineY = (OWNER_DRAW_ICON_SIZE - (int)lb.Font.Height) / 2; //テキストの先頭にアイコン番号(キャラ番号が入っている. 無駄だが汎用性を考えるとほかに方法がない) uint icon = U.atoh(text); Bitmap bitmap = UnitForm.DrawUnitMapFacePicture(icon); U.MakeTransparent(bitmap); //アイコンを描く. 処理速度を稼ぐためにマップアイコンの方を描画 Rectangle b = bounds; b.Width = OWNER_DRAW_ICON_SIZE; b.Height = OWNER_DRAW_ICON_SIZE; bounds.X += U.DrawPicture(bitmap, g, isWithDraw, b); bitmap.Dispose(); string[] parsers = new string[] { " -> ", " <- ", " ?? ", " & " }; bool found = false; foreach (string parser in parsers) { int p = text.IndexOf(parser); if (p < 0) { continue; } p += parser.Length; //前半 string a1 = text.Substring(0, p); b = bounds; b.Y += textmargineY; bounds.X += U.DrawText(a1, g, normalFont, brush, isWithDraw, b); //後半 string a2 = text.Substring(p); //後半のアイコンを描く icon = U.atoh(a2); bitmap = ClassForm.DrawWaitIcon(icon, 0, true); U.MakeTransparent(bitmap); b = bounds; b.Width = OWNER_DRAW_ICON_SIZE; b.Height = OWNER_DRAW_ICON_SIZE; bounds.X += U.DrawPicture(bitmap, g, isWithDraw, b); bitmap.Dispose(); //後半の文字列 b = bounds; b.Y += textmargineY; bounds.X += U.DrawText(a2, g, normalFont, brush, isWithDraw, b); found = true; break; } if (found == false) { //見つからなかったので、普通にテキストを描く. bounds.X += U.DrawText(text, g, normalFont, brush, isWithDraw, bounds); } brush.Dispose(); bounds.Y += OWNER_DRAW_ICON_SIZE; return(new Size(bounds.X, bounds.Y)); }
public static Size DrawEventCategory(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw) { if (index < 0 || index >= lb.Items.Count) { return(new Size(listbounds.X, listbounds.Y)); } string text = lb.Items[index].ToString(); SolidBrush brush = new SolidBrush(lb.ForeColor); Font normalFont = lb.Font; Rectangle bounds = listbounds; int lineHeight = (int)lb.Font.Height; string[] sp = text.Split(new string[] { "[", "//" }, StringSplitOptions.None); bounds.X += U.DrawText(sp[0], g, normalFont, brush, isWithDraw, bounds); for (int i = 1; i < sp.Length - 1; i++) { bounds.X += U.DrawText("[", g, normalFont, brush, isWithDraw, bounds); string nn = sp[i]; int p = nn.IndexOf(':'); if (p < 0) { bounds.X += U.DrawText(nn, g, normalFont, brush, isWithDraw, bounds); continue; } string item = nn.Substring(0, p); Bitmap bitmap = null; if (item == "UNIT") { bitmap = UnitForm.DrawUnitMapFacePicture(1); } else if (item == "CLASS") { bitmap = ClassForm.DrawWaitIcon(3); } else if (item == "POINTER_PROCS") { bitmap = ImageSystemIconForm.WeaponIcon(4); } else if (item == "POINTER_ASM") { bitmap = ImageSystemIconForm.WeaponIcon(8); } else if (item == "POINTER_UNIT") { bitmap = ClassForm.DrawWaitIcon(7); } else if (item == "POINTER_EVENT") {//サブルーチンは目立つ緑のアイコン bitmap = ImageSystemIconForm.MusicIcon(3); } else if (item == "MUSIC") { bitmap = ImageSystemIconForm.MusicIcon(6); } else if (item == "SOUND") { bitmap = ImageSystemIconForm.MusicIcon(7); } else if (item == "ITEM") {//アイテムアイコン bitmap = ImageSystemIconForm.WeaponIcon(8); } else if (item == "FLAG") { bitmap = ImageSystemIconForm.FlagIcon(); } else if (item == "WMLOCATION") {//拠点 bitmap = WorldMapImageForm.DrawWorldMapIcon(0xB); } else if (item == "WMPATH") {//道 bitmap = WorldMapImageForm.DrawWorldMapIcon(0xB); } if (bitmap != null) { U.MakeTransparent(bitmap); Rectangle b = bounds; b.Width = lineHeight; b.Height = lineHeight; bounds.X += U.DrawPicture(bitmap, g, isWithDraw, b); bitmap.Dispose(); bounds.X += U.DrawText(nn.Substring(p), g, normalFont, brush, isWithDraw, bounds); } else { bounds.X += U.DrawText(nn.Substring(p + 1), g, normalFont, brush, isWithDraw, bounds); } } //コードをコメント形式で描画 if (sp.Length > 0) { int i = sp.Length - 1; SolidBrush commentBrush = new SolidBrush(OptionForm.Color_Comment_ForeColor()); if (bounds.X < 700) { bounds.X = 700; } bounds.X += U.DrawText("//" + sp[i], g, normalFont, commentBrush, isWithDraw, bounds); commentBrush.Dispose(); } brush.Dispose(); bounds.Y += lineHeight; return(new Size(bounds.X, bounds.Y)); }
Size DrawUnitAllowToAllow(string text, ListBox lb, Graphics g, Rectangle listbounds, bool isWithDraw) { SolidBrush brush = new SolidBrush(lb.ForeColor); Font normalFont = lb.Font; Rectangle bounds = listbounds; int lineHeight = (int)lb.Font.Height; //テキストの先頭にアイコン番号(キャラ番号が入っている. 無駄だが汎用性を考えるとほかに方法がない) uint icon = U.atoh(text); Bitmap bitmap = UnitForm.DrawUnitMapFacePicture(icon); U.MakeTransparent(bitmap); //アイコンを描く. 処理速度を稼ぐためにマップアイコンの方を描画 Rectangle b = bounds; b.Width = lineHeight; b.Height = lineHeight; bounds.X += U.DrawPicture(bitmap, g, isWithDraw, b); bitmap.Dispose(); string[] parsers = new string[] { " -> ", " <- ", " ?? ", " & " }; bool found = false; foreach (string parser in parsers) { int p = text.IndexOf(parser); if (p < 0) { continue; } p += parser.Length; //前半 string a1 = text.Substring(0, p); b = bounds; bounds.X += U.DrawText(a1, g, normalFont, brush, isWithDraw, b); //後半 string a2 = text.Substring(p); //後半のアイコンを描く icon = U.atoh(a2); bitmap = UnitForm.DrawUnitMapFacePicture(icon); U.MakeTransparent(bitmap); b = bounds; b.Width = lineHeight; b.Height = lineHeight; bounds.X += U.DrawPicture(bitmap, g, isWithDraw, b); bitmap.Dispose(); //後半の文字列 b = bounds; bounds.X += U.DrawText(a2, g, normalFont, brush, isWithDraw, b); found = true; break; } if (found == false) { //見つからなかったので、普通にテキストを描く. bounds.X += U.DrawText(text, g, normalFont, brush, isWithDraw, bounds); } brush.Dispose(); bounds.Y += lineHeight; return(new Size(bounds.X, bounds.Y)); }