Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into 570-launchers-menu-gaz
Browse files Browse the repository at this point in the history
  • Loading branch information
BGazotti committed Apr 7, 2024
2 parents 18726b7 + d42d769 commit bc22dd1
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 197 deletions.
11 changes: 4 additions & 7 deletions Mopy/bash/_games_lo.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def _warn_active(self):
class LoGame(object):
"""API for setting, getting and validating the active plugins and the
load order (of all plugins) according to the game engine (in principle)."""
allow_deactivate_master = False
must_be_active_if_present: LoTuple = ()
max_espms = 255
max_esls = 0
Expand Down Expand Up @@ -529,11 +528,10 @@ def _fix_active_plugins(self, acti, lord, fix_active, on_disc):
acti_filtered_set = set(acti_filtered)
lord_set = set(lord)
fix_active.act_removed = set(acti) - acti_filtered_set
if not self.allow_deactivate_master:
if self.master_path not in acti_filtered_set:
acti_filtered.insert(0, self.master_path)
acti_filtered_set.add(self.master_path)
fix_active.master_not_active = self.master_path
if self.master_path not in acti_filtered_set:
acti_filtered.insert(0, self.master_path)
acti_filtered_set.add(self.master_path)
fix_active.master_not_active = self.master_path
for path in self.must_be_active_if_present:
if path in lord_set and path not in acti_filtered_set:
fix_active.missing_must_be_active.append(path)
Expand Down Expand Up @@ -850,7 +848,6 @@ def get_lo_file(self):
class TimestampGame(LoGame):
"""Oblivion and other games where load order is set using modification
times."""
allow_deactivate_master = True
# Intentionally imprecise mtime cache
_mtime_mods: defaultdict[int, set[Path]] = defaultdict(set)
_get_free_time_step = 1.0 # step by one second intervals
Expand Down
9 changes: 4 additions & 5 deletions Mopy/bash/balt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ def open_data_store(self):

def hide(self, items: dict[FName, ...]):
"""Hides the items in the specified iterable."""
hidden_ = []
moved_infos = []
for fnkey, inf in items.items():
destDir = inf.get_hide_dir()
if destDir.join(fnkey).exists():
Expand All @@ -1428,9 +1428,9 @@ def hide(self, items: dict[FName, ...]):
#--Do it
with BusyCursor():
inf.move_info(destDir)
hidden_.append(fnkey)
moved_infos.append(inf)
#--Refresh stuff
self.data_store.delete_refresh(hidden_, check_existence=True)
self.data_store.delete_refresh(moved_infos, check_existence=True)

@staticmethod
def _unhide_wildcard(): raise NotImplementedError
Expand Down Expand Up @@ -1466,8 +1466,7 @@ def get_source(self, uil_item: FName) -> FName | None:
if (not Link.Frame.iPanel or
not _settings['bash.installers.enabled']):
return None # Installers disabled or not initialized
pkg_column = self.data_store.table.getColumn('installer')
return FName(pkg_column.get(uil_item))
return FName(self.data_store[uil_item].get_table_prop('installer'))

# Global Menu -------------------------------------------------------------
def _populate_category(self, cat_label, target_category):
Expand Down
4 changes: 2 additions & 2 deletions Mopy/bash/basher/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ def _handle_ok(self):
'itself.') % {'chosen_plugin_name': chosen_name})
return EventResult.FINISH # leave the dialog open
if windowSelected: # assign it the group of the first selected mod
mod_group = pw.data_store.table.getColumn(u'group')
mod_group[chosen_name] = mod_group.get(windowSelected[0], u'')
if grp := pw.data_store[windowSelected[0]].get_table_prop('group'):
created_plugin.set_table_prop('group', grp)
pw.ClearSelected(clear_details=True)
pw.RefreshUI(redraw=[chosen_name])

Expand Down
46 changes: 21 additions & 25 deletions Mopy/bash/basher/mod_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,11 @@ def rename(self,oldName,newName):
self.mod_labels.append(newName)
self.mod_labels.sort()
#--Edit table entries.
colGroup = bosh.modInfos.table.getColumn(self.column)
renamed = []
for fileName, val in colGroup.items():
if val == oldName:
colGroup[fileName] = newName
renamed.append(fileName)
for fn, mod_inf in bosh.modInfos.items():
if mod_inf.get_table_prop(self.column) == oldName:
mod_inf.set_table_prop(self.column, newName)
renamed.append(fn)
self._refresh(redraw=renamed)
#--Done
return newName
Expand Down Expand Up @@ -455,11 +454,10 @@ def _check(self):
def _initData(self, window, selection):
super(_Mod_Labels, self)._initData(window, selection)
_self = self
label_column = bosh.modInfos.table.getColumn(self.column)
selection_set = set(selection)
column_contents = {x[1] for x in label_column.items()
if x[0] in selection_set}
self._none_checked = not any(column_contents)
assigned_labels = {p for k, v in bosh.modInfos.items() if
k in selection_set and (p := v.get_table_prop(self.column))}
self._none_checked = not assigned_labels
class _LabelLink(CheckLink):
def Execute(self):
for fileInfo in self.iselected_infos():
Expand All @@ -472,7 +470,7 @@ def link_help(self):
def _check(self):
"""Check the link if any of the selected plugins have labels
matching this one."""
return self._text in column_contents
return self._text in assigned_labels
self.__class__.choiceLinkType = _LabelLink

