Example #1
0
        /// <summary>
        /// joins/leaves selected lobby
        /// </summary>
        /// <param name="action">true = join; false = leave</param>
        /// <param name="index">lobby index</param>
        internal CheckState JoinLeaveChatLobby(JoinLeaveAction action, int index)
        {
            CheckState   state = CheckState.Unchecked;
            GuiChatLobby cl    = new GuiChatLobby();

            if (GetLobbyByListIndex(index, out cl))
            {
                if ((action == JoinLeaveAction.join || action == JoinLeaveAction.toggle) && !cl.Joined) // join lobby
                {
                    _b.RPC.ChatJoinLeaveLobby(RequestJoinOrLeaveLobby.LobbyAction.JOIN_OR_ACCEPT, cl.ID);
                    cl.Joined            = true;
                    cl.Lobby.lobby_state = ChatLobbyInfo.LobbyState.LOBBYSTATE_JOINED;
                    state = CheckState.Checked;
                }
                else if ((action == JoinLeaveAction.leave || action == JoinLeaveAction.toggle) && cl.Joined) // leave lobby
                {
                    _b.RPC.ChatJoinLeaveLobby(RequestJoinOrLeaveLobby.LobbyAction.LEAVE_OR_DENY, cl.ID);
                    cl.Joined            = false;
                    cl.Lobby.lobby_state = ChatLobbyInfo.LobbyState.LOBBYSTATE_VISIBLE;
                    state = CheckState.Unchecked;
                }

                // save changes
                _chatLobbies[cl.ID] = cl;
                CheckChatRegistration();
            }
            return(state);
        }
Example #2
0
        /// <summary>
        /// joins/leaves selected lobby
        /// </summary>
        /// <param name="action">true = join; false = leave</param>
        /// <param name="index">lobby index</param>
        internal CheckState JoinLeaveChatLobby(JoinLeaveAction action, int index)
        {
            CheckState state = CheckState.Unchecked;
            GuiChatLobby cl = new GuiChatLobby();
            if (GetLobbyByListIndex(index, out cl))
            {
                if ((action == JoinLeaveAction.join || action == JoinLeaveAction.toggle) && !cl.Joined) // join lobby
                {
                    _b.RPC.ChatJoinLeaveLobby(RequestJoinOrLeaveLobby.LobbyAction.JOIN_OR_ACCEPT, cl.ID);
                    cl.Joined = true;
                    cl.Lobby.lobby_state = ChatLobbyInfo.LobbyState.LOBBYSTATE_JOINED;
                    state = CheckState.Checked;
                }
                else if ((action == JoinLeaveAction.leave || action == JoinLeaveAction.toggle) && cl.Joined) // leave lobby
                {
                    _b.RPC.ChatJoinLeaveLobby(RequestJoinOrLeaveLobby.LobbyAction.LEAVE_OR_DENY, cl.ID);
                    cl.Joined = false;
                    cl.Lobby.lobby_state = ChatLobbyInfo.LobbyState.LOBBYSTATE_VISIBLE;
                    state = CheckState.Unchecked;
                }

                // save changes
                _chatLobbies[cl.ID] = cl;
                CheckChatRegistration();
            }
            return state;
        }