예제 #1
0
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OptionsForm options = new OptionsForm();

            options.ShowDialog();
        }
예제 #2
0
        /// <summary>
        /// Runs the actual map in the emulator
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void runMap_Click(object sender, EventArgs e)
        {
            // Get path of the executable
            String appDir = Path.GetDirectoryName(Application.ExecutablePath);

            // Export actual view to .\level\StartLevel.map
            MapManagerBinary MapManager = new MapManagerBinary();
            MapForm          activeForm = (MapForm)this.ActiveMdiChild;

            if (activeForm == null)
            {
                return;
            }
            Directory.CreateDirectory(appDir + "\\level");
            MapManager.Save(appDir + "\\level\\StartLevel.map", activeForm.Map, tilesetToolbox.TileControl.Tilesets);


            // Run zip program to add level-data to .jar archive
            try
            {
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.EnableRaisingEvents              = false;
                proc.StartInfo.WorkingDirectory       = appDir;
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.FileName       = "zip.exe";
                proc.StartInfo.Arguments      = "-r prototype.jar level";
                proc.StartInfo.CreateNoWindow = true;
                proc.Start();
                proc.WaitForExit();
            }
            catch (Exception ex)
            {
                string message = "I am not able to find a compression tool in your program folder." + System.Environment.NewLine;
                message += "Verify that you have zip.exe in your programfolder!";
                message += System.Environment.NewLine + ex.Message;
                MessageBox.Show(message, "We have a Problem:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            if (!File.Exists(appDir + "\\prototype.jar"))
            {
                MessageBox.Show("Error while compiling the map.", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create .jad-file with correct size of .jar-file
            FileInfo f       = new FileInfo(appDir + "\\prototype.jar");
            string   strText = "MIDlet-1: javy prototype, , GameMIDlet\nMIDlet-Jar-Size: " + f.Length;

            strText += "\nMIDlet-Jar-URL: prototype.jar\nMIDlet-Name: GameMIDlet\nMIDlet-Vendor: Midlet Suite Vendor\n";
            strText += "MIDlet-Version: 1.0.0\nMicroEdition-Configuration: CLDC-1.1\nMicroEdition-Profile: MIDP-2.0";
            File.WriteAllText(appDir + "\\prototype.jad", strText);

            // Finally run the emulater from the wtk directory
            try
            {
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc = new System.Diagnostics.Process();
                proc.EnableRaisingEvents        = false;
                proc.StartInfo.WorkingDirectory = appDir;
                proc.StartInfo.UseShellExecute  = false;
                proc.StartInfo.CreateNoWindow   = true;
                proc.StartInfo.FileName         = Javy.Properties.Settings.Default.wtkDirectory +
                                                  "\\bin\\emulator.exe";
                proc.StartInfo.Arguments = "-Xdescriptor \"" + appDir + "\\prototype.jad\"";
                proc.Start();
            }
            catch (Exception ex)
            {
                string message = "I can't find the emulator of the Java WTK!" + System.Environment.NewLine;
                message += "Verify that you have setup the correct path for the WTK25 in your Leveleditor.exe.config file.";
                message += System.Environment.NewLine + ex.Message;
                MessageBox.Show(message, "We have a Problem:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                OptionsForm options = new OptionsForm();
                options.ShowDialog();
            }
        }