예제 #1
0
		private void SetFolder(string folder)
		{
			try
			{
				var gameType = ResourceLoader.DetermineGameType(folder);
				if (gameType == null)
				{
					return;
				}

				if (gameType.Value == GameType.SC && _mainPanel._comboResourceType.Items.Count == 5)
				{
					// Remove scenes
					_mainPanel._comboResourceType.Items.RemoveAt(4);
				} else if (gameType.Value == GameType.FC && _mainPanel._comboResourceType.Items.Count == 4)
				{
					_mainPanel._comboResourceType.Items.Add(new ListItem("Scenes"));
				}

				_mainPanel._textPath.Text = folder;
				_resourceLoader = null;
				if (_executionContext != null)
				{
					_executionContext.MainWorker.TotalPassedPartChanged -= _executionContext_TotalPassedPartChanged;
				}

				_executionContext = null;
				_typeEntries = null;
				if (!string.IsNullOrEmpty(folder))
				{
					_resourceLoader = new ResourceLoader(GraphicsDevice, folder);

					_executionContext = new ExecutionContext(_resourceLoader);
					_executionContext.MainWorker.TotalPassedPartChanged += _executionContext_TotalPassedPartChanged;
				}

				RefreshFiles();
			}
			catch (Exception ex)
			{
				var msg = Dialog.CreateMessageBox("Error", ex.ToString());
				msg.ShowModal(_desktop);
			}
		}
예제 #2
0
		private void OnChangeFolder(object sender, EventArgs e)
		{
			var dlg = new FileDialog(FileDialogMode.ChooseFolder);

			try
			{
				if (!string.IsNullOrEmpty(_mainPanel._textPath.Text))
				{
					dlg.Folder = _mainPanel._textPath.Text;
				}
				else
				{
					var folder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
					dlg.Folder = folder;
				}
			}
			catch (Exception)
			{
			}

			dlg.Closed += (s, a) =>
			{
				if (!dlg.Result)
				{
					return;
				}

				var gameType = ResourceLoader.DetermineGameType(dlg.FilePath);
				if (gameType == null)
				{
					var messageBox = Dialog.CreateMessageBox("Error", "The game isnt supported.");
					messageBox.ShowModal(_desktop);
				}
				else
				{
					SetFolder(dlg.FilePath);
				}
			};

			dlg.ShowModal(_desktop);
		}