2018-11-22 00:18:42 -05:00
|
|
|
|
using OpenDiablo2.Common.Attributes;
|
|
|
|
|
using OpenDiablo2.Common.Interfaces;
|
|
|
|
|
using OpenDiablo2.Common.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2018-11-22 02:24:55 -05:00
|
|
|
|
using System.Threading;
|
2018-11-22 00:18:42 -05:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace OpenDiablo2.Scenes
|
|
|
|
|
{
|
|
|
|
|
[Scene("Main Menu")]
|
|
|
|
|
public class MainMenu : IScene
|
|
|
|
|
{
|
|
|
|
|
static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
|
|
private readonly IRenderWindow renderWindow;
|
|
|
|
|
private readonly IPaletteProvider paletteProvider;
|
|
|
|
|
private readonly IMPQProvider mpqProvider;
|
2018-11-22 00:56:36 -05:00
|
|
|
|
private readonly IMouseInfoProvider mouseInfoProvider;
|
2018-11-22 02:24:55 -05:00
|
|
|
|
private readonly IMusicProvider musicProvider;
|
2018-11-22 00:18:42 -05:00
|
|
|
|
|
|
|
|
|
private float logoFrame;
|
2018-11-22 02:41:31 -05:00
|
|
|
|
private ISprite backgroundSprite, diabloLogoLeft, diabloLogoRight, diabloLogoLeftBlack, diabloLogoRightBlack, mouseSprite, wideButton;
|
2018-11-22 00:18:42 -05:00
|
|
|
|
|
|
|
|
|
public MainMenu(
|
|
|
|
|
IRenderWindow renderWindow,
|
|
|
|
|
IPaletteProvider paletteProvider,
|
2018-11-22 00:56:36 -05:00
|
|
|
|
IMPQProvider mpqProvider,
|
2018-11-22 02:24:55 -05:00
|
|
|
|
IMouseInfoProvider mouseInfoProvider,
|
|
|
|
|
IMusicProvider musicProvider
|
2018-11-22 00:18:42 -05:00
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
this.renderWindow = renderWindow;
|
|
|
|
|
this.paletteProvider = paletteProvider;
|
|
|
|
|
this.mpqProvider = mpqProvider;
|
2018-11-22 00:56:36 -05:00
|
|
|
|
this.mouseInfoProvider = mouseInfoProvider;
|
2018-11-22 00:18:42 -05:00
|
|
|
|
|
|
|
|
|
//var texture = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\Logo\\logo.DC6")));
|
2018-11-22 00:56:36 -05:00
|
|
|
|
backgroundSprite = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\FrontEnd\\gameselectscreenEXP.dc6")));
|
2018-11-22 00:18:42 -05:00
|
|
|
|
backgroundSprite.CurrentPalette = paletteProvider.PaletteTable["Sky"];
|
|
|
|
|
|
|
|
|
|
diabloLogoLeft = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\FrontEnd\\D2logoFireLeft.DC6")));
|
|
|
|
|
diabloLogoLeft.CurrentPalette = paletteProvider.PaletteTable["Units"];
|
2018-11-22 00:56:36 -05:00
|
|
|
|
|
2018-11-22 00:18:42 -05:00
|
|
|
|
diabloLogoRight = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\FrontEnd\\D2logoFireRight.DC6")));
|
|
|
|
|
diabloLogoRight.CurrentPalette = paletteProvider.PaletteTable["Units"];
|
2018-11-22 00:56:36 -05:00
|
|
|
|
|
2018-11-22 00:18:42 -05:00
|
|
|
|
diabloLogoLeftBlack = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\FrontEnd\\D2logoBlackLeft.DC6")));
|
|
|
|
|
diabloLogoLeftBlack.CurrentPalette = paletteProvider.PaletteTable["Units"];
|
2018-11-22 00:56:36 -05:00
|
|
|
|
|
2018-11-22 00:18:42 -05:00
|
|
|
|
diabloLogoRightBlack = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\FrontEnd\\D2logoBlackRight.DC6")));
|
|
|
|
|
diabloLogoRightBlack.CurrentPalette = paletteProvider.PaletteTable["Units"];
|
|
|
|
|
|
2018-11-22 00:56:36 -05:00
|
|
|
|
mouseSprite = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\CURSOR\\ohand.DC6")));
|
|
|
|
|
mouseSprite.CurrentPalette = paletteProvider.PaletteTable["STATIC"];
|
|
|
|
|
|
2018-11-22 02:41:31 -05:00
|
|
|
|
wideButton = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\FrontEnd\\WideButtonBlank.dc6")));
|
|
|
|
|
wideButton.CurrentPalette = paletteProvider.PaletteTable["ACT1"];
|
|
|
|
|
|
2018-11-22 00:18:42 -05:00
|
|
|
|
logoFrame = 0f;
|
|
|
|
|
|
|
|
|
|
diabloLogoLeft.Location = new Point(400, 120);
|
|
|
|
|
diabloLogoRight.Location = new Point(400, 120);
|
|
|
|
|
diabloLogoLeftBlack.Location = new Point(400, 120);
|
|
|
|
|
diabloLogoRightBlack.Location = new Point(400, 120);
|
|
|
|
|
|
2018-11-22 02:24:55 -05:00
|
|
|
|
|
|
|
|
|
var loadingSprite = renderWindow.LoadSprite(ImageSet.LoadFromStream(mpqProvider.GetStream("data\\global\\ui\\Loading\\loadingscreen.dc6")));
|
|
|
|
|
loadingSprite.CurrentPalette = paletteProvider.PaletteTable["loading"];
|
|
|
|
|
loadingSprite.Location = new Point(300, 400);
|
|
|
|
|
renderWindow.Clear();
|
|
|
|
|
renderWindow.Draw(loadingSprite);
|
|
|
|
|
renderWindow.Sync();
|
|
|
|
|
|
|
|
|
|
musicProvider.LoadSong(mpqProvider.GetStream("data\\global\\music\\introedit.wav"));
|
|
|
|
|
|
|
|
|
|
// TODO: Fake loading for now, this should be in its own scene as we start loading real stuff
|
|
|
|
|
var r = new Random();
|
|
|
|
|
for(int i = 1; i < 10; i++)
|
|
|
|
|
{
|
|
|
|
|
renderWindow.Clear();
|
|
|
|
|
loadingSprite.Frame = i;
|
|
|
|
|
renderWindow.Draw(loadingSprite);
|
|
|
|
|
renderWindow.Sync();
|
|
|
|
|
Thread.Sleep(r.Next(150));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
musicProvider.PlaySong();
|
2018-11-22 00:18:42 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Render()
|
|
|
|
|
{
|
|
|
|
|
renderWindow.Clear();
|
|
|
|
|
|
|
|
|
|
for (int y = 0; y < 3; y++)
|
|
|
|
|
for (int x = 0; x < 4; x++)
|
|
|
|
|
{
|
|
|
|
|
backgroundSprite.Frame = x + (y * 4);
|
|
|
|
|
backgroundSprite.Location = new Point(x * backgroundSprite.FrameSize.Width, (y + 1) * backgroundSprite.FrameSize.Height);
|
|
|
|
|
renderWindow.Draw(backgroundSprite);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diabloLogoLeftBlack.Frame = (int)((float)diabloLogoLeftBlack.TotalFrames * logoFrame);
|
|
|
|
|
renderWindow.Draw(diabloLogoLeftBlack);
|
|
|
|
|
diabloLogoRightBlack.Frame = (int)((float)diabloLogoRightBlack.TotalFrames * logoFrame);
|
|
|
|
|
renderWindow.Draw(diabloLogoRightBlack);
|
|
|
|
|
|
|
|
|
|
diabloLogoLeft.Frame = (int)((float)diabloLogoLeft.TotalFrames * logoFrame);
|
|
|
|
|
renderWindow.Draw(diabloLogoLeft);
|
|
|
|
|
diabloLogoRight.Frame = (int)((float)diabloLogoRight.TotalFrames * logoFrame);
|
|
|
|
|
renderWindow.Draw(diabloLogoRight);
|
|
|
|
|
|
2018-11-22 02:41:31 -05:00
|
|
|
|
|
|
|
|
|
wideButton.Location = new Point(260, 320);
|
|
|
|
|
wideButton.Frame = 0;
|
|
|
|
|
renderWindow.Draw(wideButton);
|
|
|
|
|
wideButton.Frame = 1;
|
|
|
|
|
wideButton.Location = new Point(260 + 256, 320);
|
|
|
|
|
renderWindow.Draw(wideButton);
|
|
|
|
|
|
2018-11-22 00:56:36 -05:00
|
|
|
|
mouseSprite.Location = new Point(mouseInfoProvider.MouseX, mouseInfoProvider.MouseY + mouseSprite.FrameSize.Height - 1);
|
|
|
|
|
renderWindow.Draw(mouseSprite);
|
|
|
|
|
|
2018-11-22 00:18:42 -05:00
|
|
|
|
renderWindow.Sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(long ms)
|
|
|
|
|
{
|
|
|
|
|
float seconds = ((float)ms / 1000f);
|
|
|
|
|
logoFrame += seconds;
|
|
|
|
|
while (logoFrame >= 1f)
|
|
|
|
|
logoFrame -= 1f;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|