public Form2(CardDB[] cardDB_temp, Card[] card_temp, int[] cardOrder_temp,int cardNum_temp) { cardDB = cardDB_temp; card = card_temp; cardOrder = cardOrder_temp; cardNum = cardNum_temp; InitializeComponent(); }
// カード画像がない場合の拡大画像の描画 static public void DrawImage_Noimage(Graphics g, CardDB cardDB, PictureBox pb) { g.DrawString(cardDB.name, new Font("MS UI Gothic", 12, FontStyle.Bold), Brushes.Black, 6, 272); g.DrawString("N " + cardDB.node + " C " + cardDB.cost, new Font("MS UI Gothic", 16, FontStyle.Bold), Brushes.Black, 185, 28); Rectangle area = new Rectangle(10, 5, pb.Width - 20, 16); StringFormat centering = new StringFormat(); centering.Alignment = StringAlignment.Center; centering.LineAlignment = StringAlignment.Center; g.DrawString(cardDB.type + " Card", new Font("Century", 11), Brushes.Black, area, centering); g.DrawString(string.Format("No.{0:D4}", cardDB.no), new Font("Century Gothic", 8, FontStyle.Bold), Brushes.Black, 120, 378); if (cardDB.type == "Character") { g.DrawString("GRAZE", new Font("MS UI Gothic", 12, FontStyle.Bold), Brushes.Black, 12, 28); g.DrawString(cardDB.graze, new Font("MS UI Gothic", 26, FontStyle.Bold), Brushes.Black, 24, 42); g.DrawString(cardDB.cclass, new Font("MS UI Gothic", 10), Brushes.Black, 210, 275); } }
//============================== ファイル入出力 ============================== //----------cardlist.ini読み込み---------- private void ReadCardlist() { string fname = @"card\\cardlist.ini"; if (!System.IO.File.Exists(fname)) { MessageBox.Show("cardlist.iniの読み込みに失敗しました。"); return; } string line; int now_no = 0; System.IO.StreamReader reader; try { reader = new System.IO.StreamReader(fname, Encoding.Default); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } while (!reader.EndOfStream) { line = reader.ReadLine(); if (line.Length == 0) continue; //空白行 if (line[0] == '#') continue; //コメントアウト if (line[0] == '[') //[]付きカードナンバー { int n; if (int.TryParse(line.Substring(1,line.Length - 2), out n)) { //[n]であった場合 if (n == 0) continue; now_no = n; //now_noをセット cardDB[n] = new CardDB(); cardDB[n].no = n; continue; } else { now_no = 0; //now_noを無効数字に continue; } } if (now_no == 0) continue; switch (line.Substring(0, line.IndexOf("="))) { case "Type": cardDB[now_no].type = line.Substring(line.IndexOf("=") + 1); break; case "Glaze": cardDB[now_no].graze = line.Substring(line.IndexOf("=") + 1); break; case "Node": cardDB[now_no].node = line.Substring(line.IndexOf("=") + 1); break; case "Cost": cardDB[now_no].cost = line.Substring(line.IndexOf("=") + 1); break; case "Range": cardDB[now_no].range = line.Substring(line.IndexOf("=") + 1); break; case "Time": cardDB[now_no].time = line.Substring(line.IndexOf("=") + 1); break; case "User": cardDB[now_no].user = line.Substring(line.IndexOf("=") + 1); break; case "Name": cardDB[now_no].name = line.Substring(line.IndexOf("=") + 1); break; case "Class": cardDB[now_no].cclass = line.Substring(line.IndexOf("=") + 1); break; case "Skill": cardDB[now_no].skill = line.Substring(line.IndexOf("=") + 1); break; case "Upkeep": cardDB[now_no].upkeep = line.Substring(line.IndexOf("=") + 1); break; case "Ability": cardDB[now_no].ability = line.Substring(line.IndexOf("=") + 1); cardDB[now_no].ability = cardDB[now_no].ability.Replace("\\n", Environment.NewLine + Environment.NewLine ); //改行文字を変換 break; case "Attack": cardDB[now_no].attack = line.Substring(line.IndexOf("=") + 1); if (cardDB[now_no].attack == "") cardDB[now_no].attack = "-"; break; case "Toughness": cardDB[now_no].toughness = line.Substring(line.IndexOf("=") + 1); if (cardDB[now_no].toughness == "") cardDB[now_no].toughness = "-"; break; case "Text": cardDB[now_no].text = line.Substring(line.IndexOf("=") + 1); break; case "Illustration": cardDB[now_no].illustration = line.Substring(line.IndexOf("=") + 1); break; case "File": cardDB[now_no].fname = line.Substring(line.IndexOf("=") + 1); break; } } reader.Close(); }
// カード画像がない場合の拡大画像の描画 public static void DrawImage_Noimage(Graphics g, CardDB cardDB, PictureBox pb) { g.DrawString(cardDB.name, new Font("MS UI Gothic", 12, FontStyle.Bold), Brushes.Black, 6, 272); g.DrawString("N " + cardDB.node + " C " + cardDB.cost, new Font("MS UI Gothic", 16, FontStyle.Bold), Brushes.Black, 185, 28); Rectangle area = new Rectangle(10, 5, pb.Width - 20, 16); StringFormat centering = new StringFormat(); centering.Alignment = StringAlignment.Center; centering.LineAlignment = StringAlignment.Center; g.DrawString(cardDB.type + " Card", new Font("Century", 11), Brushes.Black, area, centering); g.DrawString(string.Format("No.{0:D4}", cardDB.no), new Font("Century Gothic", 8, FontStyle.Bold), Brushes.Black, 120, 378); if (cardDB.type == "Character") { g.DrawString("GRAZE", new Font("MS UI Gothic", 12, FontStyle.Bold), Brushes.Black, 12, 28); g.DrawString(cardDB.graze, new Font("MS UI Gothic", 26, FontStyle.Bold), Brushes.Black, 24, 42); g.DrawString(cardDB.cclass, new Font("MS UI Gothic", 10), Brushes.Black, 210, 275); } }
// カード画像がない場合のカードの描画 public static Bitmap DrawCard(CardDB[] cardDB, Card card, int w, int h) { Bitmap img = new Bitmap(w, h); Graphics g = Graphics.FromImage(img); Rectangle area; // 枠の描画 g.FillRectangle(Brushes.White, 0, 0, w, h); Pen pen = new Pen(Brushes.Black, 3); if (cardDB[card.no].type == "Character") pen.Brush = Brushes.Aquamarine; if (cardDB[card.no].type == "Spell") pen.Brush = Brushes.OrangeRed; if (cardDB[card.no].type == "Command") pen.Brush = Brushes.Gray; g.DrawRectangle(pen, 1, 1, w - 3, h - 3); g.DrawRectangle(new Pen(Brushes.Black, 1), 0, 0, w - 1, h - 1); // カード名の描画 area = new Rectangle(3, h / 2, w - 6, h / 2 - 15); g.DrawString(cardDB[card.no].name, new Font("MS UI Gothic", 8), Brushes.Black, area); // 攻撃力・耐久力の描画 area = new Rectangle(4, h - 13, w - 8, 10); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Center; g.DrawString(cardDB[card.no].attack + " / " + cardDB[card.no].toughness, new Font("MS UI Gothic", 8), Brushes.Black, area, stringFormat); // ノード・コストの描画 area = new Rectangle(4, 5, w - 8, 15); g.DrawString("N " + cardDB[card.no].node + " C " + cardDB[card.no].cost, new Font("MS UI Gothic", 8), Brushes.Black, area, stringFormat); g.Dispose(); return img; }