public static ColorChipData LoadChipData(MapInfo info) { ColorChipData c = new ColorChipData(); c._chipWidth = info.ChipDataInfo.Size.Width; c._chipHeight = info.ChipDataInfo.Size.Height; if (info.ChipDataInfo == null || info.ChipDataInfo.ChipInfos.Count == 0) { c._colors = new Color[] { Color.White, Color.Black }; c._hardness = new int[] { 0, 1 }; } else { c._colors = new Color[info.ChipDataInfo.ChipInfos.Count]; c._hardness = new int[info.ChipDataInfo.ChipInfos.Count]; List <Color> defaultColors = new List <Color>(); if (info.ChipDataInfo.ChipInfos.Exists((ci) => { return(!ci.Color.HasValue); })) { string mappingPath = System.IO.Path.Combine(info.DirectoryPath, info.Mapping); #region マッピングデータを読み込む if (!string.IsNullOrEmpty(info.Mapping) && System.IO.File.Exists(mappingPath)) { using (Bitmap mappingBmp = (Bitmap)Bitmap.FromFile(mappingPath)) { using (Surface ms = new Surface(mappingBmp)) { Color[,] tmp = ms.GetColors(new Rectangle(0, 0, ms.Width, ms.Height)); for (int i = 0; i < tmp.GetLength(0); i++) { for (int j = 0; j < tmp.GetLength(1); j++) { Color dc = tmp[i, j]; defaultColors.Add(dc); } } } } } #endregion } int idx = 0; foreach (ChipInfo ci in info.ChipDataInfo.ChipInfos) { c._colors[idx] = ci.Color.HasValue ? ci.Color.Value : (defaultColors.Count > idx ? defaultColors[idx] : Color.Blue); c._hardness[idx] = ci.Hardness; idx++; } } return(c); }
public static ColorChipData LoadChipData(MapInfo info) { ColorChipData c = new ColorChipData(); c._chipWidth = info.ChipDataInfo.Size.Width; c._chipHeight = info.ChipDataInfo.Size.Height; if (info.ChipDataInfo == null || info.ChipDataInfo.ChipInfos.Count == 0) { c._colors = new Color[] { Color.White, Color.Black }; c._hardness = new int[] { 0, 1 }; } else { c._colors = new Color[info.ChipDataInfo.ChipInfos.Count]; c._hardness = new int[info.ChipDataInfo.ChipInfos.Count]; List<Color> defaultColors = new List<Color>(); if (info.ChipDataInfo.ChipInfos.Exists((ci) => { return !ci.Color.HasValue; })) { string mappingPath = System.IO.Path.Combine(info.DirectoryPath, info.Mapping); #region マッピングデータを読み込む if (!string.IsNullOrEmpty(info.Mapping) && System.IO.File.Exists(mappingPath)) { using (Bitmap mappingBmp = (Bitmap)Bitmap.FromFile(mappingPath)) { using (Surface ms = new Surface(mappingBmp)) { Color[,] tmp = ms.GetColors(new Rectangle(0, 0, ms.Width, ms.Height)); for (int i = 0; i < tmp.GetLength(0); i++) { for (int j = 0; j < tmp.GetLength(1); j++) { Color dc = tmp[i, j]; defaultColors.Add(dc); } } } } } #endregion } int idx = 0; foreach (ChipInfo ci in info.ChipDataInfo.ChipInfos) { c._colors[idx] = ci.Color.HasValue ? ci.Color.Value : (defaultColors.Count > idx ? defaultColors[idx] : Color.Blue); c._hardness[idx] = ci.Hardness; idx++; } } return c; }
private Map loadUserMap(MapInfo info) { Map map = null; MapChipData chipData = null; try { switch (info.ChipDataInfo.ChipType) { case MapChipType.Builtin: { switch (info.ChipDataInfo.BuiltinType) { case MapChipBuiltinType.Binary: chipData = BinaryChipData.LoadChipData(info); map = new BinaryMap(); map.ChipData = chipData; break; case MapChipBuiltinType.Colors: chipData = ColorChipData.LoadChipData(info); map = new ColorsMap(); map.ChipData = chipData; break; } } break; case MapChipType.Image: { chipData = ImageMapChipData.LoadChipData(info); map = new Map(); map.ChipData = chipData; } break; } switch (info.MapSourceType) { case MapSourceType.Text: { string srcPath = Path.Combine(info.DirectoryPath, info.MapSourceFileName); string mapping = info.Mapping; string[] lines = File.ReadAllLines(srcPath, Encoding.UTF8); map.LoadMapText(lines, mapping); } break; case MapSourceType.Image: { string srcPath = Path.Combine(info.DirectoryPath, info.MapSourceFileName); string mappingPath = Path.Combine(info.DirectoryPath, info.Mapping); using (Bitmap srcBmp = (Bitmap)Bitmap.FromFile(srcPath)) { if (!string.IsNullOrEmpty(info.Mapping) && File.Exists(mappingPath)) { using (Bitmap mappingBmp = (Bitmap)Bitmap.FromFile(mappingPath)) { map.LoadMapImage(srcBmp, mappingBmp); } } else { map.LoadMapImage(srcBmp, null); } } } break; case MapSourceType.Music: { string srcPath = Path.Combine(info.DirectoryPath, info.MapSourceFileName); Music music = Music.LoadMusic(srcPath); info.MaxPitch = music.MaxPitch; info.MinPitch = music.MinPitch; using (Bitmap srcBmp = music.GetMap(SdlDotNet.Core.Events.TargetFps, info.PlayerVx, info.ChipDataInfo.Size.Width, info.ChipDataInfo.Size.Height, !(info.ChipDataInfo.ChipType == MapChipType.Builtin && info.ChipDataInfo.BuiltinType == MapChipBuiltinType.Binary))) { if (srcBmp != null) { string dirPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); dirPath = Path.Combine(dirPath, Properties.Resources.Dirname_Config); string fpath = Path.Combine(dirPath, Properties.Resources.Filename_MusicLogImage); srcBmp.Save(fpath); fpath = Path.Combine(dirPath, Properties.Resources.Filename_MusicLogText); using (StreamWriter writer = new StreamWriter(fpath, false, Encoding.UTF8)) { writer.WriteLine("max pitch: {0}", info.MaxPitch); writer.WriteLine("min pitch: {0}", info.MinPitch); } using (Bitmap mappingBmp = Music.GetMappingBmp()) { map.LoadMapImage(srcBmp, mappingBmp); } } } } break; } if (info.BgmInfo != null && !string.IsNullOrEmpty(info.BgmInfo.Name)) { string bgmPath = Path.Combine(info.DirectoryPath, info.BgmInfo.Name); map.Bgm = new SdlDotNet.Audio.Music(bgmPath); map.BgmVolume = info.BgmInfo.Volume; } map.MapInfo = info; return(map); } catch (Exception ex) { throw new MapLoadException(string.Format("{0}: {1}", Properties.Resources.Str_MapLoadError, info.Id), ex); } }
public ColorsMap() { _chipData = new ColorChipData(); }
public ColorsMap() { _chipData = new ColorChipData(); }