mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 05:41:03 +00:00
Merge branch 'main' of github.com:hydralauncher/hydra
This commit is contained in:
@@ -67,6 +67,12 @@ export function EditGameModal({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setCustomGameAssets = useCallback((game: LibraryGame | Game) => {
|
const setCustomGameAssets = useCallback((game: LibraryGame | Game) => {
|
||||||
|
// Check if assets were removed (URLs are null but original paths exist)
|
||||||
|
const iconRemoved = !game.iconUrl && (game as any).originalIconPath;
|
||||||
|
const logoRemoved = !game.logoImageUrl && (game as any).originalLogoPath;
|
||||||
|
const heroRemoved =
|
||||||
|
!game.libraryHeroImageUrl && (game as any).originalHeroPath;
|
||||||
|
|
||||||
setAssetPaths({
|
setAssetPaths({
|
||||||
icon: extractLocalPath(game.iconUrl),
|
icon: extractLocalPath(game.iconUrl),
|
||||||
logo: extractLocalPath(game.logoImageUrl),
|
logo: extractLocalPath(game.logoImageUrl),
|
||||||
@@ -85,10 +91,25 @@ export function EditGameModal({
|
|||||||
(game as any).originalHeroPath ||
|
(game as any).originalHeroPath ||
|
||||||
extractLocalPath(game.libraryHeroImageUrl),
|
extractLocalPath(game.libraryHeroImageUrl),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set removed assets state based on whether assets were explicitly removed
|
||||||
|
setRemovedAssets({
|
||||||
|
icon: iconRemoved,
|
||||||
|
logo: logoRemoved,
|
||||||
|
hero: heroRemoved,
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const setNonCustomGameAssets = useCallback(
|
const setNonCustomGameAssets = useCallback(
|
||||||
(game: LibraryGame) => {
|
(game: LibraryGame) => {
|
||||||
|
// Check if assets were removed (custom URLs are null but original paths exist)
|
||||||
|
const iconRemoved =
|
||||||
|
!game.customIconUrl && (game as any).customOriginalIconPath;
|
||||||
|
const logoRemoved =
|
||||||
|
!game.customLogoImageUrl && (game as any).customOriginalLogoPath;
|
||||||
|
const heroRemoved =
|
||||||
|
!game.customHeroImageUrl && (game as any).customOriginalHeroPath;
|
||||||
|
|
||||||
setAssetPaths({
|
setAssetPaths({
|
||||||
icon: extractLocalPath(game.customIconUrl),
|
icon: extractLocalPath(game.customIconUrl),
|
||||||
logo: extractLocalPath(game.customLogoImageUrl),
|
logo: extractLocalPath(game.customLogoImageUrl),
|
||||||
@@ -111,6 +132,13 @@ export function EditGameModal({
|
|||||||
extractLocalPath(game.customHeroImageUrl),
|
extractLocalPath(game.customHeroImageUrl),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set removed assets state based on whether assets were explicitly removed
|
||||||
|
setRemovedAssets({
|
||||||
|
icon: iconRemoved,
|
||||||
|
logo: logoRemoved,
|
||||||
|
hero: heroRemoved,
|
||||||
|
});
|
||||||
|
|
||||||
setDefaultUrls({
|
setDefaultUrls({
|
||||||
icon: shopDetails?.assets?.iconUrl || game.iconUrl || null,
|
icon: shopDetails?.assets?.iconUrl || game.iconUrl || null,
|
||||||
logo: shopDetails?.assets?.logoImageUrl || game.logoImageUrl || null,
|
logo: shopDetails?.assets?.logoImageUrl || game.logoImageUrl || null,
|
||||||
@@ -148,8 +176,12 @@ export function EditGameModal({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getAssetDisplayPath = (assetType: AssetType): string => {
|
const getAssetDisplayPath = (assetType: AssetType): string => {
|
||||||
// Use original path if available, otherwise fall back to display path
|
// If asset was removed, don't show any path
|
||||||
return originalAssetPaths[assetType] || assetDisplayPaths[assetType];
|
if (removedAssets[assetType]) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
// Use display path first, then fall back to original path
|
||||||
|
return assetDisplayPaths[assetType] || originalAssetPaths[assetType];
|
||||||
};
|
};
|
||||||
|
|
||||||
const setAssetPath = (assetType: AssetType, path: string): void => {
|
const setAssetPath = (assetType: AssetType, path: string): void => {
|
||||||
@@ -221,18 +253,11 @@ export function EditGameModal({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRestoreDefault = (assetType: AssetType) => {
|
const handleRestoreDefault = (assetType: AssetType) => {
|
||||||
if (game && isCustomGame(game)) {
|
// Mark asset as removed and clear paths (for both custom and non-custom games)
|
||||||
// For custom games, mark asset as removed and clear paths
|
setRemovedAssets((prev) => ({ ...prev, [assetType]: true }));
|
||||||
setRemovedAssets((prev) => ({ ...prev, [assetType]: true }));
|
setAssetPath(assetType, "");
|
||||||
setAssetPath(assetType, "");
|
setAssetDisplayPath(assetType, "");
|
||||||
setAssetDisplayPath(assetType, "");
|
// Don't clear originalAssetPaths - keep them for reference but don't use them for display
|
||||||
setOriginalAssetPaths((prev) => ({ ...prev, [assetType]: "" }));
|
|
||||||
} else {
|
|
||||||
// For non-custom games, clear custom assets (restore to shop defaults)
|
|
||||||
setAssetPath(assetType, "");
|
|
||||||
setAssetDisplayPath(assetType, "");
|
|
||||||
setOriginalAssetPaths((prev) => ({ ...prev, [assetType]: "" }));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOriginalTitle = (): string => {
|
const getOriginalTitle = (): string => {
|
||||||
@@ -402,10 +427,28 @@ export function EditGameModal({
|
|||||||
|
|
||||||
// Helper function to prepare non-custom game assets
|
// Helper function to prepare non-custom game assets
|
||||||
const prepareNonCustomGameAssets = () => {
|
const prepareNonCustomGameAssets = () => {
|
||||||
|
const hasIconPath = assetPaths.icon;
|
||||||
|
let customIconUrl: string | null = null;
|
||||||
|
if (!removedAssets.icon && hasIconPath) {
|
||||||
|
customIconUrl = `local:${assetPaths.icon}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasLogoPath = assetPaths.logo;
|
||||||
|
let customLogoImageUrl: string | null = null;
|
||||||
|
if (!removedAssets.logo && hasLogoPath) {
|
||||||
|
customLogoImageUrl = `local:${assetPaths.logo}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasHeroPath = assetPaths.hero;
|
||||||
|
let customHeroImageUrl: string | null = null;
|
||||||
|
if (!removedAssets.hero && hasHeroPath) {
|
||||||
|
customHeroImageUrl = `local:${assetPaths.hero}`;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
customIconUrl: assetPaths.icon ? `local:${assetPaths.icon}` : null,
|
customIconUrl,
|
||||||
customLogoImageUrl: assetPaths.logo ? `local:${assetPaths.logo}` : null,
|
customLogoImageUrl,
|
||||||
customHeroImageUrl: assetPaths.hero ? `local:${assetPaths.hero}` : null,
|
customHeroImageUrl,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -439,9 +482,15 @@ export function EditGameModal({
|
|||||||
customIconUrl,
|
customIconUrl,
|
||||||
customLogoImageUrl,
|
customLogoImageUrl,
|
||||||
customHeroImageUrl,
|
customHeroImageUrl,
|
||||||
customOriginalIconPath: originalAssetPaths.icon || undefined,
|
customOriginalIconPath: removedAssets.icon
|
||||||
customOriginalLogoPath: originalAssetPaths.logo || undefined,
|
? undefined
|
||||||
customOriginalHeroPath: originalAssetPaths.hero || undefined,
|
: originalAssetPaths.icon || undefined,
|
||||||
|
customOriginalLogoPath: removedAssets.logo
|
||||||
|
? undefined
|
||||||
|
: originalAssetPaths.logo || undefined,
|
||||||
|
customOriginalHeroPath: removedAssets.hero
|
||||||
|
? undefined
|
||||||
|
: originalAssetPaths.hero || undefined,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -484,6 +533,23 @@ export function EditGameModal({
|
|||||||
hero: false,
|
hero: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Clear all asset paths to ensure clean state
|
||||||
|
setAssetPaths({
|
||||||
|
icon: "",
|
||||||
|
logo: "",
|
||||||
|
hero: "",
|
||||||
|
});
|
||||||
|
setAssetDisplayPaths({
|
||||||
|
icon: "",
|
||||||
|
logo: "",
|
||||||
|
hero: "",
|
||||||
|
});
|
||||||
|
setOriginalAssetPaths({
|
||||||
|
icon: "",
|
||||||
|
logo: "",
|
||||||
|
hero: "",
|
||||||
|
});
|
||||||
|
|
||||||
if (isCustomGame(game)) {
|
if (isCustomGame(game)) {
|
||||||
setCustomGameAssets(game);
|
setCustomGameAssets(game);
|
||||||
// Clear default URLs for custom games
|
// Clear default URLs for custom games
|
||||||
|
|||||||
Reference in New Issue
Block a user