Skip to content

Commit dab8535

Browse files
committed
Fixes to the Mastermind Release
This release fixes a couple of the known misbehaviors with v.20, the "Mastermind Release": * Nulti-word pet names are now fully supported and checked in their entirety for uniqueness. * The warning dialog that some pet names have errors, which is shows at write-binds time, will only appear if binds are configured that require pet names to exist and be unique. If by-name binds and bodyguard mode bind keys are left blank, that dialog will be skipped. TODO: still might update the red error display on pet names also only to appear if unique names are required.
2 parents 6150cf5 + c33767f commit dab8535

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

Page/Mastermind.py

+18-13
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,9 @@ def CheckUndefNames(self):
385385
def CheckUniqueNames(self):
386386
if (self.Profile.Archetype() == "Mastermind"):
387387
names = []
388-
wasMultiWord = [False] * 6
389388
for i in (1,2,3,4,5,6):
390389
ctrl = self.Ctrls[f'Pet{i}Name']
391-
value = ctrl.GetValue()
392-
# if we contain multiple words, use the longest
393-
words = value.split()
394-
if len(words) > 1:
395-
wasMultiWord[i-1] = True
396-
value = max(words, key = len)
390+
value = ctrl.GetValue().strip() # don't allow whitespace at the ends
397391
names.append(value)
398392

399393
# we stash this away every time we calculate it so we can
@@ -404,8 +398,7 @@ def CheckUniqueNames(self):
404398
if self.uniqueNames[i-1]:
405399
ctrl.RemoveError('unique')
406400
else:
407-
MWWarning = " BindControl only uses the longest word of a multi-word name." if wasMultiWord[i-1] else ""
408-
ctrl.AddError('unique', f'This pet name is not different enough to identify it uniquely.{MWWarning}')
401+
ctrl.AddError('unique', f'This pet name is not different enough to identify it uniquely.')
409402
else:
410403
for i in (1,2,3,4,5,6):
411404
ctrl = self.Ctrls[f'Pet{i}Name']
@@ -562,12 +555,21 @@ def PopulateBindFiles(self):
562555

563556
if not profile.Archetype() == 'Mastermind': return True
564557

558+
needUniqueNames = False
565559
for i in (1,2,3,4,5,6):
566-
ctrl = self.Ctrls[f'Pet{i}Name']
567-
if ctrl.IsEnabled() and ctrl.HasAnyError():
568-
result = wx.MessageBox("One or more of your pet names has errors. You can continue to write these binds but they are likely not to work well in-game. Continue?", "Name Error", wx.YES_NO)
569-
if result == wx.NO: return False
560+
if self.Ctrls[f'PetSelect{i}'].GetLabel():
561+
needUniqueNames = True
570562
break
563+
if self.Ctrls['PetBodyguard'].GetLabel():
564+
needUniqueNames = True
565+
566+
if needUniqueNames:
567+
for i in (1,2,3,4,5,6):
568+
ctrl = self.Ctrls[f'Pet{i}Name']
569+
if ctrl.IsEnabled() and ctrl.HasAnyError():
570+
result = wx.MessageBox("One or more of your pet names has errors. You can continue to write these binds but they are likely not to work well in-game. Continue?", "Name Error", wx.YES_NO)
571+
if result == wx.NO: return False
572+
break
571573

572574
### Sandolphan binds
573575
if self.GetState('PetCmdEnable'):
@@ -778,6 +780,9 @@ def FindSmallestUniqueSubstring(names):
778780

779781
if not foundMatch:
780782
### This substr works!
783+
# If it contains a space, put "" around it
784+
if re.match(r'\s', substr):
785+
substr = f'"{substr}"'
781786
uniqueNames[nameInd] = substr
782787
break
783788
else:

0 commit comments

Comments
 (0)