Exemplo n.º 1
0
    def _load_variant_2(
        self, variant_uuid, database_name, personal_rating, have
    ):
        if LauncherConfig.get("variant_uuid") == variant_uuid:
            print("Variant {} is already loaded".format(variant_uuid))
        game_database = fsgs.game_database(database_name)

        # game_database_client = GameDatabaseClient(game_database)
        # try:
        #     variant_id = game_database_client.get_game_id(variant_uuid)
        # except Exception:
        #     # game not found:
        #     print("could not find game", repr(variant_uuid))
        #     Config.load_default_config()
        #     return
        # values = game_database_client.get_final_game_values(variant_id)
        try:
            values = game_database.get_game_values_for_uuid(variant_uuid)
        except Exception:
            # game not found:
            traceback.print_exc()
            print("could not find game", repr(variant_uuid))
            LauncherConfig.load_default_config()
            return

        # values["variant_uuid"] = variant_uuid
        # values["variant_rating"] = str(item["personal_rating"])

        LauncherConfig.load_values(values, uuid=variant_uuid)

        # print("--->", LauncherConfig.get("variant_uuid"))

        # variant_rating = 0
        # if item["work_rating"] is not None:
        #     variant_rating = item["work_rating"] - 2
        # if item["like_rating"]:
        #     variant_rating = item["like_rating"]
        # Config.set("__variant_rating", str(variant_rating))

        # LauncherConfig.set("variant_uuid", variant_uuid)
        LauncherConfig.set("__changed", "0")
        LauncherConfig.set("__database", database_name)

        LauncherSettings.set("__variant_rating", str(personal_rating))

        if int(have) < self.AVAILABLE:
            print(" -- some files are missing --")
            LauncherConfig.set("x_missing_files", "1")
Exemplo n.º 2
0
    def _load_variant_2(self, variant_uuid, database_name, personal_rating,
                        have):
        if LauncherConfig.get("variant_uuid") == variant_uuid:
            print("Variant {} is already loaded".format(variant_uuid))
        game_database = fsgs.game_database(database_name)

        # game_database_client = GameDatabaseClient(game_database)
        # try:
        #     variant_id = game_database_client.get_game_id(variant_uuid)
        # except Exception:
        #     # game not found:
        #     print("could not find game", repr(variant_uuid))
        #     Config.load_default_config()
        #     return
        # values = game_database_client.get_final_game_values(variant_id)
        try:
            values = game_database.get_game_values_for_uuid(variant_uuid)
        except Exception:
            # game not found:
            traceback.print_exc()
            print("could not find game", repr(variant_uuid))
            LauncherConfig.load_default_config()
            return

        # values["variant_uuid"] = variant_uuid
        # values["variant_rating"] = str(item["personal_rating"])

        LauncherConfig.load_values(values, uuid=variant_uuid)

        # print("--->", LauncherConfig.get("variant_uuid"))

        # variant_rating = 0
        # if item["work_rating"] is not None:
        #     variant_rating = item["work_rating"] - 2
        # if item["like_rating"]:
        #     variant_rating = item["like_rating"]
        # Config.set("__variant_rating", str(variant_rating))

        # LauncherConfig.set("variant_uuid", variant_uuid)
        LauncherConfig.set("__changed", "0")
        LauncherConfig.set("__database", database_name)

        LauncherSettings.set("__variant_rating", str(personal_rating))

        if int(have) < self.AVAILABLE:
            print(" -- some files are missing --")
            LauncherConfig.set("x_missing_files", "1")
    def update_list(self, game_uuid):
        print("VariantsBrowser.update_list, game_uuid=", game_uuid)
        database = Database.get_instance()
        items = database.find_game_variants_new(game_uuid, have=0)

        # items = database.search_configurations(self.search)
        sortable_items = []
        for i, item in enumerate(items):
            name = item["name"]

            name = name.replace("\nAmiga \u00b7 ", "\n")
            # print(name, item[3])
            # name = name.replace("\nCD32 \u00b7 ", "\n")
            # name = item[1].replace("\n", " \u00b7 ")

            # only show variant name (without game name)
            name = name.split("\n", 1)[-1]

            game_database = fsgs.game_database(item["database"])
            item["like_rating"], item["work_rating"] = game_database\
                .get_ratings_for_game(item["uuid"])
            item["personal_rating"], ignored = database.get_ratings_for_game(
                item["uuid"])

            sort_key = (0, 1000000 - item["like_rating"],
                        1000000 - item["work_rating"], name)
            sortable_items.append(
                (sort_key, i, item))
        # print(sortable_items)
        self.items = [x[2] for x in sorted(sortable_items)]
        self.update()
        # self.set_items(self.items)
        # self.set_item_count(len(self.items))

        self.select_item(None, signal=False)

        select_index = None
        list_uuid = LauncherSettings.get("game_list_uuid")
        if list_uuid:
            list_variant_uuid = database.get_variant_for_list_and_game(
                list_uuid, game_uuid)
            print("game list", list_uuid, "override variant",
                  list_variant_uuid)
        else:
            list_variant_uuid = None
        if list_variant_uuid:
            # override variant selection from list if possible
            for i, item in enumerate(self.items):
                print(item["uuid"], item["name"], list_variant_uuid)
                if item["uuid"] == list_variant_uuid:
                    select_index = i
                    print("override select index", select_index)
                    break
        if select_index is None:
            # default index selection
            for i, item in enumerate(self.items):
                if item["personal_rating"] == 5:
                    select_index = i
                    break
            else:
                for i, item in enumerate(self.items):
                    if item["have"] >= 3:
                        select_index = i
                        break
                else:
                    for i, item in enumerate(self.items):
                        if item["have"] >= 1:
                            select_index = i
                            break
                    else:
                        if len(self.items) > 0:
                            select_index = 0

        # self.clear()
        # for i, item in enumerate(self.items):
        #     self.add_item(item["name"], icon=self.get_item_icon(i))

        self.enable(len(self.items) > 0)
        if select_index is not None:
            print("selecting variant index", select_index)
            self.select_item(select_index)
        else:
            ConfigGroup.new_config()
