Skip to content

Commit

Permalink
Add Next / Prev Tray buttons to Gameplay tab
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonrp committed Aug 4, 2024
1 parent f099aa2 commit 7f9ba9c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Help/PowerTrayButtons.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<body>
<h2>Power Tray Buttons</h2>
<p>The Power Tray Buttons section offers the ability to rebind the keys that trigger the buttons in the main powers trays in the game's UI. The defaults are set to the same as the "Modern" profile from Homecoming Issue 27, Page 7.</p>
<p>If you don't want to change these keybinds from the defaults, it's perfectly reasonable to leave the "Server Tray" and "Tray #" rows unchecked and use the game's existing keybinds. This functionality is just for people who are interested in this degree of control over their keybinds.</p>
<p>If you don't want to change these keybinds from the defaults, it's perfectly reasonable to leave the Main Tray, Secondary Tray, Tertiary Tray, and Server Tray checkboxes unchecked and use the game's existing keybinds. This functionality is just for people who are interested in this degree of control over their keybinds.</p>
</body>
</html>
1 change: 1 addition & 0 deletions Page/CustomBinds.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def OnDeleteButton(self, evt):
self.PaneSizer.Remove(sizer)
self.Panes.remove(delButton.BindPane)
delButton.BindPane.Destroy()
self.Profile.CheckAllConflicts()
self.Layout()
evt.Skip()

Expand Down
68 changes: 36 additions & 32 deletions Page/Gameplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@ def __init__(self, parent):
'Tray3Enabled' : False,
'Tray4Enabled' : False,
}
for tray in (3,2,1):
mod = ['', '', 'ALT+', 'SHIFT+'][tray]
for tray in (4,3,2,1):
mod = ['', '', 'ALT+', 'SHIFT+', 'CTRL+'][tray]
name = ['', 'Main', 'Secondary', 'Tertiary', 'Server'][tray]
self.Init[f"Tray{tray}Next"] = ''
self.Init[f"Tray{tray}Prev"] = ''
UI.Labels[f"Tray{tray}Next"] = "Next Tray"
UI.Labels[f"Tray{tray}Prev"] = "Previous Tray"
for button in (1,2,3,4,5,6,7,8,9,0):
ctlname = f'Tray{tray}Button{button}'
self.Init[ctlname] = f"{mod}{button}"
UI.Labels[ctlname] = f"Tray {tray}, Button {button}"

for button in (1,2,3,4,5,6,7,8,9,0):
ctlname = f'Tray4Button{button}'
self.Init[ctlname] = f"CTRL+{button}"
UI.Labels[ctlname] = f"Server Tray, Button {button}"

UI.Labels[ctlname] = f"{name} Tray, Button {button}"

def BuildPage(self):

Expand All @@ -71,29 +70,11 @@ def BuildPage(self):
self.FillTrayButtons[b].Bind(wx.EVT_BUTTON, self.OnFillTray)
self.FillTrayButtons[b].SetToolTip("Fill the buttons with the numbers 1 - 0. Hold a modifier key while clicking to use that modifier key in the binds.")

trayGridSizer = wx.FlexGridSizer(12,4,0)
# server tray at the top
checkbox = wx.CheckBox(staticbox, wx.ID_ANY, label = f"Server Tray")
checkbox.SetValue(self.Init.get(f'Tray4Enabled', False))
checkbox.Bind(wx.EVT_CHECKBOX, self.SynchronizeUI)
self.Ctrls[f'Tray4Enabled'] = checkbox
trayGridSizer.Add(checkbox, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 5)
trayGridSizer = wx.FlexGridSizer(14,4,0)

for button in (1,2,3,4,5,6,7,8,9,0):
ctlname = f'Tray4Button{button}'
traybutton = bcKeyButton(staticbox, wx.ID_ANY, init = {
'CtlName' : ctlname,
'Key' : self.Init[ctlname],
'AlwaysShorten' : True,
})
self.Ctrls[ctlname] = traybutton

trayGridSizer.Add(traybutton, 1, wx.EXPAND)
trayGridSizer.Add(self.FillTrayButtons[4], 1, wx.EXPAND|wx.LEFT, 10)

