Esempio n. 1
0
        public void UpdateWaypointList()
        {
            scrollView.ClearContent();
            float yPos = spacing;

            for (int i = 0; i < Waypoints.points.Count; i++)
            {
                UILabel label = new UILabel(Waypoints.points[i].name);
                label.Scale        = .5f;
                label.X            = spacing;
                label.Y            = yPos;
                label.Tag          = i;
                label.onLeftClick += label_onLeftClick;
                yPos += label.Height;
                scrollView.AddChild(label);

                UIImage image = new UIImage(closeTexture);
                image.ForegroundColor = Color.Red;
                image.Anchor          = AnchorPosition.Right;
                image.Position        = new Vector2(scrollView.Width - 10 - spacing, label.Position.Y + label.Height / 2);
                image.Tag             = i;
                image.onLeftClick    += image_onLeftClick;

                scrollView.AddChild(image);
            }
            scrollView.ContentHeight = scrollView.GetLastChild().Y + scrollView.GetLastChild().Height + spacing;
        }
Esempio n. 2
0
        private void PopulateCategoryView()
        {
            Category[] categories = Categories;
            if (SelectedCategory != null)
            {
                categories = SelectedCategory.SubCategories.ToArray();
                if (categories.Length == 0)
                {
                    return;
                }
            }

            _categoryView.ClearContent();
            float yPos = 0;

            for (int i = 0; i < categories.Length; i++)
            {
                UIButton button = new UIButton(categories[i].LocalizedName);
                button.Tag      = categories[i];
                button.AutoSize = false;
                button.Width    = 100;
                int x = i % numberCategoryColumns;
                int y = i / numberCategoryColumns;
                button.X            = Spacing + x * (button.Width + Spacing);
                button.Y            = Spacing + y * (button.Height + Spacing);
                button.onLeftClick += button_onLeftClick;
                yPos = button.Y + button.Height + Spacing;
                _categoryView.AddChild(button);
            }
            _categoryView.ContentHeight = yPos;
        }
Esempio n. 3
0
        private void PopulatePrefixDropDown()
        {
            prefixList.ClearContent();
            float yPos = Spacing;

            foreach (Item item in validPrefixes)
            {
                UILabel label = new UILabel(Lang.prefix[item.prefix].Value);
                if (item.prefix == 0)
                {
                    label.Text = "No Prefix";
                }
                label.Scale        = .4f;
                label.X            = Spacing;
                label.Y            = yPos;
                label.Tag          = item;
                label.onLeftClick += label_onLeftClick;
                label.onHover     += label_onHover;
                yPos += label.Height;
                if (rarityColors.ContainsKey(item.rare))
                {
                    label.ForegroundColor = rarityColors[item.rare];
                }
                if (item.rare > 11)
                {
                    label.ForegroundColor = rarityColors[11];
                }
                prefixList.AddChild(label);
            }
            prefixList.ContentHeight = yPos + Spacing;
        }
Esempio n. 4
0
 public void RefreshGroupPermissions()
 {
     checkboxContainer.ClearContent();
     for (int i = 0; i < HEROsModNetwork.Group.PermissionList.Count; i++)
     {
         UICheckbox cb = new UICheckbox(HEROsModNetwork.Group.PermissionList[i].Description);
         cb.Selected = HEROsModNetwork.Network.Groups[dropdown.SelectedItem].HasPermission(HEROsModNetwork.Group.PermissionList[i].Key);
         checkboxContainer.AddChild(cb);
         int index = i;
         cb.X = spacing + index % 2 * (Width / 2);
         cb.Y = index / 2 * (cb.Height) + spacing;
     }
     if (checkboxContainer.ChildCount > 0)
     {
         checkboxContainer.ContentHeight = checkboxContainer.GetLastChild().Y + checkboxContainer.GetLastChild().Height + spacing;
     }
 }
