-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgamegenerator.py
397 lines (368 loc) · 23.7 KB
/
gamegenerator.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
import os
import util
import shutil
import ntpath
import mister
from zipfile import ZipFile
from confconverter import ConfConverter
from mapping import Mapping
# contains all data and conf about generating a given game
class GameGenerator:
def __init__(self, game, gameDir, genre, outputDir, collectionVersion, useLongFolderNames, useGenreSubFolders, metadata, conversionType,
conversionConf, exoCollectionDir, fullnameToGameDir, scriptDir, keyb2joypad, defaultDosboxConf, logger):
self.game = game
self.gameDir = gameDir
self.collectionVersion = collectionVersion
self.genre = genre
self.outputDir = outputDir
self.useLongFolderNames = useLongFolderNames
self.useGenreSubFolders = useGenreSubFolders
self.metadata = metadata
self.conversionType = conversionType
self.exoCollectionDir = exoCollectionDir
self.logger = logger
self.fullnameToGameDir = fullnameToGameDir
self.conversionConf = conversionConf
self.scriptDir = scriptDir
self.confConverter = ConfConverter(self)
self.keyb2joypad = keyb2joypad
self.defaultDosboxConf = defaultDosboxConf
##### Utils functions ####
# Checks if collection is win3x or dos
def isWin3x(self):
return True # Due to too many bugs, always generate at root
# Handle this DOS games like win3x games: files must be at C: root for them to work
# cRootForcedGames = ['Screamer', 'SWTieCD', 'CyberMag', 'ActionSo', 'scomet', 'dw1', 'RAVAGER', 'EWJ2', 'MDK',
# 'lordorm2', 'kknd', 'BURGER', 'pice', 'RedBaron', 'rzork', 'samnmax', 'WormsRe', 'Tyrian', '7thguest']
# return self.game in cRootForcedGames or util.isWin3x(self.collectionVersion)
# Returns local parent output dir of the generated game
def getLocalParentOutputDir(self):
return os.path.join(self.outputDir, self.genre) if self.useGenreSubFolders else self.outputDir
# returns local game ouput dir of the generated game
def getLocalGameOutputDir(self):
return os.path.join(self.getLocalParentOutputDir(), self.gameDir)
# returns local game data output dir of the generated game
def getLocalGameDataOutputDir(self):
return self.getLocalGameOutputDir() if self.isWin3x() else os.path.join(
self.getLocalGameOutputDir(), self.game)
# returns emulation distribution game ouput dir of the generated game
def getEmulationGameOutputDir(self):
romsFolder = util.getRomsFolderPrefix(self.conversionType, self.conversionConf)
fileSeparator = "\\" if self.conversionType == util.retrobat else '/'
return romsFolder + fileSeparator + self.genre + fileSeparator + self.gameDir if self.useGenreSubFolders else romsFolder + fileSeparator + self.gameDir
################################
##### Generation functions #####
# Converts game
def convertGame(self):
self.__copyGameFiles__()
if self.collectionVersion == 'eXoDOS v6':
optionsDosboxConfPath = os.path.join(self.exoCollectionDir, 'eXo', 'emulators', 'dosbox', 'options.conf')
self.confConverter.processV6(self, self.defaultDosboxConf, optionsDosboxConfPath)
else:
self.confConverter.processV5(self)
self.__specificFixes()
self.__postConversion__()
# Copy game files and game dosbox.conf to output dir
def __copyGameFiles__(self):
self.logger.log(" copy dosbox conf")
# Copy dosbox.conf in game.pc
shutil.copy2(
os.path.join(util.getCollectionGamesConfDir(self.exoCollectionDir, self.collectionVersion), self.game,
"dosbox.conf"),
os.path.join(self.getLocalGameDataOutputDir(), "dosbox.conf"))
if os.path.exists(os.path.join(util.getCollectionGamesConfDir(self.exoCollectionDir, self.collectionVersion), self.game, "exception.bat")):
self.logger.log(' <WARNING> This game has specific exception launch configuration', self.logger.WARNING)
# Create blank file with full game name
f = open(os.path.join(self.getLocalGameOutputDir(), util.getCleanGameID(self.metadata, '.txt')), 'w',
encoding='utf8')
f.write(self.metadata.desc)
f.close()
# Handle first-game-of-a-serie dependencies
needsFirstGame = {
'roadware': ['Roadwar 2000 (1987).zip'], # @mount a .\Games\roadwar -t floppy
'eob2': ['Eye of the Beholder (1991).zip'], # mount a .\Games\eob1\ -t floppy
'bardtal2': ["Bard's Tale 1, The - Tales Of The Unknown (1987).zip"],
# mount a .\Games\bardtal1 -t floppy
'bardtal3': ["Bard's Tale 1, The - Tales Of The Unknown (1987).zip",
# mount a .\Games\bardtal1 -t floppy
"Bard's Tale 2, The - The Destiny Knight (1988).zip"],
# @mount b .\Games\bardtal2 -t floppy
'MM2': ['Might and Magic - Book 1 (1986).zip'], # mount a .\Games\MM1\ -t floppy
'vengexca': ['Spirit of Excalibur (1990).zip'], # @mount a .\Games\spirexc -t floppy
'WC2DLX': ['Wing Commander (1990).zip'], # mount a .\Games\WC\WING\GAMEDAT\
'darkdes2': ['Dark Designs I - Grelminars Staff (1990).zip'], # mount a .\Games\darkdes1 -t floppy
'whalvoy2': ["Whale's Voyage (1993).zip"] # @mount e .\Games\whalvoy1\WVCD
}
if self.game in needsFirstGame:
for previousGameZip in needsFirstGame[self.game]:
# unzip game dependency
with ZipFile(os.path.join(util.getCollectionGamesDir(self.exoCollectionDir, self.collectionVersion),
previousGameZip), 'r') as zipFile:
# Extract all the contents of zip file in current directory
self.logger.log(" unzipping previous game " + previousGameZip)
zipFile.extractall(
path=util.getCollectionGamesDir(self.exoCollectionDir, self.collectionVersion))
# copy its directory or directory part to the inside of the second game dir
shutil.move(os.path.join(util.getCollectionGamesDir(self.exoCollectionDir, self.collectionVersion),
self.fullnameToGameDir.get(os.path.splitext(previousGameZip)[0])),
os.path.join(self.getLocalGameOutputDir()))
######################################
def __specificFixes(self):
if self.game == 'SWTieCD':
self.logger.log('ouaich test')
# shutil.copy2(os.path.join(self.getLocalGameDataOutputDir(), 'TIE.CD'), self.getLocalGameOutputDir())
# os.mkdir(os.path.join(self.getLocalGameOutputDir(), 'TIECD'))
# shutil.copy2(os.path.join(self.getLocalGameDataOutputDir(), 'TIECD', 'FOPTION.CFG'), os.path.join(self.getLocalGameOutputDir(), 'TIECD'))
# shutil.copy2(os.path.join(self.getLocalGameDataOutputDir(), 'TIECD', 'IMUSE.INI'), os.path.join(self.getLocalGameOutputDir(), 'TIECD'))
# shutil.copy2(os.path.join(self.getLocalGameDataOutputDir(), 'TIECD', 'NEWACE7.TFR'), os.path.join(self.getLocalGameOutputDir(), 'TIECD'))
# shutil.copy2(os.path.join(self.getLocalGameDataOutputDir(), 'TIECD', 'NEWACE10.TFR'), os.path.join(self.getLocalGameOutputDir(), 'TIECD'))
# shutil.copy2(os.path.join(self.getLocalGameDataOutputDir(), 'TIECD', 'READ.ME'), os.path.join(self.getLocalGameOutputDir(), 'TIECD'))
# shutil.copy2(os.path.join(self.getLocalGameDataOutputDir(), 'TIECD', 'TOPACE7.TFR'), os.path.join(self.getLocalGameOutputDir(), 'TIECD'))
# shutil.copy2(os.path.join(self.getLocalGameDataOutputDir(), 'TIECD', 'TOPACE10.TFR'), os.path.join(self.getLocalGameOutputDir(), 'TIECD'))
###### Post-conversion functions #####
# Post-conversion operations for a given game for various conversion types
def __postConversion__(self):
if self.conversionType == util.retropie:
self.__postConversionForRetropie__()
elif self.conversionType in [util.esoteric, util.simplemenu]:
self.__postConversionForOpenDingux__()
elif self.conversionType == util.mister:
self.__postConversionForMister__()
elif self.conversionType == util.recalbox:
self.__postConversionForRecalbox__()
elif self.conversionType == util.batocera or self.conversionType == util.retrobat:
self.__postConversionForBatocera__()
elif self.conversionType == util.emuelec:
self.__postConversionForEmuelec__()
# Post-conversion for Emuelec for a given game
def __postConversionForEmuelec__(self):
self.logger.log(" Emuelec post-conversion")
# create pcdata and pc subfolders in outputdir
if not os.path.exists(os.path.join(self.outputDir, 'pcdata')):
os.mkdir(os.path.join(self.outputDir, 'pcdata'))
if not os.path.exists(os.path.join(self.outputDir, 'pc')):
os.mkdir(os.path.join(self.outputDir, 'pc'))
emuElecDataDir = os.path.join(self.outputDir, 'pcdata', self.genre) if self.useGenreSubFolders \
else os.path.join(self.outputDir, 'pcdata')
if not os.path.exists(emuElecDataDir):
os.mkdir(emuElecDataDir)
# move *.pc folder to pcdata folder
shutil.move(os.path.join(self.getLocalGameOutputDir()), emuElecDataDir)
os.rename(os.path.join(emuElecDataDir, self.game + '.pc'), os.path.join(emuElecDataDir, self.game))
# move *.bat *.map and *.cfg to pc/*.pc folder and rename *.cfg to dosbox-SDL2.conf
emuelecConfOutputDir = os.path.join(self.outputDir, 'pc', self.genre, self.gameDir) \
if self.useGenreSubFolders else os.path.join(self.outputDir, 'pc', self.gameDir)
if not os.path.exists(emuelecConfOutputDir):
os.makedirs(emuelecConfOutputDir)
open(os.path.join(emuelecConfOutputDir, util.getCleanGameID(self.metadata, '.bat')),'w').close()
shutil.move(os.path.join(emuElecDataDir, self.game, 'dosbox.bat'), emuelecConfOutputDir)
shutil.move(os.path.join(emuElecDataDir, self.game, 'dosbox.cfg'),
os.path.join(emuelecConfOutputDir, 'dosbox-SDL2.conf'))
shutil.copy2(
os.path.join(emuElecDataDir, self.game, util.getCleanGameID(self.metadata, '.txt')),
emuelecConfOutputDir)
if os.path.exists(os.path.join(emuElecDataDir, self.game, 'mapper.map')) and 'mapper' in self.conversionConf and self.conversionConf['mapper'] == 'mapper.map':
shutil.move(os.path.join(emuElecDataDir, self.game, 'mapper.map'), emuelecConfOutputDir)
# modify dosbox-SDL2.conf to add mount c /storage/roms/pcdata/game at the beginning of autoexec.bat
dosboxCfg = open(os.path.join(emuelecConfOutputDir, 'dosbox-SDL2.conf'), 'a')
# add mount c at end of dosbox.cfg
romsFolder = util.getRomsFolderPrefix(self.conversionType, self.conversionConf)
emuelecGameDir = romsFolder + "/" + self.genre + "/" + self.game if self.useGenreSubFolders else romsFolder + "/" + self.game
dosboxCfg.write("mount c " + emuelecGameDir + "\n")
dosboxCfg.write("c:\n")
# copy all instructions from dosbox.bat to end of dosbox.cfg
dosboxBat = open(os.path.join(emuelecConfOutputDir, "dosbox.bat"), 'r') # retroarch dosbox.bat
for cmdLine in dosboxBat.readlines():
# needs to get rid of '.pc' in mount instructions
dosboxCfg.write(cmdLine.replace('.pc',''))
# delete dosbox.bat
dosboxCfg.close()
dosboxBat.close()
# delete dosbox.bat
os.remove(os.path.join(emuelecConfOutputDir, "dosbox.bat"))
# Post-conversion for Recalbox for a given game
def __postConversionForRecalbox__(self):
self.logger.log(" Recalbox post-conversion")
if 'mapper' in self.conversionConf and self.conversionConf['mapper'] == 'p2k':
p2kTemplate = open(os.path.join(self.scriptDir, 'data', 'P2K.template.txt'), 'r')
p2kFile = open(os.path.join(self.getLocalParentOutputDir(), self.game + '.pc.p2k.cfg'), 'w',
encoding='utf-8')
for line in p2kTemplate.readlines():
p2kFile.write(line.replace('{GameID}', self.metadata.name))
p2kFile.close()
p2kTemplate.close()
if 'dosboxPureZip' in self.conversionConf and self.conversionConf['dosboxPureZip'] is True:
self.__postConversionDosboxPureZip()
def __postConversionForBatocera__(self):
self.logger.log(" Batocera/Retrobat post-conversion")
if 'mapper' in self.conversionConf and self.conversionConf['mapper'] == 'padto.keys':
Mapping(self.keyb2joypad.gamesConf, self.game, util.getCleanGameID(self.metadata, ''), self.getLocalGameOutputDir(),
self.conversionConf, self.collectionVersion, self.scriptDir, self.logger).mapForBatocera()
if 'dosboxPureZip' in self.conversionConf and self.conversionConf['dosboxPureZip'] is True:
self.__postConversionDosboxPureZip()
def __postConversionDosboxPureZip(self):
self.logger.log(" ReZip game for dosbox-pure")
# dosbox-pure full treatment
# combine dosbox.cfg and dosbox.bat into dosbox.conf
dosboxcfgpath = os.path.join(self.getLocalGameOutputDir(), 'dosbox.cfg')
dosboxbatpath = os.path.join(self.getLocalGameOutputDir(), 'dosbox.bat')
dosboxcfg = open(dosboxcfgpath, 'r', encoding='utf-8')
dosboxbat = open(dosboxbatpath, 'r', encoding="mbcs") # ANSI encoding
dosboxconf = open(os.path.join(self.getLocalGameOutputDir(), 'dosbox.conf'), 'w', encoding='utf-8')
dosboxcfglines = list(map(lambda l: l.rstrip(' \r\n'), dosboxcfg.readlines()))
dosboxcfglines = dosboxcfglines[:dosboxcfglines.index('[autoexec]')]
dosboxconf.write('\n'.join(dosboxcfglines) + '\n[autoexec]\n')
for line in dosboxbat.readlines():
if line.lower().startswith('mount'):
substLine = line.replace('mount ', 'subst ').replace('MOUNT ', 'SUBST').replace(self.getEmulationGameOutputDir(), 'c:').replace('"', '')
substLine = substLine.replace(' -t floppy', '').replace(' -t cdrom', '')
if not self.conversionType == util.retrobat:
substLine = substLine.replace('/', "\\")
self.logger.log(" " + line.rstrip('\n\r '))
self.logger.log(
" converted to " + substLine.rstrip('\n\r '))
dosboxconf.write(substLine)
else:
dosboxconf.write(line)
dosboxcfg.close()
dosboxbat.close()
dosboxconf.close()
# remove dosbox.cfg and dosbox.conf
os.remove(dosboxcfgpath)
os.remove(dosboxbatpath)
# move padto.keys up
gamename = '.'.join(os.path.splitext(self.gameDir)[:-1])
if self.conversionType == util.batocera or self.conversionType == util.retrobat:
padtokeys = os.path.join(self.getLocalGameOutputDir(), 'padto.keys')
if os.path.exists(padtokeys):
shutil.move(padtokeys, os.path.join(self.getLocalParentOutputDir(), gamename + '.keys'))
# TODO might have issues with empty directories
shutil.make_archive(os.path.join(self.getLocalParentOutputDir(), gamename), 'zip',
self.getLocalGameOutputDir())
shutil.rmtree(os.path.join(self.getLocalParentOutputDir(), self.gameDir))
# handle issues with dosbox.conf handling option ...
# handle padtokeys not taken into account / dosbox pure mapping not disabled through scroll lock
# Post-conversion for MiSTeR for a given game
def __postConversionForMister__(self):
self.logger.log(" MiSTer post-conversion")
# Remove any C: from dosbox.bat, rename to launch.bat, remove dosbox.cfg
os.remove(os.path.join(self.getLocalGameOutputDir(), 'dosbox.cfg'))
# Move CDs to cdgames/gamefolder and rename commands
mister.batsAndMounts(self)
shutil.move(os.path.join(self.getLocalGameOutputDir(), util.getCleanGameID(self.metadata, '.txt')),
os.path.join(self.getLocalGameOutputDir(), '2_About.txt'))
# Remove unused CDs
mister.removeUnusedCds(self.game, self.getLocalGameDataOutputDir(), self.logger)
# Remove any COMMAND.COM and CHOICE.EXE files, as they are not compatible with MiSTeR
if self.isWin3x():
tobeRemoved = [file for file in os.listdir(self.getLocalGameOutputDir()) if
file.lower() in ['command.com', 'choice.exe']]
for fileToRemove in tobeRemoved:
self.logger.log(" remove non-compatible file %s" % fileToRemove)
os.remove(os.path.join(self.getLocalGameOutputDir(), fileToRemove))
else:
tobeRemoved = [file for file in os.listdir(os.path.join(self.getLocalGameDataOutputDir())) if
file.lower() in ['command.com', 'choice.exe']]
for fileToRemove in tobeRemoved:
self.logger.log(" remove non-compatible file %s" % fileToRemove)
os.remove(os.path.join(self.getLocalGameDataOutputDir(), fileToRemove))
# Create about.jpg combining About.txt and pic of the game
if self.metadata.frontPic is not None:
cover = os.path.join(self.getLocalGameOutputDir(),
'5_About' + os.path.splitext(self.metadata.frontPic)[-1])
shutil.move(
os.path.join(self.outputDir, 'downloaded_images', ntpath.basename(self.metadata.frontPic)), cover)
aboutTxt = open(os.path.join(self.getLocalGameOutputDir(), '2_About.txt'), 'r', encoding='utf-8')
mister.text2png(self.scriptDir, aboutTxt.read(), cover,
os.path.join(self.getLocalGameOutputDir(), '2_About.jpg'))
aboutTxt.close()
os.remove(os.path.join(self.getLocalGameOutputDir(), '2_About.txt'))
os.remove(os.path.join(self.getLocalGameOutputDir(),
'5_About' + os.path.splitext(self.metadata.frontPic)[-1]))
misterCleanName = util.getCleanGameID(self.metadata, '').replace('+', '').replace("'", '').replace('µ',
'mu') \
.replace('¿', '').replace('é', 'e').replace('á', '').replace('ō', 'o').replace('#', '').replace('½', '') \
.replace('$', '').replace('à', 'a').replace('&', 'and').replace(',', '')
util.misterCleanNameToGameDir[misterCleanName] = self.game
if not os.path.exists(os.path.join(self.outputDir, 'games')):
os.mkdir(os.path.join(self.outputDir, 'games'))
if self.conversionConf['preExtractGames']:
# As the game will be pre-extracted, create empty zip, only containing a warning missing.bat file
warningBat = open(os.path.join(self.outputDir, 'games', 'missing.bat'), 'w')
warningBat.write('@echo off\nECHO You have used a pre-extracted games pack but the game data '
'files in your games directory are missing or corrupted .\n'
'Please regenerate your game data using the ExoDOSConverter,'
' drop the game folder into E:\\GAMES\\GAMENAME and re-launch the game.\n')
warningBat.close()
with ZipFile(os.path.join(self.outputDir, 'games', misterCleanName + '.zip'), 'w') as zf:
zf.write(os.path.join(self.outputDir, 'games', 'missing.bat'), 'missing.bat')
os.remove(os.path.join(self.outputDir, 'games', 'missing.bat'))
# Move game.pc folder to games-data
if not os.path.exists(os.path.join(self.outputDir, 'games-data')):
os.mkdir(os.path.join(self.outputDir, 'games-data'))
shutil.move(os.path.join(self.getLocalGameOutputDir()),
os.path.join(self.outputDir, 'games-data', misterCleanName))
else:
# Zip internal game dir to longgamename.zip
self.logger.log(' Rezipping game to %s.zip' % misterCleanName)
shutil.make_archive(os.path.join(self.getLocalParentOutputDir(), misterCleanName), 'zip',
self.getLocalGameOutputDir())
# Delete everything unrelated
shutil.rmtree(os.path.join(self.getLocalGameOutputDir()))
# Move archive to games folder
shutil.move(os.path.join(self.getLocalParentOutputDir(), misterCleanName + '.zip'),
os.path.join(self.outputDir, 'games'))
# Post-conversion for openDingux for a given game
def __postConversionForOpenDingux__(self):
self.logger.log(" opendingux post-conversion")
openDinguxPicDir = '.previews' if self.conversionType == util.esoteric else '.media'
# Copy image to opendingux img folder for game.pc
distPicPath = os.path.join(self.getLocalParentOutputDir(), openDinguxPicDir)
if not os.path.exists(distPicPath):
os.mkdir(distPicPath)
shutil.copy2(self.metadata.frontPic, os.path.join(distPicPath, self.game + '.pc.png'))
# Resize image
util.resize(os.path.join(distPicPath, self.game + '.pc.png'))
# Copy image to opendingux img folder for game.pc/dosbox.bat
dosboxBatPicPath = os.path.join(self.getLocalGameOutputDir(), openDinguxPicDir)
if not os.path.exists(dosboxBatPicPath):
os.mkdir(dosboxBatPicPath)
shutil.copy2(os.path.join(distPicPath, self.game + '.pc.png'),
os.path.join(dosboxBatPicPath, 'dosbox.png'))
if 'mapper' in self.conversionConf and self.conversionConf['mapper'] == 'mapper.map':
# Generate RG350 mapper
mapper = open(os.path.join(self.getLocalGameOutputDir(), "mapper.map"), 'w')
mapper.write('key_space "key 308"\n')
mapper.write('key_lshift "key 32"\n')
mapper.write('key_lctrl "key 304"\n')
mapper.write('key_lalt "key 306"\n')
mapper.write('key_esc "key 27"\n')
mapper.write('key_enter "key 13"\n')
mapper.write('key_up "key 273"\n')
mapper.write('key_down "key 274"\n')
mapper.write('key_right "key 275"\n')
mapper.write('key_left "key 276"\n')
mapper.write('key_n "key 9"\n')
mapper.write('key_y "key 8"\n')
mapper.close()
# Post-conversion for Retropie for a given game
def __postConversionForRetropie__(self):
self.logger.log(" retropie post-conversion")
dosboxCfg = open(os.path.join(self.getLocalGameOutputDir(), "dosbox.cfg"), 'a')
# add mount c at end of dosbox.cfg
romsFolder = util.getRomsFolderPrefix(self.conversionType, self.conversionConf)
retropieGameDir = romsFolder + "/" + self.genre + "/" + self.gameDir if self.useGenreSubFolders else romsFolder + "/" + self.gameDir
dosboxCfg.write("mount c " + retropieGameDir + "\n")
dosboxCfg.write("c:\n")
# copy all instructions from dosbox.bat to end of dosbox.cfg
dosboxBat = open(os.path.join(self.getLocalGameOutputDir(), "dosbox.bat"), 'r') # retroarch dosbox.bat
for cmdLine in dosboxBat.readlines():
dosboxCfg.write(cmdLine)
# delete dosbox.bat
dosboxCfg.close()
dosboxBat.close()
os.remove(os.path.join(self.getLocalGameOutputDir(), "dosbox.bat"))
# move dosbox.cfg to {game}.conf at top level
shutil.move(os.path.join(self.getLocalGameOutputDir(), "dosbox.cfg"),
os.path.join(self.getLocalParentOutputDir(), util.getCleanGameID(self.metadata, '.conf')))
########################################