From e14a3c70adad2169087f52edc452769e8cf87887 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 18 Jun 2011 16:22:26 +0000 Subject: [PATCH] Fix bugs in message config dialog, implement message anchoring (mostly) --- BizHawk.MultiClient/RenderPanel.cs | 80 ++++++++++++++----- .../config/MessageConfig.Designer.cs | 4 +- BizHawk.MultiClient/config/MessageConfig.cs | 29 +++---- 3 files changed, 77 insertions(+), 36 deletions(-) diff --git a/BizHawk.MultiClient/RenderPanel.cs b/BizHawk.MultiClient/RenderPanel.cs index a1dfae71e8..f2c838c047 100644 --- a/BizHawk.MultiClient/RenderPanel.cs +++ b/BizHawk.MultiClient/RenderPanel.cs @@ -254,23 +254,57 @@ namespace BizHawk.MultiClient Device.Present(Present.DoNotWait); } + private int GetX(int x, int anchor) + { + switch (anchor) + { + default: + case 0: + case 2: + return x; + case 1: + case 3: + return backingControl.Size.Width - Global.Emulator.VideoProvider.BufferWidth + x; + } + } + + private int GetY(int y, int anchor) + { + switch (anchor) + { + default: + case 0: + case 1: + return y; + case 2: + case 3: + return backingControl.Size.Height - Global.Emulator.VideoProvider.BufferHeight + y; + } + } + + /// /// Display all screen info objects like fps, frame counter, lag counter, and input display /// public void DrawScreenInfo() { + int x, y; //TODO: If movie loaded use that frame counter, and also display total movie frame count if read-only if (Global.Config.DisplayFrameCounter) { - MessageFont.DrawString(null, MakeFrameCounter(), Global.Config.DispFrameCx + 1, - Global.Config.DispFrameCy + 1, new Color4(Color.Black)); - MessageFont.DrawString(null, MakeFrameCounter(), Global.Config.DispFrameCx, - Global.Config.DispFrameCy, Color.FromArgb(Global.Config.MessagesColor)); + x = GetX(Global.Config.DispFrameCx, Global.Config.DispFrameanchor); + y = GetY(Global.Config.DispFrameCy, Global.Config.DispFrameanchor); + MessageFont.DrawString(null, MakeFrameCounter(), x + 1, + y + 1, new Color4(Color.Black)); + MessageFont.DrawString(null, MakeFrameCounter(), x, + y, Color.FromArgb(Global.Config.MessagesColor)); } if (Global.Config.DisplayInput) { string input = MakeLastInputDisplay(); Color c; + x = GetX(Global.Config.DispInpx, Global.Config.DispInpanchor); + y = GetY(Global.Config.DispInpy, Global.Config.DispInpanchor); if (Global.MainForm.UserMovie.GetMovieMode() == MOVIEMODE.PLAY) { c = Color.Gray; @@ -278,28 +312,32 @@ namespace BizHawk.MultiClient else c = Color.FromArgb(Global.Config.MessagesColor); - MessageFont.DrawString(null, input, Global.Config.DispInpx + 2, Global.Config.DispInpy + 2, new Color4(Color.Black)); - MessageFont.DrawString(null, input, Global.Config.DispInpx + 1, Global.Config.DispInpy + 1, Color.FromArgb(Global.Config.LastInputColor)); + MessageFont.DrawString(null, input, x + 2, y + 2, new Color4(Color.Black)); + MessageFont.DrawString(null, input, x + 1, y + 1, Color.FromArgb(Global.Config.LastInputColor)); input = MakeInputDisplay(); - MessageFont.DrawString(null, input, Global.Config.DispInpx, Global.Config.DispInpy, c); + MessageFont.DrawString(null, input, x, y, c); } if (Global.MainForm.UserMovie.MultiTrack.isActive) { - MessageFont.DrawString(null, MT, Global.Config.DispFPSx + 1, + MessageFont.DrawString(null, MT, Global.Config.DispFPSx + 1, //TODO: Multitrack position variables Global.Config.DispFPSy + 1, new Color4(Color.Black)); MessageFont.DrawString(null, MT, Global.Config.DispFPSx, Global.Config.DispFPSy, Color.FromArgb(Global.Config.MessagesColor)); } if (Global.Config.DisplayFPS && FPS != null) { - MessageFont.DrawString(null, FPS, Global.Config.DispFPSx + 1, - Global.Config.DispFPSy + 1, new Color4(Color.Black)); - MessageFont.DrawString(null, FPS, Global.Config.DispFPSx, - Global.Config.DispFPSy, Color.FromArgb(Global.Config.MessagesColor)); + x = GetX(Global.Config.DispFPSx, Global.Config.DispFPSanchor); + y = GetY(Global.Config.DispFPSy, Global.Config.DispFPSanchor); + MessageFont.DrawString(null, FPS, x + 1, + y + 1, new Color4(Color.Black)); + MessageFont.DrawString(null, FPS, x, + y, Color.FromArgb(Global.Config.MessagesColor)); } if (Global.Config.DisplayLagCounter) { + x = GetX(Global.Config.DispLagx, Global.Config.DispLaganchor); + y = GetY(Global.Config.DispLagy, Global.Config.DispLaganchor); if (Global.Emulator.IsLagFrame) { AlertFont.DrawString(null, MakeLagCounter(), Global.Config.DispLagx + 1, @@ -309,19 +347,21 @@ namespace BizHawk.MultiClient } else { - MessageFont.DrawString(null, MakeLagCounter(), Global.Config.DispLagx + 1, - Global.Config.DispLagy + 1, new Color4(Color.Black)); - MessageFont.DrawString(null, MakeLagCounter(), Global.Config.DispLagx, - Global.Config.DispLagy, Color.FromArgb(Global.Config.MessagesColor)); + MessageFont.DrawString(null, MakeLagCounter(), x + 1, + y + 1, new Color4(Color.Black)); + MessageFont.DrawString(null, MakeLagCounter(), x, + y, Color.FromArgb(Global.Config.MessagesColor)); } } if (Global.Config.DisplayRerecordCount) { - MessageFont.DrawString(null, MakeRerecordCount(), Global.Config.DispRecx + 1, - Global.Config.DispRecy + 1, new Color4(Color.Black)); - MessageFont.DrawString(null, MakeRerecordCount(), Global.Config.DispRecx, - Global.Config.DispRecy, Color.FromArgb(Global.Config.MessagesColor)); + x = GetX(Global.Config.DispRecx, Global.Config.DispRecanchor); + y = GetY(Global.Config.DispRecy, Global.Config.DispRecanchor); + MessageFont.DrawString(null, MakeRerecordCount(), x + 1, + y + 1, new Color4(Color.Black)); + MessageFont.DrawString(null, MakeRerecordCount(), x, + y, Color.FromArgb(Global.Config.MessagesColor)); } //TODO: clean this up or replace with simple draw symbols diff --git a/BizHawk.MultiClient/config/MessageConfig.Designer.cs b/BizHawk.MultiClient/config/MessageConfig.Designer.cs index bdc7d7ac08..c383c8a049 100644 --- a/BizHawk.MultiClient/config/MessageConfig.Designer.cs +++ b/BizHawk.MultiClient/config/MessageConfig.Designer.cs @@ -463,7 +463,7 @@ 0, 0, 0}); - this.XNumeric.ValueChanged += new System.EventHandler(this.XNumeric_ValueChanged); + this.XNumeric.Click += new System.EventHandler(this.XNumeric_Click); // // YNumeric // @@ -482,7 +482,7 @@ 0, 0, 0}); - this.YNumeric.ValueChanged += new System.EventHandler(this.YNumeric_ValueChanged); + this.YNumeric.Click += new System.EventHandler(this.YNumeric_Click); // // label1 // diff --git a/BizHawk.MultiClient/config/MessageConfig.cs b/BizHawk.MultiClient/config/MessageConfig.cs index bd310337d4..7b1e7bda9b 100644 --- a/BizHawk.MultiClient/config/MessageConfig.cs +++ b/BizHawk.MultiClient/config/MessageConfig.cs @@ -17,6 +17,8 @@ namespace BizHawk.MultiClient //Deal with typing into Numerics properly //Have some method of binding a display object to top/bottom/left/right instead of an absolute position //Bug: restore defaults doesn't restore the y value of whatever radio is checked + //Implement Rerecord Counter config + //Implemetn Multitrack messages counter config int DispFPSx = Global.Config.DispFPSx; int DispFPSy = Global.Config.DispFPSy; @@ -147,6 +149,8 @@ namespace BizHawk.MultiClient } PositionPanel.Refresh(); + XNumeric.Refresh(); + YNumeric.Refresh(); SetPositionLabels(); } @@ -165,7 +169,7 @@ namespace BizHawk.MultiClient Global.Config.LastInputColor = LastInputColor; Global.Config.DispFPSanchor = DispFPSanchor; - Global.Config.DispFPSanchor = DispFrameanchor; + Global.Config.DispFrameanchor = DispFrameanchor; Global.Config.DispLaganchor = DispLaganchor; Global.Config.DispInpanchor = DispInputanchor; Global.Config.DispRecanchor = DispRecanchor; @@ -222,16 +226,6 @@ namespace BizHawk.MultiClient PositionPanel.Refresh(); } - private void XNumeric_ValueChanged(object sender, EventArgs e) - { - XNumericChange(); - } - - private void YNumeric_ValueChanged(object sender, EventArgs e) - { - YNumericChange(); - } - private void Cancel_Click(object sender, EventArgs e) { this.Close(); @@ -360,9 +354,6 @@ namespace BizHawk.MultiClient DispInputanchor = Global.Config.DispInpanchor; DispRecanchor = Global.Config.DispRecanchor; - //TODO: anchors - - SetMaxXY(); MessageColorDialog.Color = Color.FromArgb(MessageColor); AlertColorDialog.Color = Color.FromArgb(AlertColor); @@ -448,5 +439,15 @@ namespace BizHawk.MultiClient DispInputanchor = 3; } } + + private void XNumeric_Click(object sender, EventArgs e) + { + XNumericChange(); + } + + private void YNumeric_Click(object sender, EventArgs e) + { + YNumericChange(); + } } }