Esempio n. 1
0
        void addMod(ModInfo modInfo)
        {
            ModPanel mp = new ModPanel();

            mp.modInfo = modInfo;
            addModPanel(mp, ModsDisabledSP);
        }
Esempio n. 2
0
        private void ddMovePanel(ModPanel mod, StackPanel modlist, Point mousepos)
        {
            for (int i = 0; i < modlist.Children.Count; i++)
            {
                double height = ((FrameworkElement)(modlist.Children[i])).ActualHeight;

                if (mousepos.Y < modlist.Children[i].TranslatePoint(new Point(0, 0), this).Y)
                {
                    // Move Up
                    modlist.Children.Remove(mod);
                    if (i > 0)
                    {
                        modlist.Children.Insert(i - 1, mod);
                    }
                    else
                    {
                        modlist.Children.Insert(0, mod);
                    }
                    return;
                }
                else if (mousepos.Y < modlist.Children[i].TranslatePoint(new Point(0, 0), this).Y)
                {
                    // Move Down
                    modlist.Children.Remove(mod);
                    modlist.Children.Insert(i + 1, mod);
                    return;
                }
            }
        }
Esempio n. 3
0
        private void ddSpDropDisabled(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(ModType.Runtime.ToString()) || e.Data.GetDataPresent(ModType.AheadOfTime.ToString()))
            {
                ModPanel mod = null;
                if (e.Data.GetDataPresent(ModType.Runtime.ToString()))
                {
                    mod = (ModPanel)e.Data.GetData(ModType.Runtime.ToString());
                }
                else if (e.Data.GetDataPresent(ModType.AheadOfTime.ToString()))
                {
                    mod = (ModPanel)e.Data.GetData(ModType.AheadOfTime.ToString());
                }

                if (mod == null)
                {
                    return;
                }

                StackPanel modlist   = (StackPanel)mod.Parent;
                CheckBox   togglemod = (CheckBox)((DockPanel)(mod.Children[1])).Children[0];
                togglemod.IsChecked = false;

                if (ModsDisabledSP.Children.Contains(mod))
                {
                    ddMovePanel(mod, modlist, e.GetPosition(this));
                }
                else
                {
                    modlist.Children.Remove(mod);
                    ModsDisabledSP.Children.Add(mod);
                    ddMovePanel(mod, ModsDisabledSP, e.GetPosition(this));
                }
            }
        }
Esempio n. 4
0
        public void modToggleVisibility(object sender, RoutedEventArgs e)
        {
            CheckBox   chkbox = (CheckBox)sender;
            DockPanel  mdp    = (DockPanel)chkbox.Parent;
            ModPanel   mp     = (ModPanel)mdp.Parent;
            StackPanel sp     = (StackPanel)mp.Parent;

            if (chkbox.IsChecked == true)
            {
                //Enabling a mod

                //Remove from disabled stackpanel
                sp.Children.Remove(mp);

                if (mp.modInfo.type == ModType.Runtime)
                {
                    ModsInjectedSP.Children.Add(mp);
                    ModsInjectedDP.Visibility = Visibility.Visible;
                }
                else
                {
                    ModsPatchedSP.Children.Add(mp);
                }
            }
            else
            {
                //Disabling a mod


                //Remove from enabled stackpanel
                sp.Children.Remove(mp);

                ModsDisabledSP.Children.Add(mp);
            }
        }
Esempio n. 5
0
            private static void Target(ModPanel panel, IModGroup group, int groupIdx, int optionIdx)
            {
                // TODO drag options to other groups without options.
                using var target = ImRaii.DragDropTarget();
                if (!target.Success || !ImGuiUtil.IsDropping(DragDropLabel))
                {
                    return;
                }

                if (_dragDropGroupIdx >= 0 && _dragDropOptionIdx >= 0)
                {
                    if (_dragDropGroupIdx == groupIdx)
                    {
                        var sourceOption = _dragDropOptionIdx;
                        panel._delayedActions.Enqueue(() => Penumbra.ModManager.MoveOption(panel._mod, groupIdx, sourceOption, optionIdx));
                    }
                    else
                    {
                        // Move from one group to another by deleting, then adding the option.
                        var sourceGroup  = _dragDropGroupIdx;
                        var sourceOption = _dragDropOptionIdx;
                        var option       = @group[_dragDropOptionIdx];
                        var priority     = @group.OptionPriority(_dragDropGroupIdx);
                        panel._delayedActions.Enqueue(() =>
                        {
                            Penumbra.ModManager.DeleteOption(panel._mod, sourceGroup, sourceOption);
                            Penumbra.ModManager.AddOption(panel._mod, groupIdx, option, priority);
                        });
                    }
                }

                _dragDropGroupIdx  = -1;
                _dragDropOptionIdx = -1;
            }
