Refactored Startup in that MonoGame thingy.
This commit is contained in:
parent
2b67f56e9c
commit
05857b9004
@ -20,6 +20,17 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
SkyscraperHandleCollection handles = new SkyscraperHandleCollection();
|
SkyscraperHandleCollection handles = new SkyscraperHandleCollection();
|
||||||
Queue<string> errors = new Queue<string>();
|
Queue<string> errors = new Queue<string>();
|
||||||
|
|
||||||
|
PerformStartup(localLogger, handles, errors);
|
||||||
|
|
||||||
|
|
||||||
|
SkyscraperGame game = new SkyscraperGame(handles,errors);
|
||||||
|
|
||||||
|
localLogger.Log(PluginLogLevel.Info,"Entering MonoGame loop...");
|
||||||
|
game.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PerformStartup(PluginLogger localLogger, SkyscraperHandleCollection handles, Queue<string> errors)
|
||||||
|
{
|
||||||
localLogger.Log(PluginLogLevel.Info, "Starting up...");
|
localLogger.Log(PluginLogLevel.Info, "Starting up...");
|
||||||
|
|
||||||
//LOAD STORAGE ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
//LOAD STORAGE ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -50,7 +61,8 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
localLogger.Log(PluginLogLevel.Error, "Failed to start the data storage factory: {0}", e.Message);
|
localLogger.Log(PluginLogLevel.Error, "Failed to start the data storage factory: {0}", e.Message);
|
||||||
errors.Enqueue(String.Format("Could not load the data storage factory.\nThe following went wrong:\n\n{0}\n\n", e.Message));
|
errors.Enqueue(String.Format("Could not load the data storage factory.\nThe following went wrong:\n\n{0}\n\n",
|
||||||
|
e.Message));
|
||||||
dataStorageFactory = new InMemoryScraperStorageFactory();
|
dataStorageFactory = new InMemoryScraperStorageFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +75,8 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
localLogger.Log(PluginLogLevel.Error, "Failed to start the object storage factory: {0}", e.Message);
|
localLogger.Log(PluginLogLevel.Error, "Failed to start the object storage factory: {0}", e.Message);
|
||||||
errors.Enqueue(String.Format("Could not load the object storage factory.\nThe following went wrong:\n\n{0}\n\n", e.Message));
|
errors.Enqueue(String.Format("Could not load the object storage factory.\nThe following went wrong:\n\n{0}\n\n",
|
||||||
|
e.Message));
|
||||||
objectStorageFactory = new FilesystemScraperStorageFactory()
|
objectStorageFactory = new FilesystemScraperStorageFactory()
|
||||||
{
|
{
|
||||||
Directory = "dummy_object_storage"
|
Directory = "dummy_object_storage"
|
||||||
@ -93,7 +106,8 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
{
|
{
|
||||||
string objectStorageName = connectionManager.GetName(objectStorageFactory);
|
string objectStorageName = connectionManager.GetName(objectStorageFactory);
|
||||||
localLogger.Log(PluginLogLevel.Error, "Failed to start the object storage factory: {0}", e.Message);
|
localLogger.Log(PluginLogLevel.Error, "Failed to start the object storage factory: {0}", e.Message);
|
||||||
errors.Enqueue(String.Format("Could not load {1}.\nThe following went wrong:\n\n{0}\n\n", e.Message, objectStorageName));
|
errors.Enqueue(String.Format("Could not load {1}.\nThe following went wrong:\n\n{0}\n\n", e.Message,
|
||||||
|
objectStorageName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,11 +181,13 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
TunerFactoryConnectionManager tunerFactoryConnectionManager = TunerFactoryConnectionManager.GetInstance();
|
TunerFactoryConnectionManager tunerFactoryConnectionManager = TunerFactoryConnectionManager.GetInstance();
|
||||||
handles.AllTunerFactories = tunerFactoryConnectionManager.GetKnownFactories();
|
handles.AllTunerFactories = tunerFactoryConnectionManager.GetKnownFactories();
|
||||||
int tunerFactory = handles.Ini.ReadValue("startup", "tunerFactory", 0);
|
int tunerFactory = handles.Ini.ReadValue("startup", "tunerFactory", 0);
|
||||||
KeyValuePair<TunerFactoryIdAttribute, ITunerFactory> bootingTuner = handles.AllTunerFactories.First(x => x.Key.Id == tunerFactory);
|
KeyValuePair<TunerFactoryIdAttribute, ITunerFactory> bootingTuner =
|
||||||
|
handles.AllTunerFactories.First(x => x.Key.Id == tunerFactory);
|
||||||
bool isNoTuner = bootingTuner.Key.DisplayName.Equals("No tuner");
|
bool isNoTuner = bootingTuner.Key.DisplayName.Equals("No tuner");
|
||||||
if (isNoTuner)
|
if (isNoTuner)
|
||||||
{
|
{
|
||||||
errors.Enqueue("Please not that Skyscraper is currently configured to not use a Tuner Factory Class. This will work, but functionality will be severely limited. Please configure a Tuner Factory Class in order to get the best experience.");
|
errors.Enqueue(
|
||||||
|
"Please not that Skyscraper is currently configured to not use a Tuner Factory Class. This will work, but functionality will be severely limited. Please configure a Tuner Factory Class in order to get the best experience.");
|
||||||
}
|
}
|
||||||
|
|
||||||
localLogger.Log(PluginLogLevel.Info, "Applying the tuner factory class configuration..:");
|
localLogger.Log(PluginLogLevel.Info, "Applying the tuner factory class configuration..:");
|
||||||
@ -189,7 +205,8 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
}
|
}
|
||||||
catch (BadImageFormatException e)
|
catch (BadImageFormatException e)
|
||||||
{
|
{
|
||||||
errors.Enqueue("The configured tuner factory is not suitable for the current processor architecture. Tuning won't work, therefore functionality will be severely limited. Please configure a Tuner Factory Class suitable for this processor architecture in order to get the best experience. If you need to run crazycat69's StreamReader.dll on 64-bit machines, try RemoteStreamReader.");
|
errors.Enqueue(
|
||||||
|
"The configured tuner factory is not suitable for the current processor architecture. Tuning won't work, therefore functionality will be severely limited. Please configure a Tuner Factory Class suitable for this processor architecture in order to get the best experience. If you need to run crazycat69's StreamReader.dll on 64-bit machines, try RemoteStreamReader.");
|
||||||
handles.StreamReader = new NullTunerFactory().CreateStreamReader();
|
handles.StreamReader = new NullTunerFactory().CreateStreamReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +220,9 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
if (!checkForDvbExEx)
|
if (!checkForDvbExEx)
|
||||||
{
|
{
|
||||||
if (!isNoTuner)
|
if (!isNoTuner)
|
||||||
localLogger.Log(PluginLogLevel.Error, String.Format("{0} has failed. Tuning won't be possible!", nameof(handles.StreamReader.CheckForDVBExEx)));
|
localLogger.Log(PluginLogLevel.Error,
|
||||||
|
String.Format("{0} has failed. Tuning won't be possible!",
|
||||||
|
nameof(handles.StreamReader.CheckForDVBExEx)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -218,7 +237,6 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (TunerMetadata foundTuner in foundTuners)
|
foreach (TunerMetadata foundTuner in foundTuners)
|
||||||
{
|
{
|
||||||
handles.StreamReader.StopDVB();
|
handles.StreamReader.StopDVB();
|
||||||
@ -257,7 +275,8 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
localLogger.Log(PluginLogLevel.Info, String.Format("Querying storage for configuration of {0}...", foundTuner.Name));
|
localLogger.Log(PluginLogLevel.Info,
|
||||||
|
String.Format("Querying storage for configuration of {0}...", foundTuner.Name));
|
||||||
if (handles.DataStorage.UiTunerTestFor(foundTuner))
|
if (handles.DataStorage.UiTunerTestFor(foundTuner))
|
||||||
{
|
{
|
||||||
handles.DataStorage.UiTunerGetConfiguration(foundTuner);
|
handles.DataStorage.UiTunerGetConfiguration(foundTuner);
|
||||||
@ -288,22 +307,26 @@ namespace skyscraper8.UI.MonoGame
|
|||||||
case QualificationToolResultEnum.Good:
|
case QualificationToolResultEnum.Good:
|
||||||
break;
|
break;
|
||||||
case QualificationToolResultEnum.Bad:
|
case QualificationToolResultEnum.Bad:
|
||||||
errors.Enqueue(String.Format("You are using {0}, Version {1}\nThis version is known to cause issues with skyscraper. You can continue using it, but if it causes issues, you're on your own.", engineProductName, engineVersion));
|
errors.Enqueue(String.Format(
|
||||||
|
"You are using {0}, Version {1}\nThis version is known to cause issues with skyscraper. You can continue using it, but if it causes issues, you're on your own.",
|
||||||
|
engineProductName, engineVersion));
|
||||||
break;
|
break;
|
||||||
case QualificationToolResultEnum.Unknown:
|
case QualificationToolResultEnum.Unknown:
|
||||||
errors.Enqueue(String.Format("You are using {0}, Version {1}\nThis version has not been tested with skyscraper, and might cause some issues. Consider submitting a copy of this version to the author.", engineProductName, engineVersion));
|
errors.Enqueue(String.Format(
|
||||||
|
"You are using {0}, Version {1}\nThis version has not been tested with skyscraper, and might cause some issues. Consider submitting a copy of this version to the author.",
|
||||||
|
engineProductName, engineVersion));
|
||||||
break;
|
break;
|
||||||
case QualificationToolResultEnum.PossibleIssues:
|
case QualificationToolResultEnum.PossibleIssues:
|
||||||
errors.Enqueue(String.Format("You are using {0}, Version {1}\nThis version will work, but might have minor issues in some edge cases.", engineProductName, engineVersion));
|
errors.Enqueue(String.Format(
|
||||||
|
"You are using {0}, Version {1}\nThis version will work, but might have minor issues in some edge cases.",
|
||||||
|
engineProductName, engineVersion));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errors.Enqueue(String.Format("You are using {0}, Version {1}\nThe Qualification said \"{2}\", but this status is not implemented.\n Possibly your skyscraper Version and your testdrid Version mismatch?", engineProductName, engineVersion, qualification.ToString()));
|
errors.Enqueue(String.Format(
|
||||||
|
"You are using {0}, Version {1}\nThe Qualification said \"{2}\", but this status is not implemented.\n Possibly your skyscraper Version and your testdrid Version mismatch?",
|
||||||
|
engineProductName, engineVersion, qualification.ToString()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SkyscraperGame game = new SkyscraperGame(handles,errors);
|
|
||||||
game.Run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user