# Then the three main trays
for tray in (3,2,1):
checkbox = wx.CheckBox(staticbox, wx.ID_ANY, label = f"Tray {tray}")
for tray in (4,3,2,1):
label = ['', 'Main', 'Secondary', 'Tertiary', 'Server'][tray]
checkbox = wx.CheckBox(staticbox, wx.ID_ANY, label = f"{label} Tray")
checkbox.SetValue(self.Init.get(f'Tray{tray}Enabled', False))
checkbox.Bind(wx.EVT_CHECKBOX, self.SynchronizeUI)
self.Ctrls[f'Tray{tray}Enabled'] = checkbox
Expand All @@ -109,7 +90,17 @@ def BuildPage(self):
self.Ctrls[ctlname] = traybutton

trayGridSizer.Add(traybutton, 1, wx.EXPAND)
trayGridSizer.Add(self.FillTrayButtons[tray], 1, wx.EXPAND|wx.LEFT, 10)
trayGridSizer.Add(self.FillTrayButtons[tray], 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 10)
if tray == 4:
trayGridSizer.Add(wx.StaticText(staticbox, wx.ID_ANY, "Prev Tray"), 1, wx.ALIGN_CENTER|wx.LEFT, 6)
trayGridSizer.Add(wx.StaticText(staticbox, wx.ID_ANY, "Next Tray"), 1, wx.ALIGN_CENTER|wx.LEFT, 6)
else:
prevbutton = bcKeyButton(staticbox, wx.ID_ANY, init = { 'CtlName' : f"Tray{tray}Prev",})
self.Ctrls[f"Tray{tray}Prev"] = prevbutton
nextbutton = bcKeyButton(staticbox, wx.ID_ANY, init = { 'CtlName' : f"Tray{tray}Next",})
self.Ctrls[f"Tray{tray}Next"] = nextbutton
trayGridSizer.Add(prevbutton, 1, wx.ALIGN_CENTER)
trayGridSizer.Add(nextbutton, 1, wx.ALIGN_CENTER)

traySizer.Add(trayGridSizer, 0, wx.ALL, 10)
traygridbutton = HelpButton(staticbox, 'PowerTrayButtons.html')
Expand Down Expand Up @@ -216,6 +207,9 @@ def SynchronizeUI(self, evt = None):
self.FillTrayButtons[tray].Enable(self.GetState(f"Tray{tray}Enabled"))
for button in (1,2,3,4,5,6,7,8,9,0):
self.Ctrls[f"Tray{tray}Button{button}"].Enable(self.GetState(f'Tray{tray}Enabled'))
if tray != 4:
self.Ctrls[f"Tray{tray}Prev"].Enable(self.GetState(f"Tray{tray}Enabled"))
self.Ctrls[f"Tray{tray}Next"].Enable(self.GetState(f"Tray{tray}Enabled"))
self.Profile.CheckAllConflicts()
if evt: evt.Skip()

Expand Down Expand Up @@ -260,6 +254,16 @@ def PopulateBindFiles(self):
if self.GetState('Tray4Enabled'):
ResetFile.SetBind(self.Ctrls[f"Tray4Button{button}"].MakeFileKeyBind(f"powexec_serverslot {slotbutton}"))

if self.GetState('Tray1Enabled'):
ResetFile.SetBind(self.Ctrls[f"Tray1Prev"].MakeFileKeyBind("prev_tray"))
ResetFile.SetBind(self.Ctrls[f"Tray1Next"].MakeFileKeyBind("next_tray"))
if self.GetState('Tray2Enabled'):
ResetFile.SetBind(self.Ctrls[f"Tray2Prev"].MakeFileKeyBind("prev_tray_alt"))
ResetFile.SetBind(self.Ctrls[f"Tray2Next"].MakeFileKeyBind("next_tray_alt"))
if self.GetState('Tray3Enabled'):
ResetFile.SetBind(self.Ctrls[f"Tray3Prev"].MakeFileKeyBind("prev_tray_alt2"))
ResetFile.SetBind(self.Ctrls[f"Tray3Next"].MakeFileKeyBind("next_tray_alt2"))

### Team / Pet Select
if self.GetState('TPSEnable'):
if (self.GetState('TPSSelMode') != "Pets Only"
Expand Down

0 comments on commit 7f9ba9c

Please sign in to comment.