コード例 #1
0
ファイル: gtk.py プロジェクト: skybon/obozrenie
    def cb_info_button_clicked(self, *args):
        """Shows server information window."""
        dialog = self.gtk_widgets["serverinfo-dialog"]

        game_table = self.core.game_table.get_game_table_copy()
        game = self.app.settings.settings_table["common"]["selected-game-connect"]
        server_list_table = game_table[game]["servers"]
        host = self.app.settings.settings_table["common"]["server-host"]
        server_entry_index = helpers.search_dict_table(server_list_table, "host", host)
        if server_entry_index is not None:
            server_entry = server_list_table[server_entry_index]
            player_model = self.gtk_widgets["player-list-model"]
            player_scrolledview = self.gtk_widgets["serverinfo-players-scrolledview"]

            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-name"], server_entry["name"])
            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-host"], server_entry["host"])
            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-game"], game_table[server_entry["game_id"]]["info"]["name"])
            gtk_helpers.set_widget_value(self.gtk_widgets['serverinfo-gameid'], server_entry['game_id'])
            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-terrain"], server_entry["terrain"])
            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-players"], i18n._("%(player_count)s / %(player_limit)s") % {'player_count': str(server_entry["player_count"]), 'player_limit': str(server_entry["player_limit"])})
            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-ping"], server_entry["ping"])

            player_model.clear()
            try:
                player_table = helpers.dict_to_list(server_entry["players"], self.player_list_model_format)
                for entry in player_table:
                    player_model.append(entry)
                player_scrolledview.set_property("visible", True)
            except:
                player_scrolledview.set_property("visible", False)

            dialog.run()
            dialog.hide()
コード例 #2
0
ファイル: gtk.py プロジェクト: fabianod/obozrenie
    def cb_server_connect_data_changed(self, *args):
        """Resets button sensitivity on server connect data change"""
        game = self.app.settings.settings_table["common"][
            "selected-game-connect"]
        try:
            server_list_table = self.core.game_table.get_servers_data(game)
        except (ValueError, KeyError):
            server_list_table = []
        host = self.app.settings.settings_table["common"]["server-host"]
        server_entry_index = helpers.search_dict_table(server_list_table,
                                                       "host", host)

        entry_field = self.gtk_widgets["server-connect-host"]
        info_button = self.gtk_widgets["action-info-button"]
        connect_button = self.gtk_widgets["action-connect-button"]

        if server_entry_index is None:
            info_button.set_property("sensitive", False)
            if gtk_helpers.get_widget_value(entry_field) == '':
                connect_button.set_property("sensitive", False)
            else:
                connect_button.set_property("sensitive", True)
        else:
            info_button.set_property("sensitive", True)
            connect_button.set_property("sensitive", True)
コード例 #3
0
ファイル: gtk.py プロジェクト: fabianod/obozrenie
    def cb_info_button_clicked(self, *args):
        """Shows server information window."""
        dialog = self.gtk_widgets["serverinfo-dialog"]

        game_table = self.core.game_table.get_game_table_copy()
        game = self.app.settings.settings_table["common"][
            "selected-game-connect"]
        server_list_table = game_table[game]["servers"]
        host = self.app.settings.settings_table["common"]["server-host"]
        server_entry_index = helpers.search_dict_table(server_list_table,
                                                       "host", host)
        if server_entry_index is not None:
            server_entry = server_list_table[server_entry_index]
            player_model = self.gtk_widgets["player-list-model"]
            player_scrolledview = self.gtk_widgets[
                "serverinfo-players-scrolledview"]

            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-name"],
                                         server_entry["name"])
            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-host"],
                                         server_entry["host"])
            gtk_helpers.set_widget_value(
                self.gtk_widgets["serverinfo-game"],
                game_table[server_entry["game_id"]]["info"]["name"])
            gtk_helpers.set_widget_value(self.gtk_widgets['serverinfo-gameid'],
                                         server_entry['game_id'])
            gtk_helpers.set_widget_value(
                self.gtk_widgets["serverinfo-terrain"],
                server_entry["terrain"])
            gtk_helpers.set_widget_value(
                self.gtk_widgets["serverinfo-players"],
                i18n._("%(player_count)s / %(player_limit)s") % {
                    'player_count': str(server_entry["player_count"]),
                    'player_limit': str(server_entry["player_limit"])
                })
            gtk_helpers.set_widget_value(self.gtk_widgets["serverinfo-ping"],
                                         server_entry["ping"])

            player_model.clear()
            try:
                player_table = helpers.dict_to_list(
                    server_entry["players"], self.player_list_model_format)
                for entry in player_table:
                    player_model.append(entry)
                player_scrolledview.set_property("visible", True)
            except:
                player_scrolledview.set_property("visible", False)

            dialog.run()
            dialog.hide()
