migrate functionality from Engine directly into EditorApplication and remove Engine

This commit is contained in:
Michael Becker 2021-07-24 17:13:33 -04:00
parent 5d8c3c7ea6
commit e670a3646e
No known key found for this signature in database
GPG Key ID: 98C333A81F18C22C
14 changed files with 1241 additions and 1306 deletions

View File

@ -28,8 +28,13 @@ using UniversalEditor.UserInterface;
namespace UniversalEditor.Bootstrapper
{
static class Program
public class Program : EditorApplication
{
public Program()
{
ShortName = "universal-editor";
}
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -51,23 +56,7 @@ namespace UniversalEditor.Bootstrapper
return;
}
// why do we do this? because, if the class was static, it tries to load the 'Engine' type
// from another library immediately... if it can't be found, it crashes. this way, if it
// can't be found, we can still catch it since it's loaded on-demand rather than
// immediately.
(new BootstrapperInstance()).Main();
}
private class BootstrapperInstance
{
public void Main()
{
if (!Engine.Execute())
{
MessageDialog.ShowDialog("No engines are available to launch this application.", "Error", MessageDialogButtons.OK, MessageDialogIcon.Error);
return;
}
}
(new Program()).Start();
}
}
}

View File

@ -68,6 +68,10 @@
<Project>{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}</Project>
<Name>MBS.Framework.UserInterface</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="application.xml" />

View File

@ -5,7 +5,7 @@ using UniversalEditor.UserInterface;
namespace UniversalEditor.ConsoleBootstrapper
{
class Program
public class Program : EditorApplication
{
/// <summary>
/// The main entry point for the application.
@ -13,7 +13,8 @@ namespace UniversalEditor.ConsoleBootstrapper
[STAThread]
static void Main()
{
if (!Engine.Execute())
int exitCode = (new Program()).Start();
if (exitCode != 0)
{
ConsoleColor oldcolor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;

View File

@ -63,6 +63,14 @@
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework.UserInterface\Libraries\MBS.Framework.UserInterface\MBS.Framework.UserInterface.csproj">
<Project>{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}</Project>
<Name>MBS.Framework.UserInterface</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -362,7 +362,7 @@ namespace UniversalEditor.UserInterface.Dialogs
{
case DocumentPropertiesDialogMode.Open:
{
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref df, CustomOptionDialogType.Import))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref df, CustomOptionDialogType.Import))
{
return;
}
@ -371,7 +371,7 @@ namespace UniversalEditor.UserInterface.Dialogs
}
case DocumentPropertiesDialogMode.Save:
{
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref df, CustomOptionDialogType.Export))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref df, CustomOptionDialogType.Export))
{
return;
}
@ -420,7 +420,7 @@ namespace UniversalEditor.UserInterface.Dialogs
{
case DocumentPropertiesDialogMode.Open:
{
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref acc, CustomOptionDialogType.Import))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref acc, CustomOptionDialogType.Import))
{
return;
}
@ -429,7 +429,7 @@ namespace UniversalEditor.UserInterface.Dialogs
}
case DocumentPropertiesDialogMode.Save:
{
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref acc, CustomOptionDialogType.Export))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref acc, CustomOptionDialogType.Export))
{
return;
}
@ -491,7 +491,7 @@ namespace UniversalEditor.UserInterface.Dialogs
{
case DocumentPropertiesDialogMode.Open:
{
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref df, CustomOptionDialogType.Import))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref df, CustomOptionDialogType.Import))
{
return;
}
@ -499,7 +499,7 @@ namespace UniversalEditor.UserInterface.Dialogs
}
case DocumentPropertiesDialogMode.Save:
{
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref df, CustomOptionDialogType.Export))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref df, CustomOptionDialogType.Export))
{
return;
}
@ -536,7 +536,7 @@ namespace UniversalEditor.UserInterface.Dialogs
private void cmdDataFormatOptions_Click(object sender, EventArgs e)
{
DataFormat df = DataFormat;
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref df, Mode == DocumentPropertiesDialogMode.Open ? CustomOptionDialogType.Import : CustomOptionDialogType.Export))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref df, Mode == DocumentPropertiesDialogMode.Open ? CustomOptionDialogType.Import : CustomOptionDialogType.Export))
{
return;
}
@ -547,7 +547,7 @@ namespace UniversalEditor.UserInterface.Dialogs
private void cmdAccessorOptions_Click(object sender, EventArgs e)
{
Accessor acc = Accessor;
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref acc, Mode == DocumentPropertiesDialogMode.Open ? CustomOptionDialogType.Import : CustomOptionDialogType.Export))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref acc, Mode == DocumentPropertiesDialogMode.Open ? CustomOptionDialogType.Import : CustomOptionDialogType.Export))
{
return;
}

