Example #1
0
        public void EnterScene(scene.SceneType sceneType, object arg = null)//map.Map map = null)
        {
            _prevSceneType = _currentScene.SceneType;
            scene.Scene s = null;

            if (sceneType == SceneType.GameStage)
            {
                map.Map map = null;
                if (arg != null)
                {
                    map = arg as map.Map;
                }
                if (_prevMap != null && _prevMap != map)
                {
                    _prevMap.Dispose();
                }
                _prevMap = map;
                s        = CreateScene(sceneType, this, map);
            }
            else if (sceneType == SceneType.Error)
            {
                s = CreateScene(sceneType, this, (string[])arg);
            }
            else
            {
                s = CreateScene(sceneType, this, null);
            }
            if (s != null)
            {
                _currentScene = s;
            }
        }
Example #2
0
        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);
        }
Example #3
0
 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;
     }
 }
Example #4
0
        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;
            }
        }
Example #5
0
        public void EnterScene(scene.SceneType sceneType, object arg = null)//map.Map map = null)
        {
            _prevSceneType = _currentScene.SceneType;
            scene.Scene s = null;

            if (sceneType == SceneType.GameStage)
            {
                map.Map map = null;
                if (arg != null) map = arg as map.Map;
                if (_prevMap != null && _prevMap != map) _prevMap.Dispose();
                _prevMap = map;
                s = CreateScene(sceneType, this, map);
            }
            else if (sceneType == SceneType.Error)
            {
                s = CreateScene(sceneType, this, (string[])arg);
            }
            else
            {
                s = CreateScene(sceneType, this, null);
            }
            if (s != null) _currentScene = s;
        }
Example #6
0
        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);
            }
        }
Example #7
0
 public MapLoadedEventArgs(Map map)
 {
     Map = map;
 }