コード例 #4
0
ファイル: core.py プロジェクト: skybon/obozrenie
    def set_server_info(self, game: str, host: str, data) -> None:
        faulty_param = None
        if game in ("", None):
            faulty_param = i18n._("game id")
        elif host in ("", None):
            faulty_param = i18n._("hostname")
        elif isinstance(data, dict) is False:
            faulty_param = i18n._("server data")
        if faulty_param is not None:
            raise ValueError(i18n._("Invalid %(param)s specified.") % {"param": param})

        with self.__game_table as game_table:
            server_entry_index = game_table[helpers.search_dict_table(helpers.deepcopy(game_table), "host", host)]
            if server_entry_index is None:
                self.append_server_info(game, data)
            else:
                game_table[server_entry_index] = data
コード例 #5
0
ファイル: core.py プロジェクト: skybon/obozrenie
    def get_server_info(self, game: str, host: str) -> dict:
        faulty_param = None
        if game in ("", None):
            faulty_param = i18n._("game id")
        elif host in ("", None):
            faulty_param = i18n._("hostname")
        if faulty_param is not None:
            raise ValueError(i18n._("Invalid %(param)s specified.") % {"param": param})

        with self.__game_table as game_table:
            try:
                game_entry = game_table[game]
            except KeyError:
                raise ValueError(i18n._("Game not found: %(game)s") % {"game": game})

            server_table = helpers.deepcopy(game_entry["servers"])
        server_entry = server_table[helpers.search_dict_table(server_table, "host", host)]
        return server_entry
コード例 #6
0
    def set_server_info(self, game: str, host: str, data) -> None:
        faulty_param = None
        if game in ('', None):
            faulty_param = i18n._('game id')
        elif host in ('', None):
            faulty_param = i18n._('hostname')
        elif isinstance(data, dict) is False:
            faulty_param = i18n._('server data')
        if faulty_param is not None:
            raise ValueError(
                i18n._('Invalid %(param)s specified.') % {'param': param})

        with self.__game_table as game_table:
            server_entry_index = game_table[helpers.search_dict_table(
                helpers.deepcopy(game_table), "host", host)]
            if server_entry_index is None:
                self.append_server_info(game, data)
            else:
                game_table[server_entry_index] = data
コード例 #7
0
    def get_server_info(self, game: str, host: str) -> dict:
        faulty_param = None
        if game in ('', None):
            faulty_param = i18n._('game id')
        elif host in ('', None):
            faulty_param = i18n._('hostname')
        if faulty_param is not None:
            raise ValueError(
                i18n._('Invalid %(param)s specified.') % {'param': param})

        with self.__game_table as game_table:
            try:
                game_entry = game_table[game]
            except KeyError:
                raise ValueError(
                    i18n._('Game not found: %(game)s') % {'game': game})

            server_table = helpers.deepcopy(game_entry["servers"])
        server_entry = server_table[helpers.search_dict_table(
            server_table, "host", host)]
        return server_entry
コード例 #8
0
ファイル: gtk.py プロジェクト: skybon/obozrenie
    def cb_server_connect_data_changed(self, *args):
        """Resets button sensitivity on server connect data change"""
        game = self.app.settings.settings_table["common"]["selected-game-connect"]
        try:
            server_list_table = self.core.game_table.get_servers_data(game)
        except (ValueError, KeyError):
            server_list_table = []
        host = self.app.settings.settings_table["common"]["server-host"]
        server_entry_index = helpers.search_dict_table(server_list_table, "host", host)

        entry_field = self.gtk_widgets["server-connect-host"]
        info_button = self.gtk_widgets["action-info-button"]
        connect_button = self.gtk_widgets["action-connect-button"]

        if server_entry_index is None:
            info_button.set_property("sensitive", False)
            if gtk_helpers.get_widget_value(entry_field) == '':
                connect_button.set_property("sensitive", False)
            else:
                connect_button.set_property("sensitive", True)
        else:
            info_button.set_property("sensitive", True)
            connect_button.set_property("sensitive", True)