View File

@ -104,7 +104,7 @@ namespace UniversalEditor.UserInterface.Dialogs
}
Accessor acc = accref.Create ();
Engine.CurrentEngine.ApplyCustomOptions(acc, coll);
((EditorApplication)Application.Instance).ApplyCustomOptions(acc, coll);
Accessor = acc;

View File

@ -20,6 +20,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework;
using MBS.Framework.UserInterface;
using MBS.Framework.UserInterface.Controls;
using MBS.Framework.UserInterface.Controls.ListView;
@ -44,11 +45,11 @@ namespace UniversalEditor.UserInterface.Dialogs
{
base.OnCreated(e);
for (int i = 0; i < Engine.CurrentEngine.BookmarksManager.FileNames.Count; i++)
for (int i = 0; i < ((EditorApplication)Application.Instance).BookmarksManager.FileNames.Count; i++)
{
_FileNames.Add(Engine.CurrentEngine.BookmarksManager.FileNames[i]);
_FileNames.Add(((EditorApplication)Application.Instance).BookmarksManager.FileNames[i]);
string filepath = Engine.CurrentEngine.BookmarksManager.FileNames[i];
string filepath = ((EditorApplication)Application.Instance).BookmarksManager.FileNames[i];
string filetitle = System.IO.Path.GetFileName(filepath);
tm.Rows.Add(new TreeModelRow(new TreeModelRowColumn[]
@ -65,10 +66,10 @@ namespace UniversalEditor.UserInterface.Dialogs
[EventHandler(nameof(cmdOK), "Click")]
private void cmdOK_Click(object sender, EventArgs e)
{
Engine.CurrentEngine.BookmarksManager.FileNames.Clear();
((EditorApplication)Application.Instance).BookmarksManager.FileNames.Clear();
for (int i = 0; i < _FileNames.Count; i++)
{
Engine.CurrentEngine.BookmarksManager.FileNames.Add(_FileNames[i]);
((EditorApplication)Application.Instance).BookmarksManager.FileNames.Add(_FileNames[i]);
}
Close();
}
@ -108,7 +109,7 @@ namespace UniversalEditor.UserInterface.Dialogs
{
int index = e.Row.GetExtraData<int>("index");
Engine.CurrentEngine.LastWindow.OpenFile(Engine.CurrentEngine.BookmarksManager.FileNames[index]);
((EditorApplication)Application.Instance).LastWindow.OpenFile(((EditorApplication)Application.Instance).BookmarksManager.FileNames[index]);
Close();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -717,7 +717,7 @@ namespace UniversalEditor.UserInterface
if (_break)
{
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref df, CustomOptionDialogType.Import))
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref df, CustomOptionDialogType.Import))
break;
}
}
@ -998,8 +998,8 @@ namespace UniversalEditor.UserInterface
protected override void OnClosed(EventArgs e)
{
Engine.CurrentEngine.Windows.Remove(this);
if (Engine.CurrentEngine.Windows.Count <= 0)
((EditorApplication)Application.Instance).Windows.Remove(this);
if (((EditorApplication)Application.Instance).Windows.Count <= 0)
{
Application.Instance.Stop();
}
@ -1012,8 +1012,8 @@ namespace UniversalEditor.UserInterface
new DragDropTarget(DragDropTargetTypes.FileList, DragDropTargetFlags.SameApplication | DragDropTargetFlags.OtherApplication, 0x1)
}, DragDropEffect.Copy, MouseButtons.Primary | MouseButtons.Secondary, KeyboardModifierKey.None);
Engine.CurrentEngine.Windows.Add(this);
Engine.CurrentEngine.LastWindow = this;
((EditorApplication)Application.Instance).Windows.Add(this);
((EditorApplication)Application.Instance).LastWindow = this;
UpdateMenuItems();
}
@ -1021,7 +1021,7 @@ namespace UniversalEditor.UserInterface
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
Engine.CurrentEngine.LastWindow = this;
((EditorApplication)Application.Instance).LastWindow = this;
}
#region IHostApplicationWindow implementation
@ -1122,9 +1122,9 @@ namespace UniversalEditor.UserInterface
{
// FIXME: support Accessors other than FileAccessor
string fileName = (doc.Accessor as FileAccessor).FileName;
if (!Engine.CurrentEngine.RecentFileManager.FileNames.Contains(fileName))
if (!((EditorApplication)Application.Instance).RecentFileManager.FileNames.Contains(fileName))
{
Engine.CurrentEngine.RecentFileManager.FileNames.Add(fileName);
((EditorApplication)Application.Instance).RecentFileManager.FileNames.Add(fileName);
}
}
}

