Simplify splash screen operation

remove silly idle loop, call close manually

remove initialization check for generating sprite; now only calls at max
2x when starting up = not necessary to bypass with a special variable
This commit is contained in:
Kurt 2019-01-04 22:46:52 -08:00
parent 4dad475fcd
commit 559435e82e
3 changed files with 8 additions and 20 deletions

View file

@ -1774,6 +1774,7 @@ namespace PKHeX.WinForms.Controls
// Loading Setup
public void TemplateFields(ITrainerInfo info)
{
FieldsLoaded = false;
if (CB_GameOrigin.Items.Count > 0)
CB_GameOrigin.SelectedIndex = 0;
CB_Move1.SelectedValue = 1;
@ -1784,6 +1785,8 @@ namespace PKHeX.WinForms.Controls
CB_Species.SelectedValue = RequestSaveFile?.MaxSpeciesID ?? pkm.MaxSpeciesID;
CHK_Nicknamed.Checked = false;
LastData = null;
FieldsLoaded = true;
UpdateSprite();
}
public void EnableDragDrop(DragEventHandler enter, DragEventHandler drop)

View file

@ -25,7 +25,8 @@ namespace PKHeX.WinForms
public Main()
{
new Task(() => new SplashScreen().ShowDialog()).Start();
Form splash = null; // popup a splash screen in another thread
new Task(() => (splash = new SplashScreen()).ShowDialog()).Start();
new Task(() => Legal.RefreshMGDB(MGDatabasePath)).Start();
string[] args = Environment.GetCommandLineArgs();
FormLoadInitialSettings(args, out bool showChangelog, out bool BAKprompt);
@ -43,12 +44,11 @@ namespace PKHeX.WinForms
FormLoadCheckForUpdates();
FormLoadPlugins();
IsInitialized = true; // Splash Screen closes on its own.
PKME_Tabs_UpdatePreviewSprite(null, null);
BringToFront();
WindowState = FormWindowState.Minimized;
Show();
WindowState = FormWindowState.Normal;
splash.Invoke((MethodInvoker)(() => splash.Close())); // splash closes
if (HaX)
{
PKMConverter.AllowIncompatibleConversion = true;
@ -84,7 +84,6 @@ namespace PKHeX.WinForms
public static string[] GenderSymbols { get; private set; } = { "♂", "♀", "-" };
public static bool HaX { get; private set; }
public static bool IsInitialized { get; private set; }
private readonly string[] main_langlist = Enum.GetNames(typeof(ProgramLanguage));
@ -1056,8 +1055,6 @@ namespace PKHeX.WinForms
private void GetPreview(PictureBox pb, PKM pk = null)
{
if (!IsInitialized)
return;
pk = pk ?? PreparePKM(false); // don't perform control loss click
if (pb == dragout) dragout.ContextMenuStrip.Enabled = pk.Species != 0 || HaX; // Species

View file

@ -1,21 +1,9 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms;
namespace PKHeX.WinForms
{
public partial class SplashScreen : Form
{
public SplashScreen()
{
InitializeComponent();
new Task(() =>
{
while (!Main.IsInitialized)
Thread.Sleep(50);
Invoke((MethodInvoker)Close);
}).Start();
}
public SplashScreen() => InitializeComponent();
}
}