Exemple #1
103
        private void newProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Just start an all new instance. Simple as that.
            modEditor me = new modEditor();

            // Some default values.
            me.genPkgID.Checked = true;
            me.includeModManLine.Checked = true;

            // Show the instance.
            me.Show();
        }
Exemple #2
3
        public bool openProjDir(string dir)
        {
            try
            {
                // Check if the directory exists. Also should contain a package_info.xml.
                if (!Directory.Exists(dir))
                    return false;

                // Start an instance of the mod editor.
                modEditor me = new modEditor();

                if (!File.Exists(dir + "/data.sqlite"))
                {
                    MessageBox.Show("A required database file was not found in your project. It will now be generated.", "Loading Project", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    me.generateSQL(dir);
                }

                me.workingDirectory = dir;
                me.conn = new SQLiteConnection("Data Source=\"" + dir + "/data.sqlite\";Version=3;");
                me.conn.Open();
                me.hasConn = true;

                me.refreshInstructionTree();
                me.refreshExtractionTree();
                me.reloadSettings();

                // Checks.
                if (!me.settings.ContainsKey("modName") || !me.settings.ContainsKey("mbVersion") || !me.settings.ContainsKey("ignoreInstructions") || !me.settings.ContainsKey("autoGenerateModID") || !me.settings.ContainsKey("includeModManLine"))
                {
                    MessageBox.Show("Your project does not include all the required settings. Please try to repair your project and try again.", "Loading Project", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    me.conn.Close();
                    me.Close();
                    return false;
                }

                // Compare the versions
                Version lmver = new Version(Properties.Settings.Default.minMbVersion);
                Version mver = new Version(me.settings["mbVersion"]);
                int status = mver.CompareTo(lmver);

                // If the status is equal to or bigger than 0 we are running the latest version.
                if (status < 0)
                {
                    MessageBox.Show("Your project is generated with an older version of Mod Builder, which used a different format. Please repair your project and try again.", "Loading Project", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    me.conn.Close();
                    me.Close();
                    return false;
                }

                me.modID.Text = me.settings["modID"];
                me.modName.Text = me.settings["modName"];
                me.modType.SelectedItem = me.settings["modType"];
                me.modVersion.Text = me.settings["modVersion"];
                me.authorName.Text = me.settings["modUser"];
                me.modCompatibility.Text = me.settings["modCompat"];
                me.Text = me.settings["modName"] + " - Mod Builder";

                if (me.settings["ignoreInstructions"] == "true")
                    me.ignoreInstructions.Checked = true;

                if (me.settings["autoGenerateModID"] == "true")
                    me.genPkgID.Checked = true;

                if (me.settings["includeModManLine"] == "true")
                    me.includeModManLine.Checked = true;

                // Also load the readme.txt.
                if (File.Exists(dir + "/Package/readme.txt"))
                    me.modReadme.Text = File.ReadAllText(dir + "/Package/readme.txt");

                if (File.Exists(dir + "/Package/install.php"))
                    me.customCodeInstall.Text = File.ReadAllText(dir + "/Package/install.php");

                if (File.Exists(dir + "/Package/uninstall.php"))
                    me.customCodeUninstall.Text = File.ReadAllText(dir + "/Package/uninstall.php");

                if (File.Exists(dir + "/Package/installDatabase.php"))
                    me.installDatabaseCode.Text = File.ReadAllText(dir + "/Package/installDatabase.php");

                if (File.Exists(dir + "/Package/uninstallDatabase.php"))
                    me.uninstallDatabaseCode.Text = File.ReadAllText(dir + "/Package/uninstallDatabase.php");

                me.Show();

                // Log this to the recent projects file.

                return true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return false;
            }
        }
        // Loads and sets up the environment.
        public addInstruction(string workingDirectory, SQLiteConnection conn, int editing, modEditor mode)
        {
            // Start the form.
            InitializeComponent();

            // Set the working directory.
            wD = workingDirectory;

            // And set the SQLite connection.
            co = conn;

            // ModEditor form
            me = mode;

            // Are we editing anything?
            if (editing != 0)
            {
                // Yes we are... Set up the query.
                string sql = "SELECT before, after, type, file, optional FROM instructions WHERE id = " + editing + " LIMIT 1";

                // Execute it.
                SQLiteCommand command = new SQLiteCommand(sql, co);
                SQLiteDataReader reader = command.ExecuteReader();

                // And read and insert the data.
                while (reader.Read())
                {
                    before.Text = (string) reader["before"];
                    after.Text = (string) reader["after"];

                    char[] chars = { '/' };
                    string[] pieces = reader["file"].ToString().Split(chars, 2);
                    filePrefix.SelectedItem = pieces[0];
                    fileEdited.Text = pieces[1];

                    // Gather and set the method.
                    switch ((string) reader["type"])
                    {
                        case "add_before":
                            method.SelectedItem = "Add before";
                            break;

                        case "add_after":
                            method.SelectedItem = "Add after";
                            break;

                        case "end":
                            method.SelectedItem = "At the end of file";
                            break;

                        default:
                            method.SelectedItem = "Replace";
                            break;
                    }

                    // Check for an optional operation.
                    if (Convert.ToInt32(reader["optional"]) == 1)
                        optionalCheck.Checked = true;
                }
                this.editing = editing;
            }
        }
Exemple #4
0
        private void repairAProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CommonOpenFileDialog fb = new CommonOpenFileDialog();
            fb.IsFolderPicker = true;
            fb.Title = "Please select the directory that your project resides in.";
            fb.EnsurePathExists = true;
            CommonFileDialogResult rs = fb.ShowDialog();

            if (rs == CommonFileDialogResult.Cancel)
                return;

            // Get the path.
            string dir = fb.FileName;

            // Check if it is empty or if the user clicked Cancel.
            if (string.IsNullOrEmpty(dir) || !Directory.Exists(dir))
                return;

            // Check if it is a valid project.
            if (!Directory.Exists(dir + "/Package") || !File.Exists(dir + "/data.sqlite"))
            {
                MessageBox.Show("The selected project is not a valid project.", "Repairing Mod Builder project", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Ask if the user wants to generate a new database, or to just add the tables.
            DialogResult result = MessageBox.Show("Should the existing database be truncated? Answering no will instead try to add all missing data.", "Reparing project", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Cancel)
                return;

            // New instance of the mod editor.
            modEditor me = new modEditor();

            // Fiddle with the database.
            me.generateSQL(dir, (result == DialogResult.Yes), ModParser.parsePackageInfo(dir + "/Package/package-info.xml"));

            // Do /Source and /Package exist?
            if (!Directory.Exists(dir + "/Source"))
                Directory.CreateDirectory(dir + "/Source");
            if (!Directory.Exists(dir + "/Package"))
                Directory.CreateDirectory(dir + "/Package");

            // Ask if the user wants to load the project.
            result = MessageBox.Show("Your project has been repaired. Do you want to load the project now?", "Project repaired", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            // Yes? Load the project.
            if (result == DialogResult.Yes)
                PackageWorker.bootstrapLoad(dir);
                /*
            {
                // Show a loadProject dialog.
                loadProject lp = new loadProject();
                lp.Show();

                // Load the project.
                bool stat = lp.openProjDir(dir);

                // Check the status.
                if (stat == false)
                    MessageBox.Show("An error occured while loading the project.", "Loading project", MessageBoxButtons.OK, MessageBoxIcon.Error);

                // Close the loadProject dialog.
                lp.Close();
            }*/
        }
Exemple #5
0
        private void openNewProject(object sender, EventArgs e)
        {
            // Start a new instance of the Mod Editor.
            modEditor me = new modEditor();

            // Some default values.
            me.genPkgID.Checked = true;
            me.includeModManLine.Checked = true;

            me.authorName.Text = Properties.Settings.Default.idUsername;

            // Show the instance.
            me.Show();
        }