Refactored Startup in that MonoGame thingy.

This commit is contained in:
feyris-tan 2025-08-12 22:13:09 +02:00
parent 2b67f56e9c
commit 05857b9004

View File

@ -20,6 +20,17 @@ namespace skyscraper8.UI.MonoGame
SkyscraperHandleCollection handles = new SkyscraperHandleCollection();
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...");
//LOAD STORAGE ----------------------------------------------------------------------------------------------------------------------------------------------------------
@ -50,7 +61,8 @@ namespace skyscraper8.UI.MonoGame
catch (Exception e)
{
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();
}
@ -63,7 +75,8 @@ namespace skyscraper8.UI.MonoGame
catch (Exception e)
{
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()
{
Directory = "dummy_object_storage"
@ -93,7 +106,8 @@ namespace skyscraper8.UI.MonoGame
{
string objectStorageName = connectionManager.GetName(objectStorageFactory);
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();
handles.AllTunerFactories = tunerFactoryConnectionManager.GetKnownFactories();
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");
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..:");
@ -189,7 +205,8 @@ namespace skyscraper8.UI.MonoGame
}
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();
}
@ -203,7 +220,9 @@ namespace skyscraper8.UI.MonoGame
if (!checkForDvbExEx)
{
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)
@ -218,7 +237,6 @@ namespace skyscraper8.UI.MonoGame
}
foreach (TunerMetadata foundTuner in foundTuners)
{
handles.StreamReader.StopDVB();
@ -257,7 +275,8 @@ namespace skyscraper8.UI.MonoGame
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))
{
handles.DataStorage.UiTunerGetConfiguration(foundTuner);
@ -288,22 +307,26 @@ namespace skyscraper8.UI.MonoGame
case QualificationToolResultEnum.Good:
break;
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;
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;
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;
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;
}
SkyscraperGame game = new SkyscraperGame(handles,errors);
game.Run();
}
}
}