Skip to content

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.

883 B
Raw Blame
export type InstallTab = 'installation' | 'components' | 'dlcs' | 'wine'

export type DlcMasterState = 'all' | 'partial' | 'none'

export function getVisibleInstallTabs({
  hasComponents,
  hasDlcs,
  hasWine
}: {
  hasComponents: boolean
  hasDlcs: boolean
  hasWine: boolean
}): InstallTab[] {
  return [
    'installation',
    ...(hasComponents ? (['components'] as const) : []),
    ...(hasDlcs ? (['dlcs'] as const) : []),
    ...(hasWine ? (['wine'] as const) : [])
  ]
}

export function getDlcMasterState(
  selected: string[],
  all: string[]
): DlcMasterState {
  const selectedCount = all.filter((id) => selected.includes(id)).length

  if (selectedCount === 0) {
    return 'none'
  }

  return selectedCount === all.length ? 'all' : 'partial'
}

export function toggleAllDlcs(state: DlcMasterState, all: string[]): string[] {
  return state === 'all' ? [] : [...all]
}