#!/usr/bin/env python3

"""
Given a WAD, it'll detect if it's for DOOM1 or 2 (based on map names) and
run GZDoom with the right iwad arg
"""

import argparse
import os
import wad
import subprocess
import dero_config

parser = argparse.ArgumentParser()
parser.add_argument('--pwad', type=str, required=True, help='Path to the PWAD to play')
parser.add_argument('--nomons', action='store_true', default=False)
parser.add_argument('--voxels', action=argparse.BooleanOptionalAction, default=True)
parser.add_argument('--map', type=str, default=None)
parser.add_argument('--savegame', type=str, default=None)
args = parser.parse_args()

def main():
  iwad = dero_config.DOOM2_WAD_PATH

  for name in wad.enum_map_names(args.pwad):
    print(f'First map name: {name}')
    if name[0] == 'E' and name[2] == 'M':
        print('..looks like DOOM 1')
        iwad = dero_config.DOOM1_WAD_PATH
    else:
        print('..looks like DOOM 2')
    break

  print(f'Assumed IWAD: {os.path.basename(iwad)}')
  pwad_dir = os.path.dirname(args.pwad)

  # Find all WADs and PK3's in this folder and load them.
  wadpaths = []
  for file in os.listdir(pwad_dir):
    if file.lower().endswith('.wad') or file.lower().endswith('.pk3'):
      wadpaths.append(os.path.join(pwad_dir, file))

  if args.voxels:
    wadpaths.append('/Users/stevenan/dooming/wads/cheello_voxels.zip')

  gzdoom_path = '/Applications/GZDoom.app/Contents/MacOS/gzdoom'
  call_args = [gzdoom_path] + wadpaths + [
      '-iwad', iwad,
      '-savedir', pwad_dir,
      '-shotdir', pwad_dir,
      ]

  if args.nomons: call_args.append('-nomonsters')
  if args.map: call_args += ['+map', args.map, '+skill', '1']
  if args.savegame: call_args += ['-loadgame', args.savegame]

  print('final args:', call_args)
  subprocess.check_call(call_args)

if __name__ == '__main__':
  main()

6ea55426fcd24db36847baa5656080052f234554
<mask token>


def main():
    iwad = dero_config.DOOM2_WAD_PATH
    for name in wad.enum_map_names(args.pwad):
        print(f'First map name: {name}')
        if name[0] == 'E' and name[2] == 'M':
            print('..looks like DOOM 1')
            iwad = dero_config.DOOM1_WAD_PATH
        else:
            print('..looks like DOOM 2')
        break
    print(f'Assumed IWAD: {os.path.basename(iwad)}')
    pwad_dir = os.path.dirname(args.pwad)
    wadpaths = []
    for file in os.listdir(pwad_dir):
        if file.lower().endswith('.wad') or file.lower().endswith('.pk3'):
            wadpaths.append(os.path.join(pwad_dir, file))
    if args.voxels:
        wadpaths.append('/Users/stevenan/dooming/wads/cheello_voxels.zip')
    gzdoom_path = '/Applications/GZDoom.app/Contents/MacOS/gzdoom'
    call_args = [gzdoom_path] + wadpaths + ['-iwad', iwad, '-savedir',
        pwad_dir, '-shotdir', pwad_dir]
    if args.nomons:
        call_args.append('-nomonsters')
    if args.map:
        call_args += ['+map', args.map, '+skill', '1']
    if args.savegame:
        call_args += ['-loadgame', args.savegame]
    print('final args:', call_args)
    subprocess.check_call(call_args)


<mask token>

<mask token>
parser.add_argument('--pwad', type=str, required=True, help=
    'Path to the PWAD to play')
parser.add_argument('--nomons', action='store_true', default=False)
parser.add_argument('--voxels', action=argparse.BooleanOptionalAction,
    default=True)
parser.add_argument('--map', type=str, default=None)
parser.add_argument('--savegame', type=str, default=None)
<mask token>


def main():
    iwad = dero_config.DOOM2_WAD_PATH
    for name in wad.enum_map_names(args.pwad):
        print(f'First map name: {name}')
        if name[0] == 'E' and name[2] == 'M':
            print('..looks like DOOM 1')
            iwad = dero_config.DOOM1_WAD_PATH
        else:
            print('..looks like DOOM 2')
        break
    print(f'Assumed IWAD: {os.path.basename(iwad)}')
    pwad_dir = os.path.dirname(args.pwad)
    wadpaths = []
    for file in os.listdir(pwad_dir):
        if file.lower().endswith('.wad') or file.lower().endswith('.pk3'):
            wadpaths.append(os.path.join(pwad_dir, file))
    if args.voxels:
        wadpaths.append('/Users/stevenan/dooming/wads/cheello_voxels.zip')
    gzdoom_path = '/Applications/GZDoom.app/Contents/MacOS/gzdoom'
    call_args = [gzdoom_path] + wadpaths + ['-iwad', iwad, '-savedir',
        pwad_dir, '-shotdir', pwad_dir]
    if args.nomons:
        call_args.append('-nomonsters')
    if args.map:
        call_args += ['+map', args.map, '+skill', '1']
    if args.savegame:
        call_args += ['-loadgame', args.savegame]
    print('final args:', call_args)
    subprocess.check_call(call_args)


if __name__ == '__main__':
    main()

<mask token>
parser = argparse.ArgumentParser()
parser.add_argument('--pwad', type=str, required=True, help=
    'Path to the PWAD to play')
parser.add_argument('--nomons', action='store_true', default=False)
parser.add_argument('--voxels', action=argparse.BooleanOptionalAction,
    default=True)
