mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-05-02 04:52:03 -04:00
implement unlocker selection #61
This commit is contained in:
14
src/App.tsx
14
src/App.tsx
@@ -21,6 +21,7 @@ import {
|
|||||||
SettingsDialog,
|
SettingsDialog,
|
||||||
ConflictDialog,
|
ConflictDialog,
|
||||||
DisclaimerDialog,
|
DisclaimerDialog,
|
||||||
|
UnlockerSelectionDialog,
|
||||||
} from '@/components/dialogs'
|
} from '@/components/dialogs'
|
||||||
|
|
||||||
// Game components
|
// Game components
|
||||||
@@ -64,6 +65,10 @@ function App() {
|
|||||||
handleSettingsClose,
|
handleSettingsClose,
|
||||||
handleSmokeAPISettingsOpen,
|
handleSmokeAPISettingsOpen,
|
||||||
showToast,
|
showToast,
|
||||||
|
unlockerSelectionDialog,
|
||||||
|
handleSelectCreamLinux,
|
||||||
|
handleSelectSmokeAPI,
|
||||||
|
closeUnlockerDialog,
|
||||||
} = useAppContext()
|
} = useAppContext()
|
||||||
|
|
||||||
// Conflict detection
|
// Conflict detection
|
||||||
@@ -182,6 +187,15 @@ function App() {
|
|||||||
onClose={closeDialog}
|
onClose={closeDialog}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Unlocker Selection Dialog */}
|
||||||
|
<UnlockerSelectionDialog
|
||||||
|
visible={unlockerSelectionDialog.visible}
|
||||||
|
gameTitle={unlockerSelectionDialog.gameTitle || ''}
|
||||||
|
onClose={closeUnlockerDialog}
|
||||||
|
onSelectCreamLinux={handleSelectCreamLinux}
|
||||||
|
onSelectSmokeAPI={handleSelectSmokeAPI}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Disclaimer Dialog - Shows AFTER everything is loaded */}
|
{/* Disclaimer Dialog - Shows AFTER everything is loaded */}
|
||||||
<DisclaimerDialog visible={showDisclaimer} onClose={handleDisclaimerClose} />
|
<DisclaimerDialog visible={showDisclaimer} onClose={handleDisclaimerClose} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -51,11 +51,14 @@ const GameItem = ({ game, onAction, onEdit, onSmokeAPISettings }: GameItemProps)
|
|||||||
}, [game.id, imageUrl])
|
}, [game.id, imageUrl])
|
||||||
|
|
||||||
// Determine if we should show CreamLinux buttons (only for native games)
|
// Determine if we should show CreamLinux buttons (only for native games)
|
||||||
const shouldShowCream = game.native === true
|
const shouldShowCream = game.native && game.cream_installed // Only show if installed (for uninstall)
|
||||||
|
|
||||||
// Determine if we should show SmokeAPI buttons (only for non-native games with API files)
|
// Determine if we should show SmokeAPI buttons (only for non-native games with API files)
|
||||||
const shouldShowSmoke = !game.native && game.api_files && game.api_files.length > 0
|
const shouldShowSmoke = !game.native && game.api_files && game.api_files.length > 0
|
||||||
|
|
||||||
|
// Show generic button if nothing installed
|
||||||
|
const shouldShowUnlocker = game.native && !game.cream_installed && !game.smoke_installed
|
||||||
|
|
||||||
// Check if this is a Proton game without API files
|
// Check if this is a Proton game without API files
|
||||||
const isProtonNoApi = !game.native && (!game.api_files || game.api_files.length === 0)
|
const isProtonNoApi = !game.native && (!game.api_files || game.api_files.length === 0)
|
||||||
|
|
||||||
@@ -71,6 +74,11 @@ const GameItem = ({ game, onAction, onEdit, onSmokeAPISettings }: GameItemProps)
|
|||||||
onAction(game.id, action)
|
onAction(game.id, action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleUnlockerAction = () => {
|
||||||
|
if (game.installing) return
|
||||||
|
onAction(game.id, 'install_unlocker')
|
||||||
|
}
|
||||||
|
|
||||||
// Handle edit button click
|
// Handle edit button click
|
||||||
const handleEdit = () => {
|
const handleEdit = () => {
|
||||||
if (onEdit && game.cream_installed) {
|
if (onEdit && game.cream_installed) {
|
||||||
@@ -116,17 +124,27 @@ const GameItem = ({ game, onAction, onEdit, onSmokeAPISettings }: GameItemProps)
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="game-actions">
|
<div className="game-actions">
|
||||||
{/* Show CreamLinux button only for native games */}
|
{/* Show generic "Install" button for native games with nothing installed */}
|
||||||
|
{shouldShowUnlocker && (
|
||||||
|
<ActionButton
|
||||||
|
action="install_unlocker"
|
||||||
|
isInstalled={false}
|
||||||
|
isWorking={!!game.installing}
|
||||||
|
onClick={handleUnlockerAction}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Show CreamLinux uninstall button if CreamLinux is installed */}
|
||||||
{shouldShowCream && (
|
{shouldShowCream && (
|
||||||
<ActionButton
|
<ActionButton
|
||||||
action={game.cream_installed ? 'uninstall_cream' : 'install_cream'}
|
action="uninstall_cream"
|
||||||
isInstalled={!!game.cream_installed}
|
isInstalled={true}
|
||||||
isWorking={!!game.installing}
|
isWorking={!!game.installing}
|
||||||
onClick={handleCreamAction}
|
onClick={handleCreamAction}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Show SmokeAPI button only for Proton/Windows games with API files */}
|
{/* Show SmokeAPI button for Proton games OR native games with SmokeAPI installed */}
|
||||||
{shouldShowSmoke && (
|
{shouldShowSmoke && (
|
||||||
<ActionButton
|
<ActionButton
|
||||||
action={game.smoke_installed ? 'uninstall_smoke' : 'install_smoke'}
|
action={game.smoke_installed ? 'uninstall_smoke' : 'install_smoke'}
|
||||||
@@ -136,6 +154,16 @@ const GameItem = ({ game, onAction, onEdit, onSmokeAPISettings }: GameItemProps)
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Show SmokeAPI uninstall for native games if installed */}
|
||||||
|
{game.native && game.smoke_installed && (
|
||||||
|
<ActionButton
|
||||||
|
action="uninstall_smoke"
|
||||||
|
isInstalled={true}
|
||||||
|
isWorking={!!game.installing}
|
||||||
|
onClick={handleSmokeAction}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Show message for Proton games without API files */}
|
{/* Show message for Proton games without API files */}
|
||||||
{isProtonNoApi && (
|
{isProtonNoApi && (
|
||||||
<div className="api-not-found-message">
|
<div className="api-not-found-message">
|
||||||
|
|||||||
@@ -62,6 +62,16 @@ export interface AppContextType {
|
|||||||
type: 'success' | 'error' | 'warning' | 'info',
|
type: 'success' | 'error' | 'warning' | 'info',
|
||||||
options?: Record<string, unknown>
|
options?: Record<string, unknown>
|
||||||
) => void
|
) => void
|
||||||
|
|
||||||
|
// Unlocker selection
|
||||||
|
unlockerSelectionDialog: {
|
||||||
|
visible: boolean
|
||||||
|
gameId: string | null
|
||||||
|
gameTitle: string | null
|
||||||
|
}
|
||||||
|
handleSelectCreamLinux: () => void
|
||||||
|
handleSelectSmokeAPI: () => void
|
||||||
|
closeUnlockerDialog: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the context with a default value
|
// Create the context with a default value
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ export const AppProvider = ({ children }: AppProviderProps) => {
|
|||||||
handleCloseProgressDialog,
|
handleCloseProgressDialog,
|
||||||
handleGameAction: executeGameAction,
|
handleGameAction: executeGameAction,
|
||||||
handleDlcConfirm: executeDlcConfirm,
|
handleDlcConfirm: executeDlcConfirm,
|
||||||
|
unlockerSelectionDialog,
|
||||||
|
handleSelectCreamLinux,
|
||||||
|
handleSelectSmokeAPI,
|
||||||
|
closeUnlockerDialog,
|
||||||
} = useGameActions()
|
} = useGameActions()
|
||||||
|
|
||||||
const { toasts, removeToast, success, error: showError, warning, info } = useToasts()
|
const { toasts, removeToast, success, error: showError, warning, info } = useToasts()
|
||||||
@@ -241,6 +245,12 @@ export const AppProvider = ({ children }: AppProviderProps) => {
|
|||||||
|
|
||||||
// Toast notifications
|
// Toast notifications
|
||||||
showToast,
|
showToast,
|
||||||
|
|
||||||
|
// Unlocker selection
|
||||||
|
unlockerSelectionDialog,
|
||||||
|
handleSelectCreamLinux,
|
||||||
|
handleSelectSmokeAPI,
|
||||||
|
closeUnlockerDialog,
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user