コード例 #1
0
ファイル: GroupInspector.cs プロジェクト: xPanini/HEROsMod
        public void RefreshGroupList()
        {
            int prevNumOfGroups = dropdown.ItemCount;
            int prevSelected    = dropdown.SelectedItem;

            dropdown.ClearItems();
            for (int i = 0; i < HEROsModNetwork.Network.Groups.Count; i++)
            {
                dropdown.AddItem(HEROsModNetwork.Network.Groups[i].Name);
            }
            if (dropdown.ItemCount == prevNumOfGroups)
            {
                dropdown.SelectedItem = prevSelected;
            }
            RefreshGroupPermissions();
        }
コード例 #2
0
        public TestUI(UIStyle style, GraphicsDevice graphicsDevice)
        {
            UISystem = new UISystem(graphicsDevice);
            // panel 1
            UIPanel panel = new UIPanel(25, 25, 150, 150, hastitle: true, title: "Test Panel 1", titlesize: 16);

            UISystem.Add(panel);

            UILabel label1 = new UILabel(0, 0, panel.Width - 10, 10, "text goes here let's see if it will wrap automatically, which it should if everything is working properly.", fontsize: 12,
                                         font: "NotoSans_regular"); // test spritefont

            panel.AddAuto(label1);

            // panel 2
            UIPanel panel2 = new UIPanel(225, 25, 150, 150, hastitle: true, title: "Test Panel 2", titlesize: 16);

            UISystem.Add(panel2);

            UIButton button1 = new UIButton(5, 5, 75, 25, "Test Button");

            panel2.AddAuto(button1);

            UICheckbox chk1 = new UICheckbox(5, 40, 20, 20);

            panel2.Add(chk1);
            UILabel chk1label = new UILabel(30, 40, 100, 20, "unchecked");

            panel2.Add(chk1label);
            chk1.EventCheckChanged += (sender, args) =>
            {
                if (chk1.Checked)
                {
                    chk1label.Text = "checked";
                }
                else
                {
                    chk1label.Text = "unchecked";
                }
                chk1label.ProcessText();
            };


            // panel 3
            UIPanel panel3 = new UIPanel(425, 25, 150, 150, hastitle: true, title: "Test Panel 3", titlesize: 12);

            UISystem.Add(panel3);

            UITextField textfield1 = new UITextField(5, 5, 135, 25, "", fontsize: 16, placeholdertext: "Try Typing...");

            panel3.AddAuto(textfield1);

            UINumberField numfield1 = new UINumberField(5, 5, 135, 35, 40, "0", true, fontsize: 16);

            panel3.AddAuto(numfield1);

            UINumberField numfield2 = new UINumberField(5, 5, 135, 35, 40, "0.0", false, fontsize: 16);

            panel3.AddAuto(numfield2);

            // panel 4
            UIPanel panel4 = new UIPanel(625, 25, 150, 150, hastitle: true, title: "Test Panel 4", titlesize: 14);

            UISystem.Add(panel4);

            UILabel label2 = new UILabel(0, 0, panel4.Width - 10, 10, "text goes here let's see if it will wrap automatically, which it should if everything is working properly.", fontsize: 18);

            label2.TextSplitWords = true;
            panel4.AddAuto(label2);
            UILabel label3 = new UILabel(0, 10, panel4.Width - 10, 10, "A second auto-label. This gal should automatically get cut off when it goes too long", fontsize: 16);

            label3.TextSplitWords = true;
            panel4.AddAuto(label3);

            // panel 5
            UIPanel panel5 = new UIPanel(25, 200, 150, 150, true, "Dropdown Test");

            UISystem.Add(panel5);

            UIDropdown drop1 = new UIDropdown(0, 0, 80, 30, "droptest");

            drop1.AddItem("log A", (uid, args) => { drop1.Text = "AAAA"; drop1.ProcessText(); });
            drop1.AddItem("log B", (uid, args) => { drop1.Text = "BBBB"; drop1.ProcessText(); });
            panel5.AddAuto(drop1);

            // panel 6
            UIPanel panel6 = new UIPanel(200, 200, 150, 150, true, "Scroll Vert Test", hasscrolling: true, scrollh: 400);

            UISystem.Add(panel6);
            UILabel label4 = new UILabel(0, 10, panel6.Width - 20, 350, "newlines \n should be auto processed 1\n 2\n 3\n 4\n 5\n test the bottom \n test", fontsize: 16);

            panel6.AddAuto(label4);

            // panel 7
            UIPanel panel7 = new UIPanel(400, 200, 150, 150, true, "Scroll Horz Test", hasscrolling: true, scrollw: 400);

            UISystem.Add(panel7);
            UILabel label5 = new UILabel(0, 10, panel7.ScrollWidth - 10, 10, "a very long bit a text. It just goes on and on and doesn't end. A very long line that should be much smaller. But it's not, it's very large, instead.", fontsize: 18);

            panel7.AddAuto(label5);

            // panel 8
            UIPanel panel8 = new UIPanel(600, 200, 150, 150, true, "Dialogs Test");

            UISystem.Add(panel8);
            UIButton popupbtn = new UIButton(0, 0, 100, 30, "pop up");

            panel8.AddAuto(popupbtn);
            UIButton filebtn = new UIButton(0, 0, 100, 30, "open file");

            panel8.AddAuto(filebtn);

            popupbtn.EventFocused += (sender, args) =>
            {
                UIComponent.EventFocusedHandlerArgs eargs = args as UIComponent.EventFocusedHandlerArgs;
                DialogPopup popup = new DialogPopup("Popup", "time elapsed: " + eargs.ElapsedMS);
                popup.Popup(UISystem);
                popup.EventClosed += (innersender, innerargs) =>
                {
                    popup.Dispose();
                };
            };
            filebtn.EventFocused += (sender, args) =>
            {
                UIComponent.EventFocusedHandlerArgs eargs = args as UIComponent.EventFocusedHandlerArgs;
                DialogFile filepopup = new DialogFile(DialogFile.eMode.SELECT_FILE, ".\\", "file.txt", "Select a File");
                filepopup.Popup(UISystem);
                filepopup.EventClosed += (innersender, innerargs) =>
                {
                    filepopup.Dispose();
                };
            };

            // panel 9
            UIPanel panel9 = new UIPanel(100, 350, 220, 100);

            UISystem.Add(panel9);
            UITextField multiLineText = new UITextField(0, 0, 200, 80, "", autoheight: false, placeholdertext: "try typing multi lines", fontsize: 11)
            {
                MultiLine = true
            };

            multiLineText.SetTextStyler(new TextStylerTest());
            panel9.Add(multiLineText);

            // panel 10
            UIPanel panel10 = new UIPanel(20, 20, 400, 400, true, "RelaScript", titlesize: 12, hasclose: true);

            panel10.CloseButton.EventFocused += (sender, eargs) =>
            {
                panel10.Visible = false;
            };
            UISystem.Add(panel10);
            UITextField relaMultiText = new UITextField(5, 5, 380, 350, "", autoheight: false,
                                                        fontsize: 18, font: "NotoMono-Regular")
            {
                MultiLine = true
            };

            relaMultiText.EventPostInit += (sender, eargs) =>
            {
                relaMultiText.TextColor = new Microsoft.Xna.Framework.Color(218, 218, 218, 255);
            };
            relaMultiText.SetTextStyler(new TextStylerRelaScript());
            panel10.Add(relaMultiText);

            UISystem.Init(style);
        }
コード例 #3
0
ファイル: PlayerList.cs プロジェクト: tadhgmister/HEROsMod
        public PlayerInfo(int playerIndex, bool offlineUser)
        {
            if (!offlineUser)
            {
                this.player = HEROsModNetwork.Network.Players[playerIndex];
            }
            this.playerIndex           = playerIndex;
            this.UpdateWhenOutOfBounds = true;
            Width = 350;
            UIImage     bClose      = new UIImage(closeTexture);
            UILabel     lGroup      = new UILabel("Group:");
            UIButton    bBan        = new UIButton("Ban");
            UIButton    bKick       = new UIButton("Kick");
            UILabel     label       = new UILabel();
            SnoopWindow snoopWindow = new SnoopWindow();

            snoopWindow.SetPlayer(Main.player[0]);
            dropdown = new UIDropdown();
            UIButton bTeleport = new UIButton("Teleport To");
            UIButton bRestore  = new UIButton("Restore Changes Made by this Player");

            bTeleport.AutoSize = false;
            bTeleport.Width    = 150;
            bRestore.AutoSize  = false;


            // if logged in
            if (player != null && player.Username.Length > 0)
            {
                dropdown.AddItem(HEROsModNetwork.Network.AdminGroup.Name);
                for (int i = 0; i < HEROsModNetwork.Network.Groups.Count; i++)
                {
                    dropdown.AddItem(HEROsModNetwork.Network.Groups[i].Name);
                    if (player.Group.Name == HEROsModNetwork.Network.Groups[i].Name)
                    {
                        dropdown.SelectedItem = i + 1;
                    }
                }
            }
            else if (player == null)
            {
                HEROsModNetwork.UserWithID user = HEROsModNetwork.Network.RegisteredUsers[playerIndex];
                dropdown.AddItem(HEROsModNetwork.Network.AdminGroup.Name);
                for (int i = 0; i < HEROsModNetwork.Network.Groups.Count; i++)
                {
                    dropdown.AddItem(HEROsModNetwork.Network.Groups[i].Name);

                    if (user.groupID == HEROsModNetwork.Network.Groups[i].ID)
                    {
                        dropdown.SelectedItem = i + 1;
                    }
                }
            }
            dropdown.selectedChanged += dropdown_selectedChanged;

            bClose.Y       = spacing;
            lGroup.Scale   = .5f;
            lGroup.X       = spacing;
            lGroup.Y       = spacing;
            dropdown.X     = lGroup.X + lGroup.Width + 4;
            dropdown.Y     = lGroup.Y;
            dropdown.Width = 200;
            dropdown.UpdateWhenOutOfBounds = true;
            if (player != null && player.Username.Length > 0)
            {
                label.Text = "Logged in as " + player.Username;
            }
            else
            {
                label.Text = "Not Logged In";
            }
            label.X     = spacing;
            label.Y     = dropdown.Y + dropdown.Height + spacing;
            label.Scale = .35f;
            bBan.X      = label.X;
            bBan.Y      = label.Y + label.Height + spacing;
            bKick.X     = bBan.X + bBan.Width + spacing;
            bKick.Y     = bBan.Y;

            bTeleport.X = Width - bTeleport.Width - spacing;
            bTeleport.Y = bBan.Y;

            bRestore.X = Spacing;
            bRestore.Y = bTeleport.Y + bTeleport.Height + spacing;

            snoopWindow.X = bRestore.X;
            snoopWindow.Y = bRestore.Y + bRestore.Height + spacing;

            Width  = bTeleport.X + bTeleport.Width + spacing;
            Height = bRestore.Y + bRestore.Height + spacing;

            bRestore.Width = Width - spacing * 2;

            AddChild(bClose);
            AddChild(label);
            HEROsModNetwork.Group myGroup = HEROsModNetwork.LoginService.MyGroup;
            if (!offlineUser)
            {
                if (myGroup.HasPermission("TeleportToPlayers"))
                {
                    AddChild(bTeleport);
                }
                if (myGroup.HasPermission("Ban"))
                {
                    AddChild(bBan);
                }
                if (myGroup.HasPermission("Kick"))
                {
                    AddChild(bKick);
                }
                if (myGroup.HasPermission("Snoop"))
                {
                    snoopWindow.SetPlayer(Main.player[playerIndex]);
                    AddChild(snoopWindow);
                    Width  = snoopWindow.X + snoopWindow.Width + spacing * 2;
                    Height = snoopWindow.Y + snoopWindow.Height + spacing * 2;
                }
            }
            if (myGroup.IsAdmin)
            {
                AddChild(lGroup);
                AddChild(dropdown);
                if (offlineUser || player != null && player.Username.Length > 0)
                {
                    //AddChild(bRestore);
                }
            }
            bBan.Tag  = Main.player[playerIndex].name;
            bKick.Tag = Main.player[playerIndex].name;

            bClose.X               = Width - bClose.Width - spacing;
            bKick.onLeftClick     += bKick_onLeftClick;
            bBan.onLeftClick      += bBan_onLeftClick;
            bClose.onLeftClick    += bClose_onLeftClick;
            bTeleport.onLeftClick += bTeleport_onLeftClick;
            bRestore.onLeftClick  += bRestore_onLeftClick;
        }