Skip to content

Commit

Permalink
[Bugfix] Attempt at better fix to Yacoby#27
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharlikran committed Oct 17, 2017
1 parent 12b18cc commit 8d13f47
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
31 changes: 11 additions & 20 deletions Mopy/mash/masher.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,20 +633,15 @@ def PopulateItem(self, itemDex, mode=0, selected=set()):
self.list.SetStringItem(itemDex, colDex, value)
# --Text BG
if not mosh.mwIniFile.isWellOrdered(masterName):
self.list.SetItemBackgroundColour(itemDex,
colors['mash.doubleTime.load'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.doubleTime.load'])
elif masterInfo.getObjectMap():
self.list.SetItemBackgroundColour(itemDex,
colors['mash.masters.remapped'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.masters.remapped'])
elif masterInfo.hasChanged():
self.list.SetItemBackgroundColour(itemDex,
colors['mash.masters.changed'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.masters.changed'])
elif masterInfo.isExOverLoaded():
self.list.SetItemBackgroundColour(itemDex,
colors['mash.exOverLoaded'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.exOverLoaded'])
elif not masterInfo.isWellOrdered():
self.list.SetItemBackgroundColour(itemDex,
colors['mash.doubleTime.exists'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.doubleTime.exists'])
elif masterName[-1].lower() == 'm':
self.list.SetItemBackgroundColour(itemDex, colors['mash.esm'])
else:
Expand Down Expand Up @@ -993,19 +988,15 @@ def PopulateItem(self, itemDex, mode=0, selected=set()):
self.list.SetStringItem(itemDex, colDex, value)
# --Text BG
if not mosh.mwIniFile.isWellOrdered(fileName):
self.list.SetItemBackgroundColour(itemDex,
colors['mash.doubleTime.load'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.doubleTime.load'])
elif fileInfo.isExOverLoaded():
self.list.SetItemBackgroundColour(itemDex,
colors['mash.exOverLoaded'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.exOverLoaded'])
elif not fileInfo.isWellOrdered():
self.list.SetItemBackgroundColour(itemDex,
colors['mash.doubleTime.exists'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.doubleTime.exists'])
elif fileName[-1].lower() == 'm':
self.list.SetItemBackgroundColour(itemDex, colors['mash.esm'])
else:
self.list.SetItemBackgroundColour(itemDex,
colors['mash.doubleTime.not'])
self.list.SetItemBackgroundColour(itemDex, colors['mash.doubleTime.not'])
# --Image
status = fileInfo.getStatus()
on = fileInfo.name in mosh.mwIniFile.loadFiles
Expand Down Expand Up @@ -7249,8 +7240,8 @@ def InitImages():
# --Colors
colors['mash.esm'] = (220, 220, 255)
colors['mash.doubleTime.not'] = 'WHITE'
colors['mash.doubleTime.exists'] = (255, 220, 220)
colors['mash.doubleTime.load'] = (255, 100, 100)
colors['mash.doubleTime.exists'] = (255, 220, 220) # DT-Inactive
colors['mash.doubleTime.load'] = (255, 100, 100) # DT-Active
colors['mash.exOverLoaded'] = (0xFF, 0x99, 0)
colors['mash.masters.remapped'] = (100, 255, 100)
colors['mash.masters.changed'] = (220, 255, 220)
Expand Down
35 changes: 22 additions & 13 deletions Mopy/mash/mosh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2350,8 +2350,18 @@ def refresh(self):
self.safeSave()
return hasChanged

def isDoubleTimeFileLoaded(self, fileName=None):
if fileName in self.loadFiles:
if self.doubleTime[modInfos[fileName].mtime]:
return True
return False

def refreshDoubleTime(self):
"""Refresh arrays that keep track of doubletime mods."""
"""Refresh arrays that keep track of doubletime mods.
doubleTime dictionary contains True or Faluse values
assigned to modInfos[loadFile].mtime
"""
doubleTime = self.doubleTime
doubleTime.clear()
for loadFile in self.loadFiles:
Expand All @@ -2373,16 +2383,7 @@ def isWellOrdered(self, loadFile=None):
if loadFile and loadFile not in self.loadFiles:
return True
elif loadFile:
# An attempt at a fix for issue #27
# I am not sure why this is now needed and wasn't before.
# One possibility is that when modInfos gets manipulated this isn't
# refreshed.
mtime = modInfos[loadFile].mtime
if mtime not in self.doubleTime:
self.refreshDoubleTime()
return not self.doubleTime[mtime]
else:
return not (True in self.doubleTime.values())
return not self.isDoubleTimeFileLoaded(loadFile)

def getDoubleTimeFiles(self):
dtLoadFiles = []
Expand Down Expand Up @@ -2423,7 +2424,9 @@ def unload(self, modFile, doSave=True):
self.loadFiles.remove(modFile)
if doSave:
self.safeSave()
self.refreshDoubleTime()
# no need to refresh DoubleTime files here because it is done after
# uninstalling the files in ModInfos
# self.refreshDoubleTime()
self.loadOrder = modInfos.getLoadOrder(self.loadFiles)


Expand Down Expand Up @@ -3086,6 +3089,8 @@ def refresh(self):
for loadFile in mwIniFile.loadFiles[:]:
if loadFile not in self.data:
self.unload(loadFile)
# Since we refreshDoubleTime here there is no need to do that
# after uninstalling the file in MWIniFile.unload()
self.refreshDoubleTime()
# --Update mwIniLoadOrder
mwIniFile.loadOrder = modInfos.getLoadOrder(mwIniFile.loadFiles)
Expand All @@ -3103,7 +3108,11 @@ def refreshMTimes(self):
self.mtimesReset.append(fileName)

def refreshDoubleTime(self):
"""Refresh doubletime dictionary."""
"""Refresh doubletime dictionary.
doubleTime dictionary contains True or Faluse values
assigned to modInfos[loadFile].mtime
"""
doubleTime = self.doubleTime
doubleTime.clear()
for modInfo in self.data.values():
Expand Down

0 comments on commit 8d13f47

Please sign in to comment.