def __init__(self): super().__init__() self.setWindowTitle('Cuneiform') self.setStyleSheet('background-color:#343434') self.setCentralWidget(QWidget(self)) self.hbox = QHBoxLayout() self.centralWidget().setLayout(self.hbox) self.hbox.addWidget(Toolbar(parent=self)) self.setFixedSize(WIDTH, HEIGHT)
def __init__(self, resolution, host, port, username, password, split="\n"): global network_log self.log = Log('client') network_log = Log('network') # must have at least one handler self.log.logger.addHandler(logging.NullHandler()) network_log.logger.addHandler(logging.NullHandler()) # opengl must be initialized first self.log.info("Initializing display (windowed at %(resolution)s)", dict(resolution='%dx%d' % resolution)) self._screen = pygame.display.set_mode(resolution, OPENGL | DOUBLEBUF) pygame.display.set_caption('yamosg') self.log.debug( "OpenGL setup (version=\"%(version)s\", vendor=\"%(vendor)s\")", dict(version=glGetString(GL_VERSION), vendor=glGetString(GL_VENDOR))) setup_opengl() Client.cursor_default = pygame.cursors.arrow Client.cursor_capture = pygame.cursors.diamond self._resolution = Vector2i(resolution) self._username = username self._password = password self._split = split self._running = False self._state = StateManager() self._game = GameWidget(self, self._resolution) self._container = Composite(Vector2i(0, 0), self._resolution, children=[self._game]) self._toolbar = Toolbar(self._game) self._window = VBox() self._window.add(self._toolbar, size=LayoutAttachment(Vector2i(1, 0), Vector2i(0, 25))) self._window.add(self._container) self._state.push(GameState(self._resolution, self._window)) self._network = Network(self, host, port) self._command_store = {} self._command_queue = [] self._command_lock = threading.Lock() self._playerid = None self._players = {} self._capture_position = None self._timer = 0 # resizing must be done after state has been created so the event is propagated proper. self._resize(self._resolution)
def _init_ui(self): """ UI initialization. """ self.menubar = Menubar() self.login = LoginForm() self.toolbar = Toolbar(self.app) self.content = Content(self.app, self.login, self.toolbar, self.menubar, self.impartus) self.colorschemes = ColorSchemes() callbacks_functions = { 'authentication_callback': partial(self.content.show_video_callback, self.impartus), 'auto_organize_callback': self.content.auto_organize, 'set_display_columns_callback': self.content.set_display_columns, 'set_colorscheme_callback': self.colorschemes.set_colorscheme, } self.menubar.add_menu(self.app, callbacks_functions) self.toolbar.add_toolbar(self.app, callbacks_functions) self.login.add_login_form( self.app, partial(self.content.show_video_callback, self.impartus)) self.app.rowconfigure(0, weight=0) self.app.rowconfigure(1, weight=0) self.app.rowconfigure(2, weight=1) # register all the components for colorscheme updates. for comp in [self, self.content, self.toolbar, self.login]: self.colorschemes.register_component(comp) # set default color scheme. cs_configs = Config.load(ConfigType.COLORSCHEMES) default_cs = cs_configs[cs_configs['default']] self.colorschemes.set_colorscheme(default_cs) self.app.mainloop()