Compare commits

...

10 Commits

19 changed files with 276 additions and 310 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "lncvrt-games-launcher", "name": "lncvrt-games-launcher",
"private": true, "private": true,
"version": "1.6.0", "version": "1.6.1",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "lncvrt-games-launcher" name = "lncvrt-games-launcher"
version = "1.6.0" version = "1.6.1"
authors = ["Lncvrt"] authors = ["Lncvrt"]
edition = "2024" edition = "2024"
@@ -22,13 +22,14 @@ tokio = "1.49.0"
futures-util = { version = "0.3.31", features = ["io"] } futures-util = { version = "0.3.31", features = ["io"] }
tauri-plugin-decorum = "1.1.1" tauri-plugin-decorum = "1.1.1"
tauri-plugin-fs = "2.4.5" tauri-plugin-fs = "2.4.5"
zip = "7.4.0" zip = "8.0.0"
libc = "0.2.182" libc = "0.2.182"
tauri-plugin-dialog = "2.6.0" tauri-plugin-dialog = "2.6.0"
tauri-plugin-notification = "2.3.3" tauri-plugin-notification = "2.3.3"
sysinfo = "0.38.1" sysinfo = "0.38.1"
sha2 = "0.10.9" sha2 = "0.10.9"
tauri-plugin-clipboard-manager = "2.3.2" tauri-plugin-clipboard-manager = "2.3.2"
tauri-plugin-prevent-default = "4.0.3"
[target.'cfg(target_os = "linux")'.dependencies] [target.'cfg(target_os = "linux")'.dependencies]
shlex = "1.3.0" shlex = "1.3.0"

View File