View File

@ -471,7 +471,7 @@ namespace UniversalEditor.UserInterface.Pages
ObjectModel objm = objms[0].Create();
DataFormat fmt = fmts[0].Create();
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref fmt, CustomOptionDialogType.Import)) return;
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref fmt, CustomOptionDialogType.Import)) return;
Document document = new UniversalEditor.Document(objm, fmt, mvarDocument.Accessor);
document.InputAccessor.Open();
@ -497,7 +497,7 @@ namespace UniversalEditor.UserInterface.Pages
ObjectModel objm = mvarDocument.ObjectModel;
DataFormat fmt = mvarDocument.DataFormat;
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref fmt, CustomOptionDialogType.Import)) return;
if (!((EditorApplication)Application.Instance).ShowCustomOptionDialog(ref fmt, CustomOptionDialogType.Import)) return;
Document document = new UniversalEditor.Document(objm, fmt, mvarDocument.Accessor);
document.InputAccessor.Open();

View File

@ -66,7 +66,7 @@ namespace UniversalEditor.UserInterface.Panels
ctHeaderText.Visible = true;
}
foreach (string fileName in Engine.CurrentEngine.RecentFileManager.FileNames)
foreach (string fileName in ((EditorApplication)Application.Instance).RecentFileManager.FileNames)
{
TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[]
{

View File

@ -307,11 +307,11 @@ namespace UniversalEditor.UserInterface.Panels
{
if (file.SourceFileAccessor != null)
{
Engine.CurrentEngine.LastWindow.OpenFile(new Document(file.SourceFileAccessor));
((EditorApplication)Application.Instance).LastWindow.OpenFile(new Document(file.SourceFileAccessor));
}
else
{
Engine.CurrentEngine.LastWindow.OpenFile(file.SourceFileName);
((EditorApplication)Application.Instance).LastWindow.OpenFile(file.SourceFileName);
}
}
else if (folder != null)
@ -389,13 +389,13 @@ namespace UniversalEditor.UserInterface.Panels
private void mnuContextSolutionAddNewProject_Click(object sender, EventArgs e)
{
MainWindow mw = (Engine.CurrentEngine.LastWindow as MainWindow);
MainWindow mw = (((EditorApplication)Application.Instance).LastWindow as MainWindow);
if (mw == null) return;
mw.NewProject(true);
}
private void mnuContextSolutionAddExistingProject_Click(object sender, EventArgs e)
{
MainWindow mw = (Engine.CurrentEngine.LastWindow as MainWindow);
MainWindow mw = (((EditorApplication)Application.Instance).LastWindow as MainWindow);
if (mw == null) return;
ProjectObjectModel proj = mw.ShowOpenProjectDialog();

View File

@ -60,7 +60,6 @@
<Compile Include="ConfigurationManager.cs" />
<Compile Include="CustomOptionDialogType.cs" />
<Compile Include="EditorReference.cs" />
<Compile Include="Engine.cs" />
<Compile Include="Editor.cs" />
<Compile Include="ObjectModelChangingEvent.cs" />
<Compile Include="Perspective.cs" />