Beispiel #1
0
		private void btnReset_Click(object sender, EventArgs e)
		{
			this.SuspendLayout();
			this.Controls.Clear();
			this.ResumeLayout();
			this.InitializeComponent();
			this.InitializeMore();
			eif = null;
		}
Beispiel #2
0
		private bool _tryLoadItems(string fileName = null)
		{
			try
			{
				m_items = string.IsNullOrEmpty(fileName) ? new ItemFile() : new ItemFile(fileName);
			}
			catch
			{
				m_items = null;
				return false;
			}

			return true;
		}
Beispiel #3
0
		private static void Main(string[] args)
		{
			if (args.Length != 3)
			{
				Console.WriteLine("Usage: BatchMap.exe <srcmap|srcdir> <dstmap|dstdir> <pubdir>");
				return;
			}

			string srcFilePath = args[0];
			string dstFilePath = args[1];
			string pubFilePath = args[2];
			bool singleFileProcess = false;

			if (srcFilePath.ToLower().EndsWith(".emf") && !dstFilePath.ToLower().EndsWith(".emf"))
			{
				Console.WriteLine("Invalid: single map cannot be processed into output directory. Specify destination emf file.");
				return;
			}
			
			if (dstFilePath.ToLower().EndsWith(".emf") && !srcFilePath.ToLower().EndsWith(".emf"))
			{
				Console.WriteLine("Invalid: map directory cannot be processed into single output map. Specify destination output directory.");
				return;
			}

			if (srcFilePath.ToLower().EndsWith(".emf") && dstFilePath.ToLower().EndsWith(".emf"))
			{
				singleFileProcess = true;
				if (!File.Exists(srcFilePath))
				{
					Console.WriteLine("Invalid input: input file does not exist!");
					return;
				}

				if (File.Exists(dstFilePath))
				{
					char inp;
					do
					{
						Console.Write("Destination file exists. Overwrite? [y/n] ");
						string input = Console.ReadLine() ?? "";
						inp = input.Length > 0 ? input[0] : ' ';
					} while (inp != 'y' && inp != 'n' && inp != 'Y' && inp != 'N');

					if (inp == 'n' || inp == 'N')
					{
						Console.WriteLine("Will not overwrite existing file. Exiting.");
						return;
					}
				}
			}
			else
			{
				if (!Directory.Exists(srcFilePath) || Directory.GetFiles(srcFilePath, "*.emf").Length == 0)
				{
					Console.WriteLine("Invalid input: source directory does not exist or is missing maps!");
					return;
				}

				if (Directory.Exists(dstFilePath) && Directory.GetFiles(dstFilePath, "*.emf").Length > 0)
				{
					char inp;
					do
					{
						Console.WriteLine("Destination directory contains emf files. Overwrite? [y/n] ");
						string input = Console.ReadLine() ?? "";
						inp = input.Length > 0 ? input[0] : ' ';
					} while (inp != 'y' && inp != 'n' && inp != 'Y' && inp != 'N');

					if (inp == 'n' || inp == 'N')
					{
						Console.WriteLine("Will not overwrite existing files. Exiting.");
						return;
					}
				}
				else if (!Directory.Exists(dstFilePath))
				{
					Directory.CreateDirectory(dstFilePath);
				}
			}

			try
			{
				EIF = new ItemFile(Path.Combine(pubFilePath, "dat001.eif"));
				ENF = new NPCFile(Path.Combine(pubFilePath, "dtn001.enf"));
			}
			catch
			{
				Console.WriteLine("Error loading pub files!");
				return;
			}

			ProcessFiles(srcFilePath, dstFilePath, singleFileProcess);
		}
Beispiel #4
0
		private void btnLoad_Click(object sender, EventArgs e)
		{
			string fname = "";
			try
			{
				eif = new ItemFile(fname = (string.IsNullOrEmpty(txtFileName.Text) ? EOLib.Constants.ItemFilePath : txtFileName.Text));
				lblFileName.Text = "Loaded file: " + fname;
				grpStepTwo.Enabled = true;
				btnReset.Enabled = true;
			}
			catch(Exception ex)
			{
				eif = null;
				MessageBox.Show("Error loading " + fname + ":\n" + ex.Message, "Error!");
				return;
			}
		}
		private static bool _isPubValid(InitFileType fileType)
		{
			try
			{
				EODataFile file;
				switch (fileType)
				{
					case InitFileType.Item:
						file = new ItemFile();
						break;
					case InitFileType.Npc:
						file = new NPCFile();
						break;
					case InitFileType.Spell:
						file = new SpellFile();
						break;
					case InitFileType.Class:
						file = new ClassFile();
						break;
					default:
						return false;
				}

				if (file.Data.Count <= 1) return false;
			}
			catch
			{
				return false;
			}

			return true;
		}