Skip to content

Commit

Permalink
Merge branch 'utumno-219-bye-refreshSizeCrcDate' into dev:
Browse files Browse the repository at this point in the history
Core refactoring of BAIN refresh - guided by the override skips bugs
detailed in #270. Breaking functionality out of ex refreshSizeCrcDate.
Notice that I keep `bass.dir` namespacing - installers classes
will be moved out of bosh.

Under #219, #205, #270, #277.

Signed-off-by: MrD <the.ubik@gmail.com>
  • Loading branch information
Utumno committed Mar 5, 2016
2 parents daafdd5 + 89a71c0 commit 5ecf400
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 173 deletions.
19 changes: 13 additions & 6 deletions Mopy/bash/basher/__init__.py
Expand Up @@ -60,7 +60,6 @@
import time
from types import ClassType
from functools import partial

#--wxPython
import wx
import wx.gizmos
Expand Down Expand Up @@ -2409,20 +2408,28 @@ def addMarker(self):
self.SelectItemAtIndex(index)
self._gList.EditLabel(index)

def rescanInstallers(self, toRefresh, abort):
"""Refresh installers, ignoring skip refresh flag."""
def rescanInstallers(self, toRefresh, abort, update_from_data=True):
"""Refresh installers, ignoring skip refresh flag.
Will also update InstallersData for the paths this installer would
install, in case a refresh is requested because those files were
modified/deleted (BAIN only scans Data/ once or boot)."""
if not toRefresh: return
try:
with balt.Progress(_(u'Refreshing Packages...'), u'\n' + u' ' * 60,
abort=abort) as progress:
progress.setFull(len(toRefresh))
for index, (name, installer) in enumerate(toRefresh):
dest = set() # installer's destination paths rel to Data/
for index, (name, installer) in enumerate(sorted(toRefresh, key=lambda tup: tup[1].order)):
progress(index,
_(u'Refreshing Packages...') + u'\n' + name.s)
apath = bass.dirs['installers'].join(name)
installer.refreshBasic(apath, SubProgress(progress, index,
index + 1))
dest.update(installer.refreshBasic(
apath, SubProgress(progress, index, index + 1)).keys())
self.data.hasChanged = True # is it really needed ?
if update_from_data:
progress(0, _(u'Refreshing From Data...') + u'\n' + u' ' * 60)
self.data.update_data_SizeCrcDate(dest, progress)
except CancelError: # User canceled the refresh
if not abort: raise # I guess CancelError is raised on aborting
self.data.irefresh(what='NSC')
Expand Down
17 changes: 10 additions & 7 deletions Mopy/bash/basher/installer_links.py
Expand Up @@ -167,13 +167,16 @@ def _enable(self):
self.filterInstallables())

class _RefreshingLink(_SingleInstallable):
_refreshType = 'N' ##: so what's this about exactly ?
_overrides_skips = False

@balt.conversation
def Execute(self):
installer = self.idata[self.selected[0]]
installer.refreshDataSizeCrc()
if not 'S' in self._refreshType: installer.refreshStatus(self.idata)
self.idata.irefresh(what=self._refreshType)
dest_src = installer.refreshDataSizeCrc()
with balt.Progress(title=_(u'Override Skips')) as progress:
if self._overrides_skips:
self.idata.update_for_overridden_skips(set(dest_src), progress)
self.idata.irefresh(what='NS', progress=progress)
self.window.RefreshUI()

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -519,6 +522,7 @@ def _check(self): return self._enable() and (

def Execute(self):
self.idata[self.selected[0]].overrideSkips ^= True
self._overrides_skips = self.idata[self.selected[0]].overrideSkips
super(Installer_OverrideSkips, self).Execute()

class Installer_SkipRefresh(CheckLink, _InstallerLink):
Expand Down Expand Up @@ -707,19 +711,18 @@ class Installer_Refresh(_InstallerLink):

def _enable(self): return bool(self.filterInstallables())

@balt.conversation
def Execute(self):
toRefresh = set((x, self.idata[x]) for x in self.selected)
self.window.rescanInstallers(toRefresh, abort=True)

class Installer_SkipVoices(CheckLink, _RefreshingLink):
"""Toggle skipVoices flag on installer."""
text = _(u'Skip Voices')
_refreshType = 'NS' ##: Why NS and not N like the rest ?

def _initData(self, window, selection):
super(Installer_SkipVoices, self)._initData(window, selection)
self.help = _(
u"Override global voices skip setting for %(installername)s.") % (
self.help = _(u"Skip over any voice files in %(installername)s") % (
{'installername': self.selected[0]})

def _check(self): return self._enable() and (
Expand Down
15 changes: 10 additions & 5 deletions Mopy/bash/basher/installers_links.py
Expand Up @@ -31,6 +31,7 @@
from .. import bass, bosh, balt, bush
from ..balt import BoolLink, AppendableLink, ItemLink, ListBoxes
from ..bass import Resources
from ..bolt import GPath

__all__ = ['Installers_SortActive', 'Installers_SortProjects',
'Installers_Refresh', 'Installers_AddMarker',
Expand Down Expand Up @@ -329,23 +330,27 @@ class Installers_AutoRefreshBethsoft(BoolLink, Installers_Link):
opposite = True
message = _(u"Enable installation of Bethsoft Content?") + u'\n\n' + _(
u"In order to support this, Bethesda ESPs, ESMs, and BSAs need to "
u"have their CRCs calculated. This will be accomplished by a full "
u"refresh of BAIN data an may take quite some time. Are you sure "
u"have their CRCs calculated. Moreover Bethesda ESPs, ESMs will have "
u"their crc recalculated every time on booting BAIN. Are you sure "
u"you want to continue?")

@balt.conversation
def Execute(self): ##: needs optimizing - ShowPanel + rescanInstallers...
def Execute(self):
if not bosh.settings[self.key] and not self._askYes(self.message):
return
super(Installers_AutoRefreshBethsoft, self).Execute()
if bosh.settings[self.key]:
# Refresh Data - only if we are now including Bethsoft files
self.iPanel.ShowPanel(scan_data_dir=True)
with balt.Progress(title=_(u'Refreshing Bethsoft Content'),
message=u'\n' + u' ' * 60) as progress:
beth_files = set(GPath(x) for x in bush.game.bethDataFiles)
self.idata.update_data_SizeCrcDate(beth_files, progress)
# Refresh Installers
toRefresh = set()
for name, installer in self.idata.iteritems():
if installer.hasBethFiles: toRefresh.add((name,installer))
self.window.rescanInstallers(toRefresh, abort=False)
self.window.rescanInstallers(toRefresh, abort=False,
update_from_data=False)

class Installers_Enabled(BoolLink):
"""Flips installer state."""
Expand Down

0 comments on commit 5ecf400

Please sign in to comment.