Example #1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            int result = LegacyLoader.Load(textBoxFile.Text, dropdownCharacters.SelectedIndex);

            switch (result)
            {
            case 0:
                MessageBox.Show("Import successful.", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
                break;

            case 1:
                MessageBox.Show("An error has occurred while importing.", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case 2:
                MessageBox.Show("File does not exist.", "Result", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                break;

            case 3:
                MessageBox.Show("Triggers do not match.\n" +
                                "Triggers must match the Areas generated by the original tool. They are:\n\n" +
                                "intro (3 team dialogues)\nobelisk (2 team dialogues)\n" +
                                "spitblight (2 team dialogues)\nkey1 (1 team dialogue)\nturret (2 team dialogues)\n" +
                                "water (1 team dialogue)\ntreasure (1 team dialogue)\nkey2 (1 team dialogue)\n" +
                                "switches (2 team dialogues)\nbottom (2 team dialogues)\nsawPuzzle (2 team dialogues)\n" +
                                "sawTrap (1 team dialogue)\nfinalIntro (3 team dialogues)\nfinalShield (1 team dialogues)\n\n" +
                                "in that order.",
                                "Result",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                break;
            }
        }
Example #2
0
		static void Main(string[] args)
		{
			string inputFormat = "xml";
			string inputFile = null;
			string outputFile = null;
			bool showHelp = false;
			bool quitOnError = true;

			OptionSet p = new OptionSet()
				.Add("f|input-format=", "the format of the input file {[xml|legacy]}, default: xml",
					delegate(string v) { inputFormat = v.ToLower(); })
				.Add("i|input-file=", "read configuration from {FILE}", delegate(string v) { inputFile = v; })
				.Add("o|output-file=", "write results to {FILE}", delegate(string v) {outputFile = v; })
				.Add("c|continue", "continues when an error occurs", delegate(string v) { quitOnError = v == null; })
				.Add("h|help", "show this help message and exit", delegate(string v) { showHelp = v != null; });

			try
			{
				p.Parse(args);
			}
			catch (OptionException)
			{
				ShowHelp(p);
				return;
			}

			if (showHelp || inputFile == null)
			{
				ShowHelp(p);
				return;
			}

			Loader loader = null;
			switch (inputFormat)
			{
				case "xml":
					loader = new XmlLoader();
					break;

				case "legacy":
					loader = new LegacyLoader();
					break;

				default:
					Console.WriteLine("Invalid input file format specified");
					ShowHelp(p);
					return;
			}

			try
			{
				if (outputFile != null)
					loader.Output = new DefaultOutput(new StreamWriter(new FileStream(outputFile, FileMode.Create), loader.DefaultOutputEncoding));
				else
					loader.Output = new DefaultOutput(Console.Out);

				loader.QuitOnError = quitOnError;

				loader.Load(inputFile);
			}
			catch (IOException ioe)
			{
				Console.WriteLine("IO Error: " + ioe.Message);
			}
			catch (LoadException le)
			{
				Console.WriteLine("Load Error: " + le.Message);
				if (le.InnerException != null)
					Console.WriteLine(le.InnerException.Message);
			}
			catch (MorphException me)
			{
				Console.WriteLine("Morph Error: " + me.Message);
			}

			loader.Output.Close();
		}
Example #3
0
        static void Main(string[] args)
        {
            string inputFormat = "xml";
            string inputFile   = null;
            string outputFile  = null;
            bool   showHelp    = false;
            bool   quitOnError = true;

            OptionSet p = new OptionSet()
                          .Add("f|input-format=", "the format of the input file {[xml|legacy]}, default: xml",
                               delegate(string v) { inputFormat = v.ToLower(); })
                          .Add("i|input-file=", "read configuration from {FILE}", delegate(string v) { inputFile = v; })
                          .Add("o|output-file=", "write results to {FILE}", delegate(string v) { outputFile = v; })
                          .Add("c|continue", "continues when an error occurs", delegate(string v) { quitOnError = v == null; })
                          .Add("h|help", "show this help message and exit", delegate(string v) { showHelp = v != null; });

            try
            {
                p.Parse(args);
            }
            catch (OptionException)
            {
                ShowHelp(p);
                return;
            }

            if (showHelp || inputFile == null)
            {
                ShowHelp(p);
                return;
            }

            Loader loader = null;

            switch (inputFormat)
            {
            case "xml":
                loader = new XmlLoader();
                break;

            case "legacy":
                loader = new LegacyLoader();
                break;

            default:
                Console.WriteLine("Invalid input file format specified");
                ShowHelp(p);
                return;
            }

            try
            {
                if (outputFile != null)
                {
                    loader.Output = new DefaultOutput(new StreamWriter(new FileStream(outputFile, FileMode.Create), loader.DefaultOutputEncoding));
                }
                else
                {
                    loader.Output = new DefaultOutput(Console.Out);
                }

                loader.QuitOnError = quitOnError;

                loader.Load(inputFile);
            }
            catch (IOException ioe)
            {
                Console.WriteLine("IO Error: " + ioe.Message);
            }
            catch (LoadException le)
            {
                Console.WriteLine("Load Error: " + le.Message);
                if (le.InnerException != null)
                {
                    Console.WriteLine(le.InnerException.Message);
                }
            }
            catch (MorphException me)
            {
                Console.WriteLine("Morph Error: " + me.Message);
            }

            loader.Output.Close();
        }