Esempio n. 6
0
        public void modMouseUp(object sender, MouseEventArgs e)
        {
            ModPanel mod = (ModPanel)(sender);

            if (mod.isDragged == true)
            {
                Vector diff = mod.originDrag - e.GetPosition(null);
                if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                    Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
                {
                    //
                    // A drag drop has happened. Don't expand.
                    //
                }
                else
                {
                    toggleCollapsed(sender);
                }


                //TODO: Drag/Drop
                //https://social.msdn.microsoft.com/Forums/vstudio/en-US/d32bb0af-b14f-4e88-ad36-098d11cd375c/dragdrop-elements-within-a-stack-panel?forum=wpf
            }
            else
            {
                toggleCollapsed(sender);
            }
        }
Esempio n. 7
0
        public void modMouseDown(object sender, MouseEventArgs e)
        {
            //TODO: Implement drag/drop
            ModPanel mod = (ModPanel)(sender);

            mod.originMove = mod.PointToScreen(new Point(0, 0));
            mod.originDrag = e.GetPosition(null);
        }
Esempio n. 8
0
        private void ddPanelDrop(object sender, DragEventArgs e)
        {
            ModPanel   mod     = (ModPanel)(sender);
            StackPanel modList = (StackPanel)(mod.Parent);

            modList.RaiseEvent(e);
            e.Handled = true;
        }
Esempio n. 9
0
 private void ddDpDropPatched(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(ModType.AheadOfTime.ToString()))
     {
         ModPanel mod       = (ModPanel)e.Data.GetData(ModType.AheadOfTime.ToString());
         CheckBox togglemod = (CheckBox)((DockPanel)(mod.Children[1])).Children[0];
         togglemod.IsChecked = true;
         StackPanel modlist = (StackPanel)mod.Parent;
         modlist.Children.Remove(mod);
         ModsPatchedSP.Children.Insert(0, mod);
     }
 }
Esempio n. 10
0
            private IEnumerator StartModRoutine(ModPanel mod, float timeInSeconds)
            {
                mod.StartPressed();
                yield return(new WaitForSeconds(0.2f));

                while (!mod.IsFinished)
                {
                    yield return(null);
                }
                yield return(new WaitForSeconds(timeInSeconds));

                mod.ResetPressed();
                yield return(mod.CheckStartAvailable());
            }
Esempio n. 11
0
        public void createModPanel(string dir, string name, string desc, string imageDir,
                                   List <string> authors, List <string> contact, DateTime lastUpdated, ulong fileSize, ModType type)
        {
            ModPanel mpone = new ModPanel();

            mpone.modInfo.dir             = dir;
            mpone.modInfo.name            = name;
            mpone.modInfo.longDescription = desc;
            mpone.modInfo.authors         = authors;
            mpone.modInfo.contact         = contact;
            mpone.modInfo.lastUpdated     = lastUpdated;
            mpone.modInfo.fileSize        = fileSize;
            mpone.modInfo.type            = type;
            mpone.modInfo.icon            = imageDir;
            addModPanel(mpone, ModsDisabledSP);
        }
Esempio n. 12
0
        public void modMouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                ModPanel mod = ((ModPanel)(sender));
                mod.isDragged = true;

                Vector diff = mod.originDrag - e.GetPosition(null);

                if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                    Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
                {
                    DataObject dragData = new DataObject();
                    dragData.SetData(mod.modInfo.type.ToString(), mod);

                    DragDrop.DoDragDrop(this, dragData, DragDropEffects.Move);
                }
            }
        }
