TRGameInfo.cs

 avatar
ujangxhy
plain_text
10 months ago
2.5 kB
13
Indexable
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Text;

namespace TRTR;

internal static class TRGameInfo
{
	internal static class Worker
	{
		public static DoWorkEventHandler WorkerStart = null;

		public static ProgressChangedEventHandler ProgressChanged = null;

		public static RunWorkerCompletedEventHandler RunWorkerCompleted = null;

		public static CultureInfo CurrentCulture = null;
	}

	private static object changeLock = new object();

	private static TRGameStatus gameStatus = TRGameStatus.None;

	private static List<string> processors = new List<string>();

	private static GameInstance game = null;

	private static BigFilePool filePool = null;

	private static BigFileList bigFiles = null;

	internal static TextConv Conv = new TextConv(new char[4] { 'Ő', 'ő', 'Ű', 'ű' }, new char[4] { 'Ô', 'ô', 'Û', 'û' }, Encoding.UTF8);

	internal static TRGameStatus GameStatus => gameStatus;

	internal static List<string> Processors => processors;

	internal static GameInstance Game
	{
		get
		{
			return game;
		}
		set
		{
			game = value;
		}
	}

	internal static BigFilePool FilePool => filePool;

	internal static BigFileList BigFiles => bigFiles;

	internal static FileLocale TransTextLang => FileLocale.English;

	internal static FileLocale TransVoiceLang { get; set; }

	internal static void Load(GameInstance game)
	{
		Game = game;
		Log.LogDebugMsg("Loading game...");
		gameStatus = game.Load();
		Log.LogDebugMsg("Game loaded.");
		Log.LogDebugMsg("Parsing files...");
		bigFiles = new BigFileList(game.InstallFolder);
		Log.LogDebugMsg("Parsing files finished.");
		if (filePool != null)
		{
			filePool.CloseAll();
		}
		filePool = new BigFilePool(bigFiles);
		Log.LogDebugMsg("Load OK.");
	}

	internal static void LoadAsync(GameInstance game)
	{
		BackgroundWorker backgroundWorker = new BackgroundWorker();
		backgroundWorker.WorkerReportsProgress = true;
		BackgroundWorker backgroundWorker2 = backgroundWorker;
		backgroundWorker2.DoWork += workerLoad_DoWork;
		backgroundWorker2.ProgressChanged += Worker.ProgressChanged;
		backgroundWorker2.RunWorkerCompleted += Worker.RunWorkerCompleted;
		backgroundWorker2.RunWorkerAsync(game);
	}

	private static void workerLoad_DoWork(object sender, DoWorkEventArgs e)
	{
		Load((GameInstance)e.Argument);
	}

	internal static void CreateRestorationPoint()
	{
	}
}
Editor is loading...
Leave a Comment