Esempio n. 1
0
        public UserDisplayPanel(ParentComponent parent, User user, int index)
            : base(parent, new Rectangle())
        {
            this.user = user;
            this.UpdateBounds(index);
            Boolean enabled = false;
            if (user.id == ChatServerConnectionManager.GetInstance().user.id) enabled = true;

            readyCheckBox = new XNACheckBox(this, new Rectangle(10, 10, 20, 20), "");
            readyCheckBox.onClickListeners += this.OnReadyChanged;
            readyCheckBox.enabled = enabled;
            // readyCheckBox

            usernameLbl = new XNALabel(this, new Rectangle(40, 5, 230, 30), user.username);
            usernameLbl.font = MenuManager.BIG_TEXTFIELD_FONT;

            teamDropdown = new XNADropdown(this, new Rectangle(280, 5, 50, 30));
            teamDropdown.dropdownLineSpace = 15;
            teamDropdown.arrowSize = 8;
            teamDropdown.onOptionSelectedChangedListeners += this.OnTeamChanged;
            for (int i = 0; i < 8; i++) teamDropdown.AddOption((i + 1) + "");
            teamDropdown.enabled = enabled;

            colorDropdown = new XNADropdown(this, new Rectangle(340, 5, 50, 30));
            colorDropdown.dropdownLineSpace = 15;
            colorDropdown.arrowSize = 8;
            for (int i = 0; i < colors.Length; i++)
            {
                colorDropdown.AddOption("");
                colorDropdown.SetBackgroundColor(i + 1, colors[i]);
            }
            colorDropdown.onOptionSelectedChangedListeners += this.OnColorChanged;
            colorDropdown.enabled = enabled;

            kickBtn = new XNAButton(this, new Rectangle(400, 5, 75, 30), "Kick");
            kickBtn.visible = false;

            if (((GameLobby)MenuManager.GetInstance().GetCurrentlyDisplayedMenu()).IsCurrentUserHost() &&
                this.user.id != ChatServerConnectionManager.GetInstance().user.id)
            {
                kickBtn.visible = true;
                kickBtn.onClickListeners += this.OnKickButtonPressed;
            }

            if (this.user.id == 1)
            {
                // Wotuu
                this.SelectColor(1);
                this.readyCheckBox.selected = true;
                this.teamDropdown.SelectItem(0);
            }
            else if (this.user.id == 2)
            {
                this.SelectColor(3);
                this.readyCheckBox.selected = true;
                this.teamDropdown.SelectItem(1);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// When the ready state changed.
 /// </summary>
 /// <param name="source">The source, bla</param>
 public void OnReadyChanged(XNACheckBox source)
 {
     Packet p = new Packet(Headers.GAME_READY_CHANGED);
     p.AddInt(user.channelID);
     p.AddInt(user.id);
     // 1 for true, 0 for false.
     p.AddInt(this.readyCheckBox.selected ? 1 : 0);
     ChatServerConnectionManager.GetInstance().SendPacket(p);
 }