1
0
Fork 0
mirror of synced 2024-06-29 11:40:37 +12:00
Rare/rare/models/install.py
loathingKernel 4063195b4d DownloadsTab: Refactor downloads tab
When updates are queued, they are removed from the update's list. An exceptions is made
when the queued item comes from repairing (without updating), in which case the update is
disabled for the runtime.

A queued item can be either removed (if it is an update it will be added back to the
updates groups) or forced to be updated now. If a queued item is forced, the currently
running item will be added to the front of the queue. Downloads will be queued if
there is no active download but there is a queue already.

The download thread is now responsible for emitting the progress to `RareGame`

InstallDialog: Pass `RareGame` and `InstallOptionsModel` only as arguments.
The `update`, `repair` and `silent` arguments are already part of `InstallOptionsModel`
`RareGame` is used to query information about the game.

InstallInfoWorker: Pass only `InstallOptionsModel` as argument
Emit `InstallQueueItemModel` as result, to re-use the worker when queuing stopped games

RareGame: Query and store metadata property about entitlement grant date
RareGame: Add `RareEosOverlay` class that imitates `RareGame` to handle the overlay

LibraryWidgetController: Remove dead signal routing code, these signals are handled by `RareGame`
Directly parent library widgets instead of reparenting them

GameWidgets: Remove unused signals

EOSGroup: Set install location based on preferences and use EOSOverlayApp from legendary

GamesTab: Connect the `progress` signals of dlcs to the base game's signals
GamesTab: Remove dead code

GlobalSignals: Remove `ProgresSignals`

RareCore: Mangle internal signleton's names

Signed-off-by: loathingKernel <142770+loathingKernel@users.noreply.github.com>
2023-02-04 17:38:07 +02:00

66 lines
1.8 KiB
Python

import os
import platform as pf
from dataclasses import dataclass
from typing import List, Optional, Callable, Dict
from legendary.models.downloading import AnalysisResult, ConditionCheckResult
from legendary.models.game import Game, InstalledGame
from rare.lgndr.downloader.mp.manager import DLManager
@dataclass
class InstallOptionsModel:
app_name: str
base_path: str = ""
shared_memory: int = 1024
max_workers: int = os.cpu_count() * 2
force: bool = False
platform: str = "Windows"
install_tag: Optional[List[str]] = None
order_opt: bool = False
repair_mode: bool = False
repair_and_update: bool = False
no_install: bool = False
ignore_space: bool = False
skip_dlcs: bool = False
with_dlcs: bool = False
# Rare's internal arguments
# FIXME: Do we really need all of these?
create_shortcut: bool = True
overlay: bool = False
update: bool = False
silent: bool = False
install_prereqs: bool = pf.system() == "Windows"
def __post_init__(self):
self.sdl_prompt: Callable[[str, str], list] = \
lambda app_name, title: self.install_tag if self.install_tag is not None else [""]
def as_install_kwargs(self) -> Dict:
return {
k: getattr(self, k)
for k in self.__dict__
if k not in ["update", "silent", "create_shortcut", "overlay", "install_prereqs"]
}
@dataclass
class InstallDownloadModel:
dlm: DLManager
analysis: AnalysisResult
igame: InstalledGame
game: Game
repair: bool
repair_file: str
res: ConditionCheckResult
@dataclass
class InstallQueueItemModel:
options: Optional[InstallOptionsModel] = None
download: Optional[InstallDownloadModel] = None
def __bool__(self):
return (self.download is not None) and (self.options is not None)