static public MapData fromFile(String filename, List <Billboard> billboards) { MapData rtn = new MapData(); StreamReader sr = new StreamReader(filename, System.Text.Encoding.GetEncoding("shift_jis")); billboards.Clear(); while (!sr.EndOfStream) { String line = sr.ReadLine(); String[] tokens = line.Split(' '); String verb = tokens[0]; if (verb.Equals("name")) { rtn.name = tokens[1]; } else if (verb.Equals("width")) { rtn.width = int.Parse(tokens[1]); } else if (verb.Equals("height")) { rtn.height = int.Parse(tokens[1]); } else if (verb.Equals("mapchip")) { Mapchip c = new Mapchip(); if (tokens.Length <= 6) { continue; } c.p = new Point(int.Parse(tokens[1]), int.Parse(tokens[2])); c.refx = int.Parse(tokens[3]); c.refy = int.Parse(tokens[4]); c.width = int.Parse(tokens[5]); c.height = int.Parse(tokens[6]); if (c.refx >= 0) { rtn.chips.Add(c.p, c); } if (tokens.Length >= 8) { c.etc = tokens[7]; } } else if (verb.Equals("object")) { Mapchip c = new Mapchip(); if (tokens.Length <= 6) { continue; } c.p = new Point(int.Parse(tokens[1]), int.Parse(tokens[2])); c.refx = int.Parse(tokens[3]); c.refy = int.Parse(tokens[4]); c.width = int.Parse(tokens[5]); c.height = int.Parse(tokens[6]); if (tokens.Length == 8) { c.etc = tokens[7]; } if (c.refx >= 0) { rtn.objects.Add(c.p, c); } } else if (verb.Equals("billboard")) { Billboard c = new Billboard(); if (tokens.Length <= 7) { continue; } c.x = int.Parse(tokens[1]); c.y = int.Parse(tokens[2]); c.refx = int.Parse(tokens[3]); c.refy = int.Parse(tokens[4]); c.w = int.Parse(tokens[5]); c.h = int.Parse(tokens[6]); c.translate_rate_x = double.Parse(tokens[7]); c.translate_rate_y = double.Parse(tokens[8]); c.file_name = (tokens[9]); c.file_name = Path.GetFileName(c.file_name); for (int i = 10; i < tokens.Length; i++) { c.file_name += (" " + tokens[i]); } if (c.refx >= 0) { billboards.Add(c); } } else if (verb.Equals("background")) { rtn.background = tokens[1]; } else if (verb.Equals("bg_offset_x")) { rtn.bg_offset_x = int.Parse(tokens[1]); } else if (verb.Equals("bg_offset_y")) { rtn.bg_offset_y = int.Parse(tokens[1]); } else if (verb.Equals("bg_x_min")) { rtn.bg_x_min = int.Parse(tokens[1]); } else if (verb.Equals("bg_x_max")) { rtn.bg_x_max = int.Parse(tokens[1]); } else if (verb.Equals("bg_y_min")) { rtn.bg_y_min = int.Parse(tokens[1]); } else if (verb.Equals("bg_y_max")) { rtn.bg_y_max = int.Parse(tokens[1]); } else if (verb.Equals("bg_image_width")) { rtn.bg_image_width = int.Parse(tokens[1]); } else if (verb.Equals("bg_image_height")) { rtn.bg_image_height = int.Parse(tokens[1]); } else if (verb.Equals("bg_translate_rate")) { rtn.bg_translate_rate_x = rtn.bg_translate_rate_y = double.Parse(tokens[1]); } else if (verb.Equals("bg_translate_rate")) { rtn.bg_translate_rate_x = rtn.bg_translate_rate_y = double.Parse(tokens[1]); } else if (verb.Equals("bg_translate_rate_x")) { rtn.bg_translate_rate_x = double.Parse(tokens[1]); } else if (verb.Equals("bg_translate_rate_y")) { rtn.bg_translate_rate_y = double.Parse(tokens[1]); } else if (verb.Equals("bg_translate_rate_y")) { rtn.bg_translate_rate_y = double.Parse(tokens[1]); } else if (verb.Equals("bgm")) { rtn.bgm_name = tokens[1]; rtn.bgm_segno = double.Parse(tokens[2]); } } sr.Close(); return(rtn); }
public void Clip(MapData data, RectCursor cursor) { clipboard.setChips(data, cursor.OriginalIndex().Item1, cursor.OriginalIndex().Item2 , cursor.TerminalIndex().Item1 - cursor.OriginalIndex().Item1 + 1 , cursor.TerminalIndex().Item2 - cursor.OriginalIndex().Item2 + 1); }