-
Notifications
You must be signed in to change notification settings - Fork 2
/
Converter.py
109 lines (85 loc) · 3.43 KB
/
Converter.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/python3
import os
import sys
import shutil
from config import Config
import naive_parser
import makeNameList
import flagconvert
import localisation
import universe
import events
import logToFile
class Converter:
def __init__(self):
Config().Init()
def ConvertEverything(self):
self.makeFolders()
self.getUniverse()
self.convertFlags()
self.convertNameLists()
self.convertLocalisation()
self.convertEvents()
def CopyMod(self):
createdModPath = Config().getOutputPath()
finalPath = Config().getFinalPath()
createdModFile = Config().getOutputModFile()
finalModFile = Config().getFinalModFile()
if not finalPath:
return
shutil.rmtree(finalPath, True)
print("Copying '" + createdModPath + "' to '" + finalPath + "'...")
shutil.copytree(createdModPath, finalPath)
print("Copying '" + createdModFile + "' to '", finalModFile + "'...")
shutil.copyfile(createdModFile, finalModFile)
def makeFolders(self):
print("Laying out folder structure...")
converterDir = Config().getConverterDir()
shutil.rmtree(Config().getOutputPath(), True)
shutil.copytree(Config().getBaseModPath(), Config().getOutputPath())
def getUniverse(self):
print("Creating the universe...")
self.universe = universe.Universe(Config().getSaveData())
print("Establishing history...")
self.universe.Load()
def convertFlags(self):
hoi4flagpath = "gfx/flags/"
topNations = Config().getParser().getTopNations()
for topNation in topNations:
print("Creating flag for " + topNation.tag + "...")
sourcepath = hoi4flagpath + topNation.tag + "_" + topNation.government + ".tga"
sourceFlagTga = Config().getModdedHoi4File(sourcepath)
if not sourceFlagTga:
basesourcepath = hoi4flagpath + topNation.tag + ".tga"
print("WARNING: Could not find \"" + sourcepath + "\". Falling back to \"" + basesourcepath + "\".")
sourceFlagTga = Config().getModdedHoi4File(basesourcepath)
destFlagFolder = Config().getOutputPath() + "flags/convertedflags/"
flagconvert.CompileFlag(sourceFlagTga, destFlagFolder)
def convertNameLists(self):
topNations = Config().getParser().getTopNations()
for topNation in topNations:
print("Creating name list for " + topNation.tag + "...")
destNameListFolder = "outputMod/common/name_lists/"
makeNameList.MakeNameList(topNation.tag, destNameListFolder)
def convertLocalisation(self):
print("Converting localisation...")
savefile = Config().getSaveData()
parser = Config().getParser()
hoi4path = Config().getHoi4Path()
localiser = localisation.Localisation(self.universe)
print("Writing localisation...")
localiser.writeLocalisation()
localiser.writeSyncedLocalisation()
def convertEvents(self):
print("Creating events...")
savefile = Config().getSaveData()
parser = Config().getParser()
hoi4path = Config().getHoi4Path()
self.events = events.Events(self.universe)
self.events.makeEvents()
if __name__ == "__main__":
print("BEGINNING CONVERSION")
converter = Converter()
converter.ConvertEverything()
converter.CopyMod()
print("ALL DONE!")