Пример #1
0
        private void CreateSpawnPointMenu()
        {
            var spawnPointInfo = new UIPanel(new StyleDimension(300, 0), new StyleDimension(800, 0), Color.Pink);

            spawnPointInfo.Y.Pixels = 150;
            spawnPointInfo.Display  = Display.None;
            selectPanel.Append(spawnPointInfo);

            // Toggle Display
            Main.level.spawnPoint.OnClick     += (evt, elm) => spawnPointInfo.Display = Display.Visible;
            Main.level.spawnPoint.OnClickAway += (evt, elm) => spawnPointInfo.Display = Display.None;

            // Settings
            var spXPos = new UIInput <int>("X Position", 200, 50, Color.LightSkyBlue, Color.Black);

            spXPos.X.Percent    = 35;
            spXPos.Y.Pixels     = 50;
            spXPos.TextChanged += (evt, elm) =>
            {
                if (int.TryParse(spXPos.Input.Text, out int result))
                {
                    Main.level.spawnPoint.Position.X = result;
                }
            };
            spawnPointInfo.Append(spXPos);

            var spYPos = new UIInput <int>("Y Position", 200, 50, Color.LightSkyBlue, Color.Black);

            spYPos.X.Percent    = 35;
            spYPos.Y.Pixels     = 100;
            spYPos.TextChanged += (evt, elm) =>
            {
                if (int.TryParse(spYPos.Input.Text, out int result))
                {
                    Main.level.spawnPoint.Position.Y = result;
                }
            };
            spawnPointInfo.Append(spYPos);
        }
        private void CreatePartListPanel()
        {
            _partsPanel = new UIPanel
            {
                Left   = new StyleDimension(20, 0),
                Top    = new StyleDimension(40, 0),
                Width  = new StyleDimension(150, 0),
                Height = new StyleDimension(190, 0)
            };
            _partsPanel.SetPadding(0);
            _tabPanel.Append(_partsPanel);

            // Create a list
            _partsList = new UIList
            {
                Width  = new StyleDimension(_partsPanel.Width.Pixels - 25, 0),
                Height = new StyleDimension(0, 1),
                Left   = new StyleDimension(25, 0),
                Top    = new StyleDimension(5, 0)
            };
            _partsPanel.Append(_partsList);

            // And add a scrollbar
            UIScrollbar partScrollbar = new UIScrollbar
            {
                Height = new StyleDimension(_partsPanel.Height.Pixels - 10, 0),
                //Top = new StyleDimension(5, 0),
                VAlign = 0.5f,
                Width  = new StyleDimension(20, 0),
                Left   = new StyleDimension(0, 0)
            }.WithView(50, 250);

            _partsPanel.Append(partScrollbar);
            _partsList.SetScrollbar(partScrollbar);

            AddPartsToList();

            UpdateParts(null);
        }
Пример #3
0
        public override void OnInitialize()
        {
            mainPanel = new UIPanel();
            mainPanel.Left.Set(-350f, 1f);
            mainPanel.Top.Set(-620f, 1f);
            mainPanel.Width.Set(310f, 0f);
            mainPanel.Height.Set(520f, 0f);
            mainPanel.SetPadding(12);
            mainPanel.BackgroundColor = Color.Yellow * 0.8f;

            int    top  = 0;
            UIText text = new UIText("Player Layer:", 0.85f);

            text.Top.Set(top, 0f);
            mainPanel.Append(text);
            top += 20;

            playerLayerList            = new UIList();
            playerLayerList.Top.Pixels = top;
            //autoTrashGrid.Left.Pixels = spacing;
            playerLayerList.Width.Set(-25f, 1f);             // leave space for scroll?
            playerLayerList.Height.Set(-top, 1f);
            playerLayerList.ListPadding = 6f;
            mainPanel.Append(playerLayerList);

            // this will initialize grid
            updateNeeded = true;

            var playerLayerListScrollbar = new UIElements.FixedUIScrollbar(_userInterface);

            playerLayerListScrollbar.SetView(100f, 1000f);
            playerLayerListScrollbar.Top.Pixels = top;            // + spacing;
            playerLayerListScrollbar.Height.Set(-top /*- spacing*/, 1f);
            playerLayerListScrollbar.HAlign = 1f;
            mainPanel.Append(playerLayerListScrollbar);
            playerLayerList.SetScrollbar(playerLayerListScrollbar);

            Append(mainPanel);
        }
Пример #4
0
        public override void OnInitialize()
        {
            /// Item panel
            itemPanel          = new ItemUIPanel();
            itemPanel.OnClick += (s, e) =>
            {
                var sortMode = SortingMode.CurrentCollectibleSortMode == SortingMode.CollectibleSortingMode.NamesDesc ? SortingMode.CollectibleSortingMode.NamesAsc
                                                           : SortingMode.CurrentCollectibleSortMode == SortingMode.CollectibleSortingMode.NamesAsc ?
                               SortingMode.CollectibleSortingMode.Normal : SortingMode.CollectibleSortingMode.NamesDesc;

                SortingMode.ApplySort(ref MultiShop.instance.shopGUI.rightPanel, sortMode);
            };
            itemPanel.Width.Set(ShopUIPanel.panelwidth, 0f);
            itemPanel.Height.Set(ShopUIPanel.panelheight, 0f);
            base.Append(itemPanel);

            /// Header text (Item name)
            headerText   = "??";
            headerUIText = new UIText(headerText);
            headerUIText.Top.Set(Main.fontItemStack.MeasureString(headerUIText.Text).X / 2 + ShopGUI.vpadding / 4f, 0f);
            headerUIText.Left.Set(itemPanel.Width.Pixels + ShopGUI.vpadding, 0f);
            base.Append(headerUIText);

            /// Unit panel
            unitPanel          = new UIPanel();
            unitPanel.OnClick += (s, e) =>
            {
                var sortMode = SortingMode.CurrentCollectibleSortMode == SortingMode.CollectibleSortingMode.UnitDesc ?
                               SortingMode.CollectibleSortingMode.UnitAsc
                                                           : SortingMode.CollectibleSortingMode.UnitDesc;

                SortingMode.ApplySort(ref MultiShop.instance.shopGUI.rightPanel, sortMode);
            };
            unitPanel.OnMouseOver += (s, e) =>
            {
                (e as UIPanel).PanelUIHover();
            };
            unitPanel.OnMouseOut += (s, e) =>
            {
                (e as UIPanel).PanelUIHover(false);
            };
            unitPanel.Height.Set(itemPanel.Height.Pixels, 0f);
            unitPanel.Width.Set(base.Width.Pixels / 4f + ShopGUI.vpadding * 2f, 0f);
            unitPanel.Left.Set(base.Width.Pixels - unitPanel.Width.Pixels - ShopGUI.vpadding, 0f);
            base.Append(unitPanel);

            /// Unit UI Text
            unitUIText = new UIText("");
            SetUnits(_stack);
            unitPanel.Append(unitUIText);
        }
Пример #5
0
        public DraggableUIPanel(float width, float height)
        {
            // Set the width and height to the passed parameters
            Width.Set(width, 0);
            Height.Set(height, 0);
            SetPadding(0);

            // Create a new header, with custom OnMouse events
            header = new UIPanel();
            header.SetPadding(0);
            header.Width             = Width;
            header.Height            = new StyleDimension(30, 0);
            header.BackgroundColor.A = 255;
            header.OnMouseDown      += Header_OnMouseDown;
            header.OnMouseUp        += Header_OnMouseUp;
            Append(header);

            // Create a close button
            var closeBtn = new UITextPanel <char>('X');

            closeBtn.SetPadding(7);
            closeBtn.Width             = new StyleDimension(40, 0);
            closeBtn.Left              = new StyleDimension(-40, 1);
            closeBtn.BackgroundColor.A = 255;
            closeBtn.OnClick          += (evt, elm) => OnCloseBtnClicked?.Invoke();
            header.Append(closeBtn);

            // Create a lock button
            var lockBtn = new UIImageButton(ModContent.GetTexture("Terraria/Lock_" + (isDraggable ? 1 : 0)));

            lockBtn.Width  = new StyleDimension(24, 0);
            lockBtn.Height = new StyleDimension(24, 0);
            lockBtn.Left   = new StyleDimension(width - 65, 0);
            lockBtn.Top    = new StyleDimension(5, 0);
            lockBtn.SetPadding(0);
            lockBtn.OnClick += UpdateLock;
            header.Append(lockBtn);
        }
Пример #6
0
        public override void OnInitialize()
        {
            checklistPanel = new UIPanel();
            checklistPanel.SetPadding(10);
            checklistPanel.Left.Pixels = 0;
            checklistPanel.HAlign      = 1f;
            checklistPanel.Top.Set(50f, 0f);
            checklistPanel.Width.Set(250f, 0f);
            checklistPanel.Height.Set(-100, 1f);
            checklistPanel.BackgroundColor = new Color(73, 94, 171);

            toggleButton             = new UIHoverImageButton(Main.itemTexture[ItemID.SuspiciousLookingEye], "Toggle Completed");
            toggleButton.OnClick    += ToggleButtonClicked;
            toggleButton.Left.Pixels = spacing;
            toggleButton.Top.Pixels  = spacing;
            checklistPanel.Append(toggleButton);

            checklistList            = new UIList();
            checklistList.Top.Pixels = 32f + spacing;
            checklistList.Width.Set(0f, 1f);
            checklistList.Height.Set(-32f, 1f);
            checklistList.ListPadding = 12f;
            checklistPanel.Append(checklistList);

            UIScrollbar checklistListScrollbar = new UIScrollbar();

            checklistListScrollbar.SetView(100f, 1000f);
            checklistListScrollbar.Height.Set(0f, 1f);
            checklistListScrollbar.HAlign = 1f;
            checklistPanel.Append(checklistListScrollbar);
            checklistList.SetScrollbar(checklistListScrollbar);

            // Checklistlist populated when the panel is shown: UpdateCheckboxes()

            Append(checklistPanel);

            // TODO, game window resize issue
        }
        public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
        {
            if (info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0)
            {
                return(null);
            }
            UIElement uIElement = new UIPanel(Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Stat_Panel", Main.content, (AssetRequestMode)1), null, 12, 7)
            {
                Width           = new StyleDimension(-14f, 1f),
                Height          = new StyleDimension(34f, 0f),
                BackgroundColor = new Color(43, 56, 101),
                BorderColor     = Color.Transparent,
                Left            = new StyleDimension(5f, 0f)
            };

            uIElement.SetPadding(0f);
            uIElement.PaddingRight = 5f;
            UIElement filterImage = GetFilterImage();

            filterImage.HAlign = 0f;
            filterImage.Left   = new StyleDimension(5f, 0f);
            UIText element = new UIText(Language.GetText(GetDisplayNameKey()), 0.8f)
            {
                HAlign      = 0f,
                Left        = new StyleDimension(38f, 0f),
                TextOriginX = 0f,
                VAlign      = 0.5f,
                DynamicallyScaleDownToWidth = true
            };

            if (filterImage != null)
            {
                uIElement.Append(filterImage);
            }
            uIElement.Append(element);
            AddOnHover(uIElement);
            return(uIElement);
        }
Пример #8
0
        public override void OnInitialize()
        {
            checklistPanel = new UIPanel();
            checklistPanel.SetPadding(10);
            checklistPanel.Left.Pixels = 0;
            checklistPanel.HAlign      = 1f;
            checklistPanel.Top.Set(50f, 0f);
            checklistPanel.Width.Set(250f, 0f);
            checklistPanel.Height.Set(-100, 1f);
            checklistPanel.BackgroundColor = new Color(73, 94, 171);

            toggleCompletedButton             = new UIHoverImageButton(Main.magicPixel, "Toggle Completed");
            toggleCompletedButton.OnClick    += ToggleCompletedButtonClicked;
            toggleCompletedButton.Left.Pixels = spacing;
            toggleCompletedButton.Top.Pixels  = 0;
            checklistPanel.Append(toggleCompletedButton);

            toggleMiniBossButton             = new UIHoverImageButton(Main.magicPixel, "Toggle Mini Bosses");
            toggleMiniBossButton.OnClick    += ToggleMiniBossButtonClicked;
            toggleMiniBossButton.Left.Pixels = spacing + 32;
            toggleMiniBossButton.Top.Pixels  = 0;
            checklistPanel.Append(toggleMiniBossButton);

            toggleEventButton             = new UIHoverImageButton(Main.magicPixel, "Toggle Events");
            toggleEventButton.OnClick    += ToggleEventButtonClicked;
            toggleEventButton.Left.Pixels = spacing + 64;
            toggleEventButton.Top.Pixels  = 0;
            checklistPanel.Append(toggleEventButton);

            toggleHiddenButton             = new UIHoverImageButton(Main.magicPixel, "Toggle Show Hidden Bosses\n(Alt-Click to clear Hidden bosses)\n(Alt-Click on boss to hide)");
            toggleHiddenButton.OnClick    += ToggleHiddenButtonClicked;
            toggleHiddenButton.Left.Pixels = spacing + 96;
            toggleHiddenButton.Top.Pixels  = 0;
            checklistPanel.Append(toggleHiddenButton);

            checklistList            = new UIList();
            checklistList.Top.Pixels = 32f + spacing;
            checklistList.Width.Set(-25f, 1f);
            checklistList.Height.Set(-32f, 1f);
            checklistList.ListPadding = 12f;
            checklistPanel.Append(checklistList);

            FixedUIScrollbar checklistListScrollbar = new FixedUIScrollbar();

            checklistListScrollbar.SetView(100f, 1000f);
            //checklistListScrollbar.Height.Set(0f, 1f);
            checklistListScrollbar.Top.Pixels = 32f + spacing;
            checklistListScrollbar.Height.Set(-32f - spacing, 1f);
            checklistListScrollbar.HAlign = 1f;
            checklistPanel.Append(checklistListScrollbar);
            checklistList.SetScrollbar(checklistListScrollbar);

            // Checklistlist populated when the panel is shown: UpdateCheckboxes()

            Append(checklistPanel);

            // TODO, game window resize issue
        }
Пример #9
0
        public UIRadio(string name, int number, UIPanel panel, int left, int top, int on)
        {
            group = new UIToggleImage[number];
            for (int i = 0; i < number; i++)
            {
                group[i] = new UIToggleImage(Texture, 14, 14, new Point(16, 0), new Point(0, 0));
                group[i].Left.Set(left + i * 20, 0f);
                group[i].Top.Set(top, 0f);
                group[i].Width.Set(16, 0f);
                group[i].Height.Set(16, 0f);
                group[i].OnClick += ButtonClicked;
                panel.Append(group[i]);
            }
            this.name = name;
            group[on].SetState(true);
            UIText text = new UIText(name);

            text.Top.Set(top, 0f);
            text.Left.Set(left + 4 * 20, 0f);
            text.Height.Set(15, 0f);
            text.Width.Set(95, 0f);
            panel.Append(text);
        }
Пример #10
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (needToRemoveLoading)
            {
                needToRemoveLoading = false;
                uIPanel.RemoveChild(uiLoader);
            }
            if (!updateNeeded)
            {
                return;
            }
            updateNeeded = false;
            filter       = filterTextBox.Text;
            modList.Clear();
            var filterResults = new UIModsFilterResults();
            var visibleItems  = items.Where(item => item.PassFilters(filterResults)).ToList();

            if (filterResults.AnyFiltered)
            {
                var panel = new UIPanel();
                panel.Width.Set(0, 1f);
                modList.Add(panel);
                var filterMessages = new List <string>();
                if (filterResults.filteredByEnabled > 0)
                {
                    filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredByEnabled", filterResults.filteredByEnabled));
                }
                if (filterResults.filteredByModSide > 0)
                {
                    filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredByModSide", filterResults.filteredByModSide));
                }
                if (filterResults.filteredBySearch > 0)
                {
                    filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredBySearch", filterResults.filteredBySearch));
                }
                string filterMessage = string.Join("\n", filterMessages);
                var    text          = new UIText(filterMessage);
                text.Width.Set(0, 1f);
                text.IsWrapped = true;
                text.WrappedTextBottomPadding = 0;
                text.TextOriginX = 0f;
                text.Recalculate();
                panel.Append(text);
                panel.Height.Set(text.MinHeight.Pixels + panel.PaddingTop, 0f);
            }
            modList.AddRange(visibleItems);
            Recalculate();
            modList.ViewPosition = modListViewPosition;
        }
        public void init()
        {
            RemoveAllChildren();
            Width.Set(600, 0f);
            Height.Set(635, 0f);
            Top.Set(Main.screenHeight / 2 - 300, 0f);
            Left.Set(Main.screenWidth / 2 - 300, 0f);
            SetPadding(0);


            panel = new UIPanel();
            panel.Width.Set(600, 0f);
            panel.Height.Set(600, 0f);
            panel.Left.Set(5, 0f);
            panel.Top.Set(35f, 0f);



            List <AchievementSlot> achievementSlots = new List <AchievementSlot>();

            list = new AchivementUIList();
            list.Left.Set(-5f, 0f);
            list.Top.Set(35, 0f);


            Scrollbar = new UIScrollbar();
            Scrollbar.SetView(100f, 100f);
            Scrollbar.Height.Set(-35f, 1f);
            Scrollbar.Top.Set(35f, 0f);
            Scrollbar.HAlign = 1f;

            list.SetScrollbar(Scrollbar);
            panel.Append(Scrollbar);
            panel.Append(list);

            title = new UIPanel();
            title.Width.Set(200, 0f);
            title.Height.Set(50, 0f);
            title.Left.Set(200, 0f);
            title.BackgroundColor = Color.DarkBlue;

            UIText text = new UIText("Modded Achievements");

            text.Height.Set(25, 0);

            title.Append(text);

            Append(panel);
            Append(title);
        }
        internal override void InitializeOther(UIPanel panel)
        {
            craft = new ClickableButton(Language.GetTextValue("LegacyMisc.72"))
            {
                HAlign = 0.2f
            };
            craft.Top.Set(300, 0);
            panel.Append(craft);

            nextRecipe = new ClickableButton(">")
            {
                HAlign = 0.7f
            };
            nextRecipe.Top.Set(300, 0);
            panel.Append(nextRecipe);

            prevRecipe = new ClickableButton("<")
            {
                HAlign = 0.55f
            };
            prevRecipe.Top.Set(300, 0);
            panel.Append(prevRecipe);
        }
Пример #13
0
        private void AppendToPanel(UIElement element, float indent)
        {
            BasePanel.Append(element);
            element.Recalculate();
            element.Left   = new StyleDimension(indent, 0);
            element.Top    = new StyleDimension(Height.Pixels, 0);
            Height.Pixels += element.MinHeight.Pixels + 5;
            float newWidth = element.MinWidth.Pixels + indent + 20;

            if (Width.Pixels < newWidth)
            {
                Width.Pixels = newWidth;
            }
        }
Пример #14
0
        public override void OnInitialize()
        {
            // UI Panel
            FlagModifierPanel = new UIPanel();
            FlagModifierPanel.SetPadding(0);
            FlagModifierPanel.Left.Set(700f, 0f);
            FlagModifierPanel.Top.Set(200f, 0f);
            FlagModifierPanel.Width.Set(500f, 0f);
            FlagModifierPanel.Height.Set(100f, 0f);

            // Close UI button
            Texture2D     buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete");
            UIImageButton closeButton         = new UIImageButton(buttonDeleteTexture);

            closeButton.Left.Set(-32, 1f);
            closeButton.Top.Set(10, 0f);
            closeButton.Width.Set(22, 0f);
            closeButton.Height.Set(22, 0f);
            closeButton.OnClick += new MouseEvent(CloseButtonClicked);
            FlagModifierPanel.Append(closeButton);

            // Title text
            UIText title = new UIText("Flag Modifier", 1, false);

            title.Left.Set(10, 0f);
            title.Top.Set(10, 0f);
            FlagModifierPanel.Append(title);

            // Flag item slot
            FlagItemSlot itemSlot = new FlagItemSlot(currentFlag);

            itemSlot.Top.Set(-74, 1f);
            itemSlot.Left.Set(10, 0f);
            FlagModifierPanel.Append(itemSlot);

            base.Append(FlagModifierPanel);
        }
Пример #15
0
        public override void OnInitialize()
        {
            panel = new UIPanel();
            panel.Width.Set(400, 0);
            panel.Height.Set(200, 0);
            panel.Top.Set(Main.screenHeight / 2 - 100, 0);
            panel.Left.Set(Main.screenWidth / 2 - 200, 0);

            int space = 40;

            for (int i = 0; i < chargingSlot.Length; i++)
            {
                ChargingSlot slot = chargingSlot[i];
                slot.Top.Set(25, 0);
                slot.Left.Set(space, 0);
                slot.Width.Set(64, 0);
                slot.Height.Set(64, 0);
                space += 75;
                panel.Append(slot);
            }

            Texture2D     buttonDeleteTexture = ModContent.GetTexture("Terraria/UI/ButtonDelete");
            UIImageButton closeButton         = new UIImageButton(buttonDeleteTexture);

            closeButton.Left.Set(400 - 45, 0f);
            closeButton.Width.Set(22, 0f);
            closeButton.Height.Set(22, 0f);
            closeButton.OnClick += new MouseEvent(CloseButtonClicked);
            panel.Append(closeButton);

            energybar = new UIEnergyBar(capacitorEntity.energy);
            energybar.Top.Set(170f, 0);
            energybar.Height.Set(14f, 0);
            energybar.Width.Set(386f, 0);
            panel.Append(energybar);
            Append(panel);
        }
Пример #16
0
        public override void OnInitialize()
        {
            //Panel
            backPanel = new UIPanel();
            backPanel.SetPadding(0);
            backPanel.Left.Set(Terraria.Main.instance.GraphicsDevice.Viewport.Bounds.Width / 2 - panelWidth / 2, 0f);
            backPanel.Top.Set(Terraria.Main.instance.GraphicsDevice.Viewport.Bounds.Height / 2 - panelHeight / 2, 0f);
            backPanel.Width.Set(panelWidth, 0f);
            backPanel.Height.Set(panelHeight, 0f);
            base.Append(backPanel);

            //Change gamepad button
            changeGamepadButton = new UITextPanel <string>("Next", 0.5f, true)
            {
                VAlign = 0.05f,
                HAlign = 0.03f
            };
            changeGamepadButton.OnClick += new UIElement.MouseEvent(this.ChangedButtonClicked);
            backPanel.Append(changeGamepadButton);

            //Player index display
            playerIndexDisplay = new UIText("", 1.15f, false)
            {
                VAlign = 0.07f,
                HAlign = 0.6f
            };
            backPanel.Append(playerIndexDisplay);

            //Finished button
            finishButton = new UITextPanel <string>("OK", 0.5f, true)
            {
                VAlign = 0.9f,
                HAlign = 0.9f
            };
            finishButton.OnClick += FinishButtonClicked;
            backPanel.Append(finishButton);
        }
Пример #17
0
        public override void OnInitialize()
        {
            //Panel
            backPanel = new UIPanel();
            backPanel.SetPadding(0);
            backPanel.Left.Set(Terraria.Main.instance.GraphicsDevice.Viewport.Bounds.Width / 2 - panelWidth / 2, 0f);
            backPanel.Top.Set(Terraria.Main.instance.GraphicsDevice.Viewport.Bounds.Height / 2 - panelHeight / 2, 0f);
            backPanel.Width.Set(panelWidth, 0f);
            backPanel.Height.Set(panelHeight, 0f);
            base.Append(backPanel);

            //Text
            lockMouseText = new UIText("Lock mouse?", 1.15f, false)
            {
                VAlign = 0.07f,
                HAlign = 0.07f
            };
            backPanel.Append(lockMouseText);

            //Yes button
            yesButton = new UITextPanel <string>("Yes", 0.7f, true)
            {
                VAlign = 0.85f,
                HAlign = 0.06f
            };
            yesButton.OnClick += YesButtonClicked;
            backPanel.Append(yesButton);

            //No button
            noButton = new UITextPanel <string>("No", 0.7f, true)
            {
                VAlign = 0.85f,
                HAlign = 0.7f
            };
            noButton.OnClick += NoButtonClicked;
            backPanel.Append(noButton);
        }
