diff --git a/OpenDiablo2.Common/Models/GlobalConfiguration.cs b/OpenDiablo2.Common/Models/GlobalConfiguration.cs index 185810e5..114ebda5 100644 --- a/OpenDiablo2.Common/Models/GlobalConfiguration.cs +++ b/OpenDiablo2.Common/Models/GlobalConfiguration.cs @@ -11,6 +11,6 @@ public string BaseDataPath { get; set; } public eMouseMode MouseMode { get; set; } public int HardwareMouseScale { get; set; } - + public bool FullScreen { get; set; } } } diff --git a/OpenDiablo2.SDL2/SDL2RenderWindow.cs b/OpenDiablo2.SDL2/SDL2RenderWindow.cs index 84106ae7..6d69fd00 100644 --- a/OpenDiablo2.SDL2/SDL2RenderWindow.cs +++ b/OpenDiablo2.SDL2/SDL2RenderWindow.cs @@ -13,6 +13,8 @@ namespace OpenDiablo2.SDL2_ private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private IntPtr window, renderer; + private bool fullscreen; + public bool IsRunning { get; private set; } public int MouseX { get; internal set; } = 0; @@ -45,13 +47,14 @@ namespace OpenDiablo2.SDL2_ this.resourceManager = resourceManager; this.getGameState = getGameState; this.getMapEngine = getMapEngine; + this.fullscreen = globalConfig.FullScreen; SDL.SDL_Init(SDL.SDL_INIT_EVERYTHING); if (SDL.SDL_SetHint(SDL.SDL_HINT_RENDER_SCALE_QUALITY, "0") == SDL.SDL_bool.SDL_FALSE) throw new ApplicationException($"Unable to Init hinting: {SDL.SDL_GetError()}"); - window = SDL.SDL_CreateWindow("OpenDiablo2", SDL.SDL_WINDOWPOS_UNDEFINED, SDL.SDL_WINDOWPOS_UNDEFINED, 800, 600, - SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN | SDL.SDL_WindowFlags.SDL_WINDOW_VULKAN); + window = SDL.SDL_CreateWindow("OpenDiablo2", SDL.SDL_WINDOWPOS_UNDEFINED, SDL.SDL_WINDOWPOS_UNDEFINED, 800, 600, + SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN | (fullscreen ? SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN : 0)); if (window == IntPtr.Zero) throw new ApplicationException($"Unable to create SDL Window: {SDL.SDL_GetError()}"); @@ -136,7 +139,13 @@ namespace OpenDiablo2.SDL2_ } else if (evt.type == SDL.SDL_EventType.SDL_KEYDOWN) { - if (evt.key.keysym.sym == SDL.SDL_Keycode.SDLK_BACKSPACE && KeyPressCallback != null) + /* NOTE: This absolutely trashes rendering for some reason... + if (evt.key.keysym.mod.HasFlag(SDL.SDL_Keymod.KMOD_RALT) && evt.key.keysym.scancode.HasFlag(SDL.SDL_Scancode.SDL_SCANCODE_RETURN)) + { + fullscreen = !fullscreen; + SDL.SDL_SetWindowFullscreen(window, (uint)(fullscreen ? SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN : 0)); + } + else*/ if (evt.key.keysym.sym == SDL.SDL_Keycode.SDLK_BACKSPACE && KeyPressCallback != null) KeyPressCallback('\b'); } else if (evt.type == SDL.SDL_EventType.SDL_TEXTINPUT) diff --git a/OpenDiablo2/CommandLineOptions.cs b/OpenDiablo2/CommandLineOptions.cs index 5a95811b..8278be02 100644 --- a/OpenDiablo2/CommandLineOptions.cs +++ b/OpenDiablo2/CommandLineOptions.cs @@ -13,5 +13,7 @@ namespace OpenDiablo2 [Option("mousescale", Default = 1, Required = false, HelpText = "When hardware mouse is enabled, this defines the pixel scale of the mouse. No effect for software mode")] public int MouseScale { get; set; } + [Option('f', "fullscreen", Default = false, Required = false, HelpText = "When set, the game will start in full screen mode")] + public bool FullScreen { get; set; } } } diff --git a/OpenDiablo2/Program.cs b/OpenDiablo2/Program.cs index 4e364671..100712ec 100644 --- a/OpenDiablo2/Program.cs +++ b/OpenDiablo2/Program.cs @@ -22,7 +22,8 @@ namespace OpenDiablo2 { BaseDataPath = Path.GetFullPath(o.DataPath ?? Directory.GetCurrentDirectory()), MouseMode = o.HardwareMouse == true ? eMouseMode.Hardware : eMouseMode.Software, - HardwareMouseScale = o.MouseScale + HardwareMouseScale = o.MouseScale, + FullScreen = o.FullScreen }).WithNotParsed(o => { log.Warn($"Could not parse command line options."); diff --git a/README.md b/README.md index 25f99f1f..a9727f7a 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,10 @@ You need to have MonoDevelop installed, as well as any depenencies for that. You ## Command Line Parameters | Long Name | Description | | ------------ | ------------------------------------------------------------ | -| --datapath | Defines the path where the data files can be found | +| --datapath | (-d) Defines the path where the data files can be found | | --hwmouse | Use the hardware mouse instead of software | | --mousescale | When hardware mouse is enabled, this defines the pixel scale of the mouse. No effect for software mode | +| --fullscreen | (-f) When set, the game launches in full screen mode at 800x600. | By default OpenDiablo2 assumes the media files are in the same folder as itself. At minimum you'll most likely want to specify this option: