Skip to content

Commit b7362f1

Browse files
committed
Initial release of beta-quality Popmenu Editor
This release features an all-new tab, the Popmenu Editor, which allows you to install, remove, and edit popmenus for use with the in-game UI. It also will format simple macros you can paste into the game to create a button for displaying a given popmenu. The tab is mostly self-documenting -- load a menu, click on the Test button to show it, use the right-mouse context menu to edit it. Create new menus, install ones from files found on the Internet, or delete ones you no longer want in the game. This feature currently ONLY works with Homecoming installations, and requires you to set the path to the game install in the Preferences dialog. This is VERY experimental -- expect bugs and weirdness, and file issues as you find them.
2 parents 2f85526 + f6d9485 commit b7362f1

13 files changed

+5786
-106
lines changed

BindControl.py

+37-37
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ def __init__(self, parent):
6161
config = wx.FileConfig('bindcontrol')
6262
wx.ConfigBase.Set(config)
6363
# 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')
6471
if not config.Exists('BindPath'):
6572
if platform.system() == 'Windows':
6673
bindpath = "C:\\coh\\"
@@ -165,22 +172,24 @@ def __init__(self, parent):
165172

166173
# Bottom Buttons
167174
# 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")
169177
self.ProfDirButton.SetToolTip("Configure the location where this Profile will write bindfiles")
170178
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")
172180
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")
174182
self.DeleteButton.SetToolTip("Delete all BindControl-managed files in the configured binds directory")
175183
BottomButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
184+
self.BottomButtonPanel.SetSizer(BottomButtonSizer)
176185
BottomButtonSizer.Add(self.ProfDirButton, 0, wx.EXPAND)
177186
BottomButtonSizer.Add(self.WriteButton, 1, wx.EXPAND)
178187
BottomButtonSizer.Add(self.DeleteButton, 0, wx.EXPAND)
179188
self.ProfDirButton.Bind(wx.EVT_BUTTON, self.OnProfDirButton)
180189
self.WriteButton .Bind(wx.EVT_BUTTON, self.OnWriteBindsButton)
181190
self.DeleteButton .Bind(wx.EVT_BUTTON, self.OnDeleteBindsButton)
182191

183-
self.Sizer.Add(BottomButtonSizer, 0, wx.EXPAND | wx.ALL, 10)
192+
self.Sizer.Add(self.BottomButtonPanel, 0, wx.EXPAND | wx.ALL, 10)
184193

185194
# Do not SetSizerAndFit() - Fit() is poison
186195
self.SetSizer(self.Sizer)
@@ -223,7 +232,8 @@ def SetupProfile(self):
223232
if config.ReadBool('SaveSizeAndPosition') and config.HasEntry('WinX') and config.HasEntry('WinY'):
224233
self.SetPosition((config.ReadInt('WinX'), config.ReadInt('WinY')))
225234

226-
self.PrefsDialog = PrefsDialog(self)
235+
self.Bind(wx.EVT_CLOSE, self.OnWindowClosing)
236+
227237
self.BindDirsWindow = None
228238

229239
self.SetupProfileUI()
@@ -266,6 +276,15 @@ def SetupProfileUI(self):
266276
self.WriteButton.Enable(enable)
267277
self.DeleteButton.Enable(enable)
268278

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+
269288
def OnProfileNew(self, _ = None):
270289
if self.CheckIfProfileNeedsSaving() == wx.CANCEL: return
271290
# loop eternally until we get a name we like
@@ -430,10 +449,16 @@ def OnProfDirButton(self, _ = None):
430449

431450
def CheckIfProfileNeedsSaving(self):
432451
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
437462
return result
438463

439464
def CheckProfDirButtonErrors(self):
@@ -506,34 +531,9 @@ def OnDeleteBindsButton(self, _):
506531
if not self.Profile: return
507532
self.Profile.DeleteBindFiles()
508533

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()
537537

538538
def OnMenuAboutBox(self, _):
539539
from datetime import datetime

0 commit comments

Comments
 (0)