-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major rework of Help system as mostly popups; support <a> links
- Loading branch information
Showing
3 changed files
with
74 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<head><title>Controller Modifiers</title></head> | ||
<body> | ||
<p>Extra controller modifiers were added in Homecoming Issue 27, Page 1. They can be used to make extra "chord"-style binds using a controller. The details of this scheme are too complicated to summarize here. Please check the <a href="https://wiki.homecomingservers.com/wiki/Issue_27_Page_1#Enhanced_Gamepad_Support">Patch Notes</a> for details.</p> | ||
|
||
<p>Note that BindControl does <b>NOT</b> set up these modifiers for you. This configuration is intended to match whatever configuration you have manually added to the game with the <code>/controller_modifiers</code> and <code>/extra_modifiers</code> commands.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,94 @@ | ||
import sys | ||
import os | ||
from typing import Dict | ||
import webbrowser | ||
import wx | ||
import wx.html | ||
from Icon import GetIcon | ||
|
||
class HelpWindow(wx.MiniFrame): | ||
def __init__(self, parent, filename): | ||
wx.MiniFrame.__init__(self, parent, size = (800, 600), | ||
style = wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP|wx.RESIZE_BORDER) | ||
class HelpHTMLWindow(wx.html.HtmlWindow): | ||
def __init__(self, parent, filename, size = (800, 600)): | ||
wx.html.HtmlWindow.__init__(self, parent, size = size) | ||
|
||
self.manualsizer = wx.BoxSizer(wx.VERTICAL) | ||
self.manualpane = wx.html.HtmlWindow(self, size = (800, 600)) | ||
self.manualpane.SetRelatedFrame(self, '%s') | ||
self.manualsizer.Add(self.manualpane, 1, wx.EXPAND) | ||
self.SetSizer(self.manualsizer) | ||
base_path = getattr(sys, '_MEIPASS', '') | ||
if base_path: | ||
base_path = base_path + "/Help/" | ||
else: | ||
base_path = os.path.dirname(os.path.abspath(__file__)) | ||
self.manualpane.LoadFile(f"{base_path}/{filename}") | ||
self.LoadFile(f"{base_path}/{filename}") | ||
|
||
self.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.HandleLinkClicked) | ||
|
||
def HandleLinkClicked(self, evt): | ||
linkinfo = evt.GetLinkInfo() | ||
page = linkinfo.GetHref() | ||
webbrowser.open(page) | ||
|
||
|
||
class HelpWindow(wx.MiniFrame): | ||
def __init__(self, parent, filename): | ||
wx.MiniFrame.__init__(self, parent, title = filename, size = (800, 600), | ||
style = wx.TINY_CAPTION|wx.DEFAULT_FRAME_STYLE) | ||
|
||
manualhtml = HelpHTMLWindow(self, filename) | ||
|
||
self.manualsizer = wx.BoxSizer(wx.VERTICAL) | ||
|
||
self.manualsizer.Add(manualhtml, 1, wx.EXPAND) | ||
self.SetSizer(self.manualsizer) | ||
|
||
self.Layout() | ||
|
||
HelpWindows[filename] = self | ||
|
||
class HelpButton(wx.BitmapButton): | ||
class HelpPopup(wx.PopupTransientWindow): | ||
def __init__(self, parent, filename): | ||
wx.PopupTransientWindow.__init__(self, parent) | ||
|
||
self.panel = wx.Panel(self) | ||
self.panel.SetBackgroundColour([127,127,127]) | ||
manualhtml = HelpHTMLWindow(self.panel, filename, size = (600, 300)) | ||
|
||
manualsizer = wx.BoxSizer(wx.VERTICAL) | ||
manualsizer.Add(manualhtml, 1, wx.EXPAND|wx.ALL, 3) | ||
|
||
self.panel.SetSizer(manualsizer) | ||
manualsizer.Fit(self.panel) | ||
manualsizer.Fit(self) | ||
self.Layout() | ||
|
||
HelpPopups[filename] = self | ||
|
||
class HelpButton(wx.BitmapButton): | ||
def __init__(self, parent, filename, type = "popup"): | ||
wx.BitmapButton.__init__(self, parent, -1, GetIcon('Help')) | ||
self.Filename = filename | ||
self.WinType = type | ||
|
||
self.Bind(wx.EVT_BUTTON, self.GetHelpHandler()) | ||
|
||
def GetHelpHandler(self): | ||
def OnClick(_): ShowHelpWindow(self.Parent, self.Filename) | ||
if self.WinType == "popup": | ||
def OnClick(event): ShowHelpPopup(self, self.Filename, event) | ||
else: | ||
def OnClick(event): ShowHelpWindow(self, self.Filename, event) | ||
return OnClick | ||
|
||
|
||
HelpWindows: Dict[str, HelpWindow] = {} | ||
def ShowHelpWindow(parent, filename): | ||
def ShowHelpWindow(parent, filename, _ = None): | ||
if not HelpWindows.get(filename, None): | ||
HelpWindows[filename] = HelpWindow(parent, filename) | ||
HelpWindows[filename].Show() | ||
|
||
HelpPopups: Dict[str, HelpPopup] = {} | ||
def ShowHelpPopup(self, filename, event): | ||
if not HelpPopups.get(filename, None): | ||
HelpPopups[filename] = HelpPopup(self, filename) | ||
|
||
btn = event.GetEventObject() | ||
pos = btn.ClientToScreen( (0,0) ) | ||
sz = btn.GetSize() | ||
HelpPopups[filename].Position(pos, (0, sz[1])) | ||
HelpPopups[filename].Popup() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters