mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2025-01-20 22:01:12 +01:00
fixes for bnet?
This commit is contained in:
parent
654d6bdee9
commit
89498f0ac2
@ -1147,144 +1147,113 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
#Battle.net Scanner
|
#Battle.net Scanner
|
||||||
|
|
||||||
# Define your mapping
|
# Define your mapping
|
||||||
flavor_mapping = {
|
flavor_mapping = {
|
||||||
"Blizzard Arcade Collection": "RTRO",
|
"RTRO": "Blizzard Arcade Collection",
|
||||||
"Diablo": "D1",
|
"D1": "Diablo",
|
||||||
"Diablo II Resurrected": "OSI",
|
"OSI": "Diablo II Resurrected",
|
||||||
"Diablo III": "D3",
|
"D3": "Diablo III",
|
||||||
"Diablo IV": "Fen",
|
"Fen": "Diablo IV",
|
||||||
"Diablo Immortal (PC)": "ANBS",
|
"ANBS": "Diablo Immortal (PC)",
|
||||||
"Hearthstone": "WTCG",
|
"WTCG": "Hearthstone",
|
||||||
"Heroes of the Storm": "Hero",
|
"Hero": "Heroes of the Storm",
|
||||||
"Overwatch": "Pro",
|
"Pro": "Overwatch 2",
|
||||||
"Overwatch 2": "Pro",
|
"S1": "StarCraft",
|
||||||
"StarCraft": "S1",
|
"S2": "StarCraft 2",
|
||||||
"StarCraft 2": "S2",
|
"W1": "Warcraft: Orcs & Humans",
|
||||||
"Warcraft: Orcs & Humans": "W1",
|
"W2": "Warcraft II: Battle.net Edition",
|
||||||
"Warcraft II: Battle.net Edition": "W2",
|
"W3": "Warcraft III: Reforged",
|
||||||
"Warcraft III: Reforged": "W3",
|
"WoW": "World of Warcraft",
|
||||||
"World of Warcraft": "WoW",
|
"WoWC": "World of Warcraft Classic",
|
||||||
"World of Warcraft Classic": "WoWC",
|
"GRY": "Warcraft Arclight Rumble",
|
||||||
"Warcraft Arclight Rumble": "GRY",
|
"ZEUS": "Call of Duty: Black Ops - Cold War",
|
||||||
"Call of Duty: Black Ops - Cold War": "ZEUS",
|
"VIPR": "Call of Duty: Black Ops 4",
|
||||||
"Call of Duty: Black Ops 4": "VIPR",
|
"ODIN": "Call of Duty: Modern Warfare",
|
||||||
"Call of Duty: Modern Warfare": "ODIN",
|
"AUKS": "Call of Duty",
|
||||||
"Call of Duty": "AUKS",
|
"LAZR": "Call of Duty: MW 2 Campaign Remastered",
|
||||||
"Call of Duty: MW 2 Campaign Remastered": "LAZR",
|
"FORE": "Call of Duty: Vanguard",
|
||||||
"Call of Duty: Vanguard": "FORE",
|
"SPOT": "Call of Duty: Modern Warfare III",
|
||||||
"Call of Duty: Modern Warfare III": "SPOT",
|
"WLBY": "Crash Bandicoot 4: It's About Time",
|
||||||
"Crash Bandicoot 4: It's About Time": "WLBY",
|
|
||||||
# Add more games here...
|
# Add more games here...
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_flavor_from_file(game_path):
|
def parse_battlenet_config(config_file_path):
|
||||||
game_path = game_path.replace('\\', '/')
|
print(f"Opening Battle.net config file at: {config_file_path}")
|
||||||
flavor_file = os.path.join(game_path, '_retail_', '.flavor.info')
|
with open(config_file_path, 'r') as file:
|
||||||
if os.path.exists(flavor_file):
|
config_data = json.load(file)
|
||||||
with open(flavor_file, 'r') as file:
|
|
||||||
for line in file:
|
|
||||||
if 'STRING' in line:
|
|
||||||
return line.split(':')[-1].strip().capitalize()
|
|
||||||
else:
|
|
||||||
print(f"Flavor file not found: {flavor_file}")
|
|
||||||
# Use the mapping as a fallback
|
|
||||||
game_name = os.path.basename(game_path)
|
|
||||||
print(f"Game name from file path: {game_name}")
|
|
||||||
return flavor_mapping.get(game_name, 'unknown')
|
|
||||||
|
|
||||||
def getBnetGameInfo(filePath):
|
games_info = config_data.get("Games", {})
|
||||||
# Check if the file contains any Battle.net entries
|
|
||||||
with open(filePath, 'r') as file:
|
|
||||||
if "Battle.net" not in file.read():
|
|
||||||
print("No Battle.net entries found in the registry file. Skipping Battle.net Games Scanner.")
|
|
||||||
return None
|
|
||||||
|
|
||||||
# If Battle.net entries exist, parse the registry file
|
|
||||||
game_dict = {}
|
game_dict = {}
|
||||||
with open(filePath, 'r') as file:
|
|
||||||
game_name = None
|
|
||||||
exe_path = None
|
|
||||||
publisher = None
|
|
||||||
contact = None
|
|
||||||
for line in file:
|
|
||||||
split_line = line.split("=")
|
|
||||||
if len(split_line) > 1:
|
|
||||||
if "Publisher" in line:
|
|
||||||
publisher = re.findall(r'\"(.+?)\"', split_line[1])
|
|
||||||
if publisher:
|
|
||||||
publisher = publisher[0]
|
|
||||||
# Skip if the publisher is not Blizzard Entertainment
|
|
||||||
if publisher != "Blizzard Entertainment":
|
|
||||||
game_name = None
|
|
||||||
exe_path = None
|
|
||||||
publisher = None
|
|
||||||
continue
|
|
||||||
if "Contact" in line:
|
|
||||||
contact = re.findall(r'\"(.+?)\"', split_line[1])
|
|
||||||
if contact:
|
|
||||||
contact = contact[0]
|
|
||||||
if "DisplayName" in line:
|
|
||||||
game_name = re.findall(r'\"(.+?)\"', split_line[1])
|
|
||||||
if game_name:
|
|
||||||
game_name = game_name[0]
|
|
||||||
if "InstallLocation" in line:
|
|
||||||
exe_path = re.findall(r'\"(.+?)\"', split_line[1])
|
|
||||||
if exe_path:
|
|
||||||
exe_path = exe_path[0].replace('\\\\', '\\')
|
|
||||||
# Skip if the install location is for the Battle.net launcher
|
|
||||||
if "Battle.net" in exe_path:
|
|
||||||
game_name = None
|
|
||||||
exe_path = None
|
|
||||||
publisher = None
|
|
||||||
continue
|
|
||||||
if game_name and exe_path and publisher == "Blizzard Entertainment" and contact == "Blizzard Support":
|
|
||||||
game_dict[game_name] = {'exe': exe_path}
|
|
||||||
print(f"Game added to dictionary: {game_name}")
|
|
||||||
game_name = None
|
|
||||||
exe_path = None
|
|
||||||
publisher = None
|
|
||||||
contact = None
|
|
||||||
|
|
||||||
# If no games were found, return None
|
for game_key, game_data in games_info.items():
|
||||||
if not game_dict:
|
print(f"Processing game: {game_key}")
|
||||||
print("No Battle.net games found. Skipping Battle.net Games Scanner.")
|
if game_key == "battle_net":
|
||||||
return None
|
print("Skipping 'battle_net' entry")
|
||||||
|
continue
|
||||||
|
if "Resumable" not in game_data:
|
||||||
|
print(f"Skipping {game_key}, no 'Resumable' key found")
|
||||||
|
continue
|
||||||
|
if game_data["Resumable"] == "false":
|
||||||
|
print(f"Game {game_key} is not resumable, adding to game_dict")
|
||||||
|
game_dict[game_key] = {
|
||||||
|
"ServerUid": game_data.get("ServerUid", ""),
|
||||||
|
"LastActioned": game_data.get("LastActioned", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
print(f"Parsed config data: {game_dict}")
|
||||||
return game_dict
|
return game_dict
|
||||||
|
|
||||||
# Define your paths
|
|
||||||
registry_file_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{bnet_launcher}/pfx/system.reg"
|
|
||||||
|
|
||||||
game_dict = {}
|
game_dict = {}
|
||||||
|
|
||||||
# Check if the paths exist
|
print("Detected platform: Non-Windows")
|
||||||
if not os.path.exists(registry_file_path):
|
config_file_path = f"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{bnet_launcher}/pfx/drive_c/users/steamuser/AppData/Roaming/Battle.net/Battle.net.config"
|
||||||
print("One or more paths do not exist.")
|
|
||||||
print("Battle.net game data not found. Skipping Battle.net Games Scanner.")
|
print(f"Config file path: {config_file_path}")
|
||||||
|
|
||||||
|
if os.path.exists(config_file_path):
|
||||||
|
print("Battle.net config file found, parsing...")
|
||||||
|
game_dict = parse_battlenet_config(config_file_path)
|
||||||
else:
|
else:
|
||||||
game_dict = getBnetGameInfo(registry_file_path)
|
print("Battle.net config file not found. Skipping Battle.net Games Scanner.")
|
||||||
if game_dict is None:
|
|
||||||
# Skip the rest of the Battle.net scanner
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Extract the flavor for each game and create the launch options
|
|
||||||
for game, game_info in game_dict.items():
|
|
||||||
game_info['flavor'] = get_flavor_from_file(game_info['exe'])
|
|
||||||
print(f"Flavor inferred: {game_info['flavor']}")
|
|
||||||
|
|
||||||
# Check if the game name is "Overwatch" and update it to "Overwatch 2"
|
if game_dict:
|
||||||
if game == "Overwatch":
|
for game_key, game_info in game_dict.items():
|
||||||
game = "Overwatch 2"
|
print(f"Processing game: {game_key}")
|
||||||
|
|
||||||
if game_info['flavor'] == "unknown":
|
if game_key == "prometheus":
|
||||||
pass
|
print("Handling 'prometheus' as 'Pro'")
|
||||||
|
game_key = "Pro"
|
||||||
|
|
||||||
elif game_info['flavor']:
|
game_name = flavor_mapping.get(game_key, "unknown")
|
||||||
launch_options = f"STEAM_COMPAT_DATA_PATH=\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{bnet_launcher}/\" %command% \"battlenet://{game_info['flavor']}\""
|
|
||||||
exe_path = f"\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{bnet_launcher}/pfx/drive_c/Program Files (x86)/Battle.net/Battle.net.exe\" --exec=\"launch {game_info['flavor']}\""
|
if game_name == "unknown":
|
||||||
start_dir = f"\"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{bnet_launcher}/pfx/drive_c/Program Files (x86)/Battle.net/\""
|
game_name = flavor_mapping.get(game_key.upper(), "unknown")
|
||||||
create_new_entry(exe_path, game, launch_options, start_dir)
|
print(f"Trying uppercase for {game_key}: {game_name}")
|
||||||
|
if game_name == "unknown":
|
||||||
|
print(f"Game {game_key} remains unknown, skipping...")
|
||||||
|
continue
|
||||||
|
|
||||||
|
matched_key = next((k for k, v in flavor_mapping.items() if v == game_name), game_key)
|
||||||
|
print(f"Matched key for {game_key}: {matched_key}")
|
||||||
|
|
||||||
|
if game_name == "Overwatch":
|
||||||
|
game_name = "Overwatch 2"
|
||||||
|
print(f"Renaming 'Overwatch' to 'Overwatch 2'")
|
||||||
|
|
||||||
|
if game_info['ServerUid'] == "unknown":
|
||||||
|
print(f"Skipping game {game_key} due to unknown ServerUid")
|
||||||
|
continue
|
||||||
|
|
||||||
|
exe_path = f'"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{bnet_launcher}/pfx/drive_c/Program Files (x86)/Battle.net/Battle.net.exe"'
|
||||||
|
start_dir = f'"{logged_in_home}/.local/share/Steam/steamapps/compatdata/{bnet_launcher}/pfx/drive_c/Program Files (x86)/Battle.net/"'
|
||||||
|
launch_options = f'STEAM_COMPAT_DATA_PATH="{logged_in_home}/.local/share/Steam/steamapps/compatdata/{bnet_launcher}" %command% --exec="launch {matched_key}" battlenet://{matched_key}'
|
||||||
|
|
||||||
|
print(f"Creating new entry for {game_name} with exe_path: {exe_path}")
|
||||||
|
create_new_entry(exe_path, game_name, launch_options, start_dir)
|
||||||
|
|
||||||
|
print("Battle.net Games Scanner completed.")
|
||||||
|
|
||||||
# End of Battle.net Scanner
|
# End of Battle.net Scanner
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user