コード例 #1
0
ファイル: ImageMapChipData.cs プロジェクト: davinx/PitchPitch
        public static ImageMapChipData LoadChipData(MapInfo info)
        {
            ImageMapChipData c = new ImageMapChipData();
            string path = System.IO.Path.Combine(info.DirectoryPath, info.ChipDataInfo.FileName);
            c._chipSurfaces = ResourceManager.LoadSurfacesFromFile(path, info.ChipDataInfo.Size);
            c._avgColors = new Dictionary<uint, Color>();

            c._hardness = new int[c._chipSurfaces.Count];
            uint chip = 0;
            foreach (Surface s in c._chipSurfaces)
            {
                c._avgColors.Add(chip, ImageUtil.GetAvgColor(s));

                if (info.ChipDataInfo == null || chip > info.ChipDataInfo.ChipInfos.Count - 1)
                {
                    c._hardness[chip] = chip == 0 ? 0 : 1;
                }
                else
                {
                    c._hardness[chip] = info.ChipDataInfo.ChipInfos[(int)chip].Hardness;
                }

                chip++;
            }

            c._chipWidth = info.ChipDataInfo.Size.Width;
            c._chipHeight = info.ChipDataInfo.Size.Height;
            c._backChip = 0; c._wallChip = 1;
            return c;
        }
コード例 #2
0
ファイル: BinaryChipData.cs プロジェクト: davinx/PitchPitch
 public static BinaryChipData LoadChipData(MapInfo info)
 {
     BinaryChipData c = new BinaryChipData();
     c._chipWidth = info.ChipDataInfo.Size.Width;
     c._chipHeight = info.ChipDataInfo.Size.Height;
     return c;
 }
コード例 #3
0
ファイル: ColorChipData.cs プロジェクト: davinx/PitchPitch
        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;
        }
コード例 #4
0
ファイル: SceneMapSelect.cs プロジェクト: davinx/PitchPitch
        public SceneMapSelect()
        {
            sceneType = scene.SceneType.MapSelect;

            _loader = new MapLoader();
            _loader.OnMapLoaded += (s, e) =>
            {
                _loadedMap = e.Map;
                _loadEnd = true;
                _loading = false;
            };
            _loader.OnMapLoadCanceled += (s, e) =>
            {
                _loadedException = e.Exception;
                _loadedMap = null;
                _loadingMapInfo = null;
                _loadEnd = true;
                _loading = false;
            };

            _mapInfos = new List<MapInfo>();

            _keys = new Key[]
            {
                Key.UpArrow, Key.DownArrow, Key.LeftArrow, Key.RightArrow, Key.Return, Key.Escape,
                Key.One, Key.Two, Key.R
            };
            _builtinMapInfos = new MapInfo[]
            {
                EmptyMap.GetMapInfo(),
                EmptyFixedMap.GetMapInfo(),
                RandomMap.GetMapInfo(3),
                RandomMap.GetMapInfo(5),
                RandomEndlessMap.GetMapInfo(3)
            };

            _randItems = new string[_builtinMapInfos.Length + 1];
            for (int i = 0; i < _builtinMapInfos.Length; i++)
            {
                _randItems[i] = _builtinMapInfos[i].MapName;
            }
            _randItems[_randItems.Length - 1] = Properties.Resources.MenuItem_ReloadMap;


            _cursor = ResourceManager.GetColoredCursorGraphic(Constants.Color_Foreground);
            _strongCursor = ResourceManager.GetColoredCursorGraphic(Constants.Color_Strong);

            #region レイアウト初期化
            Size escSize = ResourceManager.MiddlePFont.SizeText(_escItems[0].ToString());
            _escRect = new Rectangle(
                Constants.ScreenWidth - Constants.RightBottomItemMargin - escSize.Width - Constants.CursorMargin,
                Constants.ScreenHeight - Constants.RightBottomItemMargin - escSize.Height,
                escSize.Width + Constants.CursorMargin, escSize.Height);

            _expRect = new Rectangle(
                Constants.HeaderX + Constants.UnderHeaderMargin,
                Constants.HeaderY + ResourceManager.LargePFont.Height + Constants.HeaderBottomMargin,
                Constants.ScreenWidth - Constants.UnderHeaderMargin * 2,
                ResourceManager.SmallPFont.Height);

            int top = _expRect.Bottom + Constants.SubHeaderBottomMargin;
            int bottom = _escRect.Top - Constants.UnderHeaderMargin;
            _mapRect = new Rectangle(
                Constants.HeaderX + Constants.UnderHeaderMargin + Constants.CursorMargin,
                top,
                (int)((Constants.ScreenWidth - (Constants.HeaderX + Constants.UnderHeaderMargin * 2) - Constants.MenuColumnGap) / 2.0) - Constants.CursorMargin,
                bottom - top);
            _randRect = new Rectangle(
                _mapRect.Right + Constants.MenuColumnGap + Constants.CursorMargin,
                _mapRect.Top, _mapRect.Width, _mapRect.Height);
            #endregion

            _randSurfaces = new SurfaceCollection();
            _randRects = new Rectangle[_randItems.Length];
            ImageUtil.CreateStrMenu(_randItems, Constants.Color_Foreground,
                ref _randSurfaces, ref _randRects, _randRect.Width);
            _randRects[_randRects.Length - 1].Offset(0, ResourceManager.SmallPFont.Height);

            _escSurfaces = new SurfaceCollection();
            _escRects = new Rectangle[_escItems.Length];
            ImageUtil.CreateStrMenu(_escItems, Constants.Color_Strong, ResourceManager.MiddlePFont,
                ref _escSurfaces, ref _escRects, _escRect.Width, ResourceManager.MiddlePFont.Height);
        }
