Skip to content

Commit 5d1649b

Browse files
InfernioSharlikran
authored andcommitted
WIP: Set game-specific prefix for SLocalSavePath
Prerequisite for Enderal, which is the first game to use a prefix other than 'Saves\' for this INI setting - otherwise, saves profiles won't work with Enderal. Touches a lot of code in many different places, so marked as WIP since it will need lots of testing - but it seems to work as intended.
1 parent 309d4c2 commit 5d1649b

4 files changed

Lines changed: 19 additions & 14 deletions

File tree

Mopy/bash/basher/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3750,7 +3750,9 @@ def SetTitle(*args, **kwargs):
37503750
title += u', CBash %s: ' % (CBashApi.VersionText,)
37513751
else:
37523752
title += u': '
3753-
maProfile = re.match(ur'Saves\\(.+)\\$',bosh.saveInfos.localSave,re.U)
3753+
save_prefix = re.escape(bush.game.saveProfilesKey[2])
3754+
maProfile = re.match(save_prefix + ur'(.+)\\$',
3755+
bosh.saveInfos.localSave, re.U)
37543756
if maProfile:
37553757
title += maProfile.group(1)
37563758
else:

Mopy/bash/basher/saves_links.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def getItemList(self):
7272
#--Info box
7373
def getInfo(self,item):
7474
"""Returns string info on specified item."""
75-
profileSaves = u'Saves\\'+item+u'\\'
75+
profileSaves = bush.game.saveProfilesKey[2]+item+u'\\'
7676
return bosh.saveInfos.profiles.getItem(profileSaves,'info',_(u'About %s:') % item)
7777
def setInfo(self,item,text):
7878
"""Sets string info on specified item."""
79-
profileSaves = u'Saves\\'+item+u'\\'
79+
profileSaves = bush.game.saveProfilesKey[2]+item+u'\\'
8080
bosh.saveInfos.profiles.setItem(profileSaves,'info',text)
8181

8282
def add(self):
@@ -97,7 +97,7 @@ def add(self):
9797
_(u'Name must be encodable in Windows Codepage 1252 (Western European), due to limitations of %(gameIni)s.') % {'gameIni':bush.game.iniFiles[0]})
9898
return False
9999
self.baseSaves.join(newName).makedirs()
100-
newSaves = u'Saves\\'+newName+u'\\'
100+
newSaves = bush.game.saveProfilesKey[2]+newName+u'\\'
101101
bosh.saveInfos.profiles.setItem(newSaves,'vOblivion',bosh.modInfos.voCurrent)
102102
return newName
103103

@@ -117,7 +117,7 @@ def rename(self,oldName,newName):
117117
oldDir, newDir = (self.baseSaves.join(subdir) for subdir in
118118
(oldName, newName))
119119
oldDir.moveTo(newDir)
120-
oldSaves,newSaves = ((u'Saves\\'+name+u'\\') for name in (oldName,newName))
120+
oldSaves,newSaves = ((bush.game.saveProfilesKey[2]+name+u'\\') for name in (oldName,newName))
121121
if bosh.saveInfos.localSave == oldSaves:
122122
bosh.saveInfos.setLocalSave(newSaves)
123123
Link.Frame.SetTitle()
@@ -126,7 +126,7 @@ def rename(self,oldName,newName):
126126

127127
def remove(self,profile):
128128
"""Removes load list."""
129-
profileSaves = u'Saves\\'+profile+u'\\'
129+
profileSaves = bush.game.saveProfilesKey[2]+profile+u'\\'
130130
#--Can't remove active or Default directory.
131131
if bosh.saveInfos.localSave == profileSaves:
132132
balt.showError(self.parent,_(u'Active profile cannot be removed.'))
@@ -160,7 +160,8 @@ def menu_help(self):
160160
return _(u'Set profile to %(prof)s (My Games/Saves/%(prof)s)') % {
161161
'prof': self._text}
162162
@property
163-
def relativePath(self): return u'Saves\\' + self._text + u'\\'
163+
def relativePath(self):
164+
return bush.game.saveProfilesKey[2] + self._text + u'\\'
164165
def _check(self): return Saves_Profiles.local == self.relativePath
165166
def _enable(self): return not self._check()
166167
def Execute(self):
@@ -186,7 +187,7 @@ def menu_help(self):
186187
return _(u'Set profile to the default (My Games/Saves)')
187188

188189
@property
189-
def relativePath(self): return u'Saves\\'
190+
def relativePath(self): return bush.game.saveProfilesKey[2]
190191

191192
class _Edit(ItemLink):
192193
_text = _(u"Edit Profiles...")
@@ -595,15 +596,17 @@ def _initData(self, window, selection):
595596
class _Default(EnabledLink):
596597
_text = _(u'Default')
597598
_help = _self._help_str % bass.dirs['saveBase'].join(u'Saves')
598-
def _enable(self): return Save_Move.local != u'Saves\\'
599+
def _enable(self):
600+
return Save_Move.local != bush.game.saveProfilesKey[2]
599601
def Execute(self): _self.MoveFiles(_(u'Default'))
600602
class _SaveProfileLink(EnabledLink):
601603
@property
602604
def menu_help(self):
603605
return _self._help_str % bass.dirs['saveBase'].join(
604606
u'Saves', self._text)
605607
def _enable(self):
606-
return Save_Move.local != (u'Saves\\' + self._text + u'\\')
608+
return Save_Move.local != (bush.game.saveProfilesKey[2] +
609+
self._text + u'\\')
607610
def Execute(self): _self.MoveFiles(self._text)
608611
self.__class__.choiceLinkType = _SaveProfileLink
609612
self.extraItems = [_Default()]

Mopy/bash/bosh/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,7 @@ def _setLocalSaveFromIni(self):
26632663
# saveInfos singleton is constructed in InitData after bosh.oblivionIni
26642664
self.localSave = oblivionIni.getSetting(
26652665
bush.game.saveProfilesKey[0], bush.game.saveProfilesKey[1],
2666-
u'Saves\\')
2666+
bush.game.saveProfilesKey[2])
26672667
# Hopefully will solve issues with unicode usernames # TODO(ut) test
26682668
self.localSave = decode(self.localSave) # encoding = 'cp1252' ?
26692669

@@ -2673,7 +2673,7 @@ def __init__(self):
26732673
ur'((quick|auto)save(\.bak)+|(' + # quick or auto save.bak(.bak...)
26742674
_ext + ur'|' + _ext[:-1] + ur'r' + ur'))$', # enabled/disabled save
26752675
re.I | re.U)
2676-
self.localSave = u'Saves\\'
2676+
self.localSave = bush.game.saveProfilesKey[2]
26772677
self._setLocalSaveFromIni()
26782678
super(SaveInfos, self).__init__(dirs['saveBase'].join(self.localSave),
26792679
factory=SaveInfo)

Mopy/bash/game/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ class pnd(object):
203203
voice_dir = [u'sound', u'voice']
204204

205205
# INI setting used to setup Save Profiles
206-
# (section,key)
207-
saveProfilesKey = (u'General', u'SLocalSavePath')
206+
# (section, key, prefix)
207+
saveProfilesKey = (u'General', u'SLocalSavePath', u'Saves\\')
208208

209209
# BAIN:
210210
# These are the allowed default data directories that BAIN can install to

0 commit comments

Comments
 (0)