Esempio n. 5
0
        internal void BuildList()
        {
            scrollView.ClearContent();
            float yPos = Spacing;

            for (int i = 0; i < searchResults.Count; i++)
            {
                UILabel label = new UILabel(searchResults[i].Name);
                label.Tag           = i;
                label.Scale         = .35f;
                label.X             = Spacing;
                label.Y             = yPos;
                yPos               += label.Height;
                label.onLeftClick  += label_onLeftClick;
                label.onMouseEnter += label_onMouseEnter;
                label.onMouseLeave += label_onMouseLeave;
                scrollView.AddChild(label);
            }
            scrollView.ContentHeight = yPos + Spacing;
        }
Esempio n. 6
0
        public PlayerGroupSelectionWindow(Region region, string title, bool addingPlayer)
        {
            CenterToParent();
            this.CanMove            = true;
            this._region            = region;
            UIView.exclusiveControl = this;
            UILabel      lTitle     = new UILabel(title);
            UIScrollView scrollView = new UIScrollView();
            UIButton     bCancel    = new UIButton(HEROsMod.HeroText("Cancel"));

            lTitle.X     = Spacing;
            lTitle.Y     = Spacing;
            lTitle.Scale = .6f;

            scrollView.X = lTitle.X;
            scrollView.Y = lTitle.Y + lTitle.Height + SmallSpacing;

            scrollView.Width  = 300;
            scrollView.Height = 350;

            bCancel.X            = scrollView.X + scrollView.Width - bCancel.Width;
            bCancel.Y            = scrollView.Y + scrollView.Height + Spacing;
            bCancel.onLeftClick += bCancel_onLeftClick;

            this.Anchor = AnchorPosition.Center;
            this.Width  = scrollView.Width + Spacing * 2;
            this.Height = bCancel.Y + bCancel.Height + Spacing;
            this.X      = Main.screenWidth / 2;
            this.Y      = Main.screenHeight / 2;

            AddChild(lTitle);
            AddChild(scrollView);
            AddChild(bCancel);

            float yPos = Spacing;

            if (addingPlayer)
            {
                for (int i = 0; i < Network.RegisteredUsers.Count; i++)
                {
                    UserWithID user      = Network.RegisteredUsers[i];
                    UILabel    userLabel = new UILabel(user.Username);
                    userLabel.Tag          = user.ID;
                    userLabel.X            = Spacing;
                    userLabel.Y            = yPos;
                    userLabel.Scale        = .35f;
                    yPos                  += userLabel.Height;
                    userLabel.onLeftClick += userLabel_onLeftClick;
                    scrollView.AddChild(userLabel);
                }
            }
            else
            {
                for (int i = 0; i < Network.Groups.Count; i++)
                {
                    Group   group      = Network.Groups[i];
                    UILabel groupLabel = new UILabel(group.Name);
                    groupLabel.Tag          = group.ID;
                    groupLabel.X            = Spacing;
                    groupLabel.Y            = yPos;
                    groupLabel.Scale        = .35f;
                    yPos                   += groupLabel.Height;
                    groupLabel.onLeftClick += groupLabel_onLeftClick;
                    scrollView.AddChild(groupLabel);
                }
            }
            scrollView.ContentHeight = yPos + Spacing;
        }