@@ -13,6 +13,7 @@ use std::{
use sysinfo::System; use sysinfo::System;
use tauri::{AppHandle, Emitter, Manager}; use tauri::{AppHandle, Emitter, Manager};
use tauri_plugin_os::platform; use tauri_plugin_os::platform;
use tauri_plugin_prevent_default::Flags;
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
use tokio::{io::AsyncWriteExt, time::timeout}; use tokio::{io::AsyncWriteExt, time::timeout};
use zip::ZipArchive; use zip::ZipArchive;
@@ -278,6 +279,9 @@ fn launch_game(
//if already running on macos, it'll auto take the user to that proccess //if already running on macos, it'll auto take the user to that proccess
#[cfg(any(target_os = "windows", target_os = "linux"))] #[cfg(any(target_os = "windows", target_os = "linux"))]
{ {
use tauri_plugin_dialog::DialogExt;
use tauri_plugin_dialog::MessageDialogKind;
if !use_wine && is_running_by_path(&exe_path) { if !use_wine && is_running_by_path(&exe_path) {
app.dialog() app.dialog()
.message(format!( .message(format!(
@@ -326,6 +330,22 @@ fn launch_game(
pub fn run() { pub fn run() {
#[allow(unused_variables)] #[allow(unused_variables)]
tauri::Builder::default() tauri::Builder::default()
.plugin(
tauri_plugin_prevent_default::Builder::new()
.with_flags(
Flags::FIND
| Flags::CARET_BROWSING
| Flags::DEV_TOOLS
| Flags::DOWNLOADS
| Flags::FOCUS_MOVE
| Flags::RELOAD
| Flags::SOURCE
| Flags::OPEN
| Flags::PRINT
| Flags::CONTEXT_MENU,
)
.build(),
)
.plugin(tauri_plugin_window_state::Builder::new().build()) .plugin(tauri_plugin_window_state::Builder::new().build())
.plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_notification::init()) .plugin(tauri_plugin_notification::init())
@@ -340,11 +360,7 @@ pub fn run() {
.plugin(tauri_plugin_decorum::init()) .plugin(tauri_plugin_decorum::init())
.plugin(tauri_plugin_os::init()) .plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![ .invoke_handler(tauri::generate_handler![download, launch_game, folder_size])
download,
launch_game,
folder_size
])
.setup(|app| { .setup(|app| {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
{ {

View File

@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "Lncvrt Games Launcher", "productName": "Lncvrt Games Launcher",
"version": "1.6.0", "version": "1.6.1",
"identifier": "xyz.lncvrt.games-launcher", "identifier": "xyz.lncvrt.games-launcher",
"build": { "build": {
"beforeDevCommand": "next dev --webpack", "beforeDevCommand": "next dev --webpack",

View File

@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "Lncvrt Games Launcher", "productName": "Lncvrt Games Launcher",
"version": "1.6.0", "version": "1.6.1",
"identifier": "xyz.lncvrt.games-launcher", "identifier": "xyz.lncvrt.games-launcher",
"build": { "build": {
"beforeDevCommand": "next dev --webpack", "beforeDevCommand": "next dev --webpack",

View File

@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "Lncvrt Games Launcher", "productName": "Lncvrt Games Launcher",
"version": "1.6.0", "version": "1.6.1",
"identifier": "xyz.lncvrt.games-launcher", "identifier": "xyz.lncvrt.games-launcher",
"build": { "build": {
"beforeDevCommand": "next dev --webpack", "beforeDevCommand": "next dev --webpack",

View File

@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "Lncvrt Games Launcher", "productName": "Lncvrt Games Launcher",
"version": "1.6.0", "version": "1.6.1",
"identifier": "xyz.lncvrt.games-launcher", "identifier": "xyz.lncvrt.games-launcher",
"build": { "build": {
"beforeDevCommand": "next dev --webpack", "beforeDevCommand": "next dev --webpack",

View File

@@ -7,6 +7,7 @@ import { GetIconForUser } from '@/lib/BerryDash'
import Image from 'next/image' import Image from 'next/image'
import './styles.css' import './styles.css'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import { platform } from '@tauri-apps/plugin-os'
interface BaseEntry { interface BaseEntry {
id: number id: number
@@ -175,11 +176,17 @@ export default function BerryDashLeaderboards () {
</button> </button>
</div> </div>
</div> </div>
<div className='box'> <div
className={`box ${
platform() == 'windows'
? 'h-[calc(100vh-116px)]'
: 'h-[calc(100vh-84px)]'
}`}
>
{selected == -1 ? ( {selected == -1 ? (
<> <>
<p className='text-center mt-4 text-xl'>Select a Leaderboard</p> <p className='text-center mt-2 text-xl'>Select a Leaderboard</p>
<div className='flex flex-col gap-2 mt-4 items-center justify-center'> <div className='flex flex-col gap-2 mt-2 items-center justify-center'>
<button <button
className='leaderboard-button' className='leaderboard-button'
onClick={() => setSelected(0)} onClick={() => setSelected(0)}
@@ -228,7 +235,13 @@ export default function BerryDashLeaderboards () {
<> <>
<div <div
className={`flex flex-col gap-2 overflow-y-auto ${ className={`flex flex-col gap-2 overflow-y-auto ${
selected == 1 ? 'h-[calc(100vh-128px)]' : 'h-[calc(100vh-96px)]' selected == 1
? platform() == 'windows'
? 'h-[calc(100vh-168px)]'
: 'h-[calc(100vh-136px)]'
: platform() == 'windows'
? 'h-[calc(100vh-128px)]'
: 'h-[calc(100vh-96px)]'
} px-1`} } px-1`}
> >
{entries.map((item, index) => { {entries.map((item, index) => {
@@ -288,7 +301,7 @@ export default function BerryDashLeaderboards () {
<select <select
value={selectedBerryOption} value={selectedBerryOption}
onChange={e => setSelectedBerryOption(Number(e.target.value))} onChange={e => setSelectedBerryOption(Number(e.target.value))}
className='leaderboard-select mt-2' className='leaderboard-select mt-0.75'
> >
<option value='0'>Normal Berry</option> <option value='0'>Normal Berry</option>
<option value='1'>Poison Berry</option> <option value='1'>Poison Berry</option>

View File

@@ -1,12 +1,12 @@
@import "tailwindcss"; @import "tailwindcss";
.box { .box {
@apply bg-(--col1) border border-(--col3) rounded-lg w-auto p-1 h-[calc(100vh-84px)]; @apply bg-(--col1) border border-(--col3) rounded-lg w-auto p-1;
} }
.leaderboard-button, .leaderboard-button,
.leaderboard-select { .leaderboard-select {
@apply bg-(--col2) hover:bg-(--col4) border border-(--col4) hover:border-(--col6) rounded-lg px-4 py-2 inline-block transition-all duration-200; @apply bg-(--col2) hover:bg-(--col4) border border-(--col4) hover:border-(--col6) rounded-lg px-4 py-2 inline-block transition-all duration-200 cursor-pointer;
} }
.leaderboard-entry { .leaderboard-entry {

View File

@@ -8,7 +8,7 @@ import { useRouter, useSearchParams } from 'next/navigation'
import { platform } from '@tauri-apps/plugin-os' import { platform } from '@tauri-apps/plugin-os'
import { faWarning } from '@fortawesome/free-solid-svg-icons' import { faWarning } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { ask, message } from '@tauri-apps/plugin-dialog' import { ask } from '@tauri-apps/plugin-dialog'
import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs'
import { writeVersionsConfig } from '@/lib/BazookaManager' import { writeVersionsConfig } from '@/lib/BazookaManager'
import { openFolder } from '@/lib/Util' import { openFolder } from '@/lib/Util'
@@ -113,7 +113,7 @@ export default function Installs () {
<div className='downloads-container'> <div className='downloads-container'>
<div <div
className={`downloads-scroll ${ className={`downloads-scroll ${
platform() === 'windows' platform() == 'windows'
? 'h-[calc(100vh-116px)]' ? 'h-[calc(100vh-116px)]'
: 'h-[calc(100vh-84px)]' : 'h-[calc(100vh-84px)]'
}`} }`}
@@ -129,7 +129,7 @@ export default function Installs () {
if (!info) return false if (!info) return false
if ( if (
platform() === 'linux' && platform() == 'linux' &&
info.wine && info.wine &&
!normalConfig?.settings.useWineOnUnixWhenNeeded !normalConfig?.settings.useWineOnUnixWhenNeeded
) )
@@ -165,7 +165,7 @@ export default function Installs () {
const info = getVersionInfo(v) const info = getVersionInfo(v)
if (!info) return false if (!info) return false
if ( if (
platform() === 'linux' && platform() == 'linux' &&
info.wine && info.wine &&
!normalConfig?.settings !normalConfig?.settings
.useWineOnUnixWhenNeeded .useWineOnUnixWhenNeeded
@@ -200,7 +200,7 @@ export default function Installs () {
const info = getVersionInfo(v) const info = getVersionInfo(v)
if (!info) return false if (!info) return false
if ( if (
platform() === 'linux' && platform() == 'linux' &&
info.wine && info.wine &&
!normalConfig?.settings.useWineOnUnixWhenNeeded !normalConfig?.settings.useWineOnUnixWhenNeeded
) )
@@ -226,109 +226,6 @@ export default function Installs () {
entry entry
) )
) { ) {
await message(
"Can't launch game. Need revision update.",
{ title: 'Error launching game', kind: 'error' }
)
return
}
const verInfo = getVersionInfo(entry)
if (verInfo == undefined) return
const gameInfo = getGameInfo(verInfo.game)
if (gameInfo == undefined) return
invoke('launch_game', {
name: verInfo.id,
executable: verInfo.executable,
displayName: verInfo.displayName,
useWine: !!(
platform() === 'linux' &&
verInfo.wine &&
normalConfig?.settings.useWineOnUnixWhenNeeded
),
wineCommand: normalConfig?.settings.wineOnUnixCommand
})
}}
onContextMenu={e => {
e.preventDefault()
setManagingVersion(entry)
setPopupMode(2)
setShowPopup(true)
setFadeOut(false)
}}
>
<div className='h-18 w-screen relative'>
<p className='text-2xl'>
{getVersionInfo(entry)?.displayName}{' '}
</p>
<div className='flex gap-2 absolute left-0 bottom-0'>
<div
className='entry-info-item'
title='The date the game was installed.'
onClick={e => e.stopPropagation()}
>
<p>
Installed{' '}
{new Intl.DateTimeFormat(undefined).format(
downloadedVersionsConfig?.list[entry]
)}
</p>
</div>
<div
className='entry-info-item'
title='This version is using wine. It cannot be guarenteed to work fully and might not work at all.'
hidden={
!(
platform() === 'linux' &&
getVersionInfo(entry)?.wine
) ||
needsRevisionUpdate(
getVersionInfo(entry)?.lastRevision,
entry
)
}
onClick={e => e.stopPropagation()}
>
<FontAwesomeIcon icon={faWarning} color='#ffc800' />
<p>Uses wine</p>
</div>
<div
className='entry-info-item'
onClick={e => e.stopPropagation()}
hidden={
!needsRevisionUpdate(
getVersionInfo(entry)?.lastRevision,
entry
)
}
>
<FontAwesomeIcon icon={faWarning} color='#ffc800' />
<p>Needs revision update!</p>
</div>
</div>
<div className='flex gap-2 absolute right-0 bottom-0'>
<button
className='button'
onClick={e => {
e.stopPropagation()
setManagingVersion(entry)
setPopupMode(3)
setShowPopup(true)
setFadeOut(false)
}}
hidden={needsRevisionUpdate(
getVersionInfo(entry)?.lastRevision,
entry
)}
title='Click to view version info'
>
View Info
</button>
<button
className='button'
onClick={async e => {
e.stopPropagation()
const answer = await ask( const answer = await ask(
'Before proceeding, if you do not want your installation directory wiped just yet, please backup the files to another directory. When you click "Yes", it will be wiped. Click "No" if you want to open the installation folder instead.', 'Before proceeding, if you do not want your installation directory wiped just yet, please backup the files to another directory. When you click "Yes", it will be wiped. Click "No" if you want to open the installation folder instead.',
{ {
@@ -383,17 +280,80 @@ export default function Installs () {
} else { } else {
openFolder(entry) openFolder(entry)
} }
return
}
const verInfo = getVersionInfo(entry)
if (verInfo == undefined) return
const gameInfo = getGameInfo(verInfo.game)
if (gameInfo == undefined) return
invoke('launch_game', {
name: verInfo.id,
executable: verInfo.executable,
displayName: verInfo.displayName,
useWine: !!(
platform() == 'linux' &&
verInfo.wine &&
normalConfig?.settings.useWineOnUnixWhenNeeded
),
wineCommand: normalConfig?.settings.wineOnUnixCommand
})
}} }}
onContextMenu={e => {
e.preventDefault()
setManagingVersion(entry)
setPopupMode(2)
setShowPopup(true)
setFadeOut(false)
}}
>
<div className='h-18 w-screen relative'>
<p className='text-2xl'>
{getVersionInfo(entry)?.displayName}{' '}
</p>
<div className='flex gap-2 absolute left-0 bottom-0'>
<div
className='entry-info-item'
title='The date the game was installed.'
onClick={e => e.stopPropagation()}
>
<p>
Installed{' '}
{new Intl.DateTimeFormat(undefined).format(
downloadedVersionsConfig?.list[entry]
)}
</p>
</div>
<div
className='entry-info-item'
title='This version is using wine. It cannot be guarenteed to work fully and might not work at all.'
hidden={
!(
platform() == 'linux' && getVersionInfo(entry)?.wine
) ||
needsRevisionUpdate(
getVersionInfo(entry)?.lastRevision,
entry
)
}
onClick={e => e.stopPropagation()}
>
<FontAwesomeIcon icon={faWarning} color='#ffc800' />
<p>Uses wine</p>
</div>
<div
className='entry-info-item'
onClick={e => e.stopPropagation()}
hidden={ hidden={
!needsRevisionUpdate( !needsRevisionUpdate(
getVersionInfo(entry)?.lastRevision, getVersionInfo(entry)?.lastRevision,
entry entry
) )
} }
title={'Click to update the game'}
> >
Update <FontAwesomeIcon icon={faWarning} color='#ffc800' />
</button> <p>Needs revision update!</p>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -32,11 +32,10 @@ import {
} from '@tauri-apps/plugin-notification' } from '@tauri-apps/plugin-notification'
import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs'
import DownloadsPopup from '@/componets/popups/Downloads'
import VersionInfoPopup from '@/componets/popups/VersionInfo'
import ManagingVersionPopup from '@/componets/popups/ManageVersion'
import GamesDownloadPopup from '@/componets/popups/GamesDownload'
import VersionsDownloadPopup from '@/componets/popups/VersionsDownload' import VersionsDownloadPopup from '@/componets/popups/VersionsDownload'
import GamesDownloadPopup from '@/componets/popups/GamesDownload'
import DownloadsPopup from '@/componets/popups/Downloads'
import VersionVersionPopup from '@/componets/popups/VersionVersion'
const roboto = Roboto({ const roboto = Roboto({
subsets: ['latin'] subsets: ['latin']
@@ -51,6 +50,7 @@ export default function RootLayout ({
const [loadingText, setLoadingText] = useState('Loading...') const [loadingText, setLoadingText] = useState('Loading...')
const [outdated, setOutdated] = useState(false) const [outdated, setOutdated] = useState(false)
const [version, setVersion] = useState<string | null>(null) const [version, setVersion] = useState<string | null>(null)
const [platformName, setPlatformName] = useState<string | null>(null)
const [serverVersionList, setServerVersionList] = const [serverVersionList, setServerVersionList] =
useState<null | ServerVersionsResponse>(null) useState<null | ServerVersionsResponse>(null)
@@ -89,7 +89,7 @@ export default function RootLayout ({
) )
.filter(v => { .filter(v => {
if ( if (
platform() === 'linux' && platformName == 'linux' &&
v.wine && v.wine &&
!normalConfig.settings.useWineOnUnixWhenNeeded !normalConfig.settings.useWineOnUnixWhenNeeded
) )
@@ -147,7 +147,7 @@ export default function RootLayout ({
if (!downloadedVersionsConfig || !serverVersionList) return null if (!downloadedVersionsConfig || !serverVersionList) return null
const allowWine = const allowWine =
platform() !== 'linux' || normalConfig?.settings.useWineOnUnixWhenNeeded platformName !== 'linux' || normalConfig?.settings.useWineOnUnixWhenNeeded
const installed = Object.keys(downloadedVersionsConfig.list).filter(v => { const installed = Object.keys(downloadedVersionsConfig.list).filter(v => {
const info = getVersionInfo(v) const info = getVersionInfo(v)
@@ -172,8 +172,6 @@ export default function RootLayout ({
} else if (viewingInfoFromDownloads) { } else if (viewingInfoFromDownloads) {
setViewingInfoFromDownloads(false) setViewingInfoFromDownloads(false)
setPopupMode(0) setPopupMode(0)
} else if (popupMode == 4) {
setPopupMode(3)
} else { } else {
setFadeOut(true) setFadeOut(true)
setTimeout(() => setShowPopup(false), 200) setTimeout(() => setShowPopup(false), 200)
@@ -234,10 +232,10 @@ export default function RootLayout ({
useEffect(() => { useEffect(() => {
;(async () => { ;(async () => {
setPlatformName(platform())
const client = await app.getVersion() const client = await app.getVersion()
setVersion(client) setVersion(client)
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
setLoadingText('Checking latest version...')
try { try {
const response = await axios.get( const response = await axios.get(
'https://games.lncvrt.xyz/api/launcher/latest' 'https://games.lncvrt.xyz/api/launcher/latest'
@@ -251,7 +249,6 @@ export default function RootLayout ({
return return
} }
} }
setLoadingText('Downloading version list...')
try { try {
const res = await axios.get( const res = await axios.get(
`https://games.lncvrt.xyz/api/launcher/versions?platform=${platform()}&arch=${arch()}` `https://games.lncvrt.xyz/api/launcher/versions?platform=${platform()}&arch=${arch()}`
@@ -261,7 +258,6 @@ export default function RootLayout ({
setLoadingText('Failed to download versions list.') setLoadingText('Failed to download versions list.')
return return
} }
setLoadingText('Loading configs...')
const normalConfig = await readNormalConfig() const normalConfig = await readNormalConfig()
const versionsConfig = await readVersionsConfig() const versionsConfig = await readVersionsConfig()
setDownloadedVersionsConfig(versionsConfig) setDownloadedVersionsConfig(versionsConfig)
@@ -274,13 +270,6 @@ export default function RootLayout ({
})() })()
}, []) }, [])
useEffect(() => {
if (process.env.NODE_ENV !== 'production') return
const handler = (e: MouseEvent) => e.preventDefault()
document.addEventListener('contextmenu', handler)
return () => document.removeEventListener('contextmenu', handler)
}, [])
const downloadVersions = useCallback( const downloadVersions = useCallback(
async (list: string[]): Promise<void> => { async (list: string[]): Promise<void> => {
if (list.length === 0) return if (list.length === 0) return
@@ -453,7 +442,18 @@ export default function RootLayout ({
} }
> >
{loading ? ( {loading ? (
<div className='w-screen h-screen flex items-center justify-center'> <>
<div
className='relative z-2 w-screen border-b border-b-(--col3) h-8.25 bg-(--col1)'
hidden={platformName != 'windows'}
/>
<div
className={`w-screen ${
platformName == 'windows'
? 'h-[calc(100vh-64px)]'
: 'h-screen'
} flex items-center justify-center`}
>
{outdated ? ( {outdated ? (
<div className='text-center'> <div className='text-center'>
<p className='text-8xl mb-4'>Outdated Launcher!</p> <p className='text-8xl mb-4'>Outdated Launcher!</p>
@@ -473,6 +473,7 @@ export default function RootLayout ({
<p className='text-7xl text-center'>{loadingText}</p> <p className='text-7xl text-center'>{loadingText}</p>
)} )}
</div> </div>
</>
) : ( ) : (
<GlobalProvider <GlobalProvider
value={{ value={{
@@ -519,10 +520,8 @@ export default function RootLayout ({
> >
<Sidebar /> <Sidebar />
<div <div
className='relative z-2 ml-59.75 w-[calc(100vw-239px)] border-b border-(--col3) h-8.25 bg-(--col1)' className='relative z-2 ml-59.75 w-[calc(100vw-239px)] border-b border-b-(--col3) h-8.25 bg-(--col1)'
style={{ hidden={platformName != 'windows'}
display: platform() === 'windows' ? 'block' : 'none'
}}
/> />
<div className='relative z-0'> <div className='relative z-0'>
<main className='ml-60'>{children}</main> <main className='ml-60'>{children}</main>
@@ -567,9 +566,7 @@ export default function RootLayout ({
) : popupMode === 1 ? ( ) : popupMode === 1 ? (
<DownloadsPopup /> <DownloadsPopup />
) : popupMode === 2 ? ( ) : popupMode === 2 ? (
<ManagingVersionPopup /> <VersionVersionPopup />
) : popupMode === 3 ? (
<VersionInfoPopup />
) : null} ) : null}
</div> </div>
</div> </div>

View File

@@ -54,7 +54,7 @@ export default function Installs () {
<div className='downloads-container'> <div className='downloads-container'>
<div <div
className={`downloads-scroll ${ className={`downloads-scroll ${
platform() === 'windows' platform() == 'windows'
? 'h-[calc(100vh-116px)]' ? 'h-[calc(100vh-116px)]'
: 'h-[calc(100vh-84px)]' : 'h-[calc(100vh-84px)]'
}`} }`}

View File

@@ -13,10 +13,6 @@
@apply bg-(--col3) border-(--col4); @apply bg-(--col3) border-(--col4);
} }
.logo {
@apply flex items-center pl-2 h-10 w-60 pt-2;
}
.nav-links { .nav-links {
@apply flex flex-col px-4 space-y-1; @apply flex flex-col px-4 space-y-1;
} }

View File

@@ -59,15 +59,10 @@ export default function Sidebar () {
}} }}
></div> ></div>
<div <div
className='logo' className={`flex items-center h-10 w-60 ${
style={{ (platform() == 'windows' ? 'pl-1 pt-1' : 'pl-2 pt-2') +
marginTop: (platform() == 'macos' ? ' mt-7' : '')
platform() == 'windows' }`}
? '32px'
: platform() == 'macos'
? '28px'
: ''
}}
onMouseDown={e => { onMouseDown={e => {
if (platform() != 'macos') return if (platform() != 'macos') return
if (e.buttons === 1) { if (e.buttons === 1) {
@@ -142,7 +137,7 @@ export default function Sidebar () {
if (!info) return false if (!info) return false
if ( if (
platform() === 'linux' && platform() == 'linux' &&
info.wine && info.wine &&
!normalConfig?.settings.useWineOnUnixWhenNeeded !normalConfig?.settings.useWineOnUnixWhenNeeded
) )

View File

@@ -58,7 +58,7 @@ export default function DownloadsPopup () {
v.hash_checking ? 'text-blue-300' : 'text-green-300' v.hash_checking ? 'text-blue-300' : 'text-green-300'
} inline-block w-full text-center`} } inline-block w-full text-center`}
> >
{v.hash_checking ? 'Checking hash' : 'Finishing'} {v.hash_checking ? 'Verifying file integerty' : 'Finishing'}
... ...
</span> </span>
) : ( ) : (

View File

@@ -1,106 +0,0 @@
import { useGlobal } from '@/app/GlobalProvider'
import { writeVersionsConfig } from '@/lib/BazookaManager'
import { openFolder } from '@/lib/Util'
import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs'
export default function ManageVersionPopup () {
const {
getVersionInfo,
managingVersion,
closePopup,
setDownloadedVersionsConfig,
setManagingVersion,
downloadVersions,
setSelectedVersionList,
setPopupMode
} = useGlobal()
if (!managingVersion) return <></>
return (
<>
<p className='text-xl text-center'>
Manage {getVersionInfo(managingVersion)?.displayName}
</p>
<div className='popup-content flex flex-col items-center justify-center gap-2 h-full'>
<button
className='button btntheme2'
onClick={async () => {
closePopup()
setDownloadedVersionsConfig(prev => {
if (!prev) return prev
const updatedList = Object.fromEntries(
Object.entries(prev.list).filter(([k]) => k !== managingVersion)
)
const updatedConfig = {
...prev,
list: updatedList
}
writeVersionsConfig(updatedConfig)
return updatedConfig
})
if (
await exists('game/' + managingVersion, {
baseDir: BaseDirectory.AppLocalData
})
)
await remove('game/' + managingVersion, {
baseDir: BaseDirectory.AppLocalData,
recursive: true
})
}}
title='Click to uninstall this game. This will NOT remove any progress or any save files.'
>
Uninstall
</button>
<button
className='button btntheme2'
onClick={async () => {
//change popup to downloads
setManagingVersion(null)
setPopupMode(1)
//uninstall
setDownloadedVersionsConfig(prev => {
if (!prev) return prev
const updatedList = Object.fromEntries(
Object.entries(prev.list).filter(([k]) => k !== managingVersion)
)
const updatedConfig = {
...prev,
list: updatedList
}
writeVersionsConfig(updatedConfig)
return updatedConfig
})
if (
await exists('game/' + managingVersion, {
baseDir: BaseDirectory.AppLocalData
})
)
await remove('game/' + managingVersion, {
baseDir: BaseDirectory.AppLocalData,
recursive: true
})
//reinstall
setSelectedVersionList([managingVersion])
downloadVersions([managingVersion])
}}
title="Click to reinstall this game. This will NOT remove any progress or any save files. This WILL uninstall any modifications to the game's executable files."
>
Reinstall
</button>
<button
className='button btntheme2'
onClick={async () => openFolder(managingVersion)}
title="Click to browse the game's files."
>
Open Folder
</button>
</div>
</>
)
}

View File

@@ -14,24 +14,34 @@ import { invoke } from '@tauri-apps/api/core'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import prettyBytes from 'pretty-bytes' import prettyBytes from 'pretty-bytes'
import { message } from '@tauri-apps/plugin-dialog' import { message } from '@tauri-apps/plugin-dialog'
import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs'
import { writeVersionsConfig } from '@/lib/BazookaManager'
import { openFolder } from '@/lib/Util'
export default function VersionInfoPopup () { export default function VersionVersionPopup () {
const { const {
getGameInfo, getGameInfo,
getVersionInfo, getVersionInfo,
managingVersion, managingVersion,
downloadedVersionsConfig, downloadedVersionsConfig,
viewingInfoFromDownloads viewingInfoFromDownloads,
setManagingVersion,
closePopup,
setDownloadedVersionsConfig,
setPopupMode,
setSelectedVersionList,
downloadVersions
} = useGlobal() } = useGlobal()
const [versionSize, setVersionSize] = useState<number>(0) const [versionSize, setVersionSize] = useState<number>(0)
useEffect(() => { useEffect(() => {
if (viewingInfoFromDownloads) return
invoke<string>('folder_size', { invoke<string>('folder_size', {
version: managingVersion version: managingVersion
}).then(size => { }).then(size => {
setVersionSize(Number(size)) setVersionSize(Number(size))
}) })
}, [managingVersion, setVersionSize]) }, [managingVersion, setVersionSize, viewingInfoFromDownloads])
if (!managingVersion || !downloadedVersionsConfig) return <></> if (!managingVersion || !downloadedVersionsConfig) return <></>
@@ -40,9 +50,7 @@ export default function VersionInfoPopup () {
return ( return (
<> <>
<p className='text-xl text-center'> <p className='text-xl text-center'>Viewing {versionInfo?.displayName}</p>
Viewing info for {versionInfo?.displayName}
</p>
<div className='popup-content flex flex-col items-center justify-center gap-2 h-full'> <div className='popup-content flex flex-col items-center justify-center gap-2 h-full'>
<div <div
className='entry-info-item btntheme2' className='entry-info-item btntheme2'
@@ -86,12 +94,12 @@ export default function VersionInfoPopup () {
</div> </div>
<div <div
className='entry-info-item btntheme2' className='entry-info-item btntheme2'
hidden={viewingInfoFromDownloads || versionSize === null} hidden={viewingInfoFromDownloads}
> >
<FontAwesomeIcon icon={faHardDrive} color='lightgray' /> <FontAwesomeIcon icon={faHardDrive} color='lightgray' />
<p> <p>
Size on disk:{' '} Size on disk:{' '}
{versionSize > 0 {versionSize && versionSize > 0
? prettyBytes(versionSize, { ? prettyBytes(versionSize, {
minimumFractionDigits: 2, minimumFractionDigits: 2,
maximumFractionDigits: 2 maximumFractionDigits: 2
@@ -99,7 +107,10 @@ export default function VersionInfoPopup () {
: 'N/A'} : 'N/A'}
</p> </p>
</div> </div>
<div className='entry-info-item btntheme2' hidden={!versionInfo}> <div
className='entry-info-item btntheme2'
hidden={!viewingInfoFromDownloads}
>
<FontAwesomeIcon icon={faHardDrive} color='lightgray' /> <FontAwesomeIcon icon={faHardDrive} color='lightgray' />
<p> <p>
Size when downloaded (zipped):{' '} Size when downloaded (zipped):{' '}
@@ -125,6 +136,88 @@ export default function VersionInfoPopup () {
<p>View Changelog</p> <p>View Changelog</p>
<FontAwesomeIcon icon={faArrowUpRightFromSquare} color='lightgray' /> <FontAwesomeIcon icon={faArrowUpRightFromSquare} color='lightgray' />
</div> </div>
<div
className='entry-info-item btntheme2'
onClick={async () => openFolder(managingVersion)}
title="Click to browse the game's files."
hidden={viewingInfoFromDownloads}
>
Open Folder
<FontAwesomeIcon icon={faArrowUpRightFromSquare} color='lightgray' />
</div>
<div
className='entry-info-item btntheme2'
onClick={async () => {
closePopup()
setDownloadedVersionsConfig(prev => {
if (!prev) return prev
const updatedList = Object.fromEntries(
Object.entries(prev.list).filter(([k]) => k !== managingVersion)
)
const updatedConfig = {
...prev,
list: updatedList
}
writeVersionsConfig(updatedConfig)
return updatedConfig
})
if (
await exists('game/' + managingVersion, {
baseDir: BaseDirectory.AppLocalData
})
)
await remove('game/' + managingVersion, {
baseDir: BaseDirectory.AppLocalData,
recursive: true
})
}}
title='Click to uninstall this game. This will NOT remove any progress or any save files.'
hidden={viewingInfoFromDownloads}
>
Uninstall
</div>
<div
className='entry-info-item btntheme2'
onClick={async () => {
//change popup to downloads
setManagingVersion(null)
setPopupMode(1)
//uninstall
setDownloadedVersionsConfig(prev => {
if (!prev) return prev
const updatedList = Object.fromEntries(
Object.entries(prev.list).filter(([k]) => k !== managingVersion)
)
const updatedConfig = {
...prev,
list: updatedList
}
writeVersionsConfig(updatedConfig)
return updatedConfig
})
if (
await exists('game/' + managingVersion, {
baseDir: BaseDirectory.AppLocalData
})
)
await remove('game/' + managingVersion, {
baseDir: BaseDirectory.AppLocalData,
recursive: true
})
//reinstall
setSelectedVersionList([managingVersion])
downloadVersions([managingVersion])
}}
title="Click to reinstall this game. This will NOT remove any progress or any save files. This WILL uninstall any modifications to the game's executable files."
hidden={viewingInfoFromDownloads}
>
Reinstall
</div>
</div> </div>
</> </>
) )

View File

@@ -12,10 +12,8 @@ export default function VersionsDownloadPopup () {
selectedGame, selectedGame,
setViewingInfoFromDownloads, setViewingInfoFromDownloads,
downloadedVersionsConfig, downloadedVersionsConfig,
downloadProgress,
downloadVersions, downloadVersions,
getGameInfo, getGameInfo
downloadQueue
} = useGlobal() } = useGlobal()
if (!selectedGame) return <></> if (!selectedGame) return <></>
@@ -66,7 +64,7 @@ export default function VersionsDownloadPopup () {
onClick={() => { onClick={() => {
setManagingVersion(v.id) setManagingVersion(v.id)
setViewingInfoFromDownloads(true) setViewingInfoFromDownloads(true)
setPopupMode(3) setPopupMode(2)
}} }}
title='Click to view version info' title='Click to view version info'
> >
@@ -81,25 +79,19 @@ export default function VersionsDownloadPopup () {
onClick={() => { onClick={() => {
if (downloadedVersionsConfig) { if (downloadedVersionsConfig) {
downloadVersions(selectedVersionList) downloadVersions(selectedVersionList)
setPopupMode(1)
} }
}} }}
disabled={selectedVersionList.length === 0} disabled={selectedVersionList.length == 0}
title={ title={
selectedVersionList.length === 0 selectedVersionList.length == 0
? 'Select at least one version to download' ? 'Select at least one version to download'
: downloadProgress.length > 0 || downloadQueue.length > 0
? `Add ${selectedVersionList.length} version${
selectedVersionList.length == 1 ? '' : 's'
} to download queue`
: `Download ${selectedVersionList.length} version${ : `Download ${selectedVersionList.length} version${
selectedVersionList.length == 1 ? '' : 's' selectedVersionList.length == 1 ? '' : 's'
} of ${getGameInfo(selectedGame)?.name}` } of ${getGameInfo(selectedGame)?.name}`
} }
> >
{downloadProgress.length > 0 || downloadQueue.length > 0 Download {selectedVersionList.length} version
? `Add ${selectedVersionList.length} to Queue`
: `Download ${selectedVersionList.length}`}{' '}
version
{selectedVersionList.length == 1 ? '' : 's'} {selectedVersionList.length == 1 ? '' : 's'}
</button> </button>
<button <button

View File

@@ -11,11 +11,20 @@ export const openFolder = async (name: string) => {
const folderExists = await exists(relativePath, { const folderExists = await exists(relativePath, {
baseDir: BaseDirectory.AppLocalData baseDir: BaseDirectory.AppLocalData
}) })
if (!folderExists) {
await message(`Game folder "${absolutePath}" not found.`, {
title: 'Folder not found',
kind: 'error'
})
return
}
const folderStat = await stat(relativePath, { const folderStat = await stat(relativePath, {
baseDir: BaseDirectory.AppLocalData baseDir: BaseDirectory.AppLocalData
}) })
if (!folderExists || folderStat.isFile) { if (folderStat.isFile) {
await message(`Game folder "${absolutePath}" not found.`, { await message(`Game folder "${absolutePath}" not found.`, {
title: 'Folder not found', title: 'Folder not found',
kind: 'error' kind: 'error'