-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextureReplacment.py
43 lines (31 loc) · 1.12 KB
/
TextureReplacment.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
#!/usr/bin/env python3
import os.path
'''
utility for substituing some textures according to the resolution
by Juan S. Marquerie
'''
REPLACEMENTLIST_DIR = 'configs/substitution_list.txt'
REPLACEMENTLIST = None
def load_replacements(file_dir = REPLACEMENTLIST_DIR):
global REPLACEMENTLIST
REPLACEMENTLIST = {}
with open(os.path.normpath(file_dir), 'r') as file_replacements:
lines = file_replacements.readlines()
for line in lines:
if line[0] == '#':
continue # a comment
tmp = line.rsplit()
if not tmp[0] in REPLACEMENTLIST:
REPLACEMENTLIST[tmp[0]] = {}
REPLACEMENTLIST[tmp[0]][tmp[1]] = tmp[2]
def get_replacement_texture(resolution, text_name):
global REPLACEMENTLIST
if not resolution in REPLACEMENTLIST:
if not text_name in REPLACEMENTLIST[resolution]:
return None
return REPLACEMENTLIST[resolution][text_name]
def get_replacement_list(resolution):
global REPLACEMENTLIST
if not resolution in REPLACEMENTLIST:
return None
return REPLACEMENTLIST[resolution]