Esempio n. 13
0
            void Awake()
            {
                if (instance == null)
                {
                    instance = this;
                }
                else
                {
                    Destroy(this);
                }

                totalResults = new List <TotalData>();
                testPanels   = new List <GamePanel>();
                modPanels    = new List <ModPanel>();
                float offset = 0;

                foreach (Test t in tests)
                {
                    GameObject    p   = Instantiate(testPanelPrefab, testPanelParent.transform);
                    RectTransform rt  = p.GetComponent <RectTransform>();
                    Vector3       pos = rt.localPosition;
                    pos.y           += offset;
                    rt.localPosition = pos;
                    offset          -= rt.rect.height;
                    GamePanel panel = p.GetComponent <GamePanel>();
                    panel.Init(t.testObject, t.testName);
                    testPanels.Add(panel);
                }
                offset = 0;
                foreach (GameObject m in modifiers)
                {
                    GameObject    p   = Instantiate(m, modPanelParent.transform);
                    RectTransform rt  = p.GetComponent <RectTransform>();
                    Vector3       pos = rt.localPosition;
                    pos.y           += offset;
                    rt.localPosition = pos;
                    offset          -= rt.rect.height;
                    ModPanel panel = p.GetComponent <ModPanel>();
                    modPanels.Add(panel);
                }
            }
Esempio n. 14
0
        private void ddSpDropInjected(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(ModType.Runtime.ToString()))
            {
                ModPanel   mod       = (ModPanel)e.Data.GetData(ModType.Runtime.ToString());
                StackPanel modlist   = (StackPanel)mod.Parent;
                CheckBox   togglemod = (CheckBox)((DockPanel)(mod.Children[1])).Children[0];
                togglemod.IsChecked = true;

                if (ModsInjectedSP.Children.Contains(mod))
                {
                    ddMovePanel(mod, modlist, e.GetPosition(this));
                }
                else
                {
                    modlist.Children.Remove(mod);
                    ModsInjectedSP.Children.Add(mod);
                    ddMovePanel(mod, ModsInjectedSP, e.GetPosition(this));
                }
            }
        }
Esempio n. 15
0
            public static void Draw(ModPanel panel, int groupIdx)
            {
                using var table = ImRaii.Table(string.Empty, 4, ImGuiTableFlags.SizingFixedFit);
                if (!table)
                {
                    return;
                }

                ImGui.TableSetupColumn("idx", ImGuiTableColumnFlags.WidthFixed, 60 * ImGuiHelpers.GlobalScale);
                ImGui.TableSetupColumn("name", ImGuiTableColumnFlags.WidthFixed,
                                       panel._window._inputTextWidth.X - 62 * ImGuiHelpers.GlobalScale);
                ImGui.TableSetupColumn("delete", ImGuiTableColumnFlags.WidthFixed, panel._window._iconButtonSize.X);
                ImGui.TableSetupColumn("priority", ImGuiTableColumnFlags.WidthFixed, 50 * ImGuiHelpers.GlobalScale);

                var group = panel._mod.Groups[groupIdx];

                for (var optionIdx = 0; optionIdx < group.Count; ++optionIdx)
                {
                    EditOption(panel, group, groupIdx, optionIdx);
                }

                DrawNewOption(panel._mod, groupIdx, panel._window._iconButtonSize);
            }
Esempio n. 16
0
            // Draw a line for a single option.
            private static void EditOption(ModPanel panel, IModGroup group, int groupIdx, int optionIdx)
            {
                var option = group[optionIdx];

                using var id = ImRaii.PushId(optionIdx);
                ImGui.TableNextColumn();
                ImGui.AlignTextToFramePadding();
                ImGui.Selectable($"Option #{optionIdx + 1}");
                Source(group, groupIdx, optionIdx);
                Target(panel, group, groupIdx, optionIdx);

                ImGui.TableNextColumn();
                if (Input.Text("##Name", groupIdx, optionIdx, option.Name, out var newOptionName, 256, -1))
                {
                    Penumbra.ModManager.RenameOption(panel._mod, groupIdx, optionIdx, newOptionName);
                }

                ImGui.TableNextColumn();
                if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), panel._window._iconButtonSize,
                                                 "Delete this option.\nHold Control while clicking to delete.", !ImGui.GetIO().KeyCtrl, true))
                {
                    panel._delayedActions.Enqueue(() => Penumbra.ModManager.DeleteOption(panel._mod, groupIdx, optionIdx));
                }

                ImGui.TableNextColumn();
                if (group.Type == SelectType.Multi)
                {
                    if (Input.Priority("##Priority", groupIdx, optionIdx, group.OptionPriority(optionIdx), out var priority,
                                       50 * ImGuiHelpers.GlobalScale))
                    {
                        Penumbra.ModManager.ChangeOptionPriority(panel._mod, groupIdx, optionIdx, priority);
                    }

                    ImGuiUtil.HoverTooltip("Option priority.");
                }
            }