Esempio n. 7
0
        public void PopulateRegionsList()
        {
            scrollView.ClearContent();

            bCreateRegion.Visible  = true;
            bDeleteRegion.Visible  = false;
            bAddGroup.Visible      = false;
            bAddPlayer.Visible     = false;
            bBack.Visible          = false;
            colorSlider.Visible    = false;
            bSaveColor.Visible     = false;
            bProtectChests.Visible = false;

            SelectedRegion = null;

            float yPos = Spacing;

            for (int i = 0; i < HEROsModNetwork.Network.Regions.Count; i++)
            {
                HEROsModNetwork.Region region = HEROsModNetwork.Network.Regions[i];
                UIButton bEdit = new UIButton(Language.GetTextValue("LegacyInterface.48"));                 // "Edit"
                UIRect   bg    = new UIRect();
                bg.X      = LargeSpacing;
                bg.Y      = yPos;
                bg.Height = bEdit.Height + SmallSpacing * 2;
                bg.Width  = scrollView.Width - 20 - LargeSpacing * 2;

                yPos += bg.Height;

                bg.ForegroundColor = i % 2 == 0 ? Color.Transparent : Color.Blue * .1f;

                UILabel label = new UILabel(region.Name);
                label.X     = Spacing;
                label.Y     = Spacing;
                label.Scale = .5f;

                bEdit.X            = bg.Width - bEdit.Width - Spacing;
                bEdit.Y            = SmallSpacing;
                bEdit.Tag          = i;
                bEdit.onLeftClick += bEdit_onLeftClick;

                UIRect regionColor = new UIRect();
                regionColor.ForegroundColor = region.Color;
                regionColor.Height          = bg.Height - Spacing * 2;
                regionColor.Width           = regionColor.Height;
                regionColor.Y = Spacing;

                UILabel lX      = new UILabel("X: " + region.X);
                UILabel lY      = new UILabel("Y: " + region.Y);
                UILabel lWidth  = new UILabel("Width: " + region.Width);
                UILabel lHeight = new UILabel("Height: " + region.Height);

                lX.Scale      = .35f;
                lY.Scale      = lX.Scale;
                lWidth.Scale  = lX.Scale;
                lHeight.Scale = lX.Scale;

                lWidth.X  = bEdit.X - 100;
                lHeight.X = lWidth.X;
                lHeight.Y = bg.Height - lHeight.Height;

                lX.X = lWidth.X - 75;
                lY.X = lX.X;
                lX.Y = lWidth.Y;
                lY.Y = lHeight.Y;

                regionColor.X = lX.X - regionColor.Width - Spacing;

                bg.AddChild(label);
                bg.AddChild(bEdit);
                bg.AddChild(lX);
                bg.AddChild(lY);
                bg.AddChild(lWidth);
                bg.AddChild(lHeight);
                bg.AddChild(regionColor);

                scrollView.AddChild(bg);
            }
            scrollView.ContentHeight = yPos + Spacing;
        }
Esempio n. 8
0
        public void UpdateList()
        {
            scrollView.ClearContent();
            float yPos = spacing;

            for (int i = 0; i < Main.player.Length; i++)
            {
                Player player = Main.player[i];
                if (player.active)
                {
                    UIPlayerHead playerHead = new UIPlayerHead(player);
                    playerHead.X = 8;
                    playerHead.Y = yPos;
                    yPos        += playerHead.Height;
                    UILabel label = new UILabel(player.name);
                    label.Scale        = .5f;
                    label.Anchor       = AnchorPosition.Left;
                    label.X            = playerHead.X + playerHead.Width + 8;
                    label.Y            = playerHead.Y + playerHead.Width / 2 + 8;
                    label.onLeftClick += label_onLeftClick;
                    label.Tag          = i;

                    scrollView.AddChild(playerHead);
                    scrollView.AddChild(label);
                }
            }
            // TODO changes to offline users might not prop to all admin?
            if (HEROsModNetwork.LoginService.MyGroup.IsAdmin)
            {
                UILabel lOfflinePlayers = new UILabel("Offline Users");
                lOfflinePlayers.Scale           = .6f;
                lOfflinePlayers.X               = Spacing;
                lOfflinePlayers.Y               = yPos + Spacing;
                lOfflinePlayers.ForegroundColor = Microsoft.Xna.Framework.Color.Yellow;
                yPos = lOfflinePlayers.Y + lOfflinePlayers.Height;
                scrollView.AddChild(lOfflinePlayers);
                for (int i = 0; i < HEROsModNetwork.Network.RegisteredUsers.Count; i++)
                {
                    HEROsModNetwork.UserWithID user = HEROsModNetwork.Network.RegisteredUsers[i];
                    //ErrorLogger.Log("? " + user.ID);
                    //foreach (var item in HEROsModNetwork.Network.Players)
                    //{
                    //	ErrorLogger.Log("U" + item.ID);
                    //}
                    if (HEROsModNetwork.Network.Players.Any(x => x.ID == user.ID))
                    {
                        //	ErrorLogger.Log("Continue on " + user.ID);
                        continue;
                    }
                    UILabel lUser = new UILabel(user.Username);
                    lUser.Scale           = .5f;
                    lUser.X               = 40 + Spacing * 2;
                    lUser.Y               = yPos;
                    lUser.ForegroundColor = new Microsoft.Xna.Framework.Color(200, 200, 200);
                    yPos += lUser.Height;
                    lUser.onLeftClick += lUser_onLeftClick;
                    lUser.Tag          = user.ID;
                    scrollView.AddChild(lUser);
                }
            }


            scrollView.ContentHeight = yPos + spacing;
        }
Esempio n. 9
0
        private void LoadDataToChapterPanel()
        {
            List <ChapterMapConfigsData> chapterMaps = MapModule.Instance.GetChapterModeConfigs();

            if (chapterMaps == null || chapterMaps.Count <= 0)
            {
                return;
            }

            UserModule userModule = UserModule.Instance;

            List <Button>     chapterSelectedBtns = new List <Button>(chapterMaps.Count);
            List <GameObject> smallChapterPanels  = new List <GameObject>(chapterMaps.Count);

            m_chapterModels = new Dictionary <int, KeyValuePair <UIChapterNoBtnModel, List <UIMapItemModel> > >(chapterMaps.Count);

            foreach (ChapterMapConfigsData data in chapterMaps)
            {
                // 生成选择按钮
                GameObject selectedBtnGo = GameObject.Instantiate <GameObject>(ChapterSelectedBtnPrefab, ChapterSelectedContent.transform);

                // 保存预制体的Button脚本
                UIChapterNoBtn      selectedChapterNoBtn = selectedBtnGo.GetComponent <UIChapterNoBtn>();
                UIChapterNoBtnModel chapterNoBtnModel    = new UIChapterNoBtnModel(data.chapterNo, userModule.IsChapterUnlocked(data.chapterNo));
                selectedChapterNoBtn.SetModel(chapterNoBtnModel);
                chapterSelectedBtns.Add(selectedBtnGo.GetComponent <Button>());

                // 保存章节按钮和小章节的映射
                List <UIMapItemModel> uiMapItemModels = new List <UIMapItemModel>(data.chapterConfigs.Count);
                KeyValuePair <UIChapterNoBtnModel, List <UIMapItemModel> > chapterModelKV = new KeyValuePair <UIChapterNoBtnModel, List <UIMapItemModel> >(chapterNoBtnModel, uiMapItemModels);
                m_chapterModels.Add(data.chapterNo, chapterModelKV);

                // 生成小章节面板
                GameObject smallChapterPanelGo = GameObject.Instantiate <GameObject>(SmallChapterPanelPrefab, SmallChapterRootPanel.transform);
                smallChapterPanels.Add(smallChapterPanelGo);

                // 获取小章节面板的滚动脚本
                UIScrollView smallChapterScrollView = GameObjectUtils.EnsureComponent <UIScrollView>(smallChapterPanelGo);

                // 添加数据到小章节面板
                foreach (MapConfigData mapData in data.chapterConfigs)
                {
                    GameObject mapItem = GameObject.Instantiate <GameObject>(ChapterMapItemPrefab);
                    smallChapterScrollView.AddChild(mapItem);

                    // 保存小章节数据的model
                    UIMapItemModel mapItemModel = new UIMapItemModel(mapData, userModule.IsChapterUnlocked(data.chapterNo, mapData.no));
                    SetDataToMapItem(mapItem, mapItemModel);
                    uiMapItemModels.Add(mapItemModel);
                }
            }

            UIDynamicLabelBtnGroup chapterBtnGroup = GameObjectUtils.EnsureComponent <UIDynamicLabelBtnGroup>(ChapterSelectedContent);

            chapterBtnGroup.Init(chapterSelectedBtns, (int index) =>
            {
                UIDynamicPanelGroup panelGroup = SmallChapterRootPanel.GetComponent <UIDynamicPanelGroup>();
                if (panelGroup == null)
                {
                    return;
                }

                panelGroup.ActivePanel(index);
            });

            UIDynamicPanelGroup smallChapterPanelGroup = GameObjectUtils.EnsureComponent <UIDynamicPanelGroup>(SmallChapterRootPanel.gameObject);

            smallChapterPanelGroup.Init(smallChapterPanels);
        }