Exemplo n.º 4
0
    def update_list(self, game_uuid):
        print("VariantsBrowser.update_list, game_uuid=", game_uuid)
        database = Database.get_instance()
        items = database.find_game_variants_new(game_uuid, have=0)

        # items = database.search_configurations(self.search)
        # FIXME: Merge code with
        # FSGameSystemContext.py:get_ordered_game_variants
        sortable_items = []
        for i, variant in enumerate(items):
            name = variant["name"]
            # assert "\n" not in name
            # only show variant name (without game name)
            # name = name.split("\n", 1)[-1]

            game_database = fsgs.game_database(variant["database"])
            variant["like_rating"], variant[
                "work_rating"] = game_database.get_ratings_for_game(
                    variant["uuid"])
            variant[
                "personal_rating"], ignored = database.get_ratings_for_game(
                    variant["uuid"])

            if variant["published"] == 0:
                primary_sort = 1
                variant["name"] = "[UNPUBLISHED] " + variant["name"]
            else:
                primary_sort = 0
            sort_key = (
                primary_sort,
                1000000 - variant["like_rating"],
                1000000 - variant["work_rating"],
                name,
            )
            sortable_items.append((sort_key, i, variant))
        # print(sortable_items)
        self.items = [x[2] for x in sorted(sortable_items)]
        self.update()
        # self.set_items(self.items)
        # self.set_item_count(len(self.items))

        self.select_item(None, signal=False)

        select_index = None
        list_uuid = LauncherSettings.get("game_list_uuid")
        if list_uuid:
            list_variant_uuid = database.get_variant_for_list_and_game(
                list_uuid, game_uuid)
            print("game list", list_uuid, "override variant",
                  list_variant_uuid)
        else:
            list_variant_uuid = None
        if list_variant_uuid:
            # override variant selection from list if possible
            for i, variant in enumerate(self.items):
                print(variant["uuid"], variant["name"], list_variant_uuid)
                if variant["uuid"] == list_variant_uuid:
                    select_index = i
                    print("override select index", select_index)
                    break
        if select_index is None:
            # default index selection
            for i, variant in enumerate(self.items):
                if variant["personal_rating"] == 5:
                    if variant["have"] >= 3:
                        select_index = i
                        break
                    else:
                        # FIXME: Add warning here that the favorite variant
                        # could not be selected.
                        pass
            else:
                for i, variant in enumerate(self.items):
                    if variant["have"] >= 3:
                        select_index = i
                        break
                else:
                    for i, variant in enumerate(self.items):
                        if variant["have"] >= 1:
                            select_index = i
                            break
                    else:
                        if len(self.items) > 0:
                            select_index = 0

        # self.clear()
        # for i, variant in enumerate(self.items):
        #     self.add_item(variant["name"], icon=self.get_item_icon(i))

        self.enable(len(self.items) > 0)
        if select_index is not None:
            print("selecting variant index", select_index)
            self.select_item(select_index)
        else:
            ConfigGroup.new_config()
