From 791f2bcc2f2604a10cfb94e7890fb95b7a429fae Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Tue, 8 Mar 2011 19:05:23 +0000 Subject: [PATCH] NESPPU - hook up windows position saving & autoload, and hook up UpdateValues to frame loop --- BizHawk.MultiClient/Config.cs | 6 +++++ BizHawk.MultiClient/MainForm.cs | 18 ++++++++++++-- .../NEStools/NESPPU.Designer.cs | 7 +++--- BizHawk.MultiClient/NEStools/NESPPU.cs | 24 ++++++++++++++++++- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index cf28095b95..492ef2f17e 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -84,6 +84,12 @@ public int HexEditorWidth = -1; public int HexEditorHeight = -1; + // NESPPU Setings + public bool AutoLoadNESPPU = true; + public bool NESPPUSaveWindowPosition = true; + public int NESPPUWndx = -1; + public int NESPPUWndy = -1; + //Movie Settings public RecentFiles RecentMovies = new RecentFiles(8); diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index a2d1279904..c3c664b98a 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -43,6 +43,7 @@ namespace BizHawk.MultiClient public RamWatch RamWatch1 = new RamWatch(); public RamSearch RamSearch1 = new RamSearch(); public HexEditor HexEditor1 = new HexEditor(); + public NESPPU NESPPU1 = new NESPPU(); public MainForm(string[] args) { @@ -133,6 +134,8 @@ namespace BizHawk.MultiClient LoadRamSearch(); if (Global.Config.AutoLoadHexEditor) LoadHexEditor(); + if (Global.Config.AutoLoadNESPPU && Global.Emulator is NES) + LoadNESPPU(); if (Global.Config.MainWndx >= 0 && Global.Config.MainWndy >= 0 && Global.Config.SaveWindowPosition) this.Location = new Point(Global.Config.MainWndx, Global.Config.MainWndy); @@ -706,6 +709,7 @@ namespace BizHawk.MultiClient RamWatch1.UpdateValues(); RamSearch1.UpdateValues(); HexEditor1.UpdateValues(); + NESPPU1.UpdateValues(); if (InputLog.GetMovieMode() == MOVIEMODE.RECORD) InputLog.GetMnemonic(); } @@ -985,6 +989,17 @@ namespace BizHawk.MultiClient HexEditor1.Focus(); } + private void LoadNESPPU() + { + if (!NESPPU1.IsHandleCreated || NESPPU1.IsDisposed) + { + NESPPU1 = new NESPPU(); + NESPPU1.Show(); + } + else + NESPPU1.Focus(); + } + private int lastWidth = -1; private int lastHeight = -1; @@ -1186,8 +1201,7 @@ namespace BizHawk.MultiClient private void pPUViewerToolStripMenuItem_Click(object sender, EventArgs e) { - NESPPU n = new NESPPU(); - n.Show(); + LoadNESPPU(); } private void enableRewindToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/NEStools/NESPPU.Designer.cs b/BizHawk.MultiClient/NEStools/NESPPU.Designer.cs index 489ac22f56..d3f5df5987 100644 --- a/BizHawk.MultiClient/NEStools/NESPPU.Designer.cs +++ b/BizHawk.MultiClient/NEStools/NESPPU.Designer.cs @@ -30,7 +30,7 @@ { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.PalettesGroup = new System.Windows.Forms.GroupBox(); - this.PaletteView = new PaletteViewer(); + this.PaletteView = new BizHawk.MultiClient.PaletteViewer(); this.PalettesGroup.SuspendLayout(); this.SuspendLayout(); // @@ -55,9 +55,10 @@ // // PaletteView // + this.PaletteView.BackColor = System.Drawing.Color.White; this.PaletteView.Location = new System.Drawing.Point(69, 35); - this.PaletteView.Size = new System.Drawing.Size(257, 34); this.PaletteView.Name = "PaletteView"; + this.PaletteView.Size = new System.Drawing.Size(257, 34); this.PaletteView.TabIndex = 0; // // NESPPU @@ -67,11 +68,11 @@ this.ClientSize = new System.Drawing.Size(443, 359); this.Controls.Add(this.PalettesGroup); this.Controls.Add(this.groupBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "NESPPU"; this.Text = "PPU Viewer"; this.Load += new System.EventHandler(this.NESPPU_Load); this.PalettesGroup.ResumeLayout(false); - this.PalettesGroup.PerformLayout(); this.ResumeLayout(false); } diff --git a/BizHawk.MultiClient/NEStools/NESPPU.cs b/BizHawk.MultiClient/NEStools/NESPPU.cs index d6042cf7d6..dc01fe715a 100644 --- a/BizHawk.MultiClient/NEStools/NESPPU.cs +++ b/BizHawk.MultiClient/NEStools/NESPPU.cs @@ -12,19 +12,41 @@ namespace BizHawk.MultiClient { public partial class NESPPU : Form { + int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired + int defaultHeight; + public NESPPU() { InitializeComponent(); + Closing += (o, e) => SaveConfigSettings(); + } + + private void SaveConfigSettings() + { + Global.Config.NESPPUWndx = this.Location.X; + Global.Config.NESPPUWndy = this.Location.Y; + } + + private void LoadConfigSettings() + { + defaultWidth = Size.Width; //Save these first so that the user can restore to its original size + defaultHeight = Size.Height; + + if (Global.Config.NESPPUWndx >= 0 && Global.Config.NESPPUWndy >= 0) + Location = new Point(Global.Config.NESPPUWndx, Global.Config.NESPPUWndy); + } public void UpdateValues() { if (!(Global.Emulator is NES)) return; + if (!this.IsHandleCreated || this.IsDisposed) return; + PaletteView.Refresh(); } private void NESPPU_Load(object sender, EventArgs e) { - + LoadConfigSettings(); } } }