diff --git a/README.md b/README.md index e3f4e78..2b0e586 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,6 @@ The game is a complete port of the original game to Windows with some adjustment - some locations are larger to fill wide screens - Monastery got another gap in the wall to go through -Note: unfortunately the game music is still missing due to an unclear license situation. - ### Extended Game The extended game mode adds new items, locations and gameplay features. diff --git a/resources/Changelog.md b/resources/Changelog.md index 0a7cc6d..03a5d2b 100644 --- a/resources/Changelog.md +++ b/resources/Changelog.md @@ -1,5 +1,21 @@ # Burntime Changelog +## 0.6 - Music Support (2023-10-21) + +### Changes + +- Added music support +- Remastered graphics + - Player icons on maps + - Dropped items + - Statistics screen +- Toggle fullscreen with F11 as well + +### Fixes + +- Fixed flickering items in inventory with groups +- Fixed not localized text input + ## 0.5 - Remastered Characters (2023-10-15) ### 0.5.1 diff --git a/resources/README.md b/resources/README.md index cf9f20c..2d02d67 100644 --- a/resources/README.md +++ b/resources/README.md @@ -23,8 +23,6 @@ The game is a complete port of the original game to Windows with some adjustment - some locations are larger to fill wide screens - Monastery got another gap in the wall to go through -Note: unfortunately the game music is still missing due to an unclear license situation. - ### Extended Game The extended game mode adds new items, locations and gameplay features. diff --git a/resources/game/classic_newgfx/gfx/backgrounds/info.png b/resources/game/classic_newgfx/gfx/backgrounds/info.png new file mode 100644 index 0000000..cd40d8f Binary files /dev/null and b/resources/game/classic_newgfx/gfx/backgrounds/info.png differ diff --git a/resources/game/classic_newgfx/gfx/backgrounds/statistics.png b/resources/game/classic_newgfx/gfx/backgrounds/statistics.png new file mode 100644 index 0000000..36294c2 Binary files /dev/null and b/resources/game/classic_newgfx/gfx/backgrounds/statistics.png differ diff --git a/resources/game/classic_newgfx/gfx/backgrounds/statistics2.png b/resources/game/classic_newgfx/gfx/backgrounds/statistics2.png new file mode 100644 index 0000000..448dd9e Binary files /dev/null and b/resources/game/classic_newgfx/gfx/backgrounds/statistics2.png differ diff --git a/resources/game/classic_newgfx/gfx/backgrounds/stats-rightbottom.png b/resources/game/classic_newgfx/gfx/backgrounds/stats-rightbottom.png new file mode 100644 index 0000000..a366a26 Binary files /dev/null and b/resources/game/classic_newgfx/gfx/backgrounds/stats-rightbottom.png differ diff --git a/resources/game/classic_newgfx/gfx/backgrounds/stats_leftbottom.png b/resources/game/classic_newgfx/gfx/backgrounds/stats_leftbottom.png new file mode 100644 index 0000000..1c8df5a Binary files /dev/null and b/resources/game/classic_newgfx/gfx/backgrounds/stats_leftbottom.png differ diff --git a/resources/game/classic_newgfx/gfx/backgrounds/stats_lefttop.png b/resources/game/classic_newgfx/gfx/backgrounds/stats_lefttop.png new file mode 100644 index 0000000..94dbeff Binary files /dev/null and b/resources/game/classic_newgfx/gfx/backgrounds/stats_lefttop.png differ diff --git a/resources/game/classic_newgfx/gfx/backgrounds/stats_rightbottom.png b/resources/game/classic_newgfx/gfx/backgrounds/stats_rightbottom.png new file mode 100644 index 0000000..9d9f8c1 Binary files /dev/null and b/resources/game/classic_newgfx/gfx/backgrounds/stats_rightbottom.png differ diff --git a/resources/game/classic_newgfx/gfx/backgrounds/stats_righttop.png b/resources/game/classic_newgfx/gfx/backgrounds/stats_righttop.png new file mode 100644 index 0000000..f68805c Binary files /dev/null and b/resources/game/classic_newgfx/gfx/backgrounds/stats_righttop.png differ diff --git a/resources/game/classic_newgfx/gfx/down.png b/resources/game/classic_newgfx/gfx/down.png new file mode 100644 index 0000000..6095cf1 Binary files /dev/null and b/resources/game/classic_newgfx/gfx/down.png differ diff --git a/resources/game/classic_newgfx/gfx/objects/munt.png b/resources/game/classic_newgfx/gfx/objects/munt.png new file mode 100644 index 0000000..a13e378 Binary files /dev/null and b/resources/game/classic_newgfx/gfx/objects/munt.png differ diff --git a/resources/game/classic_newgfx/gfx/objects/player_icon_colors.png b/resources/game/classic_newgfx/gfx/objects/player_icon_colors.png new file mode 100644 index 0000000..4b4fcf2 Binary files /dev/null and b/resources/game/classic_newgfx/gfx/objects/player_icon_colors.png differ diff --git a/resources/game/classic_newgfx/gfx/objects/player_icons.png b/resources/game/classic_newgfx/gfx/objects/player_icons.png new file mode 100644 index 0000000..d8002f5 Binary files /dev/null and b/resources/game/classic_newgfx/gfx/objects/player_icons.png differ diff --git a/resources/game/classic_newgfx/gfx/syst_17.png b/resources/game/classic_newgfx/gfx/syst_17.png deleted file mode 100644 index 9e68e5d..0000000 Binary files a/resources/game/classic_newgfx/gfx/syst_17.png and /dev/null differ diff --git a/resources/game/classic_newgfx/gfx/syst_28.png b/resources/game/classic_newgfx/gfx/syst_28.png deleted file mode 100644 index 67c271d..0000000 Binary files a/resources/game/classic_newgfx/gfx/syst_28.png and /dev/null differ diff --git a/resources/game/classic_newgfx/gfx/syst_6.png b/resources/game/classic_newgfx/gfx/syst_6.png deleted file mode 100644 index 7c2391c..0000000 Binary files a/resources/game/classic_newgfx/gfx/syst_6.png and /dev/null differ diff --git a/resources/game/classic_newgfx/gfx/up.png b/resources/game/classic_newgfx/gfx/up.png new file mode 100644 index 0000000..4ed6c85 Binary files /dev/null and b/resources/game/classic_newgfx/gfx/up.png differ diff --git a/resources/game/classic_newgfx/newgfx.txt b/resources/game/classic_newgfx/newgfx.txt index f3738d9..068516c 100644 --- a/resources/game/classic_newgfx/newgfx.txt +++ b/resources/game/classic_newgfx/newgfx.txt @@ -1,10 +1,3 @@ -[replacement] -sprite_scale=2x2 -burngfxani@munt.raw=pngani@gfx/munt_{0}.png -munt.raw=gfx/munt_{0}.png -sta.pac=gfx/sta.png -syst.raw=gfx/syst_{0}.png - [replacement_60x72] sprite_scale=1.875x2.25 zei_004.raw=pngsheet@maps/shared/set_4.png?{0}?60x72 @@ -44,12 +37,36 @@ film_02.pac=gfx/backgrounds/film2.png film_03.pac=gfx/backgrounds/film3.png film_04.pac=gfx/backgrounds/film4.png film_09.pac=gfx/backgrounds/film9.png +info.pac=gfx/backgrounds/info.png syssze.raw=pngsheet@gfx/syssze.png?{0}?30x36 +munt.raw?3=pngsheet@gfx/objects/munt.png?0?15x18 +munt.raw?4=pngsheet@gfx/objects/munt.png?1?15x18 +gfx/up.png=gfx/up.png +gfx/down.png=gfx/down.png + +syst.raw?16=pngsheet@gfx/objects/player_icon_colors.png?0?36x38 +syst.raw?17=pngsheet@gfx/objects/player_icon_colors.png?1?36x38 +syst.raw?18=pngsheet@gfx/objects/player_icon_colors.png?2?36x38 +syst.raw?19=pngsheet@gfx/objects/player_icon_colors.png?3?36x38 + [newgfx_native] sprite_scale=1.875x2.25 gfx/char_shadow.png=gfx/char_shadow.png +gfx/objects/player_icons.png=pngsheet@gfx/objects/player_icons.png?{0}?36x38 +gfx/backgrounds/stats_rightbottom.png=gfx/backgrounds/stats_rightbottom.png +gfx/backgrounds/stats_righttop.png=gfx/backgrounds/stats_righttop.png +gfx/backgrounds/stats_leftbottom.png=gfx/backgrounds/stats_leftbottom.png +gfx/backgrounds/stats_lefttop.png=gfx/backgrounds/stats_lefttop.png +gfx/backgrounds/statistics.png=gfx/backgrounds/statistics.png +gfx/backgrounds/statistics2.png=gfx/backgrounds/statistics2.png + +[replacement] +sprite_scale=2x2 +burngfxani@munt.raw=pngani@gfx/munt_{0}.png +munt.raw=gfx/munt_{0}.png +sta.pac=gfx/sta.png [replacement_stretched] sprite_scale=2x2.375 diff --git a/source/BurnGfxRipper/Program.cs b/source/BurnGfxRipper/Program.cs index c56b02a..98fb791 100644 --- a/source/BurnGfxRipper/Program.cs +++ b/source/BurnGfxRipper/Program.cs @@ -15,6 +15,7 @@ class CommandParameter public bool RatioCorrection = false; public bool MegaTexture = false; public bool Padding = true; + public bool Palette = true; public bool HandleArg(string arg) { @@ -37,6 +38,12 @@ public bool HandleArg(string arg) return true; } + if (arg.StartsWith("--palette")) + { + Palette = true; + return true; + } + return false; } } @@ -67,6 +74,12 @@ static void Main(string[] args) String file = System.IO.Path.GetFileName(arg); String dir = path + "\\" + file + "_output"; + if (parameter.Palette) + { + ExportColorTables(path, file); + return; + } + bool stretch = true; switch (ext) @@ -119,4 +132,20 @@ static void Main(string[] args) // Console.ReadKey(); //} } + + static void ExportColorTables(string basePath, string fileName) + { + using Bitmap bmp = new(256, 1, PixelFormat.Format24bppRgb); + for (int i = 0; i < 256; i++) + bmp.SetPixel(i, 0, Color.FromArgb(BurnGfxData.Instance.DefaultColorTable.GetColor(i).ToInt())); + + bmp.Save(System.IO.Path.Combine(basePath, System.IO.Path.GetFileNameWithoutExtension(fileName) + "_palette.png")); + + using Bitmap bmp2 = new(256, 38, PixelFormat.Format24bppRgb); + for (int map = 0; map < 38; map++) + for (int i = 0; i < 256; i++) + bmp2.SetPixel(i, map, Color.FromArgb(BurnGfxData.Instance.GetMapColorTable(map).GetColor(i).ToInt())); + + bmp2.Save(System.IO.Path.Combine(basePath, "maps_palette.png")); + } } diff --git a/source/Burntime.BurnGfx/BurnGfxData.cs b/source/Burntime.BurnGfx/BurnGfxData.cs index fe1c104..b146ddc 100644 --- a/source/Burntime.BurnGfx/BurnGfxData.cs +++ b/source/Burntime.BurnGfx/BurnGfxData.cs @@ -123,7 +123,7 @@ void InitializeMaps() } #endregion - public void Initialize() + void Initialize() { Burntime.Platform.Log.Info("Initialize BurnGfx library"); InitializeMaps(); diff --git a/source/Burntime.BurnGfx/ColorTable.cs b/source/Burntime.BurnGfx/ColorTable.cs index 84a1881..e88b372 100644 --- a/source/Burntime.BurnGfx/ColorTable.cs +++ b/source/Burntime.BurnGfx/ColorTable.cs @@ -10,9 +10,6 @@ public class ColorTable { PixelColor[] colorTable; - public static ColorTable Last; - public static ColorTable Default; - public const int DefaultBlue = 148; public const int DefaultRed = 241; public const int ButtonBlue = 140; @@ -22,10 +19,12 @@ public class ColorTable public ColorTable() { + colorTable = new PixelColor[256]; } public ColorTable(File file) { + colorTable = new PixelColor[256]; file.Seek(16, SeekPosition.Begin); Read(file); } @@ -309,9 +308,6 @@ public void FromPac(byte[] file, int offset, short[] moveCmd) public bool Read(File reader) { - colorTable = new PixelColor[256]; - // Last = this; - byte[] colorbytes = new byte[3]; int read = 3;// = File.Read(colorbytes, 0, 3); for (int i = 0; i < 256 && read == 3; i++) diff --git a/source/Burntime.BurnGfx/Map.cs b/source/Burntime.BurnGfx/Map.cs index a60ac59..1ee627a 100644 --- a/source/Burntime.BurnGfx/Map.cs +++ b/source/Burntime.BurnGfx/Map.cs @@ -212,6 +212,7 @@ public bool CheckTile(int x, int y) return false; } + [Obsolete] public void Read(File reader) { int width = reader.ReadUShort() / 2; @@ -272,107 +273,6 @@ public void Read(File reader) } - public void Convert() - { - //bmp.Save("c:\\burntime\\input.bmp", System.Drawing.Imaging.ImageFormat.Bmp); - - //Size sz = bmp.Size; - - //bmp = null; - - //System.Diagnostics.Process proc = new System.Diagnostics.Process(); - //proc.EnableRaisingEvents = false; - //proc.StartInfo.FileName = "c:\\burntime\\hq3x.exe"; - //proc.StartInfo.Arguments = "c:\\burntime\\input.bmp c:\\burntime\\output.bmp"; - //proc.Start(); - //proc.WaitForExit(); - - //Image img = Image.FromFile("c:\\burntime\\output.bmp"); - - //int zoom = 3; - //bmp = new Bitmap(zoom * sz.Width, zoom * sz.Height); - //Graphics g = Graphics.FromImage(bmp); - - //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; - //g.DrawImage(img, new Rectangle(0, 0, zoom * sz.Width, zoom * sz.Height), new Rectangle(0, 0, sz.Width * 3, sz.Height * 3), GraphicsUnit.Pixel); - - //img.Dispose(); - } - - public void DrawGrid() - { - //Graphics g = Graphics.FromImage(bmp); - - //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; - - //Pen p = new Pen(new SolidBrush(Color.Black)); - - //for (int i = 0; i < Size.Width; i++) - //{ - // Point pt1 = new Point(i * TileWidth, 0); - // Point pt2 = new Point(pt1.X, Size.Height * TileHeight - 1); - // g.DrawLine(p, pt1, pt2); - //} - - //for (int i = 0; i < Size.Height; i++) - //{ - // Point pt1 = new Point(0, i * TileHeight); - // Point pt2 = new Point(Size.Width * TileWidth - 1, pt1.Y); - // g.DrawLine(p, pt1, pt2); - //} - - //p = new Pen(new SolidBrush(Color.Red)); - //foreach (Mask m in masks) - //{ - // bool[] matrix = new bool[16]; - - // int value = m.Value; - // for (int i = 0; i < 16; i++, value >>= 1) - // matrix[15 - i] = (value & 1) != 0; - - - // for (int i = 0; i < 16; i++) - // { - // if (matrix[i]) - // { - // int x = i % 4; - // int y = (i - x) / 4; - - // Rectangle rc = new Rectangle(m.x + x * TileWidth / 4, m.y + y * TileHeight / 4, TileWidth / 4, TileHeight / 4); - - // // left - // if (x == 0 || (x > 0 && !matrix[y * 4 + x - 1])) - // { - // g.DrawLine(p, new Point(rc.Left, rc.Top), new Point(rc.Left, rc.Bottom)); - // } - // // right - // if (x == 3 || (x < 3 && !matrix[y * 4 + x + 1])) - // { - // g.DrawLine(p, new Point(rc.Right, rc.Top), new Point(rc.Right, rc.Bottom)); - // } - // // top - // if (y == 0 || (y > 0 && !matrix[(y - 1) * 4 + x])) - // { - // g.DrawLine(p, new Point(rc.Left, rc.Top), new Point(rc.Right, rc.Top)); - // } - // // bottom - // if (y == 3 || (y < 3 && !matrix[(y + 1) * 4 + x])) - // { - // g.DrawLine(p, new Point(rc.Left, rc.Bottom), new Point(rc.Right, rc.Bottom)); - // } - - // //g.DrawRectangle(p, rc); - // } - // } - //} - //p = new Pen(new SolidBrush(Color.Blue)); - - //foreach (Door d in doors) - //{ - // g.DrawRectangle(p, d.Area); - //} - } - public int GetDoor(Vector2 pos) { Vector2 pt = new Vector2(pos); @@ -393,46 +293,5 @@ public Door GetDoor(int id) return null; return doors[id - 1]; } - - public void save(String file) - { - //Bitmap bmp = new Bitmap(PixelSize.Width, PixelSize.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - - - //System.Drawing.Imaging.BitmapData bdata = bmp.LockBits(new Rectangle(0, 0, PixelSize.Width, PixelSize.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, - // System.Drawing.Imaging.PixelFormat.Format24bppRgb); - - - //ByteBuffer target = new ByteBuffer(PixelSize.Width, PixelSize.Height, new byte[3 * PixelSize.Width * PixelSize.Height]); - - - //for (int y = 0; y < height; y++) - //{ - // for (int x = 0; x < width; x++) - // { - // int tileset = data[x + y * width] & 0xff; - // int tileid = data[x + y * width] >> 8; - - // Tile tile = TileDB.Singleton.GetTile(tileset, tileid); - // tile.Draw(ref target, x * Tile.WIDTH, y * Tile.HEIGHT, ColorTable.Last); - - // ByteBuffer tt = new ByteBuffer(Tile.WIDTH, Tile.HEIGHT, new byte[3 * Tile.WIDTH * Tile.HEIGHT]); - // tile.Draw(ref tt, 0, 0, ColorTable.Last); - // Bitmap tbmp = new Bitmap(Tile.WIDTH, Tile.HEIGHT, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - // System.Drawing.Imaging.BitmapData bdata2 = tbmp.LockBits(new Rectangle(0, 0, Tile.WIDTH, Tile.HEIGHT), System.Drawing.Imaging.ImageLockMode.ReadOnly, - // System.Drawing.Imaging.PixelFormat.Format24bppRgb); - - // System.Runtime.InteropServices.Marshal.Copy(tt.Data, 0, bdata2.Scan0, tt.Height * tt.Stride); - // tbmp.UnlockBits(bdata2); - - // tbmp.Save(BurnGfxSetting.Singleton.DataPath + "\\..\\output\\tiles\\" + tileset.ToString("D2") + "_" + tileid.ToString("D2") + ".png"); - // } - //} - - //System.Runtime.InteropServices.Marshal.Copy(target.Data, 0, bdata.Scan0, target.Height * target.Stride); - //bmp.UnlockBits(bdata); - - //bmp.Save(BurnGfxSetting.Singleton.DataPath + "\\..\\output\\maps\\" + file + ".png"); - } } } diff --git a/source/Burntime.Framework/GUI/GuiImage.cs b/source/Burntime.Framework/GUI/GuiImage.cs index 85d6cc8..df0982c 100644 --- a/source/Burntime.Framework/GUI/GuiImage.cs +++ b/source/Burntime.Framework/GUI/GuiImage.cs @@ -13,6 +13,7 @@ public class GuiImage public int Width => sprite_.Width; public int Height => sprite_.Height; + public Vector2 Size => sprite_.Size; public bool IsLoaded => sprite_.IsLoaded; public SpriteAnimation Animation => sprite_.Animation; diff --git a/source/Burntime.Framework/Scene.cs b/source/Burntime.Framework/Scene.cs index c9024c0..2935063 100644 --- a/source/Burntime.Framework/Scene.cs +++ b/source/Burntime.Framework/Scene.cs @@ -33,15 +33,14 @@ internal void ActivateScene(object parameter) { OnResizeScreen(); OnActivateScene(parameter); -#warning TODO SlimDX/Mono Music - //if (music != null) - // app.Engine.Music.Play(music); + + if (music != null) + app.Engine.Music.Play(music); } internal void InactivateScene() { -#warning TODO SlimDX/Mono Music - //app.Engine.Music.Stop(); + app.Engine.Music.Stop(); OnInactivateScene(); } diff --git a/source/Burntime.MonoGame/BurntimeGame.cs b/source/Burntime.MonoGame/BurntimeGame.cs index 3899305..4c61488 100644 --- a/source/Burntime.MonoGame/BurntimeGame.cs +++ b/source/Burntime.MonoGame/BurntimeGame.cs @@ -31,6 +31,10 @@ public class BurntimeGame : Game, IEngine, ILoadingCounter readonly GraphicsDeviceManager _graphics; readonly GameThread _gameThread = new(); + public MusicPlayback Music { get; } = new MusicPlayback(); + IMusic IEngine.Music => Music; + public bool MusicBlend { get; set; } = false; + internal int loadingStack = 0; public int LoadingStack { @@ -52,11 +56,11 @@ public void DecreaseLoadingCount() public bool IsLoading { get; set; } -// #if (DEBUG) + // #if (DEBUG) public bool FullScreen { get; set; } = false; -// #else -// public bool FullScreen { get; set; } = true; -// #endif + // #else + // public bool FullScreen { get; set; } = true; + // #endif bool _initialized = false; public BurntimeGame() @@ -107,8 +111,11 @@ protected override void Initialize() Window.ClientSizeChanged += OnResize; IsMouseVisible = false; ApplyGraphicsDeviceResolution(initialize: true); - base.Initialize(); + Window.TextInput += Window_TextInput; + Music.RunThread(); + + base.Initialize(); _initialized = true; } @@ -244,6 +251,19 @@ static char ConvertKeyToChar(Microsoft.Xna.Framework.Input.Keys key, Microsoft.X return '\0'; } + private void Window_TextInput(object sender, TextInputEventArgs e) + { + if (e.Key == Keys.Escape || e.Key == Keys.Pause || e.Key == Keys.Enter + || e.Key == Keys.F1 || e.Key == Keys.F2 || e.Key == Keys.F3 || e.Key == Keys.F4) + { + // handled in Update + } + else + { + DeviceManager?.KeyPress(e.Character); + } + } + private void HandleKeyboardInput() { var keyboard = Microsoft.Xna.Framework.Input.Keyboard.GetState(); @@ -252,39 +272,33 @@ private void HandleKeyboardInput() ModifierKeys modifier = ModifierKeys.None; if (keyboard.IsKeyDown(Keys.LeftAlt)) modifier |= ModifierKeys.LeftAlt; - + foreach (var key in keys) { if (_previousKeyboardState.IsKeyUp(key)) { - if (key == Keys.Enter && (modifier & ModifierKeys.LeftAlt) == ModifierKeys.LeftAlt) + if (key == Keys.F11 + || (key == Keys.Enter && (modifier & ModifierKeys.LeftAlt) == ModifierKeys.LeftAlt)) { ToggleFullscreen(); DeviceManager.Clear(); break; } - char charValue = ConvertKeyToChar(key, keyboard); - if (charValue != 0) - DeviceManager.KeyPress(charValue, modifier); - else if (key == Keys.LeftAlt || key == Keys.RightAlt || key == Keys.LeftShift || key == Keys.RightShift - || key == Keys.LeftControl || key == Keys.RightControl) + if (key == Keys.Escape || key == Keys.Pause || key == Keys.Enter + || key == Keys.F1 || key == Keys.F2 || key == Keys.F3 || key == Keys.F4) { - // eat modifier keys - } - else - { - DeviceManager.VKeyPress(key switch - { - Keys.Escape => SystemKey.Escape, - Keys.Pause => SystemKey.Pause, - Keys.F1 => SystemKey.F1, - Keys.F2 => SystemKey.F2, - Keys.F3 => SystemKey.F3, - Keys.F4 => SystemKey.F4, - Keys.Enter => SystemKey.Enter, - _ => SystemKey.Other - }, modifier); + DeviceManager?.VKeyPress(key switch + { + Keys.Escape => SystemKey.Escape, + Keys.Pause => SystemKey.Pause, + Keys.Enter => SystemKey.Enter, + Keys.F1 => SystemKey.F1, + Keys.F2 => SystemKey.F2, + Keys.F3 => SystemKey.F3, + Keys.F4 => SystemKey.F4, + _ => SystemKey.Other + }); } } } @@ -294,12 +308,11 @@ private void HandleKeyboardInput() protected override void Update(Microsoft.Xna.Framework.GameTime gameTime) { - //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed - // || Microsoft.Xna.Framework.Input.Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) - // Exit(); - - HandleMouseInput(); - HandleKeyboardInput(); + if (IsActive) + { + HandleMouseInput(); + HandleKeyboardInput(); + } RenderDevice.Update(); @@ -324,6 +337,12 @@ void IEngine.CenterMouse() } } + protected override void OnExiting(object sender, EventArgs args) + { + Music.StopThread(); + base.OnExiting(sender, args); + } + void IEngine.ExitApplication() { Exit(); @@ -365,7 +384,7 @@ public void RenderSprite(ISprite sprite, Platform.Vector2 pos, float alpha = 1) Graphics.SpriteEntity entity = new() { Rectangle = new Rectangle(0, 0, nativeSprite.OriginalSize.x, nativeSprite.OriginalSize.y), - Color = new Color(1, 1, 1, alpha), + Color = new Color(alpha, alpha, alpha, alpha), Factor = nativeSprite.Frame.Resolution }; @@ -402,6 +421,9 @@ public void RenderSprite(ISprite sprite, Platform.Vector2 pos, Platform.Vector2 if (now - nativeSprite.Frame.TimeStamp < (long)(Stopwatch.Frequency / popInSpeed) && popInSpeed != 0) { entity.Color.A *= (byte)System.Math.Min(255, (now - nativeSprite.Frame.TimeStamp) / (float)Stopwatch.Frequency * popInSpeed); + entity.Color.R *= (byte)System.Math.Min(255, (now - nativeSprite.Frame.TimeStamp) / (float)Stopwatch.Frequency * popInSpeed); + entity.Color.G *= (byte)System.Math.Min(255, (now - nativeSprite.Frame.TimeStamp) / (float)Stopwatch.Frequency * popInSpeed); + entity.Color.B *= (byte)System.Math.Min(255, (now - nativeSprite.Frame.TimeStamp) / (float)Stopwatch.Frequency * popInSpeed); } if (nativeSprite.Animation != null && nativeSprite.Animation.Progressive && nativeSprite.Frames != null) diff --git a/source/Burntime.MonoGame/Graphics/RenderDevice.cs b/source/Burntime.MonoGame/Graphics/RenderDevice.cs index 04d5a98..6eac2d5 100644 --- a/source/Burntime.MonoGame/Graphics/RenderDevice.cs +++ b/source/Burntime.MonoGame/Graphics/RenderDevice.cs @@ -34,11 +34,6 @@ public class RenderDevice : IDisposable int renderScale = 2; SpriteBatch _spriteBatch; - public float BlendState - { - get { return 1;/* return blendOverlay.BlendState;*/ } - } - public RenderDevice(BurntimeGame Engine) { resourceManager = Engine.ResourceManager; @@ -306,14 +301,10 @@ public void Render(float elapsedSeconds) BlendOverlay.BlockFadeOut = _engine.IsLoading || BlendOverlay.Block; BlendOverlay.Render(elapsedSeconds, _spriteBatch); - //if (engine.MusicBlend) - //{ - // engine.Music.Volume = 1 - BlendState; - //} - //else - //{ - // engine.Music.Volume = 1; - //} + if (_engine.MusicBlend) + _engine.Music.Volume = 1 - BlendOverlay.BlendState; + else + _engine.Music.Volume = 1; //spriteRenderer.End(); //if (render != null) diff --git a/source/Burntime.MonoGame/Music/OggSoundEffect.cs b/source/Burntime.MonoGame/Music/OggSoundEffect.cs new file mode 100644 index 0000000..23988d8 --- /dev/null +++ b/source/Burntime.MonoGame/Music/OggSoundEffect.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework.Audio; +using NVorbis; +using System; +using System.IO; + +namespace Burntime.MonoGame; + +public static class OggSoundEffect +{ + public static SoundEffect FromStream(Stream fileStream) + { + using (var reader = new VorbisReader(fileStream, false)) + { + var sampleCount = (int)reader.TotalSamples; + var soundData = new float[sampleCount * reader.Channels]; + int readCount = reader.ReadSamples(soundData, 0, sampleCount * reader.Channels); + + var byteData = new byte[sampleCount * 2 * reader.Channels]; + CastBuffer(soundData, byteData, sampleCount * reader.Channels); + + return new SoundEffect(byteData, reader.SampleRate, reader.Channels == 2 ? AudioChannels.Stereo : AudioChannels.Mono); + } + } + + static void CastBuffer(float[] inBuffer, byte[] outBuffer, int length) + { + for (int i = 0; i < length; i++) + { + var temp = (int)(32767f * inBuffer[i]); + if (temp > short.MaxValue) temp = short.MaxValue; + else if (temp < short.MinValue) temp = short.MinValue; + + var bytes = BitConverter.GetBytes(temp); + outBuffer[i * 2] = bytes[0]; + outBuffer[i * 2 + 1] = bytes[1]; + } + } +} \ No newline at end of file diff --git a/source/Burntime.MonoGame/MusicPlayback.cs b/source/Burntime.MonoGame/MusicPlayback.cs new file mode 100644 index 0000000..87869fa --- /dev/null +++ b/source/Burntime.MonoGame/MusicPlayback.cs @@ -0,0 +1,181 @@ +using Burntime.Platform; +using Microsoft.Xna.Framework.Audio; +using Microsoft.Xna.Framework.Media; +using System.Collections.Generic; +using System.IO; +using System.Threading; + +namespace Burntime.MonoGame +{ + public sealed class MusicPlayback : IMusic + { + SoundEffect _effect; + SoundEffectInstance _music; + List playList = new List(); + Thread musicThread; + + bool stop; + bool enabled; + bool playOnce; + + public bool Enabled + { + get { return enabled; } + set { enabled = value; } + } + + bool isMuted = true; + public bool IsMuted + { + get { return isMuted; } + set + { + isMuted = value; + Volume = _volume; + } + } + + float _volume = 0; + public float Volume + { + get { if (_music == null) return 0; return _music.Volume; } + set + { + _volume = value; + if (_music != null) + _music.Volume = isMuted ? 0 : value; + } + } + + public void ClearPlayList() + { + playList.Clear(); + Stop(); + } + + public void AddPlayList(string fileName) + { + if (!enabled) + return; + + playList.Add(fileName); + } + + public void Play(string fileName) + { + if (!enabled) + return; + + playOnce = false; + playList.Clear(); + Stop(); + playList.Add(fileName); + } + + public void PlayOnce(string fileName) + { + if (!enabled) + return; + + playList.Clear(); + Stop(); + playList.Add(fileName); + playOnce = true; + } + + public void Stop() + { + playList.Clear(); + + lock (this) + { + if (_music != null) + { + _music.Stop(); + _music.Dispose(); + _music = null; + } + } + } + + public void RunThread() + { + stop = false; + musicThread = new Thread(new ThreadStart(MusicThread)); + musicThread.Start(); + } + + public void StopThread() + { + Stop(); + + if (musicThread != null) + { + stop = true; + musicThread.Join(); + musicThread = null; + } + } + + private string GetNextTitle() + { + if (playList.Count == 0) + return null; + + string next = playList[0]; + playList.RemoveAt(0); + if (!playOnce) + playList.Add(next); + + return next; + } + + private void MusicThread() + { + int sleep = 0; + + while (!stop) + { + if (sleep > 0) + Thread.Sleep(sleep); + + lock (this) + { + if (_music == null) + { + sleep = 200; + + string next = GetNextTitle(); + if (next == null) + continue; + + _effect = OggSoundEffect.FromStream(Burntime.Platform.IO.FileSystem.GetFile(next).Stream); + _music = _effect.CreateInstance(); + _music.Volume = _volume; + _music.Play(); + } + else + { + if (_music.State == SoundState.Stopped) + { + _music.Dispose(); + _effect.Dispose(); + _music = null; + sleep = 0; + } + else + sleep = 50; + } + } + } + + lock (this) + { + _music?.Dispose(); + _effect?.Dispose(); + } + + //SlimDXOggStreamingSample.DirectSoundWrapper.Device.Dispose(); + } + } +} diff --git a/source/Burntime.Platform/IEngine.cs b/source/Burntime.Platform/IEngine.cs index e180c55..1a82e65 100644 --- a/source/Burntime.Platform/IEngine.cs +++ b/source/Burntime.Platform/IEngine.cs @@ -1,8 +1,5 @@ using Burntime.Platform.Graphics; using Burntime.Platform.Utils; -using System.Diagnostics; -using System.Drawing; - namespace Burntime.Platform; public interface ILoadingCounter @@ -15,11 +12,13 @@ public interface IEngine { DeviceManager DeviceManager { get; set; } int Layer { get; set; } - + BlendOverlayBase BlendOverlay { get; } Resolution Resolution { get; } RenderTarget MainTarget { get; } + IMusic Music { get; } + bool MusicBlend { get; set; } bool IsLoading { get; set; } void CenterMouse(); diff --git a/source/Burntime.Platform/IMusic.cs b/source/Burntime.Platform/IMusic.cs new file mode 100644 index 0000000..13c8be1 --- /dev/null +++ b/source/Burntime.Platform/IMusic.cs @@ -0,0 +1,12 @@ +namespace Burntime.Platform; + +public interface IMusic +{ + bool Enabled { get; set; } + bool IsMuted { get; set; } + float Volume { get; set; } + + void Play(string song); + void PlayOnce(string sound); + void Stop(); +} diff --git a/source/Burntime.Platform/Resource/ResourceManagerBase.cs b/source/Burntime.Platform/Resource/ResourceManagerBase.cs index 943856c..682a5f1 100644 --- a/source/Burntime.Platform/Resource/ResourceManagerBase.cs +++ b/source/Burntime.Platform/Resource/ResourceManagerBase.cs @@ -295,7 +295,11 @@ public ScaledResourceId(ResourceID id, Vector2f factor) { string? idstring = null; - if (section.ContainsKey(id.Format + "@" + id.File)) + if (section.ContainsKey(id.ToString())) + { + return section.Get(id.ToString()); + } + else if (section.ContainsKey(id.Format + "@" + id.File)) { idstring = section.Get(id.Format + "@" + id.File); } diff --git a/source/Burntime.Remaster/Application.cs b/source/Burntime.Remaster/Application.cs index 04cfedd..1c14a23 100644 --- a/source/Burntime.Remaster/Application.cs +++ b/source/Burntime.Remaster/Application.cs @@ -58,8 +58,7 @@ public BurntimeClassic() public override void Start() { -#warning TODO SlimDX/Mono Music - //Engine.Music.Enabled = (!DisableMusic) & MusicPlayback; + Engine.Music.Enabled = (!DisableMusic) & MusicPlayback; MouseImage = ResourceManager.GetImage("munt.raw"); SceneManager.SetScene("IntroScene"); diff --git a/source/Burntime.Remaster/GUI/DialogWindow.cs b/source/Burntime.Remaster/GUI/DialogWindow.cs index 025337d..e0983da 100644 --- a/source/Burntime.Remaster/GUI/DialogWindow.cs +++ b/source/Burntime.Remaster/GUI/DialogWindow.cs @@ -61,16 +61,14 @@ public override void OnShow() hover = -1; base.OnShow(); -#warning TODO SlimDX/Mono Music - //BurntimeClassic.Instance.Engine.Music.Play("18_MUS 18_HSC.ogg"); + BurntimeClassic.Instance.Engine.Music.Play("18_MUS 18_HSC.ogg"); } public override void OnHide() { base.OnHide(); -#warning TODO SlimDX/Mono Music - //BurntimeClassic.Instance.Engine.Music.Stop(); + BurntimeClassic.Instance.Engine.Music.Stop(); } public void SetCharacter(Character character, Conversation conversation) diff --git a/source/Burntime.Remaster/GUI/InventoryWindow.cs b/source/Burntime.Remaster/GUI/InventoryWindow.cs index 8caf048..132df2d 100644 --- a/source/Burntime.Remaster/GUI/InventoryWindow.cs +++ b/source/Burntime.Remaster/GUI/InventoryWindow.cs @@ -66,6 +66,8 @@ public Character ActiveCharacter public InventoryWindow(Module App, InventorySide Side) : base(App) { + const int MAX_PEOPLE = 5; + side = (Side == InventorySide.Right); back = side ? "inv.raw?2" : "gfx/inventory_left.png"; @@ -79,15 +81,6 @@ public InventoryWindow(Module App, InventorySide Side) face.Layer = this.Layer + 6; Windows += face; - grid = new ItemGridWindow(App); - grid.LockPositions = true; - grid.Position = new Vector2(side ? 9 : 19, side ? 72 : 83) + basePos; - grid.Spacing = new Vector2(4, side ? 16 : 5); - grid.Grid = new Vector2(3, 2); - grid.LeftClickItemEvent += OnLeftClickItem; - grid.RightClickItemEvent += OnRightClickItem; - Windows += grid; - font = new GuiFont(BurntimeClassic.FontName, new PixelColor(128, 136, 192)); font.Borders = TextBorders.Screen; nameFont = new GuiFont(BurntimeClassic.FontName, new PixelColor(240, 64, 56)); @@ -95,7 +88,7 @@ public InventoryWindow(Module App, InventorySide Side) pageName = ""; - for (int i = 0; i < 5; i++) + for (int i = 0; i < MAX_PEOPLE; i++) { pageButtons[i] = new Button(App); pageButtons[i].Image = "munt.raw?" + (5 + i); @@ -106,10 +99,21 @@ public InventoryWindow(Module App, InventorySide Side) pageButtons[i].Hide(); pageButtons[i].Command += new CommandHandler(OnPage, i); pageIndices[i] = i; - pageButtons[i].Layer = this.Layer + i + 1; + pageButtons[i].Layer = Layer + MAX_PEOPLE + 1; Windows += pageButtons[i]; } + Windows += grid = new ItemGridWindow(App) + { + LockPositions = true, + Position = new Vector2(side ? 9 : 19, side ? 72 : 83) + basePos, + Spacing = new Vector2(4, side ? 16 : 5), + Grid = new Vector2(3, 2), + Layer = Layer + MAX_PEOPLE + 1 + }; + grid.LeftClickItemEvent += OnLeftClickItem; + grid.RightClickItemEvent += OnRightClickItem; + pages = new List(); activePageIndex = 0; activePage = null; @@ -199,21 +203,12 @@ public void OnSelectPage() public override void OnRender(RenderTarget Target) { - if (side) - { - for (int i = pages.Count - 1; i >= 0; i--) - { - Target.DrawSprite(basePos + new Vector2(3, -2) * i, back); - Target.Layer++; - } - } - else + var inventoryOffset = side ? new Vector2(3, -2) : new Vector2(-3, -3); + + for (int i = pages.Count - 1; i >= 0; i--) { - for (int i = pages.Count - 1; i >= 0; i--) - { - Target.DrawSprite(basePos + -3 * i, back); - Target.Layer++; - } + Target.DrawSprite(basePos + inventoryOffset * i, back); + Target.Layer++; } TextHelper txt = new TextHelper(app, "burn"); @@ -277,14 +272,11 @@ public override void OnRender(RenderTarget Target) } } - Target.Layer ++; - if (pageName != "") { + Target.Layer += pageButtons.Length + 1; nameFont.DrawText(Target, namePosition, pageName, TextAlignment.Center, VerticalTextAlignment.Top); } - - Target.Layer --; } void OnLeftClickItem(Framework.States.StateObject State) diff --git a/source/Burntime.Remaster/Logic/World.cs b/source/Burntime.Remaster/Logic/World.cs index 9564068..cd3e824 100644 --- a/source/Burntime.Remaster/Logic/World.cs +++ b/source/Burntime.Remaster/Logic/World.cs @@ -57,6 +57,24 @@ public void Update(float elapsed) Time -= (TimePerDay / RoundTime) * elapsed; // TimeSpeed if (Time < 0) Time = 0; + + // old save game support +#warning TODO create OnLoadSave actions? + if (Players.Count > 2 && Players[2].Character.FaceID == Players[3].Character.FaceID) + { + var usedFaces = new HashSet(); + foreach (Player player in Players) + { + if (player.Type == PlayerType.Human) + usedFaces.Add(player.Character.FaceID); + else + { + while (usedFaces.Contains(player.Character.FaceID)) + player.Character.FaceID = Platform.Math.Random.Next(0, MenuScene.MAX_FACE_ID); + usedFaces.Add(player.Character.FaceID); + } + } + } } // logic diff --git a/source/Burntime.Remaster/Maps/MapViewOverlayPlayer.cs b/source/Burntime.Remaster/Maps/MapViewOverlayPlayer.cs index bfcefad..3b2acec 100644 --- a/source/Burntime.Remaster/Maps/MapViewOverlayPlayer.cs +++ b/source/Burntime.Remaster/Maps/MapViewOverlayPlayer.cs @@ -33,43 +33,49 @@ public void UpdateOverlay(WorldState world, float elapsed) public void RenderOverlay(RenderTarget target, Vector2 offset, Vector2 size) { - if (map != null) + if (map is null) return; + + ClassicGame game = (ClassicGame)app.GameState; + for (int i = 0; i < game.World.Players.Count; i++) { - ClassicGame game = (ClassicGame)app.GameState; + Player p = game.World.Players[i]; + if (p.IsDead) + continue; - for (int i = 0; i < 4; i++) - { - Player p = game.World.Players[i]; - if (p.IsDead) - continue; + int[] icons = new int[] { 17, 16, 19, 18 }; - int[] icons = new int[] { 17, 16, 19, 18 }; + ISprite sprite = app.ResourceManager.GetImage("syst.raw?" + icons[p.IconID]); + ISprite faceSprite = app.IsNewGfx ? app.ResourceManager.GetImage("gfx/objects/player_icons.png?" + p.FaceID) : null; - ISprite sprite = app.ResourceManager.GetImage("syst.raw?" + icons[p.IconID]); + Vector2 pos = new Vector2(); - Vector2 pos = new Vector2(); + if (p.IsTraveling) + { + Vector2 start = map.Entrances[p.Location].Area.Center + offset; + Vector2 end = map.Entrances[p.Destination].Area.Center + offset; - if (p.IsTraveling) - { - Vector2 start = map.Entrances[p.Location].Area.Center + offset; - Vector2 end = map.Entrances[p.Destination].Area.Center + offset; + pos = end + ((start - end) * p.RemainingDays / p.TravelDays); + } + else + { + pos.x = map.Entrances[p.Location].Area.Position.x + offset.x; + pos.y = map.Entrances[p.Location].Area.Center.y + offset.y; - pos = end + ((start - end) * p.RemainingDays / p.TravelDays); - } - else + for (int j = 0; j < i; j++) { - pos.x = map.Entrances[p.Location].Area.Position.x + offset.x; - pos.y = map.Entrances[p.Location].Area.Center.y + offset.y; - - for (int j = 0; j < i; j++) - { - if (game.World.Players[j].Location == p.Location) - pos += 3; - } + if (game.World.Players[j].Location == p.Location) + pos += 3; } + } - target.DrawSprite(pos + new Vector2(-sprite.Width / 2, -15), sprite); + target.DrawSprite(pos + new Vector2(-sprite.Width / 2, -15), sprite); + if (faceSprite is not null) + { + target.Layer++; + target.DrawSprite(pos + new Vector2(-sprite.Width / 2, -15), faceSprite); } + + target.Layer++; } } diff --git a/source/Burntime.Remaster/Scenes/ImageScene.cs b/source/Burntime.Remaster/Scenes/ImageScene.cs index 1cfec46..9ffbe50 100644 --- a/source/Burntime.Remaster/Scenes/ImageScene.cs +++ b/source/Burntime.Remaster/Scenes/ImageScene.cs @@ -102,7 +102,7 @@ protected override void OnActivateScene(object parameter) { Music = "05_MUS 05_HSC.ogg"; } - else if (game.ImageScene == "film_08.pac") + else if (game.ImageScene == "film_09.pac") { Music = "02_MUS 02_HSC.ogg"; } diff --git a/source/Burntime.Remaster/Scenes/IntroScene.cs b/source/Burntime.Remaster/Scenes/IntroScene.cs index aea76af..ebf29be 100644 --- a/source/Burntime.Remaster/Scenes/IntroScene.cs +++ b/source/Burntime.Remaster/Scenes/IntroScene.cs @@ -116,12 +116,12 @@ protected override void OnActivateScene(object parameter) { if (oldSpeed == 0) oldSpeed = app.Engine.BlendOverlay.Speed; -#warning TODO SlimDX/Mono Music - //app.Engine.Music.Volume = 0; + + app.Engine.Music.Volume = 0; app.Engine.BlendOverlay.Speed = 0.9f; -#warning TODO SlimDX/Mono Music - //app.Engine.MusicBlend = false; - //app.Engine.Music.IsMuted = true; + + app.Engine.MusicBlend = false; + app.Engine.Music.IsMuted = true; delayedMusicStart = 2.0f; index = 0; scroll = 0; @@ -149,6 +149,7 @@ protected override void OnInactivateScene() { app.Engine.BlendOverlay.Speed = oldSpeed; app.RenderMouse = true; + app.Engine.Music.IsMuted = false; } public override void OnUpdate(float elapsed) @@ -159,8 +160,7 @@ public override void OnUpdate(float elapsed) delayedMusicStart -= elapsed; if (delayedMusicStart <= 0) { -#warning TODO SlimDX/Mono Music - //app.Engine.Music.IsMuted = false; + app.Engine.Music.IsMuted = false; } } @@ -233,8 +233,7 @@ public override void OnRender(RenderTarget target) private void NextScene() { -#warning TODO SlimDX/Mono Music - //app.Engine.MusicBlend = true; + app.Engine.MusicBlend = true; app.SceneManager.SetScene("MenuScene"); } } diff --git a/source/Burntime.Remaster/Scenes/LocationScene.cs b/source/Burntime.Remaster/Scenes/LocationScene.cs index 9fbf374..e765f98 100644 --- a/source/Burntime.Remaster/Scenes/LocationScene.cs +++ b/source/Burntime.Remaster/Scenes/LocationScene.cs @@ -284,8 +284,7 @@ protected override void OnActivateScene(object parameter) BurntimeClassic.Instance.PreviousPlayerId != game.CurrentPlayerIndex) { // play player changed sound -#warning TODO SlimDX/Mono Music - //BurntimeClassic.Instance.Engine.Music.PlayOnce("06_MUS 06_HSC.ogg"); + BurntimeClassic.Instance.Engine.Music.PlayOnce("06_MUS 06_HSC.ogg"); } BurntimeClassic.Instance.PreviousPlayerId = game.CurrentPlayerIndex; @@ -450,8 +449,7 @@ public void OnMenuMakeCamp() charOverlay.SelectedCharacter.JoinCamp(); view.Location.Player = view.Player; -#warning TODO SlimDX/Mono Music - //BurntimeClassic.Instance.Engine.Music.PlayOnce("08_MUS 08_HSC.ogg"); + BurntimeClassic.Instance.Engine.Music.PlayOnce("08_MUS 08_HSC.ogg"); } } diff --git a/source/Burntime.Remaster/Scenes/MapScene.cs b/source/Burntime.Remaster/Scenes/MapScene.cs index 6679f52..0bea0ec 100644 --- a/source/Burntime.Remaster/Scenes/MapScene.cs +++ b/source/Burntime.Remaster/Scenes/MapScene.cs @@ -141,8 +141,7 @@ protected override void OnActivateScene(object parameter) BurntimeClassic.Instance.PreviousPlayerId != game.CurrentPlayerIndex) { // play player changed sound -#warning TODO SlimDX/Mono Music - //BurntimeClassic.Instance.Engine.Music.PlayOnce("06_MUS 06_HSC.ogg"); + BurntimeClassic.Instance.Engine.Music.PlayOnce("06_MUS 06_HSC.ogg"); } BurntimeClassic.Instance.PreviousPlayerId = game.CurrentPlayerIndex; diff --git a/source/Burntime.Remaster/Scenes/MenuScene.cs b/source/Burntime.Remaster/Scenes/MenuScene.cs index 7e204a3..2bd4a9f 100644 --- a/source/Burntime.Remaster/Scenes/MenuScene.cs +++ b/source/Burntime.Remaster/Scenes/MenuScene.cs @@ -10,6 +10,8 @@ namespace Burntime.Remaster { public class MenuScene : Scene { + public const int MAX_FACE_ID = 5; + SpriteAnimation PlayerOneSlide; SpriteAnimation PlayerTwoSlide; NameWindow PlayerOneSwitch; @@ -36,7 +38,7 @@ public MenuScene(Module App) // face PlayerOneFace = new FaceWindow(App); - PlayerOneFace.MaxFaceID = 5; + PlayerOneFace.MaxFaceID = MAX_FACE_ID; PlayerOneFace.Position = new Vector2(33, 28); PlayerOneFace.Group = 3; Windows += PlayerOneFace; diff --git a/source/Burntime.Remaster/Scenes/OptionsScene.cs b/source/Burntime.Remaster/Scenes/OptionsScene.cs index ff3164e..ee16f81 100644 --- a/source/Burntime.Remaster/Scenes/OptionsScene.cs +++ b/source/Burntime.Remaster/Scenes/OptionsScene.cs @@ -278,19 +278,19 @@ void OnButtonMusicSwitch() BurntimeClassic.Instance.MusicPlayback = !BurntimeClassic.Instance.MusicPlayback; music.Text = BurntimeClassic.Instance.MusicPlayback ? "@burn?389" : "@burn?424"; music.SetTextOnly(); -#warning TODO SlimDX/Mono Music - //if (BurntimeClassic.Instance.MusicPlayback) - //{ - // // start music - // app.Engine.Music.Enabled = true; - // app.Engine.Music.Play(Music); - //} - //else - //{ - // // stop music - // app.Engine.Music.Enabled = false; - // app.Engine.Music.Stop(); - //} + + if (BurntimeClassic.Instance.MusicPlayback) + { + // start music + app.Engine.Music.Enabled = true; + app.Engine.Music.Play(Music); + } + else + { + // stop music + app.Engine.Music.Enabled = false; + app.Engine.Music.Stop(); + } } } diff --git a/source/Burntime.Remaster/Scenes/StatisticsScene.cs b/source/Burntime.Remaster/Scenes/StatisticsScene.cs index c0cd685..5199649 100644 --- a/source/Burntime.Remaster/Scenes/StatisticsScene.cs +++ b/source/Burntime.Remaster/Scenes/StatisticsScene.cs @@ -28,14 +28,28 @@ class StatisticsScene : Scene int doctor; int technician; + readonly GuiImage _rightBottom, _rightTop; + readonly GuiImage _leftBottom, _leftTop; + readonly ISprite _background, _background2; + readonly ISprite _backgroundClassic; + public StatisticsScene(Module App) : base(App) { - Background = "blz.pac"; + //Background = "blz.pac"; + Size = new Vector2(320, 200); Music = "17_MUS 17_HSC.ogg"; - Position = (app.Engine.Resolution.Game - new Vector2(320, 200)) / 2; + Position = (app.Engine.Resolution.Game - Size) / 2; font = new GuiFont(BurntimeClassic.FontName, new PixelColor(212, 212, 212), new PixelColor(92, 92, 96)); CaptureAllMouseClicks = true; + + _rightBottom = (GuiImage)"gfx/backgrounds/stats_rightbottom.png"; + _rightTop = (GuiImage)"gfx/backgrounds/stats_righttop.png"; + _leftBottom = (GuiImage)"gfx/backgrounds/stats_leftbottom.png"; + _leftTop = (GuiImage)"gfx/backgrounds/stats_lefttop.png"; + _background = app.ResourceManager.GetImage("gfx/backgrounds/statistics.png"); + _background2 = app.ResourceManager.GetImage("gfx/backgrounds/statistics2.png"); + _backgroundClassic = app.ResourceManager.GetImage("blz.pac"); } public override void OnResizeScreen() @@ -47,6 +61,24 @@ public override void OnResizeScreen() public override void OnRender(RenderTarget Target) { + if (app.IsNewGfx) + { + Target.DrawSprite(-Position, _background); + if (app.Engine.Resolution.Game.x > _background.Width) + { +#warning OPTIMIZE avoid duplicating the texture for extra wide background + Target.DrawSprite(-Position + new Vector2(_background.Width, 0), _background2); + } + Target.Layer++; + Target.DrawSprite(app.Engine.Resolution.Game - _rightBottom.Size - Position + Vector2.One, _rightBottom); + Target.DrawSprite(new Vector2(app.Engine.Resolution.Game.x - _rightTop.Width + 1, 0) - Position, _rightTop); + Target.DrawSprite(-Position, _leftTop); + Target.DrawSprite(new Vector2(0, app.Engine.Resolution.Game.y - _leftBottom.Height + 1) - Position, _leftBottom); + } + else + { + Target.DrawSprite(_backgroundClassic); + } int y = -1;