handle custom resolutions

This commit is contained in:
Milan Nikolic 2015-01-02 19:01:33 +01:00
parent aea77ba059
commit 2a06f5088f
2 changed files with 17 additions and 14 deletions

View file

@ -39,22 +39,21 @@ else:
try:
if not SDL_WasInit(SDL_INIT_VIDEO):
SDL_InitSubSystem(SDL_INIT_VIDEO)
MODES = []
if SDL2:
MODES = []
display = SDL_DisplayMode()
for mode in range(SDL_GetNumDisplayModes(0)):
ret = SDL_GetDisplayMode(0, mode, ctypes.byref(display))
MODES.append((display.w, display.h))
if (display.w, display.h) not in MODES:
MODES.append((display.w, display.h))
else:
MODES = [(mode.w, mode.h) for mode in SDL_ListModes(
None, SDL_FULLSCREEN|SDL_HWSURFACE)]
for mode in SDL_ListModes(None, SDL_FULLSCREEN|SDL_HWSURFACE):
if (mode.w, mode.h) not in MODES:
MODES.append((mode.w, mode.h))
if SDL_WasInit(SDL_INIT_VIDEO):
SDL_QuitSubSystem(SDL_INIT_VIDEO)
except Exception as err:
log.warn(str(err))
MODES = [(1920, 1440), (1600, 1200), (1400, 1050),
(1280, 960), (1152, 864), (1024, 768),
(800, 600), (640, 480), (320, 240)]
class Video():

View file

@ -307,15 +307,19 @@ class Settings(QDialog, Ui_Settings):
self.set_section(combo, button, settings)
def set_resolution(self):
self.comboResolution.clear()
for mode in MODES:
width, height = mode
self.comboResolution.addItem(
"%sx%s" % (width, height), (width, height))
width = self.core.config.get_parameter("ScreenWidth")
height = self.core.config.get_parameter("ScreenHeight")
index = self.comboResolution.findText("%sx%s" % (width, height))
if (width, height) not in MODES:
MODES.append((width, height))
self.comboResolution.clear()
for mode in MODES:
w, h = mode
self.comboResolution.addItem(
"%sx%s" % (w, h), (w, h))
index = self.comboResolution.findText(
"%sx%s" % (width, height), Qt.MatchExactly)
if index == -1: index = 0
self.comboResolution.setCurrentIndex(index)
self.comboResolution.setEnabled(not self.parent.vidext)