If we run our initialization inside the splash it works on GTK

This commit is contained in:
Michael Becker 2019-07-21 00:13:35 -04:00
parent 62fafe4d4c
commit 249a9f7825
2 changed files with 68 additions and 49 deletions

View File

@ -38,7 +38,7 @@ namespace UniversalEditor.UserInterface
splasher.Show();
// }
}
private void HideSplashScreen()
protected internal void HideSplashScreen()
{
while (splasher == null)
{
@ -704,7 +704,7 @@ namespace UniversalEditor.UserInterface
}
// FIXME: this is the single XML configuration file loader that should be executed at the beginning of engine launch
protected virtual void InitializeXMLConfiguration()
protected internal virtual void InitializeXMLConfiguration()
{
#region Load the XML files
string configurationFileNameFilter = System.Configuration.ConfigurationManager.AppSettings["UniversalEditor.Configuration.ConfigurationFileNameFilter"];
@ -1312,7 +1312,7 @@ namespace UniversalEditor.UserInterface
private Perspective.PerspectiveCollection mvarPerspectives = new Perspective.PerspectiveCollection();
public Perspective.PerspectiveCollection Perspectives { get { return mvarPerspectives; } }
protected virtual void UpdateSplashScreenStatus(string message, int progressValue = -1, int progressMinimum = 0, int progressMaximum = 100)
protected internal virtual void UpdateSplashScreenStatus(string message, int progressValue = -1, int progressMinimum = 0, int progressMaximum = 100)
{
// most of this is relic from when we had to workaround WinForms
// threading issues; these threading issues should be
@ -1339,56 +1339,11 @@ namespace UniversalEditor.UserInterface
private void Initialize()
{
ShowSplashScreen();
Application.ShortName = "mbs-editor";
// Application.Title = "Universal Editor";
// Initialize the XML files before anything else, since this also loads string tables needed
// to display the application title
InitializeXMLConfiguration();
System.Threading.Thread threadLoader = new System.Threading.Thread(threadLoader_ThreadStart);
threadLoader.Name = "Initialization Thread";
threadLoader.Start();
while (threadLoader.ThreadState == System.Threading.ThreadState.Running)
{
System.Threading.Thread.Sleep (500);
}
}
protected virtual void InitializeInternal()
{
UpdateSplashScreenStatus("Loading object models...");
UniversalEditor.Common.Reflection.GetAvailableObjectModels();
UpdateSplashScreenStatus("Loading data formats...");
UniversalEditor.Common.Reflection.GetAvailableDataFormats();
// Initialize Recent File Manager
mvarRecentFileManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "RecentItems.xml";
mvarRecentFileManager.Load();
// Initialize Bookmarks Manager
mvarBookmarksManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Bookmarks.xml";
mvarBookmarksManager.Load();
// Initialize Session Manager
mvarSessionManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Sessions.xml";
mvarSessionManager.Load();
}
private void threadLoader_ThreadStart()
{
/*
if (Configuration.SplashScreen.Enabled)
{
while (splasher == null) System.Threading.Thread.Sleep(500);
}
*/
InitializeInternal();
HideSplashScreen();
}
private bool mvarRunning = false;
public bool Running { get { return mvarRunning; } }

View File

@ -19,8 +19,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework.Drawing;
using UniversalWidgetToolkit;
using UniversalWidgetToolkit.Controls;
using UniversalWidgetToolkit.Drawing;
using UniversalWidgetToolkit.Layouts;
namespace UniversalEditor.UserInterface
{
@ -28,13 +31,74 @@ namespace UniversalEditor.UserInterface
{
public SplashScreenWindow()
{
this.Decorated = false;
this.Layout = new BoxLayout(Orientation.Vertical);
this.Size = new Dimension2D(300, 300);
Image image = new Image();
image.IconName = "universal-editor";
image.IconSize = new Dimension2D(128, 128);
Label lbl = new Label("Universal Editor");
lbl.Attributes.Add("scale", 1.4);
this.Controls.Add(image, new BoxLayout.Constraints(true, true));
// this.Controls.Add(lbl, new BoxLayout.Constraints(true, true));
}
protected override void OnCreated(EventArgs e)
{
Application.DoEvents();
// less do this
Application.ShortName = "mbs-editor";
// Application.Title = "Universal Editor";
// Initialize the XML files before anything else, since this also loads string tables needed
// to display the application title
Engine.CurrentEngine.InitializeXMLConfiguration();
System.Threading.Thread threadLoader = new System.Threading.Thread(threadLoader_ThreadStart);
threadLoader.Name = "Initialization Thread";
threadLoader.Start();
}
public void SetStatus(string message, int progressValue, int progressMinimum, int progressMaximum)
{
}
private void threadLoader_ThreadStart()
{
Application.DoEvents();
/*
if (Configuration.SplashScreen.Enabled)
{
while (splasher == null) System.Threading.Thread.Sleep(500);
}
*/
Engine.CurrentEngine.UpdateSplashScreenStatus("Loading object models...");
UniversalEditor.Common.Reflection.GetAvailableObjectModels();
Engine.CurrentEngine.UpdateSplashScreenStatus("Loading data formats...");
UniversalEditor.Common.Reflection.GetAvailableDataFormats();
// Initialize Recent File Manager
Engine.CurrentEngine.RecentFileManager.DataFileName = Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "RecentItems.xml";
Engine.CurrentEngine.RecentFileManager.Load();
// Initialize Bookmarks Manager
Engine.CurrentEngine.BookmarksManager.DataFileName = Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Bookmarks.xml";
Engine.CurrentEngine.BookmarksManager.Load();
// Initialize Session Manager
Engine.CurrentEngine.SessionManager.DataFileName = Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Sessions.xml";
Engine.CurrentEngine.SessionManager.Load();
Engine.CurrentEngine.HideSplashScreen();
}
}
public class SplashScreenSettings
{