Esempio n. 17
0
        public void toggleCollapsed(object sender)
        {
            ModPanel  mod           = (ModPanel)(sender);
            Grid      detailGrid    = (Grid)(mod.Children[2]);
            DockPanel mainDock      = (DockPanel)(mod.Children[1]);
            Image     dropDownImage = (Image)(mainDock.Children[2]);


            if (detailGrid.Visibility == Visibility.Visible)
            {
                detailGrid.Visibility = Visibility.Collapsed;
                Transform scaleTransform = new ScaleTransform(1.0, 1.0);

                dropDownImage.RenderTransform = scaleTransform;
            }
            else
            {
                detailGrid.Visibility = Visibility.Visible;
                Transform scaleTransform = new ScaleTransform(1.0, -1.0);
                dropDownImage.RenderTransformOrigin = new Point(0, 0.5);

                dropDownImage.RenderTransform = scaleTransform;
            }
        }
Esempio n. 18
0
 public TabInstalled(SettingsInterface ui)
 {
     _base    = ui;
     Selector = new Selector(_base);
     ModPanel = new ModPanel(_base, Selector);
 }
Esempio n. 19
0
 public TabInstalled(SettingsInterface ui, HashSet <string> newMods)
 {
     Selector    = new Selector(ui, newMods);
     ModPanel    = new ModPanel(ui, Selector, newMods);
     _modManager = Service <ModManager> .Get();
 }
