Simplify on screen ram watch value positioining, and respect the anchor value setting

This commit is contained in:
adelikat 2019-12-21 15:36:37 -06:00
parent f5929602ff
commit f5f22e78d8
3 changed files with 31 additions and 40 deletions

View File

@ -491,7 +491,9 @@ namespace BizHawk.Client.EmuHawk
x -= Emulator.CoreComm.ScreenLogicalOffsetX; x -= Emulator.CoreComm.ScreenLogicalOffsetX;
y -= Emulator.CoreComm.ScreenLogicalOffsetY; y -= Emulator.CoreComm.ScreenLogicalOffsetY;
} }
GlobalWin.OSD.AddGuiText(message, x, y, Color.Black, forecolor ?? Color.White, (MessagePosition.AnchorType)a);
var pos = new MessagePosition{ X = x, Y = y, Anchor = (MessagePosition.AnchorType)a };
GlobalWin.OSD.AddGuiText(message, pos, Color.Black, forecolor ?? Color.White);
} }
public void Dispose() public void Dispose()

View File

@ -33,9 +33,7 @@ namespace BizHawk.Client.EmuHawk
class UIDisplay class UIDisplay
{ {
public string Message; public string Message;
public int X; public MessagePosition Position;
public int Y;
public MessagePosition.AnchorType Anchor;
public Color ForeColor; public Color ForeColor;
public Color BackGround; public Color BackGround;
} }
@ -108,16 +106,14 @@ namespace BizHawk.Client.EmuHawk
_messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) }); _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, MessagePosition.AnchorType anchor) public void AddGuiText(string message, MessagePosition pos, Color backGround, Color foreColor)
{ {
_guiTextList.Add(new UIDisplay _guiTextList.Add(new UIDisplay
{ {
Message = message, Message = message,
X = x, Position = pos,
Y = y,
BackGround = backGround, BackGround = backGround,
ForeColor = foreColor, ForeColor = foreColor
Anchor = anchor
}); });
} }
@ -177,7 +173,7 @@ namespace BizHawk.Client.EmuHawk
{ {
try try
{ {
var point = GetCoordinates(g, new MessagePosition {X = text.X, Y = text.Y, Anchor = text.Anchor}, text.Message); var point = GetCoordinates(g, text.Position, text.Message);
g.DrawString(text.Message, MessageFont, text.ForeColor, point.X, point.Y); g.DrawString(text.Message, MessageFont, text.ForeColor, point.X, point.Y);
} }
catch (Exception) catch (Exception)

View File

@ -229,6 +229,27 @@ namespace BizHawk.Client.EmuHawk
{ {
} }
private void DisplayOnScreenWatches()
{
if (Global.Config.DisplayRamWatch)
{
for (var i = 0; i < _watches.Count; i++)
{
var frozen = !_watches[i].IsSeparator && Global.CheatList.IsActive(_watches[i].Domain, _watches[i].Address);
GlobalWin.OSD.AddGuiText(
_watches[i].ToDisplayString(),
new MessagePosition
{
X = Global.Config.RamWatches.X,
Y = Global.Config.RamWatches.Y + (i * 14),
Anchor = Global.Config.RamWatches.Anchor
},
Color.Black,
frozen ? Color.Cyan : Color.White);
}
}
}
public void UpdateValues() public void UpdateValues()
{ {
if (_paused) if (_paused)
@ -245,21 +266,7 @@ namespace BizHawk.Client.EmuHawk
if (_watches.Any()) if (_watches.Any())
{ {
_watches.UpdateValues(); _watches.UpdateValues();
DisplayOnScreenWatches();
if (Global.Config.DisplayRamWatch)
{
for (var i = 0; i < _watches.Count; i++)
{
var frozen = !_watches[i].IsSeparator && Global.CheatList.IsActive(_watches[i].Domain, _watches[i].Address);
GlobalWin.OSD.AddGuiText(
_watches[i].ToDisplayString(),
Global.Config.RamWatches.X,
Global.Config.RamWatches.Y + (i * 14),
Color.Black,
frozen ? Color.Cyan : Color.White,
0);
}
}
if (!IsHandleCreated || IsDisposed) if (!IsHandleCreated || IsDisposed)
{ {
@ -285,21 +292,7 @@ namespace BizHawk.Client.EmuHawk
if (_watches.Any()) if (_watches.Any())
{ {
_watches.UpdateValues(); _watches.UpdateValues();
DisplayOnScreenWatches();
if (Global.Config.DisplayRamWatch)
{
for (var i = 0; i < _watches.Count; i++)
{
var frozen = !_watches[i].IsSeparator && Global.CheatList.IsActive(_watches[i].Domain, _watches[i].Address);
GlobalWin.OSD.AddGuiText(
_watches[i].ToDisplayString(),
Global.Config.RamWatches.X,
Global.Config.RamWatches.Y + (i * 14),
Color.Black,
frozen ? Color.Cyan : Color.White,
0);
}
}
} }
} }