system for more thorough tooltips in hotkey and controller config dialogs (so, for instance, the function of a key can be described)
This commit is contained in:
parent
813bfa6ad4
commit
8c1eaf25ff
|
@ -2,6 +2,16 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
//TODO [LARP] - It's pointless and annoying to store such a big structure filled with static information
|
||||
//use this instead
|
||||
//public class UserBinding
|
||||
//{
|
||||
// public string DisplayName;
|
||||
// public string Bindings;
|
||||
//}
|
||||
//...also. We should consider using something other than DisplayName for keying, maybe make a KEYNAME distinct from displayname.
|
||||
//displayname is OK for now though.
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class Binding
|
||||
|
@ -10,6 +20,7 @@ namespace BizHawk.Client.Common
|
|||
public string Bindings;
|
||||
public string DefaultBinding;
|
||||
public string TabGroup;
|
||||
public string ToolTip;
|
||||
public int Ordinal = 0;
|
||||
}
|
||||
|
||||
|
@ -55,6 +66,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void ResolveWithDefaults()
|
||||
{
|
||||
//TODO - this method is potentially disastrously O(N^2) slow due to linear search nested in loop
|
||||
|
||||
//Add missing entries
|
||||
foreach (Binding default_binding in DefaultValues)
|
||||
{
|
||||
|
@ -63,6 +76,15 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
Bindings.Add(default_binding);
|
||||
}
|
||||
else
|
||||
{
|
||||
//patch entries with updated settings (necessary because of TODO LARP
|
||||
binding.Ordinal = default_binding.Ordinal;
|
||||
binding.DefaultBinding = default_binding.DefaultBinding;
|
||||
binding.TabGroup = default_binding.TabGroup;
|
||||
binding.ToolTip = default_binding.ToolTip;
|
||||
binding.Ordinal = default_binding.Ordinal;
|
||||
}
|
||||
}
|
||||
|
||||
List<Binding> entriesToRemove = (from entry in Bindings let binding = DefaultValues.FirstOrDefault(x => x.DisplayName == entry.DisplayName) where binding == null select entry).ToList();
|
||||
|
@ -73,13 +95,17 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
Bindings.Remove(entry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static List<Binding> s_DefaultValues;
|
||||
|
||||
public static List<Binding> DefaultValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<Binding>
|
||||
if(s_DefaultValues == null)
|
||||
s_DefaultValues = new List<Binding>
|
||||
{
|
||||
//General
|
||||
new Binding { DisplayName = "Frame Advance", Bindings = "F", TabGroup = "General", DefaultBinding = "F", Ordinal = 0 },
|
||||
|
@ -197,16 +223,18 @@ namespace BizHawk.Client.Common
|
|||
new Binding { DisplayName = "Toggle OBJ 4", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 7 },
|
||||
|
||||
//Analog
|
||||
new Binding { DisplayName = "Y Up Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 0 },
|
||||
new Binding { DisplayName = "Y Up Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 1 },
|
||||
new Binding { DisplayName = "Y Down Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 2 },
|
||||
new Binding { DisplayName = "Y Down Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 3 },
|
||||
new Binding { DisplayName = "X Up Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 4 },
|
||||
new Binding { DisplayName = "X Up Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 5 },
|
||||
new Binding { DisplayName = "X Down Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 6 },
|
||||
new Binding { DisplayName = "X Down Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 7 },
|
||||
new Binding { DisplayName = "Y Up Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 0, ToolTip = "For Virtual Pad" },
|
||||
new Binding { DisplayName = "Y Up Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 1, ToolTip = "For Virtual Pad" },
|
||||
new Binding { DisplayName = "Y Down Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 2, ToolTip = "For Virtual Pad" },
|
||||
new Binding { DisplayName = "Y Down Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 3, ToolTip = "For Virtual Pad" },
|
||||
new Binding { DisplayName = "X Up Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 4, ToolTip = "For Virtual Pad" },
|
||||
new Binding { DisplayName = "X Up Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 5, ToolTip = "For Virtual Pad" },
|
||||
new Binding { DisplayName = "X Down Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 6, ToolTip = "For Virtual Pad" },
|
||||
new Binding { DisplayName = "X Down Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 7, ToolTip = "For Virtual Pad" },
|
||||
|
||||
};
|
||||
|
||||
return s_DefaultValues;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private Control CreateNormalPanel(Dictionary<string, string> settings, List<string> buttons, Size size)
|
||||
{
|
||||
var cp = new ControllerConfigPanel { Dock = DockStyle.Fill };
|
||||
cp.Tooltip = toolTip1;
|
||||
cp.LoadSettings(settings, checkBoxAutoTab.Checked, buttons, size.Width, size.Height);
|
||||
return cp;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
public int ColumnWidth = 280;
|
||||
public int LabelWidth = 60;
|
||||
|
||||
public ToolTip Tooltip;
|
||||
|
||||
protected List<InputCompositeWidget> Inputs = new List<InputCompositeWidget>();
|
||||
protected List<Label> Labels = new List<Label>();
|
||||
|
||||
|
@ -117,6 +119,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
AutoTab = this.Autotab
|
||||
};
|
||||
|
||||
iw.SetupTooltip(Tooltip, null);
|
||||
|
||||
iw.BringToFront();
|
||||
Controls.Add(iw);
|
||||
Inputs.Add(iw);
|
||||
|
@ -125,6 +129,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
Location = new Point(x + InputSize + LabelPadding, y + 3),
|
||||
Text = buttons[i].Replace('_', ' ').Trim(),
|
||||
};
|
||||
|
||||
//Tooltip.SetToolTip(label, null); //??? not supported yet
|
||||
|
||||
Controls.Add(label);
|
||||
Labels.Add(label);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HotkeyConfig));
|
||||
this.label38 = new System.Windows.Forms.Label();
|
||||
this.AutoTabCheckBox = new System.Windows.Forms.CheckBox();
|
||||
|
@ -40,6 +41,7 @@
|
|||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.HotkeyTabControl.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -47,7 +49,7 @@
|
|||
//
|
||||
this.label38.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label38.AutoSize = true;
|
||||
this.label38.Location = new System.Drawing.Point(45, 441);
|
||||
this.label38.Location = new System.Drawing.Point(39, 441);
|
||||
this.label38.Name = "label38";
|
||||
this.label38.Size = new System.Drawing.Size(153, 13);
|
||||
this.label38.TabIndex = 4;
|
||||
|
@ -122,6 +124,7 @@
|
|||
this.RestoreDefaults.TabIndex = 105;
|
||||
this.RestoreDefaults.TabStop = false;
|
||||
this.RestoreDefaults.Text = "&Defaults";
|
||||
this.toolTip1.SetToolTip(this.RestoreDefaults, "Reses _all_ bindings to default.");
|
||||
this.RestoreDefaults.UseVisualStyleBackColor = true;
|
||||
this.RestoreDefaults.Click += new System.EventHandler(this.RestoreDefaults_Click);
|
||||
//
|
||||
|
@ -149,7 +152,7 @@
|
|||
//
|
||||
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(204, 441);
|
||||
this.label2.Location = new System.Drawing.Point(194, 441);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(168, 13);
|
||||
this.label2.TabIndex = 108;
|
||||
|
@ -205,5 +208,6 @@
|
|||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.ToolTip toolTip1;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
IDB_SAVE.Focus(); // A very dirty hack to avoid https://code.google.com/p/bizhawk/issues/detail?id=161
|
||||
};
|
||||
|
||||
tabPage1.Focus();
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
|
@ -130,13 +131,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
var w = new InputCompositeWidget
|
||||
{
|
||||
Bindings = b.Bindings,
|
||||
Location = new Point(_x + iwOffsetX, _y + iwOffsetY),
|
||||
AutoTab = AutoTabCheckBox.Checked,
|
||||
Width = iwWidth,
|
||||
WidgetName = b.DisplayName,
|
||||
};
|
||||
|
||||
w.SetupTooltip(toolTip1, b.ToolTip);
|
||||
toolTip1.SetToolTip(l, b.ToolTip);
|
||||
|
||||
w.Bindings = b.Bindings;
|
||||
|
||||
tb.Controls.Add(l);
|
||||
tb.Controls.Add(w);
|
||||
|
||||
|
|
|
@ -117,6 +117,9 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
|
|
@ -68,7 +68,6 @@
|
|||
// widget
|
||||
//
|
||||
this.widget.AutoTab = true;
|
||||
this.widget.Bindings = "button1";
|
||||
this.widget.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.widget.Location = new System.Drawing.Point(0, 0);
|
||||
this.widget.Margin = new System.Windows.Forms.Padding(0);
|
||||
|
|
|
@ -19,9 +19,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
DropdownMenu.ItemClicked += new ToolStripItemClickedEventHandler(DropdownMenu_ItemClicked);
|
||||
DropdownMenu.PreviewKeyDown += new PreviewKeyDownEventHandler(DropdownMenu_PreviewKeyDown);
|
||||
foreach (var str in InputWidget.SpecialBindings)
|
||||
foreach (var spec in InputWidget.SpecialBindings)
|
||||
{
|
||||
var tsi = new ToolStripMenuItem(str);
|
||||
var tsi = new ToolStripMenuItem(spec.BindingName);
|
||||
tsi.ToolTipText = spec.TooltipText;
|
||||
DropdownMenu.Items.Add(tsi);
|
||||
}
|
||||
|
||||
|
@ -30,6 +31,27 @@ namespace BizHawk.Client.EmuHawk
|
|||
widget.CompositeWidget = this;
|
||||
}
|
||||
|
||||
static readonly string WidgetTooltipText = "* Escape clears a key mapping\r\n* Disable Auto Tab to multiply bind";
|
||||
ToolTip _tooltip;
|
||||
string _bindingTooltipText;
|
||||
|
||||
public void SetupTooltip(ToolTip tip, string bindingText)
|
||||
{
|
||||
_tooltip = tip;
|
||||
_tooltip.SetToolTip(btnSpecial, "Click here for special tricky bindings");
|
||||
_bindingTooltipText = bindingText;
|
||||
RefreshTooltip();
|
||||
}
|
||||
|
||||
public void RefreshTooltip()
|
||||
{
|
||||
string widgetText = "Current Binding: " + widget.Text;
|
||||
if (_bindingTooltipText != null)
|
||||
widgetText = widgetText + "\r\n---\r\n" + _bindingTooltipText;
|
||||
widgetText = widgetText + "\r\n---\r\n" + WidgetTooltipText;
|
||||
_tooltip.SetToolTip(widget, widgetText);
|
||||
}
|
||||
|
||||
void DropdownMenu_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
//suppress handling of ALT keys, so that we can receive them as binding modifiers
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
public sealed class InputWidget : TextBox
|
||||
{
|
||||
// TODO: when binding, make sure that the new key combo is not in one of the other bindings
|
||||
private readonly ToolTip _tooltip1 = new ToolTip();
|
||||
private readonly Timer _timer = new Timer();
|
||||
private readonly List<string> _bindings = new List<string>();
|
||||
|
||||
|
@ -18,33 +17,34 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public InputCompositeWidget CompositeWidget;
|
||||
|
||||
public class SpecialBindingInfo
|
||||
{
|
||||
public string BindingName;
|
||||
public string TooltipText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// These bindings get ignored by the widget and can only be entered by SetBinding() via the contextmenu from the InputCompositeWidget
|
||||
/// </summary>
|
||||
public static readonly string[] SpecialBindings = new[] {
|
||||
"Escape",
|
||||
"WMouse L","WMouse M","WMouse R",
|
||||
"WMouse 1", "WMouse 2"
|
||||
public static readonly SpecialBindingInfo[] SpecialBindings = {
|
||||
new SpecialBindingInfo { BindingName = "Escape", TooltipText = "Binds the Escape key" },
|
||||
new SpecialBindingInfo { BindingName = "WMouse L", TooltipText = "Binds the left mouse button"},
|
||||
new SpecialBindingInfo { BindingName = "WMouse M", TooltipText = "Binds the middle mouse button"},
|
||||
new SpecialBindingInfo { BindingName = "WMouse R", TooltipText = "Binds the right mouse button"},
|
||||
new SpecialBindingInfo { BindingName = "WMouse 1", TooltipText = "Binds the mouse auxiliary button 1" },
|
||||
new SpecialBindingInfo { BindingName = "WMouse 2", TooltipText = "Binds the mouse auxiliary button 2" },
|
||||
};
|
||||
|
||||
|
||||
public InputWidget()
|
||||
{
|
||||
ContextMenu = new ContextMenu();
|
||||
_timer.Tick += Timer_Tick;
|
||||
ClearBindings();
|
||||
_tooltip1.AutoPopDelay = 2000;
|
||||
AutoTab = true;
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
|
||||
public InputWidget(int maxBindings, bool autotab)
|
||||
{
|
||||
AutoTab = autotab;
|
||||
ContextMenu = new ContextMenu();
|
||||
_timer.Tick += Timer_Tick;
|
||||
_bindings = new List<string>();
|
||||
ClearBindings();
|
||||
_tooltip1.AutoPopDelay = 2000;
|
||||
}
|
||||
|
||||
public bool AutoTab { get; set; }
|
||||
public string WidgetName { get; set; }
|
||||
|
@ -110,7 +110,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
ClearBindings();
|
||||
Text = string.Empty;
|
||||
_tooltip1.SetToolTip(this, string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -154,11 +153,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
//ignore special bindings
|
||||
if (SpecialBindings.Contains(bindingStr))
|
||||
{
|
||||
foreach(var spec in SpecialBindings)
|
||||
if(spec.BindingName == bindingStr)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!IsDuplicate(bindingStr))
|
||||
{
|
||||
|
@ -222,7 +219,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void UpdateLabel()
|
||||
{
|
||||
Text = string.Join(",", _bindings.Where(str => !string.IsNullOrWhiteSpace(str)));
|
||||
_tooltip1.SetToolTip(this, Text);
|
||||
CompositeWidget.RefreshTooltip();
|
||||
}
|
||||
|
||||
protected override void OnKeyPress(KeyPressEventArgs e)
|
||||
|
|
Loading…
Reference in New Issue