mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
refactor: moved the game status to a global file (accessible to the render part) and used it in game entity
This commit is contained in:
parent
c6e4ba4789
commit
6fa4c178a7
10
src/globals.ts
Normal file
10
src/globals.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export enum GameStatus {
|
||||||
|
Seeding = "seeding",
|
||||||
|
Downloading = "downloading",
|
||||||
|
Paused = "paused",
|
||||||
|
CheckingFiles = "checking_files",
|
||||||
|
DownloadingMetadata = "downloading_metadata",
|
||||||
|
Cancelled = "cancelled",
|
||||||
|
Finished = "finished",
|
||||||
|
Decompressing = "decompressing",
|
||||||
|
}
|
@ -34,15 +34,6 @@ export const months = [
|
|||||||
"Dec",
|
"Dec",
|
||||||
];
|
];
|
||||||
|
|
||||||
export enum GameStatus {
|
|
||||||
Seeding = "seeding",
|
|
||||||
Downloading = "downloading",
|
|
||||||
Paused = "paused",
|
|
||||||
CheckingFiles = "checking_files",
|
|
||||||
DownloadingMetadata = "downloading_metadata",
|
|
||||||
Cancelled = "cancelled",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultDownloadsPath = path.join(os.homedir(), "downloads");
|
export const defaultDownloadsPath = path.join(os.homedir(), "downloads");
|
||||||
|
|
||||||
export const databasePath = path.join(
|
export const databasePath = path.join(
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import type { GameShop } from "@types";
|
import type { GameShop } from "@types";
|
||||||
import { Repack } from "./repack.entity";
|
import { Repack } from "./repack.entity";
|
||||||
|
import { GameStatus } from "@globals";
|
||||||
|
|
||||||
@Entity("game")
|
@Entity("game")
|
||||||
export class Game {
|
export class Game {
|
||||||
@ -40,7 +41,7 @@ export class Game {
|
|||||||
shop: GameShop;
|
shop: GameShop;
|
||||||
|
|
||||||
@Column("text", { nullable: true })
|
@Column("text", { nullable: true })
|
||||||
status: string;
|
status: GameStatus | "";
|
||||||
|
|
||||||
@Column("float", { default: 0 })
|
@Column("float", { default: 0 })
|
||||||
progress: number;
|
progress: number;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { gameRepository } from "@main/repository";
|
import { gameRepository } from "@main/repository";
|
||||||
import { GameStatus } from "@main/constants";
|
|
||||||
|
|
||||||
import { searchRepacks } from "../helpers/search-games";
|
import { searchRepacks } from "../helpers/search-games";
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import sortBy from "lodash/sortBy";
|
import sortBy from "lodash/sortBy";
|
||||||
|
import { GameStatus } from "@globals";
|
||||||
|
|
||||||
const getLibrary = async (_event: Electron.IpcMainInvokeEvent) =>
|
const getLibrary = async (_event: Electron.IpcMainInvokeEvent) =>
|
||||||
gameRepository
|
gameRepository
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { GameStatus } from "@main/constants";
|
|
||||||
import { gameRepository } from "@main/repository";
|
import { gameRepository } from "@main/repository";
|
||||||
|
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import { WindowManager, writePipe } from "@main/services";
|
import { WindowManager, writePipe } from "@main/services";
|
||||||
|
|
||||||
import { In } from "typeorm";
|
import { In } from "typeorm";
|
||||||
|
import { GameStatus } from "@globals";
|
||||||
|
|
||||||
const cancelGameDownload = async (
|
const cancelGameDownload = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
|
|
||||||
import { GameStatus } from "@main/constants";
|
import { GameStatus } from "@globals";
|
||||||
import { gameRepository } from "@main/repository";
|
import { gameRepository } from "@main/repository";
|
||||||
|
|
||||||
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { WindowManager, writePipe } from "@main/services";
|
import { WindowManager, writePipe } from "@main/services";
|
||||||
|
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import { GameStatus } from "../../constants";
|
|
||||||
import { gameRepository } from "../../repository";
|
import { gameRepository } from "../../repository";
|
||||||
import { In } from "typeorm";
|
import { In } from "typeorm";
|
||||||
|
import { GameStatus } from "@globals";
|
||||||
|
|
||||||
const pauseGameDownload = async (
|
const pauseGameDownload = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { GameStatus } from "@main/constants";
|
import { GameStatus } from "@globals";
|
||||||
import { gameRepository } from "@main/repository";
|
import { gameRepository } from "@main/repository";
|
||||||
|
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import { GameStatus } from "../../constants";
|
|
||||||
import { gameRepository } from "../../repository";
|
import { gameRepository } from "../../repository";
|
||||||
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
||||||
import { In } from "typeorm";
|
import { In } from "typeorm";
|
||||||
import { writePipe } from "@main/services";
|
import { writePipe } from "@main/services";
|
||||||
|
import { GameStatus } from "@globals";
|
||||||
|
|
||||||
const resumeGameDownload = async (
|
const resumeGameDownload = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { getSteamGameIconUrl, writePipe } from "@main/services";
|
import { getSteamGameIconUrl, writePipe } from "@main/services";
|
||||||
import { gameRepository, repackRepository } from "@main/repository";
|
import { gameRepository, repackRepository } from "@main/repository";
|
||||||
import { GameStatus } from "@main/constants";
|
|
||||||
|
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
|
|
||||||
import type { GameShop } from "@types";
|
import type { GameShop } from "@types";
|
||||||
import { getImageBase64 } from "@main/helpers";
|
import { getImageBase64 } from "@main/helpers";
|
||||||
import { In } from "typeorm";
|
import { In } from "typeorm";
|
||||||
|
import { GameStatus } from "@globals";
|
||||||
|
|
||||||
const startGameDownload = async (
|
const startGameDownload = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { stateManager } from "./state-manager";
|
import { stateManager } from "./state-manager";
|
||||||
import { GameStatus, repackers } from "./constants";
|
import { repackers } from "./constants";
|
||||||
import {
|
import {
|
||||||
getNewGOGGames,
|
getNewGOGGames,
|
||||||
getNewRepacksFromCPG,
|
getNewRepacksFromCPG,
|
||||||
@ -22,6 +22,7 @@ import { Repack } from "./entity";
|
|||||||
import { Notification } from "electron";
|
import { Notification } from "electron";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import { In } from "typeorm";
|
import { In } from "typeorm";
|
||||||
|
import { GameStatus } from "@globals";
|
||||||
|
|
||||||
startProcessWatcher();
|
startProcessWatcher();
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { GameStatus } from "@globals";
|
||||||
|
|
||||||
export type GameShop = "steam" | "epic";
|
export type GameShop = "steam" | "epic";
|
||||||
export type CatalogueCategory = "recently_added" | "trending";
|
export type CatalogueCategory = "recently_added" | "trending";
|
||||||
|
|
||||||
@ -75,7 +77,7 @@ export interface Game extends Omit<CatalogueEntry, "cover"> {
|
|||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
iconUrl: string;
|
iconUrl: string;
|
||||||
status: string;
|
status: GameStatus | "";
|
||||||
folderName: string;
|
folderName: string;
|
||||||
downloadPath: string | null;
|
downloadPath: string | null;
|
||||||
repacks: GameRepack[];
|
repacks: GameRepack[];
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
"@main/*": ["src/main/*"],
|
"@main/*": ["src/main/*"],
|
||||||
"@renderer/*": ["src/renderer/*"],
|
"@renderer/*": ["src/renderer/*"],
|
||||||
"@types": ["src/types/index.ts"],
|
"@types": ["src/types/index.ts"],
|
||||||
"@locales": ["src/locales/index.ts"]
|
"@locales": ["src/locales/index.ts"],
|
||||||
|
"@globals": ["src/globals.ts"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"]
|
"include": ["src/**/*"]
|
||||||
|
Loading…
Reference in New Issue
Block a user