cleanup OSDManager
This commit is contained in:
parent
1b8b4b4926
commit
f926142921
|
@ -158,7 +158,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void ClearText()
|
||||
{
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
GlobalWin.OSD.ClearGuiText();
|
||||
}
|
||||
|
||||
public void SetDefaultForegroundColor(Color color)
|
||||
|
@ -650,7 +650,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
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, a);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ using BizHawk.Emulation.Common;
|
|||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.Common.InputAdapterExtensions;
|
||||
using BizHawk.Bizware.BizwareGL;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -43,25 +42,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public class OSDManager
|
||||
{
|
||||
public string FPS { get; set; }
|
||||
public string Fps { get; set; }
|
||||
public IBlitterFont MessageFont;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Begin(IBlitter blitter)
|
||||
{
|
||||
MessageFont = blitter.GetFontType(nameof(MessageFont));
|
||||
}
|
||||
|
||||
public Color FixedMessagesColor { get { return Color.FromArgb(Global.Config.MessagesColor); } }
|
||||
public Color FixedAlertMessageColor { get { return Color.FromArgb(Global.Config.AlertMessageColor); } }
|
||||
|
||||
public OSDManager()
|
||||
{
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
@ -127,17 +117,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
return Global.Emulator.Frame.ToString();
|
||||
}
|
||||
|
||||
private List<UIMessage> messages = new List<UIMessage>(5);
|
||||
private List<UIDisplay> GUITextList = new List<UIDisplay>();
|
||||
private readonly List<UIMessage> _messages = new List<UIMessage>(5);
|
||||
private readonly List<UIDisplay> _guiTextList = new List<UIDisplay>();
|
||||
|
||||
public void AddMessage(string message)
|
||||
{
|
||||
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, int anchor)
|
||||
public void AddGuiText(string message, int x, int y, Color backGround, Color foreColor, int anchor)
|
||||
{
|
||||
GUITextList.Add(new UIDisplay
|
||||
_guiTextList.Add(new UIDisplay
|
||||
{
|
||||
Message = message,
|
||||
X = x,
|
||||
|
@ -148,9 +138,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
});
|
||||
}
|
||||
|
||||
public void ClearGUIText()
|
||||
public void ClearGuiText()
|
||||
{
|
||||
GUITextList.Clear();
|
||||
_guiTextList.Clear();
|
||||
}
|
||||
|
||||
public void DrawMessages(IBlitter g)
|
||||
|
@ -160,58 +150,55 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
messages.RemoveAll(m => DateTime.Now > m.ExpireAt);
|
||||
_messages.RemoveAll(m => DateTime.Now > m.ExpireAt);
|
||||
int line = 1;
|
||||
if (Global.Config.StackOSDMessages)
|
||||
{
|
||||
for (int i = messages.Count - 1; i >= 0; i--, line++)
|
||||
for (int i = _messages.Count - 1; i >= 0; i--, line++)
|
||||
{
|
||||
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, messages[i].Message);
|
||||
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, messages[i].Message);
|
||||
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, _messages[i].Message);
|
||||
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, _messages[i].Message);
|
||||
if (Global.Config.DispMessageanchor < 2)
|
||||
{
|
||||
y += ((line - 1) * 18);
|
||||
y += (line - 1) * 18;
|
||||
}
|
||||
else
|
||||
{
|
||||
y -= ((line - 1) * 18);
|
||||
y -= (line - 1) * 18;
|
||||
}
|
||||
|
||||
//g.DrawString(messages[i].Message, MessageFont, Color.Black, x + 2, y + 2);
|
||||
g.DrawString(messages[i].Message, MessageFont, FixedMessagesColor, x, y);
|
||||
g.DrawString(_messages[i].Message, MessageFont, FixedMessagesColor, x, y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (messages.Any())
|
||||
if (_messages.Any())
|
||||
{
|
||||
int i = messages.Count - 1;
|
||||
int i = _messages.Count - 1;
|
||||
|
||||
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, messages[i].Message);
|
||||
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, messages[i].Message);
|
||||
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, _messages[i].Message);
|
||||
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, _messages[i].Message);
|
||||
if (Global.Config.DispMessageanchor < 2)
|
||||
{
|
||||
y += ((line - 1) * 18);
|
||||
y += (line - 1) * 18;
|
||||
}
|
||||
else
|
||||
{
|
||||
y -= ((line - 1) * 18);
|
||||
y -= (line - 1) * 18;
|
||||
}
|
||||
|
||||
//g.DrawString(messages[i].Message, MessageFont, Color.Black, x + 2, y + 2);
|
||||
g.DrawString(messages[i].Message, MessageFont, FixedMessagesColor, x, y);
|
||||
g.DrawString(_messages[i].Message, MessageFont, FixedMessagesColor, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var text in GUITextList)
|
||||
foreach (var text in _guiTextList)
|
||||
{
|
||||
try
|
||||
{
|
||||
float posx = GetX(g, text.X, text.Anchor, text.Message);
|
||||
float posy = GetY(g, text.Y, text.Anchor, text.Message);
|
||||
float posX = GetX(g, text.X, text.Anchor, text.Message);
|
||||
float posY = GetY(g, text.Y, text.Anchor, text.Message);
|
||||
|
||||
//g.DrawString(text.Message, MessageFont, text.BackGround, posx + 2, posy + 2);
|
||||
g.DrawString(text.Message, MessageFont, text.ForeColor, posx, posy);
|
||||
g.DrawString(text.Message, MessageFont, text.ForeColor, posX, posY);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -266,17 +253,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
return lg.GenerateInputDisplay();
|
||||
}
|
||||
|
||||
public string InputStrSticky()
|
||||
{
|
||||
var stickyOr = new StickyOrAdapter
|
||||
{
|
||||
Source = Global.StickyXORAdapter,
|
||||
SourceStickyOr = Global.AutofireStickyXORAdapter
|
||||
};
|
||||
|
||||
return MakeStringFor(stickyOr);
|
||||
}
|
||||
|
||||
private string MakeStringFor(IController controller)
|
||||
{
|
||||
var lg = Global.MovieSession.LogGeneratorInstance();
|
||||
|
@ -302,17 +278,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public string MakeRerecordCount()
|
||||
{
|
||||
if (Global.MovieSession.Movie.IsActive)
|
||||
{
|
||||
return Global.MovieSession.Movie.Rerecords.ToString();
|
||||
}
|
||||
|
||||
return "";
|
||||
return Global.MovieSession.Movie.IsActive
|
||||
? Global.MovieSession.Movie.Rerecords.ToString()
|
||||
: "";
|
||||
}
|
||||
|
||||
private void DrawOsdMessage(IBlitter g, string message, Color color, float x, float y)
|
||||
{
|
||||
//g.DrawString(message, MessageFont, Color.Black, x + 1, y + 1);
|
||||
g.DrawString(message, MessageFont, color, x, y);
|
||||
}
|
||||
|
||||
|
@ -344,7 +316,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
var x = GetX(g, Global.Config.DispInpx, Global.Config.DispInpanchor, input);
|
||||
var y = GetY(g, Global.Config.DispInpy, Global.Config.DispInpanchor, input);
|
||||
Color c = Color.FromArgb(Global.Config.MovieInput);
|
||||
//g.DrawString(input, MessageFont, Color.Black, x + 1, y + 1);
|
||||
g.DrawString(input, MessageFont, c, x, y);
|
||||
}
|
||||
|
||||
|
@ -368,16 +339,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
g.DrawString(previousStr, MessageFont, previousColor, x, y);
|
||||
|
||||
// next, draw the immediate input.
|
||||
//that is, whatever's being held down interactively right this moment even if the game is paused
|
||||
// that is, whatever is being held down interactively right this moment even if the game is paused
|
||||
// this includes things held down due to autohold or autofire
|
||||
// I know, this is all really confusing
|
||||
var immediate = InputStrImmediate();
|
||||
g.DrawString(immediate, MessageFont, immediateColor, x, y);
|
||||
|
||||
// next draw anything that's pressed because it's sticky.
|
||||
//this applies to autofire and autohold both. somehow. I dont understand it.
|
||||
//basically we're tinting whatever's pressed because it's sticky specially
|
||||
//in order to achieve this we want to avoid drawing anything pink that isnt actually held down right now
|
||||
// this applies to autofire and autohold both. somehow. I don't understand it.
|
||||
// basically we're tinting whatever is pressed because it's sticky specially
|
||||
// in order to achieve this we want to avoid drawing anything pink that isn't actually held down right now
|
||||
// so we make an AND adapter and combine it using immediate & sticky
|
||||
var autoString = MakeStringFor(Global.StickyXORAdapter.Source.Xor(Global.AutofireStickyXORAdapter).And(Global.AutofireStickyXORAdapter));
|
||||
g.DrawString(autoString, MessageFont, autoColor, x, y);
|
||||
|
@ -396,12 +367,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
DrawOsdMessage(g, Global.MovieSession.MultiTrack.Status, FixedMessagesColor, x, y);
|
||||
}
|
||||
|
||||
if (Global.Config.DisplayFPS && FPS != null)
|
||||
if (Global.Config.DisplayFPS && Fps != null)
|
||||
{
|
||||
float x = GetX(g, Global.Config.DispFPSx, Global.Config.DispFPSanchor, FPS);
|
||||
float y = GetY(g, Global.Config.DispFPSy, Global.Config.DispFPSanchor, FPS);
|
||||
float x = GetX(g, Global.Config.DispFPSx, Global.Config.DispFPSanchor, Fps);
|
||||
float y = GetY(g, Global.Config.DispFPSy, Global.Config.DispFPSanchor, Fps);
|
||||
|
||||
DrawOsdMessage(g, FPS, FixedMessagesColor, x, y);
|
||||
DrawOsdMessage(g, Fps, FixedMessagesColor, x, y);
|
||||
}
|
||||
|
||||
if (Global.Config.DisplayLagCounter && Global.Emulator.CanPollInput())
|
||||
|
@ -415,31 +386,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (Global.Config.DisplayRerecordCount)
|
||||
{
|
||||
string rerec = MakeRerecordCount();
|
||||
float x = GetX(g, Global.Config.DispRecx, Global.Config.DispRecanchor, rerec);
|
||||
float y = GetY(g, Global.Config.DispRecy, Global.Config.DispRecanchor, rerec);
|
||||
string rerecordCount = MakeRerecordCount();
|
||||
float x = GetX(g, Global.Config.DispRecx, Global.Config.DispRecanchor, rerecordCount);
|
||||
float y = GetY(g, Global.Config.DispRecy, Global.Config.DispRecanchor, rerecordCount);
|
||||
|
||||
DrawOsdMessage(g, rerec, FixedMessagesColor, x, y);
|
||||
DrawOsdMessage(g, rerecordCount, FixedMessagesColor, x, y);
|
||||
}
|
||||
|
||||
if (Global.ClientControls["Autohold"] || Global.ClientControls["Autofire"])
|
||||
{
|
||||
var disp = new StringBuilder("Held: ");
|
||||
var sb = new StringBuilder("Held: ");
|
||||
|
||||
foreach (string sticky in Global.StickyXORAdapter.CurrentStickies)
|
||||
{
|
||||
disp.Append(sticky).Append(' ');
|
||||
sb.Append(sticky).Append(' ');
|
||||
}
|
||||
|
||||
foreach (string autoSticky in Global.AutofireStickyXORAdapter.CurrentStickies)
|
||||
{
|
||||
disp
|
||||
sb
|
||||
.Append("Auto-")
|
||||
.Append(autoSticky)
|
||||
.Append(' ');
|
||||
}
|
||||
|
||||
var message = disp.ToString();
|
||||
var message = sb.ToString();
|
||||
|
||||
g.DrawString(
|
||||
message,
|
||||
|
@ -460,5 +431,4 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2842,7 +2842,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_lastFastForwardingOrRewinding = isFastForwardingOrRewinding;
|
||||
|
||||
// client input-related duties
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
GlobalWin.OSD.ClearGuiText();
|
||||
|
||||
Global.CheatList.Pulse();
|
||||
|
||||
|
@ -3032,7 +3032,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
" >>";
|
||||
}
|
||||
|
||||
GlobalWin.OSD.FPS = fpsString;
|
||||
GlobalWin.OSD.Fps = fpsString;
|
||||
|
||||
// need to refresh window caption in this case
|
||||
if (Global.Config.DispSpeedupFeatures == 0)
|
||||
|
@ -3954,7 +3954,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (SavestateManager.LoadStateFile(path, userFriendlyStateName))
|
||||
{
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
GlobalWin.OSD.ClearGuiText();
|
||||
ClientApi.OnStateLoaded(this, userFriendlyStateName);
|
||||
|
||||
if (GlobalWin.Tools.Has<LuaConsole>())
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
[LuaMethod("cleartext", "clears all text created by gui.text()")]
|
||||
public static void ClearText()
|
||||
{
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
GlobalWin.OSD.ClearGuiText();
|
||||
}
|
||||
|
||||
[LuaMethodExample("gui.defaultForeground( 0x000000FF );")]
|
||||
|
@ -702,7 +702,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
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, a);
|
||||
}
|
||||
|
||||
[LuaMethodExample("local nlguicre = gui.createcanvas( 77, 99, 2, 48 );")]
|
||||
|
|
|
@ -854,7 +854,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
// Shenanigans
|
||||
// We want any gui.text messages from a script to immediately update even when paused
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
GlobalWin.OSD.ClearGuiText();
|
||||
GlobalWin.Tools.UpdateToolsAfter();
|
||||
LuaImp.EndLuaDrawing();
|
||||
LuaImp.StartLuaDrawing();
|
||||
|
|
|
@ -1480,6 +1480,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
EditAnalogProgrammatically(e);
|
||||
}
|
||||
else if (!e.Control && !e.Shift && !e.Alt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RefreshDialog();
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
GlobalWin.OSD.ClearGuiText();
|
||||
if (_watches.Any())
|
||||
{
|
||||
_watches.UpdateValues();
|
||||
|
@ -251,7 +251,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
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(
|
||||
GlobalWin.OSD.AddGuiText(
|
||||
_watches[i].ToDisplayString(),
|
||||
Global.Config.DispRamWatchx,
|
||||
Global.Config.DispRamWatchy + (i * 14),
|
||||
|
@ -291,7 +291,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
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(
|
||||
GlobalWin.OSD.AddGuiText(
|
||||
_watches[i].ToDisplayString(),
|
||||
Global.Config.DispRamWatchx,
|
||||
Global.Config.DispRamWatchy + (i * 14),
|
||||
|
@ -1005,7 +1005,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (!Global.Config.DisplayRamWatch)
|
||||
{
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
GlobalWin.OSD.ClearGuiText();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -188,6 +188,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autosave/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=backcolor/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bezier/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=blitter/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bools/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=botting/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=bsnes/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
Loading…
Reference in New Issue