def send_chat_message(self):
     """
     Sends a chat message.
     """
     chat_message = self.chat_input_edit.text()
     local_network_client.send(constants.C.CHAT, constants.M.CHAT_MESSAGE, chat_message)
     self.chat_input_edit.setText('')
Exemple #2
0
 def send_chat_message(self):
     """
     Sends a chat message.
     """
     chat_message = self.chat_input_edit.text()
     local_network_client.send(constants.C.CHAT, constants.M.CHAT_MESSAGE,
                               chat_message)
     self.chat_input_edit.setText('')
    def cleanup(self, parent_widget):
        """
        User wants to close the dialog

        :param parent_widget:
        """
        local_network_client.send(constants.C.CHAT, constants.M.CHAT_UNSUBSCRIBE)
        local_network_client.disconnect_from_channel(constants.C.CHAT, self.receive_chat_messages)

        local_network_client.disconnect_from_channel(constants.C.LOBBY, self.receive_lobby_messages)

        return True
    def __init__(self):
        """

        """
        super().__init__()
        self.setTitle('Select Scenario')
        self.layout = QtWidgets.QVBoxLayout(self)

        # add a channel for us
        local_network_client.connect_to_channel(constants.C.LOBBY, self.received_titles)

        # send message and ask for scenario titles
        local_network_client.send(constants.C.LOBBY, constants.M.LOBBY_SCENARIO_CORE_LIST)
    def __init__(self, scenario_file):
        """
            Given a scenario file name, get the preview from the server.
        """
        # TODO move the network communication outside this class.
        super().__init__()

        # add a channel for us
        local_network_client.connect_to_channel(constants.C.LOBBY, self.received_preview)

        # send a message and ask for preview
        local_network_client.send(constants.C.LOBBY, constants.M.LOBBY_SCENARIO_PREVIEW, scenario_file)

        self.selected_nation = None
Exemple #6
0
    def __init__(self):
        """

        """
        super().__init__()
        self.setTitle('Select Scenario')
        self.layout = QtWidgets.QVBoxLayout(self)

        # add a channel for us
        local_network_client.connect_to_channel(constants.C.LOBBY,
                                                self.received_titles)

        # send message and ask for scenario titles
        local_network_client.send(constants.C.LOBBY,
                                  constants.M.LOBBY_SCENARIO_CORE_LIST)
Exemple #7
0
    def cleanup(self, parent_widget):
        """
        User wants to close the dialog

        :param parent_widget:
        """
        local_network_client.send(constants.C.CHAT,
                                  constants.M.CHAT_UNSUBSCRIBE)
        local_network_client.disconnect_from_channel(
            constants.C.CHAT, self.receive_chat_messages)

        local_network_client.disconnect_from_channel(
            constants.C.LOBBY, self.receive_lobby_messages)

        return True
Exemple #8
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        layout = QtWidgets.QHBoxLayout(self)

        self.client_list_widget = QtWidgets.QListWidget()
        #       list.itemSelectionChanged.connect(self.selection_changed)
        #       list.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.client_list_widget.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self.client_list_widget.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAsNeeded)
        self.client_list_widget.setFixedWidth(200)
        layout.addWidget(
            qt.wrap_in_groupbox(self.client_list_widget, 'Players'))

        self.chat_log_text_edit = QtWidgets.QTextEdit()
        self.chat_log_text_edit.setEnabled(False)
        chat_log_group = qt.wrap_in_groupbox(self.chat_log_text_edit,
                                             'Chat log')

        self.chat_input_edit = QtWidgets.QLineEdit()
        self.chat_input_edit.returnPressed.connect(self.send_chat_message)
        chat_input_group = qt.wrap_in_groupbox(self.chat_input_edit,
                                               'Chat input')
        layout.addLayout(qt.wrap_in_boxlayout(
            (chat_log_group, chat_input_group),
            horizontal=False,
            add_stretch=False),
                         stretch=1)

        # connection to server

        # chat messages
        local_network_client.connect_to_channel(constants.C.CHAT,
                                                self.receive_chat_messages)
        local_network_client.send(constants.C.CHAT, constants.M.CHAT_SUBSCRIBE)

        # LOBBY
        local_network_client.connect_to_channel(constants.C.LOBBY,
                                                self.receive_lobby_messages)
        self.request_updated_client_list()

        # set timer for connected client updates
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.request_updated_client_list)
        self.timer.setInterval(5000)
        self.timer.start()
Exemple #9
0
    def __init__(self, scenario_file):
        """
            Given a scenario file name, get the preview from the server.
        """
        # TODO move the network communication outside this class.
        super().__init__()

        # add a channel for us
        local_network_client.connect_to_channel(constants.C.LOBBY,
                                                self.received_preview)

        # send a message and ask for preview
        local_network_client.send(constants.C.LOBBY,
                                  constants.M.LOBBY_SCENARIO_PREVIEW,
                                  scenario_file)

        self.selected_nation = None
Exemple #10
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        layout = QtWidgets.QHBoxLayout(self)

        self.client_list_widget = QtWidgets.QListWidget()
#       list.itemSelectionChanged.connect(self.selection_changed)
#       list.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.client_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.client_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.client_list_widget.setFixedWidth(200)
        layout.addWidget(qt.wrap_in_groupbox(self.client_list_widget, 'Players'))

        self.chat_log_text_edit = QtWidgets.QTextEdit()
        self.chat_log_text_edit.setEnabled(False)
        chat_log_group = qt.wrap_in_groupbox(self.chat_log_text_edit, 'Chat log')

        self.chat_input_edit = QtWidgets.QLineEdit()
        self.chat_input_edit.returnPressed.connect(self.send_chat_message)
        chat_input_group = qt.wrap_in_groupbox(self.chat_input_edit, 'Chat input')
        layout.addLayout(qt.wrap_in_boxlayout((chat_log_group, chat_input_group), horizontal=False, add_stretch=False),
                         stretch=1)

        # connection to server

        # chat messages
        local_network_client.connect_to_channel(constants.C.CHAT, self.receive_chat_messages)
        local_network_client.send(constants.C.CHAT, constants.M.CHAT_SUBSCRIBE)

        # LOBBY
        local_network_client.connect_to_channel(constants.C.LOBBY, self.receive_lobby_messages)
        self.request_updated_client_list()

        # set timer for connected client updates
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.request_updated_client_list)
        self.timer.setInterval(5000)
        self.timer.start()
Exemple #11
0
 def request_updated_client_list(self):
     """
     Sends a request to get an updated connected client list.
     """
     local_network_client.send(constants.C.LOBBY,
                               constants.M.LOBBY_CONNECTED_CLIENTS)
Exemple #12
0
 def request_monitor_update(self):
     """
     Sends a request for an update of the system monitor.
     """
     local_network_client.send(constants.C.SYSTEM, constants.M.SYSTEM_MONITOR_UPDATE)
Exemple #13
0
 def request_monitor_update(self):
     """
     Sends a request for an update of the system monitor.
     """
     local_network_client.send(constants.C.SYSTEM,
                               constants.M.SYSTEM_MONITOR_UPDATE)
Exemple #14
0
 def request_updated_client_list(self):
     """
     Sends a request to get an updated connected client list.
     """
     local_network_client.send(constants.C.LOBBY, constants.M.LOBBY_CONNECTED_CLIENTS)