parser.add_argument('--map', type=str, default=None)
parser.add_argument('--savegame', type=str, default=None)
args = parser.parse_args()


def main():
    iwad = dero_config.DOOM2_WAD_PATH
    for name in wad.enum_map_names(args.pwad):
        print(f'First map name: {name}')
        if name[0] == 'E' and name[2] == 'M':
            print('..looks like DOOM 1')
            iwad = dero_config.DOOM1_WAD_PATH
        else:
            print('..looks like DOOM 2')
        break
    print(f'Assumed IWAD: {os.path.basename(iwad)}')
    pwad_dir = os.path.dirname(args.pwad)
    wadpaths = []
    for file in os.listdir(pwad_dir):
        if file.lower().endswith('.wad') or file.lower().endswith('.pk3'):
            wadpaths.append(os.path.join(pwad_dir, file))
    if args.voxels:
        wadpaths.append('/Users/stevenan/dooming/wads/cheello_voxels.zip')
    gzdoom_path = '/Applications/GZDoom.app/Contents/MacOS/gzdoom'
    call_args = [gzdoom_path] + wadpaths + ['-iwad', iwad, '-savedir',
        pwad_dir, '-shotdir', pwad_dir]
    if args.nomons:
        call_args.append('-nomonsters')
    if args.map:
        call_args += ['+map', args.map, '+skill', '1']
    if args.savegame:
        call_args += ['-loadgame', args.savegame]
    print('final args:', call_args)
    subprocess.check_call(call_args)


if __name__ == '__main__':
    main()

<mask token>
import argparse
import os
import wad
import subprocess
import dero_config
parser = argparse.ArgumentParser()
parser.add_argument('--pwad', type=str, required=True, help=
    'Path to the PWAD to play')
parser.add_argument('--nomons', action='store_true', default=False)
parser.add_argument('--voxels', action=argparse.BooleanOptionalAction,
    default=True)
parser.add_argument('--map', type=str, default=None)
parser.add_argument('--savegame', type=str, default=None)
args = parser.parse_args()


def main():
    iwad = dero_config.DOOM2_WAD_PATH
    for name in wad.enum_map_names(args.pwad):
        print(f'First map name: {name}')
        if name[0] == 'E' and name[2] == 'M':
            print('..looks like DOOM 1')
            iwad = dero_config.DOOM1_WAD_PATH
        else:
            print('..looks like DOOM 2')
        break
    print(f'Assumed IWAD: {os.path.basename(iwad)}')
    pwad_dir = os.path.dirname(args.pwad)
    wadpaths = []
    for file in os.listdir(pwad_dir):
        if file.lower().endswith('.wad') or file.lower().endswith('.pk3'):
            wadpaths.append(os.path.join(pwad_dir, file))
    if args.voxels:
        wadpaths.append('/Users/stevenan/dooming/wads/cheello_voxels.zip')
    gzdoom_path = '/Applications/GZDoom.app/Contents/MacOS/gzdoom'
    call_args = [gzdoom_path] + wadpaths + ['-iwad', iwad, '-savedir',
        pwad_dir, '-shotdir', pwad_dir]
    if args.nomons:
        call_args.append('-nomonsters')
    if args.map:
        call_args += ['+map', args.map, '+skill', '1']
    if args.savegame:
        call_args += ['-loadgame', args.savegame]
    print('final args:', call_args)
    subprocess.check_call(call_args)


if __name__ == '__main__':
    main()

#!/usr/bin/env python3

"""
Given a WAD, it'll detect if it's for DOOM1 or 2 (based on map names) and
run GZDoom with the right iwad arg
"""

import argparse
import os
import wad
import subprocess
import dero_config

parser = argparse.ArgumentParser()
parser.add_argument('--pwad', type=str, required=True, help='Path to the PWAD to play')
parser.add_argument('--nomons', action='store_true', default=False)
parser.add_argument('--voxels', action=argparse.BooleanOptionalAction, default=True)
parser.add_argument('--map', type=str, default=None)
parser.add_argument('--savegame', type=str, default=None)
args = parser.parse_args()

def main():
  iwad = dero_config.DOOM2_WAD_PATH

  for name in wad.enum_map_names(args.pwad):
    print(f'First map name: {name}')
    if name[0] == 'E' and name[2] == 'M':
        print('..looks like DOOM 1')
        iwad = dero_config.DOOM1_WAD_PATH
    else:
        print('..looks like DOOM 2')
    break

  print(f'Assumed IWAD: {os.path.basename(iwad)}')
  pwad_dir = os.path.dirname(args.pwad)

  # Find all WADs and PK3's in this folder and load them.
  wadpaths = []
  for file in os.listdir(pwad_dir):
    if file.lower().endswith('.wad') or file.lower().endswith('.pk3'):
      wadpaths.append(os.path.join(pwad_dir, file))

  if args.voxels:
    wadpaths.append('/Users/stevenan/dooming/wads/cheello_voxels.zip')

  gzdoom_path = '/Applications/GZDoom.app/Contents/MacOS/gzdoom'
  call_args = [gzdoom_path] + wadpaths + [
      '-iwad', iwad,
      '-savedir', pwad_dir,
      '-shotdir', pwad_dir,
      ]

  if args.nomons: call_args.append('-nomonsters')
  if args.map: call_args += ['+map', args.map, '+skill', '1']
  if args.savegame: call_args += ['-loadgame', args.savegame]

  print('final args:', call_args)
  subprocess.check_call(call_args)

if __name__ == '__main__':
  main()
