mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-25 11:36:26 -05:00
Moved mouse rendering outside of scene rendering logic
This commit is contained in:
parent
3d98be98fe
commit
ca79787832
@ -1,4 +1,5 @@
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -17,8 +18,10 @@ namespace OpenDiablo2.Core
|
||||
|
||||
private readonly IMPQProvider mpqProvider;
|
||||
private readonly Func<IRenderWindow> getRenderWindow;
|
||||
private readonly Func<IMouseInfoProvider> getMouseInfoProvider;
|
||||
private readonly Func<string, IScene> getScene;
|
||||
private IScene currentScene;
|
||||
private ISprite mouseSprite;
|
||||
|
||||
private readonly MPQ[] MPQs;
|
||||
|
||||
@ -27,10 +30,16 @@ namespace OpenDiablo2.Core
|
||||
private Stopwatch sw = new Stopwatch();
|
||||
|
||||
|
||||
public GameEngine(IMPQProvider mpqProvider, Func<IRenderWindow> getRenderWindow, Func<string, IScene> getScene)
|
||||
public GameEngine(
|
||||
IMPQProvider mpqProvider,
|
||||
Func<IRenderWindow> getRenderWindow,
|
||||
Func<IMouseInfoProvider> getMouseInfoProvider,
|
||||
Func<string, IScene> getScene
|
||||
)
|
||||
{
|
||||
this.mpqProvider = mpqProvider;
|
||||
this.getRenderWindow = getRenderWindow;
|
||||
this.getMouseInfoProvider = getMouseInfoProvider;
|
||||
this.getScene = getScene;
|
||||
|
||||
MPQs = mpqProvider.GetMPQs().ToArray();
|
||||
@ -63,9 +72,14 @@ namespace OpenDiablo2.Core
|
||||
|
||||
public void Run()
|
||||
{
|
||||
var renderWindow = getRenderWindow();
|
||||
var mouseInfoProvider = getMouseInfoProvider();
|
||||
|
||||
LoadPalettes();
|
||||
LoadSoundData();
|
||||
|
||||
mouseSprite = renderWindow.LoadSprite(ResourcePaths.CursorDefault, Palettes.Units);
|
||||
|
||||
currentScene = getScene("Main Menu");
|
||||
sw.Start();
|
||||
while (getRenderWindow().IsRunning)
|
||||
@ -84,8 +98,14 @@ namespace OpenDiablo2.Core
|
||||
sw.Restart();
|
||||
getRenderWindow().Update();
|
||||
currentScene.Update(ms);
|
||||
|
||||
|
||||
renderWindow.Clear();
|
||||
currentScene.Render();
|
||||
|
||||
// Draw the mouse
|
||||
renderWindow.Draw(mouseSprite, new Point(mouseInfoProvider.MouseX, mouseInfoProvider.MouseY + 3));
|
||||
|
||||
renderWindow.Sync();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace OpenDiablo2.Scenes
|
||||
private readonly IMusicProvider musicProvider;
|
||||
|
||||
private float logoFrame;
|
||||
private ISprite backgroundSprite, diabloLogoLeft, diabloLogoRight, diabloLogoLeftBlack, diabloLogoRightBlack, mouseSprite, wideButton;
|
||||
private ISprite backgroundSprite, diabloLogoLeft, diabloLogoRight, diabloLogoLeftBlack, diabloLogoRightBlack, wideButton;
|
||||
private IFont labelFont;
|
||||
private ILabel versionLabel, urlLabel;
|
||||
|
||||
@ -47,7 +47,6 @@ namespace OpenDiablo2.Scenes
|
||||
diabloLogoLeftBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units, new Point(400, 120));
|
||||
diabloLogoRightBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units, new Point(400, 120));
|
||||
|
||||
mouseSprite = renderWindow.LoadSprite(ResourcePaths.CursorDefault, Palettes.Units);
|
||||
wideButton = renderWindow.LoadSprite("data\\global\\ui\\FrontEnd\\WideButtonBlank.dc6", "ACT1");
|
||||
|
||||
labelFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Static);
|
||||
@ -80,8 +79,6 @@ namespace OpenDiablo2.Scenes
|
||||
|
||||
public void Render()
|
||||
{
|
||||
renderWindow.Clear();
|
||||
|
||||
// Render the background
|
||||
renderWindow.Draw(backgroundSprite, 4, 3, 0);
|
||||
|
||||
@ -98,11 +95,6 @@ namespace OpenDiablo2.Scenes
|
||||
// Render the UI buttons
|
||||
wideButton.Location = new Point(264, 290);
|
||||
renderWindow.Draw(wideButton, 2, 1, 0);
|
||||
|
||||
// Draw the mouse
|
||||
renderWindow.Draw(mouseSprite, new Point(mouseInfoProvider.MouseX, mouseInfoProvider.MouseY + 3));
|
||||
|
||||
renderWindow.Sync();
|
||||
}
|
||||
|
||||
public void Update(long ms)
|
||||
|
Loading…
Reference in New Issue
Block a user