-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconvertwarps.py
executable file
·47 lines (39 loc) · 1.7 KB
/
convertwarps.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
#!/usr/bin/python3
import glob,os,generate
LABELS=['Enter','Warp','To','The','Travel','Portal to','Return','Nether','Brood Hive','Slavers','Frosted Hills','Arena of Slaughter','Rotting Crypt','Abandoned Sawmill','Reeking Cellar',"Vyrax's Tower","Locked Vyrax's Tower",'Plunder Cove','Faceless King','Elemental Oasis','3 sisters']
class ReplaceDungeon(generate.Replace):
def __init__(self):
self.pattern='<STRING>DUNGEON:'
self.replacement=f'\t\t\t\t\t\t<STRING>DUNGEON:ESTHERIANCITY\n'#probably unnecessary to be uppercase, but originals were this way
class ReplaceDungeonName(generate.Replace):
def __init__(self):
self.pattern='<STRING>DUNGEON NAME:'
self.replacement=f'\t\t\t\t\t\t<STRING>DUNGEON NAME:EstherianCity\n'
class ReplaceLabel(generate.Replace):
def __init__(self,label):
self.pattern=f'<STRING>TEXT:{label}'
self.replacement=f'\t\t\t\t\t\t<STRING>TEXT:Return To Town\n'
warpers=set()
dungeons=set()
r=[ReplaceDungeon(),ReplaceDungeonName()]+[ReplaceLabel(l) for l in LABELS]
def scan(query):
for path in glob.glob(query,recursive=True):
try:
with open(path,encoding='utf-16') as f:
for l in f.readlines():
l=l.lower()
if 'warper' in l:
warpers.add(path)
if '<string>dungeon name:' in l:
dungeons.add(path)
except:
continue
def translate(path):
return './'+path.replace(generate.REFERENCE,'')
if __name__=='__main__':
scan(f'{generate.REFERENCE}/MEDIA/LAYOUTS/**/*.LAYOUT')
scan(f'{generate.REFERENCE}/MEDIA/LEVELSETS/PROPS/**/*.LAYOUT')
for w in sorted(warpers):
if w in dungeons:
w=translate(w)
generate.modify(w,os.path.basename(w),replace=r,strata='',extension='')