diff --git a/assets/jsons/patreons.json b/assets/jsons/patreons.json index 9bd6acc1..078f2e36 100644 --- a/assets/jsons/patreons.json +++ b/assets/jsons/patreons.json @@ -142,5 +142,11 @@ { "username": "Arts Rimuro Suraimu", "type": "gold" + }, + { + "username": "Ricardo Boss" + }, + { + "username": "Jesper Norsted" } ] diff --git a/assets/jsons/translations/de.json b/assets/jsons/translations/de.json index 9baa74c0..b608f8a5 100644 --- a/assets/jsons/translations/de.json +++ b/assets/jsons/translations/de.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Name", + "size": "Größe", "installed": "Installiert", "latest": "Neueste", "description": "Beschreibung", @@ -152,6 +153,10 @@ "uninstall-all": "Alle deinstallieren", "unselect-all": "Alle abwählen" } + }, + "mod-item": { + "this-is-a-large-mod": "Das ist ein großer Mod!", + "this-is-a-very-large-mod": "Das ist ein sehr großer Mod!" } }, "notifications": { diff --git a/assets/jsons/translations/en.json b/assets/jsons/translations/en.json index bda50b01..e0580b9a 100644 --- a/assets/jsons/translations/en.json +++ b/assets/jsons/translations/en.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Name", + "size": "Size", "installed": "Installed", "latest": "Latest", "description": "Description", @@ -152,6 +153,10 @@ "uninstall-all": "Uninstall all", "unselect-all": "Unselect all" } + }, + "mod-item":{ + "this-is-a-large-mod": "This is a large mod!", + "this-is-a-very-large-mod": "This is a very large mod!" } }, "notifications": { diff --git a/assets/jsons/translations/es.json b/assets/jsons/translations/es.json index 7a045c3a..e1a01261 100644 --- a/assets/jsons/translations/es.json +++ b/assets/jsons/translations/es.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Nombre", + "size": "Tamaño", "installed": "Instalado", "latest": "Último", "description": "Descripción", @@ -152,6 +153,10 @@ "uninstall-all": "Desinstalar todos", "unselect-all": "Deseleccionar todo" } + }, + "mod-item": { + "this-is-a-large-mod": "¡Este es un mod grande!", + "this-is-a-very-large-mod": "¡Este es un mod muy grande!" } }, "notifications": { diff --git a/assets/jsons/translations/fr.json b/assets/jsons/translations/fr.json index 1e9d4811..32f4b3af 100644 --- a/assets/jsons/translations/fr.json +++ b/assets/jsons/translations/fr.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Nom", + "size": "Taille", "installed": "Installé", "latest": "Récent", "description": "Description", @@ -152,6 +153,10 @@ "uninstall-all": "Tout désinstaller", "unselect-all": "Tout désélectionner" } + }, + "mod-item": { + "this-is-a-large-mod": "C'est un mod volumineux !", + "this-is-a-very-large-mod": "C'est un mod très volumineux !" } }, "notifications": { diff --git a/assets/jsons/translations/it.json b/assets/jsons/translations/it.json index 09d175eb..0cd2277e 100644 --- a/assets/jsons/translations/it.json +++ b/assets/jsons/translations/it.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Nome", + "size": "Dimensione", "installed": "Installata", "latest": "Ultima Versione", "description": "Descrizione", @@ -152,6 +153,10 @@ "uninstall-all": "Disinstalla tutto", "unselect-all": "Deseleziona tutto" } + }, + "mod-item": { + "this-is-a-large-mod": "Questo è un mod grande!", + "this-is-a-very-large-mod": "Questo è un mod molto grande!" } }, "notifications": { diff --git a/assets/jsons/translations/ja.json b/assets/jsons/translations/ja.json index 49c13446..4ab132ff 100644 --- a/assets/jsons/translations/ja.json +++ b/assets/jsons/translations/ja.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "名前", + "size": "サイズ", "installed": "インストール済み", "latest": "最新", "description": "說明", @@ -152,6 +153,10 @@ "uninstall-all": "全てアンインストールする", "unselect-all": "すべて選択解除" } + }, + "mod-item": { + "this-is-a-large-mod": "これは大きなModです!", + "this-is-a-very-large-mod": "これは非常に大きなModです!" } }, "notifications": { diff --git a/assets/jsons/translations/ko.json b/assets/jsons/translations/ko.json index 91054296..53c14586 100644 --- a/assets/jsons/translations/ko.json +++ b/assets/jsons/translations/ko.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "이름", + "size": "크기", "installed": "설치됨", "latest": "최신", "description": "설명", @@ -152,6 +153,10 @@ "uninstall-all": "모두 제거", "unselect-all": "모두 선택 해제" } + }, + "mod-item": { + "this-is-a-large-mod": "이것은 큰 모드입니다!", + "this-is-a-very-large-mod": "이것은 매우 큰 모드입니다!" } }, "notifications": { diff --git a/assets/jsons/translations/pt-br.json b/assets/jsons/translations/pt-br.json index 9ded8bce..40825a4a 100644 --- a/assets/jsons/translations/pt-br.json +++ b/assets/jsons/translations/pt-br.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Nome", + "size": "tamanho", "installed": "Instalado", "latest": "Mais recente", "description": "Descrição", @@ -152,6 +153,10 @@ "uninstall-all": "Desinstalar todos", "unselect-all": "Desmarcar todos" } + }, + "mod-item": { + "this-is-a-large-mod": "Este é um mod grande!", + "this-is-a-very-large-mod": "Este é um mod muito grande!" } }, "notifications": { diff --git a/assets/jsons/translations/ru.json b/assets/jsons/translations/ru.json index d44a5f6e..6ff7342c 100644 --- a/assets/jsons/translations/ru.json +++ b/assets/jsons/translations/ru.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Имя", + "size": "Размер", "installed": "Установлено", "latest": "Latest", "description": "Описание", @@ -152,6 +153,10 @@ "uninstall-all": "Удалить всё", "unselect-all": "Снять все выделения" } + }, + "mod-item": { + "this-is-a-large-mod": "Это большой мод!", + "this-is-a-very-large-mod": "Это очень большой мод!" } }, "notifications": { diff --git a/assets/jsons/translations/tl.json b/assets/jsons/translations/tl.json index 5fb2f246..fc87a679 100644 --- a/assets/jsons/translations/tl.json +++ b/assets/jsons/translations/tl.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Pangalan", + "size": "laki", "installed": "Naka-install", "latest": "Pinakabago", "description": "Deskripsyon", @@ -152,6 +153,10 @@ "uninstall-all": "I-uninstall ang lahat", "unselect-all": "I-unselect and lahat" } + }, + "mod-item": { + "this-is-a-large-mod": "Ito ay isang malaking mod!", + "this-is-a-very-large-mod": "Ito ay isang napakalaking mod!" } }, "notifications": { diff --git a/assets/jsons/translations/uk.json b/assets/jsons/translations/uk.json index c41b3692..c0779323 100644 --- a/assets/jsons/translations/uk.json +++ b/assets/jsons/translations/uk.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "Назва", + "size": "розмір", "installed": "Встановлено", "latest": "Остання", "description": "Опис", @@ -152,6 +153,10 @@ "uninstall-all": "Видалити всі", "unselect-all": "Зняти виділення з всіх" } + }, + "mod-item": { + "this-is-a-large-mod": "Це великий мод!", + "this-is-a-very-large-mod": "Це дуже великий мод!" } }, "notifications": { diff --git a/assets/jsons/translations/zh-tw.json b/assets/jsons/translations/zh-tw.json index f47cdfc0..c967614a 100644 --- a/assets/jsons/translations/zh-tw.json +++ b/assets/jsons/translations/zh-tw.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "名稱", + "size": "大小", "installed": "已安裝", "latest": "最新", "description": "描述", @@ -152,6 +153,10 @@ "uninstall-all": "全部移除", "unselect-all": "取消全選" } + }, + "mod-item": { + "this-is-a-large-mod": "這是一個大型Mod!", + "this-is-a-very-large-mod": "這是一個非常大型的Mod!" } }, "notifications": { diff --git a/assets/jsons/translations/zh.json b/assets/jsons/translations/zh.json index aaf1e5e2..ad9b8354 100644 --- a/assets/jsons/translations/zh.json +++ b/assets/jsons/translations/zh.json @@ -144,6 +144,7 @@ "mods-grid": { "header-bar": { "name": "名称", + "size": "大小", "installed": "已安装", "latest": "最新", "description": "描述", @@ -152,6 +153,10 @@ "uninstall-all": "全部卸载", "unselect-all": "取消全选" } + }, + "mod-item": { + "this-is-a-large-mod": "这是一个大型Mod!", + "this-is-a-very-large-mod": "这是一个非常大型的Mod!" } }, "notifications": { diff --git a/src/main/decorators/log.decorator.ts b/src/main/decorators/log.decorator.ts deleted file mode 100644 index 9c87f932..00000000 --- a/src/main/decorators/log.decorator.ts +++ /dev/null @@ -1,67 +0,0 @@ -import log from "electron-log"; -import { isPromise } from "../../shared/helpers/promise.helpers"; -import { tryit } from "../../shared/helpers/error.helpers"; - -type LogOptions = { - logInput?: boolean; - logOutput?: boolean; - logArgs?: boolean; -}; - -const stringifyArgs = (args: unknown[]) => { - return args?.map(a => JSON.stringify(a)).join(', '); -}; - -const logInfo = (message: string, propertyKey: string, args: unknown[], logArgs: boolean, result: unknown) => { - log.info(`[${message}] ${propertyKey}(${logArgs ? stringifyArgs(args) : ''})`, result); -}; - -const logError = (propertyKey: string, args: unknown[], logArgs: boolean, error: unknown) => { - log.error(`[ERROR] ${propertyKey}(${logArgs ? stringifyArgs(args) : ''})`, error); - throw error; -}; - -export function Log(options?: LogOptions){ - - const logInput = options?.logInput ?? false; - const logOutput = options?.logOutput ?? true; - const logArgs = options?.logArgs ?? true; - - return (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => { - const originalMethod = descriptor.value; - - descriptor.value = function(...args: unknown[]) { - - if (logInput) { - logInfo('INPUT', propertyKey, args, logArgs, null); - } - - const outcome = tryit(() => originalMethod.apply(this, args)); - - if (isPromise(outcome)) { - return outcome.then(({ result, error }) => { - - if (error) { - logError(propertyKey, args, logArgs, error); - } - if (logOutput) { - logInfo('OUTPUT', propertyKey, args, logArgs, result); - } - return result; - }); - } - - const { result, error } = outcome; - - if (error) { - logError(propertyKey, args, logArgs, error); - } - - if (logOutput) { - logInfo('OUTPUT', propertyKey, args, logArgs, result); - } - - return result; - }; - }; -} diff --git a/src/main/helpers/fs.helpers.ts b/src/main/helpers/fs.helpers.ts index a3df7860..2312e1ff 100644 --- a/src/main/helpers/fs.helpers.ts +++ b/src/main/helpers/fs.helpers.ts @@ -3,7 +3,6 @@ import { access, mkdir, readdir, lstat, readlink } from "fs/promises"; import path from "path"; import { Observable, concatMap, from } from "rxjs"; import log from "electron-log"; -import { BsmException } from "shared/models/bsm-exception.model"; import crypto from "crypto"; import { execSync } from "child_process"; import { tryit } from "../../shared/helpers/error.helpers"; @@ -181,7 +180,7 @@ export function isSubdirectory(parent: string, child: string): boolean { export async function copyDirectoryWithJunctions(src: string, dest: string, options?: CopyOptions): Promise { if (isSubdirectory(src, dest)) { - throw { message: `Cannot copy directory '${src}' into itself '${dest}'.`, code: "COPY_TO_SUBPATH" } as BsmException; + throw new CustomError(`Cannot copy directory '${src}' into itself '${dest}'.`, "COPY_TO_SUBPATH"); } await ensureDir(dest); diff --git a/src/main/services/additional-content/maps/song-cache.service.ts b/src/main/services/additional-content/maps/song-cache.service.ts index 751b55d8..26fad375 100644 --- a/src/main/services/additional-content/maps/song-cache.service.ts +++ b/src/main/services/additional-content/maps/song-cache.service.ts @@ -19,7 +19,6 @@ export class SongCacheService { private readonly mapsInfoCache: JsonCache; private constructor(){ - console.log(this.MAPS_INFO_CACHE_PATH); this.mapsInfoCache = new JsonCache(this.MAPS_INFO_CACHE_PATH); } diff --git a/src/renderer/components/version-viewer/slides/mods/mod-item.component.tsx b/src/renderer/components/version-viewer/slides/mods/mod-item.component.tsx index ab8be1dd..309ae883 100644 --- a/src/renderer/components/version-viewer/slides/mods/mod-item.component.tsx +++ b/src/renderer/components/version-viewer/slides/mods/mod-item.component.tsx @@ -7,6 +7,8 @@ import useDoubleClick from "use-double-click"; import { useOnUpdate } from "renderer/hooks/use-on-update.hook"; import striptags from "striptags"; import { safeGt } from "shared/helpers/semver.helpers"; +import Tippy from "@tippyjs/react"; +import { useTranslationV2 } from "renderer/hooks/use-translation.hook"; type Props = { className?: string; @@ -21,6 +23,68 @@ type Props = { onUninstall?: () => void; }; +type FileSizeProps = { + fileSize?: number; + wantInfoStyle: CSSProperties; +}; + +function FileSizeText({ fileSize, wantInfoStyle }: Readonly) { + + const { text: t } = useTranslationV2(); + + const verifyFileSize = fileSize !== undefined; + + const isMediumMod = verifyFileSize && fileSize > 1024 * 1024 * 50; // 50MB + + const isLargeMod = verifyFileSize && fileSize > 1024 * 1024 * 100; // 100MB + + const getFormattedSize = () : string => { + if (!verifyFileSize || fileSize === 0) + return `-`; + if (fileSize < 1024 * 1024) + return `${(fileSize/1024).toFixed(2)}KB`; + return `${(fileSize/1024/1024).toFixed(2)}MB`; + }; + + const getWarningText = () : string => { + if (isLargeMod) + return `pages.version-viewer.mods.mods-grid.mod-item.this-is-a-very-large-mod`; + if (isMediumMod) + return `pages.version-viewer.mods.mods-grid.mod-item.this-is-a-large-mod`; + return ""; + }; + + const getTheme = () : string => { + if (isLargeMod) + return 'red'; + if (isMediumMod) + return 'yellow'; + return ""; + }; + + const getTextColor = () : string => { + if (isLargeMod) + return "text-red-400"; + if (isMediumMod) + return "text-yellow-400"; + return ""; + }; + + return ( + + + + {getFormattedSize()} + + + ); +} + export function ModItem({ className, mod, installedVersion, isDependency, isSelected, onChange, wantInfo, onWantInfo, disabled, onUninstall }: Props) { const themeColor = useThemeColor("second-color"); @@ -65,6 +129,7 @@ export function ModItem({ className, mod, installedVersion, isDependency, isSele {mod.version.modVersion} + {striptags(mod.mod?.summary ?? "", { tagReplacementText: " " })} diff --git a/src/renderer/components/version-viewer/slides/mods/mods-grid.component.tsx b/src/renderer/components/version-viewer/slides/mods/mods-grid.component.tsx index c5b60b3b..d44bb4b2 100644 --- a/src/renderer/components/version-viewer/slides/mods/mods-grid.component.tsx +++ b/src/renderer/components/version-viewer/slides/mods/mods-grid.component.tsx @@ -58,14 +58,15 @@ export function ModsGrid({ modsMap, installed, modsSelected, onModChange, moreIn return ( modsMap && ( -
+
- {filterEnabled ? handleInput(e.target.value)} /> : {t("pages.version-viewer.mods.mods-grid.header-bar.name")}} + {filterEnabled ? handleInput(e.target.value)} /> : {t("pages.version-viewer.mods.mods-grid.header-bar.name")}} {t("pages.version-viewer.mods.mods-grid.header-bar.installed")} {t("pages.version-viewer.mods.mods-grid.header-bar.latest")} + {t("pages.version-viewer.mods.mods-grid.header-bar.size")} {t("pages.version-viewer.mods.mods-grid.header-bar.description")} .tippy-arrow::before { + @apply border-l-neutral-900; +} + +.tippy-box[data-theme~='yellow'] { + @apply bg-neutral-900; + @apply text-yellow-400; +} +.tippy-box[data-theme~='yellow'][data-placement^='left'] > .tippy-arrow::before { + @apply border-l-neutral-900; +} + .bg-theme-1 { @apply bg-light-main-color-1 dark:bg-main-color-1; } .bg-theme-2 { @apply bg-light-main-color-2 dark:bg-main-color-2; } .bg-theme-3 { @apply bg-light-main-color-3 dark:bg-main-color-3; } diff --git a/src/shared/models/mods/mod.interface.ts b/src/shared/models/mods/mod.interface.ts index c0b42cec..e58daf94 100644 --- a/src/shared/models/mods/mod.interface.ts +++ b/src/shared/models/mods/mod.interface.ts @@ -42,6 +42,7 @@ export interface BbmModVersion { downloadCount: number; lastApprovedById?: number; lastUpdatedById?: number; + fileSize?: number; createdAt?: Date; updatedAt?: Date; }