forked from ndyer/pygame-dvd
added screen resolution detection
This commit is contained in:
parent
399092238e
commit
11f5eb5a79
@ -1,13 +1,18 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
import subprocess
|
||||||
import steam_saver.surfaces as surfaces
|
import steam_saver.surfaces as surfaces
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
SCREEN_SIZE = (1920, 1080)
|
|
||||||
FPS = 60
|
FPS = 60
|
||||||
VALID_SURFACES = [
|
VALID_SURFACES = [
|
||||||
'steam_screen'
|
'steam_screen'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_screen_resolution():
|
||||||
|
command_output = subprocess.check_output(['xrandr']).decode('utf-8')
|
||||||
|
for line in command_output.split('\n'):
|
||||||
|
if '*' in line:
|
||||||
|
return tuple(map(int, line.split()[0].split('x')))
|
||||||
|
|
||||||
def main(windowed_mode=False):
|
def main(windowed_mode=False):
|
||||||
"""
|
"""
|
||||||
@ -16,13 +21,16 @@ def main(windowed_mode=False):
|
|||||||
"""
|
"""
|
||||||
pygame.init()
|
pygame.init()
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
|
screen_size = get_screen_resolution()
|
||||||
|
|
||||||
if windowed_mode:
|
if windowed_mode:
|
||||||
window = pygame.display.set_mode(SCREEN_SIZE)
|
window = pygame.display.set_mode(screen_size)
|
||||||
else:
|
else:
|
||||||
window = pygame.display.set_mode(SCREEN_SIZE, pygame.FULLSCREEN)
|
window = pygame.display.set_mode(screen_size, pygame.FULLSCREEN)
|
||||||
|
|
||||||
# Starts the program with the surface 'steam_screen' as the default
|
# Starts the program with the surface 'steam_screen' as the default
|
||||||
surface = getattr(globals()['surfaces'], 'steam_screen').Surface(SCREEN_SIZE)
|
surface = getattr(globals()['surfaces'], 'steam_screen').Surface(screen_size)
|
||||||
running = True
|
running = True
|
||||||
while running:
|
while running:
|
||||||
clock.tick(FPS)
|
clock.tick(FPS)
|
||||||
@ -37,7 +45,7 @@ def main(windowed_mode=False):
|
|||||||
next_surface = surface.next_surface
|
next_surface = surface.next_surface
|
||||||
if next_surface not in VALID_SURFACES:
|
if next_surface not in VALID_SURFACES:
|
||||||
raise Exception('Given surface is not a valid surface!')
|
raise Exception('Given surface is not a valid surface!')
|
||||||
surface = getattr(globals()['surfaces'], next_surface).Surface(SCREEN_SIZE)
|
surface = getattr(globals()['surfaces'], next_surface).Surface(screen_size)
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
Loading…
Reference in New Issue
Block a user