Added fullscreen option

This commit is contained in:
Tim Sarbin 2018-11-29 18:20:38 -05:00
parent e5c9af0367
commit baed1834b4
5 changed files with 19 additions and 6 deletions

View File

@ -11,6 +11,6 @@
public string BaseDataPath { get; set; }
public eMouseMode MouseMode { get; set; }
public int HardwareMouseScale { get; set; }
public bool FullScreen { get; set; }
}
}

View File

@ -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)

View File

@ -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; }
}
}

View File

@ -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.");

View File

@ -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: