Beispiel #1
0
        private void MoveUpButton_Click(object sender, EventArgs e)
        {
            if (SelectedPanel != null)
            {
                int ModNumber = 0;
                if (PanelHashList.TryGetValue(SelectedPanel.GetHashCode(), out ModNumber))
                {
                    if (ModNumber != 1)
                    {
                        ModPanel temp = new ModPanel();
                        temp = ModList[ModNumber];

                        //Swap HashCodes
                        PanelHashList[ModList[ModNumber - 1].MainPanel.GetHashCode()] = ModNumber;
                        PanelHashList[SelectedPanel.GetHashCode()] = ModNumber - 1;

                        //Swap ModPanels
                        ModList[ModNumber] = ModList[ModNumber - 1];
                        ModList[ModNumber].SetOrder(ModNumber);
                        ModList[ModNumber - 1] = temp;
                        ModList[ModNumber - 1].SetOrder(ModNumber - 1);

                        UpdateList();
                    }
                }
            }
        }
Beispiel #2
0
        private void UpdateList()
        {
            //Reset scroll for drawing - Need to find a cleaner way to achieve this
            Point ScrollPosition = MainModPanel.AutoScrollPosition;

            MainModPanel.AutoScrollPosition = new Point(AutoScrollPosition.X, 0);

            //Determines next panel's Y value
            int TotalPanelHeight = 0;

            //Go through dictionary via keys
            for (int ModNumber = 1; ModNumber <= ModList.Count; ModNumber++)
            {
                ModPanel mPanel = new ModPanel();
                if (ModList.TryGetValue(ModNumber, out mPanel))
                {
                    //Update position of panel
                    mPanel.MainPanel.Location = new Point(mPanel.MainPanel.Location.X, TotalPanelHeight);
                    //Set next panel's Y value
                    TotalPanelHeight += mPanel.MainPanel.Height;
                }
            }

            //Reset the scroll bar to where it was pre-update
            MainModPanel.AutoScrollPosition = new Point(Math.Abs(ScrollPosition.X), Math.Abs(ScrollPosition.Y));
        }
Beispiel #3
0
        private void CreateList(Dictionary <string, ModRegistryJSON> ListOfMods, GameDataJSON GDJ, DLCLoadJSON DLJ)
        {
            int ModNumber = 1, TotalPanelHeight = 0;

            foreach (string ID in GDJ.modsOrder)
            {
                ModRegistryJSON Mod = new ModRegistryJSON();
                if (ListOfMods.TryGetValue(ID, out Mod))
                {
                    bool IsEnabled = false;
                    if (DLJ.enabled_mods.Find(x => x == Mod.gameRegistryId) != null)
                    {
                        IsEnabled = true;
                    }

                    //Create new ModPanel
                    ModPanel mPanel = new ModPanel(ModNumber.ToString(), Mod.displayName, ID, Mod.gameRegistryId, Mod.steamId, IsEnabled);

                    //Add to container
                    MainModPanel.Controls.Add(mPanel.MainPanel);
                    //Set location
                    mPanel.MainPanel.Location = new Point(mPanel.MainPanel.Location.X, TotalPanelHeight);
                    //Set next Y position
                    TotalPanelHeight += mPanel.MainPanel.Height;

                    //Add panel to dictionary
                    ModList.Add(ModNumber, mPanel);
                    //Hash codes for referencing panels
                    PanelHashList.Add(mPanel.MainPanel.GetHashCode(), ModNumber);

                    //Mouse start hover
                    mPanel.MainPanel.MouseEnter  += ModPanelMouseEnter;
                    mPanel.ModLabel.MouseEnter   += ModPanelMouseEnter;
                    mPanel.OrderLabel.MouseEnter += ModPanelMouseEnter;
                    mPanel.Enabled.MouseEnter    += ModPanelMouseEnter;

                    //Mouse end hover
                    mPanel.MainPanel.MouseLeave  += ModPanelMouseLeave;
                    mPanel.ModLabel.MouseLeave   += ModPanelMouseLeave;
                    mPanel.OrderLabel.MouseLeave += ModPanelMouseLeave;
                    mPanel.Enabled.MouseLeave    += ModPanelMouseLeave;

                    //Select panel
                    mPanel.MainPanel.MouseClick  += ModPanelSelected;
                    mPanel.ModLabel.MouseClick   += ModPanelSelected;
                    mPanel.OrderLabel.MouseClick += ModPanelSelected;
                    mPanel.Enabled.MouseClick    += ModPanelSelected;

                    //Increase mod number to keep count
                    ModNumber++;
                }
            }
        }