Browse Source

Make graphics modes configurable (#44)

* Make graphics modes configurable

[devilutionx]
scale quality=2
fullscreen=1
grab input=1

* Update dx.cpp
pull/50/head
Anders Jenbo 7 years ago committed by GitHub
parent
commit
a77c75a097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      SourceX/DiabloUI/diabloui.cpp
  2. 3
      SourceX/DiabloUI/diabloui.h
  3. 5
      SourceX/dx.cpp
  4. 11
      SourceX/miniwin/misc.cpp

20
SourceX/DiabloUI/diabloui.cpp

@ -819,4 +819,24 @@ void DrawMouse()
DrawArt(MouseX, MouseY, &ArtCursor);
}
/**
* @brief Get int from ini, if not found the provided value will be added to the ini instead
*/
void DvlIntSetting(const char *valuename, int *value)
{
if (!SRegLoadValue("devilutionx", valuename, 0, value)) {
SRegSaveValue("devilutionx", valuename, 0, *value);
}
}
/**
* @brief Get string from ini, if not found the provided value will be added to the ini instead
*/
void DvlStringSetting(const char *valuename, char *string, int len)
{
if (!SRegLoadString("devilutionx", valuename, 0, string, len)) {
SRegSaveString("devilutionx", valuename, 0, string);
}
}
}

3
SourceX/DiabloUI/diabloui.h

@ -118,4 +118,7 @@ void UiRender();
void UiRenderItems(UI_Item *items, int size);
void WordWrap(UI_Item *item);
void DvlIntSetting(const char *valuename, int *value);
void DvlStringSetting(const char *valuename, char *string, int len);
}

5
SourceX/dx.cpp

@ -358,7 +358,10 @@ void dx_init(HWND hWnd)
return;
}
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2");
char scaleQuality[2] = "2";
DvlStringSetting("scaling quality", scaleQuality, 2);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaleQuality);
if (SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT) != 0) {
SDL_Log("SDL_RenderSetLogicalSize: %s\n", SDL_GetError());
return;

11
SourceX/miniwin/misc.cpp

@ -282,10 +282,15 @@ HWND CreateWindowExA(
}
atexit(SDL_Quit);
int flags = SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_INPUT_GRABBED;
if (!fullscreen) {
flags = SDL_WINDOW_RESIZABLE;
DvlIntSetting("fullscreen", &fullscreen);
int flags = fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_RESIZABLE;
int grabInput = 1;
DvlIntSetting("grab input", &grabInput);
if (grabInput) {
flags |= SDL_WINDOW_INPUT_GRABBED;
}
window = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, nWidth, nHeight, flags);
atexit(FakeWMDestroy);

Loading…
Cancel
Save