UI: Allow recent game selection screen to display 4 or 9 titles based on window size
This commit is contained in:
parent
1d7f0596ce
commit
4f98329f33
7 changed files with 477 additions and 134 deletions
119
UI/Controls/ctrlRecentGame.Designer.cs
generated
Normal file
119
UI/Controls/ctrlRecentGame.Designer.cs
generated
Normal file
|
@ -0,0 +1,119 @@
|
|||
namespace Mesen.GUI.Controls
|
||||
{
|
||||
partial class ctrlRecentGame
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.lblGameName = new System.Windows.Forms.Label();
|
||||
this.lblSaveDate = new System.Windows.Forms.Label();
|
||||
this.picPreviousState = new Mesen.GUI.Controls.GamePreviewBox();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPreviousState)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 1;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.picPreviousState, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.lblGameName, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.lblSaveDate, 0, 2);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 3;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(158, 93);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// lblGameName
|
||||
//
|
||||
this.lblGameName.AutoEllipsis = true;
|
||||
this.lblGameName.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblGameName.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lblGameName.ForeColor = System.Drawing.Color.White;
|
||||
this.lblGameName.Location = new System.Drawing.Point(3, 64);
|
||||
this.lblGameName.Name = "lblGameName";
|
||||
this.lblGameName.Size = new System.Drawing.Size(152, 16);
|
||||
this.lblGameName.TabIndex = 12;
|
||||
this.lblGameName.Text = "Game Name";
|
||||
this.lblGameName.TextAlign = System.Drawing.ContentAlignment.TopCenter;
|
||||
//
|
||||
// lblSaveDate
|
||||
//
|
||||
this.lblSaveDate.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.lblSaveDate.AutoSize = true;
|
||||
this.lblSaveDate.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblSaveDate.ForeColor = System.Drawing.Color.White;
|
||||
this.lblSaveDate.Location = new System.Drawing.Point(64, 80);
|
||||
this.lblSaveDate.Name = "lblSaveDate";
|
||||
this.lblSaveDate.Size = new System.Drawing.Size(30, 13);
|
||||
this.lblSaveDate.TabIndex = 13;
|
||||
this.lblSaveDate.Text = "Date";
|
||||
//
|
||||
// picPreviousState
|
||||
//
|
||||
this.picPreviousState.BackColor = System.Drawing.Color.Black;
|
||||
this.picPreviousState.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.picPreviousState.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.picPreviousState.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
this.picPreviousState.Location = new System.Drawing.Point(0, 0);
|
||||
this.picPreviousState.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.picPreviousState.Name = "picPreviousState";
|
||||
this.picPreviousState.Size = new System.Drawing.Size(158, 64);
|
||||
this.picPreviousState.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.picPreviousState.TabIndex = 11;
|
||||
this.picPreviousState.TabStop = false;
|
||||
this.picPreviousState.Visible = false;
|
||||
this.picPreviousState.Click += new System.EventHandler(this.picPreviousState_Click);
|
||||
//
|
||||
// ctrlRecentGame
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Name = "ctrlRecentGame";
|
||||
this.Size = new System.Drawing.Size(158, 93);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPreviousState)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private GamePreviewBox picPreviousState;
|
||||
private System.Windows.Forms.Label lblGameName;
|
||||
private System.Windows.Forms.Label lblSaveDate;
|
||||
}
|
||||
}
|
77
UI/Controls/ctrlRecentGame.cs
Normal file
77
UI/Controls/ctrlRecentGame.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using Mesen.GUI.Emulation;
|
||||
|
||||
namespace Mesen.GUI.Controls
|
||||
{
|
||||
public partial class ctrlRecentGame : UserControl
|
||||
{
|
||||
private RecentGameInfo _recentGame;
|
||||
|
||||
public ctrlRecentGame()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public RecentGameInfo RecentGame
|
||||
{
|
||||
get { return _recentGame; }
|
||||
set
|
||||
{
|
||||
if(_recentGame == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
_recentGame = value;
|
||||
|
||||
lblSaveDate.Visible = false;
|
||||
|
||||
if(value == null) {
|
||||
picPreviousState.Visible = false;
|
||||
lblGameName.Visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
lblGameName.Text = Path.GetFileNameWithoutExtension(_recentGame.RomName);
|
||||
lblSaveDate.Text = _recentGame.Timestamp.ToString();
|
||||
|
||||
try {
|
||||
ZipArchive zip = new ZipArchive(new MemoryStream(File.ReadAllBytes(_recentGame.FileName)));
|
||||
ZipArchiveEntry entry = zip.GetEntry("Screenshot.png");
|
||||
if(entry != null) {
|
||||
using(Stream stream = entry.Open()) {
|
||||
picPreviousState.Image = Image.FromStream(stream);
|
||||
}
|
||||
} else {
|
||||
picPreviousState.Image = null;
|
||||
}
|
||||
} catch {
|
||||
picPreviousState.Image = null;
|
||||
}
|
||||
|
||||
lblGameName.Visible = true;
|
||||
lblSaveDate.Visible = true;
|
||||
picPreviousState.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Highlight
|
||||
{
|
||||
set { picPreviousState.Highlight = value; }
|
||||
}
|
||||
|
||||
private void picPreviousState_Click(object sender, EventArgs e)
|
||||
{
|
||||
EmuRunner.LoadRecentGame(_recentGame.FileName);
|
||||
}
|
||||
}
|
||||
}
|
120
UI/Controls/ctrlRecentGame.resx
Normal file
120
UI/Controls/ctrlRecentGame.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
88
UI/Controls/ctrlRecentGames.Designer.cs
generated
88
UI/Controls/ctrlRecentGames.Designer.cs
generated
|
@ -29,14 +29,11 @@
|
|||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.tlpPreviousState = new Mesen.GUI.Controls.DBTableLayoutPanel();
|
||||
this.picPreviousState = new Mesen.GUI.Controls.GamePreviewBox();
|
||||
this.lblGameName = new System.Windows.Forms.Label();
|
||||
this.lblSaveDate = new System.Windows.Forms.Label();
|
||||
this.picNextGame = new System.Windows.Forms.PictureBox();
|
||||
this.picPrevGame = new System.Windows.Forms.PictureBox();
|
||||
this.tmrInput = new System.Windows.Forms.Timer(this.components);
|
||||
this.tlpGrid = new DBTableLayoutPanel();
|
||||
this.tlpPreviousState.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPreviousState)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picNextGame)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPrevGame)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
|
@ -48,65 +45,21 @@
|
|||
this.tlpPreviousState.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tlpPreviousState.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tlpPreviousState.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tlpPreviousState.Controls.Add(this.picPreviousState, 1, 1);
|
||||
this.tlpPreviousState.Controls.Add(this.lblGameName, 1, 2);
|
||||
this.tlpPreviousState.Controls.Add(this.lblSaveDate, 1, 3);
|
||||
this.tlpPreviousState.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tlpPreviousState.Controls.Add(this.picNextGame, 2, 1);
|
||||
this.tlpPreviousState.Controls.Add(this.picPrevGame, 0, 1);
|
||||
this.tlpPreviousState.Controls.Add(this.tlpGrid, 1, 1);
|
||||
this.tlpPreviousState.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tlpPreviousState.Location = new System.Drawing.Point(0, 0);
|
||||
this.tlpPreviousState.Name = "tlpPreviousState";
|
||||
this.tlpPreviousState.RowCount = 6;
|
||||
this.tlpPreviousState.RowCount = 3;
|
||||
this.tlpPreviousState.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F));
|
||||
this.tlpPreviousState.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tlpPreviousState.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tlpPreviousState.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tlpPreviousState.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 5F));
|
||||
this.tlpPreviousState.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tlpPreviousState.Size = new System.Drawing.Size(272, 107);
|
||||
this.tlpPreviousState.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tlpPreviousState.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tlpPreviousState.Size = new System.Drawing.Size(272, 236);
|
||||
this.tlpPreviousState.TabIndex = 9;
|
||||
//
|
||||
// picPreviousState
|
||||
//
|
||||
this.picPreviousState.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.picPreviousState.BackColor = System.Drawing.Color.Black;
|
||||
this.picPreviousState.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.picPreviousState.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
this.picPreviousState.Location = new System.Drawing.Point(115, 10);
|
||||
this.picPreviousState.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.picPreviousState.Name = "picPreviousState";
|
||||
this.picPreviousState.Size = new System.Drawing.Size(42, 42);
|
||||
this.picPreviousState.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.picPreviousState.TabIndex = 7;
|
||||
this.picPreviousState.TabStop = false;
|
||||
this.picPreviousState.Visible = false;
|
||||
this.picPreviousState.Click += new System.EventHandler(this.picPreviousState_Click);
|
||||
//
|
||||
// lblGameName
|
||||
//
|
||||
this.lblGameName.AutoEllipsis = true;
|
||||
this.lblGameName.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblGameName.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lblGameName.ForeColor = System.Drawing.Color.White;
|
||||
this.lblGameName.Location = new System.Drawing.Point(36, 62);
|
||||
this.lblGameName.Name = "lblGameName";
|
||||
this.lblGameName.Size = new System.Drawing.Size(200, 16);
|
||||
this.lblGameName.TabIndex = 9;
|
||||
this.lblGameName.Text = "Game Name";
|
||||
this.lblGameName.TextAlign = System.Drawing.ContentAlignment.TopCenter;
|
||||
//
|
||||
// lblSaveDate
|
||||
//
|
||||
this.lblSaveDate.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.lblSaveDate.AutoSize = true;
|
||||
this.lblSaveDate.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblSaveDate.ForeColor = System.Drawing.Color.White;
|
||||
this.lblSaveDate.Location = new System.Drawing.Point(121, 78);
|
||||
this.lblSaveDate.Name = "lblSaveDate";
|
||||
this.lblSaveDate.Size = new System.Drawing.Size(30, 13);
|
||||
this.lblSaveDate.TabIndex = 10;
|
||||
this.lblSaveDate.Text = "Date";
|
||||
//
|
||||
// picNextGame
|
||||
//
|
||||
this.picNextGame.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
|
@ -114,7 +67,7 @@
|
|||
this.picNextGame.Image = global::Mesen.GUI.Properties.Resources.MediaPlay;
|
||||
this.picNextGame.Location = new System.Drawing.Point(242, 13);
|
||||
this.picNextGame.Name = "picNextGame";
|
||||
this.picNextGame.Size = new System.Drawing.Size(27, 46);
|
||||
this.picNextGame.Size = new System.Drawing.Size(27, 200);
|
||||
this.picNextGame.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||
this.picNextGame.TabIndex = 11;
|
||||
this.picNextGame.TabStop = false;
|
||||
|
@ -127,7 +80,7 @@
|
|||
this.picPrevGame.Image = global::Mesen.GUI.Properties.Resources.MediaPlay;
|
||||
this.picPrevGame.Location = new System.Drawing.Point(3, 13);
|
||||
this.picPrevGame.Name = "picPrevGame";
|
||||
this.picPrevGame.Size = new System.Drawing.Size(27, 46);
|
||||
this.picPrevGame.Size = new System.Drawing.Size(27, 200);
|
||||
this.picPrevGame.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||
this.picPrevGame.TabIndex = 12;
|
||||
this.picPrevGame.TabStop = false;
|
||||
|
@ -138,6 +91,21 @@
|
|||
this.tmrInput.Interval = 50;
|
||||
this.tmrInput.Tick += new System.EventHandler(this.tmrInput_Tick);
|
||||
//
|
||||
// tlpGrid
|
||||
//
|
||||
this.tlpGrid.ColumnCount = 2;
|
||||
this.tlpGrid.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tlpGrid.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tlpGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tlpGrid.Location = new System.Drawing.Point(33, 10);
|
||||
this.tlpGrid.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
|
||||
this.tlpGrid.Name = "tlpGrid";
|
||||
this.tlpGrid.RowCount = 2;
|
||||
this.tlpGrid.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tlpGrid.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tlpGrid.Size = new System.Drawing.Size(206, 206);
|
||||
this.tlpGrid.TabIndex = 13;
|
||||
//
|
||||
// ctrlRecentGames
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -145,10 +113,8 @@
|
|||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.tlpPreviousState);
|
||||
this.Name = "ctrlRecentGames";
|
||||
this.Size = new System.Drawing.Size(272, 107);
|
||||
this.Size = new System.Drawing.Size(272, 236);
|
||||
this.tlpPreviousState.ResumeLayout(false);
|
||||
this.tlpPreviousState.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPreviousState)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picNextGame)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPrevGame)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -158,11 +124,9 @@
|
|||
#endregion
|
||||
|
||||
private DBTableLayoutPanel tlpPreviousState;
|
||||
private GamePreviewBox picPreviousState;
|
||||
private System.Windows.Forms.Label lblGameName;
|
||||
private System.Windows.Forms.Label lblSaveDate;
|
||||
private System.Windows.Forms.PictureBox picNextGame;
|
||||
private System.Windows.Forms.PictureBox picPrevGame;
|
||||
private System.Windows.Forms.Timer tmrInput;
|
||||
private DBTableLayoutPanel tlpGrid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ namespace Mesen.GUI.Controls
|
|||
{
|
||||
public partial class ctrlRecentGames : BaseControl
|
||||
{
|
||||
private int _elementsPerRow = 0;
|
||||
private int _elementsPerPage = 0;
|
||||
|
||||
public delegate void RecentGameLoadedHandler(RecentGameInfo gameInfo);
|
||||
|
||||
public new event MouseEventHandler MouseMove
|
||||
|
@ -36,7 +39,7 @@ namespace Mesen.GUI.Controls
|
|||
private bool _initialized = false;
|
||||
private int _currentIndex = 0;
|
||||
private List<RecentGameInfo> _recentGames = new List<RecentGameInfo>();
|
||||
private PrivateFontCollection _fonts = new PrivateFontCollection();
|
||||
private List<ctrlRecentGame> _controls = new List<ctrlRecentGame>();
|
||||
|
||||
public ctrlRecentGames()
|
||||
{
|
||||
|
@ -47,13 +50,51 @@ namespace Mesen.GUI.Controls
|
|||
|
||||
DoubleBuffered = true;
|
||||
|
||||
_fonts.AddFontFile(Path.Combine(ConfigManager.HomeFolder, "Resources", "PixelFont.ttf"));
|
||||
lblGameName.Font = new Font(_fonts.Families[0], 10);
|
||||
lblSaveDate.Font = new Font(_fonts.Families[0], 10);
|
||||
|
||||
picPrevGame.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
|
||||
}
|
||||
|
||||
private void InitGrid()
|
||||
{
|
||||
int elementsPerRow = 1;
|
||||
if(ClientSize.Width > 850 && ClientSize.Height > 850) {
|
||||
elementsPerRow = 3;
|
||||
} else if(ClientSize.Width > 450 && ClientSize.Height > 450) {
|
||||
elementsPerRow = 2;
|
||||
}
|
||||
|
||||
if(_recentGames.Count <= 1) {
|
||||
elementsPerRow = 1;
|
||||
} else if(_recentGames.Count <= 4) {
|
||||
elementsPerRow = Math.Min(2, elementsPerRow);
|
||||
}
|
||||
|
||||
if(_elementsPerRow == elementsPerRow) {
|
||||
return;
|
||||
}
|
||||
|
||||
_elementsPerRow = elementsPerRow;
|
||||
_elementsPerPage = elementsPerRow * elementsPerRow;
|
||||
|
||||
_controls = new List<ctrlRecentGame>();
|
||||
tlpGrid.ColumnCount = _elementsPerRow;
|
||||
tlpGrid.RowCount = _elementsPerRow;
|
||||
tlpGrid.ColumnStyles.Clear();
|
||||
tlpGrid.RowStyles.Clear();
|
||||
tlpGrid.Controls.Clear();
|
||||
for(int j = 0; j < _elementsPerRow; j++) {
|
||||
tlpGrid.RowStyles.Add(new RowStyle(SizeType.Percent, 100F / _elementsPerRow));
|
||||
for(int i = 0; i < _elementsPerRow; i++) {
|
||||
tlpGrid.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F / _elementsPerRow));
|
||||
ctrlRecentGame ctrl = new ctrlRecentGame();
|
||||
ctrl.Dock = DockStyle.Fill;
|
||||
ctrl.Margin = new Padding(2);
|
||||
tlpGrid.Controls.Add(ctrl, i, j);
|
||||
_controls.Add(ctrl);
|
||||
}
|
||||
}
|
||||
UpdateGameInfo();
|
||||
}
|
||||
|
||||
public new bool Visible
|
||||
{
|
||||
get { return base.Visible; }
|
||||
|
@ -68,7 +109,7 @@ namespace Mesen.GUI.Controls
|
|||
//We just re-enabled the screen, initialize it
|
||||
Initialize();
|
||||
}
|
||||
|
||||
InitGrid();
|
||||
base.Visible = value;
|
||||
tmrInput.Enabled = value;
|
||||
}
|
||||
|
@ -82,6 +123,8 @@ namespace Mesen.GUI.Controls
|
|||
|
||||
public void Initialize()
|
||||
{
|
||||
InitGrid();
|
||||
|
||||
_initialized = true;
|
||||
_recentGames = new List<RecentGameInfo>();
|
||||
_currentIndex = 0;
|
||||
|
@ -107,8 +150,8 @@ namespace Mesen.GUI.Controls
|
|||
|
||||
_recentGames = _recentGames.OrderBy((info) => info.Timestamp).Reverse().ToList();
|
||||
|
||||
if(_recentGames.Count > 5) {
|
||||
_recentGames.RemoveRange(5, _recentGames.Count - 5);
|
||||
if(_recentGames.Count > 20) {
|
||||
_recentGames.RemoveRange(36, _recentGames.Count - 36);
|
||||
}
|
||||
|
||||
if(_recentGames.Count == 0) {
|
||||
|
@ -119,33 +162,19 @@ namespace Mesen.GUI.Controls
|
|||
tmrInput.Enabled = true;
|
||||
}
|
||||
|
||||
picPreviousState.Visible = _recentGames.Count > 0;
|
||||
picPrevGame.Visible = _recentGames.Count > 1;
|
||||
picNextGame.Visible = _recentGames.Count > 1;
|
||||
picPrevGame.Visible = true;
|
||||
picNextGame.Visible = true;
|
||||
}
|
||||
|
||||
public void UpdateGameInfo()
|
||||
{
|
||||
if(_currentIndex < _recentGames.Count) {
|
||||
lblGameName.Text = Path.GetFileNameWithoutExtension(_recentGames[_currentIndex].RomName);
|
||||
lblSaveDate.Text = _recentGames[_currentIndex].Timestamp.ToString();
|
||||
int count = _recentGames.Count;
|
||||
int pageStart = _currentIndex / _elementsPerPage * _elementsPerPage;
|
||||
|
||||
try {
|
||||
ZipArchive zip = new ZipArchive(new MemoryStream(File.ReadAllBytes(_recentGames[_currentIndex].FileName)));
|
||||
ZipArchiveEntry entry = zip.GetEntry("Screenshot.png");
|
||||
if(entry != null) {
|
||||
using(Stream stream = entry.Open()) {
|
||||
picPreviousState.Image = Image.FromStream(stream);
|
||||
}
|
||||
} else {
|
||||
picPreviousState.Image = null;
|
||||
}
|
||||
} catch {
|
||||
picPreviousState.Image = null;
|
||||
}
|
||||
UpdateSize();
|
||||
for(int i = 0; i < _elementsPerPage; i++) {
|
||||
_controls[i].RecentGame = count > pageStart + i ? _recentGames[pageStart+i] : null;
|
||||
_controls[i].Highlight = (_currentIndex % _elementsPerPage) == i;
|
||||
}
|
||||
picPreviousState.Visible = _recentGames.Count > 0;
|
||||
}
|
||||
|
||||
float _xFactor = 1;
|
||||
|
@ -157,22 +186,6 @@ namespace Mesen.GUI.Controls
|
|||
base.ScaleControl(factor, specified);
|
||||
}
|
||||
|
||||
private void UpdateSize()
|
||||
{
|
||||
tlpPreviousState.Visible = false;
|
||||
Size maxSize = new Size(this.Size.Width - (int)(120 * _xFactor), this.Size.Height - (int)(50 * _yFactor));
|
||||
|
||||
if(picPreviousState.Image != null) {
|
||||
double xRatio = (double)picPreviousState.Image.Width / maxSize.Width;
|
||||
double yRatio = (double)picPreviousState.Image.Height / maxSize.Height;
|
||||
double ratio = Math.Max(xRatio, yRatio);
|
||||
|
||||
Size newSize = new Size((int)(picPreviousState.Image.Width / ratio), (int)(picPreviousState.Image.Height / ratio));
|
||||
picPreviousState.Size = newSize;
|
||||
}
|
||||
tlpPreviousState.Visible = true;
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
if(Program.IsMono) {
|
||||
|
@ -183,48 +196,40 @@ namespace Mesen.GUI.Controls
|
|||
picPrevGame.Dock = DockStyle.Fill;
|
||||
}
|
||||
|
||||
if(picPreviousState.Image != null) {
|
||||
UpdateSize();
|
||||
}
|
||||
InitGrid();
|
||||
base.OnResize(e);
|
||||
}
|
||||
|
||||
private void picPreviousState_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadSelectedGame();
|
||||
}
|
||||
|
||||
private void picNextGame_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
GoToNextGame();
|
||||
GoToNextPage();
|
||||
}
|
||||
|
||||
private void picPrevGame_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
GoToPreviousGame();
|
||||
GoToPreviousPage();
|
||||
}
|
||||
|
||||
private void GoToPreviousGame()
|
||||
private void GoToPreviousPage()
|
||||
{
|
||||
if(_currentIndex == 0) {
|
||||
_currentIndex = _recentGames.Count - 1;
|
||||
if(_currentIndex < _elementsPerPage) {
|
||||
_currentIndex = _recentGames.Count - _elementsPerPage;
|
||||
} else {
|
||||
_currentIndex--;
|
||||
_currentIndex -= _elementsPerPage;
|
||||
}
|
||||
UpdateGameInfo();
|
||||
}
|
||||
|
||||
private void GoToNextGame()
|
||||
private void GoToNextPage()
|
||||
{
|
||||
_currentIndex = (_currentIndex + 1) % _recentGames.Count;
|
||||
if(_currentIndex + _elementsPerPage < _recentGames.Count) {
|
||||
_currentIndex += _elementsPerPage;
|
||||
} else {
|
||||
_currentIndex = 0;
|
||||
}
|
||||
UpdateGameInfo();
|
||||
}
|
||||
|
||||
private void LoadSelectedGame()
|
||||
{
|
||||
EmuRunner.LoadRecentGame(_recentGames[_currentIndex].FileName);
|
||||
}
|
||||
|
||||
private bool _waitForRelease = false;
|
||||
private void tmrInput_Tick(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -244,13 +249,51 @@ namespace Mesen.GUI.Controls
|
|||
foreach(KeyMapping mapping in mappings) {
|
||||
if(mapping.Left == keyCode) {
|
||||
_waitForRelease = true;
|
||||
GoToPreviousGame();
|
||||
if(_currentIndex == 0) {
|
||||
_currentIndex = _recentGames.Count - 1;
|
||||
} else {
|
||||
_currentIndex--;
|
||||
}
|
||||
UpdateGameInfo();
|
||||
} else if(mapping.Right == keyCode) {
|
||||
_waitForRelease = true;
|
||||
GoToNextGame();
|
||||
} else if(mapping.A == keyCode || mapping.B == keyCode) {
|
||||
_currentIndex = (_currentIndex + 1) % _recentGames.Count;
|
||||
UpdateGameInfo();
|
||||
} else if(mapping.Down == keyCode) {
|
||||
_waitForRelease = true;
|
||||
LoadSelectedGame();
|
||||
if(_currentIndex + _elementsPerRow < _recentGames.Count) {
|
||||
_currentIndex += _elementsPerRow;
|
||||
} else {
|
||||
_currentIndex = 0;
|
||||
}
|
||||
UpdateGameInfo();
|
||||
} else if(mapping.Up == keyCode) {
|
||||
_waitForRelease = true;
|
||||
if(_currentIndex < _elementsPerRow) {
|
||||
_currentIndex = _recentGames.Count - _elementsPerRow;
|
||||
} else {
|
||||
_currentIndex -= _elementsPerRow;
|
||||
}
|
||||
UpdateGameInfo();
|
||||
} else if(mapping.L == keyCode) {
|
||||
_waitForRelease = true;
|
||||
if(_currentIndex < _elementsPerPage) {
|
||||
_currentIndex = _recentGames.Count - _elementsPerPage;
|
||||
} else {
|
||||
_currentIndex -= _elementsPerPage;
|
||||
}
|
||||
UpdateGameInfo();
|
||||
} else if(mapping.R == keyCode) {
|
||||
_waitForRelease = true;
|
||||
if(_currentIndex + _elementsPerPage < _recentGames.Count) {
|
||||
_currentIndex += _elementsPerPage;
|
||||
} else {
|
||||
_currentIndex = 0; ;
|
||||
}
|
||||
UpdateGameInfo();
|
||||
} else if(mapping.A == keyCode || mapping.B == keyCode || mapping.X == keyCode || mapping.Y == keyCode || mapping.Select == keyCode || mapping.Start == keyCode) {
|
||||
_waitForRelease = true;
|
||||
EmuRunner.LoadRecentGame(_recentGames[_currentIndex].FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,6 +316,7 @@ namespace Mesen.GUI.Controls
|
|||
{
|
||||
public System.Drawing.Drawing2D.InterpolationMode InterpolationMode { get; set; }
|
||||
private bool _hovered = false;
|
||||
private bool _highlight = false;
|
||||
|
||||
public GamePreviewBox()
|
||||
{
|
||||
|
@ -280,6 +324,16 @@ namespace Mesen.GUI.Controls
|
|||
InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
|
||||
}
|
||||
|
||||
public bool Highlight
|
||||
{
|
||||
get { return _highlight; }
|
||||
set
|
||||
{
|
||||
_highlight = value;
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(EventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
|
@ -299,7 +353,7 @@ namespace Mesen.GUI.Controls
|
|||
pe.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
base.OnPaint(pe);
|
||||
|
||||
using(Pen pen = new Pen(_hovered ? Color.LightBlue : Color.Gray, 2)) {
|
||||
using(Pen pen = new Pen(_hovered ? Color.LightBlue : (_highlight ? Color.Orange : Color.Gray), 2)) {
|
||||
pe.Graphics.DrawRectangle(pen, 1, 1, this.Width - 2, this.Height - 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -432,7 +432,7 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
private void ResizeRecentGames()
|
||||
{
|
||||
ctrlRecentGames.Height = this.ClientSize.Height - ctrlRecentGames.Top - 80;
|
||||
ctrlRecentGames.Height = this.ClientSize.Height - ctrlRecentGames.Top - 5;
|
||||
}
|
||||
|
||||
private void frmMain_Resize(object sender, EventArgs e)
|
||||
|
|
|
@ -230,6 +230,12 @@
|
|||
<Compile Include="Controls\ctrlLinkLabel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ctrlRecentGame.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ctrlRecentGame.Designer.cs">
|
||||
<DependentUpon>ctrlRecentGame.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ctrlRecentGames.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -920,6 +926,9 @@
|
|||
<EmbeddedResource Include="Controls\ctrlPathSelection.resx">
|
||||
<DependentUpon>ctrlPathSelection.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Controls\ctrlRecentGame.resx">
|
||||
<DependentUpon>ctrlRecentGame.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Controls\ctrlRecentGames.resx">
|
||||
<DependentUpon>ctrlRecentGames.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
Loading…
Add table
Reference in a new issue