示例#1
0
        public MainMenu(
            IRenderWindow renderWindow,
            ISceneManager sceneManager,
            ITextDictionary textDictionary,
            IResourceManager resourceManager,
            ISoundProvider soundProvider,
            IMPQProvider mpqProvider,
            Func <eButtonType, IButton> createButton
            )
        {
            this.renderWindow = renderWindow;
            this.sceneManager = sceneManager;

            backgroundSprite      = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky);
            diabloLogoLeft        = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120));
            diabloLogoLeft.Blend  = true;
            diabloLogoRight       = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireRight, Palettes.Units, new Point(400, 120));
            diabloLogoRight.Blend = true;
            diabloLogoLeftBlack   = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units, new Point(400, 120));
            diabloLogoRightBlack  = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units, new Point(400, 120));

            btnSinglePlayer            = createButton(eButtonType.Wide);
            btnSinglePlayer.Text       = textDictionary.Translate("strStartMenu1");
            btnSinglePlayer.Location   = new Point(264, 290);
            btnSinglePlayer.OnActivate = OnSinglePlayerClicked;

            btnWebsite            = createButton(eButtonType.Wide);
            btnWebsite.Text       = "Visit Github".ToUpper();
            btnWebsite.Location   = new Point(264, 330);
            btnWebsite.OnActivate = OnVisitWebsiteClicked;

            btnExit            = createButton(eButtonType.Wide);
            btnExit.Text       = textDictionary.Translate("strexitentiregame");
            btnExit.Location   = new Point(264, 500);
            btnExit.OnActivate = OnExitClicked;

            btnCredits            = createButton(eButtonType.Short);
            btnCredits.Text       = textDictionary.Translate("strGameCredits"); /* TODO: We apparently need a 'half font' option... */
            btnCredits.Location   = new Point(264, 470);
            btnCredits.OnActivate = OnCreditsClicked;

            labelFont          = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Static);
            versionLabel       = renderWindow.CreateLabel(labelFont, new Point(50, 555), "v0.02 Pre-Alpha");
            urlLabel           = renderWindow.CreateLabel(labelFont, new Point(50, 569), "https://github.com/essial/OpenDiablo2/");
            urlLabel.TextColor = Color.Magenta;

            soundProvider.LoadSong(mpqProvider.GetStream(ResourcePaths.BGMTitle));
            soundProvider.PlaySong();
        }
示例#2
0
        public MainMenu(
            IRenderWindow renderWindow,
            ISceneManager sceneManager,
            IResourceManager resourceManager,
            ISoundProvider soundProvider,
            IMPQProvider mpqProvider,
            Func <eButtonType, IButton> createButton,
            Func <eSceneType, IScene> getScene // Temporary until SDL load functions are sped up
            )
        {
            this.renderWindow = renderWindow;
            this.sceneManager = sceneManager;

            backgroundSprite      = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky);
            diabloLogoLeft        = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120));
            diabloLogoLeft.Blend  = true;
            diabloLogoRight       = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireRight, Palettes.Units, new Point(400, 120));
            diabloLogoRight.Blend = true;
            diabloLogoLeftBlack   = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units, new Point(400, 120));
            diabloLogoRightBlack  = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units, new Point(400, 120));

            btnSinglePlayer            = createButton(eButtonType.Wide);
            btnSinglePlayer.Text       = "Single Player".ToUpper();
            btnSinglePlayer.Location   = new Point(264, 290);
            btnSinglePlayer.OnActivate = OnSinglePlayerClicked;

            btnWebsite            = createButton(eButtonType.Wide);
            btnWebsite.Text       = "Visit Github".ToUpper();
            btnWebsite.Location   = new Point(264, 460);
            btnWebsite.OnActivate = OnVisitWebsiteClicked;

            btnExit            = createButton(eButtonType.Wide);
            btnExit.Text       = "Exit Diablo II".ToUpper();
            btnExit.Location   = new Point(264, 500);
            btnExit.OnActivate = OnExitClicked;

            labelFont          = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Static);
            versionLabel       = renderWindow.CreateLabel(labelFont, new Point(50, 555), "v0.01 Pre-Alpha");
            urlLabel           = renderWindow.CreateLabel(labelFont, new Point(50, 569), "https://github.com/essial/OpenDiablo2/");
            urlLabel.TextColor = Color.Magenta;

            soundProvider.LoadSong(mpqProvider.GetStream(ResourcePaths.BGMTitle));
            soundProvider.PlaySong();
        }
示例#3
0
        public IMapInfo InsertMap(int levelId, Point origin, IMapInfo parentMap = null)
        {
            var levelDetails = engineDataManager.Levels.First(x => x.Id == levelId);

            if (levelDetails.LevelPreset == null)
            {
                // There is no preset level, so we must generate one
                var generator = getRandomizedMapGenerator(levelDetails.LevelName);

                if (generator == null)
                {
                    throw new OpenDiablo2Exception($"Could not locate a map generator for '{levelDetails.LevelName}'.");
                }

                generator.Generate(parentMap, origin);

                // There is no core map so we cannot return a value here. If anyone actually uses
                // this value on a generated map they are making a terrible mistake anyway...
                return(null);
            }

            // Some maps have variations, so lets pick a random one
            var mapNames = new List <string>();

            if (levelDetails.LevelPreset.File1 != "0")
            {
                mapNames.Add(levelDetails.LevelPreset.File1);
            }
            if (levelDetails.LevelPreset.File2 != "0")
            {
                mapNames.Add(levelDetails.LevelPreset.File2);
            }
            if (levelDetails.LevelPreset.File3 != "0")
            {
                mapNames.Add(levelDetails.LevelPreset.File3);
            }
            if (levelDetails.LevelPreset.File4 != "0")
            {
                mapNames.Add(levelDetails.LevelPreset.File4);
            }
            if (levelDetails.LevelPreset.File5 != "0")
            {
                mapNames.Add(levelDetails.LevelPreset.File5);
            }
            if (levelDetails.LevelPreset.File6 != "0")
            {
                mapNames.Add(levelDetails.LevelPreset.File6);
            }


            var random = new Random(Seed);
            // -------------------------------------------------------------------------------------
            // var mapName = "data\\global\\tiles\\" + mapNames[random.Next(mapNames.Count)].Replace("/", "\\");
            // -------------------------------------------------------------------------------------
            // TODO: ***TEMP FOR TESTING
            var mapName = "data\\global\\tiles\\" + mapNames[0].Replace("/", "\\");

            // -------------------------------------------------------------------------------------
            MapName = levelDetails.LevelPreset.Name;
            Act     = levelDetails.LevelType.Act;

            var fileData = resourceManager.GetMPQDS1(mapName, levelDetails.LevelPreset, levelDetails.LevelType);

            var result = new MapInfo
            {
                LevelId      = levelId,
                FileData     = fileData,
                CellInfo     = new Dictionary <eRenderCellType, MapCellInfo[]>(),
                TileLocation = new Rectangle(origin, new Size(fileData.Width - 1, fileData.Height - 1))
            };

            mapInfo.Add(result);

            // Only change music if loading a 'core' map
            if (Enum.IsDefined(typeof(eLevelId), levelId))
            {
                soundProvider.StopSong();
                soundProvider.LoadSong(mpqProvider.GetStream(ResourcePaths.GetMusicPathForLevel((eLevelId)levelId)));
                soundProvider.PlaySong();
            }


            return(result);
        }