Message config - fixes, make Anchor an enum instead of int
This commit is contained in:
parent
8e030c47b6
commit
6748d32830
|
@ -253,15 +253,15 @@ namespace BizHawk.Client.Common
|
|||
public bool DispAutoPrescale = true;
|
||||
public int DispSpeedupFeatures = 2;
|
||||
|
||||
public MessageOption Fps = DefaultMessageOptions.Fps;
|
||||
public MessageOption FrameCounter = DefaultMessageOptions.FrameCounter;
|
||||
public MessageOption LagCounter = DefaultMessageOptions.LagCounter;
|
||||
public MessageOption InputDisplay = DefaultMessageOptions.InputDisplay;
|
||||
public MessageOption ReRecordCounter = DefaultMessageOptions.ReRecordCounter;
|
||||
public MessageOption MultitrackRecorder = DefaultMessageOptions.MultitrackRecorder;
|
||||
public MessageOption Messages = DefaultMessageOptions.Messages;
|
||||
public MessageOption Autohold = DefaultMessageOptions.Autohold;
|
||||
public MessageOption RamWatches = DefaultMessageOptions.RamWatches;
|
||||
public MessageOption Fps = DefaultMessageOptions.Fps.Clone();
|
||||
public MessageOption FrameCounter = DefaultMessageOptions.FrameCounter.Clone();
|
||||
public MessageOption LagCounter = DefaultMessageOptions.LagCounter.Clone();
|
||||
public MessageOption InputDisplay = DefaultMessageOptions.InputDisplay.Clone();
|
||||
public MessageOption ReRecordCounter = DefaultMessageOptions.ReRecordCounter.Clone();
|
||||
public MessageOption MultitrackRecorder = DefaultMessageOptions.MultitrackRecorder.Clone();
|
||||
public MessageOption Messages = DefaultMessageOptions.Messages.Clone();
|
||||
public MessageOption Autohold = DefaultMessageOptions.Autohold.Clone();
|
||||
public MessageOption RamWatches = DefaultMessageOptions.RamWatches.Clone();
|
||||
|
||||
public int MessagesColor = DefaultMessageOptions.MessagesColor;
|
||||
public int AlertMessageColor = DefaultMessageOptions.AlertMessageColor;
|
||||
|
|
|
@ -4,7 +4,15 @@
|
|||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Anchor { get; set; } // TODO: make an enum 0 = UL, 1 = UR, 2 = DL, 3 = DR
|
||||
public AnchorType Anchor { get; set; }
|
||||
|
||||
public enum AnchorType
|
||||
{
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomLeft = 2,
|
||||
BottomRight = 3
|
||||
}
|
||||
|
||||
public MessageOption Clone()
|
||||
{
|
||||
|
@ -12,6 +20,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
public static class MessageOptionExtensions
|
||||
{
|
||||
public static bool IsTop(this MessageOption.AnchorType type)
|
||||
{
|
||||
return type == MessageOption.AnchorType.TopLeft
|
||||
|| type == MessageOption.AnchorType.TopRight;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DefaultMessageOptions
|
||||
{
|
||||
public static MessageOption Fps = new MessageOption { X = 0, Y = 0 };
|
||||
|
@ -19,9 +36,9 @@
|
|||
public static MessageOption LagCounter = new MessageOption { X = 0, Y = 42 };
|
||||
public static MessageOption InputDisplay = new MessageOption { X = 0, Y = 28 };
|
||||
public static MessageOption ReRecordCounter = new MessageOption { X = 0, Y = 56 };
|
||||
public static MessageOption MultitrackRecorder = new MessageOption { X = 0, Y = 14, Anchor = 1 };
|
||||
public static MessageOption Messages = new MessageOption { X = 0, Y = 0, Anchor = 2 };
|
||||
public static MessageOption Autohold = new MessageOption { X = 0, Y = 0, Anchor = 1 };
|
||||
public static MessageOption MultitrackRecorder = new MessageOption { X = 0, Y = 14, Anchor = MessageOption.AnchorType.TopRight };
|
||||
public static MessageOption Messages = new MessageOption { X = 0, Y = 0, Anchor = MessageOption.AnchorType.BottomLeft };
|
||||
public static MessageOption Autohold = new MessageOption { X = 0, Y = 0, Anchor = MessageOption.AnchorType.TopRight };
|
||||
public static MessageOption RamWatches = new MessageOption { X = 0, Y = 70 };
|
||||
|
||||
public const int
|
||||
|
|
|
@ -491,7 +491,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
x -= Emulator.CoreComm.ScreenLogicalOffsetX;
|
||||
y -= Emulator.CoreComm.ScreenLogicalOffsetY;
|
||||
}
|
||||
GlobalWin.OSD.AddGuiText(message, x, y, Color.Black, forecolor ?? Color.White, a);
|
||||
GlobalWin.OSD.AddGuiText(message, x, y, Color.Black, forecolor ?? Color.White, (MessageOption.AnchorType)a);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public string Message;
|
||||
public int X;
|
||||
public int Y;
|
||||
public int Anchor;
|
||||
public MessageOption.AnchorType Anchor;
|
||||
public Color ForeColor;
|
||||
public Color BackGround;
|
||||
}
|
||||
|
@ -53,34 +53,34 @@ namespace BizHawk.Client.EmuHawk
|
|||
public Color FixedMessagesColor => Color.FromArgb(Global.Config.MessagesColor);
|
||||
public Color FixedAlertMessageColor => Color.FromArgb(Global.Config.AlertMessageColor);
|
||||
|
||||
private float GetX(IBlitter g, int x, int anchor, string message)
|
||||
private float GetX(IBlitter g, int x, MessageOption.AnchorType anchor, string message)
|
||||
{
|
||||
var size = g.MeasureString(message, MessageFont);
|
||||
|
||||
switch (anchor)
|
||||
{
|
||||
default:
|
||||
case 0: //Top Left
|
||||
case 2: //Bottom Left
|
||||
case MessageOption.AnchorType.TopLeft:
|
||||
case MessageOption.AnchorType.BottomLeft:
|
||||
return x;
|
||||
case 1: //Top Right
|
||||
case 3: //Bottom Right
|
||||
case MessageOption.AnchorType.TopRight:
|
||||
case MessageOption.AnchorType.BottomRight:
|
||||
return g.ClipBounds.Width - x - size.Width;
|
||||
}
|
||||
}
|
||||
|
||||
private float GetY(IBlitter g, int y, int anchor, string message)
|
||||
private float GetY(IBlitter g, int y, MessageOption.AnchorType anchor, string message)
|
||||
{
|
||||
var size = g.MeasureString(message, MessageFont);
|
||||
|
||||
switch (anchor)
|
||||
{
|
||||
default:
|
||||
case 0: //Top Left
|
||||
case 1: //Top Right
|
||||
case MessageOption.AnchorType.TopLeft:
|
||||
case MessageOption.AnchorType.TopRight:
|
||||
return y;
|
||||
case 2: //Bottom Left
|
||||
case 3: //Bottom Right
|
||||
case MessageOption.AnchorType.BottomLeft:
|
||||
case MessageOption.AnchorType.BottomRight:
|
||||
return g.ClipBounds.Height - y - size.Height;
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) });
|
||||
}
|
||||
|
||||
public void AddGuiText(string message, int x, int y, Color backGround, Color foreColor, int anchor)
|
||||
public void AddGuiText(string message, int x, int y, Color backGround, Color foreColor, MessageOption.AnchorType anchor)
|
||||
{
|
||||
_guiTextList.Add(new UIDisplay
|
||||
{
|
||||
|
@ -158,7 +158,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
float x = GetX(g, Global.Config.Messages.X, Global.Config.Messages.Anchor, _messages[i].Message);
|
||||
float y = GetY(g, Global.Config.Messages.X, Global.Config.Messages.Anchor, _messages[i].Message);
|
||||
if (Global.Config.Messages.Anchor < 2)
|
||||
if (Global.Config.Messages.Anchor.IsTop())
|
||||
{
|
||||
y += (line - 1) * 18;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
float x = GetX(g, Global.Config.Messages.X, Global.Config.Messages.Anchor, _messages[i].Message);
|
||||
float y = GetY(g, Global.Config.Messages.Y, Global.Config.Messages.Anchor, _messages[i].Message);
|
||||
if (Global.Config.Messages.Anchor < 2)
|
||||
if (Global.Config.Messages.Anchor.IsTop())
|
||||
{
|
||||
y += (line - 1) * 18;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private int _px;
|
||||
private int _py;
|
||||
private bool _mousedown;
|
||||
private bool _programmaticallyChangingValues;
|
||||
|
||||
public MessageConfig(Config config)
|
||||
{
|
||||
|
@ -96,33 +97,32 @@ namespace BizHawk.Client.EmuHawk
|
|||
MovieInputText.Text = $"{_movieInput:X8}";
|
||||
}
|
||||
|
||||
private void SetAnchorRadio(int anchor)
|
||||
{
|
||||
switch (anchor)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
TL.Checked = true;
|
||||
break;
|
||||
case 1:
|
||||
TR.Checked = true;
|
||||
break;
|
||||
case 2:
|
||||
BL.Checked = true;
|
||||
break;
|
||||
case 3:
|
||||
BR.Checked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFromOption(MessageOption option)
|
||||
{
|
||||
_programmaticallyChangingValues = true;
|
||||
XNumeric.Value = option.X;
|
||||
YNumeric.Value = option.Y;
|
||||
_px = option.X;
|
||||
_py = option.Y;
|
||||
SetAnchorRadio(option.Anchor);
|
||||
|
||||
switch (option.Anchor)
|
||||
{
|
||||
default:
|
||||
case MessageOption.AnchorType.TopLeft:
|
||||
TL.Checked = true;
|
||||
break;
|
||||
case MessageOption.AnchorType.TopRight:
|
||||
TR.Checked = true;
|
||||
break;
|
||||
case MessageOption.AnchorType.BottomLeft:
|
||||
BL.Checked = true;
|
||||
break;
|
||||
case MessageOption.AnchorType.BottomRight:
|
||||
BR.Checked = true;
|
||||
break;
|
||||
}
|
||||
|
||||
_programmaticallyChangingValues = false;
|
||||
}
|
||||
|
||||
private void SetPositionInfo()
|
||||
|
@ -259,6 +259,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SetNewPosition(int mx, int my)
|
||||
{
|
||||
_programmaticallyChangingValues = true;
|
||||
if (mx < 0) mx = 0;
|
||||
if (my < 0) my = 0;
|
||||
if (mx > XNumeric.Maximum) mx = (int)XNumeric.Maximum;
|
||||
|
@ -289,6 +290,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
PositionPanel.Refresh();
|
||||
SetPositionLabels();
|
||||
|
||||
_programmaticallyChangingValues = false;
|
||||
}
|
||||
|
||||
private void PositionPanel_MouseMove(object sender, MouseEventArgs e)
|
||||
|
@ -362,15 +365,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void ResetDefaultsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
_fps = _config.Fps = DefaultMessageOptions.Fps;
|
||||
_frameCounter = _config.FrameCounter = DefaultMessageOptions.FrameCounter;
|
||||
_lagCounter = _config.LagCounter = DefaultMessageOptions.LagCounter;
|
||||
_inputDisplay = _config.InputDisplay = DefaultMessageOptions.InputDisplay;
|
||||
_reRecordCounter = _config.ReRecordCounter = DefaultMessageOptions.ReRecordCounter;
|
||||
_multitrackRecorder = _config.MultitrackRecorder = DefaultMessageOptions.MultitrackRecorder;
|
||||
_messages = _config.Messages = DefaultMessageOptions.Messages;
|
||||
_autohold = _config.Autohold = DefaultMessageOptions.Autohold;
|
||||
_ramWatches = _config.RamWatches = DefaultMessageOptions.RamWatches;
|
||||
_fps = _config.Fps = DefaultMessageOptions.Fps.Clone();
|
||||
_frameCounter = _config.FrameCounter = DefaultMessageOptions.FrameCounter.Clone();
|
||||
_lagCounter = _config.LagCounter = DefaultMessageOptions.LagCounter.Clone();
|
||||
_inputDisplay = _config.InputDisplay = DefaultMessageOptions.InputDisplay.Clone();
|
||||
_reRecordCounter = _config.ReRecordCounter = DefaultMessageOptions.ReRecordCounter.Clone();
|
||||
_multitrackRecorder = _config.MultitrackRecorder = DefaultMessageOptions.MultitrackRecorder.Clone();
|
||||
_messages = _config.Messages = DefaultMessageOptions.Messages.Clone();
|
||||
_autohold = _config.Autohold = DefaultMessageOptions.Autohold.Clone();
|
||||
_ramWatches = _config.RamWatches = DefaultMessageOptions.RamWatches.Clone();
|
||||
|
||||
_messageColor = _config.MessagesColor = DefaultMessageOptions.MessagesColor;
|
||||
_alertColor = _config.AlertMessageColor = DefaultMessageOptions.AlertMessageColor;
|
||||
|
@ -389,7 +392,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
StackMessagesCheckbox.Checked = _config.StackOSDMessages = true;
|
||||
}
|
||||
|
||||
private void SetAnchorValue(int value)
|
||||
private void SetAnchorValue(MessageOption.AnchorType value)
|
||||
{
|
||||
if (FPSRadio.Checked)
|
||||
{
|
||||
|
@ -433,7 +436,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (TL.Checked)
|
||||
{
|
||||
SetAnchorValue(0);
|
||||
SetAnchorValue(MessageOption.AnchorType.TopLeft);
|
||||
}
|
||||
|
||||
PositionPanel.Refresh();
|
||||
|
@ -443,7 +446,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (TR.Checked)
|
||||
{
|
||||
SetAnchorValue(1);
|
||||
SetAnchorValue(MessageOption.AnchorType.TopRight);
|
||||
}
|
||||
|
||||
PositionPanel.Refresh();
|
||||
|
@ -453,7 +456,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (BL.Checked)
|
||||
{
|
||||
SetAnchorValue(2);
|
||||
SetAnchorValue(MessageOption.AnchorType.BottomLeft);
|
||||
}
|
||||
|
||||
PositionPanel.Refresh();
|
||||
|
@ -463,7 +466,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (BR.Checked)
|
||||
{
|
||||
SetAnchorValue(3);
|
||||
SetAnchorValue(MessageOption.AnchorType.BottomRight);
|
||||
}
|
||||
|
||||
PositionPanel.Refresh();
|
||||
|
@ -471,16 +474,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void XNumeric_Changed(object sender, EventArgs e)
|
||||
{
|
||||
_px = (int)XNumeric.Value;
|
||||
SetPositionLabels();
|
||||
PositionPanel.Refresh();
|
||||
if (!_programmaticallyChangingValues)
|
||||
{
|
||||
_px = (int)XNumeric.Value;
|
||||
SetPositionLabels();
|
||||
PositionPanel.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void YNumeric_Changed(object sender, EventArgs e)
|
||||
{
|
||||
_py = (int)YNumeric.Value;
|
||||
SetPositionLabels();
|
||||
PositionPanel.Refresh();
|
||||
if (!_programmaticallyChangingValues)
|
||||
{
|
||||
_py = (int)YNumeric.Value;
|
||||
SetPositionLabels();
|
||||
PositionPanel.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorPanel_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue