Skip to content

Commit

Permalink
Last uses of IdList, the Ripper is on his/her/it way
Browse files Browse the repository at this point in the history
  • Loading branch information
Utumno committed Feb 28, 2015
1 parent 312f016 commit 000f320
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 36 deletions.
25 changes: 13 additions & 12 deletions Mopy/bash/basher/mod_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,23 +257,24 @@ def Execute(self, event):
self.window.PopulateItems()
self.extraItems = [_Edit(), SeparatorLink(), _None()]

def _initData(self, window, data):
super(_Mod_Labels, self)._initData(window, data)
_self = self
class _LabelLink(ItemLink):
def Execute(self, event):
fileLabels = bosh.modInfos.table.getColumn(_self.column)
for fileName in self.selected: fileLabels[fileName] = self.text
if isinstance(_self, Mod_Groups):
bosh.modInfos.refresh(doInfos=False) # needed ?
self.window.RefreshUI()
self.__class__.cls = _LabelLink

@property
def items(self):
items = self.labels[:]
items.sort(key=lambda a: a.lower())
return items

def DoList(self,event):
"""Handle selection of label."""
label = self.items[event.GetId()-self.idList.BASE]
fileLabels = bosh.modInfos.table.getColumn(self.column)
for fileName in self.selected:
fileLabels[fileName] = label
if isinstance(self,Mod_Groups) and bosh.modInfos.refresh(doInfos=False):
self.window.SortItems()
self.window.RefreshUI()


#--Groups ---------------------------------------------------------------------
class _Mod_Groups_Export(EnabledLink):
"""Export mod groups to text file."""
Expand Down Expand Up @@ -354,7 +355,7 @@ def _initData(self, window, data):
data = set(data)
mod_group = bosh.modInfos.table.getColumn('group').items()
modGroup = set([x[1] for x in mod_group if x[0] in data])
class _CheckGroup(CheckLink):
class _CheckGroup(CheckLink, self.__class__.cls):
def _check(self):
"""Check the Link if any of the selected mods belongs to it."""
return self.text in modGroup
Expand Down
42 changes: 18 additions & 24 deletions Mopy/bash/basher/saves_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ def items(self): return [x.s for x in bosh.saveInfos.getLocalSaveDirs()]
class _CheckLink(CheckLink):
def _check(self):
return Saves_Profiles.local == (u'Saves\\' + self.text + u'\\')
def Execute(self, event):
"""Handle selection of label."""
arcSaves = bosh.saveInfos.localSave
newSaves = u'Saves\\%s\\' % (self.text,)
bosh.saveInfos.setLocalSave(newSaves)
Saves_Profiles.swapPlugins(arcSaves,newSaves)
Saves_Profiles.swapOblivionVersion(newSaves)
Link.Frame.SetTitle()
self.window.details.SetFile(None)
Link.Frame.RefreshData()
bosh.modInfos.autoGhost()
BashFrame.modList.RefreshUI()

cls = _CheckLink

class _Default(CheckLink):
Expand Down Expand Up @@ -198,20 +211,6 @@ def _initData(self, window, data):
self.extraItems = [Saves_Profiles._Edit(), SeparatorLink(),
Saves_Profiles._Default()]

def DoList(self,event):
"""Handle selection of label."""
profile = self.items[event.GetId()-self.idList.BASE]
arcSaves = bosh.saveInfos.localSave
newSaves = u'Saves\\%s\\' % (profile,)
bosh.saveInfos.setLocalSave(newSaves)
self.swapPlugins(arcSaves,newSaves)
self.swapOblivionVersion(newSaves)
Link.Frame.SetTitle()
self.window.details.SetFile(None)
Link.Frame.RefreshData()
bosh.modInfos.autoGhost()
BashFrame.modList.RefreshUI()

@staticmethod
def swapPlugins(arcSaves,newSaves):
"""Saves current plugins into arcSaves directory and loads plugins
Expand Down Expand Up @@ -624,11 +623,6 @@ def __init__(self, copyMode=False):
@property
def items(self): return [x.s for x in bosh.saveInfos.getLocalSaveDirs()]

class _SaveProfileLink(EnabledLink):
def _enable(self):
return Save_Move.local != (u'Saves\\'+ self.text +u'\\')
cls = _SaveProfileLink

def _initData(self, window, data):
super(Save_Move, self)._initData(window, data)
Save_Move.local = bosh.saveInfos.localSave
Expand All @@ -637,13 +631,13 @@ class _Default(EnabledLink):
text = _(u'Default')
def _enable(self): return Save_Move.local != u'Saves\\'
def Execute(self, event): _self.MoveFiles(_(u'Default'))
class _SaveProfileLink(EnabledLink):
def _enable(self):
return Save_Move.local != (u'Saves\\'+ self.text +u'\\')
def Execute(self, event): _self.MoveFiles(self.text)
self.__class__.cls = _SaveProfileLink
self.extraItems = [_Default()]

def DoList(self,event):
"""Handle selection of label."""
profile = self.items[event.GetId()-self.idList.BASE]
self.MoveFiles(profile)

def MoveFiles(self,profile):
fileInfos = self.window.data
destDir = bosh.dirs['saveBase'].join(u'Saves')
Expand Down

0 comments on commit 000f320

Please sign in to comment.