Esempio n. 10
0
        public BuffWindow()
        {
            this.CanMove = true;
            UILabel lTitle   = new UILabel(HEROsMod.HeroText("Buffs"));
            UILabel lSeconds = new UILabel(HEROsMod.HeroText("Seconds"));

            tbSeconds = new UITextbox();
            UIScrollView scrollView = new UIScrollView();
            UIImage      bClose     = new UIImage(closeTexture);

            lTitle.Scale          = .6f;
            lTitle.X              = Spacing;
            lTitle.Y              = Spacing;
            lTitle.OverridesMouse = false;

            bClose.Y            = Spacing;
            bClose.onLeftClick += bClose_onLeftClick;

            tbSeconds.Text          = "60";
            tbSeconds.Numeric       = true;
            tbSeconds.MaxCharacters = 5;
            tbSeconds.Width         = 75;
            tbSeconds.Y             = lTitle.Y + lTitle.Height;

            scrollView.X      = lTitle.X;
            scrollView.Y      = tbSeconds.Y + tbSeconds.Height + Spacing;
            scrollView.Width  = 300;
            scrollView.Height = 250;

            float yPos = Spacing;

            for (int i = 0; i < Main.debuff.Length /*BuffService.Buffs.Length*/; i++)
            {
                if ((Main.debuff[i] && i != BuffID.Wet) || Main.lightPet[i] || Main.vanityPet[i] || i == 0 || BuffService.SkipBuffs.Contains(i))
                {
                    continue;
                }
                //if (i >= BuffID.Count) ;
                int buffType = i;                /*BuffService.Buffs[i];*/

                UIRect bg = new UIRect();
                bg.ForegroundColor = i % 2 == 0 ? Color.Transparent : Color.Blue * .1f;
                bg.X     = Spacing;
                bg.Y     = yPos;
                bg.Width = scrollView.Width - 20 - Spacing * 2;
                bg.Tag   = buffType;
                string buffDescription = Lang.GetBuffDescription(buffType);
                bg.Tooltip      = (buffDescription == null ? "" : buffDescription);
                bg.onLeftClick += bg_onLeftClick;

                UIImage buffImage = new UIImage(Main.buffTexture[buffType]);
                buffImage.X = Spacing;
                buffImage.Y = SmallSpacing / 2;
                buffImage.OverridesMouse = false;

                bg.Height = buffImage.Height + SmallSpacing;
                yPos     += bg.Height;

                UILabel label = new UILabel(Lang.GetBuffName(buffType));
                label.Scale          = .4f;
                label.Anchor         = AnchorPosition.Left;
                label.X              = buffImage.X + buffImage.Width + Spacing;
                label.Y              = buffImage.Y + buffImage.Height / 2;
                label.OverridesMouse = false;

                bg.AddChild(buffImage);
                bg.AddChild(label);
                scrollView.AddChild(bg);
            }

            scrollView.ContentHeight = yPos;

            this.Width  = scrollView.X + scrollView.Width + Spacing;
            this.Height = scrollView.Y + scrollView.Height + Spacing;

            tbSeconds.X = Width - tbSeconds.Width - Spacing;
            bClose.X    = Width - bClose.Width - Spacing;

            lSeconds.Scale  = .4f;
            lSeconds.Anchor = AnchorPosition.Right;
            lSeconds.X      = tbSeconds.X - Spacing;
            lSeconds.Y      = tbSeconds.Y + tbSeconds.Height / 2;

            AddChild(lTitle);
            AddChild(lSeconds);
            AddChild(tbSeconds);
            AddChild(scrollView);
            AddChild(bClose);
        }