Exemplo n.º 1
0
        private void AddNewPatch(string name, string description, Version version, Version minAppVersion, Version maxAppVersion, string firstScriptName)
        {
            var patch = new PatchProfile()
            {
                Name        = name,
                Description = description,
                Version     = version,
                MinVersion  = minAppVersion,
                MaxVersion  = maxAppVersion
            };

            patch.ID.Generate();
            var script = new PatchScript()
            {
                Name = firstScriptName
            };

            script.ID.Generate();
            patch.Scripts.Add(script);
            var btnItem = GetButtonItemFromPatch(patch);

            ItemListBox1.Items.Add(btnItem);
            SaveSinglePatch(patch);
            ItemListBox1.SelectedItem = btnItem;
            ItemListBox1.Refresh();
            ItemListBox1.EnsureVisible(btnItem);
        }
Exemplo n.º 2
0
 internal static void PatchScript(IWin32Window owner, PatchScript script, PatchProfile profile, SM64Lib.RomManager rommgr)
 {
     try
     {
         TweakBeforeApply?.Invoke();
         var mgr = new PatchingManager();
         mgr.Patch(
             script,
             rommgr,
             owner,
             new Dictionary <string, object>()
         {
             { "romfile", rommgr.RomFile },
             { "rommgr", rommgr },
             { "profilepath", profile?.FileName },
             { "files", profile.EmbeddedFiles },
             { "owner", owner }
         },
             General.GetAdditionalReferencedAssemblied());
         TweakAfterApply?.Invoke();
         MessageBoxEx.Show(owner, "Patched successfully.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception)
     {
         TweakFailedApply?.Invoke();
         MessageBoxEx.Show(owner, "Error while executing the script. It probably contains errors.", "Script Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
        // F e a t u r e s

        private void CopyScript(PatchScript source, PatchScript dest)
        {
            dest.Description = source.Description;
            dest.Name        = source.Name;
            dest.Script      = source.Script;
            dest.Type        = source.Type;
            dest.References.Clear();
            foreach (string @ref in source.References)
            {
                dest.References.Add(@ref);
            }
        }
Exemplo n.º 4
0
        private void ComboBoxEx_Scripts_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboItem item      = (ComboItem)ComboBoxEx_Scripts.SelectedItem;
            bool      isNotNull = item is object;

            ButtonX8.Enabled = isNotNull;
            ButtonX4.Enabled = isNotNull;
            ButtonX6.Enabled = isNotNull;
            if (isNotNull)
            {
                PatchScript script = (PatchScript)item.Tag;
                LoadScript(script);
            }
        }
Exemplo n.º 5
0
        private void AddNewScript(string name, PatchProfile patch)
        {
            var script = new PatchScript();

            script.ID.Generate();
            script.Name = name;
            patch.Scripts.Add(script);
            var comboItem = new ComboItem();

            comboItem.Text = script.Name;
            comboItem.Tag  = script;
            ComboBoxEx_Scripts.Items.Add(comboItem);
            ComboBoxEx_Scripts.SelectedItem = comboItem;
        }
Exemplo n.º 6
0
        private void EditScript(ref PatchScript script, ImporterProfile profile)
        {
            if (script is null)
            {
                script = new PatchScript();
            }
            var editor = new PatchScripts.TweakScriptEditor(script, rommgr, profile.EmbeddedFiles);

            if (editor.ShowDialog(this) == DialogResult.OK)
            {
                if (editor.NeedToSave)
                {
                    SaveProfile(SelectedProfile());
                }
            }
        }
Exemplo n.º 7
0
        private void ButtonItem_ExportToFile_Click(object sender, EventArgs e)
        {
            var isMultiselect = IsMultiselect();
            CommonFileDialog sfd_SM64RM_ExportCustomObjectToFile;
            var tbxName      = new CommonFileDialogTextBox("rmobj.name", customObject.Name);
            var btnAddScript = new CommonFileDialogButton("rmobj.script", "Setup Script")
            {
                IsProminent = true
            };

            btnAddScript.Click  += BtnAddScript_Click;
            export_EmbeddedFiles = new EmbeddedFilesContainer();
            export_Script        = new PatchScript();

            if (isMultiselect && MessageBoxEx.Show(this, "You are going to export multiple custom objects. Do you want to save all objects to one single file (Yes) or do you want to save every single object to one file (No)?", "Export Custom Objects", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                sfd_SM64RM_ExportCustomObjectToFile = new CommonOpenFileDialog()
                {
                    IsFolderPicker = true
                }
            }
            ;
            else
            {
                isMultiselect = false;
                sfd_SM64RM_ExportCustomObjectToFile = new CommonSaveFileDialog()
                {
                    DefaultExtension = FILTER_CUSTOM_OBJECT_EXTENSIONS
                };
                sfd_SM64RM_ExportCustomObjectToFile.Filters.Add(new CommonFileDialogFilter(FILTER_CUSTOM_OBJECT_NAMES, FILTER_CUSTOM_OBJECT_EXTENSIONS));
            }

            sfd_SM64RM_ExportCustomObjectToFile.Controls.Add(tbxName);
            sfd_SM64RM_ExportCustomObjectToFile.Controls.Add(btnAddScript);

            if (sfd_SM64RM_ExportCustomObjectToFile.ShowDialog(Handle) == CommonFileDialogResult.Ok)
            {
                ExportObjects(sfd_SM64RM_ExportCustomObjectToFile.FileName, isMultiselect, tbxName.Text);
            }
        }
Exemplo n.º 8
0
        public TweakScriptEditor(PatchScript script, RomManager rommgr, EmbeddedFilesContainer filesContainer)
        {
            this.filesContainer = filesContainer;

            // G u i
            base.Load        += TweakScriptEditor_Load;
            base.FormClosing += TweakScriptEditor_FormClosing;
            this.rommgr       = rommgr;
            this.script       = script;

            // Create Temp Script
            CopyScript(script, tempScript);
            SuspendLayout();
            InitializeComponent();
            CodeEditor             = new FastColoredTextBox();
            CodeEditor.Language    = Language.Custom;
            CodeEditor.Dock        = DockStyle.Fill;
            CodeEditor.BorderStyle = BorderStyle.FixedSingle;
            Panel2.Controls.Add(CodeEditor);
            LayoutControlItem4.Visible = false;
            layoutControlItem5.Visible = false;
            base.UpdateAmbientColors();
            ResumeLayout(false);
        }
Exemplo n.º 9
0
        // C o n s t r u c t o r s

        public TweakScriptEditor(PatchScript script, RomManager rommgr) : this(script, rommgr, null)
        {
        }
Exemplo n.º 10
0
 private void LoadScript(PatchScript script)
 {
     SuperTooltip1.SetSuperTooltip(new ComboItem(), new SuperTooltipInfo(script.Name, "", script.Description, null, null, eTooltipColor.Default, false, false, default));
 }