コード例 #5
0
ファイル: SceneMapSelect.cs プロジェクト: davinx/PitchPitch
 protected override void proc(KeyboardEventArgs e)
 {
     if (_loadEnd)
     {
         if (_loadingMapInfo == null)
         {
             _loadTransition = false;
             SetAlert(true, Properties.Resources.Str_MapLoadError);
         }
         else
         {
             if (_loadedMap != null)
             {
                 _parent.EnterScene(scene.SceneType.GameStage, _loadedMap);
             }
             else
             {
                 _loadTransition = false;
                 SetAlert(true, Properties.Resources.Str_MapLoadError);
             }
         }
         _loadingMapInfo = null;
         _loadedMap = null;
         _loadEnd = false;
     }
 }
コード例 #6
0
ファイル: SceneMapSelect.cs プロジェクト: davinx/PitchPitch
 private void procMenuDefault(int idx)
 {
     switch (idx)
     {
         case RET_TITLE_OK: // タイトルに戻る
             PlaySeOK();
             startTransition(() => { _parent.EnterScene(scene.SceneType.Title); });
             break;
         case RET_TITLE_CANCEL: // タイトルに戻る
             PlaySeCancel();
             startTransition(() => { _parent.EnterScene(scene.SceneType.Title); });
             break;
         case MENU_SELECT: // メニュー項目選択
             PlaySeOK();
             if (_mapFocus)
             {
                 // ユーザマップメニューの場合
                 _loadingMapInfo = _mapInfos[_mapSelectedIdx];
                 loadMap();
             }
             else
             {
                 // ビルトインマップメニューの場合
                 if (_randSelectedIdx == _randItems.Length - 1)
                 {
                     // マップ再読み込み
                     updateMapInfos();
                 }
                 else if (_randSelectedIdx >= 0 && _randSelectedIdx < _builtinMapInfos.Length)
                 {
                     _loadingMapInfo = _builtinMapInfos[_randSelectedIdx];
                     loadMap();
                 }
             }
             break;
     }
 }
コード例 #7
0
ファイル: SceneMapSelect.cs プロジェクト: davinx/PitchPitch
        public override void SetAlert(bool on, string message)
        {
            base.SetAlert(on, message);
            if (!on)
            {
                _cursor.Animate = true;

                _loading = false;
                _loadEnd = false;
                _loadingMapInfo = null;
                _loadedMap = null;
                _octaveSelecting = false;
                _octave = 0;
            }
            else
            {
                _cursor.Animate = false;
            }
        }
