Ejemplo n.º 1
0
from lib.browser import BrowserWidget
import base.tools as t
import base.constants as c
import base.network as net
from base.constants import PropertyKeyNames as k, NationPropertyKeyNames as kn
from client.graphics import MiniMapNationItem
import client.graphics as cg
import client.audio as audio
from client.main_screen import GameMainScreen
from client.editor import EditorScreen

"""
    Starts the client and delivers most of the code reponsible for the main client screen and the diverse dialogs.
"""

network_client = net.NetworkClient()
network_client.set_socket()


class MapItem(QtCore.QObject):
    """
        Holds together a clickable QPixmapItem, a description text and a reference to a label that shows the text

        TODO use signals to show the text instead
    """
    description_change = QtCore.Signal(str)

    def __init__(self, parent, pixmap, label, description):
        super().__init__(parent)
        # store label and description
        self.label = label
    """
    clientA.send(constants.C.CHAT, constants.M.CHAT_MESSAGE, "I'm fine Bob, and you?")

def clientB_chats():
    """
    Client B chats.
    """
    clientB.send(constants.C.CHAT, constants.M.CHAT_MESSAGE, 'Hi Alice, how are you?')

if __name__ == '__main__':
    imperialism_remake.fix_pyqt5_exception_eating()
    imperialism_remake.set_start_directory()

    app = QtCore.QCoreApplication([])

    server_manager = ServerManager()
    clientA = network.NetworkClient()
    clientB = network.NetworkClient()

    # actions
    QtCore.QTimer.singleShot(0, server_manager.start)
    QtCore.QTimer.singleShot(100, clients_connect)
    QtCore.QTimer.singleShot(500, clients_send_names)
    QtCore.QTimer.singleShot(800, clientA_subscribes)
    QtCore.QTimer.singleShot(1000, clientB_chats)
    QtCore.QTimer.singleShot(1200, clientB_subscribes)
    QtCore.QTimer.singleShot(1400, clientA_chats)
    QtCore.QTimer.singleShot(3000, app.quit)

    app.exec_()
Ejemplo n.º 3
0
    """
    Send shutdown message.
    """
    client.send(constants.C.SYSTEM, constants.M.SYSTEM_SHUTDOWN)


if __name__ == '__main__':
    imperialism_remake.fix_pyqt5_exception_eating()
    imperialism_remake.set_start_directory()

    # create server process and start it
    server_process = server.ServerProcess()
    server_process.start()

    # create app in this process
    app = QtCore.QCoreApplication([])

    client = network.NetworkClient()

    # actions
    QtCore.QTimer.singleShot(100, client_connect)
    QtCore.QTimer.singleShot(1000, send)
    QtCore.QTimer.singleShot(2000, send_shutdown)
    QtCore.QTimer.singleShot(3000, app.quit)

    app.exec_()
    print('client app has quit')

    # wait for server
    server_process.join()