-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
52 lines (35 loc) · 1.55 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import yaml
import pygame
class Config() :
## Define screen size
width_base = 1800
height_base = 1000
def __init__(self) :
## Load config file
with open("config.yaml") as config_data :
self.config_data = yaml.load(config_data)
## Read and set width, height and amplification factor
self.width = self.config_data["Config"]["Screen"]["width"]
self.height = self.config_data["Config"]["Screen"]["height"]
if self.config_data["Config"]["Screen"]["width"] < self.config_data["Config"]["Screen"]["height"] :
self.factor = self.width/self.width_base
else :
self.factor = self.height/self.height_base
self.xfactor = self.width/self.width_base
## Return config file var
def get_config_data(self) :
## Load config file
with open("config.yaml") as config_data :
self.config_data = yaml.load(config_data)
return self.config_data
########## GET SCREEN METHODE ##########
def get_screen_mode(self) :
## FULLSCREEN
if self.config_data["Config"]["Screen"]["state"] == 'FULLSCREEN' :
return pygame.FULLSCREEN | pygame.HWSURFACE | pygame.DOUBLEBUF
elif self.config_data["Config"]["Screen"]["state"] == 'WINDOWED' :
return pygame.HWSURFACE | pygame.DOUBLEBUF
## If the entry is not reconise
else :
## Return the value
return eval(self.config_data["Config"]["Screen"]["state"])