@property
Expand All @@ -487,27 +485,25 @@ class _ModGroups(CsvParser):
def __init__(self):
self.mod_group = {}

def readFromModInfos(self,mods=None):
"""Imports mods/groups from modInfos."""
column = bosh.modInfos.table.getColumn(u'group')
mods = mods or list(column) # if mods are None read groups for all mods
groups = tuple(column.get(x) for x in mods)
self.mod_group.update((x, y) for x, y in zip(mods, groups) if y)
def readFromModInfos(self, mods):
"""Read groups for specified mods from modInfos."""
self.mod_group.update((x, g) for x in mods if (
g := bosh.modInfos[x].get_table_prop('group')))

@staticmethod
def assignedGroups():
"""Return all groups that are currently assigned to mods."""
column = bosh.modInfos.table.getColumn(u'group')
return {x for x in column.values() if x}
return {g for x in bosh.modInfos.values() if
(g := x.get_table_prop('group'))}

def writeToModInfos(self,mods=None):
def writeToModInfos(self, mods):
"""Exports mod groups to modInfos."""
mod_group = self.mod_group
column = bosh.modInfos.table.getColumn(u'group')
changed_count = 0
for mod in (mods or bosh.modInfos.table):
if mod in mod_group and column.get(mod) != mod_group[mod]:
column[mod] = mod_group[mod]
for x in mods:
if x in mod_group and (g := mod_group[x]) != (
(inf := bosh.modInfos[x]).get_table_prop('group')):
inf.set_table_prop('group', g)
changed_count += 1
return changed_count

Expand Down Expand Up @@ -824,7 +820,7 @@ def toGhost(filename): return _GhostLink.getAllow(filename) and \
not load_order.cached_is_active(filename) # cannot ghost active mods
@staticmethod
def getAllow(filename):
return bosh.modInfos.table.getItem(filename, u'allowGhosting', True)
return bosh.modInfos[filename].get_table_prop('allowGhosting', True)

def Execute(self):
"""Loop selected files applying allow ghosting settings and
Expand All @@ -833,7 +829,7 @@ def Execute(self):
set_allow = self.__class__.setAllow
to_ghost = self.__class__.toGhost
for fileName, fileInfo in self.iselected_pairs():
fileInfo.set_table_prop(u'allowGhosting', set_allow(fileName))
fileInfo.set_table_prop('allowGhosting', set_allow(fileName))
if fileInfo.setGhost(to_ghost(fileName)):
ghost_changed.append(fileName)
self.window.RefreshUI(redraw=ghost_changed)
Expand Down
8 changes: 3 additions & 5 deletions Mopy/bash/basher/mods_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,11 @@ def link_help(self):
def _check(self): return bosh.modInfos.voCurrent == self._version_key

def _enable(self):
return bosh.modInfos.voCurrent is not None \
and self._version_key in bosh.modInfos.voAvailable
return bosh.modInfos.voCurrent is not None and not self._check() and \
self._version_key in bosh.modInfos.voAvailable

def Execute(self):
"""Handle selection."""
if bosh.modInfos.voCurrent == self._version_key: return
bosh.modInfos.setOblivionVersion(self._version_key, askYes)
##: Why refresh saves? Saves should only ever depend on Oblivion.esm,
# not any of the modding ESMs. Maybe we should enforce that those
Expand Down Expand Up @@ -381,10 +380,9 @@ def Execute(self):
super(Mods_AutoGhost, self).Execute()
flipped = []
toGhost = bass.settings['bash.mods.autoGhost']
allowGhosting = bosh.modInfos.table.getColumn('allowGhosting')
for mod, modInfo in bosh.modInfos.items():
modGhost = toGhost and not load_order.cached_is_active(
mod) and allowGhosting.get(mod, True)
mod) and modInfo.get_table_prop('allowGhosting', True)
if modInfo.setGhost(modGhost):
flipped.append(mod)
self.window.RefreshUI(redraw=flipped)
Expand Down
2 changes: 1 addition & 1 deletion Mopy/bash/basher/saves_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ def MoveFiles(self, profile: str | None):
count = self._move_saves(destDir, profile)
finally:
if not self.copyMode: # files moved to other profile, refresh
moved = bosh.saveInfos.delete_refresh(self.selected,
moved = bosh.saveInfos.delete_refresh(self.iselected_infos(),
check_existence=True)
self.window.RefreshUI(to_del=moved)
profile_rel = os.path.relpath(destDir, bass.dirs['saveBase'])
Expand Down
Loading

0 comments on commit bc22dd1

Please sign in to comment.