Skip to content

Commit

Permalink
Indicate plugins provided by multiple mods
Browse files Browse the repository at this point in the history
In the same way that mods which provide files provided by other mods are
indicated via asterisk, indicate plugins that are provided by multiple
mods with an asterisk.
  • Loading branch information
cyberrumor committed Feb 9, 2024
1 parent 38296d0 commit eeef303
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ammo/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class Plugin:
mod: Union[None, Mod]
enabled: bool
visible: bool = field(init=False, default=True)
conflict: bool = field(init=False, default=False)



@dataclass(slots=True)
Expand Down
17 changes: 14 additions & 3 deletions ammo/mod_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(self, downloads_dir: Path, game: Game, *keywords):
name = line.strip().strip("*").strip()

# Don't add duplicate plugins
if name in [p.name for p in self.plugins]:
if name.lower() in (p.name.lower() for p in self.plugins):
continue

enabled = self.game.enabled_formula(line)
Expand Down Expand Up @@ -247,7 +247,10 @@ def __str__(self) -> str:
if plugin.visible:
priority = f"[{i}]"
enabled = f"[{plugin.enabled}]"
result += f"{priority:<7} {enabled:<11} {plugin.name}\n"
conflict = "*" if plugin.conflict else " "
result += (
f"{priority:<7} {enabled:<9} {conflict:<1} {plugin.name}\n"
)

if not result:
result = "\n"
Expand Down Expand Up @@ -407,7 +410,6 @@ def _set_component_state(self, component: ComponentEnum, index: int, state: bool
if not self.changes:
self.changes = starting_state != subject.enabled


def _stage(self) -> dict:
"""
Responsible for assigning mod.conflict for the staged configuration.
Expand Down Expand Up @@ -442,6 +444,15 @@ def _stage(self) -> dict:
conflicting_mod[0].conflict = True
result[dest] = (mod.name, src)

plugin_names = []
for mod in self.mods:
if mod.enabled:
plugin_names.extend(mod.plugins)
for plugin in self.plugins:
plugin.conflict = False
if plugin_names.count(plugin.name.lower()) > 1:
plugin.conflict = True

return result

def _remove_empty_dirs(self):
Expand Down

0 comments on commit eeef303

Please sign in to comment.