Пример #18
0
 private void PopulateModBrowser()
 {
     loading = true;
     SpecialModPackFilter      = null;
     SpecialModPackFilterTitle = null;
     reloadButton.SetText(Language.GetTextValue("tModLoader.MBGettingData"));
     SetHeading(Language.GetTextValue("tModLoader.MenuModBrowser"));
     uIPanel.Append(uILoader);
     modList.Clear();
     items.Clear();
     modList.Deactivate();
     try {
         ServicePointManager.Expect100Continue = false;
         string url    = "http://javid.ddns.net/tModLoader/listmods.php";
         var    values = new NameValueCollection
         {
             { "modloaderversion", ModLoader.versionedName },
             { "platform", ModLoader.compressedPlatformRepresentation },
         };
         using (WebClient client = new WebClient()) {
             ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return(true); });
             client.UploadValuesCompleted += new UploadValuesCompletedEventHandler(UploadComplete);
             client.UploadValuesAsync(new Uri(url), "POST", values);
         }
     }
     catch (WebException e) {
         ShowOfflineTroubleshootingMessage();
         if (e.Status == WebExceptionStatus.Timeout)
         {
             SetHeading(Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", Language.GetTextValue("tModLoader.MBBusy")));
             return;
         }
         if (e.Status == WebExceptionStatus.ProtocolError)
         {
             var resp = (HttpWebResponse)e.Response;
             if (resp.StatusCode == HttpStatusCode.NotFound)
             {
                 SetHeading(Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", resp.StatusCode));
                 return;
             }
             SetHeading(Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", resp.StatusCode));
             return;
         }
     }
     catch (Exception e) {
         UIModBrowser.LogModBrowserException(e);
         return;
     }
 }
Пример #19
0
        public override void OnInitialize()
        {
            DragableUIPanel ConfirmPanel = new DragableUIPanel("Are you sure you want to delete all your items?", 550f, 100f);

            ConfirmPanel.SetPadding(0);
            ConfirmPanel.VAlign             = ConfirmPanel.HAlign = 0.5f;
            ConfirmPanel.OnCloseBtnClicked += () => Visible = false;
            Append(ConfirmPanel);

            UIPanel YEPbutton = new UIPanel();

            YEPbutton.Width.Set(100, 0);
            YEPbutton.Height.Set(50, 0);
            YEPbutton.HAlign = 0.03f;
            YEPbutton.Top.Set(35, 0);
            YEPbutton.OnClick += YEPClicked;
            ConfirmPanel.Append(YEPbutton);

            UIPanel DelFavbutton = new UIPanel();

            DelFavbutton.Width.Set(300, 0);
            DelFavbutton.Height.Set(50, 0);
            DelFavbutton.HAlign = 0.5f;
            DelFavbutton.Top.Set(35, 0);
            DelFavbutton.OnClick += DelFavClicked;
            ConfirmPanel.Append(DelFavbutton);

            UIPanel NObutton = new UIPanel();

            NObutton.Width.Set(100, 0);
            NObutton.Height.Set(50, 0);
            NObutton.HAlign = 0.97f;
            NObutton.Top.Set(35, 0);
            NObutton.OnClick += NOClicked;
            ConfirmPanel.Append(NObutton);

            YEPbutton.Append(new UIText("Yes")
            {
                HAlign = 0.5f, VAlign = 0.5f
            });
            DelFavbutton.Append(new UIText("Delete all, exept favorited Items")
            {
                HAlign = 0.5f, VAlign = 0.5f
            });
            NObutton.Append(new UIText("NO!")
            {
                HAlign = 0.5f, VAlign = 0.5f
            });
        }
Пример #20
0
        public override void OnInitialize()
        {
            UIPanel panel = new UIPanel();

            panel.Width.Set(300, 0);
            panel.Height.Set(100, 0);
            panel.Top.Set(0, 0);
            panel.Left.Set(Main.screenWidth / 2 - panel.Width.Pixels / 2, 0f);
            Append(panel);

            positionText = new UIText("0|0"); //text to show current hp or mana
            positionText.Width.Set(300, 0f);
            positionText.Height.Set(100, 0f);
            panel.Append(positionText);
        }
Пример #21
0
        public override void OnInitialize()
        {
            icon = new AmmoIconSprite();

            ammoPanel = new UIPanel();
            ammoPanel.Top.Set(10, 0f);
            ammoPanel.Left.Set(-80, 0f);
            ammoPanel.Width.Set(48f, 0f);
            ammoPanel.Height.Set(48f, 0f);
            ammoPanel.BackgroundColor = new Color(73, 94, 171);
            ammoPanel.Append(icon);
            ammoPanel.VAlign = ratioY;
            ammoPanel.HAlign = ratioX;
            base.Append(ammoPanel);
        }
        public override void OnInitialize()
        {
            panelMain.Width.Pixels   = Main.screenWidth / 7f;
            panelMain.Height.Precent = 0.25f;
            panelMain.Center();
            panelMain.SetPadding(0);
            panelMain.OnMouseDown    += DragStart;
            panelMain.OnMouseUp      += DragEnd;
            panelMain.BackgroundColor = panelColor;
            Append(panelMain);

            textLabel.Top.Pixels = 8;
            textLabel.HAlign     = 0.5f;
            panelMain.Append(textLabel);

            barEnergy.Width.Pixels = 32;
            barEnergy.Height.Set(-16, 1);
            barEnergy.Left.Set(-barEnergy.Width.Pixels - 8, 1);
            barEnergy.Top.Pixels = 8;
            panelMain.Append(barEnergy);

            panelInfo.Width.Set(-56, 1);
            panelInfo.Height.Set(-44, 1);
            panelInfo.Left.Pixels = 8;
            panelInfo.Top.Pixels  = 36;
            panelInfo.SetPadding(0);
            panelMain.Append(panelInfo);

            textGeneration.Left.Pixels = 8;
            textGeneration.Top.Pixels  = 8;
            panelInfo.Append(textGeneration);

            textWaterTiles.Left.Pixels = 8;
            textWaterTiles.Top.Pixels  = 36;
            panelInfo.Append(textWaterTiles);
        }
Пример #23
0
        private void CycleShopButtonClicked(UIMouseEvent evt, UIElement listeningElement)
        {
            ShopPanel.RemoveChild(m_OpenShopButton);

            ShiftShop();

            // Recreate 'Open Shop Button', to update the name of the new shop once the cycle shop button is clicked
            m_OpenShopButton = new TextButton(CurrentShops[TheShop], 0.9f);
            m_OpenShopButton.Left.Set(10, 0f);
            m_OpenShopButton.Top.Set(4, 0f);
            m_OpenShopButton.OnClick += new MouseEvent(ShopButtonClicked);

            ShopPanel.Append(m_OpenShopButton);

            OpenShop();
        }
        private void InitializeHeroesPanel()
        {
            _heroesPanel = new UIPanel();

            _heroesPanel.Width.Set(0, 1f);
            _heroesPanel.Height.Set(0, 0.75f);

            _heroesPanel.Top.Set(_mainLabel.GetDimensions().Height + 100f, 0f);
            _heroesPanel.SetPadding(50f);

            //_heroesPanel.BackgroundColor = Color.Red;
            _heroesPanel.BackgroundColor = Color.Transparent;
            _heroesPanel.BorderColor     = Color.Transparent;

            _mainPanel.Append(_heroesPanel);
        }
Пример #25
0
        public override void OnInitialize()
        {
            UIPanel panel = new UIPanel();

            panel.Width.Set(300, 0);
            panel.Height.Set(300, 0);
            Append(panel);

            UIText text = new UIText("TEST TEST")
            {
                VAlign = 0.5f,
                HAlign = 0.1f
            };

            panel.Append(text);
        }
Пример #26
0
        public override void OnActivate()
        {
            scrollPanel.Append(uiLoader);
            modListList.Clear();
            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }
            Task.Factory
            .StartNew(delegate
            {
                mods = ModOrganizer.FindMods().Select(m => m.Name).ToArray();
                return(FindModLists());
            })
            .ContinueWith(task =>
            {
                string[] modListsFullPath = task.Result;
                foreach (string modListFilePath in modListsFullPath)
                {
                    try
                    {
                        string[] mods = { };
                        //string path = ModListSaveDirectory + Path.DirectorySeparatorChar + modListFilePath + ".json";

                        if (File.Exists(modListFilePath))
                        {
                            using (StreamReader r = new StreamReader(modListFilePath))
                            {
                                string json = r.ReadToEnd();

                                mods = JsonConvert.DeserializeObject <string[]>(json);
                            }
                        }
                        UIModPackItem modItem = new UIModPackItem(Path.GetFileNameWithoutExtension(modListFilePath), mods);
                        modListList.Add(modItem);
                    }
                    catch
                    {
                        UIAutoScaleTextTextPanel <string> badModPackMessage = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackMalformed", Path.GetFileName(modListFilePath)));
                        badModPackMessage.Width.Set(0, 1);
                        badModPackMessage.Height.Set(50, 0);
                        modListList.Add(badModPackMessage);
                    }
                }
                scrollPanel.RemoveChild(uiLoader);
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Пример #27
0
 internal void ToggleTileChooser(bool show = true)
 {
     if (show)
     {
         recipeGridPanel.Width.Set(-113, 1f);
         recipeGridPanel.Left.Set(53, 0f);
         mainPanel.Append(tileChooserPanel);
     }
     else
     {
         recipeGridPanel.Width.Set(-60, 1f);
         recipeGridPanel.Left.Set(0, 0f);
         mainPanel.RemoveChild(tileChooserPanel);
         Tile = -1;
     }
     recipeGridPanel.Recalculate();
 }
Пример #28
0
        public override void OnInitialize()
        {
            UIPanel panel = new UIPanel();

            panel.Width.Set(60, 0);
            panel.Height.Set(30, 0);
            panel.Left.Set(-panel.Width.Pixels - 1470, 1f);
            panel.OnClick += OnButtonClick;
            panel.Top.Set(800, 0f);
            Append(panel);


            UIText text = new UIText("Scale"); //all of this code is horrendesly broken.

            text.HAlign = text.VAlign = 0.5f;
            panel.Append(text);
        }
Пример #29
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            // TODO : Fix panel not being drageable all over its surface.

            backPanel = new UIPanel();
            backPanel.Width.Set(GFX.backPanel.Width, 0f);
            backPanel.Height.Set(GFX.backPanel.Height, 0f);
            backPanel.Left.Set(Main.screenWidth / 2f - backPanel.Width.Pixels / 2f, 0f);
            backPanel.Top.Set(Main.screenHeight / 2f - backPanel.Height.Pixels / 2f, 0f);
            backPanel.BackgroundColor = new Color(0, 0, 0, 0);
            backPanel.OnMouseDown    += new MouseEvent(DragStart);
            backPanel.OnMouseUp      += new MouseEvent(DragEnd);
            Append(backPanel);

            backPanelImage = new UIImage(GFX.backPanel);
            backPanelImage.Width.Set(GFX.backPanel.Width, 0f);
            backPanelImage.Height.Set(GFX.backPanel.Height, 0f);
            backPanelImage.Left.Set(-12, 0f);
            backPanelImage.Top.Set(-12, 0f);
            backPanel.Append(backPanelImage);

            int
                rowXOffset = PADDINGX,
                rowYOffset = PADDINGY;

            // 125 is the width of the text ?
            InitText(ref _titleText, "Transformation Tree", 1, GFX.backPanel.Bounds.X, -32, Color.White);

            NodeTree <TransformationDefinition> tDefTree = DBZMOD.Instance.TransformationDefinitionManager.Tree;

            foreach (KeyValuePair <TransformationDefinition, ManyToManyNode <TransformationDefinition> > rootedTree in tDefTree.RootedTree)
            {
                // A root element of the transformation tree should always have an BuffIcon.
                if (rootedTree.Key.BuffIconGetter == null)
                {
                    continue;
                }

                RecursiveDrawTransformation(tDefTree.Tree, rootedTree.Value, ref rowXOffset, ref rowYOffset);

                rowXOffset  = PADDINGX;
                rowYOffset += rootedTree.Key.BuffIconGetter().Height + SMALL_SPACE;
            }
        }
Пример #30
0
        public override void OnInitialize()
        {
            int screenWidth = Main.screenWidth;

            this.Width.Set(0, 0.5f);
            this.Height.Set(105, 0f);
            this.Left.Set(screenWidth / 4, 0f); // can't use precent as that causes the draggable windows to jump when first dragged
            this.Top.Set(10f, 0f);

            titleText            = new UIText("");
            titleText.Top.Pixels = -5;
            this.Append(titleText);

            commandInput = new UIBetterTextBox("Command");
            commandInput.BackgroundColor = Color.White;
            commandInput.Top.Set(0, 0.25f);
            commandInput.Width.Precent  = 1f;
            commandInput.Height.Pixels  = 30;
            commandInput.OnTextChanged += () => { CommandInputChanged(); };
            this.Append(commandInput);

            outputCheckbox             = new UICheckbox("Show debug output?", "");
            outputCheckbox.Top.Precent = 0.78f;
            outputCheckbox.Left.Pixels = 70f;
            this.Append(outputCheckbox);

            button = new UIPanel();
            button.Width.Pixels    = 60f;
            button.Height.Pixels   = 30f;
            button.Top.Precent     = 0.70f;
            button.BackgroundColor = new Color(73, 94, 171);
            button.OnClick        += (evt, element) => { SaveBtnPress(); };
            UIText buttonText = new UIText("Save");

            buttonText.Top.Pixels  = -4f;
            buttonText.Left.Pixels = 0f;
            button.Append(buttonText);
            this.Append(button);

            UIQuitButton quitButton = new UIQuitButton("Close Menu");

            quitButton.Top.Set(-6, 0f);
            quitButton.Left.Set(0, 0.983f);
            quitButton.OnClick += (evt, element) => { ModContent.GetInstance <TICMod>().ToggleCommandUI(i, j, uiType, true); };
            this.Append(quitButton);
        }