private void DrawMessage(IBlitter g, UIMessage message, int yOffset) { var point = GetCoordinates(g, Global.Config.Messages, message.Message); var y = point.Y + yOffset; // TODO: clean me up g.DrawString(message.Message, MessageFont, FixedMessagesColor, point.X, y); }
public void DrawMessages(IBlitter g) { if (!Global.Config.DisplayMessages) { return; } _messages.RemoveAll(m => DateTime.Now > m.ExpireAt); if (_messages.Any()) { if (Global.Config.StackOSDMessages) { int line = 1; for (int i = _messages.Count - 1; i >= 0; i--, line++) { int yOffset = (line - 1) * 18; if (!Global.Config.Messages.Anchor.IsTop()) { yOffset = 0 - yOffset; } DrawMessage(g, _messages[i], yOffset); } } else { var message = _messages.Last(); DrawMessage(g, message, 0); } } foreach (var text in _guiTextList.Concat(_ramWatchList)) { try { var point = GetCoordinates(g, text.Position, text.Message); g.DrawString(text.Message, MessageFont, text.ForeColor, point.X, point.Y); } catch (Exception) { return; } } }
/// <summary> /// Display all screen info objects like fps, frame counter, lag counter, and input display /// </summary> public void DrawScreenInfo(IBlitter g) { if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance) { string message = MakeFrameCounter(); float x = GetX(g, Global.Config.DispFrameCx, Global.Config.DispFrameanchor, message); float y = GetY(g, Global.Config.DispFrameCy, Global.Config.DispFrameanchor, message); DrawOsdMessage(g, message, Color.FromArgb(Global.Config.MessagesColor), x, y); if (GlobalWin.MainForm.IsLagFrame) { DrawOsdMessage(g, Global.Emulator.Frame.ToString(), FixedAlertMessageColor, x, y); } } if (Global.Config.DisplayInput && !Global.Game.IsNullInstance) { if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) { var input = InputStrMovie(); 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); } else // TODO: message config -- allow setting of "previous", "mixed", and "auto" { var bgStr = InputStrOrAll(); var x = GetX(g, Global.Config.DispInpx, Global.Config.DispInpanchor, bgStr); var y = GetY(g, Global.Config.DispInpy, Global.Config.DispInpanchor, bgStr); g.DrawString(bgStr, MessageFont, Color.Black, x + 1, y + 1); var previousStr = InputPrevious(); var pColor = Color.Orange; g.DrawString(previousStr, MessageFont, pColor, x, y); var immediate = InputStrImmediate(); Color immediateColor = Color.FromArgb(Global.Config.MessagesColor); g.DrawString(immediate, MessageFont, immediateColor, x, y); var immediateOverlay = MakeIntersectImmediatePrevious(); var oColor = Color.PeachPuff; g.DrawString(immediateOverlay, MessageFont, oColor, x, y); var autoString = InputStrSticky(); g.DrawString(autoString, MessageFont, Color.Pink, x, y); } } if (Global.MovieSession.MultiTrack.IsActive) { float x = GetX(g, Global.Config.DispMultix, Global.Config.DispMultianchor, Global.MovieSession.MultiTrack.Status); float y = GetY(g, Global.Config.DispMultiy, Global.Config.DispMultianchor, Global.MovieSession.MultiTrack.Status); DrawOsdMessage(g, Global.MovieSession.MultiTrack.Status, FixedMessagesColor, x, y); } 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); DrawOsdMessage(g, FPS, FixedMessagesColor, x, y); } if (Global.Config.DisplayLagCounter && Global.Emulator.CanPollInput()) { var counter = Global.Emulator.AsInputPollable().LagCount.ToString(); var x = GetX(g, Global.Config.DispLagx, Global.Config.DispLaganchor, counter); var y = GetY(g, Global.Config.DispLagy, Global.Config.DispLaganchor, counter); DrawOsdMessage(g, counter, FixedAlertMessageColor, x, y); } 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); DrawOsdMessage(g, rerec, FixedMessagesColor, x, y); } if (Global.ClientControls["Autohold"] || Global.ClientControls["Autofire"]) { var disp = new StringBuilder("Held: "); foreach (string sticky in Global.StickyXORAdapter.CurrentStickies) { disp.Append(sticky).Append(' '); } foreach (string autoSticky in Global.AutofireStickyXORAdapter.CurrentStickies) { disp .Append("Auto-") .Append(autoSticky) .Append(' '); } var message = disp.ToString(); g.DrawString( message, MessageFont, Color.White, GetX(g, Global.Config.DispAutoholdx, Global.Config.DispAutoholdanchor, message), GetY(g, Global.Config.DispAutoholdy, Global.Config.DispAutoholdanchor, message)); } if (Global.MovieSession.Movie.IsActive && Global.Config.DisplaySubtitles) { var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame); foreach (var sub in subList) { DrawOsdMessage(g, sub.Message, Color.FromArgb((int)sub.Color), sub.X, sub.Y); } } }
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); }
public void DrawMessages(IBlitter g) { messages.RemoveAll(m => DateTime.Now > m.ExpireAt); int line = 1; if (Global.Config.StackOSDMessages) { 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); if (Global.Config.DispMessageanchor < 2) { y += ((line - 1) * 18); } else { 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); } } else { if (messages.Any()) { 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); if (Global.Config.DispMessageanchor < 2) { y += ((line - 1) * 18); } else { 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); } } 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); g.DrawString(text.Message, MessageFont, text.BackGround, posx + 2, posy + 2); g.DrawString(text.Message, MessageFont, text.ForeColor, posx, posy); } catch (Exception) { return; } } }
/// <summary> /// Display all screen info objects like fps, frame counter, lag counter, and input display /// </summary> public void DrawScreenInfo(IBlitter g) { if (Global.Config.DisplayFrameCounter && !Global.Game.IsNullInstance()) { string message = MakeFrameCounter(); var point = GetCoordinates(g, Global.Config.FrameCounter, message); DrawOsdMessage(g, message, Color.FromArgb(Global.Config.MessagesColor), point.X, point.Y); if (GlobalWin.MainForm.IsLagFrame) { DrawOsdMessage(g, GlobalWin.Emulator.Frame.ToString(), FixedAlertMessageColor, point.X, point.Y); } } if (Global.Config.DisplayInput && !Global.Game.IsNullInstance()) { if (Global.MovieSession.Movie.IsPlaying() || (Global.MovieSession.Movie.IsFinished() && GlobalWin.Emulator.Frame == Global.MovieSession.Movie.InputLogLength)) // Account for the last frame of the movie, the movie state is immediately "Finished" here but we still want to show the input { var input = InputStrMovie(); var point = GetCoordinates(g, Global.Config.InputDisplay, input); Color c = Color.FromArgb(Global.Config.MovieInput); g.DrawString(input, MessageFont, c, point.X, point.Y); } else // TODO: message config -- allow setting of "previous", "mixed", and "auto" { var previousColor = Color.Orange; Color immediateColor = Color.FromArgb(Global.Config.MessagesColor); var autoColor = Color.Pink; var changedColor = Color.PeachPuff; //we need some kind of string for calculating position when right-anchoring, of something like that var bgStr = InputStrOrAll(); var point = GetCoordinates(g, Global.Config.InputDisplay, bgStr); // now, we're going to render these repeatedly, with higher-priority things overriding // first display previous frame's input. // note: that's only available in case we're working on a movie var previousStr = InputPrevious(); g.DrawString(previousStr, MessageFont, previousColor, point.X, point.Y); // next, draw the immediate input. // 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, point.X, point.Y); // next draw anything that's pressed because it's sticky. // 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.InputManager.StickyXorAdapter.Source.Xor(Global.InputManager.AutofireStickyXorAdapter).And(Global.InputManager.AutofireStickyXorAdapter)); g.DrawString(autoString, MessageFont, autoColor, point.X, point.Y); //recolor everything that's changed from the previous input var immediateOverlay = MakeIntersectImmediatePrevious(); g.DrawString(immediateOverlay, MessageFont, changedColor, point.X, point.Y); } } if (Global.MovieSession.MultiTrack.IsActive) { var point = GetCoordinates(g, Global.Config.MultitrackRecorder, Global.MovieSession.MultiTrack.Status); DrawOsdMessage(g, Global.MovieSession.MultiTrack.Status, FixedMessagesColor, point.X, point.Y); } if (Global.Config.DisplayFps && Fps != null) { var point = GetCoordinates(g, Global.Config.Fps, Fps); DrawOsdMessage(g, Fps, FixedMessagesColor, point.X, point.Y); } if (Global.Config.DisplayLagCounter && GlobalWin.Emulator.CanPollInput()) { var counter = GlobalWin.Emulator.AsInputPollable().LagCount.ToString(); var point = GetCoordinates(g, Global.Config.LagCounter, counter); DrawOsdMessage(g, counter, FixedAlertMessageColor, point.X, point.Y); } if (Global.Config.DisplayRerecordCount) { string rerecordCount = MakeRerecordCount(); var point = GetCoordinates(g, Global.Config.ReRecordCounter, rerecordCount); DrawOsdMessage(g, rerecordCount, FixedMessagesColor, point.X, point.Y); } if (Global.InputManager.ClientControls["Autohold"] || Global.InputManager.ClientControls["Autofire"]) { var sb = new StringBuilder("Held: "); foreach (string sticky in Global.InputManager.StickyXorAdapter.CurrentStickies) { sb.Append(sticky).Append(' '); } foreach (string autoSticky in Global.InputManager.AutofireStickyXorAdapter.CurrentStickies) { sb .Append("Auto-") .Append(autoSticky) .Append(' '); } var message = sb.ToString(); var point = GetCoordinates(g, Global.Config.Autohold, message); g.DrawString(message, MessageFont, Color.White, point.X, point.Y); } if (Global.MovieSession.Movie.IsActive() && Global.Config.DisplaySubtitles) { var subList = Global.MovieSession.Movie.Subtitles.GetSubtitles(GlobalWin.Emulator.Frame); foreach (var sub in subList) { DrawOsdMessage(g, sub.Message, Color.FromArgb((int)sub.Color), sub.X, sub.Y); } } }
public void DrawMessages(IBlitter g) { if (!Global.Config.DisplayMessages) { return; } messages.RemoveAll(m => DateTime.Now > m.ExpireAt); int line = 1; if (Global.Config.StackOSDMessages) { 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); if (Global.Config.DispMessageanchor < 2) { y += ((line - 1) * 18); } else { 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); } } else { if (messages.Any()) { 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); if (Global.Config.DispMessageanchor < 2) { y += ((line - 1) * 18); } else { 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); } } 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); g.DrawString(text.Message, MessageFont, text.BackGround, posx + 2, posy + 2); g.DrawString(text.Message, MessageFont, text.ForeColor, posx, posy); } catch (Exception) { return; } } }
public void DrawMessages(IBlitter g) { if (!Global.Config.DisplayMessages) { return; } _messages.RemoveAll(m => DateTime.Now > m.ExpireAt); int line = 1; if (Global.Config.StackOSDMessages) { 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); if (Global.Config.DispMessageanchor < 2) { y += (line - 1) * 18; } else { y -= (line - 1) * 18; } g.DrawString(_messages[i].Message, MessageFont, FixedMessagesColor, x, y); } } else { if (_messages.Any()) { 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); if (Global.Config.DispMessageanchor < 2) { y += (line - 1) * 18; } else { y -= (line - 1) * 18; } g.DrawString(_messages[i].Message, MessageFont, FixedMessagesColor, x, y); } } 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); g.DrawString(text.Message, MessageFont, text.ForeColor, posX, posY); } catch (Exception) { return; } } }