Esempio n. 20
0
        public void Awake()
        {
            Debug.Log("SavedGames - Original by morris1927");
            //Singleton used for hacky crap :)
            if (instance == null)
            {
                instance = this;
            }
            else
            {
                Destroy(this);
            }

            loadKey = Config.Wrap <int>(
                "Keybinds", "LoadKey", null,
                (int)KeyCode.F5);
            saveKey = Config.Wrap <int>(
                "Keybinds", "SaveKey", null,
                (int)KeyCode.F8);

            //Register our Commands
            On.RoR2.Console.Awake += (orig, self) => {
                Generic.CommandHelper.RegisterCommands(self);
                orig(self);
            };


            //Stop the scene loading objects so we can load our own
            On.RoR2.SceneDirector.PopulateScene += (orig, self) => {
                if (!loadingScene)
                {
                    orig(self);
                }
                loadingScene = false;
            };

            //Removing targetGraphic null error
            On.RoR2.UI.CustomButtonTransition.DoStateTransition += (orig, self, state, instant) => {
                if (self.targetGraphic != null)
                {
                    orig(self, state, instant);
                }
            };

            //Removing targetGraphic null error
            On.RoR2.UI.CustomScrollbar.DoStateTransition += (orig, self, state, instant) => {
                if (self.targetGraphic != null)
                {
                    orig(self, state, instant);
                }
            };

            //Setup "Load Game" Main Menu button and loading menu
            On.RoR2.UI.MainMenu.MainMenuController.Start += (orig, self) => {
                ModButton button          = new ModButton("Load Game");
                Transform buttonTransform = button.gameObject.transform;
                buttonTransform.SetParent(self.titleMenuScreen.transform.GetChild(2).transform);
                buttonTransform.SetSiblingIndex(1);

                Color32 c = button.baseImage.color;
                c.a = 73;
                button.baseImage.color = c;

                button.rectTransform.localScale = Vector3.one;
                button.rectTransform.sizeDelta  = new Vector2(320, 48);
                button.buttonSkinController.useRecommendedAlignment = false;
                button.tmpText.alignment = TextAlignmentOptions.Left;
                button.tmpText.rectTransform.sizeDelta = new Vector2(-24, -8);

                GameObject    submenuPrefab = new GameObject("Load Game");
                GameObject    scaledSpace   = new GameObject("Scaled Space");
                RectTransform scaledRect    = scaledSpace.AddComponent <RectTransform>();
                scaledRect.anchorMin = new Vector2(0.05f, 0.05f);
                scaledRect.anchorMax = new Vector2(0.95f, 0.95f);
                scaledRect.offsetMax = new Vector2(0, 0);
                scaledRect.offsetMin = new Vector2(0, 0);

                scaledSpace.transform.SetParent(submenuPrefab.transform);

                ModPanel topPanel = new ModPanel();
                topPanel.gameObject.transform.SetParent(scaledSpace.transform);
                topPanel.rectTransform.anchorMin = new Vector2(0, 1);
                topPanel.rectTransform.anchorMax = new Vector2(1, 1);

                topPanel.rectTransform.sizeDelta = new Vector2(0, 96);
                topPanel.rectTransform.pivot     = new Vector2(0.5f, 1);

                ModButton backButton = new ModButton("Back");
                backButton.gameObject.transform.SetParent(scaledSpace.transform);
                backButton.customButtonTransition.onClick.AddListener(delegate() { self.SetDesiredMenuScreen(self.titleMenuScreen); });

                //ModButton loadButton = new ModButton("Load");
                //loadButton.gameObject.transform.SetParent(scaledSpace.transform);
                //loadButton.customButtonTransition.onClick.AddListener(delegate () { });

                ModSubMenu saveMenu = new ModSubMenu("Load Menu", self, submenuPrefab);
                submenuPrefab.transform.SetParent(saveMenu.subMenuObject.transform);

                ModScrollBar sb = new ModScrollBar();
                sb.gameObject.transform.SetParent(scaledSpace.transform);

                submenuPrefab.SetActive(false);

                GameObject contentObject = new GameObject("Content");
                contentObject.transform.SetParent(sb.viewportObject.transform);
                contentObject.AddComponent <CanvasRenderer>();

                instance.StartCoroutine(SetupUI(delegate() {
                    backButton.rectTransform.anchoredPosition = new Vector2(0, 0);
                    backButton.rectTransform.anchorMin        = new Vector2(0, 0);
                    backButton.rectTransform.anchorMax        = new Vector2(0, 0);
                    backButton.rectTransform.sizeDelta        = new Vector2(200, 50);
                    backButton.rectTransform.pivot            = new Vector2(0, 0);

                    //loadButton.rectTransform.anchorMin = new Vector2(1, 0);
                    //loadButton.rectTransform.anchorMax = new Vector2(1, 0);
                    //loadButton.rectTransform.sizeDelta = new Vector2(200, 50);
                    //loadButton.rectTransform.pivot = new Vector2(1, 0);



                    RectTransform contentRect = contentObject.AddComponent <RectTransform>();
                    contentRect.sizeDelta     = new Vector2(100, 300);


                    sb.scrollRect.content        = contentRect;
                    sb.customScrollbar.direction = Scrollbar.Direction.BottomToTop;
                    sb.scrollRect.movementType   = ScrollRect.MovementType.Clamped;

                    sb.rectTransform.anchorMin        = new Vector2(0, 0);
                    sb.rectTransform.anchorMax        = new Vector2(1, 1);
                    sb.rectTransform.sizeDelta        = new Vector2(-60, -200);
                    sb.rectTransform.anchoredPosition = new Vector2(0, 0);

                    sb.gameObject.GetComponent <Image>().color  = new Color32(16, 16, 16, 150);
                    sb.gameObject.GetComponent <Image>().sprite = Generic.FindResource <Sprite>("texUIHighlightHeader");
                    sb.gameObject.GetComponent <Image>().color  = new Color32(14, 14, 14, 150);
                    sb.gameObject.GetComponent <Image>().type   = Image.Type.Sliced;

                    sb.customScrollbar.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
                    sb.customScrollbar.GetComponent <RectTransform>().anchorMax = new Vector2(1, 1);
                    sb.customScrollbar.GetComponent <RectTransform>().sizeDelta = new Vector2(20, 0);

                    sb.handleAreaObject.GetComponent <RectTransform>().anchorMin = new Vector2(1, 0);
                    sb.handleAreaObject.GetComponent <RectTransform>().anchorMax = new Vector2(1, 1);
                    sb.handleAreaObject.GetComponent <RectTransform>().sizeDelta = new Vector2(10, 0);
                    sb.handleAreaObject.GetComponent <RectTransform>().pivot     = new Vector2(0, 1);
                    sb.handleAreaObject.GetComponent <Image>().sprite            = Generic.FindResource <Sprite>("texUICleanButton");
                    sb.handleAreaObject.GetComponent <Image>().color             = new Color32(44, 44, 44, 150);
                    sb.handleAreaObject.GetComponent <Image>().type = Image.Type.Sliced;

                    sb.handleObject.GetComponent <RectTransform>().sizeDelta = new Vector2(20, 0);
                    sb.handleObject.GetComponent <Image>().sprite            = Generic.FindResource <Sprite>("texUICleanButton");
                    sb.handleObject.GetComponent <Image>().type = Image.Type.Sliced;

                    sb.handleOutlineObject.GetComponent <Image>().enabled = false;

                    sb.viewportObject.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
                    sb.viewportObject.GetComponent <RectTransform>().anchorMax = new Vector2(1, 1);
                    sb.viewportObject.GetComponent <RectTransform>().sizeDelta = new Vector2(0, 0);

                    contentObject.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
                    contentObject.GetComponent <RectTransform>().anchorMax = new Vector2(1, 1);
                    contentObject.GetComponent <RectTransform>().pivot     = new Vector2(1, 1);
                    contentObject.GetComponent <RectTransform>().sizeDelta = new Vector2(0, 0);


                    VerticalLayoutGroup contentLayoutGroup = contentObject.AddComponent <VerticalLayoutGroup>();
                    ContentSizeFitter contentSizeFitter    = contentObject.AddComponent <ContentSizeFitter>();

                    contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.MinSize;

                    if (Directory.Exists(directory))
                    {
                        foreach (var file in Directory.GetFiles(directory))
                        {
                            FileStream saveFile = File.Open(file, FileMode.Open);
                            string fileName     = saveFile.Name.Replace(directory, "")
                                                  .Replace(".json", "");
                            ModButton fileSelectButton = new ModButton(fileName);
                            fileSelectButton.customButtonTransition.onClick.AddListener(delegate() {
                                RoR2.Console.instance.SubmitCmd(null, $"load {fileName}");
                            });
                            fileSelectButton.gameObject.GetComponent <LayoutElement>().minHeight = 200;
                            fileSelectButton.gameObject.transform.SetParent(contentObject.transform);

                            saveFile.Close();
                        }
                    }
                }));


                button.customButtonTransition.onClick.AddListener(delegate() {
                    self.SetDesiredMenuScreen(saveMenu.submenuMainMenuScreen);
                    submenuPrefab.SetActive(true);
                });

                orig(self);
            };

            //Add save button to pause screen
            On.RoR2.UI.PauseScreenController.Awake += (orig, self) => {
                ModButton  button       = new ModButton("Save");
                GameObject buttonObject = button.gameObject;
                buttonObject.transform.SetParent(self.mainPanel.GetChild(0));
                buttonObject.transform.SetSiblingIndex(1);
                buttonObject.GetComponent <RectTransform>().localScale = Vector3.one;
                buttonObject.GetComponent <RectTransform>().sizeDelta  = new Vector2(320, 48);

                ModInputField inputField  = new ModInputField();
                GameObject    inputObject = inputField.gameObject;

                inputObject.transform.SetParent(self.mainPanel.GetChild(0));
                inputObject.transform.SetSiblingIndex(1);

                RectTransform inputRect = inputField.rectTransform;
                inputRect.sizeDelta  = new Vector2(320, 48);
                inputRect.localScale = new Vector3(1, 1, 1);

                CustomButtonTransition buttonEvents = buttonObject.GetComponent <CustomButtonTransition>();

                buttonEvents.onClick.AddListener(() => { RoR2.Console.instance.SubmitCmd(null, $"save {inputField.tmpInputField.text}"); });

                orig(self);
            };
        }