コード例 #8
0
ファイル: MapLoader.cs プロジェクト: davinx/PitchPitch
 public void LoadMap(MapInfo info)
 {
     loadMapTh(info);
 }
コード例 #9
0
ファイル: MapLoader.cs プロジェクト: davinx/PitchPitch
        public MapInfo LoadMapInfo(string dirPath)
        {
            MapInfo mi = new MapInfo();

            string mapXmlFile = Path.Combine(dirPath, "map.xml");
            if (!File.Exists(mapXmlFile)) return null;

            XmlDocument mapXml = new XmlDocument();
            try
            {
                mapXml.Load(mapXmlFile);
            }
            catch (Exception)
            {
                return null;
            }

            XmlNode rootNode = mapXml.FirstChild;
            if (rootNode == null || rootNode.Name.ToLower() != "map") return null;

            mi.DirectoryPath = dirPath;
            mi.Id = Path.GetFileName(dirPath);
            mi.PitchType = PitchType.Undefined;

            foreach (XmlNode node in rootNode)
            {
                switch (node.Name.ToLower())
                {
                    #region name
                    case "name":
                        {
                            mi.MapName = node.InnerText.Trim();
                        }
                        break;
                    #endregion
                    #region author
                    case "author":
                        {
                            mi.AuthorName = node.InnerText.Trim();
                        }
                        break;
                    #endregion
                    #region player
                    case "player":
                        {
                            foreach (XmlNode plNode in node)
                            {
                                switch (plNode.Name.ToLower())
                                {
                                    case "vx":
                                        int vx = 1;
                                        string vxt = plNode.InnerText.Trim();
                                        if (int.TryParse(vxt, out vx)) mi.PlayerVx = vx;
                                        break;
                                }
                            }
                        }
                        break;
                    #endregion
                    #region color
                    case "color":
                        {
                            foreach (XmlNode coNode in node)
                            {
                                switch (coNode.Name.ToLower())
                                {
                                    case "foreground":
                                        mi.ForegroundColor = ImageUtil.GetColor(coNode.InnerText.Trim());
                                        break;
                                    case "background":
                                        mi.BackgroundColor = ImageUtil.GetColor(coNode.InnerText.Trim());
                                        break;
                                    case "strong":
                                        mi.StrongColor = ImageUtil.GetColor(coNode.InnerText.Trim());
                                        break;
                                }
                            }
                        }
                        break;
                    #endregion
                    #region pitch
                    case "pitch":
                        {
                            #region PitchType
                            try
                            {
                                string pt = node.InnerText.Trim();
                                mi.PitchType = (PitchType)Enum.Parse(typeof(PitchType), pt, true);
                            }
                            catch (Exception) { mi.PitchType = PitchType.Undefined; }
                            #endregion

                            #region max/min
                            if (mi.PitchType == PitchType.Fixed)
                            {
                                double max = Config.Instance.MaxFreq;
                                double min = Config.Instance.MinFreq;
                                foreach (XmlAttribute attr in node.Attributes)
                                {
                                    switch (attr.Name.ToLower())
                                    {
                                        case "max":
                                            if (double.TryParse(attr.InnerText.Trim(), out max)) mi.MaxPitch = max;
                                            break;
                                        case "min":
                                            if (double.TryParse(attr.InnerText.Trim(), out min)) mi.MinPitch = min;
                                            break;
                                    }
                                }
                            }
                            #endregion
                        }
                        break;
                    #endregion
                    #region chipdata
                    case "chipdata":
                        {
                            ChipDataInfo cdi = new ChipDataInfo();
                            #region default
                            cdi.ChipType = MapChipType.Builtin;
                            cdi.FileName = "";
                            cdi.BuiltinType = MapChipBuiltinType.Binary;
                            #endregion

                            #region size
                            int width = 16; int height = 16;
                            foreach (XmlAttribute attr in node.Attributes)
                            {
                                switch (attr.Name.ToLower())
                                {
                                    case "width":
                                        if (!int.TryParse(attr.InnerText.Trim(), out width)) width = 16;
                                        break;
                                    case "height":
                                        if (!int.TryParse(attr.InnerText.Trim(), out height)) height = 16;
                                        break;
                                }
                            }
                            cdi.Size = new Size(width, height);
                            #endregion

                            string name = null;
                            foreach (XmlNode cdiNode in node)
                            {
                                switch (cdiNode.Name.ToLower())
                                {
                                    #region type
                                    case "type":
                                        {
                                            try
                                            {
                                                string ct = cdiNode.InnerText.Trim();
                                                cdi.ChipType = (MapChipType)Enum.Parse(typeof(MapChipType), ct, true);
                                            }
                                            catch (ArgumentException)
                                            {
                                                cdi.ChipType = MapChipType.None;
                                            }
                                        }
                                        break;
                                    #endregion
                                    #region name
                                    case "name":
                                        {
                                            name = cdiNode.InnerText.Trim();
                                        }
                                        break;
                                    #endregion
                                    #region chip
                                    case "chip":
                                        {
                                            if (cdi.ChipInfos == null) cdi.ChipInfos = new List<ChipInfo>();

                                            ChipInfo ci = new ChipInfo();
                                            ci.Color = null;
                                            ci.Hardness = cdi.ChipInfos.Count == 0 ? 0 : 1;

                                            foreach (XmlNode ciNode in cdiNode)
                                            {
                                                switch (ciNode.Name.ToLower())
                                                {
                                                    case "color":
                                                        {
                                                            string ciColorStr = ciNode.InnerText.Trim();
                                                            ci.Color = ImageUtil.GetColor(ciColorStr);
                                                        }
                                                        break;
                                                    case "hardness":
                                                        {
                                                            string ciHardStr = ciNode.InnerText.Trim();
                                                            if (!int.TryParse(ciHardStr, out ci.Hardness)) ci.Hardness = cdi.ChipInfos.Count == 0 ? 0 : 1;
                                                        }
                                                        break;
                                                }
                                            }
                                            cdi.ChipInfos.Add(ci);
                                        }
                                        break;
                                    #endregion
                                }
                            }

                            #region name解釈
                            if (cdi.ChipType == MapChipType.Builtin)
                            {
                                try
                                {
                                    if (string.IsNullOrEmpty(name)) cdi.BuiltinType = MapChipBuiltinType.Binary;
                                    else cdi.BuiltinType = (MapChipBuiltinType)Enum.Parse(typeof(MapChipBuiltinType), name, true);
                                }
                                catch (ArgumentException)
                                {
                                    cdi.BuiltinType = MapChipBuiltinType.Binary;
                                }
                            }
                            else
                            {
                                cdi.FileName = getFilePath(name);
                                cdi.BuiltinType = MapChipBuiltinType.None;
                            }
                            #endregion

                            mi.ChipDataInfo = cdi;
                        }
                        break;
                    #endregion
                    #region source
                    case "source":
                        foreach (XmlNode soNode in node)
                        {
                            switch (soNode.Name.ToLower())
                            {
                                #region type
                                case "type":
                                    try
                                    {
                                        string mt = soNode.InnerText.Trim();
                                        mi.MapSourceType = (MapSourceType)Enum.Parse(typeof(MapSourceType), mt, true);
                                    }
                                    catch (ArgumentException)
                                    {
                                        mi.MapSourceType = MapSourceType.None;
                                    }
                                    break;
                                #endregion
                                #region name
                                case "name":
                                    mi.MapSourceFileName = getFilePath(soNode.InnerText.Trim());
                                    break;
                                #endregion
                                #region mapping
                                case "mapping":
                                    mi.Mapping = soNode.InnerText.Trim();
                                    break;
                                #endregion
                            }
                        }
                        break;
                    #endregion
                    #region bgm
                    case "bgm":
                        {
                            BgmInfo bi = new BgmInfo();
                            bi.Name = getFilePath(node.InnerText.Trim());
                            foreach (XmlAttribute attr in node.Attributes)
                            {
                                switch (attr.Name.ToLower())
                                {
                                    #region volume
                                    case "volume":
                                        {
                                            int vol = 50;
                                            if (int.TryParse(attr.InnerText.Trim(), out vol))
                                            {
                                                vol = vol < 0 ? 0 : (vol > 100 ? 100 : vol);
                                            }
                                            bi.Volume = vol;
                                        }
                                        break;
                                    #endregion
                                }
                            }
                            mi.BgmInfo = bi;
                        }
                        break;
                    #endregion
                    default:
                        break;
                }
            }

            #region Pitchの記述が無い場合
            if (mi.PitchType == PitchType.Undefined)
            {
                if (mi.MapSourceType == MapSourceType.Music) mi.PitchType = PitchType.Fixed;
                else mi.PitchType = PitchType.Variable;
            }
            #endregion

            if (isValidMapInfo(mi)) return mi;
            return null;
        }
