Skip to content

Commit

Permalink
finalize battle.net parser
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartondock committed May 1, 2024
1 parent 7a54431 commit 07426a1
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 27 deletions.
1 change: 1 addition & 0 deletions files/shellscripts/bnet.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#From https://github.com/SteamGridDB/steamgriddb-manager/blob/master/BnetHelper.ps1
param (
[Parameter(Mandatory=$True)][string]$bnet, # Path to the Battle.net executable
[Parameter(Mandatory=$True)][string]$launchid # Battle.net launch id to launch
Expand Down
13 changes: 10 additions & 3 deletions src/lang/en-US/langStrings.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,24 @@
"legendaryInstalledFilePlaceholder": "/path/to/legendary/installed.json",
"errors": {
"legendaryNotInstalled": "> Legendary installed.json not found",
"fatalError__i": "> Legendary parser failed with fatal error: \n ${error}"
"fatalError__i": "> Legendary parser failed with fatal error:\n ${error}"
}
},
"battleNetParser": {
"battleExeOverrideTitle": "Battle.net.exe Path Override",
"battleExeOverridePlaceholder": "/path/to/Battle.net/Battle.net.exe",
"errors": {
"battleNotCompatible": "> Battle.net parser is only available on Windows.",
"fatalError__i": "> Battle.net parser failed with fatal error:\n ${error}"
}
},
"UWPParser": {
"UWPDirTitle": "XboxGames Directory Override",

"UWPDirPlaceholder": "/path/to/XboxGames or /path/to/WindowsApps",
"UWPLauncherModeTitle": "Launch game as UWP instead of launcher helper",
"errors": {
"fatalError__i": "> UWP parser failed with fatal error:\n ${error}",
"UWPNotCompatible": "> UWP parser is not compatible in this platform."
"UWPNotCompatible": "> UWP parser is only available on Windows."
}
},
"uplayParser": {
Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/UWP-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Unique inputs for UWP Parser
# UWP Parser Specific Inputs

## Games directory

Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/UWP-parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This parser imports `UWP` games in your Windows OS, having a games library path

## Compatibility

This parser should only work on `Windows 10` and `Windows 11`.
This parser should only work on `Windows 10` and `Windows 11`.
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/amazon-games-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Amazon Games Parser specific inputs
# Amazon Games Parser Specific Inputs

## Amazon Games Path Override
By default Steam ROM Manager assumes your Amazon Games installation is located at `C:\Users\<username>\AppData\Local\Amazon Games\App\Amazon Games.exe`. This field allows you to override that path if your Amazon Games installation is elsewhere.
Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/amazon-games-parser.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Amazon Games Parser

This parser imports games from `Amazon Games` so that artwork can be chosen for them and they can be added into Steam. If it doesn't work it is because Amazon Games has altered the structure of their game database or their fuel.json, in this case please let the developers of SRM know and we will resolve the issue.
This parser imports games from `Amazon Games` so that artwork can be chosen for them and they can be added into Steam. If it doesn't work it is because Amazon Games has altered the structure of their game database or their fuel.json, in this case please let the developers of SRM know and we will resolve the issue.
4 changes: 4 additions & 0 deletions src/lang/en-US/markdown/battle-net-parser-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Battle.net Parser Specific Inputs

## Battle.net.exe Path Override
By default Steam ROM Manager assumes your `Battle.net` executable is located at `C:\Program Files (x86)\Battle.net\Battle.net.exe`. This field allows you to override that if your `Battle.net` is installed elsewhere.
5 changes: 5 additions & 0 deletions src/lang/en-US/markdown/battle-net-parser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Battle.net Parser

This parser imports games from the `Battle.net` app, so that artwork can be chosen for them and they can be added into Steam. If it doesn't work it is because Blizzard has altered the structure of their database files, in which case please let the developers of SRM know and we will resolve the issue.

The `Battle.net` parser is somewhat special in that it uses a shell script at `${srmDir}/scripts/bnet.ps1` in order to launch `Battle.net`, wait an appropriate amount of time, and only then launch the actual title.
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/ea-desktop-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EA Desktop Parser specific inputs
# EA Desktop Parser Specific Inputs

## EA Games Directory Override
By default Steam ROM Manager assumes your `EA Desktop` games are installed at `C:\Program Files\EA Games\`. This field allows you to change that to wherever your games are installed, e.g. `D:\Games\EA Games`.
Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/epic-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Epic Games Store specific inputs
# Epic Games Store Specific Inputs

## Manifests Directory Override

Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/glob-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Glob Parser specific inputs
# Glob Parser Specific Inputs

## User's glob

Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/glob-regex-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Glob-regex Parser specific inputs
# Glob-regex Parser Specific Inputs

## User's glob-regex

Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/gog-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Unique inputs for GOG Galaxy Parser
# GOG Galaxy Parser Specific Inputs

## Galaxy Path Override
By default Steam ROM Manager assumes your Galaxy Client is located at `C:\Program Files (x86)\GOG Galaxy\GalaxyClient.exe`. This field allows you to override that path if your GOG Galaxy installation is elsewhere.
Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/itch-io-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# itch.io Parser specific inputs
# itch.io Parser Specific Inputs

## itch.io AppData Path Override
By default Steam ROM Manager assumes your itch.io app data is located at `%APPDATA%\itch` on windows `$HOME/.config/itch` on linux and `$HOME/Library/Application Support/itch` on macos.
Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/itch-io-parser.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# itch.io Parser

This parser imports games from `the itch.io desktop app` so that artwork can be chosen for them and they can be added into Steam. If it doesn't work it is because itch.io has altered the structure of their game database, in this case please let the developers of SRM know and we will resolve the issue.
This parser imports games from `the itch.io desktop app` so that artwork can be chosen for them and they can be added into Steam. If it doesn't work it is because itch.io has altered the structure of their game database, in this case please let the developers of SRM know and we will resolve the issue.
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/legendary-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Legendary Parser specific inputs
# Legendary Parser Specific Inputs

## Legendary `installed.json` Path Override

Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/manual-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Manual Parser specific inputs
# Manual Parser Specific Inputs

## Manifests Directory `[Supports Environment Variables]`{.noWrap}

Expand Down
2 changes: 1 addition & 1 deletion src/lang/en-US/markdown/steam-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Steam Parser specific inputs
# Steam Parser Specific Inputs

## Find artwork for games only
If enabled SRM will filter out any Steam applications that are not full games, such as demos and tools like `3DMark` or `Wallpaper Engine`.
Expand Down
4 changes: 2 additions & 2 deletions src/lang/en-US/markdown/uplay-parser-input.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Unique inputs for UPlay Parser
# UPlay Parser Specific Inputs

## Ubisoft Directory Override
By default Steam ROM Manager assumes your UPlay install is located in `C:\Program Files (x86)\Ubisoft`. This field allows you to override that path if your UPlay installation is elsewhere.

## Launch Via UPlay `[Recommend disabled]`

What it sounds like, this toggle let's you set whether games will launch via UPlay or directly from the game's executable.

For UPlay this doesn't matter too much as UPlay games will automatically launch UPlay in the background even when launched from the executable. Steam Overlay will not work when `Launch via UPlay` is enabled, whereas both Steam and Ubisoft overlays work when `Launch via UPlay` is disabled.
11 changes: 11 additions & 0 deletions src/lang/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ function getMarkdown(langPath: string) {
]
}
},
battleNetParser: {
docs__md: {
self: [
require(`${langPath}/battle-net-parser.md`),
require(`${langPath}/battle-net-parser-input.md`)
],
input: [
require(`${langPath}/battle-net-parser-input.md`)
]
}
},
uplayParser: {
docs__md: {
self: [
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parsers/available-parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const availableParserInputs: Record<ParserType, string[]> = {
'UPlay': ['uplayDir','uplayLauncherMode'],
'UWP': ['UWPDir', 'UWPLauncherMode'],
'EA Desktop': ['eaGamesDir','eaLauncherMode'],
'Battle.net': ['battleDir']
'Battle.net': ['battleExeOverride']
};

export const availableParsers: ParserType[] = Object.keys(availableParserInputs) as ParserType[];
Expand Down
14 changes: 7 additions & 7 deletions src/lib/parsers/battle-net.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ const BNET_GAMES: {[k: string]:
export class BattleNetParser implements GenericParser {

private get lang() {
return APP.lang.UWPParser;
return APP.lang.battleNetParser;
}

getParserInfo(): ParserInfo {
return {
title: 'Battle.net',
info: this.lang.docs__md.self.join(''),
inputs: {
'battleDir': {
label: 'Battle Dir',
placeholder: '/path/to/battle',
inputType: 'dir',
'battleExeOverride': {
label: this.lang.battleExeOverrideTitle,
placeholder: this.lang.battleExeOverridePlaceholder,
inputType: 'path',
validationFn: null,
info: this.lang.docs__md.input.join('')
}
Expand All @@ -106,11 +106,11 @@ export class BattleNetParser implements GenericParser {
execute(directories: string[], inputs: { [key: string]: any }, cache?: { [key: string]: any }): Promise<ParsedData> {
return new Promise<ParsedData>(async (resolve, reject) => {
if (os.type() !== 'Windows_NT') {
reject(this.lang.errors.UWPNotCompatible)
reject(this.lang.errors.battleNotCompatible)
}
try {
const dbPath = 'C:\\ProgramData\\Battle.net\\Agent\\product.db';
const bNetExe = 'C:\\Program Files (x86)\\Battle.net\\Battle.net.exe';
const bNetExe = inputs.battleExeOverride || 'C:\\Program Files (x86)\\Battle.net\\Battle.net.exe';
const bNetDir = path.dirname(bNetExe)
const scriptPath = path.join(paths.userDataDir,'scripts','bnet.ps1');
if(!fs.existsSync(scriptPath)) {
Expand Down
12 changes: 12 additions & 0 deletions src/models/language.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ export interface languageStruct {
fatalError__i: string
}
},
battleNetParser: {
battleExeOverrideTitle: string,
battleExeOverridePlaceholder: string,
docs__md: {
self: string[],
input: string[]
},
errors: {
fatalError__i: string,
battleNotCompatible: string
}
},
UWPParser: {
UWPDirTitle: string,
UWPDirPlaceholder: string,
Expand Down

0 comments on commit 07426a1

Please sign in to comment.