Esempio n. 21
0
        void addModPanel(ModPanel mod, StackPanel destination)
        {
            Brush fontColour = (Brush)(this.FindResource("FontColour"));

            Brush backgroundColour = (Brush)(this.FindResource("ColourBackground"));
            Brush midgroundColour  = (Brush)(this.FindResource("ColourMidground"));
            Brush foregroundColour = (Brush)(this.FindResource("ColourForeground"));

            Brush placeholderBackground = (Brush)(this.FindResource("ColourForeground"));

            ControlTemplate buttonTemplate = (ControlTemplate)(this.FindResource("StandardButton"));

            //Brush debug = (Brush)(this.FindResource("placeholderBackground"));

            double fontSize = 18.0f;

            //Without this, where there's nothing the click even goes to the background StackPanel
            //Rather than this dockpanel.
            mod.Background = midgroundColour;


            Canvas header = new Canvas();

            header.Background = midgroundColour;
            header.Height     = 2;
            DockPanel.SetDock(header, Dock.Top);
            mod.Children.Add(header);

            //Non expanded form
            DockPanel mainDock = new DockPanel();

            DockPanel.SetDock(mainDock, Dock.Top);
            mainDock.Margin = new Thickness(0, 2, 0, 0);
            mainDock.HorizontalAlignment = HorizontalAlignment.Stretch;
            mainDock.Background          = midgroundColour;

            CheckBox  modChecked = new CheckBox();
            TextBlock modName    = new TextBlock();
            Image     dropDown   = new Image();

            modChecked.VerticalAlignment     = VerticalAlignment.Center;
            modChecked.RenderTransformOrigin = new Point(0, 0.5);
            modChecked.Margin = new Thickness(0, 0, 10, 0);

            Transform scaleTransform = new ScaleTransform(1.5, 1.5);

            modChecked.RenderTransform = scaleTransform;

            modChecked.Click     += new RoutedEventHandler(this.modToggleVisibility);
            modChecked.Checked   += new RoutedEventHandler(this.modEnable);
            modChecked.Unchecked += new RoutedEventHandler(this.modDisable);

            modName.Text = mod.modInfo.name;
            DockPanel.SetDock(modName, Dock.Left);
            modName.Foreground = fontColour;

            dropDown.Source = new BitmapImage(new Uri(@"pack://application:,,,/GUI/Resources/DropDown.png"));
            dropDown.Width  = 24;
            dropDown.HorizontalAlignment = HorizontalAlignment.Right;
            dropDown.Margin = new Thickness(0, 0, 5, 0);
            DockPanel.SetDock(dropDown, Dock.Right);

            // Let me be real with you chief, there is no reason why this SHOULD be here
            // But without it being here, the f*****g image breaks the second the window
            // is streched to the right
            // When it breaks is influenced by the image's size.
            // I dont know WHY it breaks There's f*****g nothing on stack overflow about this shit,
            // so I'll just Keep this here as a work around.

            // Also this was found completely on accident. Lucky me, Fixed a bug accidentally.
            // TODO: Why the f**k does this work?
            dropDown.OpacityMask = placeholderBackground;

            mainDock.Children.Add(modChecked);
            mainDock.Children.Add(modName);
            mainDock.Children.Add(dropDown);


            //These controls will only be visible whilst in expanded form.
            #region Collapsable
            Grid elementGrid = new Grid();
            elementGrid.Background = midgroundColour;

            ColumnDefinition leftColumn = new ColumnDefinition();

            ColumnDefinition rightColumn = new ColumnDefinition();
            rightColumn.Width = new GridLength(100);

            elementGrid.ColumnDefinitions.Add(leftColumn);
            elementGrid.ColumnDefinitions.Add(rightColumn);

            StackPanel infoDock = new StackPanel();
            DockPanel.SetDock(infoDock, Dock.Left);
            infoDock.Background = midgroundColour;

            int leftPanelWidth = 115;

            DockPanel _description    = new DockPanel();
            TextBlock _descriptionKey = new TextBlock();
            _descriptionKey.Text  = "Description: ";
            _descriptionKey.Width = leftPanelWidth;
            TextBlock _descriptionValue = new TextBlock();
            _descriptionValue.Text         = mod.modInfo.longDescription;
            _descriptionValue.TextWrapping = TextWrapping.Wrap;
            _description.Children.Add(_descriptionKey);
            _description.Children.Add(_descriptionValue);

            DockPanel _type    = new DockPanel();
            TextBlock _typeKey = new TextBlock();
            _typeKey.Text  = "Type : ";
            _typeKey.Width = leftPanelWidth;
            TextBlock _typeValue = new TextBlock();
            switch (mod.modInfo.type)
            {
            case ModType.AheadOfTime:
                _typeValue.Text = "Ahead of Time";
                break;

            case ModType.Runtime:
                _typeValue.Text = "Runtime";
                break;

            default:
                _typeValue.Text = "Invalid Type";
                break;
            }
            _typeValue.TextWrapping = TextWrapping.Wrap;
            _type.Children.Add(_typeKey);
            _type.Children.Add(_typeValue);

            DockPanel _authors   = new DockPanel();
            TextBlock _authorKey = new TextBlock();
            _authorKey.Text  = "Authors : ";
            _authorKey.Width = leftPanelWidth;
            TextBlock _authorValue = new TextBlock();

            string authors = "";

            for (int i = 0; i < mod.modInfo.authors.Count; i++)
            {
                if (i != 0)
                {
                    // If there's a line break, dont put the comma.
                    // I - 1 should never be out of bounds, I=0 is skipped.
                    if (!(mod.modInfo.authors[i - 1].Last() == '\n' || mod.modInfo.authors[i - 1].Last() == '\r'))
                    {
                        authors += ", ";
                    }
                }
                authors += mod.modInfo.authors[i];
            }

            _authorValue.Text         = authors;
            _authorValue.TextWrapping = TextWrapping.Wrap;
            _authors.Children.Add(_authorKey);
            _authors.Children.Add(_authorValue);

            DockPanel _lastUpdated    = new DockPanel();
            TextBlock _lastUpdatedKey = new TextBlock();
            _lastUpdatedKey.Text  = "Last Updated: ";
            _lastUpdatedKey.Width = leftPanelWidth;
            TextBlock _lastUpdatedValue = new TextBlock();
            //TODO: Format time
            _lastUpdatedValue.Text         = mod.modInfo.lastUpdated.ToString();
            _lastUpdatedValue.TextWrapping = TextWrapping.Wrap;
            _lastUpdated.Children.Add(_lastUpdatedKey);
            _lastUpdated.Children.Add(_lastUpdatedValue);

            DockPanel _modSize    = new DockPanel();
            TextBlock _modSizeKey = new TextBlock();
            _modSizeKey.Text  = "Mod Size: ";
            _modSizeKey.Width = leftPanelWidth;
            TextBlock _modSizeValue = new TextBlock();
            //TODO: Convert bytes to KB, MB, etc
            _modSizeValue.Text         = mod.modInfo.fileSize.ToString() + " bytes";
            _modSizeValue.TextWrapping = TextWrapping.Wrap;
            _modSize.Children.Add(_modSizeKey);
            _modSize.Children.Add(_modSizeValue);

            DockPanel _status    = new DockPanel();
            TextBlock _statusKey = new TextBlock();
            _statusKey.Text  = "Description: ";
            _statusKey.Width = leftPanelWidth;
            TextBlock _statusValue = new TextBlock();
            _statusValue.Text         = mod.modInfo.longDescription;
            _statusValue.TextWrapping = TextWrapping.Wrap;
            _status.Children.Add(_statusKey);
            _status.Children.Add(_statusValue);

            infoDock.Children.Add(_description);
            infoDock.Children.Add(_type);
            infoDock.Children.Add(_authors);
            infoDock.Children.Add(_lastUpdated);
            infoDock.Children.Add(_modSize);
            //infoDock.Children.Add(_status);

            #endregion
            DockPanel rightSideDock = new DockPanel();
            DockPanel buttonDock    = new DockPanel();

            rightSideDock.HorizontalAlignment = HorizontalAlignment.Right;
            rightSideDock.MinWidth            = 100;
            Grid.SetColumn(rightSideDock, 1);

            DockPanel.SetDock(buttonDock, Dock.Bottom);
            buttonDock.Height = 25;
            buttonDock.HorizontalAlignment = HorizontalAlignment.Right;

            Button dependencies = new Button();
            dependencies.Template = buttonTemplate;
            dependencies.Content  = "Dep";
            dependencies.Click   += new RoutedEventHandler(this.viewDependancies);
            dependencies.Width    = 32;

            Button options = new Button();
            options.Template = buttonTemplate;
            options.Content  = "Opt";
            options.Click   += new RoutedEventHandler(this.viewOptions);
            options.Width    = 32;

            Button delete = new Button();
            delete.Template = buttonTemplate;
            delete.Content  = "Del";
            delete.Click   += new RoutedEventHandler(this.deleteMod);
            delete.Width    = 32;

            buttonDock.Children.Add(dependencies);
            buttonDock.Children.Add(options);
            buttonDock.Children.Add(delete);

            Image icon = new Image();

            icon.Source = new BitmapImage(new Uri(launcherConfig.modDir + "\\" + mod.modInfo.name + "\\" + mod.modInfo.icon));

            icon.Width               = 96;
            icon.VerticalAlignment   = VerticalAlignment.Bottom;
            icon.HorizontalAlignment = HorizontalAlignment.Right;
            DockPanel.SetDock(icon, Dock.Left);

            rightSideDock.Children.Add(buttonDock);
            rightSideDock.Children.Add(icon);

            elementGrid.Children.Add(infoDock);
            elementGrid.Children.Add(rightSideDock);

            elementGrid.Visibility = Visibility.Collapsed;

            mod.Children.Add(mainDock);
            mod.Children.Add(elementGrid);

            mod.MouseLeftButtonUp   += new MouseButtonEventHandler(this.modMouseUp);
            mod.MouseLeftButtonDown += new MouseButtonEventHandler(this.modMouseDown);
            mod.MouseMove           += new MouseEventHandler(this.modMouseMove);

            mod.DragOver += new DragEventHandler(this.ddPanelVisibility);
            mod.Drop     += new DragEventHandler(this.ddPanelDrop);

            mod.AllowDrop = true;



            destination.Children.Add(mod);
        }