Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wargroove: Add Linux support to WargrooveClient #4526

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 51 additions & 23 deletions WargrooveClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import Utils
import json
import logging
import settings

if __name__ == "__main__":
Utils.init_logging("WargrooveClient", exception_logger="Client")
Expand Down Expand Up @@ -78,31 +79,58 @@ def __init__(self, server_address, password):
self.syncing = False
self.awaiting_bridge = False
# self.game_communication_path: files go in this path to pass data between us and the actual game
game_options = settings.get_settings()["wargroove_options"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI i believe it is recommended to use settings.get_settings().wargroove_options (and then subsequently game_options.save_directory) because they are properly typed


# Validate the AppData directory with Wargroove save data.
# By default, Windows sets an environment variable we can leverage.
# However, other OSes don't usually have this value set, so we need to rely on a settings value instead.
appdata_wargroove = None
if "appdata" in os.environ:
options = Utils.get_options()
root_directory = os.path.join(options["wargroove_options"]["root_directory"])
data_directory = os.path.join("lib", "worlds", "wargroove", "data")
dev_data_directory = os.path.join("worlds", "wargroove", "data")
appdata_wargroove = os.path.expandvars(os.path.join("%APPDATA%", "Chucklefish", "Wargroove"))
if not os.path.isfile(os.path.join(root_directory, "win64_bin", "wargroove64.exe")):
print_error_and_close("WargrooveClient couldn't find wargroove64.exe. "
"Unable to infer required game_communication_path")
self.game_communication_path = os.path.join(root_directory, "AP")
if not os.path.exists(self.game_communication_path):
os.makedirs(self.game_communication_path)
self.remove_communication_files()
atexit.register(self.remove_communication_files)
if not os.path.isdir(appdata_wargroove):
print_error_and_close("WargrooveClient couldn't find Wargoove in appdata!"
"Boot Wargroove and then close it to attempt to fix this error")
if not os.path.isdir(data_directory):
data_directory = dev_data_directory
if not os.path.isdir(data_directory):
print_error_and_close("WargrooveClient couldn't find Wargoove mod and save files in install!")
shutil.copytree(data_directory, appdata_wargroove, dirs_exist_ok=True)
appdata_wargroove = os.environ['appdata']
else:
print_error_and_close("WargrooveClient couldn't detect system type. "
"Unable to infer required game_communication_path")
try:
appdata_wargroove = game_options["save_directory"]
except FileNotFoundError:
print_error_and_close("WargrooveClient couldn't detect a path to the AppData folder.\n"
"Unable to infer required game_communication_path.\n"
"Try setting the \"save_directory\" value in your local options file "
"to the AppData folder containing your Wargroove saves.")
appdata_wargroove = os.path.expandvars(os.path.join(appdata_wargroove, "Chucklefish", "Wargroove"))
if not os.path.isdir(appdata_wargroove):
print_error_and_close(f"WargrooveClient couldn't find Wargroove data in your AppData folder.\n"
f"Looked in \"{appdata_wargroove}\".\n"
f"If you haven't yet booted the game at least once, boot Wargroove "
f"and then close it to attempt to fix this error.\n"
f"If the AppData folder above seems wrong, try setting the "
f"\"save_directory\" value in your local options file "
f"to the AppData folder containing your Wargroove saves.")

# Check for the Wargroove game executable path.
# This should always be set regardless of the OS.
root_directory = os.path.join(game_options["root_directory"])
data_directory = os.path.join("lib", "worlds", "wargroove", "data")
dev_data_directory = os.path.join("worlds", "wargroove", "data")
if not os.path.isfile(os.path.join(root_directory, "win64_bin", "wargroove64.exe")):
print_error_and_close(f"WargrooveClient couldn't find wargroove64.exe in "
f"\"{root_directory}/win64_bin/\".\n"
f"Unable to infer required game_communication_path.\n"
f"Please verify the \"root_directory\" value in your local "
f"options file is set correctly.")
self.game_communication_path = os.path.join(root_directory, "AP")
if not os.path.exists(self.game_communication_path):
os.makedirs(self.game_communication_path)
self.remove_communication_files()
atexit.register(self.remove_communication_files)

# Make sure the Wargroove mod is where we expect.
# If it isn't, uh.... panic???
if not os.path.isdir(data_directory):
data_directory = dev_data_directory
if not os.path.isdir(data_directory):
print_error_and_close(f"WargrooveClient couldn't find Wargoove mod and save files in install!\n"
f"Please make sure the mod files exist in \"{data_directory}\" "
f"and reinstall Archipelago if they are missing.")
shutil.copytree(data_directory, appdata_wargroove, dirs_exist_ok=True)

async def server_auth(self, password_requested: bool = False):
if password_requested and not self.password:
Expand Down
19 changes: 17 additions & 2 deletions worlds/wargroove/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,27 @@
class WargrooveSettings(settings.Group):
class RootDirectory(settings.UserFolderPath):
"""
Locate the Wargroove root directory on your system.
This is used by the Wargroove client, so it knows where to send communication files to
Locates the Wargroove root directory on your system.
This is used by the Wargroove client, so it knows where to send communication files to.
"""
description = "Wargroove root directory"

class SaveDirectory(settings.UserFolderPath):
"""
Locates the Wargroove save file directory on your system.
This is used by the Wargroove client, so it knows where to send communication files to.
"""
description = "Wargroove save file/appdata directory"

def browse(self, **kwargs):
from Utils import messagebox
messagebox("AppData folder not found",
"WargrooveClient couldn't detect a path to the AppData folder.\n"
"Please select the folder containing the \"/Chucklefish/Wargroove/\" directories.")
super().browse(**kwargs)

root_directory: RootDirectory = RootDirectory("C:/Program Files (x86)/Steam/steamapps/common/Wargroove")
save_directory: SaveDirectory = SaveDirectory("%APPDATA%")


class WargrooveWeb(WebWorld):
Expand Down
2 changes: 1 addition & 1 deletion worlds/wargroove/docs/en_Wargroove.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Wargroove (Steam, Windows)
# Wargroove (Steam, Windows, Linux)

## Where is the options page?

Expand Down
14 changes: 12 additions & 2 deletions worlds/wargroove/docs/wargroove_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Required Files

- Wargroove with the Double Trouble DLC installed through Steam on Windows
- Only the Steam Windows version is supported. MAC, Switch, Xbox, and Playstation are not supported.
- Wargroove with the Double Trouble DLC installed through Steam on Windows and Linux
- Only the Steam version on Windows and Linux is supported. MAC, Switch, Xbox, and Playstation are not supported.
- [The most recent Archipelago release](https://github.com/ArchipelagoMW/Archipelago/releases)

## Backup playerProgress files
Expand All @@ -23,6 +23,16 @@ is strongly recommended in case they become corrupted.
- You may have to replace all single \\ with \\\\.
4. Start the Wargroove client.

## Linux Only: Select AppData equivalent when starting the client
1. Shut down Wargroove if it is open.
2. Start the ArchipelagoWargrooveClient.exe from the Archipelago installation.
3. A file select dialogue will appear, claiming it cannot detect a path to the AppData folder.
4. Navigate to your Steam install directory and select .
`/steamapps/compatdata/607050/pfx/drive_c/users/steamuser/AppData/Roaming` as the save directory.
5. Using a default Steam install path, the full AppData path is
`~/.steam/steam/steamapps/compatdata/607050/pfx/drive_c/users/steamuser/AppData/Roaming`.
6. The client should start.

## Installing the Archipelago Wargroove Mod and Campaign files

1. Shut down Wargroove if it is open.
Expand Down