From 81f681bcd83d237640adba2d784599014fef5fb7 Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Tue, 2 Jan 2018 21:08:09 +0300 Subject: [PATCH 1/4] account for linebreaks when measuring message string --- .../StringRenderer.cs | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs index 94a879483d..101bfe06da 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs @@ -32,34 +32,66 @@ namespace BizHawk.Bizware.BizwareGL public sd.SizeF Measure(string str) { float x = 0; + float y = FontInfo.LineHeight; + float ox = x; int len = str.Length; + for (int i = 0; i < len; i++) { - Cyotek.Drawing.BitmapFont.Character c; - if (!FontInfo.Characters.TryGetValue(str[i], out c)) - c = FontInfo.Characters[unchecked((char)-1)]; + int c = str[i]; - x += c.XAdvance; + if (c == '\r') + { + if (i != len - 1 && str[i + 1] == '\n') + i++; + } + + if (c == '\r') + { + c = '\n'; + } + + if (c == '\n') + { + if (x > ox) + ox = x; + x = 0; + y += FontInfo.LineHeight; + continue; + } + + Cyotek.Drawing.BitmapFont.Character bfc; + if (!FontInfo.Characters.TryGetValue((char)c, out bfc)) + bfc = FontInfo.Characters[unchecked((char)-1)]; + + x += bfc.XAdvance; } - return new sd.SizeF(x, FontInfo.LineHeight); + return new sd.SizeF(ox, y); } public void RenderString(IGuiRenderer renderer, float x, float y, string str) { float ox = x; int len = str.Length; + for (int i = 0; i < len; i++) { int c = str[i]; + if (c == '\r') { if (i != len - 1 && str[i + 1] == '\n') i++; } - if (c == '\r') c = '\n'; - if(c == '\n') { + if (c == '\r') + { + c = '\n'; + } + + if(c == '\n') + { x = ox; y += FontInfo.LineHeight; continue; From 761c1532e01d6485a0df1c95eba01d008a03d50e Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Tue, 2 Jan 2018 22:44:47 +0300 Subject: [PATCH 2/4] fix single-line messaged --- Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs index 101bfe06da..11e4d360b2 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs @@ -67,7 +67,7 @@ namespace BizHawk.Bizware.BizwareGL x += bfc.XAdvance; } - return new sd.SizeF(ox, y); + return new sd.SizeF(Math.Max(x, ox), y); } public void RenderString(IGuiRenderer renderer, float x, float y, string str) From 68a0fcf408a5fad8deecc11554277ee63ceb5eaf Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Wed, 3 Jan 2018 19:35:37 +0300 Subject: [PATCH 3/4] move avi writer call so it captures lua messages I think it doesn't outrun anything critical this way --- BizHawk.Client.EmuHawk/MainForm.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index fa6977cd9f..ba91ad68c5 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -2969,11 +2969,6 @@ namespace BizHawk.Client.EmuHawk Global.CheatList.Pulse(); - if (!PauseAvi) - { - AvFrameAdvance(); - } - if (IsLagFrame && Global.Config.AutofireLagFrames) { Global.AutoFireController.IncrementStarts(); @@ -2997,6 +2992,11 @@ namespace BizHawk.Client.EmuHawk UpdateToolsAfter(SuppressLua); } + if (!PauseAvi) + { + AvFrameAdvance(); + } + if (GlobalWin.Tools.IsLoaded() && GlobalWin.Tools.TAStudio.LastPositionFrame == Emulator.Frame) { From eea6740722dcb2e55dcf2867feea4f65c6b67610 Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Sat, 6 Jan 2018 13:30:47 +0300 Subject: [PATCH 4/4] lua: client.isturbo() and client.isseeking() --- BizHawk.Client.EmuHawk/MainForm.cs | 2 +- .../tools/Lua/Libraries/EmuLuaLibrary.Client.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index ba91ad68c5..78817fbbf2 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -609,7 +609,7 @@ namespace BizHawk.Client.EmuHawk private bool IsTurboSeeking => PauseOnFrame.HasValue && Global.Config.TurboSeek; - private bool IsTurboing => Global.ClientControls["Turbo"] || IsTurboSeeking; + public bool IsTurboing => Global.ClientControls["Turbo"] || IsTurboSeeking; #endregion diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index 7a20625169..40b99bd2b9 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -150,6 +150,18 @@ namespace BizHawk.Client.EmuHawk return GlobalWin.MainForm.EmulatorPaused; } + [LuaMethod("isturbo", "Returns true if emulator is in turbo mode, otherwise, false")] + public static bool IsTurbo() + { + return GlobalWin.MainForm.IsTurboing; + } + + [LuaMethod("isseeking", "Returns true if emulator is seeking, otherwise, false")] + public static bool IsSeeking() + { + return GlobalWin.MainForm.IsSeeking; + } + [LuaMethod("opencheats", "opens the Cheats dialog")] public static void OpenCheats() {