Skip to content

Commit

Permalink
Initial release of beta-quality Popmenu Editor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
emersonrp committed Jan 19, 2025
2 parents 2f85526 + f6d9485 commit b7362f1
Show file tree
Hide file tree
Showing 13 changed files with 5,786 additions and 106 deletions.
74 changes: 37 additions & 37 deletions BindControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def __init__(self, parent):
config = wx.FileConfig('bindcontrol')
wx.ConfigBase.Set(config)
# Check each config bit for existence and set to default if no
if not config.Exists('GamePath'):
if platform.system() == 'Windows':
gamepath = "C:\\Games\\HC\\"
else:
gamepath = str(Path.home() / '.wine' / 'drive_c' / 'Games' / 'HC')
config.Write('GamePath', gamepath)
if not config.Exists('GameLang'): config.Write('GameLang', 'English')
if not config.Exists('BindPath'):
if platform.system() == 'Windows':
bindpath = "C:\\coh\\"
Expand Down Expand Up @@ -165,22 +172,24 @@ def __init__(self, parent):

# Bottom Buttons
# BUTTONS
self.ProfDirButton = cgButton(self, -1, "Set Binds Location")
self.BottomButtonPanel = wx.Panel(self)
self.ProfDirButton = cgButton(self.BottomButtonPanel, -1, "Set Binds Location")
self.ProfDirButton.SetToolTip("Configure the location where this Profile will write bindfiles")
self.ProfDirButton.DefaultToolTip = "Configure the location where this Profile will write bindfiles"
self.WriteButton = wx.Button(self, -1, "Write Binds")
self.WriteButton = wx.Button(self.BottomButtonPanel, -1, "Write Binds")
self.WriteButton.SetToolTip("Write out the bindfiles to the configured binds directory")
self.DeleteButton = wx.Button(self, -1, "Delete All Binds")
self.DeleteButton = wx.Button(self.BottomButtonPanel, -1, "Delete All Binds")
self.DeleteButton.SetToolTip("Delete all BindControl-managed files in the configured binds directory")
BottomButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
self.BottomButtonPanel.SetSizer(BottomButtonSizer)
BottomButtonSizer.Add(self.ProfDirButton, 0, wx.EXPAND)
BottomButtonSizer.Add(self.WriteButton, 1, wx.EXPAND)
BottomButtonSizer.Add(self.DeleteButton, 0, wx.EXPAND)
self.ProfDirButton.Bind(wx.EVT_BUTTON, self.OnProfDirButton)
self.WriteButton .Bind(wx.EVT_BUTTON, self.OnWriteBindsButton)
self.DeleteButton .Bind(wx.EVT_BUTTON, self.OnDeleteBindsButton)

self.Sizer.Add(BottomButtonSizer, 0, wx.EXPAND | wx.ALL, 10)
self.Sizer.Add(self.BottomButtonPanel, 0, wx.EXPAND | wx.ALL, 10)

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

self.PrefsDialog = PrefsDialog(self)
self.Bind(wx.EVT_CLOSE, self.OnWindowClosing)

self.BindDirsWindow = None

self.SetupProfileUI()
Expand Down Expand Up @@ -266,6 +276,15 @@ def SetupProfileUI(self):
self.WriteButton.Enable(enable)
self.DeleteButton.Enable(enable)

def OnPageChanged(self, evt):
if evt.GetSelection() == 6:
self.BottomButtonPanel.Hide()
if self.Profile:
self.Profile.PopmenuEditor.SynchronizeUI()
else:
self.BottomButtonPanel.Show(True)
self.Layout()

def OnProfileNew(self, _ = None):
if self.CheckIfProfileNeedsSaving() == wx.CANCEL: return
# loop eternally until we get a name we like
Expand Down Expand Up @@ -430,10 +449,16 @@ def OnProfDirButton(self, _ = None):

def CheckIfProfileNeedsSaving(self):
result = wx.OK
if self.Profile and self.Profile.Modified:
result = wx.MessageBox("Profile not saved, save now?", "Profile modified", wx.YES_NO|wx.CANCEL)
if result == wx.YES:
self.Profile.doSaveToFile()
if self.Profile:
if self.Profile.Modified:
result = wx.MessageBox("Profile not saved, save now?", "Profile modified", wx.YES_NO|wx.CANCEL)
if result == wx.YES:
self.Profile.doSaveToFile()
if self.Profile.PopmenuEditor.CheckForModifiedMenus():
result = wx.MessageBox("Some popmenus contain unsaved changes, return to editor?", "Popmenus modified", wx.YES_NO)
if result == wx.YES:
result = wx.CANCEL
self.Profile.SetSelection(6) # TODO - hardcoded "6" is ugly but meh
return result

def CheckProfDirButtonErrors(self):
Expand Down Expand Up @@ -506,34 +531,9 @@ def OnDeleteBindsButton(self, _):
if not self.Profile: return
self.Profile.DeleteBindFiles()

def OnMenuPrefsDialog(self, _):
if self.PrefsDialog.ShowModal() == wx.ID_OK:
config = wx.ConfigBase.Get()
config.Write('BindPath', self.PrefsDialog.bindsDirPicker.GetPath())
if self.PrefsDialog.gameBindsDirPicker:
config.Write('GameBindPath', self.PrefsDialog.gameBindsDirPicker.GetValue())
config.WriteBool('UseSplitModKeys', self.PrefsDialog.UseSplitModKeys.GetValue())
config.WriteBool('FlushAllBinds', self.PrefsDialog.FlushAllBinds.GetValue())
config.Write('ResetKey', self.PrefsDialog.ResetKey.GetLabel())

config.WriteBool('StartWithLastProfile', self.PrefsDialog.StartWithLastProfile.GetValue())
config.Write('ProfilePath', self.PrefsDialog.ProfileDirPicker.GetPath())

config.WriteBool('SaveSizeAndPosition', self.PrefsDialog.SaveSizeAndPosition.GetValue())

config.Write('ControllerMod1', self.PrefsDialog.ControllerModPicker1.GetStringSelection())
config.Write('ControllerMod2', self.PrefsDialog.ControllerModPicker2.GetStringSelection())
config.Write('ExtraMod1', self.PrefsDialog.ExtraModPicker1.GetStringSelection())
config.Write('ExtraMod2', self.PrefsDialog.ExtraModPicker2.GetStringSelection())
config.Write('ExtraMod3', self.PrefsDialog.ExtraModPicker3.GetStringSelection())
config.Write('ExtraMod4', self.PrefsDialog.ExtraModPicker4.GetStringSelection())

config.WriteBool('VerboseBLF', self.PrefsDialog.VerboseBLF.GetValue())
config.WriteBool('CrashOnBindError', self.PrefsDialog.CrashOnBindError.GetValue())
config.WriteBool('ShowInspector', self.PrefsDialog.ShowInspector.GetValue())
config.WriteBool('ShowDebugMessages', self.PrefsDialog.ShowDebugMessages.GetValue())

config.Flush()
def OnMenuPrefsDialog(self, _ = None):
with PrefsDialog(self) as dlg:
dlg.ShowAndUpdatePrefs()

def OnMenuAboutBox(self, _):
from datetime import datetime
Expand Down
Loading

0 comments on commit b7362f1

Please sign in to comment.