Skip to content

Commit

Permalink
Fixes Config Path on Windows and Mac and add minimize to tray on laun…
Browse files Browse the repository at this point in the history
…ch setting (Heroic-Games-Launcher#1059)

* fix: wrong config path on windows and mac

* chore: update version

* feat: add minimize on launch setting

* i18n: updated keys

* fix: legendary config path

* chore: remove unecessary slash on some paths

* chore: removed unecessary quotes

* chore: pr comments

* fix: workflow

* fix: invisible chracter
  • Loading branch information
flavioislima authored Mar 8, 2022
1 parent cbed5ca commit e2642e2
Show file tree
Hide file tree
Showing 40 changed files with 150 additions and 34 deletions.
59 changes: 48 additions & 11 deletions .github/workflows/build-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,64 @@ on:
workflow_dispatch:

jobs:
build:
build_windows:
runs-on: windows-latest
steps:
- name: Checkout repository.
uses: actions/checkout@v2
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install modules.
continue-on-error: true
run: npm i --legacy-peer-deps
- name: Build artifacts.
continue-on-error: true
run: npm run dist-win portable
- name: Upload EXE.
uses: actions/upload-artifact@v2
with:
name: win-portable
path: dist/Heroic*.exe
retention-days: 14
build_linux:
runs-on: ubuntu-latest
steps:
- name: Checkout repository.
uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '16'
- name: Install modules.
run: yarn
- name: Build 'src'.
run: yarn build
- name: Build 'electron'.
run: yarn build-electron
- name: Build artifacts.
run: |
sudo apt-get install --no-install-recommends -y libarchive-tools libopenjp2-tools
yarn dist appimage --publish=never
run: yarn dist appimage --publish=never
- name: Upload AppImage.
uses: actions/upload-artifact@v2
with:
name: linux-appimage
path: dist/Heroic-*.AppImage
retention-days: 7
retention-days: 14
build_mac:
runs-on: macos-11
steps:
- name: Checkout repository.
uses: actions/checkout@v2
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install modules.
continue-on-error: true
run: yarn
- name: Build artifacts.
continue-on-error: true
run: yarn dist-mac --publish=never
- name: Upload DMG.
uses: actions/upload-artifact@v2
with:
name: mac-dmg
path: dist/Heroic*.dmg
retention-days: 14
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Build
on:
push:
branches: [main]
tags:
- '!v*'
workflow_dispatch:

jobs:
Expand Down
1 change: 1 addition & 0 deletions electron/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ class GlobalConfigV0 extends GlobalConfig {
defaultWinePrefix: `${home}/Games/Heroic/Prefixes`,
language: 'en',
maxWorkers: 0,
minimizeOnLaunch: false,
nvidiaPrime: false,
otherOptions: '',
showUnrealMarket: false,
Expand Down
34 changes: 19 additions & 15 deletions electron/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,32 @@ const isLinux = platform() == 'linux'
const isFlatpak = Boolean(env.FLATPAK_ID)
const currentGameConfigVersion: GameConfigVersion = 'v0'
const currentGlobalConfigVersion: GlobalConfigVersion = 'v0'

const flatPakHome = env.XDG_DATA_HOME?.replace('/data', '') || homedir()
const home = isFlatpak ? flatPakHome : homedir()
const configFolder = app.getPath('appData')
const legendaryConfigPath = `${configFolder}/legendary`
const heroicFolder = `${configFolder}/heroic`
const legendaryConfigPath = isLinux
? join(configFolder, 'legendary')
: join(home, '.config', 'legendary')
const heroicFolder = join(configFolder, 'heroic')
const heroicConfigPath = join(heroicFolder, 'config.json')
const heroicGamesConfigPath = join(heroicFolder, 'GamesConfig')
const heroicToolsPath = join(heroicFolder, 'tools')
const heroicIconFolder = join(heroicFolder, 'icons')
const userInfo = join(legendaryConfigPath, 'user.json')
const heroicInstallPath = join(homedir(), 'Games', 'Heroic')

const { currentLogFile: currentLogFile, lastLogFile: lastLogFile } =
createNewLogFileAndClearOldOnces()
const heroicConfigPath = `${heroicFolder}/config.json`
const heroicGamesConfigPath = `${heroicFolder}/GamesConfig/`
const heroicToolsPath = `${heroicFolder}/tools`
const heroicIconFolder = `${heroicFolder}/icons`
const userInfo = `${legendaryConfigPath}/user.json`
const heroicInstallPath = isWindows
? `${homedir()}\\Games\\Heroic`
: `${homedir()}/Games/Heroic`

const legendaryBin = getLegendaryBin()
const gogdlBin = getGOGdlBin()
const icon = fixAsarPath(join(__dirname, '/icon.png'))
const iconDark = fixAsarPath(join(__dirname, '/icon-dark.png'))
const iconLight = fixAsarPath(join(__dirname, '/icon-light.png'))
const installed = `${legendaryConfigPath}/installed.json`
const libraryPath = `${legendaryConfigPath}/metadata/`

const icon = fixAsarPath(join(__dirname, 'icon.png'))
const iconDark = fixAsarPath(join(__dirname, 'icon-dark.png'))
const iconLight = fixAsarPath(join(__dirname, 'icon-light.png'))
const installed = join(legendaryConfigPath, 'installed.json')
const libraryPath = join(legendaryConfigPath, 'metadata')
const steamCompatFolder: string = getSteamCompatFolder()
const fallBackImage = 'fallback'
const epicLoginUrl =
Expand Down
10 changes: 9 additions & 1 deletion electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,9 @@ ipcMain.handle(
const game = appName.split(' ')[0]
const gameData = await Game.get(game, runner).getGameInfo()
const { title } = gameData
const MAX_RECENT_GAMES = GlobalConfig.get().config.maxRecentGames || 5
const { minimizeOnLaunch, maxRecentGames: MAX_RECENT_GAMES = 5 } =
await GlobalConfig.get().getSettings()

const startPlayingDate = new Date()

if (!tsStore.has(game)) {
Expand All @@ -751,9 +753,14 @@ ipcMain.handle(
store.set('games.recent', [{ game, title: title }])
}

if (minimizeOnLaunch) {
mainWindow.hide()
}

return Game.get(appName, runner)
.launch(launchArguments)
.then(async ({ stderr, command, gameSettings }: LaunchResult) => {
mainWindow.show()
const finishedPlayingDate = new Date()
tsStore.set(`${game}.lastPlayed`, finishedPlayingDate)
const sessionPlayingTime =
Expand Down Expand Up @@ -796,6 +803,7 @@ ipcMain.handle(
return stderr
})
.catch(async (exception) => {
mainWindow.show()
const stderr = `${exception.name} - ${exception.message}`
errorHandler({ error: { stderr, stdout: '' } })
writeFile(
Expand Down
1 change: 1 addition & 0 deletions electron/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface AppSettings {
maxRecentGames: number
maxSharpness: number
maxWorkers: number
minimizeOnLaunch: boolean
nvidiaPrime: boolean
offlineMode: boolean
otherOptions: string
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "heroic",
"version": "2.2.2",
"version": "2.2.3",
"private": true,
"main": "public/main.js",
"homepage": "./",
Expand Down
1 change: 1 addition & 0 deletions public/locales/bg/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Играно наскоро за показване",
"maxworkers": "Максимален брой работни процеси при сваляне",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Пускане на играта в режим „извън линия“",
"primerun": "Включване на „Nvidia Prime Render“",
"resizableBar": "Включване на „Resizable BAR“ (Само за NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ca/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Jugats recentment a mostrar",
"maxworkers": "Nombre màxim de Workers en baixar",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Executa el joc sense connexió",
"primerun": "Activa l'Nvidia Prime Render",
"resizableBar": "Activa el BAR redimensionable (només amb NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Max. nedávno hraných her k zobrazení",
"maxworkers": "Maximální počet vláken při stahování",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Spustit hru offline",
"primerun": "Povolení vykreslování Nvidia Prime",
"resizableBar": "Používat Resizable BAR (pouze s NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Zuletzt gespielte Spiele anzeigen",
"maxworkers": "Maximale Anzahl von Prozessen zum gleichzeitigem Herunterladen",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Spiel offline ausführen",
"primerun": "Nvidia Prime Render aktivieren",
"resizableBar": "Resizable BAR aktivieren (nur NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/el/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Πρόσφατα Παιχνίδια για Προβολή",
"maxworkers": "Μέγιστος αριθμός εργατών κατά την λήψη",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Τρέξιμο παιχνιδιού εκτός δικτύου",
"primerun": "Ενεργοποίηση Nvidia Prime Render",
"resizableBar": "Ενεργοποίηση Μεταβλητού BAR (NVIDIA RTX 30xx μόνο)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Played Recently to Show",
"maxworkers": "Maximum Number of Workers when downloading",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Run Game Offline",
"primerun": "Enable Nvidia Prime Render",
"resizableBar": "Enable Resizable BAR (NVIDIA RTX 30xx only)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Jugado recientemente para mostrar",
"maxworkers": "Número máximo de descargas",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Ejecutar juego sin conexión",
"primerun": "Habilitar Nvidia Prime Render",
"resizableBar": "Habilitar Resizable Bar (NVIDIA RTX 30xx únicamente)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/et/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Hiljuti mängitud mänge, mida näidata",
"maxworkers": "Töötajate maksimaalne arv allalaadimisel",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Käivita mäng võrguühenduseta",
"primerun": "Luba Nvidia Prime Render",
"resizableBar": "Luba muudetav BAR (ainult NVIDIA RTX 30xx)",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/fa/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "اخیرا بازی شده برای نمایش",
"maxworkers": "بیسترین تعداد ورکر هنگام دانلود",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "اجرای آفلاین بازی",
"primerun": "فعالسازی Nvidia Prime Render",
"resizableBar": "فعالسازی Resizable BAR (فقط محصولات NVIDIA RTX 30xx)",
Expand Down Expand Up @@ -326,7 +327,7 @@
"wine": {
"manager": {
"error": "نمیتوان در این زمان نسخههای Wine/Proton را به دست آورد.",
"link": "مدیریت Wine",
"link": "مدیریت Wine",
"title": "مدیریت Wine (آزمایشی)",
"unzipping": "در حال خارج کردن از حالت فشرده"
}
Expand Down
1 change: 1 addition & 0 deletions public/locales/fi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Viimeisten pelien näytetty lukumäärä",
"maxworkers": "Työntekijöiden enimmäismäärä ladattaessa",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Käynnistä peli offline-tilassa",
"primerun": "Ota käyttöön Nvidia Prime Render",
"resizableBar": "Ota käyttöön Resizable BAR (Vain NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Jeux récents à afficher",
"maxworkers": "Nombre Maximum de Workers pendant le téléchargement",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Lancer le jeu hors ligne",
"primerun": "Activer Nvidia Prime Render",
"resizableBar": "Activer Resizable BAR (NVIDIA RTX 30xx seulement)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/gl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Recent Games to Show",
"maxworkers": "",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Executar xogo sen conexión",
"primerun": "Activar renderizado de Nvidia Prime",
"resizableBar": "Activar Resizable Bar (só NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/hr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Recent Games to Show",
"maxworkers": "",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "",
"primerun": "Enable Nvidia Prime Render",
"resizableBar": "Enable Resizable BAR (NVIDIA RTX only)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/hu/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Nemrég játszottak megjelenítése",
"maxworkers": "Maximum dolgozók száma letöltéskor",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Játék futtatása offline",
"primerun": "Nvidia Prime Render engedélyezése",
"resizableBar": "Átméretezhető BAR engedélyezése (csak NVIDIA RTX 30xx kártyával)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/id/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Played Recently to Show",
"maxworkers": "",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "",
"primerun": "Enable Nvidia Prime Render",
"resizableBar": "Enable Resizable BAR (NVIDIA RTX only)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Giocati di recente da mostrare",
"maxworkers": "Numero massimo di connessioni durante il download",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Avvia il gioco in modalità offline",
"primerun": "Attiva Nvidia Prime Render",
"resizableBar": "Abilita Resizable BAR (solo NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "表示する最近のゲーム",
"maxworkers": "ダウンロード時のワーカーの最大数",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "ゲームをオフラインで実行する",
"primerun": "Nvidia Prime Renderを有効にする",
"resizableBar": "サイズ変更可能なBARを有効にする(NVIDIA RTX 30xxのみ)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "표시할 최근 플레이한 게임",
"maxworkers": "다운로드할 때 최대 워커 개수",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "게임 오프라인으로 실행",
"primerun": "Nvidia Prime 렌더 활성화",
"resizableBar": "Resizable BAR 활성화 (NVIDIA RTX 30xx 전용)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ml/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "അടുത്തിടെയുള്ള പതിവ് കളികള്",
"maxworkers": "ഇറക്കിയെടുക്കുമ്പോള് പണിയുന്നവരുടെ പരമാവധി എണ്ണം",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "ഓഫ്ലൈനില് കളിക്കുക",
"primerun": "എന്വിഡിയ പ്രൈം റെന്റര് വയ്ക്കൂ",
"resizableBar": "വലുപ്പം മാറ്റാവുന്ന BAR വയ്ക്കൂ (എന്വിഡിയ RTX 30xxനു മാത്രം)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Recente spellen om te tonen",
"maxworkers": "Maximale hoeveelheid van werkers tijdens het downloaden",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Spel offline draaien",
"primerun": "Aciveer Nvidia Prime Render",
"resizableBar": "Resizable BAR inschakelen (Alleen voor NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/pl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Ostatnio Grane do Pokazania",
"maxworkers": "Maksymalna liczba wątków przy pobieraniu",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Uruchom grę w trybie offline",
"primerun": "Włącz renderowanie Nvidia Prime",
"resizableBar": "Włącz Resizable BAR (Tylko dla kart NVIDIA RTX)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Número de jogos recents a mostrar",
"maxworkers": "CPUs máximos utilizados ao baixar jogos",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Executar o jogo offline",
"primerun": "Habilitar Nvidia Prime Render",
"resizableBar": "Ativar BARRA redimensionável (apenas NVIDIA RTX 30xx)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/pt_BR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Máximo de jogos em Jogados Recentemente",
"maxworkers": "Máximo de núcleos da CPU para utilizar ao fazer baixar jogos",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Iniciar o jogo offline",
"primerun": "Habilitar o PRIME Render da NVIDIA",
"resizableBar": "Enable Resizable BAR (NVIDIA RTX only)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Показывать недавно запускавшихся игр",
"maxworkers": "Максимальное количество потоков при скачивании",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Запускать игру офлайн",
"primerun": "Включить Nvidia Prime Render",
"resizableBar": "Включить Resizable BAR (только NVIDIA RTX)",
Expand Down
1 change: 1 addition & 0 deletions public/locales/sv/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"maxRecentGames": "Visa nyligen spelat",
"maxworkers": "Maximalt antal samtida nedladdningar",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"offlinemode": "Kör spelet offline",
"primerun": "Aktivera Nvidia Prime Render",
"resizableBar": "Aktivera Resizable BAR (NVIDIA RTX endast)",
Expand Down
Loading

0 comments on commit e2642e2

Please sign in to comment.