mikew / wadpunk

Cross-platform app to help you manage your WAD library and launch Source Ports like GZDoom.
4 stars 0 forks source link

Specify type of source port #74

Closed mikew closed 6 months ago

mikew commented 6 months ago

While WADPunk points people towards GZDoom, it technically supports any source port: all it's doing is building a command to execute.

I've used GZDoom, Chocolate Doom, and Eternity Engine.

There's a couple of ways of doing this (at least):

Method 1

interface SourcePortType {
  description: string
  iwadFlag: string
  fileFlag?: string
  configFileFlag?: string
  saveDirFlag?: string
}

const gzdoom: SourcePortType = {
  description: "...",
  iwadFlag: "-iwad",
  fileFlag: "-file",
  configFileFlag: "-config",
  saveDirFlag: "-savedir"
}

const eternityEngine: SourcePortType = {
  description: "...",
  iwadFlag: "-iwad",
  fileFlag: "-file",
  configFileFlag: "-config",
  saveDirFlag: "-save"
}

...

Method 2

interface SourcePortType {
  supportsCustomConfig: boolean
  supportsSaveDir: boolean

  buildCommand: (args: {
    executable: string
    iwad: string
    files: string[]
    useCustomConfig: boolean
    gameMetaDir: string
  }): string[]
}

const gzdoom: SourcePortType = {
  supportsCustomConfig: true
  supportsSaveDir: true

  buildCommand(args) {
    const command = [
      args.executable,
      '-iwad', args.iwad,
      '-file', ...files,
      ...(args.useCustomConfig ? ['-config', path.join(args.gameMetaDir, 'config.ini')] : [])
      '-saveDirFlag', path.join(args.gameMetaDir, 'saves')
    ]

    return command
  }
}

What I would like from the chosen approach is:

I like the approach with buildCommand, as that can probably take whatever args are passed to startGame()