Exemplo n.º 1
0
    def __init__(self, core: LegendaryCore):
        super(GameListUninstalled, self).__init__()
        self.core = core
        self.widget = QWidget()
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        self.layout = QVBoxLayout()

        self.filter = QLineEdit()
        self.filter.textChanged.connect(self.filter_games)
        self.filter.setPlaceholderText(self.tr("Filter Games"))
        self.import_button = QPushButton(
            self.tr("Import installed Game from Epic Games Store"))
        self.import_button.clicked.connect(self.import_game)
        self.layout.addWidget(self.filter)
        self.layout.addWidget(self.import_button)
        self.widgets_uninstalled = []
        games = []
        installed = [i.app_name for i in core.get_installed_list()]
        for game in core.get_game_list():
            if not game.app_name in installed:
                games.append(game)
        games = sorted(games, key=lambda x: x.app_title)
        for game in games:
            game_widget = UninstalledGameWidget(game)
            game_widget.finished.connect(lambda: self.reload.emit())
            self.layout.addWidget(game_widget)
            self.widgets_uninstalled.append(game_widget)

        self.layout.addStretch(1)
        self.widget.setLayout(self.layout)
        self.setWidget(self.widget)
Exemplo n.º 2
0
    def __init__(self, parent, core: LegendaryCore):
        super(GameListUninstalled, self).__init__(parent=parent)
        self.widget = QWidget()
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        self.layout = QVBoxLayout()

        self.filter = QLineEdit()
        self.filter.textChanged.connect(self.filter_games)
        self.filter.setPlaceholderText("Filter Games")
        self.layout.addWidget(self.filter)

        self.widgets_uninstalled = []
        games = []
        installed = [i.app_name for i in core.get_installed_list()]
        for game in core.get_game_list():
            if not game.app_name in installed:
                games.append(game)
        games = sorted(games, key=lambda x: x.app_title)
        for game in games:
            game_widget = UninstalledGameWidget(game)
            self.layout.addWidget(game_widget)
            self.widgets_uninstalled.append(game_widget)

        self.layout.addStretch(1)
        self.widget.setLayout(self.layout)
        self.setWidget(self.widget)
Exemplo n.º 3
0
    def __init__(self, core: LegendaryCore):
        super(LaunchDialog, self).__init__()

        self.title = QLabel("<h3>" + self.tr("Launching Rare") + "</h3>")
        self.thread = LaunchThread(core, self)
        self.thread.download_progess.connect(self.update_pb)
        self.thread.action.connect(self.info)
        self.info_pb = QProgressBar()
        self.info_pb.setMaximum(len(core.get_game_list()))
        self.info_text = QLabel(self.tr("Logging in"))
        self.layout = QVBoxLayout()

        self.layout.addWidget(self.title)
        self.layout.addWidget(self.info_pb)
        self.layout.addWidget(self.info_text)

        self.setLayout(self.layout)
        self.thread.start()
Exemplo n.º 4
0
def download_images(signal: pyqtSignal, core: LegendaryCore):
    if not os.path.isdir(IMAGE_DIR):
        os.makedirs(IMAGE_DIR)
        logger.info("Create Image dir")

    # Download Images
    for i, game in enumerate(
            sorted(core.get_game_list(), key=lambda x: x.app_title)):

        if not os.path.isdir(f"{IMAGE_DIR}/" + game.app_name):
            os.mkdir(f"{IMAGE_DIR}/" + game.app_name)

        if not os.path.isfile(f"{IMAGE_DIR}/{game.app_name}/image.json"):
            json_data = {"DieselGameBoxTall": None, "DieselGameBoxLogo": None}
        else:
            json_data = json.load(
                open(f"{IMAGE_DIR}/{game.app_name}/image.json", "r"))

        for image in game.metadata["keyImages"]:
            if image["type"] == "DieselGameBoxTall" or image[
                    "type"] == "DieselGameBoxLogo":

                if json_data[
                        image["type"]] != image["md5"] or not os.path.isfile(
                            f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png"
                        ):
                    # Download
                    json_data[image["type"]] = image["md5"]
                    # os.remove(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png")
                    json.dump(
                        json_data,
                        open(f"{IMAGE_DIR}/{game.app_name}/image.json", "w"))
                    logger.info(f"Download Image for Game: {game.app_title}")
                    url = image["url"]
                    with open(
                            f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png",
                            "wb") as f:
                        f.write(requests.get(url).content)
                        f.close()

        if not os.path.isfile(f'{IMAGE_DIR}/' + game.app_name +
                              '/UninstalledArt.png'):

            if os.path.isfile(f'{IMAGE_DIR}/' + game.app_name +
                              '/DieselGameBoxTall.png'):
                # finalArt = Image.open(f'{IMAGE_DIR}/' + game.app_name + '/DieselGameBoxTall.png')
                # finalArt.save(f'{IMAGE_DIR}/{game.app_name}/FinalArt.png')
                # And same with the grayscale one

                bg = Image.open(
                    f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png")
                uninstalledArt = bg.convert('L')
                uninstalledArt.save(
                    f'{IMAGE_DIR}/{game.app_name}/UninstalledArt.png')
            elif os.path.isfile(
                    f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png"):
                bg: Image.Image = Image.open(
                    f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png")
                bg = bg.resize((int(bg.size[1] * 3 / 4), bg.size[1]))
                logo = Image.open(
                    f'{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png'
                ).convert('RGBA')
                wpercent = ((bg.size[0] * (3 / 4)) / float(logo.size[0]))
                hsize = int((float(logo.size[1]) * float(wpercent)))
                logo = logo.resize((int(bg.size[0] * (3 / 4)), hsize),
                                   Image.ANTIALIAS)
                # Calculate where the image has to be placed
                pasteX = int((bg.size[0] - logo.size[0]) / 2)
                pasteY = int((bg.size[1] - logo.size[1]) / 2)
                # And finally copy the background and paste in the image
                # finalArt = bg.copy()
                # finalArt.paste(logo, (pasteX, pasteY), logo)
                # Write out the file
                # finalArt.save(f'{IMAGE_DIR}/' + game.app_name + '/FinalArt.png')
                logoCopy = logo.copy()
                logoCopy.putalpha(int(256 * 3 / 4))
                logo.paste(logoCopy, logo)
                uninstalledArt = bg.copy()
                uninstalledArt.paste(logo, (pasteX, pasteY), logo)
                uninstalledArt = uninstalledArt.convert('L')
                uninstalledArt.save(f'{IMAGE_DIR}/' + game.app_name +
                                    '/UninstalledArt.png')
            else:
                logger.warning(
                    f"File {IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png dowsn't exist"
                )
        signal.emit(i)