mirror of
https://github.com/SourMesen/Mesen.git
synced 2025-04-02 10:52:48 -04:00
UI: Added option to show color indexes in palette viewer
This commit is contained in:
parent
2faf6aecd4
commit
6078b0120e
3 changed files with 85 additions and 35 deletions
|
@ -51,6 +51,7 @@ namespace Mesen.GUI.Config
|
|||
public bool FullscreenForceIntegerScale = false;
|
||||
|
||||
public bool UseCustomVsPalette = false;
|
||||
public bool ShowColorIndexes = true;
|
||||
|
||||
public List<PaletteInfo> SavedPalettes = new List<PaletteInfo>();
|
||||
|
||||
|
|
80
GUI.NET/Forms/Config/frmVideoConfig.Designer.cs
generated
80
GUI.NET/Forms/Config/frmVideoConfig.Designer.cs
generated
|
@ -35,7 +35,6 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.lblVideoScale = new System.Windows.Forms.Label();
|
||||
this.chkVerticalSync = new System.Windows.Forms.CheckBox();
|
||||
this.lblDisplayRatio = new System.Windows.Forms.Label();
|
||||
this.chkShowFps = new System.Windows.Forms.CheckBox();
|
||||
this.flowLayoutPanel7 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.chkUseHdPacks = new System.Windows.Forms.CheckBox();
|
||||
this.picHdNesTooltip = new System.Windows.Forms.PictureBox();
|
||||
|
@ -44,6 +43,8 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.cboAspectRatio = new System.Windows.Forms.ComboBox();
|
||||
this.lblCustomRatio = new System.Windows.Forms.Label();
|
||||
this.nudCustomRatio = new System.Windows.Forms.NumericUpDown();
|
||||
this.chkFullscreenForceIntegerScale = new System.Windows.Forms.CheckBox();
|
||||
this.chkShowFps = new System.Windows.Forms.CheckBox();
|
||||
this.tabMain = new System.Windows.Forms.TabControl();
|
||||
this.tpgGeneral = new System.Windows.Forms.TabPage();
|
||||
this.tpgPicture = new System.Windows.Forms.TabPage();
|
||||
|
@ -123,7 +124,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.mnuPaletteSonyCxa2025As = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuPaletteUnsaturated = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuPaletteYuv = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.chkFullscreenForceIntegerScale = new System.Windows.Forms.CheckBox();
|
||||
this.chkShowColorIndexes = new System.Windows.Forms.CheckBox();
|
||||
this.tlpMain.SuspendLayout();
|
||||
this.flowLayoutPanel7.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picHdNesTooltip)).BeginInit();
|
||||
|
@ -229,18 +230,6 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.lblDisplayRatio.TabIndex = 17;
|
||||
this.lblDisplayRatio.Text = "Aspect Ratio:";
|
||||
//
|
||||
// chkShowFps
|
||||
//
|
||||
this.chkShowFps.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.chkShowFps.AutoSize = true;
|
||||
this.tlpMain.SetColumnSpan(this.chkShowFps, 2);
|
||||
this.chkShowFps.Location = new System.Drawing.Point(3, 124);
|
||||
this.chkShowFps.Name = "chkShowFps";
|
||||
this.chkShowFps.Size = new System.Drawing.Size(76, 17);
|
||||
this.chkShowFps.TabIndex = 9;
|
||||
this.chkShowFps.Text = "Show FPS";
|
||||
this.chkShowFps.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// flowLayoutPanel7
|
||||
//
|
||||
this.tlpMain.SetColumnSpan(this.flowLayoutPanel7, 2);
|
||||
|
@ -357,6 +346,30 @@ namespace Mesen.GUI.Forms.Config
|
|||
65536});
|
||||
this.nudCustomRatio.Visible = false;
|
||||
//
|
||||
// chkFullscreenForceIntegerScale
|
||||
//
|
||||
this.chkFullscreenForceIntegerScale.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.chkFullscreenForceIntegerScale.AutoSize = true;
|
||||
this.tlpMain.SetColumnSpan(this.chkFullscreenForceIntegerScale, 2);
|
||||
this.chkFullscreenForceIntegerScale.Location = new System.Drawing.Point(3, 101);
|
||||
this.chkFullscreenForceIntegerScale.Name = "chkFullscreenForceIntegerScale";
|
||||
this.chkFullscreenForceIntegerScale.Size = new System.Drawing.Size(289, 17);
|
||||
this.chkFullscreenForceIntegerScale.TabIndex = 23;
|
||||
this.chkFullscreenForceIntegerScale.Text = "Use integer scale values when entering fullscreen mode";
|
||||
this.chkFullscreenForceIntegerScale.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// chkShowFps
|
||||
//
|
||||
this.chkShowFps.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.chkShowFps.AutoSize = true;
|
||||
this.tlpMain.SetColumnSpan(this.chkShowFps, 2);
|
||||
this.chkShowFps.Location = new System.Drawing.Point(3, 124);
|
||||
this.chkShowFps.Name = "chkShowFps";
|
||||
this.chkShowFps.Size = new System.Drawing.Size(76, 17);
|
||||
this.chkShowFps.TabIndex = 9;
|
||||
this.chkShowFps.Text = "Show FPS";
|
||||
this.chkShowFps.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabMain
|
||||
//
|
||||
this.tabMain.Controls.Add(this.tpgGeneral);
|
||||
|
@ -1053,20 +1066,23 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.picPalette.Location = new System.Drawing.Point(1, 1);
|
||||
this.picPalette.Margin = new System.Windows.Forms.Padding(1);
|
||||
this.picPalette.Name = "picPalette";
|
||||
this.picPalette.Size = new System.Drawing.Size(352, 88);
|
||||
this.picPalette.Size = new System.Drawing.Size(338, 338);
|
||||
this.picPalette.TabIndex = 0;
|
||||
this.picPalette.TabStop = false;
|
||||
this.picPalette.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picPalette_MouseDown);
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tableLayoutPanel2.ColumnCount = 1;
|
||||
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel2.Controls.Add(this.btnExportPalette, 0, 2);
|
||||
this.tableLayoutPanel2.Controls.Add(this.btnSelectPalette, 0, 0);
|
||||
this.tableLayoutPanel2.Controls.Add(this.btnLoadPalFile, 0, 1);
|
||||
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(354, 0);
|
||||
this.tableLayoutPanel2.Controls.Add(this.chkShowColorIndexes, 0, 3);
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(340, 0);
|
||||
this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
this.tableLayoutPanel2.RowCount = 4;
|
||||
|
@ -1074,7 +1090,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(167, 90);
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(181, 340);
|
||||
this.tableLayoutPanel2.TabIndex = 1;
|
||||
//
|
||||
// btnExportPalette
|
||||
|
@ -1083,7 +1099,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.btnExportPalette.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.btnExportPalette.Location = new System.Drawing.Point(3, 61);
|
||||
this.btnExportPalette.Name = "btnExportPalette";
|
||||
this.btnExportPalette.Size = new System.Drawing.Size(161, 23);
|
||||
this.btnExportPalette.Size = new System.Drawing.Size(175, 23);
|
||||
this.btnExportPalette.TabIndex = 3;
|
||||
this.btnExportPalette.Text = "Export Palette";
|
||||
this.btnExportPalette.UseVisualStyleBackColor = true;
|
||||
|
@ -1096,7 +1112,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.btnSelectPalette.Image = ((System.Drawing.Image)(resources.GetObject("btnSelectPalette.Image")));
|
||||
this.btnSelectPalette.Location = new System.Drawing.Point(3, 3);
|
||||
this.btnSelectPalette.Name = "btnSelectPalette";
|
||||
this.btnSelectPalette.Size = new System.Drawing.Size(161, 23);
|
||||
this.btnSelectPalette.Size = new System.Drawing.Size(175, 23);
|
||||
this.btnSelectPalette.TabIndex = 2;
|
||||
this.btnSelectPalette.Text = "Load Preset Palette...";
|
||||
this.btnSelectPalette.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage;
|
||||
|
@ -1109,7 +1125,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.btnLoadPalFile.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.btnLoadPalFile.Location = new System.Drawing.Point(3, 32);
|
||||
this.btnLoadPalFile.Name = "btnLoadPalFile";
|
||||
this.btnLoadPalFile.Size = new System.Drawing.Size(161, 23);
|
||||
this.btnLoadPalFile.Size = new System.Drawing.Size(175, 23);
|
||||
this.btnLoadPalFile.TabIndex = 0;
|
||||
this.btnLoadPalFile.Text = "Load Palette File";
|
||||
this.btnLoadPalFile.UseVisualStyleBackColor = true;
|
||||
|
@ -1119,7 +1135,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
//
|
||||
this.chkUseCustomVsPalette.AutoSize = true;
|
||||
this.tableLayoutPanel3.SetColumnSpan(this.chkUseCustomVsPalette, 2);
|
||||
this.chkUseCustomVsPalette.Location = new System.Drawing.Point(3, 93);
|
||||
this.chkUseCustomVsPalette.Location = new System.Drawing.Point(3, 343);
|
||||
this.chkUseCustomVsPalette.Name = "chkUseCustomVsPalette";
|
||||
this.chkUseCustomVsPalette.Size = new System.Drawing.Size(202, 17);
|
||||
this.chkUseCustomVsPalette.TabIndex = 2;
|
||||
|
@ -1320,17 +1336,16 @@ namespace Mesen.GUI.Forms.Config
|
|||
this.mnuPaletteYuv.Text = "YUV v3 (by FirebrandX)";
|
||||
this.mnuPaletteYuv.Click += new System.EventHandler(this.mnuPaletteYuv_Click);
|
||||
//
|
||||
// chkFullscreenForceIntegerScale
|
||||
// chkShowColorIndexes
|
||||
//
|
||||
this.chkFullscreenForceIntegerScale.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.chkFullscreenForceIntegerScale.AutoSize = true;
|
||||
this.tlpMain.SetColumnSpan(this.chkFullscreenForceIntegerScale, 2);
|
||||
this.chkFullscreenForceIntegerScale.Location = new System.Drawing.Point(3, 101);
|
||||
this.chkFullscreenForceIntegerScale.Name = "chkFullscreenForceIntegerScale";
|
||||
this.chkFullscreenForceIntegerScale.Size = new System.Drawing.Size(289, 17);
|
||||
this.chkFullscreenForceIntegerScale.TabIndex = 23;
|
||||
this.chkFullscreenForceIntegerScale.Text = "Use integer scale values when entering fullscreen mode";
|
||||
this.chkFullscreenForceIntegerScale.UseVisualStyleBackColor = true;
|
||||
this.chkShowColorIndexes.AutoSize = true;
|
||||
this.chkShowColorIndexes.Location = new System.Drawing.Point(3, 90);
|
||||
this.chkShowColorIndexes.Name = "chkShowColorIndexes";
|
||||
this.chkShowColorIndexes.Size = new System.Drawing.Size(118, 17);
|
||||
this.chkShowColorIndexes.TabIndex = 4;
|
||||
this.chkShowColorIndexes.Text = "Show color indexes";
|
||||
this.chkShowColorIndexes.UseVisualStyleBackColor = true;
|
||||
this.chkShowColorIndexes.CheckedChanged += new System.EventHandler(this.chkShowColorIndexes_CheckedChanged);
|
||||
//
|
||||
// frmVideoConfig
|
||||
//
|
||||
|
@ -1498,5 +1513,6 @@ namespace Mesen.GUI.Forms.Config
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuPaletteCompositeDirect;
|
||||
private System.Windows.Forms.CheckBox chkUseCustomVsPalette;
|
||||
private System.Windows.Forms.CheckBox chkFullscreenForceIntegerScale;
|
||||
private System.Windows.Forms.CheckBox chkShowColorIndexes;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Mesen.GUI.Config;
|
||||
using Mesen.GUI.Controls;
|
||||
|
||||
namespace Mesen.GUI.Forms.Config
|
||||
{
|
||||
|
@ -65,6 +66,8 @@ namespace Mesen.GUI.Forms.Config
|
|||
|
||||
AddBinding("UseCustomVsPalette", chkUseCustomVsPalette);
|
||||
|
||||
AddBinding("ShowColorIndexes", chkShowColorIndexes);
|
||||
|
||||
_paletteData = InteropEmu.GetRgbPalette();
|
||||
RefreshPalette();
|
||||
|
||||
|
@ -120,14 +123,36 @@ namespace Mesen.GUI.Forms.Config
|
|||
GCHandle handle = GCHandle.Alloc(_paletteData, GCHandleType.Pinned);
|
||||
try {
|
||||
Bitmap source = new Bitmap(16, 4, 16*4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject());
|
||||
Bitmap target = new Bitmap(384, 96);
|
||||
Bitmap target = new Bitmap(336, 336);
|
||||
|
||||
Font font = new Font(BaseControl.MonospaceFontFamily, BaseControl.DefaultFontSize - 2);
|
||||
using(Graphics g = Graphics.FromImage(target)) {
|
||||
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
|
||||
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
|
||||
g.ScaleTransform(22, 22);
|
||||
g.ScaleTransform(42, 42);
|
||||
g.DrawImageUnscaled(source, 0, 0);
|
||||
g.DrawImageUnscaled(source, -8, 4);
|
||||
|
||||
if(chkShowColorIndexes.Checked) {
|
||||
g.ScaleTransform(1f/42, 1f/42);
|
||||
using(Brush bg = new SolidBrush(Color.FromArgb(150, Color.LightGray))) {
|
||||
for(int y = 0; y < 8; y++) {
|
||||
for(int x = 0; x < 8; x++) {
|
||||
int index = y * 16 + x;
|
||||
if(y >= 4) {
|
||||
index = (y - 4) * 16 + x + 8;
|
||||
}
|
||||
for(int i = -1; i <= 1; i++) {
|
||||
for(int j = -1; j <= 1; j++) {
|
||||
g.DrawString(index.ToString("X2"), font, bg, 42*x + 22+j, 42*y + 26+i);
|
||||
}
|
||||
}
|
||||
g.DrawString(index.ToString("X2"), font, Brushes.Black, 42*x + 22, 42*y + 26);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.picPalette.Image = target;
|
||||
} finally {
|
||||
|
@ -137,7 +162,10 @@ namespace Mesen.GUI.Forms.Config
|
|||
|
||||
private void picPalette_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
int offset = (e.X / 22) + (e.Y / 22 * 16);
|
||||
int y = e.Y / 42 < 4 ? e.Y : (e.Y - 168);
|
||||
int x = e.Y / 42 < 4 ? e.X : (e.X + 336);
|
||||
|
||||
int offset = (x / 42) + (y / 42 * 16);
|
||||
|
||||
colorDialog.SolidColorOnly = true;
|
||||
colorDialog.AllowFullOpen = true;
|
||||
|
@ -425,5 +453,10 @@ namespace Mesen.GUI.Forms.Config
|
|||
//Used in ValueChanged to make field more user-friendly
|
||||
_lastScaleInputNumber = -1;
|
||||
}
|
||||
|
||||
private void chkShowColorIndexes_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.RefreshPalette();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue