コード例 #1
0
        private void ItemListBox1_SelectedItemChanged()
        {
            ButtonItem   btnItem = (ButtonItem)ItemListBox1.SelectedItem;
            PatchProfile patch   = (PatchProfile)btnItem.Tag;

            LoadTweak(patch);
        }
コード例 #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);
     }
 }
コード例 #3
0
        private void LoadScriptsList(PatchProfile patch)
        {
            ComboBoxEx_Scripts.Items.Clear();

            foreach (PatchScript script in patch.Scripts)
            {
                var item = new ComboItem();
                if (!string.IsNullOrEmpty(script.Name))
                {
                    item.Text = script.Name;
                }
                else
                {
                    item.Text = "Untitled";
                }

                item.Tag = script;
                ComboBoxEx_Scripts.Items.Add(item);
            }

            if (ComboBoxEx_Scripts.Items.Count > 0)
            {
                ComboBoxEx_Scripts.SelectedIndex = 0;
            }

            Panel1.Refresh();
        }
コード例 #4
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);
        }
コード例 #5
0
 private void SaveSinglePatch(PatchProfile patch)
 {
     if (patch is object)
     {
         var profmgr = new PatchingManager();
         profmgr.Save(patch, Path.Combine(General.MyDataPath, "Tweaks"));
     }
 }
コード例 #6
0
        private ButtonItem GetButtonItemFromPatch(PatchProfile patch)
        {
            var btnItem = new ButtonItem()
            {
                Text      = patch.Name,
                Tag       = patch,
                ForeColor = GetTweakColor(patch)
            };

            btnItem.MouseUp += ItemListBox1_ItemMouseClick;
            return(btnItem);
        }
コード例 #7
0
        private void ButtonX5_Click(object sender, EventArgs e)
        {
            ButtonItem   btnItem = (ButtonItem)ItemListBox1.SelectedItem;
            PatchProfile patch   = (PatchProfile)btnItem?.Tag;

            if (patch is object && MessageBoxEx.Show(this, "Are you sure to remove this tweak? You will not be able to recover it.", "Remove Tweak", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Flyout1.Close();
                ItemListBox1.Items.Remove(btnItem);
                ItemListBox1.Refresh();
                myPatchs.Remove(patch);
                File.Delete(patch.FileName);
            }
        }
コード例 #8
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;
        }
コード例 #9
0
        private void ButtonX2_Click(object sender, EventArgs e)
        {
            PatchProfile patch = (PatchProfile)((ButtonItem)ItemListBox1.SelectedItem)?.Tag;

            // Close Flyout
            Flyout1.Close();

            // Edit the Patch
            EditPatch(patch);

            // Save Patch
            SaveSinglePatch(patch);

            // Update Tweak Infos
            ItemListBox1_SelectedItemChanged();
        }
コード例 #10
0
        private Color GetTweakColor(PatchProfile patch)
        {
            switch (true)
            {
            case object _ when patch.FileName.StartsWith(Path.Combine(General.MyTweaksPath, dbmgr.Preferences.CategoryPaths[TweakDatabaseCategories.Reviewed])):
                return(default);

            case object _ when patch.FileName.StartsWith(Path.Combine(General.MyTweaksPath, dbmgr.Preferences.CategoryPaths[TweakDatabaseCategories.Experimental])):
                return(Color.Orange);

            case object _ when patch.FileName.StartsWith(Path.Combine(General.MyTweaksPath, dbmgr.Preferences.CategoryPaths[TweakDatabaseCategories.Uploads])):
                return(Color.OrangeRed);

            default:
                return(Color.DarkViolet);
            }
        }
コード例 #11
0
        private void LoadTweak(PatchProfile patch)
        {
            LabelX_PatchName.Text = patch.Name;
            labelX_Version.Text   = $"Version {patch.Version}";

            if (!string.IsNullOrEmpty(LabelX_Description.Text))
            {
                LabelX_Description.Text = patch.Description;
                SuperTooltip1.SetSuperTooltip(LabelX_Description, new SuperTooltipInfo("", "", patch.Description, null, null, eTooltipColor.Default, false, false, default));
            }
            else
            {
                LabelX_Description.Text = "(No description available.)";
                SuperTooltip1.SetSuperTooltip(LabelX_Description, null);
            }

            LoadScriptsList(patch);
        }
コード例 #12
0
        public bool PatchProfileId(int profileId, JsonPatchDocument <PatchProfile> patchProfile)
        {
            Profile profile = GetProfileId(profileId);

            if (profile != null)
            {
                PatchProfile _patchProfile = new PatchProfile
                {
                    Friends           = profile.Friends,
                    ProfilePictureUrl = profile.ProfilePictureUrl
                };
                patchProfile.ApplyTo(_patchProfile);
                profile.Friends           = _patchProfile.Friends;
                profile.ProfilePictureUrl = _patchProfile.ProfilePictureUrl;
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #13
0
        private void EditPatch(PatchProfile patch)
        {
            var editor = new TweakProfileEditor()
            {
                Titel         = patch.Name,
                Description   = patch.Description,
                Version       = patch.Version,
                MinAppVersion = patch.MinVersion,
                MaxAppVersion = patch.MaxVersion
            };

            if (editor.ShowDialog(this) == DialogResult.OK)
            {
                string oldName        = patch.Name;
                string oldDescription = patch.Description;

                patch.Name        = editor.Titel.Trim();
                patch.Description = editor.Description.Trim();
                patch.Version     = editor.Version;
                patch.MinVersion  = editor.MinAppVersion;
                patch.MaxVersion  = editor.MaxAppVersion;

                if ((oldName ?? "") != (patch.Name ?? ""))
                {
                    //// Rename File
                    //string newFileName = Path.Combine(Path.GetDirectoryName(patch.FileName), editor.Titel + Path.GetExtension(patch.FileName));
                    //newFileName = EnsureFileNameIsNotUsed(newFileName);
                    //File.Move(patch.FileName, newFileName);
                    //patch.FileName = newFileName;

                    // Update Title in ListBox
                    ItemListBox1.SelectedItem.Text = patch.Name;
                    ItemListBox1.Refresh();
                }
            }
        }