@@ -61,6 +61,13 @@ def __init__(self, parent):
61
61
config = wx .FileConfig ('bindcontrol' )
62
62
wx .ConfigBase .Set (config )
63
63
# Check each config bit for existence and set to default if no
64
+ if not config .Exists ('GamePath' ):
65
+ if platform .system () == 'Windows' :
66
+ gamepath = "C:\\ Games\\ HC\\ "
67
+ else :
68
+ gamepath = str (Path .home () / '.wine' / 'drive_c' / 'Games' / 'HC' )
69
+ config .Write ('GamePath' , gamepath )
70
+ if not config .Exists ('GameLang' ): config .Write ('GameLang' , 'English' )
64
71
if not config .Exists ('BindPath' ):
65
72
if platform .system () == 'Windows' :
66
73
bindpath = "C:\\ coh\\ "
@@ -165,22 +172,24 @@ def __init__(self, parent):
165
172
166
173
# Bottom Buttons
167
174
# BUTTONS
168
- self .ProfDirButton = cgButton (self , - 1 , "Set Binds Location" )
175
+ self .BottomButtonPanel = wx .Panel (self )
176
+ self .ProfDirButton = cgButton (self .BottomButtonPanel , - 1 , "Set Binds Location" )
169
177
self .ProfDirButton .SetToolTip ("Configure the location where this Profile will write bindfiles" )
170
178
self .ProfDirButton .DefaultToolTip = "Configure the location where this Profile will write bindfiles"
171
- self .WriteButton = wx .Button (self , - 1 , "Write Binds" )
179
+ self .WriteButton = wx .Button (self . BottomButtonPanel , - 1 , "Write Binds" )
172
180
self .WriteButton .SetToolTip ("Write out the bindfiles to the configured binds directory" )
173
- self .DeleteButton = wx .Button (self , - 1 , "Delete All Binds" )
181
+ self .DeleteButton = wx .Button (self . BottomButtonPanel , - 1 , "Delete All Binds" )
174
182
self .DeleteButton .SetToolTip ("Delete all BindControl-managed files in the configured binds directory" )
175
183
BottomButtonSizer = wx .BoxSizer (wx .HORIZONTAL )
184
+ self .BottomButtonPanel .SetSizer (BottomButtonSizer )
176
185
BottomButtonSizer .Add (self .ProfDirButton , 0 , wx .EXPAND )
177
186
BottomButtonSizer .Add (self .WriteButton , 1 , wx .EXPAND )
178
187
BottomButtonSizer .Add (self .DeleteButton , 0 , wx .EXPAND )
179
188
self .ProfDirButton .Bind (wx .EVT_BUTTON , self .OnProfDirButton )
180
189
self .WriteButton .Bind (wx .EVT_BUTTON , self .OnWriteBindsButton )
181
190
self .DeleteButton .Bind (wx .EVT_BUTTON , self .OnDeleteBindsButton )
182
191
183
- self .Sizer .Add (BottomButtonSizer , 0 , wx .EXPAND | wx .ALL , 10 )
192
+ self .Sizer .Add (self . BottomButtonPanel , 0 , wx .EXPAND | wx .ALL , 10 )
184
193
185
194
# Do not SetSizerAndFit() - Fit() is poison
186
195
self .SetSizer (self .Sizer )
@@ -223,7 +232,8 @@ def SetupProfile(self):
223
232
if config .ReadBool ('SaveSizeAndPosition' ) and config .HasEntry ('WinX' ) and config .HasEntry ('WinY' ):
224
233
self .SetPosition ((config .ReadInt ('WinX' ), config .ReadInt ('WinY' )))
225
234
226
- self .PrefsDialog = PrefsDialog (self )
235
+ self .Bind (wx .EVT_CLOSE , self .OnWindowClosing )
236
+
227
237
self .BindDirsWindow = None
228
238
229
239
self .SetupProfileUI ()
@@ -266,6 +276,15 @@ def SetupProfileUI(self):
266
276
self .WriteButton .Enable (enable )
267
277
self .DeleteButton .Enable (enable )
268
278
279
+ def OnPageChanged (self , evt ):
280
+ if evt .GetSelection () == 6 :
281
+ self .BottomButtonPanel .Hide ()
282
+ if self .Profile :
283
+ self .Profile .PopmenuEditor .SynchronizeUI ()
284
+ else :
285
+ self .BottomButtonPanel .Show (True )
286
+ self .Layout ()
287
+
269
288
def OnProfileNew (self , _ = None ):
270
289
if self .CheckIfProfileNeedsSaving () == wx .CANCEL : return
271
290
# loop eternally until we get a name we like
@@ -430,10 +449,16 @@ def OnProfDirButton(self, _ = None):
430
449
431
450
def CheckIfProfileNeedsSaving (self ):
432
451
result = wx .OK
433
- if self .Profile and self .Profile .Modified :
434
- result = wx .MessageBox ("Profile not saved, save now?" , "Profile modified" , wx .YES_NO | wx .CANCEL )
435
- if result == wx .YES :
436
- self .Profile .doSaveToFile ()
452
+ if self .Profile :
453
+ if self .Profile .Modified :
454
+ result = wx .MessageBox ("Profile not saved, save now?" , "Profile modified" , wx .YES_NO | wx .CANCEL )
455
+ if result == wx .YES :
456
+ self .Profile .doSaveToFile ()
457
+ if self .Profile .PopmenuEditor .CheckForModifiedMenus ():
458
+ result = wx .MessageBox ("Some popmenus contain unsaved changes, return to editor?" , "Popmenus modified" , wx .YES_NO )
459
+ if result == wx .YES :
460
+ result = wx .CANCEL
461
+ self .Profile .SetSelection (6 ) # TODO - hardcoded "6" is ugly but meh
437
462
return result
438
463
439
464
def CheckProfDirButtonErrors (self ):
@@ -506,34 +531,9 @@ def OnDeleteBindsButton(self, _):
506
531
if not self .Profile : return
507
532
self .Profile .DeleteBindFiles ()
508
533
509
- def OnMenuPrefsDialog (self , _ ):
510
- if self .PrefsDialog .ShowModal () == wx .ID_OK :
511
- config = wx .ConfigBase .Get ()
512
- config .Write ('BindPath' , self .PrefsDialog .bindsDirPicker .GetPath ())
513
- if self .PrefsDialog .gameBindsDirPicker :
514
- config .Write ('GameBindPath' , self .PrefsDialog .gameBindsDirPicker .GetValue ())
515
- config .WriteBool ('UseSplitModKeys' , self .PrefsDialog .UseSplitModKeys .GetValue ())
516
- config .WriteBool ('FlushAllBinds' , self .PrefsDialog .FlushAllBinds .GetValue ())
517
- config .Write ('ResetKey' , self .PrefsDialog .ResetKey .GetLabel ())
518
-
519
- config .WriteBool ('StartWithLastProfile' , self .PrefsDialog .StartWithLastProfile .GetValue ())
520
- config .Write ('ProfilePath' , self .PrefsDialog .ProfileDirPicker .GetPath ())
521
-
522
- config .WriteBool ('SaveSizeAndPosition' , self .PrefsDialog .SaveSizeAndPosition .GetValue ())
523
-
524
- config .Write ('ControllerMod1' , self .PrefsDialog .ControllerModPicker1 .GetStringSelection ())
525
- config .Write ('ControllerMod2' , self .PrefsDialog .ControllerModPicker2 .GetStringSelection ())
526
- config .Write ('ExtraMod1' , self .PrefsDialog .ExtraModPicker1 .GetStringSelection ())
527
- config .Write ('ExtraMod2' , self .PrefsDialog .ExtraModPicker2 .GetStringSelection ())
528
- config .Write ('ExtraMod3' , self .PrefsDialog .ExtraModPicker3 .GetStringSelection ())
529
- config .Write ('ExtraMod4' , self .PrefsDialog .ExtraModPicker4 .GetStringSelection ())
530
-
531
- config .WriteBool ('VerboseBLF' , self .PrefsDialog .VerboseBLF .GetValue ())
532
- config .WriteBool ('CrashOnBindError' , self .PrefsDialog .CrashOnBindError .GetValue ())
533
- config .WriteBool ('ShowInspector' , self .PrefsDialog .ShowInspector .GetValue ())
534
- config .WriteBool ('ShowDebugMessages' , self .PrefsDialog .ShowDebugMessages .GetValue ())
535
-
536
- config .Flush ()
534
+ def OnMenuPrefsDialog (self , _ = None ):
535
+ with PrefsDialog (self ) as dlg :
536
+ dlg .ShowAndUpdatePrefs ()
537
537
538
538
def OnMenuAboutBox (self , _ ):
539
539
from datetime import datetime
0 commit comments