Beispiel #1
0
        public MainMenu(
            IRenderWindow renderWindow,
            IPaletteProvider paletteProvider,
            IMPQProvider mpqProvider,
            IMouseInfoProvider mouseInfoProvider,
            IMusicProvider musicProvider,
            ISceneManager sceneManager,
            IResourceManager resourceManager,
            Func <eButtonType, IButton> createButton,
            Func <string, IScene> getScene // Temporary until SDL load functions are sped up
            )
        {
            this.renderWindow      = renderWindow;
            this.paletteProvider   = paletteProvider;
            this.mpqProvider       = mpqProvider;
            this.mouseInfoProvider = mouseInfoProvider;
            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;

            var loadingSprite = renderWindow.LoadSprite(ResourcePaths.LoadingScreen, Palettes.Loading, new Point(300, 400));


            // Pre-load all the scenes for now until we fix the sdl load problem
            var scenesToLoad = new string[] { "Select Hero Class" };

            for (int i = 0; i < scenesToLoad.Count(); i++)
            {
                renderWindow.Clear();
                renderWindow.Draw(loadingSprite, (int)((float)loadingSprite.TotalFrames * ((float)i / (float)scenesToLoad.Count())));
                renderWindow.Sync();
                getScene(scenesToLoad[i]);
            }



            /*
             * musicProvider.LoadSong(mpqProvider.GetStream("data\\global\\music\\introedit.wav"));
             *
             * musicProvider.PlaySong();
             */
        }