Exemplo n.º 5
0
    def update_list(self, game_uuid):
        print("VariantsBrowser.update_list, game_uuid=", game_uuid)
        database = Database.get_instance()
        items = database.find_game_variants_new(game_uuid, have=0)

        # items = database.search_configurations(self.search)
        # FIXME: Merge code with
        # FSGameSystemContext.py:get_ordered_game_variants
        sortable_items = []
        for i, variant in enumerate(items):
            name = variant["name"]
            # assert "\n" not in name
            # only show variant name (without game name)
            # name = name.split("\n", 1)[-1]

            game_database = fsgs.game_database(variant["database"])
            variant["like_rating"], variant[
                "work_rating"
            ] = game_database.get_ratings_for_game(variant["uuid"])
            variant[
                "personal_rating"
            ], ignored = database.get_ratings_for_game(variant["uuid"])

            if variant["published"] == 0:
                primary_sort = 1
                variant["name"] = "[UNPUBLISHED] " + variant["name"]
            else:
                primary_sort = 0
            sort_key = (
                primary_sort,
                1000000 - variant["like_rating"],
                1000000 - variant["work_rating"],
                name,
            )
            sortable_items.append((sort_key, i, variant))
        # print(sortable_items)
        self.items = [x[2] for x in sorted(sortable_items)]
        self.update()
        # self.set_items(self.items)
        # self.set_item_count(len(self.items))

        self.select_item(None, signal=False)

        select_index = None
        list_uuid = LauncherSettings.get("game_list_uuid")
        if list_uuid:
            list_variant_uuid = database.get_variant_for_list_and_game(
                list_uuid, game_uuid
            )
            print(
                "game list", list_uuid, "override variant", list_variant_uuid
            )
        else:
            list_variant_uuid = None
        if list_variant_uuid:
            # override variant selection from list if possible
            for i, variant in enumerate(self.items):
                print(variant["uuid"], variant["name"], list_variant_uuid)
                if variant["uuid"] == list_variant_uuid:
                    select_index = i
                    print("override select index", select_index)
                    break
        if select_index is None:
            # default index selection
            for i, variant in enumerate(self.items):
                if variant["personal_rating"] == 5:
                    if variant["have"] >= 3:
                        select_index = i
                        break
                    else:
                        # FIXME: Add warning here that the favorite variant
                        # could not be selected.
                        pass
            else:
                for i, variant in enumerate(self.items):
                    if variant["have"] >= 3:
                        select_index = i
                        break
                else:
                    for i, variant in enumerate(self.items):
                        if variant["have"] >= 1:
                            select_index = i
                            break
                    else:
                        if len(self.items) > 0:
                            select_index = 0

        # self.clear()
        # for i, variant in enumerate(self.items):
        #     self.add_item(variant["name"], icon=self.get_item_icon(i))

        self.enable(len(self.items) > 0)
        if select_index is not None:
            print("selecting variant index", select_index)
            self.select_item(select_index)
        else:
            ConfigGroup.new_config()
Exemplo n.º 6
0
    def update_list(self, game_uuid):
        print("VariantsBrowser.update_list, game_uuid=", game_uuid)
        database = Database.get_instance()
        items = database.find_game_variants_new(game_uuid, have=0)

        # items = database.search_configurations(self.search)
        # FIXME: Merge code with FSGameSystemContext.py
        sortable_items = []
        for i, variant in enumerate(items):
            name = variant["name"]

            name = name.replace("\nAmiga \u00b7 ", "\n")
            # print(name, variant[3])
            # name = name.replace("\nCD32 \u00b7 ", "\n")
            # name = variant[1].replace("\n", " \u00b7 ")

            # only show variant name (without game name)
            name = name.split("\n", 1)[-1]

            game_database = fsgs.game_database(variant["database"])
            variant["like_rating"], variant["work_rating"] = \
                game_database.get_ratings_for_game(variant["uuid"])
            variant["personal_rating"], ignored = \
                database.get_ratings_for_game(variant["uuid"])

            sort_key = (0, 1000000 - variant["like_rating"],
                        1000000 - variant["work_rating"], name)
            sortable_items.append((sort_key, i, variant))
        # print(sortable_items)
        self.items = [x[2] for x in sorted(sortable_items)]
        self.update()
        # self.set_items(self.items)
        # self.set_item_count(len(self.items))

        self.select_item(None, signal=False)

        select_index = None
        list_uuid = LauncherSettings.get("game_list_uuid")
        if list_uuid:
            list_variant_uuid = database.get_variant_for_list_and_game(
                list_uuid, game_uuid)
            print("game list", list_uuid, "override variant",
                  list_variant_uuid)
        else:
            list_variant_uuid = None
        if list_variant_uuid:
            # override variant selection from list if possible
            for i, variant in enumerate(self.items):
                print(variant["uuid"], variant["name"], list_variant_uuid)
                if variant["uuid"] == list_variant_uuid:
                    select_index = i
                    print("override select index", select_index)
                    break
        if select_index is None:
            # default index selection
            for i, variant in enumerate(self.items):
                if variant["personal_rating"] == 5:
                    select_index = i
                    break
            else:
                for i, variant in enumerate(self.items):
                    if variant["have"] >= 3:
                        select_index = i
                        break
                else:
                    for i, variant in enumerate(self.items):
                        if variant["have"] >= 1:
                            select_index = i
                            break
                    else:
                        if len(self.items) > 0:
                            select_index = 0

        # self.clear()
        # for i, variant in enumerate(self.items):
        #     self.add_item(variant["name"], icon=self.get_item_icon(i))

        self.enable(len(self.items) > 0)
        if select_index is not None:
            print("selecting variant index", select_index)
            self.select_item(select_index)
        else:
            ConfigGroup.new_config()