UI: Fixed rendering issues on startup
+ Improved load-up for recent games to not appear glitched for a split second
This commit is contained in:
parent
38e4403b79
commit
c96e37145f
10 changed files with 66 additions and 59 deletions
|
@ -33,6 +33,11 @@
|
|||
#include "../Utilities/PlatformUtilities.h"
|
||||
#include "../Utilities/FolderUtilities.h"
|
||||
|
||||
Console::Console()
|
||||
{
|
||||
_settings.reset(new EmuSettings());
|
||||
}
|
||||
|
||||
Console::~Console()
|
||||
{
|
||||
}
|
||||
|
@ -41,7 +46,6 @@ void Console::Initialize()
|
|||
{
|
||||
_lockCounter = 0;
|
||||
|
||||
_settings.reset(new EmuSettings());
|
||||
_notificationManager.reset(new NotificationManager());
|
||||
_videoDecoder.reset(new VideoDecoder(shared_from_this()));
|
||||
_videoRenderer.reset(new VideoRenderer(shared_from_this()));
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
void WaitForPauseEnd();
|
||||
|
||||
public:
|
||||
Console();
|
||||
~Console();
|
||||
|
||||
void Initialize();
|
||||
|
|
|
@ -37,7 +37,6 @@ FrameInfo VideoDecoder::GetFrameInfo()
|
|||
ScreenSize VideoDecoder::GetScreenSize(bool ignoreScale)
|
||||
{
|
||||
ScreenSize size;
|
||||
OverscanDimensions overscan = ignoreScale ? _videoFilter->GetOverscan() : _console->GetSettings()->GetOverscan();
|
||||
FrameInfo frameInfo = _videoFilter->GetFrameInfo();
|
||||
double aspectRatio = _console->GetSettings()->GetAspectRatio(_console->GetRegion());
|
||||
double scale = (ignoreScale ? 1 : _console->GetSettings()->GetVideoConfig().VideoScale);
|
||||
|
@ -48,6 +47,7 @@ ScreenSize VideoDecoder::GetScreenSize(bool ignoreScale)
|
|||
size.Width = (int32_t)(frameInfo.Width * scale / divider);
|
||||
size.Height = (int32_t)(frameInfo.Height * scale / divider);
|
||||
if(aspectRatio != 0.0) {
|
||||
OverscanDimensions overscan = _console->GetSettings()->GetOverscan();
|
||||
uint32_t originalHeight = frameInfo.Height + (overscan.Top + overscan.Bottom) * divider;
|
||||
uint32_t originalWidth = frameInfo.Width + (overscan.Left + overscan.Right) * divider;
|
||||
size.Width = (uint32_t)(originalHeight * scale * aspectRatio * ((double)frameInfo.Width / originalWidth)) / divider;
|
||||
|
|
|
@ -57,11 +57,12 @@ extern "C" {
|
|||
DllExport void __stdcall InitDll()
|
||||
{
|
||||
_console.reset(new Console());
|
||||
_console->Initialize();
|
||||
}
|
||||
|
||||
DllExport void __stdcall InitializeEmu(const char* homeFolder, void *windowHandle, void *viewerHandle, bool noAudio, bool noVideo, bool noInput)
|
||||
{
|
||||
_console->Initialize();
|
||||
|
||||
FolderUtilities::SetHomeFolder(homeFolder);
|
||||
_shortcutKeyHandler.reset(new ShortcutKeyHandler(_console));
|
||||
|
||||
|
|
|
@ -182,9 +182,10 @@ void SdlRenderer::Render()
|
|||
SDL_Rect dest = {0, 0, (int)_screenWidth, (int)_screenHeight };
|
||||
SDL_RenderCopy(_sdlRenderer, _sdlTexture, &source, &dest);
|
||||
|
||||
if(paused) {
|
||||
DrawPauseScreen();
|
||||
} else if(_console->GetVideoDecoder()->IsRunning()) {
|
||||
if(_console->GetVideoDecoder()->IsRunning()) {
|
||||
if(paused) {
|
||||
DrawPauseScreen();
|
||||
}
|
||||
DrawCounters();
|
||||
}
|
||||
|
||||
|
|
23
UI/Controls/ctrlRecentGames.Designer.cs
generated
23
UI/Controls/ctrlRecentGames.Designer.cs
generated
|
@ -29,7 +29,6 @@
|
|||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.tlpPreviousState = new Mesen.GUI.Controls.DBTableLayoutPanel();
|
||||
this.pnlPreviousState = new System.Windows.Forms.Panel();
|
||||
this.picPreviousState = new Mesen.GUI.Controls.GamePreviewBox();
|
||||
this.lblGameName = new System.Windows.Forms.Label();
|
||||
this.lblSaveDate = new System.Windows.Forms.Label();
|
||||
|
@ -37,7 +36,6 @@
|
|||
this.picPrevGame = new System.Windows.Forms.PictureBox();
|
||||
this.tmrInput = new System.Windows.Forms.Timer(this.components);
|
||||
this.tlpPreviousState.SuspendLayout();
|
||||
this.pnlPreviousState.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPreviousState)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picNextGame)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPrevGame)).BeginInit();
|
||||
|
@ -50,7 +48,7 @@
|
|||
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.pnlPreviousState, 1, 1);
|
||||
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.Controls.Add(this.picNextGame, 2, 1);
|
||||
|
@ -68,32 +66,21 @@
|
|||
this.tlpPreviousState.Size = new System.Drawing.Size(272, 107);
|
||||
this.tlpPreviousState.TabIndex = 9;
|
||||
//
|
||||
// pnlPreviousState
|
||||
//
|
||||
this.pnlPreviousState.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.pnlPreviousState.BackColor = System.Drawing.Color.Gray;
|
||||
this.pnlPreviousState.Controls.Add(this.picPreviousState);
|
||||
this.pnlPreviousState.Location = new System.Drawing.Point(113, 13);
|
||||
this.pnlPreviousState.Name = "pnlPreviousState";
|
||||
this.pnlPreviousState.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.pnlPreviousState.Size = new System.Drawing.Size(46, 46);
|
||||
this.pnlPreviousState.TabIndex = 8;
|
||||
//
|
||||
// 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(2, 2);
|
||||
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);
|
||||
this.picPreviousState.MouseEnter += new System.EventHandler(this.picPreviousState_MouseEnter);
|
||||
this.picPreviousState.MouseLeave += new System.EventHandler(this.picPreviousState_MouseLeave);
|
||||
//
|
||||
// lblGameName
|
||||
//
|
||||
|
@ -161,7 +148,6 @@
|
|||
this.Size = new System.Drawing.Size(272, 107);
|
||||
this.tlpPreviousState.ResumeLayout(false);
|
||||
this.tlpPreviousState.PerformLayout();
|
||||
this.pnlPreviousState.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPreviousState)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picNextGame)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picPrevGame)).EndInit();
|
||||
|
@ -172,7 +158,6 @@
|
|||
#endregion
|
||||
|
||||
private DBTableLayoutPanel tlpPreviousState;
|
||||
private System.Windows.Forms.Panel pnlPreviousState;
|
||||
private GamePreviewBox picPreviousState;
|
||||
private System.Windows.Forms.Label lblGameName;
|
||||
private System.Windows.Forms.Label lblSaveDate;
|
||||
|
|
|
@ -111,9 +111,6 @@ namespace Mesen.GUI.Controls
|
|||
_recentGames.RemoveRange(5, _recentGames.Count - 5);
|
||||
}
|
||||
|
||||
picPrevGame.Visible = _recentGames.Count > 1;
|
||||
picNextGame.Visible = _recentGames.Count > 1;
|
||||
|
||||
if(_recentGames.Count == 0) {
|
||||
this.Visible = false;
|
||||
tmrInput.Enabled = false;
|
||||
|
@ -121,6 +118,10 @@ namespace Mesen.GUI.Controls
|
|||
UpdateGameInfo();
|
||||
tmrInput.Enabled = true;
|
||||
}
|
||||
|
||||
picPreviousState.Visible = _recentGames.Count > 0;
|
||||
picPrevGame.Visible = _recentGames.Count > 1;
|
||||
picNextGame.Visible = _recentGames.Count > 1;
|
||||
}
|
||||
|
||||
public void UpdateGameInfo()
|
||||
|
@ -144,8 +145,9 @@ namespace Mesen.GUI.Controls
|
|||
}
|
||||
UpdateSize();
|
||||
}
|
||||
picPreviousState.Visible = _recentGames.Count > 0;
|
||||
}
|
||||
|
||||
|
||||
float _xFactor = 1;
|
||||
float _yFactor = 1;
|
||||
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
|
||||
|
@ -167,7 +169,6 @@ namespace Mesen.GUI.Controls
|
|||
|
||||
Size newSize = new Size((int)(picPreviousState.Image.Width / ratio), (int)(picPreviousState.Image.Height / ratio));
|
||||
picPreviousState.Size = newSize;
|
||||
pnlPreviousState.Size = new Size(newSize.Width+4, newSize.Height+4);
|
||||
}
|
||||
tlpPreviousState.Visible = true;
|
||||
}
|
||||
|
@ -187,17 +188,7 @@ namespace Mesen.GUI.Controls
|
|||
}
|
||||
base.OnResize(e);
|
||||
}
|
||||
|
||||
private void picPreviousState_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
pnlPreviousState.BackColor = Color.LightBlue;
|
||||
}
|
||||
|
||||
private void picPreviousState_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
pnlPreviousState.BackColor = Color.Gray;
|
||||
}
|
||||
|
||||
|
||||
private void picPreviousState_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadSelectedGame();
|
||||
|
@ -281,6 +272,7 @@ namespace Mesen.GUI.Controls
|
|||
public class GamePreviewBox : PictureBox
|
||||
{
|
||||
public System.Drawing.Drawing2D.InterpolationMode InterpolationMode { get; set; }
|
||||
private bool _hovered = false;
|
||||
|
||||
public GamePreviewBox()
|
||||
{
|
||||
|
@ -288,10 +280,28 @@ namespace Mesen.GUI.Controls
|
|||
InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(EventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
_hovered = true;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
_hovered = false;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pe)
|
||||
{
|
||||
pe.Graphics.InterpolationMode = InterpolationMode;
|
||||
pe.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
base.OnPaint(pe);
|
||||
|
||||
using(Pen pen = new Pen(_hovered ? Color.LightBlue : Color.Gray, 2)) {
|
||||
pe.Graphics.DrawRectangle(pen, 1, 1, this.Width - 2, this.Height - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace Mesen.GUI.Emulation
|
|||
SetScale(scale, false);
|
||||
}
|
||||
|
||||
private void SetScaleBasedOnWindowSize()
|
||||
public void SetScaleBasedOnWindowSize()
|
||||
{
|
||||
SetScaleBasedOnDimensions(_panel.ClientSize);
|
||||
}
|
||||
|
|
|
@ -62,24 +62,30 @@ namespace Mesen.GUI.Forms
|
|||
ConfigManager.Config.ApplyConfig();
|
||||
|
||||
_displayManager = new DisplayManager(this, ctrlRenderer, pnlRenderer, mnuMain, ctrlRecentGames);
|
||||
_displayManager.UpdateViewerSize();
|
||||
_displayManager.SetScaleBasedOnWindowSize();
|
||||
_shortcuts = new ShortcutHandler(_displayManager);
|
||||
|
||||
_notifListener = new NotificationListener();
|
||||
_notifListener.OnNotification += OnNotificationReceived;
|
||||
|
||||
SaveStateManager.InitializeStateMenu(mnuSaveState, true, _shortcuts);
|
||||
SaveStateManager.InitializeStateMenu(mnuLoadState, false, _shortcuts);
|
||||
|
||||
BindShortcuts();
|
||||
|
||||
ctrlRecentGames.Initialize();
|
||||
ResizeRecentGames();
|
||||
|
||||
_commandLine.LoadGameFromCommandLine();
|
||||
if(!EmuRunner.IsRunning()) {
|
||||
ctrlRecentGames.Visible = true;
|
||||
}
|
||||
|
||||
Task.Run(() => {
|
||||
System.Threading.Thread.Sleep(25);
|
||||
this.BeginInvoke((Action)(() => {
|
||||
SaveStateManager.InitializeStateMenu(mnuSaveState, true, _shortcuts);
|
||||
SaveStateManager.InitializeStateMenu(mnuLoadState, false, _shortcuts);
|
||||
|
||||
BindShortcuts();
|
||||
|
||||
ResizeRecentGames();
|
||||
ctrlRecentGames.Initialize();
|
||||
|
||||
if(!EmuRunner.IsRunning()) {
|
||||
ctrlRecentGames.Visible = true;
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
if(ConfigManager.Config.Preferences.AutomaticallyCheckForUpdates) {
|
||||
UpdateHelper.CheckForUpdates(true);
|
||||
|
|
|
@ -569,11 +569,10 @@ void Renderer::Render()
|
|||
//Draw screen
|
||||
DrawScreen();
|
||||
|
||||
if(paused) {
|
||||
DrawPauseScreen();
|
||||
}
|
||||
|
||||
if(_console->IsRunning()) {
|
||||
if(paused) {
|
||||
DrawPauseScreen();
|
||||
}
|
||||
DrawCounters();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue