Skip to content

Commit

Permalink
Fix external libraries, requires Flatpak migration
Browse files Browse the repository at this point in the history
In favor of fixing external steam library support, drop support for
having an ammo.conf specific to Flatpak and another ammo.conf specific
to Steam in cases where a game was installed in both locations.

Instead, only use the normal ~/.local/share/ammo/<game name>/ammo.conf,
and show the library location on the game selection screen. This is more
accurate since it's possible to use Flatpak steam to add an external
library, at which point there's no way to tell that external library was
accessed via Flatpak steam. Steam installation instances do not have
exclusive ownership of steam libraries.

If you had games installed via Flatpak, pulling this update will
require you to either reactivate/reorder your mods and commit, or move
~/.var/app/com.valvesoftware.Steam/.local/share/ammo to
~/.local/share/ammo.
  • Loading branch information
cyberrumor committed Mar 2, 2024
1 parent eeef303 commit 1e37c2a
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions ammo/game_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@
)


class Source(str, Enum):
UNKNOWN = "unknown"
STEAM = "steam"
FLATPAK = "flatpak"


@dataclass(frozen=True, kw_only=True)
class GameSelection:
name: field(default_factory=str)
source: field(default_factory=Source)
library: field(default_factory=Path)


Expand Down Expand Up @@ -80,15 +73,8 @@ def __init__(self):
if game.name not in self.ids:
continue

source = Source.UNKNOWN
if self.steam in [library, library.parents]:
source = Source.STEAM
elif self.flatpak in [library, library.parents]:
source = Source.FLATPAK

game_selection = GameSelection(
name=game.name,
source=source,
library=library,
)

Expand Down Expand Up @@ -116,7 +102,7 @@ def __str__(self) -> str:
result += "-------|-----\n"
for i, game in enumerate(self.games):
index = f"[{i}]"
result += f"{index:<7} {game.name} ({game.source.value})\n"
result += f"{index:<7} {game.name} ({game.library})\n"
return result

def _autocomplete(self, text: str, state: int) -> Union[str, None]:
Expand Down Expand Up @@ -152,17 +138,8 @@ def _manage_game(self, index: int) -> None:
app_data / f"{game_selection.name.replace('t 4', 't4')}/Plugins.txt"
)
data = directory / "Data"
if game_selection.source == Source.FLATPAK:
ammo_conf_dir = (
Path.home()
/ f".var/app/com.valvesoftware.Steam/.local/share/ammo/{game_selection.name}"
)
elif game_selection.source == Source.STEAM:
ammo_conf_dir = Path.home() / f".local/share/ammo/{game_selection.name}"
else:
raise TypeError(
f"Expected {list(Source)} but got {game_selection.source} of type {type(game_selection.source)}"
)

ammo_conf_dir = Path.home() / f".local/share/ammo/{game_selection.name}"
ammo_mods_dir = ammo_conf_dir / "mods"
ammo_conf = ammo_conf_dir / "ammo.conf"

Expand Down

0 comments on commit 1e37c2a

Please sign in to comment.