コード例 #10
0
ファイル: MapLoader.cs プロジェクト: davinx/PitchPitch
 private Map loadMap(MapInfo info)
 {
     if (info is BuiltinMapInfo) return loadBuiltinMap(info);
     else return loadUserMap(info);
 }
コード例 #11
0
ファイル: MapLoader.cs プロジェクト: davinx/PitchPitch
        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);
            }
        }
コード例 #12
0
ファイル: MapLoader.cs プロジェクト: davinx/PitchPitch
 private Map loadBuiltinMap(MapInfo info)
 {
     Map map = null;
     if (info is RandomMap.RandomMapInfo)
     {
         map = new RandomMap(info.Level);
     }
     else if (info is EmptyMap.EmptyMapInfo)
     {
         map = new EmptyMap();
     }
     else if (info is EmptyFixedMap.EmptyFixedMapInfo)
     {
         map = new EmptyFixedMap();
     }
     else if (info is RandomEndlessMap.RandomEndlessMapInfo)
     {
         map = new RandomEndlessMap(info.Level);
     }
     return map;
 }
コード例 #13
0
ファイル: MapLoader.cs プロジェクト: davinx/PitchPitch
 private void loadMapTh(MapInfo info)
 {
     BackgroundWorker worker = new BackgroundWorker();
     worker.WorkerSupportsCancellation = true;
     worker.WorkerReportsProgress = true;
     worker.DoWork += (s, e) =>
     {
         try
         {
             e.Result = loadMap(e.Argument as MapInfo);
         }
         catch (MapLoadException)
         {
             e.Cancel = true;
         }
     };
     worker.RunWorkerCompleted += (s, e) =>
     {
         if (e.Cancelled)
         {
             MapLoadCanceledEventHandler del = OnMapLoadCanceled;
             if (del != null)
             {
                 MapLoadCanceledEventArgs arg = new MapLoadCanceledEventArgs(null);
                 del(s, arg);
             }
         }
         else
         {
             MapLoadedEventHandler del = OnMapLoaded;
             if (del != null)
             {
                 MapLoadedEventArgs arg = new MapLoadedEventArgs(e.Result as Map);
                 del(s, arg);
             }
         }
     };
     worker.RunWorkerAsync(info);
 }
コード例 #14
0
ファイル: MapLoader.cs プロジェクト: davinx/PitchPitch
        private bool isValidMapInfo(MapInfo info)
        {
            if (info.MapSourceType == MapSourceType.None) return false;
            if (info.ChipDataInfo == null) return false;
            if (info.ChipDataInfo.ChipType == MapChipType.None) return false;
            if (info.PitchType == PitchType.Undefined) return false;

            ChipDataInfo ci = info.ChipDataInfo;
            if (ci.ChipType == MapChipType.Image)
            {
                if (ci.Size == Size.Empty) return false;
                if (string.IsNullOrEmpty(ci.FileName)) return false;
                if (!File.Exists(Path.Combine(info.DirectoryPath, ci.FileName))) return false;
            }
            else if (ci.ChipType == MapChipType.Builtin)
            {
                if (ci.BuiltinType == MapChipBuiltinType.None) return false;
            }

            if (string.IsNullOrEmpty(info.MapName)) return false;
            if (string.IsNullOrEmpty(info.MapSourceFileName)) return false;

            if (!File.Exists(Path.Combine(info.DirectoryPath, info.MapSourceFileName))) return false;

            return true;
        }