mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
Compare commits
140 Commits
v0.2.0-bet
...
v0.3.1-app
| Author | SHA1 | Date | |
|---|---|---|---|
| c78079e4be | |||
| 92e42262c1 | |||
| 106c229c8f | |||
| 527476e7c1 | |||
| 81d324a026 | |||
| 3d5de9bec8 | |||
| 380084bb95 | |||
| 50d76bb76f | |||
| de3be25914 | |||
| 95fc7d9605 | |||
| f9c45053cc | |||
| 683e3ac7f2 | |||
| fe586be658 | |||
| aa034c21a9 | |||
| 50f7955734 | |||
| 73608ab85b | |||
| 1ed29aaa12 | |||
| 849dc26677 | |||
| 7db2e42006 | |||
| 61fa43dd86 | |||
| 301152a69f | |||
| 5e945734c7 | |||
| 53211e94fe | |||
| af49a6751f | |||
| 9e93ec688c | |||
| a70c2c64e4 | |||
| d63d6efa3e | |||
| 51555e43ee | |||
| cb7c297443 | |||
| 4484de0507 | |||
| 4599e5713c | |||
| 263cceb17f | |||
| 0249a3248f | |||
| bf4b2e0ad6 | |||
| 7555cc3cdf | |||
| 6f30d248eb | |||
| cc562662f0 | |||
| dbe8c8df4d | |||
| 35f49b8811 | |||
| cc5339a389 | |||
| 6104bfda72 | |||
| be688cb18f | |||
| 13cc69f10e | |||
| 574782f445 | |||
| b5a8543194 | |||
| d0e4aea5ce | |||
| 739e6166c5 | |||
| 682c6e9c0b | |||
| 46e1f16cdd | |||
| d19f9bbc31 | |||
| 2913fdf35b | |||
| f9fdf151ea | |||
| 495d93705e | |||
| c477dd4872 | |||
| f560a62c8f | |||
| 2874b9776b | |||
| afcd4e916f | |||
| 885fa42ecc | |||
| 6d295bd47f | |||
| c3ee09af85 | |||
| 0ce55e12c5 | |||
| 86bce1c68d | |||
| 924e4e334c | |||
| 065eb2356a | |||
| 689e9ad890 | |||
| 7c35ed73aa | |||
| 8f261a5dac | |||
| 67b6f2aa2e | |||
| 11e2b3fe8a | |||
| eba224f998 | |||
| d045385a5d | |||
| d878806ade | |||
| b71081006e | |||
| c9e1ed78eb | |||
| 446aa70b0b | |||
| 1d0b81078a | |||
| 5251a56c3c | |||
| eeca8a7a98 | |||
| 365cdaf311 | |||
| 2957773179 | |||
| 15e5fe4dc0 | |||
| 2dc0a78354 | |||
| 51c480f245 | |||
| 95d223e2b2 | |||
| 790e8c2afe | |||
| 02edb2cbc1 | |||
| 4b4c0734ec | |||
| e75e0044fb | |||
| 65561abdab | |||
| fed3e08dce | |||
| b0b1e397b1 | |||
| 7b443818d1 | |||
| fa4a881cc0 | |||
| 4f16a6e6b2 | |||
| 47d9e9949b | |||
| a643d6102b | |||
| a71ff160c2 | |||
| a53a566792 | |||
| ac6b034501 | |||
| 5ef20f7a57 | |||
| 8e5e3b2715 | |||
| 0f717d51d0 | |||
| 4941f2a6fa | |||
| 40eb19cf8b | |||
| 6b9b9e3606 | |||
| 3e074abc0a | |||
| 1fdf569278 | |||
| 77251a6524 | |||
| 137b71b3ba | |||
| 569ba4243c | |||
| 834f52d024 | |||
| 1ce6be80db | |||
| 19c8fc24aa | |||
| 4239215451 | |||
| 9614af7f03 | |||
| 639d3b4630 | |||
| cdcd69391d | |||
| 8520b255a3 | |||
| d9c4f7aa75 | |||
| 316a3742eb | |||
| b9df197534 | |||
| 5c479cb283 | |||
| 4c59c5d6c1 | |||
| 9977107374 | |||
| 2690c3019d | |||
| 2a1a7326d0 | |||
| f33ca95bdf | |||
| bb23e88ead | |||
| 810fbdfe49 | |||
| e204ff30b4 | |||
| 501145c5d9 | |||
| dca5f65e89 | |||
| 00f55ff3ae | |||
| 52c70052a4 | |||
| 7a0cf4fbb6 | |||
| 76bae3d926 | |||
| 53234d283e | |||
| 6e4ac4ad83 | |||
| 40c4e8a71c | |||
| 4ad688da14 |
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: "[BUG]"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS: [e.g. Arch Linux, Windows]
|
||||||
|
- App Version [e.g. 22]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
23
.github/workflows/clippy.yml
vendored
Normal file
23
.github/workflows/clippy.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
on: push
|
||||||
|
name: Clippy check
|
||||||
|
jobs:
|
||||||
|
clippy_check:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
permissions:
|
||||||
|
checks: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: install dependencies (ubuntu only)
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwebkit2gtk-4.1-dev
|
||||||
|
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: nightly
|
||||||
|
components: clippy
|
||||||
|
override: true
|
||||||
|
- uses: actions-rs/clippy-check@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
args: --manifest-path ./src-tauri/Cargo.toml
|
||||||
108
.github/workflows/release.yml
vendored
Normal file
108
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
name: 'publish'
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch: {}
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
# This can be used to automatically publish nightlies at UTC nighttime
|
||||||
|
# schedule:
|
||||||
|
# - cron: "0 2 * * *" # run at 2 AM UTC
|
||||||
|
|
||||||
|
# This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the release.
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish-tauri:
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: 'macos-latest' # for Arm based macs (M1 and above).
|
||||||
|
args: '--target aarch64-apple-darwin'
|
||||||
|
- platform: 'macos-latest' # for Intel based macs.
|
||||||
|
args: '--target x86_64-apple-darwin'
|
||||||
|
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
|
||||||
|
args: ''
|
||||||
|
- platform: 'ubuntu-22.04-arm'
|
||||||
|
args: '--target aarch64-unknown-linux-gnu'
|
||||||
|
- platform: 'windows-latest'
|
||||||
|
args: ''
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: setup node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: lts/*
|
||||||
|
|
||||||
|
- name: install Rust nightly
|
||||||
|
uses: dtolnay/rust-toolchain@nightly
|
||||||
|
with:
|
||||||
|
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
|
||||||
|
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
||||||
|
|
||||||
|
- name: install dependencies (ubuntu only)
|
||||||
|
if: matrix.platform == 'ubuntu-22.04' || matrix.platform == 'ubuntu-22.04-arm' # This must match the platform value defined above.
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||||
|
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
|
||||||
|
|
||||||
|
|
||||||
|
- name: Import Apple Developer Certificate
|
||||||
|
if: matrix.platform == 'macos-latest'
|
||||||
|
env:
|
||||||
|
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||||
|
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||||
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
|
||||||
|
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
|
||||||
|
security default-keychain -s build.keychain
|
||||||
|
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
|
||||||
|
security set-keychain-settings -t 3600 -u build.keychain
|
||||||
|
|
||||||
|
curl https://droposs.org/drop.crt --output drop.pem
|
||||||
|
sudo security authorizationdb write com.apple.trust-settings.admin allow
|
||||||
|
sudo security add-trusted-cert -d -r trustRoot -k build.keychain -p codeSign -u -1 drop.pem
|
||||||
|
sudo security authorizationdb remove com.apple.trust-settings.admin
|
||||||
|
|
||||||
|
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
|
||||||
|
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
|
||||||
|
security find-identity -v -p codesigning build.keychain
|
||||||
|
|
||||||
|
- name: Verify Certificate
|
||||||
|
if: matrix.platform == 'macos-latest'
|
||||||
|
run: |
|
||||||
|
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Drop OSS")
|
||||||
|
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
|
||||||
|
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
|
||||||
|
echo "Certificate imported. Using identity: $CERT_ID"
|
||||||
|
|
||||||
|
- name: install frontend dependencies
|
||||||
|
run: yarn install # change this to npm, pnpm or bun depending on which one you use.
|
||||||
|
|
||||||
|
- uses: tauri-apps/tauri-action@v0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||||
|
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||||
|
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
|
||||||
|
with:
|
||||||
|
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
|
||||||
|
releaseName: 'Auto-release v__VERSION__'
|
||||||
|
releaseBody: 'See the assets to download this version and install. This release was created automatically.'
|
||||||
|
releaseDraft: false
|
||||||
|
prerelease: true
|
||||||
|
args: ${{ matrix.args }}
|
||||||
|
|
||||||
|
- name: Bundle Appimage
|
||||||
|
if: matrix.platform == 'ubuntu-22.04' || matrix.platform == 'ubuntu-22.04-arm'
|
||||||
|
run:
|
||||||
|
build_appimage.sh --nobuild
|
||||||
@ -3,7 +3,7 @@ stages:
|
|||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
stage: build
|
stage: build
|
||||||
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/rust:1.81.0-bookworm
|
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/rustlang/rust:nightly
|
||||||
script:
|
script:
|
||||||
- apt-get update -y
|
- apt-get update -y
|
||||||
- apt-get install yarnpkg libsoup-3.0-0 libsoup-3.0-dev libatk-adaptor libgtk-3-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev -y
|
- apt-get install yarnpkg libsoup-3.0-0 libsoup-3.0-dev libatk-adaptor libgtk-3-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev -y
|
||||||
|
|||||||
9
.gitmodules
vendored
Normal file
9
.gitmodules
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[submodule "drop-base"]
|
||||||
|
path = drop-base
|
||||||
|
url = https://github.com/drop-oss/drop-base
|
||||||
|
[submodule "src-tauri/tailscale/libtailscale"]
|
||||||
|
path = src-tauri/tailscale/libtailscale
|
||||||
|
url = https://github.com/tailscale/libtailscale.git
|
||||||
|
[submodule "src-tauri/umu/umu-launcher"]
|
||||||
|
path = src-tauri/umu/umu-launcher
|
||||||
|
url = https://github.com/Open-Wine-Components/umu-launcher.git
|
||||||
@ -4,7 +4,7 @@ Drop app is the companion app for [Drop](https://github.com/Drop-OSS/drop). It u
|
|||||||
|
|
||||||
## Running
|
## Running
|
||||||
Before setting up the drop app, be sure that you have a server set up.
|
Before setting up the drop app, be sure that you have a server set up.
|
||||||
The instructions for this can be found on the [Drop Wiki](https://wiki.droposs.org/guides/quickstart.html)
|
The instructions for this can be found on the [Drop Docs](https://docs.droposs.org/docs/guides/quickstart)
|
||||||
|
|
||||||
## Current features
|
## Current features
|
||||||
Currently supported are the following features:
|
Currently supported are the following features:
|
||||||
|
|||||||
2
app.vue
2
app.vue
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<LoadingIndicator />
|
||||||
<NuxtLayout class="select-none w-screen h-screen">
|
<NuxtLayout class="select-none w-screen h-screen">
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
<ModalStack />
|
<ModalStack />
|
||||||
@ -26,6 +27,7 @@ try {
|
|||||||
console.error("failed to parse state", e);
|
console.error("failed to parse state", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is inefficient but apparently we do it lol
|
||||||
router.beforeEach(async () => {
|
router.beforeEach(async () => {
|
||||||
try {
|
try {
|
||||||
state.value = JSON.parse(await invoke("fetch_state"));
|
state.value = JSON.parse(await invoke("fetch_state"));
|
||||||
|
|||||||
1
build/appimage/drop-app.d/.DirIcon
Symbolic link
1
build/appimage/drop-app.d/.DirIcon
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
drop-oss-app.png
|
||||||
8
build/appimage/drop-app.d/AppRun
Executable file
8
build/appimage/drop-app.d/AppRun
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
program="drop-app"
|
||||||
|
|
||||||
|
# point to libraries and run
|
||||||
|
LD_LIBRARY_PATH=$APPDIR/usr/lib:/usr/local/lib:/usr/lib $APPDIR/usr/bin/$program $@
|
||||||
|
|
||||||
|
# vim:ft=sh
|
||||||
8
build/appimage/drop-app.d/drop-oss-app.desktop
Normal file
8
build/appimage/drop-app.d/drop-oss-app.desktop
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=drop-oss-app
|
||||||
|
Comment=The client application for the open-source, self-hosted game distribution platform Drop
|
||||||
|
Exec=AppRun
|
||||||
|
Icon=drop-oss-app
|
||||||
|
Type=Application
|
||||||
|
Categories=Game;Network
|
||||||
|
MimeType=x-scheme-handler/drop
|
||||||
BIN
build/appimage/drop-app.d/drop-oss-app.png
Normal file
BIN
build/appimage/drop-app.d/drop-oss-app.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
0
build/appimage/drop-app.d/usr/bin/.execs_go_here
Normal file
0
build/appimage/drop-app.d/usr/bin/.execs_go_here
Normal file
0
build/appimage/drop-app.d/usr/lib/.libs_go_here
Normal file
0
build/appimage/drop-app.d/usr/lib/.libs_go_here
Normal file
38
build_appimage.sh
Executable file
38
build_appimage.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# run this from the root of the git repo to make this work
|
||||||
|
|
||||||
|
arch="$(uname -m)"
|
||||||
|
git_dir="$PWD"
|
||||||
|
target_dir="$git_dir/src-tauri/target/"
|
||||||
|
appimage_dir="$git_dir/build/appimage"
|
||||||
|
appdir="$appimage_dir/drop-app.d"
|
||||||
|
|
||||||
|
build() {
|
||||||
|
# set up the repo
|
||||||
|
git submodule init
|
||||||
|
git submodule update --recursive
|
||||||
|
|
||||||
|
# set up yarn and build
|
||||||
|
yarn
|
||||||
|
yarn tauri build
|
||||||
|
}
|
||||||
|
|
||||||
|
rm -f $appdir/usr/bin/* $appdir/usr/lib/*
|
||||||
|
|
||||||
|
if [[ ! "$1" == "--nobuild" ]]; then
|
||||||
|
build
|
||||||
|
fi
|
||||||
|
|
||||||
|
# install binaries in the appdir, then the libraries
|
||||||
|
cp $target_dir/release/drop-app $appdir/usr/bin
|
||||||
|
for i in $(readelf -d "$target_dir/release/drop-app" |grep NEEDED |cut -d'[' -f2 |tr -d ]);
|
||||||
|
do
|
||||||
|
install -g 1000 -o 1000 -Dm755 "$(ls -L1 /usR/LIB/$i)" $appdir/usr/lib
|
||||||
|
done
|
||||||
|
|
||||||
|
wget -O $appimage_dir/appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$arch.AppImage
|
||||||
|
|
||||||
|
cd $appimage_dir
|
||||||
|
chmod u+x appimagetool
|
||||||
|
appimagetool $appdir
|
||||||
287
changelog.md
287
changelog.md
@ -1,5 +1,292 @@
|
|||||||
|
|
||||||
|
|
||||||
|
## Release 0.2.0-beta
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Re-enabled killing games #005bab2
|
||||||
|
- fixed queue manipulation and waiting for downloads #01260f0
|
||||||
|
- fix logic error in detecting dir #04368ff
|
||||||
|
- absolute executable invoke #17759c4
|
||||||
|
- don't crash download manager if multiple errors come in #21204de
|
||||||
|
- clear stale data before requesting new #327628b
|
||||||
|
- fixed completed indexes #39f2ebd
|
||||||
|
- add file & line to console logs #4d8eadc
|
||||||
|
- Games not launching due to string semantics #4ef49cc
|
||||||
|
- Added error handling for chunk request errors #4fc0855
|
||||||
|
- Chunk counting logic error #5ba151f
|
||||||
|
- modal stack doesn't cover whole app #5db9ae5
|
||||||
|
- use set_file_name instead of pushing to strings #60d0a48
|
||||||
|
- use of completed signal, and pause/resuming #64d7f64
|
||||||
|
- add message about nonce expiration #6a8d0af
|
||||||
|
- Added "LIbrary Failed to Update" content to recover from library load fail #76bae3d
|
||||||
|
- Restored RUST_LOG env functionality #7a0cf4f
|
||||||
|
- initialise doesn't recreate default install dir #7a3841b
|
||||||
|
- update routes for new server #7ab53f3
|
||||||
|
- use vendored flag #7c8089e
|
||||||
|
- fix poorly designed parsing for executables with spaces #7c90d2b
|
||||||
|
- assorted fixes #89ea34c
|
||||||
|
- Added Settings component #8aad64f
|
||||||
|
- windows build #8d9234f
|
||||||
|
- fix ugly scrollbars on edge webview #95f2174
|
||||||
|
- windows shadow #9a8cc59
|
||||||
|
- add better error message #9af0d08
|
||||||
|
- Broken command invoke logic in settings/downloads.vue #9e29aa7
|
||||||
|
- Accidentally was attempting to lock onto something that was already in scope #9e82a0b
|
||||||
|
- fix incorrect error assumptions & update types #a17311a
|
||||||
|
- Re-enabled uninstalling apps #a56ee25
|
||||||
|
- types #af056c0
|
||||||
|
- fix other metadata endpoints #c2f54c1
|
||||||
|
- Re-enabled deep links #c3f6222
|
||||||
|
- added console as an appender #d12bf15
|
||||||
|
- remove unnecessary unstable feature #d5ac1b0
|
||||||
|
- fix install button #d7b0302
|
||||||
|
- stop loading on error #d83aae6
|
||||||
|
- use unix timestamp to avoid invalid characters in filename #dafce24
|
||||||
|
- Renamed game_id to id #dceaa56
|
||||||
|
- use chrono library to generate timestamps #e22e6d8
|
||||||
|
- clear stale data before requesting new #e72662c
|
||||||
|
- fix scrollbars on edge webview #f09605a
|
||||||
|
- update readme instructions #f0c47d8
|
||||||
|
- Adding usize to completed_contexts_lock instead of &usize #f508186
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Game kill tauri command #01e6162
|
||||||
|
- add debug page #02f8591
|
||||||
|
- Add signout functionality (#16) #0a0d9d6
|
||||||
|
- queue and library UIs #0a20139
|
||||||
|
- add note about more install dirs #139bc0c
|
||||||
|
- Using SerializeDisplay for better error management with Result #170fde5
|
||||||
|
- add pre-launch log to file #17f8d76
|
||||||
|
- Added option to change root directory #1aa52c0
|
||||||
|
- add speed and time remaining information #1f899ec
|
||||||
|
- lockless tracking of downloaded chunks #2183585
|
||||||
|
- quit button #239b8d5
|
||||||
|
- use shift or DEBUG RUST_LOG to show Debug Info #245a84d
|
||||||
|
- Added database corruption dialog #25ba200
|
||||||
|
- only allow downloads for supported platforms #269dcbb
|
||||||
|
- add installed ui in the library menu #2c8164e
|
||||||
|
- added file-based logging #2d4a7e8
|
||||||
|
- automatically fetch remote data if not available #2dedfbb
|
||||||
|
- Added database recovery #32ae7d5
|
||||||
|
- ability to add more download dirs #384f7a5
|
||||||
|
- re-enable checksums #3ca87fc
|
||||||
|
- background processes and close/open menu #3d60fd5
|
||||||
|
- launch games with log files #3f71149
|
||||||
|
- Download cancelling #450bca9
|
||||||
|
- refactoring and error message #469a2d6
|
||||||
|
- Added UI to change download threads #4e93eb4
|
||||||
|
- Made save button include user feedback & only allow numeric characters #53234d2
|
||||||
|
- download widget and queue fix #532d13e
|
||||||
|
- Pausing and resuming game downloads #55b7921
|
||||||
|
- Allow settings to update UI using fetch_settings command #5bb04da
|
||||||
|
- temporary queue ui and flamegraph instructions #5cbeb3b
|
||||||
|
- Added DownloadThreadControl struct #5e05e68
|
||||||
|
- Added max_download_threads setting and separated settings from db #5ea47d7
|
||||||
|
- Added generic download manager #6159319
|
||||||
|
- Added AgentInterfaceData to get information about all downloads in queue #63c3cc1
|
||||||
|
- debug queue interface #671d45f
|
||||||
|
- reduce scope of download agent #6a38ea3
|
||||||
|
- Added multi-argument game launch and setup support #6ad3837
|
||||||
|
- shared child with stop command #6b96e40
|
||||||
|
- Added function to take and set any game state #6bc6482
|
||||||
|
- Added line numbers to file logging and highlighting to console #7c3140e
|
||||||
|
- Separated chunk updates into individual counters #7d3c601
|
||||||
|
- Ensure that any database issues are resolved by standalone functions #7d4651d
|
||||||
|
- ui to install games #8670bca
|
||||||
|
- Implemented spawning with umu (using umu-wrapper-lib) #88b2505
|
||||||
|
- offer manual signin #949acfc
|
||||||
|
- better process management, including running state #a135b13
|
||||||
|
- Added Download Manager #a1ada07
|
||||||
|
- retry connnection on server unavailable #a53d838
|
||||||
|
- finish download dir CRUD interface #a580a46
|
||||||
|
- better download manager errors + modal #ad92dbe
|
||||||
|
- syncs state to disk to persist across reboots #b556842
|
||||||
|
- prevent default context menu and emit event on elements #c560656
|
||||||
|
- initial creation and logo update #d9a51cf
|
||||||
|
- Added manifest.json utility for persistent download progress #d9d0122
|
||||||
|
- game uninstalling & partial compat #dd7f567
|
||||||
|
- combined db and download interface improvements #de52dac
|
||||||
|
- update db state with ui and emit events #e4df4eb
|
||||||
|
- Generic function to set download state #f10d92d
|
||||||
|
- Convert DownloadThreadControlFlag to AtomicBool #f25bfed
|
||||||
|
- add note about more install dirs #f4ac1c8
|
||||||
|
- Added rolling progress window #fd30b3e
|
||||||
|
|
||||||
|
|
||||||
|
### Other Changes
|
||||||
|
- quexeky <git@quexeky.dev>
|
||||||
|
- Convert DATA_ROOT_DIR to Mutex #00b7179
|
||||||
|
- Converting DB access to a trait #01b092c
|
||||||
|
- Updated changelog #022330b
|
||||||
|
- Progress on cleanup and exit #0381b8b
|
||||||
|
- library ui #03fa364
|
||||||
|
- Scoping changes and removing qualifications #046ba64
|
||||||
|
- Moved all files relevant to game downloads to their own directory #06d1e9e
|
||||||
|
- SLowly integrating game_download into the FE. Started with using the manifest minimal example in the server (#1) #07379b2
|
||||||
|
- Ran cargo clippy & moved DownloadManagerInterface #075d6ec
|
||||||
|
- Made logging systems match #0a1dddf
|
||||||
|
- Some easy cleanup of the download manager #0a2ac25
|
||||||
|
- client now fetches user information from Drop server #0c0cfeb
|
||||||
|
- Included in AppStatus (Also trying to link to Issue #1)
|
||||||
|
- Accidentally serialized AppStatus and broke everything :/ #10791ed
|
||||||
|
- Removed debugging statements #10c8344
|
||||||
|
- Wrappers are the bane of my existence. Also here's the download cancelling logic. #13df631
|
||||||
|
- Merge branch 'error-handling' #1520471
|
||||||
|
- Updated README.md #165a967
|
||||||
|
- Removed unnecessary dependencies #1724449
|
||||||
|
- merge(download-manager) -> 'main' #172d6b0
|
||||||
|
- More refactoring and renaming camelCase struct definitions to snake_case #1742793
|
||||||
|
- General cleanup #182361e
|
||||||
|
- Delete pages/library.vue #1861659
|
||||||
|
- progress on more precise download control #18b9149
|
||||||
|
- Allowing some dead code features because they are there for future use (potentially) #191e62c
|
||||||
|
- Ensure that Downloadable is also send and sync #1a89135
|
||||||
|
- I think that download queuing is working #1ab61c8
|
||||||
|
- auth initiate, database and more #22b1aee
|
||||||
|
- Update .gitlab-ci.yml" #2307704
|
||||||
|
- More fleshing out on how specifically game downloads will work (#1) #23137dd
|
||||||
|
- Removed utils.rs #270bc8b
|
||||||
|
- Fixing some references to "id" vs "game_id" #27e5a8e
|
||||||
|
- More cleanup after cargo clippy #2822b7a
|
||||||
|
- Updated contributing link #2aa5b9c
|
||||||
|
- More fleshing out on how specifically game downloads will work #2b90de9
|
||||||
|
- Cleaning up downloads playing and pausing #2c7b5fb
|
||||||
|
- fixed multi-chunk downloads #2ec351f
|
||||||
|
- Clippy refactoring #2efe304
|
||||||
|
- remove unpacker mod statement #32067c0
|
||||||
|
- Progress on adding tools #3299c71
|
||||||
|
- Fixed bug with bad initial loading into store instead of auth #3923acf
|
||||||
|
- add nvm rc #3ccd444
|
||||||
|
- partial download manager #3dbf5ab
|
||||||
|
- Update .gitlab-ci.yml with artifacts #3e10f17
|
||||||
|
- Removed tools/ #3eda979
|
||||||
|
- Downloads should be fixed now #403ca65
|
||||||
|
- transient vs synced state now defined #42c0198
|
||||||
|
- added adenmgb's autostart feature #472eb1d
|
||||||
|
- better download defaults #4779383
|
||||||
|
- Progress on downloads. Currently working on parsing functions to be run asynchronously #496c6a5
|
||||||
|
- Ran cargo clippy & cargo fmt #4983b25
|
||||||
|
- handshakes #4bb33c8
|
||||||
|
- Convert DOWNLOAD_MAX_THREADS to const #4fc13a1
|
||||||
|
- Merge branch 'downloads' #50ed841
|
||||||
|
- Moved generateGameMeta.ts to composables, using PathBuf instead of String for install_dirs #50f37fd
|
||||||
|
- Added time debugging and fixed logging formatting #5243694
|
||||||
|
- Clippy changes #553bc37
|
||||||
|
- Queue is running game downloads sequentially now #5564d23
|
||||||
|
- migrate to new droplet ca system #556898f
|
||||||
|
- Add LICENSE #57a5737
|
||||||
|
- ran cargo clippy & cargo fmt #5e3d26b
|
||||||
|
- my own take on some BASED design decisions #5ed0833
|
||||||
|
- cleanup and game UI beginnings #5ef6b8e
|
||||||
|
- Progress on terminator #5f5cbd0
|
||||||
|
- Implement better error system and segregate errors and commands (#23) #604d5b5
|
||||||
|
- moved to completed index arr to help serialization #64ebc19
|
||||||
|
- Ran cargo clippy & cargo fmt #653717e
|
||||||
|
- Removed all references to anything outside of the DownloadManager #6568faa
|
||||||
|
- Merge remote-tracking branch 'origin/main' #68ca4a7
|
||||||
|
- swap file name and to binary encoding #694f2fd
|
||||||
|
- chore(polish & cleanup) #6cc0c67
|
||||||
|
- Update .gitlab-ci.yml #6d7630e
|
||||||
|
- Moved some variable declarations outside of the spawned download thread #6ea4cf2
|
||||||
|
- Encoding game IDs and versions #6ef444e
|
||||||
|
- restructing and renaming #7049673
|
||||||
|
- Converted to md5 #706f525
|
||||||
|
- Merge branch 'main' into downloads #714b968
|
||||||
|
- Semantic naming changes #725f16b
|
||||||
|
- Abstracted queue system #76b0975
|
||||||
|
- Moved manifest and stored_manifest to download_manager" #78149bb
|
||||||
|
- README update #78fc668
|
||||||
|
- Ensured everything is serializing/deserializing to camelCase #7a95b7f
|
||||||
|
- fixed some of quexeky's BASED design decisions #7e3da04
|
||||||
|
- Progress checker works #7fec00d
|
||||||
|
- Progress on refactoring and abiding by cargo clippy #816b427
|
||||||
|
- Added GAME_PAUSE_CHECK_INTERVAL value #8204795
|
||||||
|
- Ran cargo clippy & fmt #82804eb
|
||||||
|
- update metadata #85a0899
|
||||||
|
- Renamed most instances of "game" outside of actual game downloads #881fcc6
|
||||||
|
- Debugging & starting work on parsing manifest #89d2814
|
||||||
|
- slight ui/ux fixes and updates to auth protocol #8a2d23d
|
||||||
|
- Removed Arc requirement for DownloadableMetadata #8be1dd4
|
||||||
|
- compliant with new APIs #8f6f184
|
||||||
|
- Ran cargo clippy & cargo fmt #9272970
|
||||||
|
- Added rolling_progress_updates.rs #9369ff1
|
||||||
|
- Add files via upload #93b8b83
|
||||||
|
- More refining info!() statements #94cf678
|
||||||
|
- fixed windows issues #959dad3
|
||||||
|
- Starting p2p progress #97bb1fa
|
||||||
|
- Game downloads from the client are working (multithreaded) by parsing in gameID, GameVersion, and maxThreads from FE (#1) #984472e
|
||||||
|
- Version bump & appimage build #9897698
|
||||||
|
- Some progress on thread terminations #99beca4
|
||||||
|
- rename files to what they contain #99c8b39
|
||||||
|
- Created separate function to generate requests #9a184a8
|
||||||
|
- cleanup of lib and toml #9b1cfa7
|
||||||
|
- refactor for generic way to implement cross platform launchers #9ea2aa4
|
||||||
|
- Updated logging format #a213765
|
||||||
|
- fix(windows build) #a24cc8a
|
||||||
|
- Added ToolDownloadAgent #a2e63aa
|
||||||
|
- copy direct to disk #a628fc1
|
||||||
|
- Moved manifest and stored_manifest to download_manager #a846eed
|
||||||
|
- adds nvm rc! #a881d8e
|
||||||
|
- Reordered DownloadThreadControlFlag to agree with From<bool> #ab606e8
|
||||||
|
- ci/cd and patches for windows builds #ac1c3b6
|
||||||
|
- patch for not draggable windows during setup #ac66b20
|
||||||
|
- another stage of client authentication #ae4c65b
|
||||||
|
- Renamed GameDonwloadError to ApplicationDownloadError and moved #aed58e4
|
||||||
|
- Progress on write speeds & added debug statements #b065e10
|
||||||
|
- Updated logging #b3963b6
|
||||||
|
- Created file settings.rs #b47b7ea
|
||||||
|
- Added Downloadable trait and replaced references to GameDownloadAgent #b4d70a3
|
||||||
|
- Update .gitlab-ci.yml #b6a54c0
|
||||||
|
- Moved download manager to separate directory #b6c64e5
|
||||||
|
- Ran cargo fmt #b8cf44c
|
||||||
|
- Imported appropriate logging macros #b99ff67
|
||||||
|
- Merge branch 'main' into download-manager #bb60942
|
||||||
|
- Ran cargo clippy & cargo fmt #bd3deac
|
||||||
|
- beginnings of game state management #bf46dec
|
||||||
|
- Update Cargo.toml #c1fb39e
|
||||||
|
- migrated unpacking to rust zstd to conform with droplet #c46c54b
|
||||||
|
- More progress on checksums #c51e761
|
||||||
|
- Delete pages/library.vue #c722a54
|
||||||
|
- Merge branch 'downloads' (again) #c748aec
|
||||||
|
- migrate to nuxt and groundwork #c957744
|
||||||
|
- More debugging because apparently checksums are the bane of my existence. But it works and I was just an idiot #c9d9d2e
|
||||||
|
- Fully separate & generic download manager #cac612b
|
||||||
|
- Progress on rolling progress window #cf19477
|
||||||
|
- Ensured that all logs start with lowercase capital and have no trailing punctuation #cfc9d13
|
||||||
|
- Validated that loading data works #d21b1d2
|
||||||
|
- Mostly finished with checksums. Just merging main in at the same time #d39e7cb
|
||||||
|
- Ran cargo clippy #dcb1564
|
||||||
|
- Add files via upload #dcb2c0f
|
||||||
|
- Theoretically adding queue support and optimistic manifest downloading (#1). Needs tests when actual functions are implemented #dcd8fa8
|
||||||
|
- Merge remote-tracking branch 'origin/downloads' into downloads #dd23ca8
|
||||||
|
- Debugging line #ddc585d
|
||||||
|
- Re-enabled closing the window and some more renaming #defba51
|
||||||
|
- drop no longer freaks out if server is unavailable on startup #df88395
|
||||||
|
- Apply stashed changes #e0ea8c9
|
||||||
|
- Merge remote-tracking branch 'origin/downloads' into downloads #e4e605b
|
||||||
|
- convert to more sensible permission schema #e504c00
|
||||||
|
- Update on GameDownload #e71e4cf
|
||||||
|
- reorganisation, cleanup and new nonce protocol #e828bca
|
||||||
|
- rustix fs feature #e9805a8
|
||||||
|
- Added manage_go_signal command #ea70ec9
|
||||||
|
- Drop will no longer crash when the server goes down #eb3311a
|
||||||
|
- Made all errors type-based #ec2f414
|
||||||
|
- Added description on how the DownloadManager works #f029cbf
|
||||||
|
- Using more appropriate logging statements #f183a9d
|
||||||
|
- remove unnecessary compat code (#20) #f1c8bbf
|
||||||
|
- Manifests are now being parsed successfully #f28c880
|
||||||
|
- Removed tests/ #f29e989
|
||||||
|
- I think that downloads are working. Need to test and set decent file locations now #f388237
|
||||||
|
- Just debugging tauri's damn Sync command features #f60ca2b
|
||||||
|
- fixes and patches for merged changes #f6476bc
|
||||||
|
- Added manage_queue_signal #f64782e
|
||||||
|
- initial commit #f6cd7c3
|
||||||
|
- Update .gitlab-ci.yml #fc6bab9
|
||||||
|
|
||||||
|
|
||||||
|
_changelog generated by_ [go-conventional-commits](https://github.com/joselitofilho/go-conventional-commits)
|
||||||
|
|
||||||
## Release 0.1.0-beta
|
## Release 0.1.0-beta
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|||||||
31
components/GameOptions/Launch.vue
Normal file
31
components/GameOptions/Launch.vue
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<label for="launch" class="block text-sm/6 font-medium text-zinc-100"
|
||||||
|
>Launch string template</label
|
||||||
|
>
|
||||||
|
<div class="mt-2">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="launch"
|
||||||
|
id="launch"
|
||||||
|
class="block w-full rounded-md bg-zinc-800 px-3 py-1.5 text-base text-zinc-100 outline-1 -outline-offset-1 outline-zinc-800 placeholder:text-zinc-400 focus:outline-2 focus:-outline-offset-2 focus:outline-blue-600 sm:text-sm/6"
|
||||||
|
placeholder="{}"
|
||||||
|
aria-describedby="launch-description"
|
||||||
|
v-model="model!!.launchString"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p class="mt-2 text-sm text-zinc-400" id="launch-description">
|
||||||
|
Override the launch string. Passed to system's default shell, and replaces
|
||||||
|
"{}" with the command to start the game.
|
||||||
|
<span class="font-semibold text-zinc-200"
|
||||||
|
>Leaving it blank will cause the game not to start.</span
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { FrontendGameConfiguration } from "~/composables/game";
|
||||||
|
|
||||||
|
const model = defineModel<FrontendGameConfiguration>();
|
||||||
|
</script>
|
||||||
122
components/GameOptionsModal.vue
Normal file
122
components/GameOptionsModal.vue
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<template>
|
||||||
|
<ModalTemplate size-class="max-w-4xl" v-model="open">
|
||||||
|
<template #default>
|
||||||
|
<div class="flex flex-row gap-x-4">
|
||||||
|
<nav class="flex flex-1 flex-col" aria-label="Sidebar">
|
||||||
|
<ul role="list" class="-mx-2 space-y-1">
|
||||||
|
<li v-for="(tab, tabIdx) in tabs" :key="tab.name">
|
||||||
|
<button
|
||||||
|
@click="() => (currentTabIndex = tabIdx)"
|
||||||
|
:class="[
|
||||||
|
tabIdx == currentTabIndex
|
||||||
|
? 'bg-zinc-800 text-zinc-100'
|
||||||
|
: 'text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100',
|
||||||
|
'transition w-full group flex gap-x-3 rounded-md p-2 text-sm/6 font-semibold',
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="tab.icon"
|
||||||
|
:class="[
|
||||||
|
tabIdx == currentTabIndex
|
||||||
|
? 'text-zinc-100'
|
||||||
|
: 'text-gray-400 group-hover:text-zinc-100',
|
||||||
|
'size-6 shrink-0',
|
||||||
|
]"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{{ tab.name }}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<div class="border-l-2 border-zinc-800 w-full grow pl-4">
|
||||||
|
<component
|
||||||
|
v-model="configuration"
|
||||||
|
:is="tabs[currentTabIndex]?.page"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="saveError" class="mt-5 rounded-md bg-red-600/10 p-4">
|
||||||
|
<div class="flex">
|
||||||
|
<div class="flex-shrink-0">
|
||||||
|
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
|
||||||
|
</div>
|
||||||
|
<div class="ml-3">
|
||||||
|
<h3 class="text-sm font-medium text-red-600">
|
||||||
|
{{ saveError }}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #buttons>
|
||||||
|
<LoadingButton
|
||||||
|
@click="() => save()"
|
||||||
|
:loading="saveLoading"
|
||||||
|
type="submit"
|
||||||
|
class="ml-2 w-full sm:w-fit"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</LoadingButton>
|
||||||
|
<button
|
||||||
|
@click="() => (open = false)"
|
||||||
|
type="button"
|
||||||
|
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
||||||
|
ref="cancelButtonRef"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</ModalTemplate>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { Component } from "vue";
|
||||||
|
import {
|
||||||
|
RocketLaunchIcon,
|
||||||
|
ServerIcon,
|
||||||
|
TrashIcon,
|
||||||
|
XCircleIcon,
|
||||||
|
} from "@heroicons/vue/20/solid";
|
||||||
|
import Launch from "./GameOptions/Launch.vue";
|
||||||
|
import type { FrontendGameConfiguration } from "~/composables/game";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
|
const open = defineModel<boolean>();
|
||||||
|
const props = defineProps<{ gameId: string }>();
|
||||||
|
const game = await useGame(props.gameId);
|
||||||
|
|
||||||
|
const configuration: Ref<FrontendGameConfiguration> = ref({
|
||||||
|
launchString: game.version!!.launchCommandTemplate,
|
||||||
|
});
|
||||||
|
|
||||||
|
const tabs: Array<{ name: string; icon: Component; page: Component }> = [
|
||||||
|
{
|
||||||
|
name: "Launch",
|
||||||
|
icon: RocketLaunchIcon,
|
||||||
|
page: Launch,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Storage",
|
||||||
|
icon: ServerIcon,
|
||||||
|
page: h("div"),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const currentTabIndex = ref(0);
|
||||||
|
|
||||||
|
const saveLoading = ref(false);
|
||||||
|
const saveError = ref<undefined | string>();
|
||||||
|
async function save() {
|
||||||
|
saveLoading.value = true;
|
||||||
|
try {
|
||||||
|
await invoke("update_game_configuration", {
|
||||||
|
gameId: game.game.id,
|
||||||
|
options: configuration.value,
|
||||||
|
});
|
||||||
|
open.value = false;
|
||||||
|
} catch (e) {
|
||||||
|
saveError.value = (e as unknown as string).toString();
|
||||||
|
}
|
||||||
|
saveLoading.value = false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -1,32 +1,76 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<!-- Do not add scale animations to this: https://stackoverflow.com/a/35683068 -->
|
||||||
<div class="inline-flex divide-x divide-zinc-900">
|
<div class="inline-flex divide-x divide-zinc-900">
|
||||||
<button type="button" @click="() => buttonActions[props.status.type]()" :class="[
|
<button
|
||||||
|
type="button"
|
||||||
|
@click="() => buttonActions[props.status.type]()"
|
||||||
|
:class="[
|
||||||
styles[props.status.type],
|
styles[props.status.type],
|
||||||
showDropdown ? 'rounded-l-md' : 'rounded-md',
|
showDropdown ? 'rounded-l-md' : 'rounded-md',
|
||||||
'inline-flex uppercase font-display items-center gap-x-2 px-4 py-3 text-md font-semibold shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2',
|
'inline-flex uppercase font-display items-center gap-x-2 px-4 py-3 text-md font-semibold shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2',
|
||||||
]">
|
]"
|
||||||
<component :is="buttonIcons[props.status.type]" class="-mr-0.5 size-5" aria-hidden="true" />
|
>
|
||||||
|
<component
|
||||||
|
:is="buttonIcons[props.status.type]"
|
||||||
|
class="-mr-0.5 size-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
{{ buttonNames[props.status.type] }}
|
{{ buttonNames[props.status.type] }}
|
||||||
</button>
|
</button>
|
||||||
<Menu v-if="showDropdown" as="div" class="relative inline-block text-left grow">
|
<Menu
|
||||||
|
v-if="showDropdown"
|
||||||
|
as="div"
|
||||||
|
class="relative inline-block text-left grow"
|
||||||
|
>
|
||||||
<div class="h-full">
|
<div class="h-full">
|
||||||
<MenuButton :class="[
|
<MenuButton
|
||||||
|
:class="[
|
||||||
styles[props.status.type],
|
styles[props.status.type],
|
||||||
'inline-flex w-full h-full justify-center items-center rounded-r-md px-1 py-2 text-sm font-semibold shadow-sm'
|
'inline-flex w-full h-full justify-center items-center rounded-r-md px-1 py-2 text-sm font-semibold shadow-sm group',
|
||||||
]">
|
'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2',
|
||||||
|
]"
|
||||||
|
>
|
||||||
<ChevronDownIcon class="size-5" aria-hidden="true" />
|
<ChevronDownIcon class="size-5" aria-hidden="true" />
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<transition enter-active-class="transition ease-out duration-100" enter-from-class="transform opacity-0 scale-95"
|
<transition
|
||||||
enter-to-class="transform opacity-100 scale-100" leave-active-class="transition ease-in duration-75"
|
enter-active-class="transition ease-out duration-100"
|
||||||
leave-from-class="transform opacity-100 scale-100" leave-to-class="transform opacity-0 scale-95">
|
enter-from-class="transform opacity-0 scale-95"
|
||||||
|
enter-to-class="transform opacity-100 scale-100"
|
||||||
|
leave-active-class="transition ease-in duration-75"
|
||||||
|
leave-from-class="transform opacity-100 scale-100"
|
||||||
|
leave-to-class="transform opacity-0 scale-95"
|
||||||
|
>
|
||||||
<MenuItems
|
<MenuItems
|
||||||
class="absolute right-0 z-50 mt-2 w-32 origin-top-right rounded-md bg-zinc-900 shadow-lg ring-1 ring-zinc-100/5 focus:outline-none">
|
class="absolute right-0 z-[500] mt-2 w-32 origin-top-right rounded-md bg-zinc-900 shadow-lg ring-1 ring-zinc-100/5 focus:outline-none"
|
||||||
|
>
|
||||||
<div class="py-1">
|
<div class="py-1">
|
||||||
|
<MenuItem v-if="showOptions" v-slot="{ active }">
|
||||||
|
<button
|
||||||
|
@click="() => emit('options')"
|
||||||
|
:class="[
|
||||||
|
active
|
||||||
|
? 'bg-zinc-800 text-zinc-100 outline-none'
|
||||||
|
: 'text-zinc-400',
|
||||||
|
'w-full block px-4 py-2 text-sm inline-flex justify-between',
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
Options
|
||||||
|
<Cog6ToothIcon class="size-5" />
|
||||||
|
</button>
|
||||||
|
</MenuItem>
|
||||||
<MenuItem v-slot="{ active }">
|
<MenuItem v-slot="{ active }">
|
||||||
<button @click="() => emit('uninstall')"
|
<button
|
||||||
:class="[active ? 'bg-zinc-800 text-zinc-100 outline-none' : 'text-zinc-400', 'w-full block px-4 py-2 text-sm inline-flex justify-between']">Uninstall
|
@click="() => emit('uninstall')"
|
||||||
|
:class="[
|
||||||
|
active
|
||||||
|
? 'bg-zinc-800 text-zinc-100 outline-none'
|
||||||
|
: 'text-zinc-400',
|
||||||
|
'w-full block px-4 py-2 text-sm inline-flex justify-between',
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
Uninstall
|
||||||
<TrashIcon class="size-5" />
|
<TrashIcon class="size-5" />
|
||||||
</button>
|
</button>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
@ -43,13 +87,15 @@ import {
|
|||||||
ChevronDownIcon,
|
ChevronDownIcon,
|
||||||
PlayIcon,
|
PlayIcon,
|
||||||
QueueListIcon,
|
QueueListIcon,
|
||||||
TrashIcon,
|
ServerIcon,
|
||||||
|
StopIcon,
|
||||||
WrenchIcon,
|
WrenchIcon,
|
||||||
} from "@heroicons/vue/20/solid";
|
} from "@heroicons/vue/20/solid";
|
||||||
|
|
||||||
import type { Component } from "vue";
|
import type { Component } from "vue";
|
||||||
import { GameStatusEnum, type GameStatus } from "~/types.js";
|
import { GameStatusEnum, type GameStatus } from "~/types.js";
|
||||||
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
|
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
|
||||||
|
import { Cog6ToothIcon, TrashIcon } from "@heroicons/vue/24/outline";
|
||||||
|
|
||||||
const props = defineProps<{ status: GameStatus }>();
|
const props = defineProps<{ status: GameStatus }>();
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@ -58,51 +104,80 @@ const emit = defineEmits<{
|
|||||||
(e: "queue"): void;
|
(e: "queue"): void;
|
||||||
(e: "uninstall"): void;
|
(e: "uninstall"): void;
|
||||||
(e: "kill"): void;
|
(e: "kill"): void;
|
||||||
|
(e: "options"): void;
|
||||||
|
(e: "resume"): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const showDropdown = computed(() => props.status.type === GameStatusEnum.Installed || props.status.type === GameStatusEnum.SetupRequired);
|
const showDropdown = computed(
|
||||||
|
() =>
|
||||||
|
props.status.type === GameStatusEnum.Installed ||
|
||||||
|
props.status.type === GameStatusEnum.SetupRequired ||
|
||||||
|
props.status.type === GameStatusEnum.PartiallyInstalled
|
||||||
|
);
|
||||||
|
|
||||||
|
const showOptions = computed(
|
||||||
|
() => props.status.type === GameStatusEnum.Installed
|
||||||
|
);
|
||||||
|
|
||||||
const styles: { [key in GameStatusEnum]: string } = {
|
const styles: { [key in GameStatusEnum]: string } = {
|
||||||
[GameStatusEnum.Remote]: "bg-blue-600 text-white hover:bg-blue-500 focus-visible:outline-blue-600",
|
[GameStatusEnum.Remote]:
|
||||||
[GameStatusEnum.Queued]: "bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700",
|
"bg-blue-600 text-white hover:bg-blue-500 focus-visible:outline-blue-600 hover:bg-blue-500",
|
||||||
[GameStatusEnum.Downloading]: "bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700",
|
[GameStatusEnum.Queued]:
|
||||||
[GameStatusEnum.SetupRequired]: "bg-yellow-600 text-white hover:bg-yellow-500 focus-visible:outline-yellow-600",
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
[GameStatusEnum.Installed]: "bg-green-600 text-white hover:bg-green-500 focus-visible:outline-green-600",
|
[GameStatusEnum.Downloading]:
|
||||||
[GameStatusEnum.Updating]: "bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700",
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
[GameStatusEnum.Uninstalling]: "bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700",
|
[GameStatusEnum.Validating]:
|
||||||
[GameStatusEnum.Running]: "bg-zinc-800 text-white focus-visible:outline-zinc-700"
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
|
[GameStatusEnum.SetupRequired]:
|
||||||
|
"bg-yellow-600 text-white hover:bg-yellow-500 focus-visible:outline-yellow-600 hover:bg-yellow-500",
|
||||||
|
[GameStatusEnum.Installed]:
|
||||||
|
"bg-green-600 text-white hover:bg-green-500 focus-visible:outline-green-600 hover:bg-green-500",
|
||||||
|
[GameStatusEnum.Updating]:
|
||||||
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
|
[GameStatusEnum.Uninstalling]:
|
||||||
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
|
[GameStatusEnum.Running]:
|
||||||
|
"bg-zinc-800 text-white hover:bg-zinc-700 focus-visible:outline-zinc-700 hover:bg-zinc-700",
|
||||||
|
[GameStatusEnum.PartiallyInstalled]:
|
||||||
|
"bg-blue-600 text-white hover:bg-blue-500 focus-visible:outline-blue-600 hover:bg-blue-500",
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonNames: { [key in GameStatusEnum]: string } = {
|
const buttonNames: { [key in GameStatusEnum]: string } = {
|
||||||
[GameStatusEnum.Remote]: "Install",
|
[GameStatusEnum.Remote]: "Install",
|
||||||
[GameStatusEnum.Queued]: "Queued",
|
[GameStatusEnum.Queued]: "Queued",
|
||||||
[GameStatusEnum.Downloading]: "Downloading",
|
[GameStatusEnum.Downloading]: "Downloading",
|
||||||
|
[GameStatusEnum.Validating]: "Validating",
|
||||||
[GameStatusEnum.SetupRequired]: "Setup",
|
[GameStatusEnum.SetupRequired]: "Setup",
|
||||||
[GameStatusEnum.Installed]: "Play",
|
[GameStatusEnum.Installed]: "Play",
|
||||||
[GameStatusEnum.Updating]: "Updating",
|
[GameStatusEnum.Updating]: "Updating",
|
||||||
[GameStatusEnum.Uninstalling]: "Uninstalling",
|
[GameStatusEnum.Uninstalling]: "Uninstalling",
|
||||||
[GameStatusEnum.Running]: "Stop"
|
[GameStatusEnum.Running]: "Stop",
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: "Resume",
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonIcons: { [key in GameStatusEnum]: Component } = {
|
const buttonIcons: { [key in GameStatusEnum]: Component } = {
|
||||||
[GameStatusEnum.Remote]: ArrowDownTrayIcon,
|
[GameStatusEnum.Remote]: ArrowDownTrayIcon,
|
||||||
[GameStatusEnum.Queued]: QueueListIcon,
|
[GameStatusEnum.Queued]: QueueListIcon,
|
||||||
[GameStatusEnum.Downloading]: ArrowDownTrayIcon,
|
[GameStatusEnum.Downloading]: ArrowDownTrayIcon,
|
||||||
|
[GameStatusEnum.Validating]: ServerIcon,
|
||||||
[GameStatusEnum.SetupRequired]: WrenchIcon,
|
[GameStatusEnum.SetupRequired]: WrenchIcon,
|
||||||
[GameStatusEnum.Installed]: PlayIcon,
|
[GameStatusEnum.Installed]: PlayIcon,
|
||||||
[GameStatusEnum.Updating]: ArrowDownTrayIcon,
|
[GameStatusEnum.Updating]: ArrowDownTrayIcon,
|
||||||
[GameStatusEnum.Uninstalling]: TrashIcon,
|
[GameStatusEnum.Uninstalling]: TrashIcon,
|
||||||
[GameStatusEnum.Running]: PlayIcon
|
[GameStatusEnum.Running]: StopIcon,
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: ArrowDownTrayIcon,
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonActions: { [key in GameStatusEnum]: () => void } = {
|
const buttonActions: { [key in GameStatusEnum]: () => void } = {
|
||||||
[GameStatusEnum.Remote]: () => emit("install"),
|
[GameStatusEnum.Remote]: () => emit("install"),
|
||||||
[GameStatusEnum.Queued]: () => emit("queue"),
|
[GameStatusEnum.Queued]: () => emit("queue"),
|
||||||
[GameStatusEnum.Downloading]: () => emit("queue"),
|
[GameStatusEnum.Downloading]: () => emit("queue"),
|
||||||
|
[GameStatusEnum.Validating]: () => emit("queue"),
|
||||||
[GameStatusEnum.SetupRequired]: () => emit("launch"),
|
[GameStatusEnum.SetupRequired]: () => emit("launch"),
|
||||||
[GameStatusEnum.Installed]: () => emit("launch"),
|
[GameStatusEnum.Installed]: () => emit("launch"),
|
||||||
[GameStatusEnum.Updating]: () => emit("queue"),
|
[GameStatusEnum.Updating]: () => emit("queue"),
|
||||||
[GameStatusEnum.Uninstalling]: () => {},
|
[GameStatusEnum.Uninstalling]: () => {},
|
||||||
[GameStatusEnum.Running]: () => emit("kill")
|
[GameStatusEnum.Running]: () => emit("kill"),
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: () => emit("resume"),
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
v-for="(nav, navIdx) in navigation"
|
v-for="(nav, navIdx) in navigation"
|
||||||
:class="[
|
:class="[
|
||||||
'transition uppercase font-display font-semibold text-md',
|
'transition uppercase font-display font-semibold text-md',
|
||||||
navIdx === currentPageIndex
|
navIdx === currentNavigation
|
||||||
? 'text-zinc-100'
|
? 'text-zinc-100'
|
||||||
: 'text-zinc-400 hover:text-zinc-200',
|
: 'text-zinc-400 hover:text-zinc-200',
|
||||||
]"
|
]"
|
||||||
@ -28,9 +28,7 @@
|
|||||||
/>
|
/>
|
||||||
<div class="inline-flex items-center">
|
<div class="inline-flex items-center">
|
||||||
<ol class="inline-flex gap-3">
|
<ol class="inline-flex gap-3">
|
||||||
<HeaderQueueWidget
|
<HeaderQueueWidget :object="currentQueueObject" />
|
||||||
:object="currentQueueObject"
|
|
||||||
/>
|
|
||||||
<li v-for="(item, itemIdx) in quickActions">
|
<li v-for="(item, itemIdx) in quickActions">
|
||||||
<HeaderWidget
|
<HeaderWidget
|
||||||
@click="item.action"
|
@click="item.action"
|
||||||
@ -39,21 +37,23 @@
|
|||||||
<component class="h-5" :is="item.icon" />
|
<component class="h-5" :is="item.icon" />
|
||||||
</HeaderWidget>
|
</HeaderWidget>
|
||||||
</li>
|
</li>
|
||||||
|
<OfflineHeaderWidget v-if="state.status === AppStatus.Offline" />
|
||||||
<HeaderUserWidget />
|
<HeaderUserWidget />
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<WindowControl class="h-16 w-16 p-4" />
|
<WindowControl />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { BellIcon, UserGroupIcon } from "@heroicons/vue/16/solid";
|
import { BellIcon, UserGroupIcon } from "@heroicons/vue/16/solid";
|
||||||
import type { NavigationItem, QuickActionNav } from "../types";
|
import { AppStatus, type NavigationItem, type QuickActionNav } from "../types";
|
||||||
import HeaderWidget from "./HeaderWidget.vue";
|
import HeaderWidget from "./HeaderWidget.vue";
|
||||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
|
|
||||||
const window = getCurrentWindow();
|
const window = getCurrentWindow();
|
||||||
|
const state = useAppState();
|
||||||
|
|
||||||
const navigation: Array<NavigationItem> = [
|
const navigation: Array<NavigationItem> = [
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ const navigation: Array<NavigationItem> = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const currentPageIndex = useCurrentNavigationIndex(navigation);
|
const { currentNavigation } = useCurrentNavigationIndex(navigation);
|
||||||
|
|
||||||
const quickActions: Array<QuickActionNav> = [
|
const quickActions: Array<QuickActionNav> = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<button class="transition h-10 w-10 text-zinc-300 hover:bg-zinc-800 hover:text-zinc-100 p-2">
|
<button class="transition h-full aspect-square text-zinc-300 hover:bg-zinc-800 hover:text-zinc-100 p-[1.1rem]">
|
||||||
<slot />
|
<slot />
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<MenuItems
|
<MenuItems
|
||||||
class="absolute bg-zinc-900 right-0 top-10 z-50 w-56 origin-top-right focus:outline-none shadow-md"
|
class="absolute bg-zinc-900 right-0 top-10 z-50 w-56 origin-top-right focus:outline-none shadow-md"
|
||||||
>
|
>
|
||||||
<PanelWidget class="flex-col gap-y-2">
|
<div class="flex-col gap-y-2">
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
to="/id/me"
|
to="/id/me"
|
||||||
class="transition inline-flex items-center w-full py-3 px-4 hover:bg-zinc-800"
|
class="transition inline-flex items-center w-full py-3 px-4 hover:bg-zinc-800"
|
||||||
@ -49,7 +49,10 @@
|
|||||||
Admin Dashboard
|
Admin Dashboard
|
||||||
</a>
|
</a>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem v-for="(nav, navIdx) in navigation" v-slot="{ active, close }">
|
<MenuItem
|
||||||
|
v-for="(nav, navIdx) in navigation"
|
||||||
|
v-slot="{ active, close }"
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
@click="() => navigate(close, nav)"
|
@click="() => navigate(close, nav)"
|
||||||
:href="nav.route"
|
:href="nav.route"
|
||||||
@ -58,11 +61,11 @@
|
|||||||
'transition text-left block px-4 py-2 text-sm',
|
'transition text-left block px-4 py-2 text-sm',
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
{{ nav.label }}</button
|
{{ nav.label }}
|
||||||
>
|
</button>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</div>
|
</div>
|
||||||
</PanelWidget>
|
</div>
|
||||||
</MenuItems>
|
</MenuItems>
|
||||||
</transition>
|
</transition>
|
||||||
</Menu>
|
</Menu>
|
||||||
@ -80,12 +83,12 @@ const open = ref(false);
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
})
|
});
|
||||||
|
|
||||||
const state = useAppState();
|
const state = useAppState();
|
||||||
const profilePictureUrl: string = await invoke("gen_drop_url", {
|
const profilePictureUrl: string = await useObject(
|
||||||
path: `/api/v1/object/${state.value.user?.profilePicture}`,
|
state.value.user?.profilePictureObjectId ?? ""
|
||||||
});
|
);
|
||||||
const adminUrl: string = await invoke("gen_drop_url", {
|
const adminUrl: string = await invoke("gen_drop_url", {
|
||||||
path: "/admin",
|
path: "/admin",
|
||||||
});
|
});
|
||||||
@ -96,11 +99,6 @@ function navigate(close: () => any, to: NavigationItem){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const navigation: NavigationItem[] = [
|
const navigation: NavigationItem[] = [
|
||||||
{
|
|
||||||
label: "Account settings",
|
|
||||||
route: "/account",
|
|
||||||
prefix: "",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: "App settings",
|
label: "App settings",
|
||||||
route: "/settings",
|
route: "/settings",
|
||||||
@ -110,6 +108,6 @@ const navigation: NavigationItem[] = [
|
|||||||
label: "Quit Drop",
|
label: "Quit Drop",
|
||||||
route: "/quit",
|
route: "/quit",
|
||||||
prefix: "",
|
prefix: "",
|
||||||
}
|
},
|
||||||
]
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -13,11 +13,7 @@
|
|||||||
<div class="max-w-lg">
|
<div class="max-w-lg">
|
||||||
<slot />
|
<slot />
|
||||||
<div class="mt-10">
|
<div class="mt-10">
|
||||||
<button
|
<div>
|
||||||
@click="() => authWrapper_wrapper()"
|
|
||||||
:disabled="loading"
|
|
||||||
class="text-sm text-left font-semibold leading-7 text-blue-600"
|
|
||||||
>
|
|
||||||
<div v-if="loading" role="status">
|
<div v-if="loading" role="status">
|
||||||
<svg
|
<svg
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
@ -37,10 +33,19 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span class="sr-only">Loading...</span>
|
<span class="sr-only">Loading...</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>
|
<span class="inline-flex gap-x-8 items-center" v-else>
|
||||||
Sign in with your browser <span aria-hidden="true">→</span>
|
<button
|
||||||
</span>
|
@click="() => authWrapper_wrapper()"
|
||||||
|
:disabled="loading"
|
||||||
|
class="px-3 py-1 inline-flex items-center gap-x-2 bg-zinc-700 rounded text-sm text-left font-semibold leading-7 text-white"
|
||||||
|
>
|
||||||
|
Sign in with your browser <ArrowTopRightOnSquareIcon class="size-4" />
|
||||||
</button>
|
</button>
|
||||||
|
<NuxtLink href="/auth/code" class="text-zinc-100 text-sm hover:text-zinc-300">
|
||||||
|
Use a code →
|
||||||
|
</NuxtLink>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mt-5" v-if="offerManual">
|
<div class="mt-5" v-if="offerManual">
|
||||||
<h1 class="text-zinc-100 font-semibold">Having trouble?</h1>
|
<h1 class="text-zinc-100 font-semibold">Having trouble?</h1>
|
||||||
@ -121,11 +126,13 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { XCircleIcon } from "@heroicons/vue/16/solid";
|
import { XCircleIcon } from "@heroicons/vue/16/solid";
|
||||||
|
import { ArrowTopRightOnSquareIcon } from "@heroicons/vue/20/solid";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const error = ref<string | undefined>();
|
const error = ref<string | undefined>();
|
||||||
|
|
||||||
|
let offerManualTimeout: NodeJS.Timeout | undefined;
|
||||||
const offerManual = ref(false);
|
const offerManual = ref(false);
|
||||||
const manualToken = ref("");
|
const manualToken = ref("");
|
||||||
const manualLoading = ref(false);
|
const manualLoading = ref(false);
|
||||||
@ -135,14 +142,16 @@ async function auth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function authWrapper_wrapper() {
|
function authWrapper_wrapper() {
|
||||||
|
error.value = undefined;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
auth().catch((e) => {
|
auth().catch((e) => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
error.value = e;
|
error.value = e;
|
||||||
|
if (offerManualTimeout) clearTimeout(offerManualTimeout);
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
offerManualTimeout = setTimeout(() => {
|
||||||
offerManual.value = true;
|
offerManual.value = true;
|
||||||
}, 10000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function continueManual() {
|
async function continueManual() {
|
||||||
|
|||||||
196
components/LibrarySearch.vue
Normal file
196
components/LibrarySearch.vue
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="mb-3 inline-flex gap-x-2">
|
||||||
|
<div
|
||||||
|
class="relative transition-transform duration-300 hover:scale-105 active:scale-95"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3"
|
||||||
|
>
|
||||||
|
<MagnifyingGlassIcon
|
||||||
|
class="h-5 w-5 text-zinc-400"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="searchQuery"
|
||||||
|
class="block w-full rounded-lg border-0 bg-zinc-800/50 py-2 pl-10 pr-3 text-zinc-100 placeholder:text-zinc-500 focus:bg-zinc-800 focus:ring-2 focus:ring-inset focus:ring-blue-500 sm:text-sm sm:leading-6"
|
||||||
|
placeholder="Search library..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="() => calculateGames(true)"
|
||||||
|
class="p-1 flex items-center justify-center transition-transform duration-300 size-10 hover:scale-110 active:scale-90 rounded-lg bg-zinc-800/50 text-zinc-100"
|
||||||
|
>
|
||||||
|
<ArrowPathIcon class="size-4" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TransitionGroup name="list" tag="ul" class="flex flex-col gap-y-1.5">
|
||||||
|
<NuxtLink
|
||||||
|
v-for="nav in filteredNavigation"
|
||||||
|
:key="nav.id"
|
||||||
|
:class="[
|
||||||
|
'transition-all duration-300 rounded-lg flex items-center py-2 px-3 hover:scale-105 active:scale-95 hover:shadow-lg hover:shadow-zinc-950/50',
|
||||||
|
nav.index === currentNavigation
|
||||||
|
? 'bg-zinc-800 text-zinc-100 shadow-md shadow-zinc-950/20'
|
||||||
|
: nav.isInstalled.value
|
||||||
|
? 'text-zinc-300 hover:bg-zinc-800/90 hover:text-zinc-200'
|
||||||
|
: 'text-zinc-500 hover:bg-zinc-800/70 hover:text-zinc-300',
|
||||||
|
]"
|
||||||
|
:href="nav.route"
|
||||||
|
>
|
||||||
|
<div class="flex items-center w-full gap-x-3">
|
||||||
|
<div
|
||||||
|
class="flex-none transition-transform duration-300 hover:-rotate-2"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
class="size-8 object-cover bg-zinc-900 rounded-lg transition-all duration-300 shadow-sm"
|
||||||
|
:src="icons[nav.id]"
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col flex-1">
|
||||||
|
<p
|
||||||
|
class="truncate text-xs font-display leading-5 flex-1 font-semibold"
|
||||||
|
>
|
||||||
|
{{ nav.label }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="text-xs font-medium"
|
||||||
|
:class="[gameStatusTextStyle[games[nav.id].status.value.type]]"
|
||||||
|
>
|
||||||
|
{{ gameStatusText[games[nav.id].status.value.type] }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NuxtLink>
|
||||||
|
</TransitionGroup>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ArrowPathIcon, MagnifyingGlassIcon } from "@heroicons/vue/20/solid";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { GameStatusEnum, type Game, type GameStatus } from "~/types";
|
||||||
|
import { TransitionGroup } from "vue";
|
||||||
|
import { listen } from "@tauri-apps/api/event";
|
||||||
|
|
||||||
|
// Style information
|
||||||
|
const gameStatusTextStyle: { [key in GameStatusEnum]: string } = {
|
||||||
|
[GameStatusEnum.Installed]: "text-green-500",
|
||||||
|
[GameStatusEnum.Downloading]: "text-blue-500",
|
||||||
|
[GameStatusEnum.Validating]: "text-blue-300",
|
||||||
|
[GameStatusEnum.Running]: "text-green-500",
|
||||||
|
[GameStatusEnum.Remote]: "text-zinc-500",
|
||||||
|
[GameStatusEnum.Queued]: "text-blue-500",
|
||||||
|
[GameStatusEnum.Updating]: "text-blue-500",
|
||||||
|
[GameStatusEnum.Uninstalling]: "text-zinc-100",
|
||||||
|
[GameStatusEnum.SetupRequired]: "text-yellow-500",
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: "text-gray-400",
|
||||||
|
};
|
||||||
|
const gameStatusText: { [key in GameStatusEnum]: string } = {
|
||||||
|
[GameStatusEnum.Remote]: "Not installed",
|
||||||
|
[GameStatusEnum.Queued]: "Queued",
|
||||||
|
[GameStatusEnum.Downloading]: "Downloading...",
|
||||||
|
[GameStatusEnum.Validating]: "Validating...",
|
||||||
|
[GameStatusEnum.Installed]: "Installed",
|
||||||
|
[GameStatusEnum.Updating]: "Updating...",
|
||||||
|
[GameStatusEnum.Uninstalling]: "Uninstalling...",
|
||||||
|
[GameStatusEnum.SetupRequired]: "Setup required",
|
||||||
|
[GameStatusEnum.Running]: "Running",
|
||||||
|
[GameStatusEnum.PartiallyInstalled]: "Partially installed",
|
||||||
|
};
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const searchQuery = ref("");
|
||||||
|
|
||||||
|
const games: {
|
||||||
|
[key: string]: { game: Game; status: Ref<GameStatus, GameStatus> };
|
||||||
|
} = {};
|
||||||
|
const icons: { [key: string]: string } = {};
|
||||||
|
|
||||||
|
const rawGames: Ref<Game[], Game[]> = ref([]);
|
||||||
|
|
||||||
|
async function calculateGames(clearAll = false) {
|
||||||
|
if (clearAll) rawGames.value = [];
|
||||||
|
// If we update immediately, the navigation gets re-rendered before we
|
||||||
|
// add all the necessary state, and it freaks tf out
|
||||||
|
const newGames = await invoke<typeof rawGames.value>("fetch_library");
|
||||||
|
for (const game of newGames) {
|
||||||
|
if (games[game.id]) continue;
|
||||||
|
games[game.id] = await useGame(game.id);
|
||||||
|
}
|
||||||
|
for (const game of newGames) {
|
||||||
|
if (icons[game.id]) continue;
|
||||||
|
icons[game.id] = await useObject(game.mIconObjectId);
|
||||||
|
}
|
||||||
|
rawGames.value = newGames;
|
||||||
|
}
|
||||||
|
|
||||||
|
await calculateGames();
|
||||||
|
|
||||||
|
const navigation = computed(() =>
|
||||||
|
rawGames.value.map((game) => {
|
||||||
|
const status = games[game.id].status;
|
||||||
|
|
||||||
|
const isInstalled = computed(
|
||||||
|
() =>
|
||||||
|
status.value.type == GameStatusEnum.Installed ||
|
||||||
|
status.value.type == GameStatusEnum.SetupRequired
|
||||||
|
);
|
||||||
|
|
||||||
|
const item = {
|
||||||
|
label: game.mName,
|
||||||
|
route: `/library/${game.id}`,
|
||||||
|
prefix: `/library/${game.id}`,
|
||||||
|
isInstalled,
|
||||||
|
id: game.id,
|
||||||
|
};
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
const { currentNavigation, recalculateNavigation } = useCurrentNavigationIndex(
|
||||||
|
navigation.value
|
||||||
|
);
|
||||||
|
|
||||||
|
const filteredNavigation = computed(() => {
|
||||||
|
if (!searchQuery.value)
|
||||||
|
return navigation.value.map((e, i) => ({ ...e, index: i }));
|
||||||
|
const query = searchQuery.value.toLowerCase();
|
||||||
|
return navigation.value
|
||||||
|
.filter((nav) => nav.label.toLowerCase().includes(query))
|
||||||
|
.map((e, i) => ({ ...e, index: i }));
|
||||||
|
});
|
||||||
|
|
||||||
|
listen("update_library", async (event) => {
|
||||||
|
console.log("Updating library");
|
||||||
|
let oldNavigation = navigation.value[currentNavigation.value];
|
||||||
|
await calculateGames();
|
||||||
|
recalculateNavigation();
|
||||||
|
if (oldNavigation !== navigation.value[currentNavigation.value]) {
|
||||||
|
console.log("Triggered");
|
||||||
|
router.push("/library");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.list-move,
|
||||||
|
.list-enter-active,
|
||||||
|
.list-leave-active {
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-enter-from,
|
||||||
|
.list-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(-30px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-leave-active {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
7
components/LoadingIndicator.vue
Normal file
7
components/LoadingIndicator.vue
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<template></template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const loading = useLoadingIndicator();
|
||||||
|
|
||||||
|
watch(loading.isLoading, console.log);
|
||||||
|
</script>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="h-10 cursor-pointer flex flex-row items-center justify-between bg-zinc-950"
|
class="h-16 cursor-pointer flex flex-row items-center justify-between bg-zinc-950"
|
||||||
>
|
>
|
||||||
<div class="px-5 py-3 grow" @mousedown="() => window.startDragging()">
|
<div class="px-5 py-3 grow" @mousedown="() => window.startDragging()">
|
||||||
<Wordmark class="mt-1" />
|
<Wordmark class="mt-1" />
|
||||||
|
|||||||
17
components/OfflineHeaderWidget.vue
Normal file
17
components/OfflineHeaderWidget.vue
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ArrowDownTrayIcon, CloudIcon } from "@heroicons/vue/20/solid";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="transition inline-flex items-center rounded-sm px-4 py-1.5 bg-zinc-900 text-sm text-zinc-400 gap-x-2"
|
||||||
|
>
|
||||||
|
<div class="relative">
|
||||||
|
<CloudIcon class="h-5 z-50 text-zinc-500" />
|
||||||
|
<div
|
||||||
|
class="absolute rounded-full left-1/2 top-1/2 -translate-y-[45%] -translate-x-1/2 w-[2px] h-6 rotate-[45deg] bg-zinc-400 z-50"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
Offline
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@ -1,4 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<HeaderButton v-if="showMinimise" @click="() => minimise()">
|
||||||
|
<MinusIcon />
|
||||||
|
</HeaderButton>
|
||||||
<HeaderButton @click="() => close()">
|
<HeaderButton @click="() => close()">
|
||||||
<XMarkIcon />
|
<XMarkIcon />
|
||||||
</HeaderButton>
|
</HeaderButton>
|
||||||
@ -8,11 +11,14 @@
|
|||||||
import { MinusIcon, XMarkIcon } from "@heroicons/vue/16/solid";
|
import { MinusIcon, XMarkIcon } from "@heroicons/vue/16/solid";
|
||||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
|
|
||||||
|
const window = getCurrentWindow();
|
||||||
|
const showMinimise = await window.isMinimizable();
|
||||||
|
|
||||||
async function close() {
|
async function close() {
|
||||||
console.log(window);
|
await window.close();
|
||||||
const result = await window.close();
|
|
||||||
console.log(`closed window: ${result}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const window = getCurrentWindow();
|
async function minimise() {
|
||||||
|
await window.minimize();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -26,5 +26,7 @@ export const useCurrentNavigationIndex = (
|
|||||||
currentNavigation.value = calculateCurrentNavIndex(to);
|
currentNavigation.value = calculateCurrentNavIndex(to);
|
||||||
});
|
});
|
||||||
|
|
||||||
return currentNavigation;
|
return {currentNavigation, recalculateNavigation: () => {
|
||||||
|
currentNavigation.value = calculateCurrentNavIndex(route);
|
||||||
|
}};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import type { Game, GameStatus, GameStatusEnum } from "~/types";
|
import type { Game, GameStatus, GameStatusEnum, GameVersion } from "~/types";
|
||||||
|
|
||||||
const gameRegistry: { [key: string]: Game } = {};
|
const gameRegistry: { [key: string]: { game: Game; version?: GameVersion } } =
|
||||||
|
{};
|
||||||
|
|
||||||
const gameStatusRegistry: { [key: string]: Ref<GameStatus> } = {};
|
const gameStatusRegistry: { [key: string]: Ref<GameStatus> } = {};
|
||||||
|
|
||||||
@ -13,7 +14,6 @@ export type SerializedGameStatus = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const parseStatus = (status: SerializedGameStatus): GameStatus => {
|
export const parseStatus = (status: SerializedGameStatus): GameStatus => {
|
||||||
console.log(status);
|
|
||||||
if (status[0]) {
|
if (status[0]) {
|
||||||
return {
|
return {
|
||||||
type: status[0].type,
|
type: status[0].type,
|
||||||
@ -31,27 +31,43 @@ export const parseStatus = (status: SerializedGameStatus): GameStatus => {
|
|||||||
|
|
||||||
export const useGame = async (gameId: string) => {
|
export const useGame = async (gameId: string) => {
|
||||||
if (!gameRegistry[gameId]) {
|
if (!gameRegistry[gameId]) {
|
||||||
const data: { game: Game; status: SerializedGameStatus } = await invoke(
|
const data: {
|
||||||
"fetch_game",
|
game: Game;
|
||||||
{
|
status: SerializedGameStatus;
|
||||||
|
version?: GameVersion;
|
||||||
|
} = await invoke("fetch_game", {
|
||||||
gameId,
|
gameId,
|
||||||
}
|
});
|
||||||
);
|
gameRegistry[gameId] = { game: data.game, version: data.version };
|
||||||
gameRegistry[gameId] = data.game;
|
|
||||||
if (!gameStatusRegistry[gameId]) {
|
if (!gameStatusRegistry[gameId]) {
|
||||||
gameStatusRegistry[gameId] = ref(parseStatus(data.status));
|
gameStatusRegistry[gameId] = ref(parseStatus(data.status));
|
||||||
|
|
||||||
listen(`update_game/${gameId}`, (event) => {
|
listen(`update_game/${gameId}`, (event) => {
|
||||||
const payload: {
|
const payload: {
|
||||||
status: SerializedGameStatus;
|
status: SerializedGameStatus;
|
||||||
|
version?: GameVersion;
|
||||||
} = event.payload as any;
|
} = event.payload as any;
|
||||||
console.log(payload.status);
|
|
||||||
gameStatusRegistry[gameId].value = parseStatus(payload.status);
|
gameStatusRegistry[gameId].value = parseStatus(payload.status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I am not super happy about this.
|
||||||
|
*
|
||||||
|
* This will mean that we will still have a version assigned if we have a game installed then uninstall it.
|
||||||
|
* It is necessary because a flag to check if we should overwrite seems excessive, and this function gets called
|
||||||
|
* on transient state updates.
|
||||||
|
*/
|
||||||
|
if (payload.version) {
|
||||||
|
gameRegistry[gameId].version = payload.version;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const game = gameRegistry[gameId];
|
const game = gameRegistry[gameId];
|
||||||
const status = gameStatusRegistry[gameId];
|
const status = gameStatusRegistry[gameId];
|
||||||
return { game, status };
|
return { ...game, status };
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FrontendGameConfiguration = {
|
||||||
|
launchString: string;
|
||||||
};
|
};
|
||||||
@ -1,9 +1,11 @@
|
|||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { data } from "autoprefixer";
|
import { data } from "autoprefixer";
|
||||||
import { AppStatus, type AppState } from "~/types";
|
import { AppStatus, type AppState } from "~/types";
|
||||||
|
|
||||||
export function setupHooks() {
|
export function setupHooks() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const state = useAppState();
|
||||||
|
|
||||||
listen("auth/processing", (event) => {
|
listen("auth/processing", (event) => {
|
||||||
router.push("/auth/processing");
|
router.push("/auth/processing");
|
||||||
@ -15,8 +17,9 @@ export function setupHooks() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
listen("auth/finished", (event) => {
|
listen("auth/finished", async (event) => {
|
||||||
router.push("/store");
|
router.push("/library");
|
||||||
|
state.value = JSON.parse(await invoke("fetch_state"));
|
||||||
});
|
});
|
||||||
|
|
||||||
listen("download_error", (event) => {
|
listen("download_error", (event) => {
|
||||||
@ -27,12 +30,31 @@ export function setupHooks() {
|
|||||||
description: `Drop encountered an error while downloading your game: "${(
|
description: `Drop encountered an error while downloading your game: "${(
|
||||||
event.payload as unknown as string
|
event.payload as unknown as string
|
||||||
).toString()}"`,
|
).toString()}"`,
|
||||||
buttonText: "Close"
|
buttonText: "Close",
|
||||||
},
|
},
|
||||||
(e, c) => c()
|
(e, c) => c()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// This is for errors that (we think) aren't our fault
|
||||||
|
listen("launch_external_error", (event) => {
|
||||||
|
createModal(
|
||||||
|
ModalType.Confirmation,
|
||||||
|
{
|
||||||
|
title: "Did something go wrong?",
|
||||||
|
description:
|
||||||
|
"Drop detected that something might've gone wrong with launching your game. Do you want to open the log directory?",
|
||||||
|
buttonText: "Open",
|
||||||
|
},
|
||||||
|
async (e, c) => {
|
||||||
|
if (e == "confirm") {
|
||||||
|
await invoke("open_process_logs", { gameId: event.payload });
|
||||||
|
}
|
||||||
|
c();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
document.addEventListener("contextmenu", (event) => {
|
document.addEventListener("contextmenu", (event) => {
|
||||||
@ -60,6 +82,6 @@ export function initialNavigation(state: Ref<AppState>) {
|
|||||||
router.push("/error/serverunavailable");
|
router.push("/error/serverunavailable");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
router.push("/store");
|
router.push("/library");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
drop-base
Submodule
1
drop-base
Submodule
Submodule drop-base added at 26698e5b06
90
error.vue
Normal file
90
error.vue
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<template>
|
||||||
|
<NuxtLayout name="default">
|
||||||
|
<div
|
||||||
|
class="grid min-h-full grid-cols-1 grid-rows-[1fr,auto,1fr] lg:grid-cols-[max(50%,36rem),1fr]"
|
||||||
|
>
|
||||||
|
<header
|
||||||
|
class="mx-auto w-full max-w-7xl px-6 pt-6 sm:pt-10 lg:col-span-2 lg:col-start-1 lg:row-start-1 lg:px-8"
|
||||||
|
>
|
||||||
|
<Logo class="h-10 w-auto sm:h-12" />
|
||||||
|
</header>
|
||||||
|
<main
|
||||||
|
class="mx-auto w-full max-w-7xl px-6 py-24 sm:py-32 lg:col-span-2 lg:col-start-1 lg:row-start-2 lg:px-8"
|
||||||
|
>
|
||||||
|
<div class="max-w-lg">
|
||||||
|
<p class="text-base font-semibold leading-8 text-blue-600">
|
||||||
|
{{ error?.statusCode }}
|
||||||
|
</p>
|
||||||
|
<h1
|
||||||
|
class="mt-4 text-3xl font-bold font-display tracking-tight text-zinc-100 sm:text-5xl"
|
||||||
|
>
|
||||||
|
Oh no!
|
||||||
|
</h1>
|
||||||
|
<p
|
||||||
|
v-if="message"
|
||||||
|
class="mt-3 font-bold text-base leading-7 text-red-500"
|
||||||
|
>
|
||||||
|
{{ message }}
|
||||||
|
</p>
|
||||||
|
<p class="mt-6 text-base leading-7 text-zinc-400">
|
||||||
|
An error occurred while responding to your request. If you believe
|
||||||
|
this to be a bug, please report it. Try signing in and see if it
|
||||||
|
resolves the issue.
|
||||||
|
</p>
|
||||||
|
<div class="mt-10">
|
||||||
|
<!-- full app reload to fix errors -->
|
||||||
|
<a
|
||||||
|
href="/store"
|
||||||
|
class="text-sm font-semibold leading-7 text-blue-600"
|
||||||
|
><span aria-hidden="true">←</span> Back to store</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<footer class="self-end lg:col-span-2 lg:col-start-1 lg:row-start-3">
|
||||||
|
<div class="border-t border-zinc-700 bg-zinc-900 py-10">
|
||||||
|
<nav
|
||||||
|
class="mx-auto flex w-full max-w-7xl items-center gap-x-4 px-6 text-sm leading-7 text-zinc-400 lg:px-8"
|
||||||
|
>
|
||||||
|
<NuxtLink href="/docs">Documentation</NuxtLink>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 2 2"
|
||||||
|
aria-hidden="true"
|
||||||
|
class="h-0.5 w-0.5 fill-zinc-600"
|
||||||
|
>
|
||||||
|
<circle cx="1" cy="1" r="1" />
|
||||||
|
</svg>
|
||||||
|
<a href="https://discord.gg/NHx46XKJWA" target="_blank"
|
||||||
|
>Support Discord</a
|
||||||
|
>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<div
|
||||||
|
class="hidden lg:relative lg:col-start-2 lg:row-start-1 lg:row-end-4 lg:block"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="@/assets/wallpaper.jpg"
|
||||||
|
alt=""
|
||||||
|
class="absolute inset-0 h-full w-full object-cover"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NuxtLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { NuxtError } from "#app";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
error: Object as () => NuxtError,
|
||||||
|
});
|
||||||
|
|
||||||
|
const statusCode = props.error?.statusCode;
|
||||||
|
const message =
|
||||||
|
props.error?.statusMessage ||
|
||||||
|
props.error?.message ||
|
||||||
|
"An unknown error occurred.";
|
||||||
|
|
||||||
|
console.error(props.error);
|
||||||
|
</script>
|
||||||
@ -1,9 +1,79 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col bg-zinc-900 overflow-hidden">
|
<div class="flex flex-col bg-zinc-900 overflow-hidden h-screen">
|
||||||
|
<NuxtErrorBoundary>
|
||||||
<Header class="select-none" />
|
<Header class="select-none" />
|
||||||
<div class="relative grow overflow-y-auto">
|
<div class="relative grow overflow-y-auto">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
<template #error="{ error }">
|
||||||
|
<MiniHeader />
|
||||||
|
<div class="relative grow overflow-y-auto bg-zinc-950">
|
||||||
|
<div
|
||||||
|
class="grid min-h-full grid-cols-1 grid-rows-[1fr,auto,1fr] lg:grid-cols-[max(50%,36rem),1fr]"
|
||||||
|
>
|
||||||
|
<header
|
||||||
|
class="mx-auto w-full max-w-7xl px-6 pt-6 sm:pt-10 lg:col-span-2 lg:col-start-1 lg:row-start-1 lg:px-8"
|
||||||
|
>
|
||||||
|
<Logo class="h-10 w-auto sm:h-12" />
|
||||||
|
</header>
|
||||||
|
<main
|
||||||
|
class="mx-auto w-full max-w-7xl px-6 py-24 sm:py-32 lg:col-span-2 lg:col-start-1 lg:row-start-2 lg:px-8"
|
||||||
|
>
|
||||||
|
<div class="max-w-lg">
|
||||||
|
<h1
|
||||||
|
class="mt-4 text-3xl font-bold font-display tracking-tight text-zinc-100 sm:text-5xl"
|
||||||
|
>
|
||||||
|
Unrecoverable error
|
||||||
|
</h1>
|
||||||
|
<p class="mt-6 text-base leading-7 text-zinc-400">
|
||||||
|
Drop encountered an error that it couldn't handle. Please
|
||||||
|
restart the application and file a bug report.
|
||||||
|
</p>
|
||||||
|
<p class="mt-3 text-sm font-monospace text-zinc-500">
|
||||||
|
Error: {{ error }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<footer
|
||||||
|
class="self-end lg:col-span-2 lg:col-start-1 lg:row-start-3"
|
||||||
|
>
|
||||||
|
<div class="border-t border-blue-600 bg-zinc-900 py-10">
|
||||||
|
<nav
|
||||||
|
class="mx-auto flex w-full max-w-7xl items-center gap-x-4 px-6 text-sm leading-7 text-zinc-400 lg:px-8"
|
||||||
|
>
|
||||||
|
<a href="#">Documentation</a>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 2 2"
|
||||||
|
aria-hidden="true"
|
||||||
|
class="h-0.5 w-0.5 fill-zinc-700"
|
||||||
|
>
|
||||||
|
<circle cx="1" cy="1" r="1" />
|
||||||
|
</svg>
|
||||||
|
<a href="#">Troubleshooting</a>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 2 2"
|
||||||
|
aria-hidden="true"
|
||||||
|
class="h-0.5 w-0.5 fill-zinc-700"
|
||||||
|
>
|
||||||
|
<circle cx="1" cy="1" r="1" />
|
||||||
|
</svg>
|
||||||
|
<NuxtLink to="/setup/server">Switch instance</NuxtLink>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<div
|
||||||
|
class="hidden lg:relative lg:col-start-2 lg:row-start-1 lg:row-end-4 lg:block"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="@/assets/wallpaper.jpg"
|
||||||
|
alt=""
|
||||||
|
class="absolute inset-0 h-full w-full object-cover"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NuxtErrorBoundary>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col bg-zinc-950 overflow-hidden">
|
<div class="flex flex-col bg-zinc-950 overflow-hidden h-screen">
|
||||||
<MiniHeader />
|
<MiniHeader />
|
||||||
<div class="relative grow overflow-y-auto">
|
<div class="relative grow overflow-y-auto">
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@ -13,5 +13,5 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
ssr: false,
|
ssr: false,
|
||||||
|
|
||||||
extends: [["github:drop-oss/drop-base"]],
|
extends: [["./drop-base"]],
|
||||||
});
|
});
|
||||||
|
|||||||
13
package.json
13
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "drop-app",
|
"name": "drop-app",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.1",
|
"version": "0.3.1-appimage",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxt build",
|
"build": "nuxt build",
|
||||||
@ -18,10 +18,13 @@
|
|||||||
"@tauri-apps/api": ">=2.0.0",
|
"@tauri-apps/api": ">=2.0.0",
|
||||||
"@tauri-apps/plugin-deep-link": "~2",
|
"@tauri-apps/plugin-deep-link": "~2",
|
||||||
"@tauri-apps/plugin-dialog": "^2.0.1",
|
"@tauri-apps/plugin-dialog": "^2.0.1",
|
||||||
|
"@tauri-apps/plugin-opener": "^2.4.0",
|
||||||
"@tauri-apps/plugin-os": "~2",
|
"@tauri-apps/plugin-os": "~2",
|
||||||
"@tauri-apps/plugin-shell": ">=2.0.0",
|
"@tauri-apps/plugin-shell": "^2.2.1",
|
||||||
|
"koa": "^2.16.1",
|
||||||
"markdown-it": "^14.1.0",
|
"markdown-it": "^14.1.0",
|
||||||
"nuxt": "^3.13.0",
|
"micromark": "^4.0.1",
|
||||||
|
"nuxt": "^3.16.0",
|
||||||
"scss": "^0.2.4",
|
"scss": "^0.2.4",
|
||||||
"vue": "latest",
|
"vue": "latest",
|
||||||
"vue-router": "latest",
|
"vue-router": "latest",
|
||||||
@ -35,7 +38,9 @@
|
|||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.47",
|
||||||
"sass-embedded": "^1.79.4",
|
"sass-embedded": "^1.79.4",
|
||||||
"tailwindcss": "^3.4.13"
|
"tailwindcss": "^3.4.13",
|
||||||
|
"typescript": "^5.8.3",
|
||||||
|
"vue-tsc": "^2.2.10"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,72 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="mx-auto max-w-7xl px-8">
|
|
||||||
<div class="border-b border-zinc-700 py-5">
|
|
||||||
<h3 class="text-base font-semibold font-display leading-6 text-zinc-100">
|
|
||||||
Account
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-5">
|
|
||||||
<div class="divide-y divide-zinc-700">
|
|
||||||
<div class="py-6">
|
|
||||||
<div class="flex flex-col gap-4">
|
|
||||||
<div class="flex flex-row items-center justify-between">
|
|
||||||
<div>
|
|
||||||
<h3 class="text-sm font-medium leading-6 text-zinc-100">Sign out</h3>
|
|
||||||
<p class="mt-1 text-sm leading-6 text-zinc-400">
|
|
||||||
Sign out of your Drop account on this device
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
@click="signOut"
|
|
||||||
type="button"
|
|
||||||
class="rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-600"
|
|
||||||
>
|
|
||||||
Sign out
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="error" class="rounded-md bg-red-600/10 p-4">
|
|
||||||
<div class="flex">
|
|
||||||
<div class="flex-shrink-0">
|
|
||||||
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
|
|
||||||
</div>
|
|
||||||
<div class="ml-3">
|
|
||||||
<h3 class="text-sm font-medium text-red-600">
|
|
||||||
{{ error }}
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
|
||||||
import { listen } from '@tauri-apps/api/event'
|
|
||||||
import { useRouter } from '#imports'
|
|
||||||
import { XCircleIcon } from "@heroicons/vue/16/solid";
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const error = ref<string | null>(null)
|
|
||||||
|
|
||||||
// Listen for auth events
|
|
||||||
onMounted(async () => {
|
|
||||||
await listen('auth/signedout', () => {
|
|
||||||
router.push('/auth/signedout')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
async function signOut() {
|
|
||||||
try {
|
|
||||||
error.value = null
|
|
||||||
await invoke('sign_out')
|
|
||||||
} catch (e) {
|
|
||||||
error.value = `Failed to sign out: ${e}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
37
pages/auth/code.vue
Normal file
37
pages/auth/code.vue
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<div class="min-h-full w-full flex items-center justify-center">
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
||||||
|
Device authorization
|
||||||
|
</h1>
|
||||||
|
<div class="mt-4">
|
||||||
|
<p class="text-sm text-zinc-400 max-w-md mx-auto">
|
||||||
|
Open Drop on another one of your devices, and use your account
|
||||||
|
dropdown to "Authorize client", and enter the code below.
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
class="mt-8 flex items-center justify-center gap-x-5 text-8xl font-bold text-zinc-100"
|
||||||
|
>
|
||||||
|
<span v-for="letter in code.split('')">{{ letter }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-10 flex items-center justify-center gap-x-6">
|
||||||
|
<NuxtLink href="/auth" class="text-sm font-semibold text-blue-600"
|
||||||
|
><span aria-hidden="true">←</span> Use a different method
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
|
const code = await invoke<string>("auth_initiate_code");
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
layout: "mini",
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@ -1,66 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div
|
|
||||||
class="grid min-h-full grid-cols-1 grid-rows-[1fr,auto,1fr] lg:grid-cols-[max(50%,36rem),1fr]"
|
|
||||||
>
|
|
||||||
<header
|
|
||||||
class="mx-auto w-full max-w-7xl px-6 pt-6 sm:pt-10 lg:col-span-2 lg:col-start-1 lg:row-start-1 lg:px-8"
|
|
||||||
>
|
|
||||||
<Logo class="h-10 w-auto sm:h-12" />
|
|
||||||
</header>
|
|
||||||
<main
|
|
||||||
class="mx-auto w-full max-w-7xl px-6 py-24 sm:py-32 lg:col-span-2 lg:col-start-1 lg:row-start-2 lg:px-8"
|
|
||||||
>
|
|
||||||
<div class="max-w-lg">
|
|
||||||
<h1
|
|
||||||
class="mt-4 text-3xl font-bold font-display tracking-tight text-zinc-100 sm:text-5xl"
|
|
||||||
>
|
|
||||||
Unrecoverable error
|
|
||||||
</h1>
|
|
||||||
<p class="mt-6 text-base leading-7 text-zinc-400">
|
|
||||||
Drop encountered an error that it couldn't handle. Please restart the
|
|
||||||
application and file a bug report.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
<footer class="self-end lg:col-span-2 lg:col-start-1 lg:row-start-3">
|
|
||||||
<div class="border-t border-blue-600 bg-zinc-900 py-10">
|
|
||||||
<nav
|
|
||||||
class="mx-auto flex w-full max-w-7xl items-center gap-x-4 px-6 text-sm leading-7 text-zinc-400 lg:px-8"
|
|
||||||
>
|
|
||||||
<a href="#">Documentation</a>
|
|
||||||
<svg
|
|
||||||
viewBox="0 0 2 2"
|
|
||||||
aria-hidden="true"
|
|
||||||
class="h-0.5 w-0.5 fill-zinc-700"
|
|
||||||
>
|
|
||||||
<circle cx="1" cy="1" r="1" />
|
|
||||||
</svg>
|
|
||||||
<a href="#">Troubleshooting</a>
|
|
||||||
<svg
|
|
||||||
viewBox="0 0 2 2"
|
|
||||||
aria-hidden="true"
|
|
||||||
class="h-0.5 w-0.5 fill-zinc-700"
|
|
||||||
>
|
|
||||||
<circle cx="1" cy="1" r="1" />
|
|
||||||
</svg>
|
|
||||||
<NuxtLink to="/setup/server">Switch instance</NuxtLink>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<div
|
|
||||||
class="hidden lg:relative lg:col-start-2 lg:row-start-1 lg:row-end-4 lg:block"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="@/assets/wallpaper.jpg"
|
|
||||||
alt=""
|
|
||||||
class="absolute inset-0 h-full w-full object-cover"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
definePageMeta({
|
|
||||||
layout: "mini",
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@ -1,66 +1,52 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-row h-full">
|
<div class="flex flex-row h-full">
|
||||||
|
<!-- Sidebar -->
|
||||||
<div
|
<div
|
||||||
class="flex-none max-h-full overflow-y-auto w-64 bg-zinc-950 px-2 py-1"
|
class="flex-none max-h-full overflow-y-auto w-72 bg-zinc-950/50 backdrop-blur-xl px-4 py-3 border-r border-zinc-800/50"
|
||||||
>
|
>
|
||||||
<ul class="flex flex-col gap-y-1">
|
<LibrarySearch />
|
||||||
<NuxtLink
|
|
||||||
v-for="(nav, navIdx) in navigation"
|
|
||||||
:key="nav.route"
|
|
||||||
:class="[
|
|
||||||
'transition-all duration-200 rounded-lg flex items-center py-1.5 px-3',
|
|
||||||
navIdx === currentNavigationIndex
|
|
||||||
? 'bg-zinc-800 text-zinc-100'
|
|
||||||
: nav.isInstalled.value
|
|
||||||
? 'text-zinc-300 hover:bg-zinc-800/90 hover:text-zinc-200'
|
|
||||||
: 'text-zinc-500 hover:bg-zinc-800/70 hover:text-zinc-300',
|
|
||||||
]"
|
|
||||||
:href="nav.route"
|
|
||||||
>
|
|
||||||
<div class="flex items-center w-full gap-x-3">
|
|
||||||
<img
|
|
||||||
class="size-6 flex-none object-cover bg-zinc-900 rounded"
|
|
||||||
:src="icons[navIdx]"
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
<p class="truncate text-sm font-display leading-6 flex-1">
|
|
||||||
{{ nav.label }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</NuxtLink>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="grow overflow-y-auto">
|
<div class="grow overflow-y-auto">
|
||||||
|
<NuxtErrorBoundary>
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
|
<template #error="{ error }">
|
||||||
|
<main
|
||||||
|
class="grid min-h-full w-full place-items-center px-6 py-24 sm:py-32 lg:px-8"
|
||||||
|
>
|
||||||
|
<div class="text-center">
|
||||||
|
<p class="text-base font-semibold text-blue-600">Error</p>
|
||||||
|
<h1
|
||||||
|
class="mt-4 text-3xl font-bold font-display tracking-tight text-zinc-100 sm:text-5xl"
|
||||||
|
>
|
||||||
|
Failed to load library
|
||||||
|
</h1>
|
||||||
|
<p class="mt-6 text-base leading-7 text-zinc-400">
|
||||||
|
Drop couldn't load your library: "{{ error }}".
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
|
</NuxtErrorBoundary>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts"></script>
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
|
||||||
import { GameStatusEnum, type Game, type NavigationItem } from "~/types";
|
|
||||||
|
|
||||||
const rawGames: Array<Game> = await invoke("fetch_library");
|
<style scoped>
|
||||||
const games = await Promise.all(rawGames.map((e) => useGame(e.id)));
|
.list-move,
|
||||||
const icons = await Promise.all(
|
.list-enter-active,
|
||||||
games.map(({ game, status }) => useObject(game.mIconId))
|
.list-leave-active {
|
||||||
);
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
const navigation = games.map(({ game, status }) => {
|
.list-enter-from,
|
||||||
const isInstalled = computed(
|
.list-leave-to {
|
||||||
() =>
|
opacity: 0;
|
||||||
status.value.type == GameStatusEnum.Installed ||
|
transform: translateX(-30px);
|
||||||
status.value.type == GameStatusEnum.SetupRequired
|
}
|
||||||
);
|
|
||||||
|
|
||||||
const item = {
|
.list-leave-active {
|
||||||
label: game.mName,
|
position: absolute;
|
||||||
route: `/library/${game.id}`,
|
}
|
||||||
prefix: `/library/${game.id}`,
|
</style>
|
||||||
isInstalled,
|
|
||||||
};
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentNavigationIndex = useCurrentNavigationIndex(navigation);
|
|
||||||
</script>
|
|
||||||
|
|||||||
@ -1,52 +1,165 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="mx-auto w-full relative flex flex-col justify-center pt-64 z-10 overflow-hidden"
|
class="mx-auto w-full relative flex flex-col justify-center pt-72 overflow-hidden"
|
||||||
>
|
>
|
||||||
<!-- banner image -->
|
<div class="absolute inset-0 z-0">
|
||||||
<div class="absolute flex top-0 h-fit inset-x-0 z-[-20]">
|
<img
|
||||||
<img :src="bannerUrl" class="w-full h-auto object-cover" />
|
:src="bannerUrl"
|
||||||
|
class="w-full h-[24rem] object-cover blur-sm scale-105"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 bg-gradient-to-t from-zinc-900 via-zinc-900/80 to-transparent opacity-90"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 bg-gradient-to-r from-zinc-900/95 via-zinc-900/80 to-transparent opacity-90"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="relative z-10">
|
||||||
|
<div class="px-8 pb-4">
|
||||||
<h1
|
<h1
|
||||||
class="absolute inset-x-0 w-fit mx-auto text-center top-32 -translate-y-[50%] text-4xl text-zinc-100 font-bold font-display z-50 p-4 shadow-xl bg-zinc-900/80 rounded-xl"
|
class="text-5xl text-zinc-100 font-bold font-display drop-shadow-lg mb-8"
|
||||||
>
|
>
|
||||||
{{ game.mName }}
|
{{ game.mName }}
|
||||||
</h1>
|
</h1>
|
||||||
<div
|
|
||||||
class="absolute inset-0 bg-gradient-to-b from-transparent to-50% to-zinc-900"
|
<div class="flex flex-row gap-x-4 items-stretch mb-8">
|
||||||
/>
|
<!-- Do not add scale animations to this: https://stackoverflow.com/a/35683068 -->
|
||||||
</div>
|
|
||||||
<!-- main page -->
|
|
||||||
<div class="w-full min-h-screen mx-auto bg-zinc-900 px-5 py-6">
|
|
||||||
<!-- game toolbar -->
|
|
||||||
<div class="h-full flex flex-row gap-x-4 items-stretch">
|
|
||||||
<GameStatusButton
|
<GameStatusButton
|
||||||
@install="() => installFlow()"
|
@install="() => installFlow()"
|
||||||
@launch="() => launch()"
|
@launch="() => launch()"
|
||||||
@queue="() => queue()"
|
@queue="() => queue()"
|
||||||
@uninstall="() => uninstall()"
|
@uninstall="() => uninstall()"
|
||||||
@kill="() => kill()"
|
@kill="() => kill()"
|
||||||
|
@options="() => (configureModalOpen = true)"
|
||||||
|
@resume="() => resumeDownload()"
|
||||||
:status="status"
|
:status="status"
|
||||||
/>
|
/>
|
||||||
<a
|
<a
|
||||||
:href="remoteUrl"
|
:href="remoteUrl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex items-center rounded-md bg-zinc-800/50 px-4 font-semibold text-white shadow-sm hover:bg-zinc-800/80 uppercase font-display"
|
class="transition-transform duration-300 hover:scale-105 active:scale-95 inline-flex items-center rounded-md bg-zinc-800/50 px-6 font-semibold text-white shadow-xl backdrop-blur-sm hover:bg-zinc-800/80 uppercase font-display"
|
||||||
>
|
>
|
||||||
<BuildingStorefrontIcon class="mr-2 size-5" aria-hidden="true" />
|
<BuildingStorefrontIcon class="mr-2 size-5" aria-hidden="true" />
|
||||||
|
|
||||||
Store
|
Store
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Main content -->
|
||||||
|
<div class="w-full bg-zinc-900 px-8 py-6">
|
||||||
|
<div class="grid grid-cols-[2fr,1fr] gap-8">
|
||||||
|
<div class="space-y-6">
|
||||||
|
<div class="bg-zinc-800/50 rounded-xl p-6 backdrop-blur-sm">
|
||||||
|
<div
|
||||||
|
v-html="htmlDescription"
|
||||||
|
class="prose prose-invert prose-blue overflow-y-auto custom-scrollbar max-w-none"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-6">
|
||||||
|
<div class="bg-zinc-800/50 rounded-xl p-6 backdrop-blur-sm">
|
||||||
|
<h2 class="text-xl font-display font-semibold text-zinc-100 mb-4">
|
||||||
|
Game Images
|
||||||
|
</h2>
|
||||||
|
<div class="relative">
|
||||||
|
<div v-if="mediaUrls.length > 0">
|
||||||
|
<div
|
||||||
|
class="relative aspect-video rounded-lg overflow-hidden cursor-pointer group"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="absolute inset-0"
|
||||||
|
@click="fullscreenImage = mediaUrls[currentImageIndex]"
|
||||||
|
>
|
||||||
|
<TransitionGroup name="slide" tag="div" class="h-full">
|
||||||
|
<img
|
||||||
|
v-for="(url, index) in mediaUrls"
|
||||||
|
:key="index"
|
||||||
|
:src="url"
|
||||||
|
class="absolute inset-0 w-full h-full object-cover"
|
||||||
|
v-show="index === currentImageIndex"
|
||||||
|
/>
|
||||||
|
</TransitionGroup>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 flex items-center justify-between px-4 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none"
|
||||||
|
>
|
||||||
|
<div class="pointer-events-auto">
|
||||||
|
<button
|
||||||
|
v-if="mediaUrls.length > 1"
|
||||||
|
@click.stop="previousImage()"
|
||||||
|
class="p-2 rounded-full bg-zinc-900/50 text-zinc-100 hover:bg-zinc-900/80 transition-all duration-300 hover:scale-110"
|
||||||
|
>
|
||||||
|
<ChevronLeftIcon class="size-5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="pointer-events-auto">
|
||||||
|
<button
|
||||||
|
v-if="mediaUrls.length > 1"
|
||||||
|
@click.stop="nextImage()"
|
||||||
|
class="p-2 rounded-full bg-zinc-900/50 text-zinc-100 hover:bg-zinc-900/80 transition-all duration-300 hover:scale-110"
|
||||||
|
>
|
||||||
|
<ChevronRightIcon class="size-5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 bg-gradient-to-t from-black/50 to-transparent opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="absolute bottom-4 right-4 flex items-center gap-x-2 text-white opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none"
|
||||||
|
>
|
||||||
|
<ArrowsPointingOutIcon class="size-5" />
|
||||||
|
<span class="text-sm font-medium">View Fullscreen</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="absolute -bottom-2 left-1/2 -translate-x-1/2 flex gap-x-2"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-for="(_, index) in mediaUrls"
|
||||||
|
:key="index"
|
||||||
|
@click.stop="currentImageIndex = index"
|
||||||
|
class="w-1.5 h-1.5 rounded-full transition-all"
|
||||||
|
:class="[
|
||||||
|
currentImageIndex === index
|
||||||
|
? 'bg-zinc-100 scale-125'
|
||||||
|
: 'bg-zinc-600 hover:bg-zinc-500',
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="aspect-video rounded-lg overflow-hidden bg-zinc-900/50 flex flex-col items-center justify-center text-center px-4"
|
||||||
|
>
|
||||||
|
<PhotoIcon class="size-12 text-zinc-500 mb-2" />
|
||||||
|
<p class="text-zinc-400 font-medium">No images available</p>
|
||||||
|
<p class="text-zinc-500 text-sm">
|
||||||
|
Game screenshots will appear here when available
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ModalTemplate v-model="installFlowOpen">
|
<ModalTemplate v-model="installFlowOpen">
|
||||||
<template #default>
|
<template #default>
|
||||||
<div class="sm:flex sm:items-start">
|
<div class="sm:flex sm:items-start">
|
||||||
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
<div class="mt-3 text-center sm:mt-0 sm:text-left">
|
||||||
<DialogTitle as="h3" class="text-base font-semibold text-zinc-100"
|
<h3 class="text-base font-semibold text-zinc-100">
|
||||||
>Install {{ game.mName }}?
|
Install {{ game.mName }}?
|
||||||
</DialogTitle>
|
</h3>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<p class="text-sm text-zinc-400">
|
<p class="text-sm text-zinc-400">
|
||||||
Drop will add {{ game.mName }} to the queue to be downloaded.
|
Drop will add {{ game.mName }} to the queue to be downloaded.
|
||||||
@ -237,9 +350,7 @@
|
|||||||
<template #buttons>
|
<template #buttons>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
@click="() => install()"
|
@click="() => install()"
|
||||||
:disabled="
|
:disabled="!(versionOptions && versionOptions.length > 0)"
|
||||||
!(versionOptions && versionOptions.length > 0 && !installDir)
|
|
||||||
"
|
|
||||||
:loading="installLoading"
|
:loading="installLoading"
|
||||||
type="submit"
|
type="submit"
|
||||||
class="ml-2 w-full sm:w-fit"
|
class="ml-2 w-full sm:w-fit"
|
||||||
@ -256,14 +367,89 @@
|
|||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
</ModalTemplate>
|
</ModalTemplate>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Dear future DecDuck,
|
||||||
|
This v-if is necessary for Vue rendering reasons
|
||||||
|
(it tries to access the game version for not installed games)
|
||||||
|
You have already tried to remove it
|
||||||
|
Don't.
|
||||||
|
-->
|
||||||
|
<GameOptionsModal
|
||||||
|
v-if="status.type === GameStatusEnum.Installed"
|
||||||
|
v-model="configureModalOpen"
|
||||||
|
:game-id="game.id"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Transition
|
||||||
|
enter="transition ease-out duration-300"
|
||||||
|
enter-from="opacity-0"
|
||||||
|
enter-to="opacity-100"
|
||||||
|
leave="transition ease-in duration-200"
|
||||||
|
leave-from="opacity-100"
|
||||||
|
leave-to="opacity-0"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="fullscreenImage"
|
||||||
|
class="fixed inset-0 z-50 bg-black/95 flex items-center justify-center"
|
||||||
|
@click="fullscreenImage = null"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="relative w-full h-full flex items-center justify-center"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="absolute top-4 right-4 p-2 rounded-full bg-zinc-900/50 text-zinc-100 hover:bg-zinc-900 transition-colors"
|
||||||
|
@click.stop="fullscreenImage = null"
|
||||||
|
>
|
||||||
|
<XMarkIcon class="size-6" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
v-if="mediaUrls.length > 1"
|
||||||
|
@click.stop="previousImage()"
|
||||||
|
class="absolute left-4 p-3 rounded-full bg-zinc-900/50 text-zinc-100 hover:bg-zinc-900 transition-colors"
|
||||||
|
>
|
||||||
|
<ChevronLeftIcon class="size-6" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="mediaUrls.length > 1"
|
||||||
|
@click.stop="nextImage()"
|
||||||
|
class="absolute right-4 p-3 rounded-full bg-zinc-900/50 text-zinc-100 hover:bg-zinc-900 transition-colors"
|
||||||
|
>
|
||||||
|
<ChevronRightIcon class="size-6" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<TransitionGroup
|
||||||
|
name="slide"
|
||||||
|
tag="div"
|
||||||
|
class="w-full h-full flex items-center justify-center"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-for="(url, index) in mediaUrls"
|
||||||
|
v-show="currentImageIndex === index"
|
||||||
|
:key="index"
|
||||||
|
:src="url"
|
||||||
|
class="max-h-[90vh] max-w-[90vw] object-contain"
|
||||||
|
:alt="`${game.mName} screenshot ${index + 1}`"
|
||||||
|
/>
|
||||||
|
</TransitionGroup>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="absolute bottom-4 left-1/2 -translate-x-1/2 px-4 py-2 rounded-full bg-zinc-900/50 backdrop-blur-sm"
|
||||||
|
>
|
||||||
|
<p class="text-zinc-100 text-sm font-medium">
|
||||||
|
{{ currentImageIndex + 1 }} / {{ mediaUrls.length }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
Dialog,
|
|
||||||
DialogTitle,
|
|
||||||
TransitionChild,
|
|
||||||
TransitionRoot,
|
|
||||||
Listbox,
|
Listbox,
|
||||||
ListboxButton,
|
ListboxButton,
|
||||||
ListboxLabel,
|
ListboxLabel,
|
||||||
@ -274,10 +460,17 @@ import {
|
|||||||
CheckIcon,
|
CheckIcon,
|
||||||
ChevronUpDownIcon,
|
ChevronUpDownIcon,
|
||||||
WrenchIcon,
|
WrenchIcon,
|
||||||
|
ChevronLeftIcon,
|
||||||
|
ChevronRightIcon,
|
||||||
|
XMarkIcon,
|
||||||
|
ArrowsPointingOutIcon,
|
||||||
|
PhotoIcon,
|
||||||
} from "@heroicons/vue/20/solid";
|
} from "@heroicons/vue/20/solid";
|
||||||
import { BuildingStorefrontIcon } from "@heroicons/vue/24/outline";
|
import { BuildingStorefrontIcon } from "@heroicons/vue/24/outline";
|
||||||
import { XCircleIcon } from "@heroicons/vue/24/solid";
|
import { XCircleIcon } from "@heroicons/vue/24/solid";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { micromark } from "micromark";
|
||||||
|
import { GameStatusEnum } from "~/types";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -290,13 +483,27 @@ const remoteUrl: string = await invoke("gen_drop_url", {
|
|||||||
path: `/store/${game.value.id}`,
|
path: `/store/${game.value.id}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const bannerUrl = await useObject(game.value.mBannerId);
|
const bannerUrl = await useObject(game.value.mBannerObjectId);
|
||||||
|
|
||||||
|
// Get all available images
|
||||||
|
const mediaUrls = await Promise.all(
|
||||||
|
game.value.mImageCarouselObjectIds.map(async (v) => {
|
||||||
|
const src = await useObject(v);
|
||||||
|
return src;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const htmlDescription = micromark(game.value.mDescription);
|
||||||
|
|
||||||
const installFlowOpen = ref(false);
|
const installFlowOpen = ref(false);
|
||||||
const versionOptions = ref<
|
const versionOptions = ref<
|
||||||
undefined | Array<{ versionName: string; platform: string }>
|
undefined | Array<{ versionName: string; platform: string }>
|
||||||
>();
|
>();
|
||||||
const installDirs = ref<undefined | Array<string>>();
|
const installDirs = ref<undefined | Array<string>>();
|
||||||
|
const currentImageIndex = ref(0);
|
||||||
|
|
||||||
|
const configureModalOpen = ref(false);
|
||||||
|
|
||||||
async function installFlow() {
|
async function installFlow() {
|
||||||
installFlowOpen.value = true;
|
installFlowOpen.value = true;
|
||||||
versionOptions.value = undefined;
|
versionOptions.value = undefined;
|
||||||
@ -319,8 +526,7 @@ const installVersionIndex = ref(0);
|
|||||||
const installDir = ref(0);
|
const installDir = ref(0);
|
||||||
async function install() {
|
async function install() {
|
||||||
try {
|
try {
|
||||||
if (!versionOptions.value)
|
if (!versionOptions.value) throw new Error("Versions have not been loaded");
|
||||||
throw new Error("Versions have not been loaded");
|
|
||||||
installLoading.value = true;
|
installLoading.value = true;
|
||||||
await invoke("download_game", {
|
await invoke("download_game", {
|
||||||
gameId: game.value.id,
|
gameId: game.value.id,
|
||||||
@ -335,6 +541,14 @@ async function install() {
|
|||||||
installLoading.value = false;
|
installLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function resumeDownload() {
|
||||||
|
try {
|
||||||
|
await invoke("resume_download", { gameId: game.value.id });
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function launch() {
|
async function launch() {
|
||||||
try {
|
try {
|
||||||
await invoke("launch_game", { id: game.value.id });
|
await invoke("launch_game", { id: game.value.id });
|
||||||
@ -376,4 +590,61 @@ async function kill() {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nextImage() {
|
||||||
|
currentImageIndex.value = (currentImageIndex.value + 1) % mediaUrls.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function previousImage() {
|
||||||
|
currentImageIndex.value =
|
||||||
|
(currentImageIndex.value - 1 + mediaUrls.length) % mediaUrls.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fullscreenImage = ref<string | null>(null);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.fade-enter-active,
|
||||||
|
.fade-leave-active {
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade-enter-from,
|
||||||
|
.fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-enter-active,
|
||||||
|
.slide-leave-active {
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-enter-from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-scrollbar {
|
||||||
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: rgb(82 82 91) transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-scrollbar::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-scrollbar::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-scrollbar::-webkit-scrollbar-thumb {
|
||||||
|
background-color: rgb(82 82 91);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
|
<div class="h-full flex flex-col items-center justify-center">
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="flex flex-col items-center gap-y-4">
|
||||||
|
<div class="p-4 rounded-xl bg-zinc-700/50 backdrop-blur-sm">
|
||||||
|
<RocketLaunchIcon class="size-12 text-zinc-400" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xl font-display font-semibold text-zinc-100">Select a game</h3>
|
||||||
|
<p class="mt-1 text-sm text-zinc-400">Choose a game from your library to view details</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { RocketLaunchIcon } from '@heroicons/vue/24/outline';
|
||||||
|
</script>
|
||||||
@ -91,7 +91,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ServerIcon, XMarkIcon } from "@heroicons/vue/20/solid";
|
import { ServerIcon, XMarkIcon } from "@heroicons/vue/20/solid";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import type { DownloadableMetadata, Game, GameStatus } from "~/types";
|
import { GameStatusEnum, type DownloadableMetadata, type Game, type GameStatus } from "~/types";
|
||||||
|
|
||||||
|
// const actionNames = {
|
||||||
|
// [GameStatusEnum.Downloading]: "downloading",
|
||||||
|
// [GameStatusEnum.Verifying]: "verifying",
|
||||||
|
// }
|
||||||
|
|
||||||
const windowWidth = ref(window.innerWidth);
|
const windowWidth = ref(window.innerWidth);
|
||||||
window.addEventListener("resize", (event) => {
|
window.addEventListener("resize", (event) => {
|
||||||
@ -158,7 +163,7 @@ function loadGamesForQueue(v: typeof queue.value) {
|
|||||||
if (games.value[id]) return;
|
if (games.value[id]) return;
|
||||||
(async () => {
|
(async () => {
|
||||||
const gameData = await useGame(id);
|
const gameData = await useGame(id);
|
||||||
const cover = await useObject(gameData.game.mCoverId);
|
const cover = await useObject(gameData.game.mCoverObjectId);
|
||||||
games.value[id] = { ...gameData, cover };
|
games.value[id] = { ...gameData, cover };
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
@ -167,7 +172,7 @@ function loadGamesForQueue(v: typeof queue.value) {
|
|||||||
loadGamesForQueue(queue.value);
|
loadGamesForQueue(queue.value);
|
||||||
|
|
||||||
async function onEnd(event: { oldIndex: number; newIndex: number }) {
|
async function onEnd(event: { oldIndex: number; newIndex: number }) {
|
||||||
await invoke("move_game_in_queue", {
|
await invoke("move_download_in_queue", {
|
||||||
oldIndex: event.oldIndex,
|
oldIndex: event.oldIndex,
|
||||||
newIndex: event.newIndex,
|
newIndex: event.newIndex,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
<ul role="list" class="-mx-2 space-y-1">
|
<ul role="list" class="-mx-2 space-y-1">
|
||||||
<li v-for="(item, itemIdx) in navigation" :key="item.prefix">
|
<li v-for="(item, itemIdx) in navigation" :key="item.prefix">
|
||||||
<NuxtLink :href="item.route" :class="[
|
<NuxtLink :href="item.route" :class="[
|
||||||
itemIdx === currentPageIndex
|
itemIdx === currentNavigation
|
||||||
? 'bg-zinc-800/50 text-zinc-100'
|
? 'bg-zinc-800/50 text-zinc-100'
|
||||||
: 'text-zinc-400 hover:bg-zinc-800/30 hover:text-zinc-200',
|
: 'text-zinc-400 hover:bg-zinc-800/30 hover:text-zinc-200',
|
||||||
'transition group flex gap-x-3 rounded-md p-2 pr-12 text-sm font-semibold leading-6',
|
'transition group flex gap-x-3 rounded-md p-2 pr-12 text-sm font-semibold leading-6',
|
||||||
]">
|
]">
|
||||||
<component :is="item.icon" :class="[
|
<component :is="item.icon" :class="[
|
||||||
itemIdx === currentPageIndex
|
itemIdx === currentNavigation
|
||||||
? 'text-zinc-100'
|
? 'text-zinc-100'
|
||||||
: 'text-zinc-400 group-hover:text-zinc-200',
|
: 'text-zinc-400 group-hover:text-zinc-200',
|
||||||
'transition h-6 w-6 shrink-0',
|
'transition h-6 w-6 shrink-0',
|
||||||
@ -45,6 +45,7 @@ import type { Component } from "vue";
|
|||||||
import type { NavigationItem } from "~/types";
|
import type { NavigationItem } from "~/types";
|
||||||
import { platform } from '@tauri-apps/plugin-os';
|
import { platform } from '@tauri-apps/plugin-os';
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { UserIcon } from "@heroicons/vue/20/solid";
|
||||||
|
|
||||||
const systemData = await invoke<{
|
const systemData = await invoke<{
|
||||||
clientId: string;
|
clientId: string;
|
||||||
@ -101,6 +102,12 @@ const navigation = computed(() => [
|
|||||||
prefix: "/settings/downloads",
|
prefix: "/settings/downloads",
|
||||||
icon: ArrowDownTrayIcon,
|
icon: ArrowDownTrayIcon,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Account",
|
||||||
|
route: "/settings/account",
|
||||||
|
prefix: "/settings/account",
|
||||||
|
icon: UserIcon
|
||||||
|
},
|
||||||
...(isDebugMode.value ? [{
|
...(isDebugMode.value ? [{
|
||||||
label: "Debug Info",
|
label: "Debug Info",
|
||||||
route: "/settings/debug",
|
route: "/settings/debug",
|
||||||
@ -112,10 +119,10 @@ const navigation = computed(() => [
|
|||||||
const currentPlatform = platform();
|
const currentPlatform = platform();
|
||||||
|
|
||||||
// Use .value to unwrap the computed ref
|
// Use .value to unwrap the computed ref
|
||||||
const currentPageIndex = useCurrentNavigationIndex(navigation.value);
|
const {currentNavigation} = useCurrentNavigationIndex(navigation.value);
|
||||||
|
|
||||||
// Watch for navigation changes and update currentPageIndex
|
// Watch for navigation changes and update currentPageIndex
|
||||||
watch(navigation, (newNav) => {
|
watch(navigation, (newNav) => {
|
||||||
currentPageIndex.value = useCurrentNavigationIndex(newNav).value;
|
currentNavigation.value = useCurrentNavigationIndex(newNav).currentNavigation.value;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
64
pages/settings/account.vue
Normal file
64
pages/settings/account.vue
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<template>
|
||||||
|
<div class="border-b border-zinc-700 py-5">
|
||||||
|
<h3 class="text-base font-semibold font-display leading-6 text-zinc-100">
|
||||||
|
General
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-5 flex flex-col gap-4">
|
||||||
|
<div class="flex flex-row items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-sm font-medium leading-6 text-zinc-100">Sign out</h3>
|
||||||
|
<p class="mt-1 text-sm leading-6 text-zinc-400">
|
||||||
|
Sign out of your Drop account on this device
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="signOut"
|
||||||
|
type="button"
|
||||||
|
class="rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-600"
|
||||||
|
>
|
||||||
|
Sign out
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="error" class="rounded-md bg-red-600/10 p-4">
|
||||||
|
<div class="flex">
|
||||||
|
<div class="flex-shrink-0">
|
||||||
|
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
|
||||||
|
</div>
|
||||||
|
<div class="ml-3">
|
||||||
|
<h3 class="text-sm font-medium text-red-600">
|
||||||
|
{{ error }}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { listen } from "@tauri-apps/api/event";
|
||||||
|
import { useRouter } from "#imports";
|
||||||
|
import { XCircleIcon } from "@heroicons/vue/16/solid";
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const error = ref<string | null>(null);
|
||||||
|
|
||||||
|
// Listen for auth events
|
||||||
|
onMounted(async () => {
|
||||||
|
await listen("auth/signedout", () => {
|
||||||
|
router.push("/auth/signedout");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
async function signOut() {
|
||||||
|
try {
|
||||||
|
error.value = null;
|
||||||
|
await invoke("sign_out");
|
||||||
|
} catch (e) {
|
||||||
|
error.value = `Failed to sign out: ${e}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -106,8 +106,6 @@ const systemData = await invoke<{
|
|||||||
dataDir: string;
|
dataDir: string;
|
||||||
}>("fetch_system_data");
|
}>("fetch_system_data");
|
||||||
|
|
||||||
console.log(systemData);
|
|
||||||
|
|
||||||
clientId.value = systemData.clientId;
|
clientId.value = systemData.clientId;
|
||||||
baseUrl.value = systemData.baseUrl;
|
baseUrl.value = systemData.baseUrl;
|
||||||
dataDir.value = systemData.dataDir;
|
dataDir.value = systemData.dataDir;
|
||||||
|
|||||||
@ -1,10 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="border-b border-zinc-700 py-5">
|
||||||
<div class="border-b border-zinc-600 py-2 px-1">
|
<h3 class="text-base font-semibold font-display leading-6 text-zinc-100">
|
||||||
<div
|
Downloads
|
||||||
class="-ml-4 -mt-2 flex flex-wrap items-center justify-between sm:flex-nowrap"
|
</h3>
|
||||||
>
|
</div>
|
||||||
<div class="ml-4 mt-2">
|
|
||||||
|
|
||||||
|
<div class="mt-5">
|
||||||
|
<div class="border-b border-zinc-600">
|
||||||
|
<div class="-ml-4 -mt-2 flex flex-wrap items-center justify-between sm:flex-nowrap">
|
||||||
|
<div class="ml-4 mt-2 pb-4">
|
||||||
<h3 class="text-base font-display font-semibold text-zinc-100">
|
<h3 class="text-base font-display font-semibold text-zinc-100">
|
||||||
Install directories
|
Install directories
|
||||||
</h3>
|
</h3>
|
||||||
@ -15,27 +20,17 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-4 mt-2 shrink-0">
|
<div class="ml-4 mt-2 shrink-0">
|
||||||
<button
|
<button @click="() => (open = true)" type="button"
|
||||||
@click="() => (open = true)"
|
class="relative inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600">
|
||||||
type="button"
|
|
||||||
class="relative inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
|
|
||||||
>
|
|
||||||
Add new directory
|
Add new directory
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul role="list" class="divide-y divide-gray-800">
|
<ul role="list" class="divide-y divide-gray-800">
|
||||||
<li
|
<li v-for="(dir, dirIdx) in dirs" :key="dir" class="flex justify-between gap-x-6 py-5">
|
||||||
v-for="(dir, dirIdx) in dirs"
|
|
||||||
:key="dir"
|
|
||||||
class="flex justify-between gap-x-6 py-5"
|
|
||||||
>
|
|
||||||
<div class="flex min-w-0 gap-x-4">
|
<div class="flex min-w-0 gap-x-4">
|
||||||
<FolderIcon
|
<FolderIcon class="h-6 w-6 text-blue-600 flex-none rounded-full" alt="" />
|
||||||
class="h-6 w-6 text-blue-600 flex-none rounded-full"
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
<div class="min-w-0 flex-auto">
|
<div class="min-w-0 flex-auto">
|
||||||
<p class="text-sm/6 text-zinc-100">
|
<p class="text-sm/6 text-zinc-100">
|
||||||
{{ dir }}
|
{{ dir }}
|
||||||
@ -43,16 +38,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex shrink-0 items-center gap-x-6">
|
<div class="flex shrink-0 items-center gap-x-6">
|
||||||
<button
|
<button @click="() => deleteDirectory(dirIdx)" :disabled="dirs.length <= 1" :class="[
|
||||||
@click="() => deleteDirectory(dirIdx)"
|
|
||||||
:disabled="dirs.length <= 1"
|
|
||||||
:class="[
|
|
||||||
dirs.length <= 1
|
dirs.length <= 1
|
||||||
? 'text-zinc-700'
|
? 'text-zinc-700'
|
||||||
: 'text-zinc-400 hover:text-zinc-100',
|
: 'text-zinc-400 hover:text-zinc-100',
|
||||||
'-m-2.5 block p-2.5',
|
'-m-2.5 block p-2.5',
|
||||||
]"
|
]">
|
||||||
>
|
|
||||||
<span class="sr-only">Open options</span>
|
<span class="sr-only">Open options</span>
|
||||||
<TrashIcon class="size-5" aria-hidden="true" />
|
<TrashIcon class="size-5" aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
@ -72,78 +63,72 @@
|
|||||||
Maximum Download Threads
|
Maximum Download Threads
|
||||||
</label>
|
</label>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<input
|
<input type="number" name="threads" id="threads" min="1" max="32" v-model="downloadThreads"
|
||||||
type="number"
|
@keypress="validateNumberInput" @paste="validatePaste"
|
||||||
name="threads"
|
class="block w-full rounded-md border-0 py-1.5 text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 bg-zinc-800 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6" />
|
||||||
id="threads"
|
|
||||||
min="1"
|
|
||||||
max="32"
|
|
||||||
v-model="downloadThreads"
|
|
||||||
class="block w-full rounded-md border-0 py-1.5 text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 bg-zinc-800 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-zinc-400">
|
<p class="mt-2 text-sm text-zinc-400">
|
||||||
The maximum number of concurrent download threads. Higher values may
|
The maximum number of concurrent download threads. Higher values may
|
||||||
download faster but use more system resources. Default is 4.
|
download faster but use more system resources. Default is 4.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mt-10 space-y-8">
|
||||||
|
<div class="flex flex-row items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-sm font-medium leading-6 text-zinc-100">Force Offline</h3>
|
||||||
|
<p class="mt-1 text-sm leading-6 text-zinc-400">
|
||||||
|
Drop will not make any external connections
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch v-model="forceOffline" :class="[
|
||||||
|
forceOffline ? 'bg-blue-600' : 'bg-zinc-700',
|
||||||
|
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out'
|
||||||
|
]">
|
||||||
|
<span :class="[
|
||||||
|
forceOffline ? 'translate-x-5' : 'translate-x-0',
|
||||||
|
'pointer-events-none relative inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out'
|
||||||
|
]" />
|
||||||
|
</Switch>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<button
|
<button type="button" @click="saveSettings" :disabled="saveState.loading" :class="[
|
||||||
type="button"
|
'inline-flex items-center rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 transition-colors duration-300',
|
||||||
@click="saveDownloadThreads"
|
saveState.success
|
||||||
class="inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 disabled:bg-blue-600/50 disabled:cursor-not-allowed"
|
? 'bg-green-600 hover:bg-green-500 focus-visible:outline-green-600'
|
||||||
>
|
: 'bg-blue-600 hover:bg-blue-500 focus-visible:outline-blue-600',
|
||||||
Save Changes
|
'disabled:bg-blue-600/50 disabled:cursor-not-allowed'
|
||||||
|
]">
|
||||||
|
{{ saveState.success ? 'Saved' : 'Save Changes' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<TransitionRoot as="template" :show="open">
|
<TransitionRoot as="template" :show="open">
|
||||||
<Dialog class="relative z-50" @close="open = false">
|
<Dialog class="relative z-50" @close="open = false">
|
||||||
<TransitionChild
|
<TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0" enter-to="opacity-100"
|
||||||
as="template"
|
leave="ease-in duration-200" leave-from="opacity-100" leave-to="opacity-0">
|
||||||
enter="ease-out duration-300"
|
<div class="fixed inset-0 bg-zinc-950 bg-opacity-75 transition-opacity" />
|
||||||
enter-from="opacity-0"
|
|
||||||
enter-to="opacity-100"
|
|
||||||
leave="ease-in duration-200"
|
|
||||||
leave-from="opacity-100"
|
|
||||||
leave-to="opacity-0"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="fixed inset-0 bg-zinc-950 bg-opacity-75 transition-opacity"
|
|
||||||
/>
|
|
||||||
</TransitionChild>
|
</TransitionChild>
|
||||||
|
|
||||||
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||||
<div
|
<div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||||
class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0"
|
<TransitionChild as="template" enter="ease-out duration-300"
|
||||||
>
|
|
||||||
<TransitionChild
|
|
||||||
as="template"
|
|
||||||
enter="ease-out duration-300"
|
|
||||||
enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||||
enter-to="opacity-100 translate-y-0 sm:scale-100"
|
enter-to="opacity-100 translate-y-0 sm:scale-100" leave="ease-in duration-200"
|
||||||
leave="ease-in duration-200"
|
|
||||||
leave-from="opacity-100 translate-y-0 sm:scale-100"
|
leave-from="opacity-100 translate-y-0 sm:scale-100"
|
||||||
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95">
|
||||||
>
|
|
||||||
<DialogPanel
|
<DialogPanel
|
||||||
class="relative transform overflow-hidden rounded-lg bg-zinc-900 px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6"
|
class="relative transform overflow-hidden rounded-lg bg-zinc-900 px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6">
|
||||||
>
|
|
||||||
<div class="sm:flex sm:items-start">
|
<div class="sm:flex sm:items-start">
|
||||||
<div class="mt-3 w-full sm:ml-4 sm:mt-0">
|
<div class="mt-3 w-full sm:ml-4 sm:mt-0">
|
||||||
<div>
|
<div>
|
||||||
<label
|
<label for="dir" class="block text-sm/6 font-medium text-zinc-100">Select game directory</label>
|
||||||
for="dir"
|
|
||||||
class="block text-sm/6 font-medium text-zinc-100"
|
|
||||||
>Select game directory</label
|
|
||||||
>
|
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<button
|
<button @click="() => selectDirectory()"
|
||||||
@click="() => selectDirectory()"
|
class="block text-left w-full rounded-md border-0 px-3 py-1.5 text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 bg-zinc-800 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm/6">
|
||||||
class="block text-left w-full rounded-md border-0 px-3 py-1.5 text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-700 bg-zinc-800 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm/6"
|
|
||||||
>
|
|
||||||
{{
|
{{
|
||||||
currentDirectory ?? "Click to select a directory..."
|
currentDirectory ?? "Click to select a directory..."
|
||||||
}}
|
}}
|
||||||
@ -156,36 +141,25 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
<div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
||||||
<LoadingButton
|
<LoadingButton :disabled="currentDirectory == undefined" type="button" :loading="createDirectoryLoading"
|
||||||
:disabled="currentDirectory == undefined"
|
@click="() => submitDirectory()" :class="[
|
||||||
type="button"
|
|
||||||
:loading="createDirectoryLoading"
|
|
||||||
@click="() => submitDirectory()"
|
|
||||||
:class="[
|
|
||||||
'inline-flex w-full shadow-sm sm:ml-3 sm:w-auto',
|
'inline-flex w-full shadow-sm sm:ml-3 sm:w-auto',
|
||||||
currentDirectory === undefined
|
currentDirectory === undefined
|
||||||
? 'text-zinc-400 bg-blue-600/10 hover:bg-blue-600/10'
|
? 'text-zinc-400 bg-blue-600/10 hover:bg-blue-600/10'
|
||||||
: 'text-white bg-blue-600 hover:bg-blue-500',
|
: 'text-white bg-blue-600 hover:bg-blue-500',
|
||||||
]"
|
]">
|
||||||
>
|
|
||||||
Add
|
Add
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<button
|
<button type="button"
|
||||||
type="button"
|
|
||||||
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-800 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
class="mt-3 inline-flex w-full justify-center rounded-md bg-zinc-800 px-3 py-2 text-sm font-semibold text-zinc-100 shadow-sm ring-1 ring-inset ring-zinc-800 hover:bg-zinc-900 sm:mt-0 sm:w-auto"
|
||||||
@click="() => cancelDirectory()"
|
@click="() => cancelDirectory()" ref="cancelButtonRef">
|
||||||
ref="cancelButtonRef"
|
|
||||||
>
|
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="error" class="mt-3 rounded-md bg-red-600/10 p-4">
|
<div v-if="error" class="mt-3 rounded-md bg-red-600/10 p-4">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div class="flex-shrink-0">
|
<div class="flex-shrink-0">
|
||||||
<XCircleIcon
|
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
|
||||||
class="h-5 w-5 text-red-600"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-3">
|
<div class="ml-3">
|
||||||
<h3 class="text-sm font-medium text-red-600">
|
<h3 class="text-sm font-medium text-red-600">
|
||||||
@ -211,6 +185,7 @@ import {
|
|||||||
} from "@headlessui/vue";
|
} from "@headlessui/vue";
|
||||||
import { FolderIcon, TrashIcon, XCircleIcon } from "@heroicons/vue/16/solid";
|
import { FolderIcon, TrashIcon, XCircleIcon } from "@heroicons/vue/16/solid";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { Switch } from '@headlessui/vue'
|
||||||
import { type Settings } from "~/types";
|
import { type Settings } from "~/types";
|
||||||
|
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
@ -222,6 +197,12 @@ const dirs = ref<Array<string>>([]);
|
|||||||
|
|
||||||
const settings = await invoke<Settings>("fetch_settings");
|
const settings = await invoke<Settings>("fetch_settings");
|
||||||
const downloadThreads = ref(settings?.maxDownloadThreads ?? 4);
|
const downloadThreads = ref(settings?.maxDownloadThreads ?? 4);
|
||||||
|
const forceOffline = ref(settings?.forceOffline ?? false);
|
||||||
|
|
||||||
|
const saveState = reactive({
|
||||||
|
loading: false,
|
||||||
|
success: false
|
||||||
|
});
|
||||||
|
|
||||||
async function updateDirs() {
|
async function updateDirs() {
|
||||||
const newDirs = await invoke<Array<string>>("fetch_download_dir_stats");
|
const newDirs = await invoke<Array<string>>("fetch_download_dir_stats");
|
||||||
@ -279,10 +260,41 @@ async function deleteDirectory(index: number) {
|
|||||||
await updateDirs();
|
await updateDirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveDownloadThreads() {
|
async function saveSettings() {
|
||||||
//Would save download threads downloadThreads.value);
|
try {
|
||||||
|
saveState.loading = true;
|
||||||
await invoke("update_settings", {
|
await invoke("update_settings", {
|
||||||
newSettings: { maxDownloadThreads: downloadThreads.value },
|
newSettings: { maxDownloadThreads: downloadThreads.value, forceOffline: forceOffline.value },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Show success state
|
||||||
|
saveState.success = true;
|
||||||
|
|
||||||
|
// Reset back to normal state after 2 seconds
|
||||||
|
setTimeout(() => {
|
||||||
|
saveState.success = false;
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to save settings:', error);
|
||||||
|
} finally {
|
||||||
|
saveState.loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateNumberInput(event: KeyboardEvent) {
|
||||||
|
// Allow only numbers and basic control keys
|
||||||
|
if (!/^\d$/.test(event.key) &&
|
||||||
|
!['Backspace', 'Delete', 'Tab', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validatePaste(event: ClipboardEvent) {
|
||||||
|
// Prevent paste if content contains non-numeric characters
|
||||||
|
const pastedData = event.clipboardData?.getData('text');
|
||||||
|
if (pastedData && !/^\d+$/.test(pastedData)) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="divide-y divide-zinc-700">
|
<div class="border-b border-zinc-700 py-5">
|
||||||
<div class="py-6">
|
<h3 class="text-base font-semibold font-display leading-6 text-zinc-100">
|
||||||
<h2 class="text-base font-semibold font-display leading-7 text-zinc-100">General</h2>
|
General
|
||||||
<p class="mt-1 text-sm leading-6 text-zinc-400">
|
</h3>
|
||||||
Configure basic application settings
|
</div>
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="mt-10 space-y-8">
|
<div class="mt-5 space-y-8">
|
||||||
<div class="flex flex-row items-center justify-between">
|
<div class="flex flex-row items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h3 class="text-sm font-medium leading-6 text-zinc-100">Start with system</h3>
|
<h3 class="text-sm font-medium leading-6 text-zinc-100">
|
||||||
|
Start with system
|
||||||
|
</h3>
|
||||||
<p class="mt-1 text-sm leading-6 text-zinc-400">
|
<p class="mt-1 text-sm leading-6 text-zinc-400">
|
||||||
Drop will automatically start when you log into your computer
|
Drop will automatically start when you log into your computer
|
||||||
</p>
|
</p>
|
||||||
@ -18,43 +19,41 @@
|
|||||||
v-model="autostartEnabled"
|
v-model="autostartEnabled"
|
||||||
:class="[
|
:class="[
|
||||||
autostartEnabled ? 'bg-blue-600' : 'bg-zinc-700',
|
autostartEnabled ? 'bg-blue-600' : 'bg-zinc-700',
|
||||||
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out'
|
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out',
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
:class="[
|
:class="[
|
||||||
autostartEnabled ? 'translate-x-5' : 'translate-x-0',
|
autostartEnabled ? 'translate-x-5' : 'translate-x-0',
|
||||||
'pointer-events-none relative inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out'
|
'pointer-events-none relative inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out',
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Switch } from '@headlessui/vue'
|
import { Switch } from "@headlessui/vue";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
defineProps<{}>()
|
defineProps<{}>();
|
||||||
|
|
||||||
const autostartEnabled = ref<boolean>(false)
|
const autostartEnabled = ref<boolean>(false);
|
||||||
|
|
||||||
// Load initial state
|
// Load initial state
|
||||||
invoke('get_autostart_enabled').then((enabled) => {
|
invoke("get_autostart_enabled").then((enabled) => {
|
||||||
autostartEnabled.value = enabled as boolean
|
autostartEnabled.value = enabled as boolean;
|
||||||
})
|
});
|
||||||
|
|
||||||
// Watch for changes and update autostart
|
// Watch for changes and update autostart
|
||||||
watch(autostartEnabled, async (newValue: boolean) => {
|
watch(autostartEnabled, async (newValue: boolean) => {
|
||||||
try {
|
try {
|
||||||
await invoke('toggle_autostart', { enabled: newValue })
|
await invoke("toggle_autostart", { enabled: newValue });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to toggle autostart:', error)
|
console.error("Failed to toggle autostart:", error);
|
||||||
// Revert the toggle if it failed
|
// Revert the toggle if it failed
|
||||||
autostartEnabled.value = !newValue
|
autostartEnabled.value = !newValue;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -1,2 +1,37 @@
|
|||||||
<template></template>
|
<template>
|
||||||
<script setup lang="ts"></script>
|
<div class="grow w-full h-full flex items-center justify-center">
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<BuildingStorefrontIcon
|
||||||
|
class="h-12 w-12 text-blue-600"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<div class="mt-3 text-center sm:mt-5">
|
||||||
|
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
||||||
|
Store not supported in client
|
||||||
|
</h1>
|
||||||
|
<div class="mt-4">
|
||||||
|
<p class="text-sm text-zinc-400 max-w-lg">
|
||||||
|
Currently, Drop requires you to view the store in your browser.
|
||||||
|
Please click the button below to open it in your default browser.
|
||||||
|
</p>
|
||||||
|
<NuxtLink
|
||||||
|
:href="storeUrl"
|
||||||
|
target="_blank"
|
||||||
|
class="mt-6 transition text-sm/6 font-semibold text-zinc-400 hover:text-zinc-100 inline-flex gap-x-2 items-center duration-200 hover:scale-105"
|
||||||
|
>
|
||||||
|
Open Store <ArrowTopRightOnSquareIcon class="size-4" />
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
ArrowTopRightOnSquareIcon,
|
||||||
|
BuildingStorefrontIcon,
|
||||||
|
} from "@heroicons/vue/20/solid";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
|
const storeUrl = await invoke<string>("gen_drop_url", { path: "/store" });
|
||||||
|
</script>
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
// Also possible
|
// Also possible
|
||||||
|
/*
|
||||||
nuxtApp.hook("vue:error", (error, instance, info) => {
|
nuxtApp.hook("vue:error", (error, instance, info) => {
|
||||||
|
|
||||||
console.error(error, info);
|
console.error(error, info);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
router.replace(`/error`);
|
router.replace(`/error`);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|||||||
3718
src-tauri/Cargo.lock
generated
3718
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "drop-app"
|
name = "drop-app"
|
||||||
version = "0.2.0-beta-prerelease-1"
|
version = "0.3.1-appimage"
|
||||||
description = "The client application for the open-source, self-hosted game distribution platform Drop"
|
description = "The client application for the open-source, self-hosted game distribution platform Drop"
|
||||||
authors = ["Drop OSS"]
|
authors = ["Drop OSS"]
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
@ -16,8 +16,6 @@ tauri-plugin-single-instance = { version = "2.0.0", features = ["deep-link"] }
|
|||||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||||
name = "drop_app_lib"
|
name = "drop_app_lib"
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build]
|
|
||||||
rustflags = ["-C", "target-feature=+aes,+sse2"]
|
rustflags = ["-C", "target-feature=+aes,+sse2"]
|
||||||
|
|
||||||
|
|
||||||
@ -25,11 +23,9 @@ rustflags = ["-C", "target-feature=+aes,+sse2"]
|
|||||||
tauri-build = { version = "2.0.0", features = [] }
|
tauri-build = { version = "2.0.0", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-shell = "2.0.0"
|
tauri-plugin-shell = "2.2.1"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
serde-binary = "0.5.0"
|
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
directories = "5.0.1"
|
|
||||||
webbrowser = "1.0.2"
|
webbrowser = "1.0.2"
|
||||||
url = "2.5.2"
|
url = "2.5.2"
|
||||||
tauri-plugin-deep-link = "2"
|
tauri-plugin-deep-link = "2"
|
||||||
@ -50,11 +46,40 @@ slice-deque = "0.3.0"
|
|||||||
throttle_my_fn = "0.2.6"
|
throttle_my_fn = "0.2.6"
|
||||||
parking_lot = "0.12.3"
|
parking_lot = "0.12.3"
|
||||||
atomic-instant-full = "0.1.0"
|
atomic-instant-full = "0.1.0"
|
||||||
|
cacache = "13.1.0"
|
||||||
|
http-serde = "2.1.1"
|
||||||
|
reqwest-middleware = "0.4.0"
|
||||||
|
reqwest-middleware-cache = "0.1.1"
|
||||||
|
deranged = "=0.4.0"
|
||||||
|
droplet-rs = "0.7.3"
|
||||||
|
gethostname = "1.0.1"
|
||||||
|
zstd = "0.13.3"
|
||||||
|
tar = "0.4.44"
|
||||||
|
rand = "0.9.1"
|
||||||
|
regex = "1.11.1"
|
||||||
|
tempfile = "3.19.1"
|
||||||
|
schemars = "0.8.22"
|
||||||
|
sha1 = "0.10.6"
|
||||||
|
dirs = "6.0.0"
|
||||||
|
whoami = "1.6.0"
|
||||||
|
filetime = "0.2.25"
|
||||||
|
walkdir = "2.5.0"
|
||||||
|
known-folders = "1.2.0"
|
||||||
|
native_model = { version = "0.6.1", features = ["rmp_serde_1_3"] }
|
||||||
|
tauri-plugin-opener = "2.4.0"
|
||||||
|
bitcode = "0.6.6"
|
||||||
|
reqwest-websocket = "0.5.0"
|
||||||
|
futures-lite = "2.6.0"
|
||||||
|
page_size = "0.6.0"
|
||||||
|
# tailscale = { path = "./tailscale" }
|
||||||
|
|
||||||
|
[dependencies.dynfmt]
|
||||||
|
version = "0.1.5"
|
||||||
|
features = ["curly"]
|
||||||
|
|
||||||
[dependencies.tauri]
|
[dependencies.tauri]
|
||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
features = ["tray-icon"]
|
features = ["protocol-asset", "tray-icon"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies.tokio]
|
[dependencies.tokio]
|
||||||
version = "1.40.0"
|
version = "1.40.0"
|
||||||
@ -70,23 +95,16 @@ features = ["fs"]
|
|||||||
|
|
||||||
[dependencies.uuid]
|
[dependencies.uuid]
|
||||||
version = "1.10.0"
|
version = "1.10.0"
|
||||||
features = [
|
features = ["v4", "fast-rng", "macro-diagnostics"]
|
||||||
"v4", # Lets you generate random UUIDs
|
|
||||||
"fast-rng", # Use a faster (but still sufficiently random) RNG
|
|
||||||
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
|
|
||||||
]
|
|
||||||
|
|
||||||
[dependencies.openssl]
|
|
||||||
version = "0.10.66"
|
|
||||||
features = ["vendored"]
|
|
||||||
|
|
||||||
[dependencies.rustbreak]
|
[dependencies.rustbreak]
|
||||||
version = "2"
|
version = "2"
|
||||||
features = [] # You can also use "yaml_enc" or "bin_enc"
|
features = ["other_errors"] # You can also use "yaml_enc" or "bin_enc"
|
||||||
|
|
||||||
[dependencies.reqwest]
|
[dependencies.reqwest]
|
||||||
version = "0.12"
|
version = "0.12"
|
||||||
features = ["json", "blocking"]
|
default-features = false
|
||||||
|
features = ["json", "http2", "blocking", "rustls-tls-webpki-roots"]
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "1"
|
version = "1"
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
tauri_build::build()
|
tauri_build::build();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
"core:window:allow-close",
|
"core:window:allow-close",
|
||||||
"deep-link:default",
|
"deep-link:default",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"os:default"
|
"os:default",
|
||||||
|
"opener:default"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::database::db::{borrow_db_checked, borrow_db_mut_checked, save_db};
|
use crate::database::db::{borrow_db_checked, borrow_db_mut_checked};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
use tauri_plugin_autostart::ManagerExt;
|
use tauri_plugin_autostart::ManagerExt;
|
||||||
@ -17,7 +17,6 @@ pub fn toggle_autostart_logic(app: AppHandle, enabled: bool) -> Result<(), Strin
|
|||||||
let mut db_handle = borrow_db_mut_checked();
|
let mut db_handle = borrow_db_mut_checked();
|
||||||
db_handle.settings.autostart = enabled;
|
db_handle.settings.autostart = enabled;
|
||||||
drop(db_handle);
|
drop(db_handle);
|
||||||
save_db();
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -13,10 +13,10 @@ pub fn cleanup_and_exit(app: &AppHandle, state: &tauri::State<'_, std::sync::Mut
|
|||||||
let download_manager = state.lock().unwrap().download_manager.clone();
|
let download_manager = state.lock().unwrap().download_manager.clone();
|
||||||
match download_manager.ensure_terminated() {
|
match download_manager.ensure_terminated() {
|
||||||
Ok(res) => match res {
|
Ok(res) => match res {
|
||||||
Ok(_) => debug!("download manager terminated correctly"),
|
Ok(()) => debug!("download manager terminated correctly"),
|
||||||
Err(_) => error!("download manager failed to terminate correctly"),
|
Err(()) => error!("download manager failed to terminate correctly"),
|
||||||
},
|
},
|
||||||
Err(e) => panic!("{:?}", e),
|
Err(e) => panic!("{e:?}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
app.exit(0);
|
app.exit(0);
|
||||||
3
src-tauri/src/client/mod.rs
Normal file
3
src-tauri/src/client/mod.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub mod autostart;
|
||||||
|
pub mod cleanup;
|
||||||
|
pub mod commands;
|
||||||
102
src-tauri/src/cloud_saves/backup_manager.rs
Normal file
102
src-tauri/src/cloud_saves/backup_manager.rs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
use std::{collections::HashMap, path::PathBuf, str::FromStr};
|
||||||
|
|
||||||
|
use log::warn;
|
||||||
|
|
||||||
|
use crate::{database::db::{GameVersion, DATA_ROOT_DIR}, error::backup_error::BackupError, process::process_manager::Platform};
|
||||||
|
|
||||||
|
use super::path::CommonPath;
|
||||||
|
|
||||||
|
pub struct BackupManager<'a> {
|
||||||
|
pub current_platform: Platform,
|
||||||
|
pub sources: HashMap<(Platform, Platform), &'a (dyn BackupHandler + Sync + Send)>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BackupManager<'_> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
BackupManager {
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
current_platform: Platform::Windows,
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
current_platform: Platform::MacOs,
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
current_platform: Platform::Linux,
|
||||||
|
|
||||||
|
sources: HashMap::from([
|
||||||
|
// Current platform to target platform
|
||||||
|
(
|
||||||
|
(Platform::Windows, Platform::Windows),
|
||||||
|
&WindowsBackupManager {} as &(dyn BackupHandler + Sync + Send),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(Platform::Linux, Platform::Linux),
|
||||||
|
&LinuxBackupManager {} as &(dyn BackupHandler + Sync + Send),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(Platform::MacOs, Platform::MacOs),
|
||||||
|
&MacBackupManager {} as &(dyn BackupHandler + Sync + Send),
|
||||||
|
),
|
||||||
|
|
||||||
|
]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait BackupHandler: Send + Sync {
|
||||||
|
fn root_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { Ok(DATA_ROOT_DIR.lock().unwrap().join("games")) }
|
||||||
|
fn game_translate(&self, _path: &PathBuf, game: &GameVersion) -> Result<PathBuf, BackupError> { Ok(PathBuf::from_str(&game.game_id).unwrap()) }
|
||||||
|
fn base_translate(&self, path: &PathBuf, game: &GameVersion) -> Result<PathBuf, BackupError> { Ok(self.root_translate(path, game)?.join(self.game_translate(path, game)?)) }
|
||||||
|
fn home_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { let c = CommonPath::Home.get().ok_or(BackupError::NotFound); println!("{:?}", c); c }
|
||||||
|
fn store_user_id_translate(&self, _path: &PathBuf, game: &GameVersion) -> Result<PathBuf, BackupError> { PathBuf::from_str(&game.game_id).map_err(|_| BackupError::ParseError) }
|
||||||
|
fn os_user_name_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { Ok(PathBuf::from_str(&whoami::username()).unwrap()) }
|
||||||
|
fn win_app_data_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected Windows Reference in Backup <winAppData>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn win_local_app_data_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected Windows Reference in Backup <winLocalAppData>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn win_local_app_data_low_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected Windows Reference in Backup <winLocalAppDataLow>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn win_documents_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected Windows Reference in Backup <winDocuments>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn win_public_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected Windows Reference in Backup <winPublic>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn win_program_data_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected Windows Reference in Backup <winProgramData>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn win_dir_translate(&self, _path: &PathBuf,_game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected Windows Reference in Backup <winDir>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn xdg_data_translate(&self, _path: &PathBuf,_game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected XDG Reference in Backup <xdgData>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn xdg_config_translate(&self, _path: &PathBuf,_game: &GameVersion) -> Result<PathBuf, BackupError> { warn!("Unexpected XDG Reference in Backup <xdgConfig>"); Err(BackupError::InvalidSystem) }
|
||||||
|
fn skip_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> { Ok(PathBuf::new()) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct LinuxBackupManager {}
|
||||||
|
impl BackupHandler for LinuxBackupManager {
|
||||||
|
fn xdg_config_translate(&self, _path: &PathBuf,_game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(CommonPath::Data.get().ok_or(BackupError::NotFound)?)
|
||||||
|
}
|
||||||
|
fn xdg_data_translate(&self, _path: &PathBuf,_game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(CommonPath::Config.get().ok_or(BackupError::NotFound)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct WindowsBackupManager {}
|
||||||
|
impl BackupHandler for WindowsBackupManager {
|
||||||
|
fn win_app_data_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(CommonPath::Config.get().ok_or(BackupError::NotFound)?)
|
||||||
|
}
|
||||||
|
fn win_local_app_data_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(CommonPath::DataLocal.get().ok_or(BackupError::NotFound)?)
|
||||||
|
}
|
||||||
|
fn win_local_app_data_low_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(CommonPath::DataLocalLow.get().ok_or(BackupError::NotFound)?)
|
||||||
|
}
|
||||||
|
fn win_dir_translate(&self, _path: &PathBuf,_game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(PathBuf::from_str("C:/Windows").unwrap())
|
||||||
|
}
|
||||||
|
fn win_documents_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(CommonPath::Document.get().ok_or(BackupError::NotFound)?)
|
||||||
|
|
||||||
|
}
|
||||||
|
fn win_program_data_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(PathBuf::from_str("C:/ProgramData").unwrap())
|
||||||
|
}
|
||||||
|
fn win_public_translate(&self, _path: &PathBuf, _game: &GameVersion) -> Result<PathBuf, BackupError> {
|
||||||
|
Ok(CommonPath::Public.get().ok_or(BackupError::NotFound)?)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct MacBackupManager {}
|
||||||
|
impl BackupHandler for MacBackupManager {}
|
||||||
6
src-tauri/src/cloud_saves/conditions.rs
Normal file
6
src-tauri/src/cloud_saves/conditions.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
use crate::process::process_manager::Platform;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub enum Condition {
|
||||||
|
Os(Platform)
|
||||||
|
}
|
||||||
35
src-tauri/src/cloud_saves/metadata.rs
Normal file
35
src-tauri/src/cloud_saves/metadata.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use crate::database::db::GameVersion;
|
||||||
|
|
||||||
|
use super::conditions::{Condition};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct CloudSaveMetadata {
|
||||||
|
pub files: Vec<GameFile>,
|
||||||
|
pub game_version: GameVersion,
|
||||||
|
pub save_id: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct GameFile {
|
||||||
|
pub path: String,
|
||||||
|
pub id: Option<String>,
|
||||||
|
pub data_type: DataType,
|
||||||
|
pub tags: Vec<Tag>,
|
||||||
|
pub conditions: Vec<Condition>
|
||||||
|
}
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub enum DataType {
|
||||||
|
Registry,
|
||||||
|
File,
|
||||||
|
Other
|
||||||
|
}
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub enum Tag {
|
||||||
|
Config,
|
||||||
|
Save,
|
||||||
|
#[default]
|
||||||
|
#[serde(other)]
|
||||||
|
Other,
|
||||||
|
}
|
||||||
7
src-tauri/src/cloud_saves/mod.rs
Normal file
7
src-tauri/src/cloud_saves/mod.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
pub mod conditions;
|
||||||
|
pub mod metadata;
|
||||||
|
pub mod resolver;
|
||||||
|
pub mod placeholder;
|
||||||
|
pub mod normalise;
|
||||||
|
pub mod path;
|
||||||
|
pub mod backup_manager;
|
||||||
162
src-tauri/src/cloud_saves/normalise.rs
Normal file
162
src-tauri/src/cloud_saves/normalise.rs
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
|
use regex::Regex;
|
||||||
|
use crate::process::process_manager::Platform;
|
||||||
|
|
||||||
|
use super::placeholder::*;
|
||||||
|
|
||||||
|
|
||||||
|
pub fn normalize(path: &str, os: Platform) -> String {
|
||||||
|
let mut path = path.trim().trim_end_matches(['/', '\\']).replace('\\', "/");
|
||||||
|
|
||||||
|
if path == "~" || path.starts_with("~/") {
|
||||||
|
path = path.replacen('~', HOME, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CONSECUTIVE_SLASHES: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"/{2,}").unwrap());
|
||||||
|
static UNNECESSARY_DOUBLE_STAR_1: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"([^/*])\*{2,}").unwrap());
|
||||||
|
static UNNECESSARY_DOUBLE_STAR_2: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\*{2,}([^/*])").unwrap());
|
||||||
|
static ENDING_WILDCARD: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(/\*)+$").unwrap());
|
||||||
|
static ENDING_DOT: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(/\.)$").unwrap());
|
||||||
|
static INTERMEDIATE_DOT: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(/\./)").unwrap());
|
||||||
|
static BLANK_SEGMENT: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(/\s+/)").unwrap());
|
||||||
|
static APP_DATA: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?i)%appdata%").unwrap());
|
||||||
|
static APP_DATA_ROAMING: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?i)%userprofile%/AppData/Roaming").unwrap());
|
||||||
|
static APP_DATA_LOCAL: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?i)%localappdata%").unwrap());
|
||||||
|
static APP_DATA_LOCAL_2: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?i)%userprofile%/AppData/Local/").unwrap());
|
||||||
|
static USER_PROFILE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?i)%userprofile%").unwrap());
|
||||||
|
static DOCUMENTS: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?i)%userprofile%/Documents").unwrap());
|
||||||
|
|
||||||
|
for (pattern, replacement) in [
|
||||||
|
(&CONSECUTIVE_SLASHES, "/"),
|
||||||
|
(&UNNECESSARY_DOUBLE_STAR_1, "${1}*"),
|
||||||
|
(&UNNECESSARY_DOUBLE_STAR_2, "*${1}"),
|
||||||
|
(&ENDING_WILDCARD, ""),
|
||||||
|
(&ENDING_DOT, ""),
|
||||||
|
(&INTERMEDIATE_DOT, "/"),
|
||||||
|
(&BLANK_SEGMENT, "/"),
|
||||||
|
(&APP_DATA, WIN_APP_DATA),
|
||||||
|
(&APP_DATA_ROAMING, WIN_APP_DATA),
|
||||||
|
(&APP_DATA_LOCAL, WIN_LOCAL_APP_DATA),
|
||||||
|
(&APP_DATA_LOCAL_2, &format!("{}/", WIN_LOCAL_APP_DATA)),
|
||||||
|
(&USER_PROFILE, HOME),
|
||||||
|
(&DOCUMENTS, WIN_DOCUMENTS),
|
||||||
|
] {
|
||||||
|
path = pattern.replace_all(&path, replacement).to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
if os == Platform::Windows {
|
||||||
|
let documents_2: Regex = Regex::new(r"(?i)<home>/Documents").unwrap();
|
||||||
|
|
||||||
|
#[allow(clippy::single_element_loop)]
|
||||||
|
for (pattern, replacement) in [(&documents_2, WIN_DOCUMENTS)] {
|
||||||
|
path = pattern.replace_all(&path, replacement).to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (pattern, replacement) in [
|
||||||
|
("{64BitSteamID}", STORE_USER_ID),
|
||||||
|
("{Steam3AccountID}", STORE_USER_ID),
|
||||||
|
] {
|
||||||
|
path = path.replace(pattern, replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
|
fn too_broad(path: &str) -> bool {
|
||||||
|
println!("Path: {}", path);
|
||||||
|
use {BASE, HOME, ROOT, STORE_USER_ID, WIN_APP_DATA, WIN_DIR, WIN_DOCUMENTS, XDG_CONFIG, XDG_DATA};
|
||||||
|
|
||||||
|
let path_lower = path.to_lowercase();
|
||||||
|
|
||||||
|
for item in ALL {
|
||||||
|
if path == *item {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for item in AVOID_WILDCARDS {
|
||||||
|
if path.starts_with(&format!("{}/*", item)) || path.starts_with(&format!("{}/{}", item, STORE_USER_ID)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// These paths are present whether or not the game is installed.
|
||||||
|
// If possible, they should be narrowed down on the wiki.
|
||||||
|
for item in [
|
||||||
|
format!("{}/{}", BASE, STORE_USER_ID), // because `<storeUserId>` is handled as `*`
|
||||||
|
format!("{}/Documents", HOME),
|
||||||
|
format!("{}/Saved Games", HOME),
|
||||||
|
format!("{}/AppData", HOME),
|
||||||
|
format!("{}/AppData/Local", HOME),
|
||||||
|
format!("{}/AppData/Local/Packages", HOME),
|
||||||
|
format!("{}/AppData/LocalLow", HOME),
|
||||||
|
format!("{}/AppData/Roaming", HOME),
|
||||||
|
format!("{}/Documents/My Games", HOME),
|
||||||
|
format!("{}/Library/Application Support", HOME),
|
||||||
|
format!("{}/Library/Application Support/UserData", HOME),
|
||||||
|
format!("{}/Library/Preferences", HOME),
|
||||||
|
format!("{}/.renpy", HOME),
|
||||||
|
format!("{}/.renpy/persistent", HOME),
|
||||||
|
format!("{}/Library", HOME),
|
||||||
|
format!("{}/Library/RenPy", HOME),
|
||||||
|
format!("{}/Telltale Games", HOME),
|
||||||
|
format!("{}/config", ROOT),
|
||||||
|
format!("{}/MMFApplications", WIN_APP_DATA),
|
||||||
|
format!("{}/RenPy", WIN_APP_DATA),
|
||||||
|
format!("{}/RenPy/persistent", WIN_APP_DATA),
|
||||||
|
format!("{}/win.ini", WIN_DIR),
|
||||||
|
format!("{}/SysWOW64", WIN_DIR),
|
||||||
|
format!("{}/My Games", WIN_DOCUMENTS),
|
||||||
|
format!("{}/Telltale Games", WIN_DOCUMENTS),
|
||||||
|
format!("{}/unity3d", XDG_CONFIG),
|
||||||
|
format!("{}/unity3d", XDG_DATA),
|
||||||
|
"C:/Program Files".to_string(),
|
||||||
|
"C:/Program Files (x86)".to_string(),
|
||||||
|
] {
|
||||||
|
let item = item.to_lowercase();
|
||||||
|
if path_lower == item
|
||||||
|
|| path_lower.starts_with(&format!("{}/*", item))
|
||||||
|
|| path_lower.starts_with(&format!("{}/{}", item, STORE_USER_ID.to_lowercase()))
|
||||||
|
|| path_lower.starts_with(&format!("{}/savesdir", item))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Drive letters:
|
||||||
|
let drives: Regex = Regex::new(r"^[a-zA-Z]:$").unwrap();
|
||||||
|
if drives.is_match(path) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Colon not for a drive letter
|
||||||
|
if path.get(2..).is_some_and(|path| path.contains(':')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Root:
|
||||||
|
if path == "/" {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relative path wildcard:
|
||||||
|
if path.starts_with('*') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn usable(path: &str) -> bool {
|
||||||
|
let unprintable: Regex = Regex::new(r"(\p{Cc}|\p{Cf})").unwrap();
|
||||||
|
|
||||||
|
!path.is_empty()
|
||||||
|
&& !path.contains("{{")
|
||||||
|
&& !path.starts_with("./")
|
||||||
|
&& !path.starts_with("../")
|
||||||
|
&& !too_broad(path)
|
||||||
|
&& !unprintable.is_match(path)
|
||||||
|
}
|
||||||
48
src-tauri/src/cloud_saves/path.rs
Normal file
48
src-tauri/src/cloud_saves/path.rs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
use std::{path::PathBuf, sync::LazyLock};
|
||||||
|
|
||||||
|
pub enum CommonPath {
|
||||||
|
Config,
|
||||||
|
Data,
|
||||||
|
DataLocal,
|
||||||
|
DataLocalLow,
|
||||||
|
Document,
|
||||||
|
Home,
|
||||||
|
Public,
|
||||||
|
SavedGames,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CommonPath {
|
||||||
|
pub fn get(&self) -> Option<PathBuf> {
|
||||||
|
static CONFIG: LazyLock<Option<PathBuf>> = LazyLock::new(|| dirs::config_dir());
|
||||||
|
static DATA: LazyLock<Option<PathBuf>> = LazyLock::new(|| dirs::data_dir());
|
||||||
|
static DATA_LOCAL: LazyLock<Option<PathBuf>> = LazyLock::new(|| dirs::data_local_dir());
|
||||||
|
static DOCUMENT: LazyLock<Option<PathBuf>> = LazyLock::new(|| dirs::document_dir());
|
||||||
|
static HOME: LazyLock<Option<PathBuf>> = LazyLock::new(|| dirs::home_dir());
|
||||||
|
static PUBLIC: LazyLock<Option<PathBuf>> = LazyLock::new(|| dirs::public_dir());
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
static DATA_LOCAL_LOW: LazyLock<Option<PathBuf>> = LazyLock::new(|| {
|
||||||
|
known_folders::get_known_folder_path(known_folders::KnownFolder::LocalAppDataLow)
|
||||||
|
});
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
static DATA_LOCAL_LOW: Option<PathBuf> = None;
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
static SAVED_GAMES: LazyLock<Option<PathBuf>> = LazyLock::new(|| {
|
||||||
|
known_folders::get_known_folder_path(known_folders::KnownFolder::SavedGames)
|
||||||
|
});
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
static SAVED_GAMES: Option<PathBuf> = None;
|
||||||
|
|
||||||
|
match self {
|
||||||
|
Self::Config => CONFIG.clone(),
|
||||||
|
Self::Data => DATA.clone(),
|
||||||
|
Self::DataLocal => DATA_LOCAL.clone(),
|
||||||
|
Self::DataLocalLow => DATA_LOCAL_LOW.clone(),
|
||||||
|
Self::Document => DOCUMENT.clone(),
|
||||||
|
Self::Home => HOME.clone(),
|
||||||
|
Self::Public => PUBLIC.clone(),
|
||||||
|
Self::SavedGames => SAVED_GAMES.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
src-tauri/src/cloud_saves/placeholder.rs
Normal file
51
src-tauri/src/cloud_saves/placeholder.rs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
|
pub const ALL: &[&str] = &[
|
||||||
|
ROOT,
|
||||||
|
GAME,
|
||||||
|
BASE,
|
||||||
|
HOME,
|
||||||
|
STORE_USER_ID,
|
||||||
|
OS_USER_NAME,
|
||||||
|
WIN_APP_DATA,
|
||||||
|
WIN_LOCAL_APP_DATA,
|
||||||
|
WIN_DOCUMENTS,
|
||||||
|
WIN_PUBLIC,
|
||||||
|
WIN_PROGRAM_DATA,
|
||||||
|
WIN_DIR,
|
||||||
|
XDG_DATA,
|
||||||
|
XDG_CONFIG,
|
||||||
|
];
|
||||||
|
|
||||||
|
/// These are paths where `<placeholder>/*/` is suspicious.
|
||||||
|
pub const AVOID_WILDCARDS: &[&str] = &[
|
||||||
|
ROOT,
|
||||||
|
HOME,
|
||||||
|
WIN_APP_DATA,
|
||||||
|
WIN_LOCAL_APP_DATA,
|
||||||
|
WIN_DOCUMENTS,
|
||||||
|
WIN_PUBLIC,
|
||||||
|
WIN_PROGRAM_DATA,
|
||||||
|
WIN_DIR,
|
||||||
|
XDG_DATA,
|
||||||
|
XDG_CONFIG,
|
||||||
|
];
|
||||||
|
|
||||||
|
pub const ROOT: &str = "<root>"; // a directory where games are installed (configured in backup tool)
|
||||||
|
pub const GAME: &str = "<game>"; // an installDir (if defined) or the game's canonical name in the manifest
|
||||||
|
pub const BASE: &str = "<base>"; // shorthand for <root>/<game> (unless overridden by store-specific rules)
|
||||||
|
pub const HOME: &str = "<home>"; // current user's home directory in the OS (~)
|
||||||
|
pub const STORE_USER_ID: &str = "<storeUserId>"; // a store-specific id from the manifest, corresponding to the root's store type
|
||||||
|
pub const OS_USER_NAME: &str = "<osUserName>"; // current user's ID in the game store
|
||||||
|
pub const WIN_APP_DATA: &str = "<winAppData>"; // current user's name in the OS
|
||||||
|
pub const WIN_LOCAL_APP_DATA: &str = "<winLocalAppData>"; // %APPDATA% on Windows
|
||||||
|
pub const WIN_LOCAL_APP_DATA_LOW: &str = "<winLocalAppDataLow>"; // %LOCALAPPDATA% on Windows
|
||||||
|
pub const WIN_DOCUMENTS: &str = "<winDocuments>"; // <home>/AppData/LocalLow on Windows
|
||||||
|
pub const WIN_PUBLIC: &str = "<winPublic>"; // <home>/Documents (f.k.a. <home>/My Documents) or a localized equivalent on Windows
|
||||||
|
pub const WIN_PROGRAM_DATA: &str = "<winProgramData>"; // %PUBLIC% on Windows
|
||||||
|
pub const WIN_DIR: &str = "<winDir>"; // %PROGRAMDATA% on Windows
|
||||||
|
pub const XDG_DATA: &str = "<xdgData>"; // %WINDIR% on Windows
|
||||||
|
pub const XDG_CONFIG: &str = "<xdgConfig>"; // $XDG_DATA_HOME on Linux
|
||||||
|
pub const SKIP: &str = "<skip>"; // $XDG_CONFIG_HOME on Linux
|
||||||
|
|
||||||
|
pub static OS_USERNAME: LazyLock<String> = LazyLock::new(|| whoami::username());
|
||||||
262
src-tauri/src/cloud_saves/resolver.rs
Normal file
262
src-tauri/src/cloud_saves/resolver.rs
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
use std::{
|
||||||
|
fs::{self, create_dir_all, File},
|
||||||
|
io::{self, ErrorKind, Read, Write},
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
thread::sleep,
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
backup_manager::BackupHandler, conditions::Condition, metadata::GameFile, placeholder::*,
|
||||||
|
};
|
||||||
|
use log::{debug, warn};
|
||||||
|
use rustix::path::Arg;
|
||||||
|
use tempfile::tempfile;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
database::db::GameVersion, error::backup_error::BackupError, process::process_manager::Platform,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::{backup_manager::BackupManager, metadata::CloudSaveMetadata, normalise::normalize};
|
||||||
|
|
||||||
|
pub fn resolve(meta: &mut CloudSaveMetadata) -> File {
|
||||||
|
let f = File::create_new("save").unwrap();
|
||||||
|
let compressor = zstd::Encoder::new(f, 22).unwrap();
|
||||||
|
let mut tarball = tar::Builder::new(compressor);
|
||||||
|
let manager = BackupManager::new();
|
||||||
|
for file in meta.files.iter_mut() {
|
||||||
|
let id = uuid::Uuid::new_v4().to_string();
|
||||||
|
let os = match file
|
||||||
|
.conditions
|
||||||
|
.iter()
|
||||||
|
.find_map(|p| match p {
|
||||||
|
super::conditions::Condition::Os(os) => Some(os),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.cloned()
|
||||||
|
{
|
||||||
|
Some(os) => os,
|
||||||
|
None => {
|
||||||
|
warn!(
|
||||||
|
"File {:?} could not be backed up because it did not provide an OS",
|
||||||
|
&file
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let handler = match manager.sources.get(&(manager.current_platform, os)) {
|
||||||
|
Some(h) => *h,
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
let t_path = PathBuf::from(normalize(&file.path, os));
|
||||||
|
println!("{:?}", &t_path);
|
||||||
|
let path = parse_path(t_path, handler, &meta.game_version).unwrap();
|
||||||
|
let f = std::fs::metadata(&path).unwrap(); // TODO: Fix unwrap here
|
||||||
|
if f.is_dir() {
|
||||||
|
tarball.append_dir_all(&id, path).unwrap();
|
||||||
|
} else if f.is_file() {
|
||||||
|
tarball
|
||||||
|
.append_file(&id, &mut File::open(path).unwrap())
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
file.id = Some(id);
|
||||||
|
}
|
||||||
|
let binding = serde_json::to_string(meta).unwrap();
|
||||||
|
let serialized = binding.as_bytes();
|
||||||
|
let mut file = tempfile().unwrap();
|
||||||
|
file.write(serialized).unwrap();
|
||||||
|
tarball.append_file("metadata", &mut file).unwrap();
|
||||||
|
tarball.into_inner().unwrap().finish().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn extract(file: PathBuf) -> Result<(), BackupError> {
|
||||||
|
let tmpdir = tempfile::tempdir().unwrap();
|
||||||
|
|
||||||
|
// Reopen the file for reading
|
||||||
|
let file = File::open(file).unwrap();
|
||||||
|
|
||||||
|
let decompressor = zstd::Decoder::new(file).unwrap();
|
||||||
|
let mut f = tar::Archive::new(decompressor);
|
||||||
|
f.unpack(tmpdir.path()).unwrap();
|
||||||
|
|
||||||
|
let path = tmpdir.path();
|
||||||
|
|
||||||
|
let mut manifest = File::open(path.join("metadata")).unwrap();
|
||||||
|
|
||||||
|
let mut manifest_slice = Vec::new();
|
||||||
|
manifest.read_to_end(&mut manifest_slice).unwrap();
|
||||||
|
|
||||||
|
let manifest: CloudSaveMetadata = serde_json::from_slice(&manifest_slice).unwrap();
|
||||||
|
|
||||||
|
for file in manifest.files {
|
||||||
|
let current_path = path.join(file.id.as_ref().unwrap());
|
||||||
|
|
||||||
|
let manager = BackupManager::new();
|
||||||
|
let os = match file
|
||||||
|
.conditions
|
||||||
|
.iter()
|
||||||
|
.find_map(|p| match p {
|
||||||
|
super::conditions::Condition::Os(os) => Some(os),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.cloned()
|
||||||
|
{
|
||||||
|
Some(os) => os,
|
||||||
|
None => {
|
||||||
|
warn!(
|
||||||
|
"File {:?} could not be replaced up because it did not provide an OS",
|
||||||
|
&file
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let handler = match manager.sources.get(&(manager.current_platform, os)) {
|
||||||
|
Some(h) => *h,
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
let new_path = parse_path(file.path.into(), handler, &manifest.game_version)?;
|
||||||
|
create_dir_all(&new_path.parent().unwrap()).unwrap();
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Current path {:?} copying to {:?}",
|
||||||
|
¤t_path, &new_path
|
||||||
|
);
|
||||||
|
|
||||||
|
copy_item(current_path, new_path).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy_item<P: AsRef<Path>>(src: P, dest: P) -> io::Result<()> {
|
||||||
|
let src_path = src.as_ref();
|
||||||
|
let dest_path = dest.as_ref();
|
||||||
|
|
||||||
|
let metadata = fs::metadata(&src_path)?;
|
||||||
|
|
||||||
|
if metadata.is_file() {
|
||||||
|
// Ensure the parent directory of the destination exists for a file copy
|
||||||
|
if let Some(parent) = dest_path.parent() {
|
||||||
|
fs::create_dir_all(parent)?;
|
||||||
|
}
|
||||||
|
fs::copy(&src_path, &dest_path)?;
|
||||||
|
} else if metadata.is_dir() {
|
||||||
|
// For directories, we call the recursive helper function.
|
||||||
|
// The destination for the recursive copy is the `dest_path` itself.
|
||||||
|
copy_dir_recursive(&src_path, &dest_path)?;
|
||||||
|
} else {
|
||||||
|
// Handle other file types like symlinks if necessary,
|
||||||
|
// for now, return an error or skip.
|
||||||
|
return Err(io::Error::new(
|
||||||
|
io::ErrorKind::Other,
|
||||||
|
format!("Source {:?} is neither a file nor a directory", src_path),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn copy_dir_recursive(src: &Path, dest: &Path) -> io::Result<()> {
|
||||||
|
fs::create_dir_all(&dest)?;
|
||||||
|
|
||||||
|
for entry in fs::read_dir(src)? {
|
||||||
|
let entry = entry?;
|
||||||
|
let entry_path = entry.path();
|
||||||
|
let entry_file_name = match entry_path.file_name() {
|
||||||
|
Some(name) => name,
|
||||||
|
None => continue, // Skip if somehow there's no file name
|
||||||
|
};
|
||||||
|
let dest_entry_path = dest.join(entry_file_name);
|
||||||
|
let metadata = entry.metadata()?;
|
||||||
|
|
||||||
|
if metadata.is_file() {
|
||||||
|
debug!(
|
||||||
|
"Writing file {} to {}",
|
||||||
|
entry_path.display(),
|
||||||
|
dest_entry_path.display()
|
||||||
|
);
|
||||||
|
fs::copy(&entry_path, &dest_entry_path)?;
|
||||||
|
} else if metadata.is_dir() {
|
||||||
|
copy_dir_recursive(&entry_path, &dest_entry_path)?;
|
||||||
|
}
|
||||||
|
// Ignore other types like symlinks for this basic implementation
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_path(
|
||||||
|
path: PathBuf,
|
||||||
|
backup_handler: &dyn BackupHandler,
|
||||||
|
game: &GameVersion,
|
||||||
|
) -> Result<PathBuf, BackupError> {
|
||||||
|
println!("Parsing: {:?}", &path);
|
||||||
|
let mut s = PathBuf::new();
|
||||||
|
for component in path.components() {
|
||||||
|
match component.as_str().unwrap() {
|
||||||
|
ROOT => s.push(backup_handler.root_translate(&path, game)?),
|
||||||
|
GAME => s.push(backup_handler.game_translate(&path, game)?),
|
||||||
|
BASE => s.push(backup_handler.base_translate(&path, game)?),
|
||||||
|
HOME => s.push(backup_handler.home_translate(&path, game)?),
|
||||||
|
STORE_USER_ID => s.push(backup_handler.store_user_id_translate(&path, game)?),
|
||||||
|
OS_USER_NAME => s.push(backup_handler.os_user_name_translate(&path, game)?),
|
||||||
|
WIN_APP_DATA => s.push(backup_handler.win_app_data_translate(&path, game)?),
|
||||||
|
WIN_LOCAL_APP_DATA => s.push(backup_handler.win_local_app_data_translate(&path, game)?),
|
||||||
|
WIN_LOCAL_APP_DATA_LOW => {
|
||||||
|
s.push(backup_handler.win_local_app_data_low_translate(&path, game)?)
|
||||||
|
}
|
||||||
|
WIN_DOCUMENTS => s.push(backup_handler.win_documents_translate(&path, game)?),
|
||||||
|
WIN_PUBLIC => s.push(backup_handler.win_public_translate(&path, game)?),
|
||||||
|
WIN_PROGRAM_DATA => s.push(backup_handler.win_program_data_translate(&path, game)?),
|
||||||
|
WIN_DIR => s.push(backup_handler.win_dir_translate(&path, game)?),
|
||||||
|
XDG_DATA => s.push(backup_handler.xdg_data_translate(&path, game)?),
|
||||||
|
XDG_CONFIG => s.push(backup_handler.xdg_config_translate(&path, game)?),
|
||||||
|
SKIP => s.push(backup_handler.skip_translate(&path, game)?),
|
||||||
|
_ => s.push(PathBuf::from(component.as_os_str())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Final line: {:?}", &s);
|
||||||
|
Ok(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn test() {
|
||||||
|
let mut meta = CloudSaveMetadata {
|
||||||
|
files: vec![
|
||||||
|
GameFile {
|
||||||
|
path: String::from("<home>/favicon.png"),
|
||||||
|
id: None,
|
||||||
|
data_type: super::metadata::DataType::File,
|
||||||
|
tags: Vec::new(),
|
||||||
|
conditions: vec![Condition::Os(Platform::Linux)],
|
||||||
|
},
|
||||||
|
GameFile {
|
||||||
|
path: String::from("<home>/Documents/Pixel Art"),
|
||||||
|
id: None,
|
||||||
|
data_type: super::metadata::DataType::File,
|
||||||
|
tags: Vec::new(),
|
||||||
|
conditions: vec![Condition::Os(Platform::Linux)],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
game_version: GameVersion {
|
||||||
|
game_id: String::new(),
|
||||||
|
version_name: String::new(),
|
||||||
|
platform: Platform::Linux,
|
||||||
|
launch_command: String::new(),
|
||||||
|
launch_args: Vec::new(),
|
||||||
|
launch_command_template: String::new(),
|
||||||
|
setup_command: String::new(),
|
||||||
|
setup_args: Vec::new(),
|
||||||
|
setup_command_template: String::new(),
|
||||||
|
only_setup: true,
|
||||||
|
version_index: 0,
|
||||||
|
delta: false,
|
||||||
|
umu_id_override: None,
|
||||||
|
},
|
||||||
|
save_id: String::from("aaaaaaa"),
|
||||||
|
};
|
||||||
|
//resolve(&mut meta);
|
||||||
|
|
||||||
|
extract("save".into()).unwrap();
|
||||||
|
}
|
||||||
0
src-tauri/src/cloud_saves/strict_path.rs
Normal file
0
src-tauri/src/cloud_saves/strict_path.rs
Normal file
@ -7,13 +7,13 @@ use std::{
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{db::borrow_db_mut_checked, settings::Settings},
|
database::{db::borrow_db_mut_checked, scan::scan_install_dirs}, error::download_manager_error::DownloadManagerError,
|
||||||
download_manager::internal_error::InternalError,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
db::{borrow_db_checked, save_db, DATA_ROOT_DIR},
|
db::{borrow_db_checked, DATA_ROOT_DIR},
|
||||||
debug::SystemData,
|
debug::SystemData,
|
||||||
|
models::data::Settings,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Will, in future, return disk/remaining size
|
// Will, in future, return disk/remaining size
|
||||||
@ -28,12 +28,10 @@ pub fn fetch_download_dir_stats() -> Vec<PathBuf> {
|
|||||||
pub fn delete_download_dir(index: usize) {
|
pub fn delete_download_dir(index: usize) {
|
||||||
let mut lock = borrow_db_mut_checked();
|
let mut lock = borrow_db_mut_checked();
|
||||||
lock.applications.install_dirs.remove(index);
|
lock.applications.install_dirs.remove(index);
|
||||||
drop(lock);
|
|
||||||
save_db();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn add_download_dir(new_dir: PathBuf) -> Result<(), InternalError<()>> {
|
pub fn add_download_dir(new_dir: PathBuf) -> Result<(), DownloadManagerError<()>> {
|
||||||
// Check the new directory is all good
|
// Check the new directory is all good
|
||||||
let new_dir_path = Path::new(&new_dir);
|
let new_dir_path = Path::new(&new_dir);
|
||||||
if new_dir_path.exists() {
|
if new_dir_path.exists() {
|
||||||
@ -60,7 +58,8 @@ pub fn add_download_dir(new_dir: PathBuf) -> Result<(), InternalError<()>> {
|
|||||||
}
|
}
|
||||||
lock.applications.install_dirs.push(new_dir);
|
lock.applications.install_dirs.push(new_dir);
|
||||||
drop(lock);
|
drop(lock);
|
||||||
save_db();
|
|
||||||
|
scan_install_dirs();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -74,7 +73,6 @@ pub fn update_settings(new_settings: Value) {
|
|||||||
}
|
}
|
||||||
let new_settings: Settings = serde_json::from_value(current_settings).unwrap();
|
let new_settings: Settings = serde_json::from_value(current_settings).unwrap();
|
||||||
db_lock.settings = new_settings;
|
db_lock.settings = new_settings;
|
||||||
println!("new Settings: {:?}", db_lock.settings);
|
|
||||||
}
|
}
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_settings() -> Settings {
|
pub fn fetch_settings() -> Settings {
|
||||||
@ -86,7 +84,7 @@ pub fn fetch_system_data() -> SystemData {
|
|||||||
SystemData::new(
|
SystemData::new(
|
||||||
db_handle.auth.as_ref().unwrap().client_id.clone(),
|
db_handle.auth.as_ref().unwrap().client_id.clone(),
|
||||||
db_handle.base_url.clone(),
|
db_handle.base_url.clone(),
|
||||||
DATA_ROOT_DIR.lock().unwrap().to_string_lossy().to_string(),
|
DATA_ROOT_DIR.to_string_lossy().to_string(),
|
||||||
std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()),
|
std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,138 +1,44 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
|
||||||
fs::{self, create_dir_all},
|
fs::{self, create_dir_all},
|
||||||
hash::Hash,
|
mem::ManuallyDrop,
|
||||||
path::{Path, PathBuf},
|
ops::{Deref, DerefMut},
|
||||||
sync::{LazyLock, Mutex, RwLockReadGuard, RwLockWriteGuard},
|
path::PathBuf,
|
||||||
|
sync::{Arc, LazyLock, RwLockReadGuard, RwLockWriteGuard},
|
||||||
};
|
};
|
||||||
|
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use directories::BaseDirs;
|
use log::{debug, error, info, warn};
|
||||||
use log::{debug, error, info};
|
use native_model::{Decode, Encode};
|
||||||
use rustbreak::{DeSerError, DeSerializer, PathDatabase, RustbreakError};
|
use rustbreak::{DeSerError, DeSerializer, PathDatabase, RustbreakError};
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{Serialize, de::DeserializeOwned};
|
||||||
use serde_with::serde_as;
|
|
||||||
use tauri::AppHandle;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::DB;
|
||||||
database::settings::Settings,
|
|
||||||
download_manager::downloadable_metadata::DownloadableMetadata,
|
|
||||||
games::{library::push_game_update, state::GameStatusManager},
|
|
||||||
process::process_manager::Platform,
|
|
||||||
DB,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(serde::Serialize, Clone, Deserialize)]
|
use super::models::data::Database;
|
||||||
pub struct DatabaseAuth {
|
|
||||||
pub private: String,
|
|
||||||
pub cert: String,
|
|
||||||
pub client_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings are version names for a particular game
|
pub static DATA_ROOT_DIR: LazyLock<Arc<PathBuf>> =
|
||||||
#[derive(Serialize, Clone, Deserialize)]
|
LazyLock::new(|| Arc::new(dirs::data_dir().unwrap().join("drop")));
|
||||||
#[serde(tag = "type")]
|
|
||||||
pub enum GameDownloadStatus {
|
|
||||||
Remote {},
|
|
||||||
SetupRequired {
|
|
||||||
version_name: String,
|
|
||||||
install_dir: String,
|
|
||||||
},
|
|
||||||
Installed {
|
|
||||||
version_name: String,
|
|
||||||
install_dir: String,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stuff that shouldn't be synced to disk
|
|
||||||
#[derive(Clone, Serialize)]
|
|
||||||
pub enum ApplicationTransientStatus {
|
|
||||||
Downloading { version_name: String },
|
|
||||||
Uninstalling {},
|
|
||||||
Updating { version_name: String },
|
|
||||||
Running {},
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct GameVersion {
|
|
||||||
pub game_id: String,
|
|
||||||
pub version_name: String,
|
|
||||||
|
|
||||||
pub platform: Platform,
|
|
||||||
|
|
||||||
pub launch_command: String,
|
|
||||||
pub launch_args: Vec<String>,
|
|
||||||
|
|
||||||
pub setup_command: String,
|
|
||||||
pub setup_args: Vec<String>,
|
|
||||||
|
|
||||||
pub only_setup: bool,
|
|
||||||
|
|
||||||
pub version_index: usize,
|
|
||||||
pub delta: bool,
|
|
||||||
|
|
||||||
pub umu_id_override: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[serde_as]
|
|
||||||
#[derive(Serialize, Clone, Deserialize, Default)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct DatabaseApplications {
|
|
||||||
pub install_dirs: Vec<PathBuf>,
|
|
||||||
// Guaranteed to exist if the game also exists in the app state map
|
|
||||||
pub game_statuses: HashMap<String, GameDownloadStatus>,
|
|
||||||
pub game_versions: HashMap<String, HashMap<String, GameVersion>>,
|
|
||||||
pub installed_game_version: HashMap<String, DownloadableMetadata>,
|
|
||||||
|
|
||||||
#[serde(skip)]
|
|
||||||
pub transient_statuses: HashMap<DownloadableMetadata, ApplicationTransientStatus>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
|
||||||
pub struct Database {
|
|
||||||
#[serde(default)]
|
|
||||||
pub settings: Settings,
|
|
||||||
pub auth: Option<DatabaseAuth>,
|
|
||||||
pub base_url: String,
|
|
||||||
pub applications: DatabaseApplications,
|
|
||||||
pub prev_database: Option<PathBuf>,
|
|
||||||
}
|
|
||||||
impl Database {
|
|
||||||
fn new<T: Into<PathBuf>>(games_base_dir: T, prev_database: Option<PathBuf>) -> Self {
|
|
||||||
Self {
|
|
||||||
applications: DatabaseApplications {
|
|
||||||
install_dirs: vec![games_base_dir.into()],
|
|
||||||
game_statuses: HashMap::new(),
|
|
||||||
game_versions: HashMap::new(),
|
|
||||||
installed_game_version: HashMap::new(),
|
|
||||||
transient_statuses: HashMap::new(),
|
|
||||||
},
|
|
||||||
prev_database,
|
|
||||||
base_url: "".to_owned(),
|
|
||||||
auth: None,
|
|
||||||
settings: Settings {
|
|
||||||
autostart: false,
|
|
||||||
max_download_threads: 4,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub static DATA_ROOT_DIR: LazyLock<Mutex<PathBuf>> =
|
|
||||||
LazyLock::new(|| Mutex::new(BaseDirs::new().unwrap().data_dir().join("drop")));
|
|
||||||
|
|
||||||
// Custom JSON serializer to support everything we need
|
// Custom JSON serializer to support everything we need
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct DropDatabaseSerializer;
|
pub struct DropDatabaseSerializer;
|
||||||
|
|
||||||
impl<T: Serialize + DeserializeOwned> DeSerializer<T> for DropDatabaseSerializer {
|
impl<T: native_model::Model + Serialize + DeserializeOwned> DeSerializer<T>
|
||||||
|
for DropDatabaseSerializer
|
||||||
|
{
|
||||||
fn serialize(&self, val: &T) -> rustbreak::error::DeSerResult<Vec<u8>> {
|
fn serialize(&self, val: &T) -> rustbreak::error::DeSerResult<Vec<u8>> {
|
||||||
serde_json::to_vec(val).map_err(|e| DeSerError::Internal(e.to_string()))
|
native_model::rmp_serde_1_3::RmpSerde::encode(val)
|
||||||
|
.map_err(|e| DeSerError::Internal(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize<R: std::io::Read>(&self, s: R) -> rustbreak::error::DeSerResult<T> {
|
fn deserialize<R: std::io::Read>(&self, mut s: R) -> rustbreak::error::DeSerResult<T> {
|
||||||
serde_json::from_reader(s).map_err(|e| DeSerError::Internal(e.to_string()))
|
let mut buf = Vec::new();
|
||||||
|
s.read_to_end(&mut buf)
|
||||||
|
.map_err(|e| rustbreak::error::DeSerError::Other(e.into()))?;
|
||||||
|
let val = native_model::rmp_serde_1_3::RmpSerde::decode(buf)
|
||||||
|
.map_err(|e| DeSerError::Internal(e.to_string()))?;
|
||||||
|
Ok(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,32 +52,33 @@ pub trait DatabaseImpls {
|
|||||||
}
|
}
|
||||||
impl DatabaseImpls for DatabaseInterface {
|
impl DatabaseImpls for DatabaseInterface {
|
||||||
fn set_up_database() -> DatabaseInterface {
|
fn set_up_database() -> DatabaseInterface {
|
||||||
let data_root_dir = DATA_ROOT_DIR.lock().unwrap();
|
let db_path = DATA_ROOT_DIR.join("drop.db");
|
||||||
let db_path = data_root_dir.join("drop.db");
|
let games_base_dir = DATA_ROOT_DIR.join("games");
|
||||||
let games_base_dir = data_root_dir.join("games");
|
let logs_root_dir = DATA_ROOT_DIR.join("logs");
|
||||||
let logs_root_dir = data_root_dir.join("logs");
|
let cache_dir = DATA_ROOT_DIR.join("cache");
|
||||||
|
let pfx_dir = DATA_ROOT_DIR.join("pfx");
|
||||||
|
|
||||||
debug!("creating data directory at {:?}", data_root_dir);
|
debug!("creating data directory at {DATA_ROOT_DIR:?}");
|
||||||
create_dir_all(data_root_dir.clone()).unwrap();
|
create_dir_all(DATA_ROOT_DIR.as_path()).unwrap();
|
||||||
create_dir_all(games_base_dir.clone()).unwrap();
|
create_dir_all(&games_base_dir).unwrap();
|
||||||
create_dir_all(logs_root_dir.clone()).unwrap();
|
create_dir_all(&logs_root_dir).unwrap();
|
||||||
|
create_dir_all(&cache_dir).unwrap();
|
||||||
|
create_dir_all(&pfx_dir).unwrap();
|
||||||
|
|
||||||
let exists = fs::exists(db_path.clone()).unwrap();
|
let exists = fs::exists(db_path.clone()).unwrap();
|
||||||
|
|
||||||
match exists {
|
if exists {
|
||||||
true => match PathDatabase::load_from_path(db_path.clone()) {
|
match PathDatabase::load_from_path(db_path.clone()) {
|
||||||
Ok(db) => db,
|
Ok(db) => db,
|
||||||
Err(e) => handle_invalid_database(e, db_path, games_base_dir),
|
Err(e) => handle_invalid_database(e, db_path, games_base_dir, cache_dir),
|
||||||
},
|
}
|
||||||
false => {
|
} else {
|
||||||
let default = Database::new(games_base_dir, None);
|
let default = Database::new(games_base_dir, None, cache_dir);
|
||||||
debug!(
|
debug!(
|
||||||
"Creating database at path {}",
|
"Creating database at path {}",
|
||||||
db_path.as_os_str().to_str().unwrap()
|
db_path.as_os_str().to_str().unwrap()
|
||||||
);
|
);
|
||||||
PathDatabase::create_at_path(db_path, default)
|
PathDatabase::create_at_path(db_path, default).expect("Database could not be created")
|
||||||
.expect("Database could not be created")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,72 +92,86 @@ impl DatabaseImpls for DatabaseInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_game_status<F: FnOnce(&mut RwLockWriteGuard<'_, Database>, &DownloadableMetadata)>(
|
|
||||||
app_handle: &AppHandle,
|
|
||||||
meta: DownloadableMetadata,
|
|
||||||
setter: F,
|
|
||||||
) {
|
|
||||||
let mut db_handle = borrow_db_mut_checked();
|
|
||||||
setter(&mut db_handle, &meta);
|
|
||||||
drop(db_handle);
|
|
||||||
save_db();
|
|
||||||
|
|
||||||
let status = GameStatusManager::fetch_state(&meta.id);
|
|
||||||
|
|
||||||
push_game_update(app_handle, &meta.id, status);
|
|
||||||
}
|
|
||||||
// TODO: Make the error relelvant rather than just assume that it's a Deserialize error
|
// TODO: Make the error relelvant rather than just assume that it's a Deserialize error
|
||||||
fn handle_invalid_database(
|
fn handle_invalid_database(
|
||||||
_e: RustbreakError,
|
_e: RustbreakError,
|
||||||
db_path: PathBuf,
|
db_path: PathBuf,
|
||||||
games_base_dir: PathBuf,
|
games_base_dir: PathBuf,
|
||||||
|
cache_dir: PathBuf,
|
||||||
) -> rustbreak::Database<Database, rustbreak::backend::PathBackend, DropDatabaseSerializer> {
|
) -> rustbreak::Database<Database, rustbreak::backend::PathBackend, DropDatabaseSerializer> {
|
||||||
|
warn!("{_e}");
|
||||||
let new_path = {
|
let new_path = {
|
||||||
let time = Utc::now().timestamp();
|
let time = Utc::now().timestamp();
|
||||||
let mut base = db_path.clone();
|
let mut base = db_path.clone();
|
||||||
base.set_file_name(format!("drop.db.backup-{}", time));
|
base.set_file_name(format!("drop.db.backup-{time}"));
|
||||||
base
|
base
|
||||||
};
|
};
|
||||||
info!(
|
info!("old database stored at: {}", new_path.to_string_lossy());
|
||||||
"old database stored at: {}",
|
|
||||||
new_path.to_string_lossy().to_string()
|
|
||||||
);
|
|
||||||
fs::rename(&db_path, &new_path).unwrap();
|
fs::rename(&db_path, &new_path).unwrap();
|
||||||
|
|
||||||
let db = Database::new(
|
let db = Database::new(
|
||||||
games_base_dir.into_os_string().into_string().unwrap(),
|
games_base_dir.into_os_string().into_string().unwrap(),
|
||||||
Some(new_path),
|
Some(new_path),
|
||||||
|
cache_dir,
|
||||||
);
|
);
|
||||||
|
|
||||||
PathDatabase::create_at_path(db_path, db).expect("Database could not be created")
|
PathDatabase::create_at_path(db_path, db).expect("Database could not be created")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borrow_db_checked<'a>() -> RwLockReadGuard<'a, Database> {
|
// To automatically save the database upon drop
|
||||||
match DB.borrow_data() {
|
pub struct DBRead<'a>(RwLockReadGuard<'a, Database>);
|
||||||
Ok(data) => data,
|
pub struct DBWrite<'a>(ManuallyDrop<RwLockWriteGuard<'a, Database>>);
|
||||||
Err(e) => {
|
impl<'a> Deref for DBWrite<'a> {
|
||||||
error!("database borrow failed with error {}", e);
|
type Target = Database;
|
||||||
panic!("database borrow failed with error {}", e);
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl<'a> DerefMut for DBWrite<'a> {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> Deref for DBRead<'a> {
|
||||||
|
type Target = Database;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Drop for DBWrite<'_> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
ManuallyDrop::drop(&mut self.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borrow_db_mut_checked<'a>() -> RwLockWriteGuard<'a, Database> {
|
|
||||||
match DB.borrow_data_mut() {
|
|
||||||
Ok(data) => data,
|
|
||||||
Err(e) => {
|
|
||||||
error!("database borrow mut failed with error {}", e);
|
|
||||||
panic!("database borrow mut failed with error {}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn save_db() {
|
|
||||||
match DB.save() {
|
match DB.save() {
|
||||||
Ok(_) => {}
|
Ok(()) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("database failed to save with error {}", e);
|
error!("database failed to save with error {e}");
|
||||||
panic!("database failed to save with error {}", e)
|
panic!("database failed to save with error {e}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn borrow_db_checked<'a>() -> DBRead<'a> {
|
||||||
|
match DB.borrow_data() {
|
||||||
|
Ok(data) => DBRead(data),
|
||||||
|
Err(e) => {
|
||||||
|
error!("database borrow failed with error {e}");
|
||||||
|
panic!("database borrow failed with error {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn borrow_db_mut_checked<'a>() -> DBWrite<'a> {
|
||||||
|
match DB.borrow_data_mut() {
|
||||||
|
Ok(data) => DBWrite(ManuallyDrop::new(data)),
|
||||||
|
Err(e) => {
|
||||||
|
error!("database borrow mut failed with error {e}");
|
||||||
|
panic!("database borrow mut failed with error {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod debug;
|
pub mod debug;
|
||||||
pub mod settings;
|
pub mod models;
|
||||||
|
pub mod scan;
|
||||||
350
src-tauri/src/database/models.rs
Normal file
350
src-tauri/src/database/models.rs
Normal file
@ -0,0 +1,350 @@
|
|||||||
|
/**
|
||||||
|
* NEXT BREAKING CHANGE
|
||||||
|
*
|
||||||
|
* UPDATE DATABASE TO USE RPMSERDENAMED
|
||||||
|
*
|
||||||
|
* WE CAN'T DELETE ANY FIELDS
|
||||||
|
*/
|
||||||
|
pub mod data {
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
|
||||||
|
use native_model::native_model;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
pub type GameVersion = v1::GameVersion;
|
||||||
|
pub type Database = v3::Database;
|
||||||
|
pub type Settings = v1::Settings;
|
||||||
|
pub type DatabaseAuth = v1::DatabaseAuth;
|
||||||
|
|
||||||
|
pub type GameDownloadStatus = v2::GameDownloadStatus;
|
||||||
|
pub type ApplicationTransientStatus = v1::ApplicationTransientStatus;
|
||||||
|
pub type DownloadableMetadata = v1::DownloadableMetadata;
|
||||||
|
pub type DownloadType = v1::DownloadType;
|
||||||
|
pub type DatabaseApplications = v2::DatabaseApplications;
|
||||||
|
pub type DatabaseCompatInfo = v2::DatabaseCompatInfo;
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
pub mod v1 {
|
||||||
|
use crate::process::process_manager::Platform;
|
||||||
|
use serde_with::serde_as;
|
||||||
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
|
use super::{Deserialize, Serialize, native_model};
|
||||||
|
|
||||||
|
fn default_template() -> String {
|
||||||
|
"{}".to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[native_model(id = 2, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
pub struct GameVersion {
|
||||||
|
pub game_id: String,
|
||||||
|
pub version_name: String,
|
||||||
|
|
||||||
|
pub platform: Platform,
|
||||||
|
|
||||||
|
pub launch_command: String,
|
||||||
|
pub launch_args: Vec<String>,
|
||||||
|
#[serde(default = "default_template")]
|
||||||
|
pub launch_command_template: String,
|
||||||
|
|
||||||
|
pub setup_command: String,
|
||||||
|
pub setup_args: Vec<String>,
|
||||||
|
#[serde(default = "default_template")]
|
||||||
|
pub setup_command_template: String,
|
||||||
|
|
||||||
|
pub only_setup: bool,
|
||||||
|
|
||||||
|
pub version_index: usize,
|
||||||
|
pub delta: bool,
|
||||||
|
|
||||||
|
pub umu_id_override: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[serde_as]
|
||||||
|
#[derive(Serialize, Clone, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[native_model(id = 3, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
pub struct DatabaseApplications {
|
||||||
|
pub install_dirs: Vec<PathBuf>,
|
||||||
|
// Guaranteed to exist if the game also exists in the app state map
|
||||||
|
pub game_statuses: HashMap<String, GameDownloadStatus>,
|
||||||
|
pub game_versions: HashMap<String, HashMap<String, GameVersion>>,
|
||||||
|
pub installed_game_version: HashMap<String, DownloadableMetadata>,
|
||||||
|
|
||||||
|
#[serde(skip)]
|
||||||
|
pub transient_statuses: HashMap<DownloadableMetadata, ApplicationTransientStatus>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[native_model(id = 4, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
pub struct Settings {
|
||||||
|
pub autostart: bool,
|
||||||
|
pub max_download_threads: usize,
|
||||||
|
pub force_offline: bool, // ... other settings ...
|
||||||
|
}
|
||||||
|
impl Default for Settings {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
autostart: false,
|
||||||
|
max_download_threads: 4,
|
||||||
|
force_offline: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strings are version names for a particular game
|
||||||
|
#[derive(Serialize, Clone, Deserialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
#[native_model(id = 5, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
pub enum GameDownloadStatus {
|
||||||
|
Remote {},
|
||||||
|
SetupRequired {
|
||||||
|
version_name: String,
|
||||||
|
install_dir: String,
|
||||||
|
},
|
||||||
|
Installed {
|
||||||
|
version_name: String,
|
||||||
|
install_dir: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stuff that shouldn't be synced to disk
|
||||||
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
|
pub enum ApplicationTransientStatus {
|
||||||
|
Downloading { version_name: String },
|
||||||
|
Uninstalling {},
|
||||||
|
Updating { version_name: String },
|
||||||
|
Validating { version_name: String },
|
||||||
|
Running {},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(serde::Serialize, Clone, Deserialize)]
|
||||||
|
#[native_model(id = 6, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
pub struct DatabaseAuth {
|
||||||
|
pub private: String,
|
||||||
|
pub cert: String,
|
||||||
|
pub client_id: String,
|
||||||
|
pub web_token: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[native_model(id = 8, version = 1)]
|
||||||
|
#[derive(
|
||||||
|
Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone, Copy,
|
||||||
|
)]
|
||||||
|
pub enum DownloadType {
|
||||||
|
Game,
|
||||||
|
Tool,
|
||||||
|
Dlc,
|
||||||
|
Mod,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[native_model(id = 7, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct DownloadableMetadata {
|
||||||
|
pub id: String,
|
||||||
|
pub version: Option<String>,
|
||||||
|
pub download_type: DownloadType,
|
||||||
|
}
|
||||||
|
impl DownloadableMetadata {
|
||||||
|
pub fn new(id: String, version: Option<String>, download_type: DownloadType) -> Self {
|
||||||
|
Self {
|
||||||
|
id,
|
||||||
|
version,
|
||||||
|
download_type,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[native_model(id = 1, version = 1)]
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||||
|
pub struct Database {
|
||||||
|
#[serde(default)]
|
||||||
|
pub settings: Settings,
|
||||||
|
pub auth: Option<DatabaseAuth>,
|
||||||
|
pub base_url: String,
|
||||||
|
pub applications: DatabaseApplications,
|
||||||
|
pub prev_database: Option<PathBuf>,
|
||||||
|
pub cache_dir: PathBuf,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod v2 {
|
||||||
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
|
use serde_with::serde_as;
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
ApplicationTransientStatus, DatabaseAuth, Deserialize, DownloadableMetadata,
|
||||||
|
GameVersion, Serialize, Settings, native_model, v1,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[native_model(id = 1, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||||
|
pub struct Database {
|
||||||
|
#[serde(default)]
|
||||||
|
pub settings: Settings,
|
||||||
|
pub auth: Option<DatabaseAuth>,
|
||||||
|
pub base_url: String,
|
||||||
|
pub applications: v1::DatabaseApplications,
|
||||||
|
#[serde(skip)]
|
||||||
|
pub prev_database: Option<PathBuf>,
|
||||||
|
pub cache_dir: PathBuf,
|
||||||
|
pub compat_info: Option<DatabaseCompatInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[native_model(id = 8, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||||
|
|
||||||
|
pub struct DatabaseCompatInfo {
|
||||||
|
pub umu_installed: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<v1::Database> for Database {
|
||||||
|
fn from(value: v1::Database) -> Self {
|
||||||
|
Self {
|
||||||
|
settings: value.settings,
|
||||||
|
auth: value.auth,
|
||||||
|
base_url: value.base_url,
|
||||||
|
applications: value.applications,
|
||||||
|
prev_database: value.prev_database,
|
||||||
|
cache_dir: value.cache_dir,
|
||||||
|
compat_info: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Strings are version names for a particular game
|
||||||
|
#[derive(Serialize, Clone, Deserialize, Debug)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
#[native_model(id = 5, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
pub enum GameDownloadStatus {
|
||||||
|
Remote {},
|
||||||
|
SetupRequired {
|
||||||
|
version_name: String,
|
||||||
|
install_dir: String,
|
||||||
|
},
|
||||||
|
Installed {
|
||||||
|
version_name: String,
|
||||||
|
install_dir: String,
|
||||||
|
},
|
||||||
|
PartiallyInstalled {
|
||||||
|
version_name: String,
|
||||||
|
install_dir: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
impl From<v1::GameDownloadStatus> for GameDownloadStatus {
|
||||||
|
fn from(value: v1::GameDownloadStatus) -> Self {
|
||||||
|
match value {
|
||||||
|
v1::GameDownloadStatus::Remote {} => Self::Remote {},
|
||||||
|
v1::GameDownloadStatus::SetupRequired {
|
||||||
|
version_name,
|
||||||
|
install_dir,
|
||||||
|
} => Self::SetupRequired {
|
||||||
|
version_name,
|
||||||
|
install_dir,
|
||||||
|
},
|
||||||
|
v1::GameDownloadStatus::Installed {
|
||||||
|
version_name,
|
||||||
|
install_dir,
|
||||||
|
} => Self::Installed {
|
||||||
|
version_name,
|
||||||
|
install_dir,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[serde_as]
|
||||||
|
#[derive(Serialize, Clone, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[native_model(id = 3, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
pub struct DatabaseApplications {
|
||||||
|
pub install_dirs: Vec<PathBuf>,
|
||||||
|
// Guaranteed to exist if the game also exists in the app state map
|
||||||
|
pub game_statuses: HashMap<String, GameDownloadStatus>,
|
||||||
|
pub game_versions: HashMap<String, HashMap<String, GameVersion>>,
|
||||||
|
pub installed_game_version: HashMap<String, DownloadableMetadata>,
|
||||||
|
|
||||||
|
#[serde(skip)]
|
||||||
|
pub transient_statuses: HashMap<DownloadableMetadata, ApplicationTransientStatus>,
|
||||||
|
}
|
||||||
|
impl From<v1::DatabaseApplications> for DatabaseApplications {
|
||||||
|
fn from(value: v1::DatabaseApplications) -> Self {
|
||||||
|
Self {
|
||||||
|
game_statuses: value
|
||||||
|
.game_statuses
|
||||||
|
.into_iter()
|
||||||
|
.map(|x| (x.0, x.1.into()))
|
||||||
|
.collect::<HashMap<String, GameDownloadStatus>>(),
|
||||||
|
install_dirs: value.install_dirs,
|
||||||
|
game_versions: value.game_versions,
|
||||||
|
installed_game_version: value.installed_game_version,
|
||||||
|
transient_statuses: value.transient_statuses,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mod v3 {
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
DatabaseApplications, DatabaseAuth, DatabaseCompatInfo, Deserialize, Serialize,
|
||||||
|
Settings, native_model, v2,
|
||||||
|
};
|
||||||
|
#[native_model(id = 1, version = 3, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||||
|
pub struct Database {
|
||||||
|
#[serde(default)]
|
||||||
|
pub settings: Settings,
|
||||||
|
pub auth: Option<DatabaseAuth>,
|
||||||
|
pub base_url: String,
|
||||||
|
pub applications: DatabaseApplications,
|
||||||
|
#[serde(skip)]
|
||||||
|
pub prev_database: Option<PathBuf>,
|
||||||
|
pub cache_dir: PathBuf,
|
||||||
|
pub compat_info: Option<DatabaseCompatInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<v2::Database> for Database {
|
||||||
|
fn from(value: v2::Database) -> Self {
|
||||||
|
Self {
|
||||||
|
settings: value.settings,
|
||||||
|
auth: value.auth,
|
||||||
|
base_url: value.base_url,
|
||||||
|
applications: value.applications.into(),
|
||||||
|
prev_database: value.prev_database,
|
||||||
|
cache_dir: value.cache_dir,
|
||||||
|
compat_info: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Database {
|
||||||
|
pub fn new<T: Into<PathBuf>>(
|
||||||
|
games_base_dir: T,
|
||||||
|
prev_database: Option<PathBuf>,
|
||||||
|
cache_dir: PathBuf,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
applications: DatabaseApplications {
|
||||||
|
install_dirs: vec![games_base_dir.into()],
|
||||||
|
game_statuses: HashMap::new(),
|
||||||
|
game_versions: HashMap::new(),
|
||||||
|
installed_game_version: HashMap::new(),
|
||||||
|
transient_statuses: HashMap::new(),
|
||||||
|
},
|
||||||
|
prev_database,
|
||||||
|
base_url: String::new(),
|
||||||
|
auth: None,
|
||||||
|
settings: Settings::default(),
|
||||||
|
cache_dir,
|
||||||
|
compat_info: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
52
src-tauri/src/database/scan.rs
Normal file
52
src-tauri/src/database/scan.rs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
use std::fs;
|
||||||
|
|
||||||
|
use log::warn;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
database::{
|
||||||
|
db::borrow_db_mut_checked,
|
||||||
|
models::data::v1::{DownloadType, DownloadableMetadata},
|
||||||
|
},
|
||||||
|
games::{
|
||||||
|
downloads::drop_data::{v1::DropData, DROP_DATA_PATH},
|
||||||
|
library::set_partially_installed_db,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn scan_install_dirs() {
|
||||||
|
let mut db_lock = borrow_db_mut_checked();
|
||||||
|
for install_dir in db_lock.applications.install_dirs.clone() {
|
||||||
|
let Ok(files) = fs::read_dir(install_dir) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
for game in files.into_iter().flatten() {
|
||||||
|
let drop_data_file = game.path().join(DROP_DATA_PATH);
|
||||||
|
if !drop_data_file.exists() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let game_id = game.file_name().into_string().unwrap();
|
||||||
|
let Ok(drop_data) = DropData::read(&game.path()) else {
|
||||||
|
warn!(
|
||||||
|
".dropdata exists for {}, but couldn't read it. is it corrupted?",
|
||||||
|
game.file_name().into_string().unwrap()
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if db_lock.applications.game_statuses.contains_key(&game_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let metadata = DownloadableMetadata::new(
|
||||||
|
drop_data.game_id,
|
||||||
|
Some(drop_data.game_version),
|
||||||
|
DownloadType::Game,
|
||||||
|
);
|
||||||
|
set_partially_installed_db(
|
||||||
|
&mut db_lock,
|
||||||
|
&metadata,
|
||||||
|
drop_data.base_path.to_str().unwrap().to_string(),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,24 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct Settings {
|
|
||||||
pub autostart: bool,
|
|
||||||
pub max_download_threads: usize,
|
|
||||||
// ... other settings ...
|
|
||||||
}
|
|
||||||
impl Default for Settings {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
autostart: false,
|
|
||||||
max_download_threads: 4,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Ideally use pointers instead of a macro to assign the settings
|
|
||||||
// fn deserialize_into<T>(v: serde_json::Value, t: &mut T) -> Result<(), serde_json::Error>
|
|
||||||
// where T: for<'a> Deserialize<'a>
|
|
||||||
// {
|
|
||||||
// *t = serde_json::from_value(v)?;
|
|
||||||
// Ok(())
|
|
||||||
// }
|
|
||||||
@ -1,15 +1,15 @@
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use crate::{download_manager::downloadable_metadata::DownloadableMetadata, AppState};
|
use crate::{database::models::data::DownloadableMetadata, AppState};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn pause_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
pub fn pause_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
||||||
state.lock().unwrap().download_manager.pause_downloads()
|
state.lock().unwrap().download_manager.pause_downloads();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn resume_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
pub fn resume_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
||||||
state.lock().unwrap().download_manager.resume_downloads()
|
state.lock().unwrap().download_manager.resume_downloads();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -22,10 +22,10 @@ pub fn move_download_in_queue(
|
|||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.download_manager
|
.download_manager
|
||||||
.rearrange(old_index, new_index)
|
.rearrange(old_index, new_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn cancel_game(state: tauri::State<'_, Mutex<AppState>>, meta: DownloadableMetadata) {
|
pub fn cancel_game(state: tauri::State<'_, Mutex<AppState>>, meta: DownloadableMetadata) {
|
||||||
state.lock().unwrap().download_manager.cancel(meta)
|
state.lock().unwrap().download_manager.cancel(meta);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +1,29 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::{
|
sync::{
|
||||||
mpsc::{channel, Receiver, Sender},
|
|
||||||
Arc, Mutex,
|
Arc, Mutex,
|
||||||
|
mpsc::{Receiver, Sender, channel},
|
||||||
},
|
},
|
||||||
thread::{spawn, JoinHandle},
|
thread::{JoinHandle, spawn},
|
||||||
};
|
};
|
||||||
|
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use tauri::{AppHandle, Emitter};
|
use tauri::{AppHandle, Emitter};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
database::models::data::DownloadableMetadata,
|
||||||
error::application_download_error::ApplicationDownloadError,
|
error::application_download_error::ApplicationDownloadError,
|
||||||
games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent},
|
games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
download_manager::{DownloadManager, DownloadManagerSignal, DownloadManagerStatus},
|
download_manager_frontend::{DownloadManager, DownloadManagerSignal, DownloadManagerStatus},
|
||||||
download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag},
|
|
||||||
downloadable::Downloadable,
|
downloadable::Downloadable,
|
||||||
downloadable_metadata::DownloadableMetadata,
|
util::{
|
||||||
|
download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag},
|
||||||
progress_object::ProgressObject,
|
progress_object::ProgressObject,
|
||||||
queue::Queue,
|
queue::Queue,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type DownloadAgent = Arc<Box<dyn Downloadable + Send + Sync>>;
|
pub type DownloadAgent = Arc<Box<dyn Downloadable + Send + Sync>>;
|
||||||
@ -174,15 +176,14 @@ impl DownloadManagerBuilder {
|
|||||||
DownloadManagerSignal::Cancel(meta) => {
|
DownloadManagerSignal::Cancel(meta) => {
|
||||||
self.manage_cancel_signal(&meta);
|
self.manage_cancel_signal(&meta);
|
||||||
}
|
}
|
||||||
_ => {}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn manage_queue_signal(&mut self, download_agent: DownloadAgent) {
|
fn manage_queue_signal(&mut self, download_agent: DownloadAgent) {
|
||||||
debug!("got signal Queue");
|
debug!("got signal Queue");
|
||||||
let meta = download_agent.metadata();
|
let meta = download_agent.metadata();
|
||||||
|
|
||||||
debug!("queue metadata: {:?}", meta);
|
debug!("queue metadata: {meta:?}");
|
||||||
|
|
||||||
if self.download_queue.exists(meta.clone()) {
|
if self.download_queue.exists(meta.clone()) {
|
||||||
warn!("download with same ID already exists");
|
warn!("download with same ID already exists");
|
||||||
@ -208,7 +209,10 @@ impl DownloadManagerBuilder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.current_download_agent.is_some() {
|
if self.current_download_agent.is_some()
|
||||||
|
&& self.download_queue.read().front().unwrap()
|
||||||
|
== &self.current_download_agent.as_ref().unwrap().metadata()
|
||||||
|
{
|
||||||
debug!(
|
debug!(
|
||||||
"Current download agent: {:?}",
|
"Current download agent: {:?}",
|
||||||
self.current_download_agent.as_ref().unwrap().metadata()
|
self.current_download_agent.as_ref().unwrap().metadata()
|
||||||
@ -221,7 +225,7 @@ impl DownloadManagerBuilder {
|
|||||||
// Should always be Some if the above two statements keep going
|
// Should always be Some if the above two statements keep going
|
||||||
let agent_data = self.download_queue.read().front().unwrap().clone();
|
let agent_data = self.download_queue.read().front().unwrap().clone();
|
||||||
|
|
||||||
info!("starting download for {:?}", agent_data);
|
info!("starting download for {agent_data:?}");
|
||||||
|
|
||||||
let download_agent = self
|
let download_agent = self
|
||||||
.download_agent_registry
|
.download_agent_registry
|
||||||
@ -238,26 +242,47 @@ impl DownloadManagerBuilder {
|
|||||||
let app_handle = self.app_handle.clone();
|
let app_handle = self.app_handle.clone();
|
||||||
|
|
||||||
*download_thread_lock = Some(spawn(move || {
|
*download_thread_lock = Some(spawn(move || {
|
||||||
match download_agent.download(&app_handle) {
|
loop {
|
||||||
|
let download_result = match download_agent.download(&app_handle) {
|
||||||
// Ok(true) is for completed and exited properly
|
// Ok(true) is for completed and exited properly
|
||||||
Ok(true) => {
|
Ok(v) => v,
|
||||||
debug!("download {:?} has completed", download_agent.metadata());
|
Err(e) => {
|
||||||
|
error!("download {:?} has error {}", download_agent.metadata(), &e);
|
||||||
|
download_agent.on_error(&app_handle, &e);
|
||||||
|
sender.send(DownloadManagerSignal::Error(e)).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// If the download gets cancelled
|
||||||
|
// immediately return, on_cancelled gets called for us earlier
|
||||||
|
if !download_result {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let validate_result = match download_agent.validate(&app_handle) {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(e) => {
|
||||||
|
error!(
|
||||||
|
"download {:?} has validation error {}",
|
||||||
|
download_agent.metadata(),
|
||||||
|
&e
|
||||||
|
);
|
||||||
|
download_agent.on_error(&app_handle, &e);
|
||||||
|
sender.send(DownloadManagerSignal::Error(e)).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if validate_result {
|
||||||
download_agent.on_complete(&app_handle);
|
download_agent.on_complete(&app_handle);
|
||||||
sender
|
sender
|
||||||
.send(DownloadManagerSignal::Completed(download_agent.metadata()))
|
.send(DownloadManagerSignal::Completed(download_agent.metadata()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
|
||||||
// Ok(false) is for incomplete but exited properly
|
|
||||||
Ok(false) => {
|
|
||||||
download_agent.on_incomplete(&app_handle);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
error!("download {:?} has error {}", download_agent.metadata(), &e);
|
|
||||||
download_agent.on_error(&app_handle, e.clone());
|
|
||||||
sender.send(DownloadManagerSignal::Error(e)).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sender.send(DownloadManagerSignal::UpdateUIQueue).unwrap();
|
sender.send(DownloadManagerSignal::UpdateUIQueue).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
self.set_status(DownloadManagerStatus::Downloading);
|
self.set_status(DownloadManagerStatus::Downloading);
|
||||||
@ -274,23 +299,24 @@ impl DownloadManagerBuilder {
|
|||||||
}
|
}
|
||||||
fn manage_completed_signal(&mut self, meta: DownloadableMetadata) {
|
fn manage_completed_signal(&mut self, meta: DownloadableMetadata) {
|
||||||
debug!("got signal Completed");
|
debug!("got signal Completed");
|
||||||
if let Some(interface) = &self.current_download_agent {
|
if let Some(interface) = &self.current_download_agent
|
||||||
if interface.metadata() == meta {
|
&& interface.metadata() == meta
|
||||||
|
{
|
||||||
self.remove_and_cleanup_front_download(&meta);
|
self.remove_and_cleanup_front_download(&meta);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self.push_ui_queue_update();
|
self.push_ui_queue_update();
|
||||||
self.sender.send(DownloadManagerSignal::Go).unwrap();
|
self.sender.send(DownloadManagerSignal::Go).unwrap();
|
||||||
}
|
}
|
||||||
fn manage_error_signal(&mut self, error: ApplicationDownloadError) {
|
fn manage_error_signal(&mut self, error: ApplicationDownloadError) {
|
||||||
debug!("got signal Error");
|
debug!("got signal Error");
|
||||||
if let Some(current_agent) = self.current_download_agent.clone() {
|
if let Some(current_agent) = self.current_download_agent.clone() {
|
||||||
current_agent.on_error(&self.app_handle, error.clone());
|
current_agent.on_error(&self.app_handle, &error);
|
||||||
|
|
||||||
self.stop_and_wait_current_download();
|
self.stop_and_wait_current_download();
|
||||||
self.remove_and_cleanup_front_download(¤t_agent.metadata());
|
self.remove_and_cleanup_front_download(¤t_agent.metadata());
|
||||||
}
|
}
|
||||||
self.set_status(DownloadManagerStatus::Error(error));
|
self.set_status(DownloadManagerStatus::Error);
|
||||||
}
|
}
|
||||||
fn manage_cancel_signal(&mut self, meta: &DownloadableMetadata) {
|
fn manage_cancel_signal(&mut self, meta: &DownloadableMetadata) {
|
||||||
debug!("got signal Cancel");
|
debug!("got signal Cancel");
|
||||||
|
|||||||
@ -12,22 +12,24 @@ use std::{
|
|||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::error::application_download_error::ApplicationDownloadError;
|
use crate::{
|
||||||
|
database::models::data::DownloadableMetadata,
|
||||||
|
error::application_download_error::ApplicationDownloadError,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
download_manager_builder::{CurrentProgressObject, DownloadAgent},
|
download_manager_builder::{CurrentProgressObject, DownloadAgent},
|
||||||
downloadable_metadata::DownloadableMetadata,
|
util::queue::Queue,
|
||||||
queue::Queue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub enum DownloadManagerSignal {
|
pub enum DownloadManagerSignal {
|
||||||
/// Resumes (or starts) the DownloadManager
|
/// Resumes (or starts) the `DownloadManager`
|
||||||
Go,
|
Go,
|
||||||
/// Pauses the DownloadManager
|
/// Pauses the `DownloadManager`
|
||||||
Stop,
|
Stop,
|
||||||
/// Called when a DownloadAgent has fully completed a download.
|
/// Called when a `DownloadAgent` has fully completed a download.
|
||||||
Completed(DownloadableMetadata),
|
Completed(DownloadableMetadata),
|
||||||
/// Generates and appends a DownloadAgent
|
/// Generates and appends a `DownloadAgent`
|
||||||
/// to the registry and queue
|
/// to the registry and queue
|
||||||
Queue(DownloadAgent),
|
Queue(DownloadAgent),
|
||||||
/// Tells the Manager to stop the current
|
/// Tells the Manager to stop the current
|
||||||
@ -36,25 +38,19 @@ pub enum DownloadManagerSignal {
|
|||||||
Finish,
|
Finish,
|
||||||
/// Stops, removes, and tells a download to cleanup
|
/// Stops, removes, and tells a download to cleanup
|
||||||
Cancel(DownloadableMetadata),
|
Cancel(DownloadableMetadata),
|
||||||
/// Removes a given application
|
|
||||||
Remove(DownloadableMetadata),
|
|
||||||
/// Any error which occurs in the agent
|
/// Any error which occurs in the agent
|
||||||
Error(ApplicationDownloadError),
|
Error(ApplicationDownloadError),
|
||||||
/// Pushes UI update
|
/// Pushes UI update
|
||||||
UpdateUIQueue,
|
UpdateUIQueue,
|
||||||
UpdateUIStats(usize, usize), //kb/s and seconds
|
UpdateUIStats(usize, usize), //kb/s and seconds
|
||||||
/// Uninstall download
|
|
||||||
/// Takes download ID
|
|
||||||
Uninstall(DownloadableMetadata),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug)]
|
||||||
pub enum DownloadManagerStatus {
|
pub enum DownloadManagerStatus {
|
||||||
Downloading,
|
Downloading,
|
||||||
Paused,
|
Paused,
|
||||||
Empty,
|
Empty,
|
||||||
Error(ApplicationDownloadError),
|
Error,
|
||||||
Finished,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for DownloadManagerStatus {
|
impl Serialize for DownloadManagerStatus {
|
||||||
@ -62,7 +58,7 @@ impl Serialize for DownloadManagerStatus {
|
|||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
serializer.serialize_str(&format!["{:?}", self])
|
serializer.serialize_str(&format!["{self:?}"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,17 +66,18 @@ impl Serialize for DownloadManagerStatus {
|
|||||||
pub enum DownloadStatus {
|
pub enum DownloadStatus {
|
||||||
Queued,
|
Queued,
|
||||||
Downloading,
|
Downloading,
|
||||||
|
Validating,
|
||||||
Error,
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accessible front-end for the DownloadManager
|
/// Accessible front-end for the `DownloadManager`
|
||||||
///
|
///
|
||||||
/// The system works entirely through signals, both internally and externally,
|
/// The system works entirely through signals, both internally and externally,
|
||||||
/// all of which are accessible through the DownloadManagerSignal type, but
|
/// all of which are accessible through the `DownloadManagerSignal` type, but
|
||||||
/// should not be used directly. Rather, signals are abstracted through this
|
/// should not be used directly. Rather, signals are abstracted through this
|
||||||
/// interface.
|
/// interface.
|
||||||
///
|
///
|
||||||
/// The actual download queue may be accessed through the .edit() function,
|
/// The actual download queue may be accessed through the .`edit()` function,
|
||||||
/// which provides raw access to the underlying queue.
|
/// which provides raw access to the underlying queue.
|
||||||
/// THIS EDITING IS BLOCKING!!!
|
/// THIS EDITING IS BLOCKING!!!
|
||||||
pub struct DownloadManager {
|
pub struct DownloadManager {
|
||||||
@ -142,7 +139,7 @@ impl DownloadManager {
|
|||||||
pub fn rearrange(&self, current_index: usize, new_index: usize) {
|
pub fn rearrange(&self, current_index: usize, new_index: usize) {
|
||||||
if current_index == new_index {
|
if current_index == new_index {
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
let needs_pause = current_index == 0 || new_index == 0;
|
let needs_pause = current_index == 0 || new_index == 0;
|
||||||
if needs_pause {
|
if needs_pause {
|
||||||
@ -151,10 +148,7 @@ impl DownloadManager {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!(
|
debug!("moving download at index {current_index} to index {new_index}");
|
||||||
"moving download at index {} to index {}",
|
|
||||||
current_index, new_index
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut queue = self.edit();
|
let mut queue = self.edit();
|
||||||
let to_move = queue.remove(current_index).unwrap();
|
let to_move = queue.remove(current_index).unwrap();
|
||||||
@ -167,6 +161,7 @@ impl DownloadManager {
|
|||||||
self.command_sender
|
self.command_sender
|
||||||
.send(DownloadManagerSignal::UpdateUIQueue)
|
.send(DownloadManagerSignal::UpdateUIQueue)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
self.command_sender.send(DownloadManagerSignal::Go).unwrap();
|
||||||
}
|
}
|
||||||
pub fn pause_downloads(&self) {
|
pub fn pause_downloads(&self) {
|
||||||
self.command_sender
|
self.command_sender
|
||||||
@ -183,17 +178,12 @@ impl DownloadManager {
|
|||||||
let terminator = self.terminator.lock().unwrap().take();
|
let terminator = self.terminator.lock().unwrap().take();
|
||||||
terminator.unwrap().join()
|
terminator.unwrap().join()
|
||||||
}
|
}
|
||||||
pub fn uninstall_application(&self, meta: DownloadableMetadata) {
|
|
||||||
self.command_sender
|
|
||||||
.send(DownloadManagerSignal::Uninstall(meta))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
pub fn get_sender(&self) -> Sender<DownloadManagerSignal> {
|
pub fn get_sender(&self) -> Sender<DownloadManagerSignal> {
|
||||||
self.command_sender.clone()
|
self.command_sender.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes in the locked value from .edit() and attempts to
|
/// Takes in the locked value from .`edit()` and attempts to
|
||||||
/// get the index of whatever id is passed in
|
/// get the index of whatever id is passed in
|
||||||
fn get_index_from_id(
|
fn get_index_from_id(
|
||||||
queue: &mut MutexGuard<'_, VecDeque<DownloadableMetadata>>,
|
queue: &mut MutexGuard<'_, VecDeque<DownloadableMetadata>>,
|
||||||
@ -2,22 +2,26 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
|
|
||||||
use crate::error::application_download_error::ApplicationDownloadError;
|
use crate::{
|
||||||
|
database::models::data::DownloadableMetadata,
|
||||||
|
error::application_download_error::ApplicationDownloadError,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
download_manager::DownloadStatus, download_thread_control_flag::DownloadThreadControl,
|
download_manager_frontend::DownloadStatus,
|
||||||
downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject,
|
util::{download_thread_control_flag::DownloadThreadControl, progress_object::ProgressObject},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Downloadable: Send + Sync {
|
pub trait Downloadable: Send + Sync {
|
||||||
fn download(&self, app_handle: &AppHandle) -> Result<bool, ApplicationDownloadError>;
|
fn download(&self, app_handle: &AppHandle) -> Result<bool, ApplicationDownloadError>;
|
||||||
|
fn validate(&self, app_handle: &AppHandle) -> Result<bool, ApplicationDownloadError>;
|
||||||
|
|
||||||
fn progress(&self) -> Arc<ProgressObject>;
|
fn progress(&self) -> Arc<ProgressObject>;
|
||||||
fn control_flag(&self) -> DownloadThreadControl;
|
fn control_flag(&self) -> DownloadThreadControl;
|
||||||
fn status(&self) -> DownloadStatus;
|
fn status(&self) -> DownloadStatus;
|
||||||
fn metadata(&self) -> DownloadableMetadata;
|
fn metadata(&self) -> DownloadableMetadata;
|
||||||
fn on_initialised(&self, app_handle: &AppHandle);
|
fn on_initialised(&self, app_handle: &AppHandle);
|
||||||
fn on_error(&self, app_handle: &AppHandle, error: ApplicationDownloadError);
|
fn on_error(&self, app_handle: &AppHandle, error: &ApplicationDownloadError);
|
||||||
fn on_complete(&self, app_handle: &AppHandle);
|
fn on_complete(&self, app_handle: &AppHandle);
|
||||||
fn on_incomplete(&self, app_handle: &AppHandle);
|
|
||||||
fn on_cancelled(&self, app_handle: &AppHandle);
|
fn on_cancelled(&self, app_handle: &AppHandle);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone, Copy)]
|
|
||||||
pub enum DownloadType {
|
|
||||||
Game,
|
|
||||||
Tool,
|
|
||||||
DLC,
|
|
||||||
Mod,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct DownloadableMetadata {
|
|
||||||
pub id: String,
|
|
||||||
pub version: Option<String>,
|
|
||||||
pub download_type: DownloadType,
|
|
||||||
}
|
|
||||||
impl DownloadableMetadata {
|
|
||||||
pub fn new(id: String, version: Option<String>, download_type: DownloadType) -> Self {
|
|
||||||
Self {
|
|
||||||
id,
|
|
||||||
version,
|
|
||||||
download_type,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
use std::{fmt::Display, io, sync::mpsc::SendError};
|
|
||||||
|
|
||||||
use serde_with::SerializeDisplay;
|
|
||||||
|
|
||||||
#[derive(SerializeDisplay)]
|
|
||||||
pub enum InternalError<T> {
|
|
||||||
IOError(io::Error),
|
|
||||||
SignalError(SendError<T>),
|
|
||||||
}
|
|
||||||
impl<T> Display for InternalError<T> {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
InternalError::IOError(error) => write!(f, "{}", error),
|
|
||||||
InternalError::SignalError(send_error) => write!(f, "{}", send_error),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T> From<SendError<T>> for InternalError<T> {
|
|
||||||
fn from(value: SendError<T>) -> Self {
|
|
||||||
InternalError::SignalError(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T> From<io::Error> for InternalError<T> {
|
|
||||||
fn from(value: io::Error) -> Self {
|
|
||||||
InternalError::IOError(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +1,5 @@
|
|||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod download_manager;
|
|
||||||
pub mod download_manager_builder;
|
pub mod download_manager_builder;
|
||||||
pub mod download_thread_control_flag;
|
pub mod download_manager_frontend;
|
||||||
pub mod downloadable;
|
pub mod downloadable;
|
||||||
pub mod downloadable_metadata;
|
pub mod util;
|
||||||
pub mod internal_error;
|
|
||||||
pub mod progress_object;
|
|
||||||
pub mod queue;
|
|
||||||
pub mod rolling_progress_updates;
|
|
||||||
|
|||||||
@ -1,80 +0,0 @@
|
|||||||
use std::{
|
|
||||||
collections::VecDeque,
|
|
||||||
sync::{Arc, Mutex, MutexGuard},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::downloadable_metadata::DownloadableMetadata;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Queue {
|
|
||||||
inner: Arc<Mutex<VecDeque<DownloadableMetadata>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
impl Default for Queue {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Queue {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
inner: Arc::new(Mutex::new(VecDeque::new())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn read(&self) -> VecDeque<DownloadableMetadata> {
|
|
||||||
self.inner.lock().unwrap().clone()
|
|
||||||
}
|
|
||||||
pub fn edit(&self) -> MutexGuard<'_, VecDeque<DownloadableMetadata>> {
|
|
||||||
self.inner.lock().unwrap()
|
|
||||||
}
|
|
||||||
pub fn pop_front(&self) -> Option<DownloadableMetadata> {
|
|
||||||
self.edit().pop_front()
|
|
||||||
}
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
self.inner.lock().unwrap().len() == 0
|
|
||||||
}
|
|
||||||
pub fn exists(&self, meta: DownloadableMetadata) -> bool {
|
|
||||||
self.read().contains(&meta)
|
|
||||||
}
|
|
||||||
/// Either inserts `interface` at the specified index, or appends to
|
|
||||||
/// the back of the deque if index is greater than the length of the deque
|
|
||||||
pub fn insert(&self, interface: DownloadableMetadata, index: usize) {
|
|
||||||
if self.read().len() > index {
|
|
||||||
self.append(interface);
|
|
||||||
} else {
|
|
||||||
self.edit().insert(index, interface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn append(&self, interface: DownloadableMetadata) {
|
|
||||||
self.edit().push_back(interface);
|
|
||||||
}
|
|
||||||
pub fn pop_front_if_equal(&self, meta: &DownloadableMetadata) -> Option<DownloadableMetadata> {
|
|
||||||
let mut queue = self.edit();
|
|
||||||
let front = queue.front()?;
|
|
||||||
if front == meta {
|
|
||||||
return queue.pop_front();
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
pub fn get_by_meta(&self, meta: &DownloadableMetadata) -> Option<usize> {
|
|
||||||
self.read().iter().position(|data| data == meta)
|
|
||||||
}
|
|
||||||
pub fn move_to_index_by_meta(
|
|
||||||
&self,
|
|
||||||
meta: &DownloadableMetadata,
|
|
||||||
new_index: usize,
|
|
||||||
) -> Result<(), ()> {
|
|
||||||
let index = match self.get_by_meta(meta) {
|
|
||||||
Some(index) => index,
|
|
||||||
None => return Err(()),
|
|
||||||
};
|
|
||||||
let existing = match self.edit().remove(index) {
|
|
||||||
Some(existing) => existing,
|
|
||||||
None => return Err(()),
|
|
||||||
};
|
|
||||||
self.edit().insert(new_index, existing);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -22,10 +22,7 @@ impl From<DownloadThreadControlFlag> for bool {
|
|||||||
/// false => Stop
|
/// false => Stop
|
||||||
impl From<bool> for DownloadThreadControlFlag {
|
impl From<bool> for DownloadThreadControlFlag {
|
||||||
fn from(value: bool) -> Self {
|
fn from(value: bool) -> Self {
|
||||||
match value {
|
if value { DownloadThreadControlFlag::Go } else { DownloadThreadControlFlag::Stop }
|
||||||
true => DownloadThreadControlFlag::Go,
|
|
||||||
false => DownloadThreadControlFlag::Stop,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,9 +38,9 @@ impl DownloadThreadControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn get(&self) -> DownloadThreadControlFlag {
|
pub fn get(&self) -> DownloadThreadControlFlag {
|
||||||
self.inner.load(Ordering::Relaxed).into()
|
self.inner.load(Ordering::Acquire).into()
|
||||||
}
|
}
|
||||||
pub fn set(&self, flag: DownloadThreadControlFlag) {
|
pub fn set(&self, flag: DownloadThreadControlFlag) {
|
||||||
self.inner.store(flag.into(), Ordering::Relaxed);
|
self.inner.store(flag.into(), Ordering::Release);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
4
src-tauri/src/download_manager/util/mod.rs
Normal file
4
src-tauri/src/download_manager/util/mod.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
pub mod download_thread_control_flag;
|
||||||
|
pub mod progress_object;
|
||||||
|
pub mod queue;
|
||||||
|
pub mod rolling_progress_updates;
|
||||||
@ -10,9 +10,9 @@ use std::{
|
|||||||
use atomic_instant_full::AtomicInstant;
|
use atomic_instant_full::AtomicInstant;
|
||||||
use throttle_my_fn::throttle;
|
use throttle_my_fn::throttle;
|
||||||
|
|
||||||
use super::{
|
use crate::download_manager::download_manager_frontend::DownloadManagerSignal;
|
||||||
download_manager::DownloadManagerSignal, rolling_progress_updates::RollingProgressWindow,
|
|
||||||
};
|
use super::rolling_progress_updates::RollingProgressWindow;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ProgressObject {
|
pub struct ProgressObject {
|
||||||
@ -39,20 +39,20 @@ impl ProgressHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn set(&self, amount: usize) {
|
pub fn set(&self, amount: usize) {
|
||||||
self.progress.store(amount, Ordering::Relaxed);
|
self.progress.store(amount, Ordering::Release);
|
||||||
}
|
}
|
||||||
pub fn add(&self, amount: usize) {
|
pub fn add(&self, amount: usize) {
|
||||||
self.progress
|
self.progress
|
||||||
.fetch_add(amount, std::sync::atomic::Ordering::Relaxed);
|
.fetch_add(amount, std::sync::atomic::Ordering::AcqRel);
|
||||||
calculate_update(&self.progress_object);
|
calculate_update(&self.progress_object);
|
||||||
}
|
}
|
||||||
pub fn skip(&self, amount: usize) {
|
pub fn skip(&self, amount: usize) {
|
||||||
self.progress
|
self.progress
|
||||||
.fetch_add(amount, std::sync::atomic::Ordering::Relaxed);
|
.fetch_add(amount, std::sync::atomic::Ordering::Acquire);
|
||||||
// Offset the bytes at last offset by this amount
|
// Offset the bytes at last offset by this amount
|
||||||
self.progress_object
|
self.progress_object
|
||||||
.bytes_last_update
|
.bytes_last_update
|
||||||
.fetch_add(amount, Ordering::Relaxed);
|
.fetch_add(amount, Ordering::Acquire);
|
||||||
// Dont' fire update
|
// Dont' fire update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,6 @@ impl ProgressHandle {
|
|||||||
impl ProgressObject {
|
impl ProgressObject {
|
||||||
pub fn new(max: usize, length: usize, sender: Sender<DownloadManagerSignal>) -> Self {
|
pub fn new(max: usize, length: usize, sender: Sender<DownloadManagerSignal>) -> Self {
|
||||||
let arr = Mutex::new((0..length).map(|_| Arc::new(AtomicUsize::new(0))).collect());
|
let arr = Mutex::new((0..length).map(|_| Arc::new(AtomicUsize::new(0))).collect());
|
||||||
// TODO: consolidate this calculation with the set_max function below
|
|
||||||
Self {
|
Self {
|
||||||
max: Arc::new(Mutex::new(max)),
|
max: Arc::new(Mutex::new(max)),
|
||||||
progress_instances: Arc::new(arr),
|
progress_instances: Arc::new(arr),
|
||||||
@ -81,9 +80,19 @@ impl ProgressObject {
|
|||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|instance| instance.load(Ordering::Relaxed))
|
.map(|instance| instance.load(Ordering::Acquire))
|
||||||
.sum()
|
.sum()
|
||||||
}
|
}
|
||||||
|
pub fn reset(&self) {
|
||||||
|
self.set_time_now();
|
||||||
|
self.bytes_last_update.store(0, Ordering::Release);
|
||||||
|
self.rolling.reset();
|
||||||
|
self.progress_instances
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.for_each(|x| x.store(0, Ordering::SeqCst));
|
||||||
|
}
|
||||||
pub fn get_max(&self) -> usize {
|
pub fn get_max(&self) -> usize {
|
||||||
*self.max.lock().unwrap()
|
*self.max.lock().unwrap()
|
||||||
}
|
}
|
||||||
@ -116,13 +125,13 @@ pub fn calculate_update(progress: &ProgressObject) {
|
|||||||
let max = progress.get_max();
|
let max = progress.get_max();
|
||||||
let bytes_at_last_update = progress
|
let bytes_at_last_update = progress
|
||||||
.bytes_last_update
|
.bytes_last_update
|
||||||
.swap(current_bytes_downloaded, Ordering::Relaxed);
|
.swap(current_bytes_downloaded, Ordering::Acquire);
|
||||||
|
|
||||||
let bytes_since_last_update = current_bytes_downloaded - bytes_at_last_update;
|
let bytes_since_last_update = current_bytes_downloaded - bytes_at_last_update;
|
||||||
|
|
||||||
let kilobytes_per_second = bytes_since_last_update / (time_since_last_update as usize).max(1);
|
let kilobytes_per_second = bytes_since_last_update / (time_since_last_update as usize).max(1);
|
||||||
|
|
||||||
let bytes_remaining = max - current_bytes_downloaded; // bytes
|
let bytes_remaining = max.saturating_sub(current_bytes_downloaded); // bytes
|
||||||
|
|
||||||
progress.update_window(kilobytes_per_second);
|
progress.update_window(kilobytes_per_second);
|
||||||
push_update(progress, bytes_remaining);
|
push_update(progress, bytes_remaining);
|
||||||
44
src-tauri/src/download_manager/util/queue.rs
Normal file
44
src-tauri/src/download_manager/util/queue.rs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
use std::{
|
||||||
|
collections::VecDeque,
|
||||||
|
sync::{Arc, Mutex, MutexGuard},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::database::models::data::DownloadableMetadata;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Queue {
|
||||||
|
inner: Arc<Mutex<VecDeque<DownloadableMetadata>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
impl Default for Queue {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Queue {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
inner: Arc::new(Mutex::new(VecDeque::new())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn read(&self) -> VecDeque<DownloadableMetadata> {
|
||||||
|
self.inner.lock().unwrap().clone()
|
||||||
|
}
|
||||||
|
pub fn edit(&self) -> MutexGuard<'_, VecDeque<DownloadableMetadata>> {
|
||||||
|
self.inner.lock().unwrap()
|
||||||
|
}
|
||||||
|
pub fn pop_front(&self) -> Option<DownloadableMetadata> {
|
||||||
|
self.edit().pop_front()
|
||||||
|
}
|
||||||
|
pub fn exists(&self, meta: DownloadableMetadata) -> bool {
|
||||||
|
self.read().contains(&meta)
|
||||||
|
}
|
||||||
|
pub fn append(&self, interface: DownloadableMetadata) {
|
||||||
|
self.edit().push_back(interface);
|
||||||
|
}
|
||||||
|
pub fn get_by_meta(&self, meta: &DownloadableMetadata) -> Option<usize> {
|
||||||
|
self.read().iter().position(|data| data == meta)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,7 +11,7 @@ pub struct RollingProgressWindow<const S: usize> {
|
|||||||
impl<const S: usize> RollingProgressWindow<S> {
|
impl<const S: usize> RollingProgressWindow<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
window: Arc::new([(); S].map(|_| AtomicUsize::new(0))),
|
window: Arc::new([(); S].map(|()| AtomicUsize::new(0))),
|
||||||
current: Arc::new(AtomicUsize::new(0)),
|
current: Arc::new(AtomicUsize::new(0)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,8 +26,13 @@ impl<const S: usize> RollingProgressWindow<S> {
|
|||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(i, _)| i < ¤t)
|
.filter(|(i, _)| i < ¤t)
|
||||||
.map(|(_, x)| x.load(Ordering::Relaxed))
|
.map(|(_, x)| x.load(Ordering::Acquire))
|
||||||
.sum::<usize>()
|
.sum::<usize>()
|
||||||
/ S
|
/ S
|
||||||
}
|
}
|
||||||
|
pub fn reset(&self) {
|
||||||
|
self.window
|
||||||
|
.iter()
|
||||||
|
.for_each(|x| x.store(0, Ordering::Release));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -5,14 +5,13 @@ use std::{
|
|||||||
|
|
||||||
use serde_with::SerializeDisplay;
|
use serde_with::SerializeDisplay;
|
||||||
|
|
||||||
use super::{remote_access_error::RemoteAccessError, setup_error::SetupError};
|
use super::remote_access_error::RemoteAccessError;
|
||||||
|
|
||||||
// TODO: Rename / separate from downloads
|
// TODO: Rename / separate from downloads
|
||||||
#[derive(Debug, Clone, SerializeDisplay)]
|
#[derive(Debug, SerializeDisplay)]
|
||||||
pub enum ApplicationDownloadError {
|
pub enum ApplicationDownloadError {
|
||||||
Communication(RemoteAccessError),
|
Communication(RemoteAccessError),
|
||||||
Checksum,
|
Checksum,
|
||||||
Setup(SetupError),
|
|
||||||
Lock,
|
Lock,
|
||||||
IoError(io::ErrorKind),
|
IoError(io::ErrorKind),
|
||||||
DownloadError,
|
DownloadError,
|
||||||
@ -21,11 +20,10 @@ pub enum ApplicationDownloadError {
|
|||||||
impl Display for ApplicationDownloadError {
|
impl Display for ApplicationDownloadError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
ApplicationDownloadError::Communication(error) => write!(f, "{}", error),
|
ApplicationDownloadError::Communication(error) => write!(f, "{error}"),
|
||||||
ApplicationDownloadError::Setup(error) => write!(f, "an error occurred while setting up the download: {}", error),
|
|
||||||
ApplicationDownloadError::Lock => write!(f, "failed to acquire lock. Something has gone very wrong internally. Please restart the application"),
|
ApplicationDownloadError::Lock => write!(f, "failed to acquire lock. Something has gone very wrong internally. Please restart the application"),
|
||||||
ApplicationDownloadError::Checksum => write!(f, "checksum failed to validate for download"),
|
ApplicationDownloadError::Checksum => write!(f, "checksum failed to validate for download"),
|
||||||
ApplicationDownloadError::IoError(error) => write!(f, "{}", error),
|
ApplicationDownloadError::IoError(error) => write!(f, "io error: {error}"),
|
||||||
ApplicationDownloadError::DownloadError => write!(f, "download failed. See Download Manager status for specific error"),
|
ApplicationDownloadError::DownloadError => write!(f, "download failed. See Download Manager status for specific error"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
src-tauri/src/error/download_manager_error.rs
Normal file
27
src-tauri/src/error/download_manager_error.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
use std::{fmt::Display, io, sync::mpsc::SendError};
|
||||||
|
|
||||||
|
use serde_with::SerializeDisplay;
|
||||||
|
|
||||||
|
#[derive(SerializeDisplay)]
|
||||||
|
pub enum DownloadManagerError<T> {
|
||||||
|
IOError(io::Error),
|
||||||
|
SignalError(SendError<T>),
|
||||||
|
}
|
||||||
|
impl<T> Display for DownloadManagerError<T> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
DownloadManagerError::IOError(error) => write!(f, "{error}"),
|
||||||
|
DownloadManagerError::SignalError(send_error) => write!(f, "{send_error}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<T> From<SendError<T>> for DownloadManagerError<T> {
|
||||||
|
fn from(value: SendError<T>) -> Self {
|
||||||
|
DownloadManagerError::SignalError(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<T> From<io::Error> for DownloadManagerError<T> {
|
||||||
|
fn from(value: io::Error) -> Self {
|
||||||
|
DownloadManagerError::IOError(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,6 +5,6 @@ use serde::Deserialize;
|
|||||||
pub struct DropServerError {
|
pub struct DropServerError {
|
||||||
pub status_code: usize,
|
pub status_code: usize,
|
||||||
pub status_message: String,
|
pub status_message: String,
|
||||||
pub message: String,
|
// pub message: String,
|
||||||
pub url: String,
|
// pub url: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,8 +11,7 @@ impl Display for LibraryError {
|
|||||||
match self {
|
match self {
|
||||||
LibraryError::MetaNotFound(id) => write!(
|
LibraryError::MetaNotFound(id) => write!(
|
||||||
f,
|
f,
|
||||||
"Could not locate any installed version of game ID {} in the database",
|
"Could not locate any installed version of game ID {id} in the database"
|
||||||
id
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
pub mod application_download_error;
|
pub mod application_download_error;
|
||||||
|
pub mod download_manager_error;
|
||||||
pub mod drop_server_error;
|
pub mod drop_server_error;
|
||||||
pub mod library_error;
|
pub mod library_error;
|
||||||
pub mod process_error;
|
pub mod process_error;
|
||||||
pub mod remote_access_error;
|
pub mod remote_access_error;
|
||||||
pub mod setup_error;
|
|
||||||
|
|||||||
@ -4,28 +4,28 @@ use serde_with::SerializeDisplay;
|
|||||||
|
|
||||||
#[derive(SerializeDisplay)]
|
#[derive(SerializeDisplay)]
|
||||||
pub enum ProcessError {
|
pub enum ProcessError {
|
||||||
SetupRequired,
|
|
||||||
NotInstalled,
|
NotInstalled,
|
||||||
AlreadyRunning,
|
AlreadyRunning,
|
||||||
NotDownloaded,
|
|
||||||
InvalidID,
|
InvalidID,
|
||||||
InvalidVersion,
|
InvalidVersion,
|
||||||
IOError(Error),
|
IOError(Error),
|
||||||
|
FormatError(String), // String errors supremacy
|
||||||
InvalidPlatform,
|
InvalidPlatform,
|
||||||
|
OpenerError(tauri_plugin_opener::Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for ProcessError {
|
impl Display for ProcessError {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let s = match self {
|
let s = match self {
|
||||||
ProcessError::SetupRequired => "Game not set up",
|
|
||||||
ProcessError::NotInstalled => "Game not installed",
|
ProcessError::NotInstalled => "Game not installed",
|
||||||
ProcessError::AlreadyRunning => "Game already running",
|
ProcessError::AlreadyRunning => "Game already running",
|
||||||
ProcessError::NotDownloaded => "Game not downloaded",
|
ProcessError::InvalidID => "Invalid game ID",
|
||||||
ProcessError::InvalidID => "Invalid Game ID",
|
ProcessError::InvalidVersion => "Invalid game version",
|
||||||
ProcessError::InvalidVersion => "Invalid Game version",
|
|
||||||
ProcessError::IOError(error) => &error.to_string(),
|
ProcessError::IOError(error) => &error.to_string(),
|
||||||
ProcessError::InvalidPlatform => "This Game cannot be played on the current platform",
|
ProcessError::InvalidPlatform => "This game cannot be played on the current platform",
|
||||||
|
ProcessError::FormatError(e) => &format!("Failed to format template: {e}"),
|
||||||
|
ProcessError::OpenerError(error) => &format!("Failed to open directory: {error}"),
|
||||||
};
|
};
|
||||||
write!(f, "{}", s)
|
write!(f, "{s}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,24 +10,44 @@ use url::ParseError;
|
|||||||
|
|
||||||
use super::drop_server_error::DropServerError;
|
use super::drop_server_error::DropServerError;
|
||||||
|
|
||||||
#[derive(Debug, Clone, SerializeDisplay)]
|
#[derive(Debug, SerializeDisplay)]
|
||||||
pub enum RemoteAccessError {
|
pub enum RemoteAccessError {
|
||||||
FetchError(Arc<reqwest::Error>),
|
FetchError(Arc<reqwest::Error>),
|
||||||
|
FetchErrorWS(Arc<reqwest_websocket::Error>),
|
||||||
ParsingError(ParseError),
|
ParsingError(ParseError),
|
||||||
InvalidEndpoint,
|
InvalidEndpoint,
|
||||||
HandshakeFailed(String),
|
HandshakeFailed(String),
|
||||||
GameNotFound,
|
GameNotFound(String),
|
||||||
InvalidResponse(DropServerError),
|
InvalidResponse(DropServerError),
|
||||||
InvalidRedirect,
|
UnparseableResponse(String),
|
||||||
ManifestDownloadFailed(StatusCode, String),
|
ManifestDownloadFailed(StatusCode, String),
|
||||||
OutOfSync,
|
OutOfSync,
|
||||||
Generic(String),
|
Cache(std::io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for RemoteAccessError {
|
impl Display for RemoteAccessError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
RemoteAccessError::FetchError(error) => write!(
|
RemoteAccessError::FetchError(error) => {
|
||||||
|
if error.is_connect() {
|
||||||
|
return write!(
|
||||||
|
f,
|
||||||
|
"Failed to connect to Drop server. Check if you access Drop through a browser, and then try again."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}: {}",
|
||||||
|
error,
|
||||||
|
error
|
||||||
|
.source()
|
||||||
|
.map(std::string::ToString::to_string)
|
||||||
|
.or_else(|| Some("Unknown error".to_string()))
|
||||||
|
.unwrap()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
RemoteAccessError::FetchErrorWS(error) => write!(
|
||||||
f,
|
f,
|
||||||
"{}: {}",
|
"{}: {}",
|
||||||
error,
|
error,
|
||||||
@ -38,20 +58,29 @@ impl Display for RemoteAccessError {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
),
|
),
|
||||||
RemoteAccessError::ParsingError(parse_error) => {
|
RemoteAccessError::ParsingError(parse_error) => {
|
||||||
write!(f, "{}", parse_error)
|
write!(f, "{parse_error}")
|
||||||
}
|
}
|
||||||
RemoteAccessError::InvalidEndpoint => write!(f, "invalid drop endpoint"),
|
RemoteAccessError::InvalidEndpoint => write!(f, "invalid drop endpoint"),
|
||||||
RemoteAccessError::HandshakeFailed(message) => write!(f, "failed to complete handshake: {}", message),
|
RemoteAccessError::HandshakeFailed(message) => {
|
||||||
RemoteAccessError::GameNotFound => write!(f, "could not find game on server"),
|
write!(f, "failed to complete handshake: {message}")
|
||||||
RemoteAccessError::InvalidResponse(error) => write!(f, "server returned an invalid response: {} {}", error.status_code, error.status_message),
|
}
|
||||||
RemoteAccessError::InvalidRedirect => write!(f, "server redirect was invalid"),
|
RemoteAccessError::GameNotFound(id) => write!(f, "could not find game on server: {id}"),
|
||||||
RemoteAccessError::ManifestDownloadFailed(status, response) => write!(
|
RemoteAccessError::InvalidResponse(error) => write!(
|
||||||
f,
|
f,
|
||||||
"failed to download game manifest: {} {}",
|
"server returned an invalid response: {}, {}",
|
||||||
status, response
|
error.status_code, error.status_message
|
||||||
),
|
),
|
||||||
RemoteAccessError::OutOfSync => write!(f, "server's and client's time are out of sync. Please ensure they are within at least 30 seconds of each other"),
|
RemoteAccessError::UnparseableResponse(error) => {
|
||||||
RemoteAccessError::Generic(message) => write!(f, "{}", message),
|
write!(f, "server returned an invalid response: {error}")
|
||||||
|
}
|
||||||
|
RemoteAccessError::ManifestDownloadFailed(status, response) => {
|
||||||
|
write!(f, "failed to download game manifest: {status} {response}")
|
||||||
|
}
|
||||||
|
RemoteAccessError::OutOfSync => write!(
|
||||||
|
f,
|
||||||
|
"server's and client's time are out of sync. Please ensure they are within at least 30 seconds of each other"
|
||||||
|
),
|
||||||
|
RemoteAccessError::Cache(error) => write!(f, "Cache Error: {error}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,6 +90,11 @@ impl From<reqwest::Error> for RemoteAccessError {
|
|||||||
RemoteAccessError::FetchError(Arc::new(err))
|
RemoteAccessError::FetchError(Arc::new(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl From<reqwest_websocket::Error> for RemoteAccessError {
|
||||||
|
fn from(err: reqwest_websocket::Error) -> Self {
|
||||||
|
RemoteAccessError::FetchErrorWS(Arc::new(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
impl From<ParseError> for RemoteAccessError {
|
impl From<ParseError> for RemoteAccessError {
|
||||||
fn from(err: ParseError) -> Self {
|
fn from(err: ParseError) -> Self {
|
||||||
RemoteAccessError::ParsingError(err)
|
RemoteAccessError::ParsingError(err)
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
use std::fmt::{Display, Formatter};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub enum SetupError {
|
|
||||||
Context,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for SetupError {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
SetupError::Context => write!(f, "failed to generate contexts for download"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
23
src-tauri/src/games/collections/collection.rs
Normal file
23
src-tauri/src/games/collections/collection.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::games::library::Game;
|
||||||
|
|
||||||
|
pub type Collections = Vec<Collection>;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Collection {
|
||||||
|
id: String,
|
||||||
|
name: String,
|
||||||
|
is_default: bool,
|
||||||
|
user_id: String,
|
||||||
|
entries: Vec<CollectionObject>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct CollectionObject {
|
||||||
|
collection_id: String,
|
||||||
|
game_id: String,
|
||||||
|
game: Game,
|
||||||
|
}
|
||||||
109
src-tauri/src/games/collections/commands.rs
Normal file
109
src-tauri/src/games/collections/commands.rs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
use serde_json::json;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
DB,
|
||||||
|
database::db::DatabaseImpls,
|
||||||
|
error::remote_access_error::RemoteAccessError,
|
||||||
|
remote::{auth::generate_authorization_header, requests::make_request, utils::DROP_CLIENT_SYNC},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::collection::{Collection, Collections};
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn fetch_collections() -> Result<Collections, RemoteAccessError> {
|
||||||
|
let client = DROP_CLIENT_SYNC.clone();
|
||||||
|
let response = make_request(&client, &["/api/v1/client/collection"], &[], |r| {
|
||||||
|
r.header("Authorization", generate_authorization_header())
|
||||||
|
})?
|
||||||
|
.send()?;
|
||||||
|
|
||||||
|
Ok(response.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn fetch_collection(collection_id: String) -> Result<Collection, RemoteAccessError> {
|
||||||
|
let client = DROP_CLIENT_SYNC.clone();
|
||||||
|
let response = make_request(
|
||||||
|
&client,
|
||||||
|
&["/api/v1/client/collection/", &collection_id],
|
||||||
|
&[],
|
||||||
|
|r| r.header("Authorization", generate_authorization_header()),
|
||||||
|
)?
|
||||||
|
.send()?;
|
||||||
|
|
||||||
|
Ok(response.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn create_collection(name: String) -> Result<Collection, RemoteAccessError> {
|
||||||
|
let client = DROP_CLIENT_SYNC.clone();
|
||||||
|
let base_url = DB.fetch_base_url();
|
||||||
|
|
||||||
|
let base_url = Url::parse(&format!("{base_url}api/v1/client/collection/"))?;
|
||||||
|
|
||||||
|
let response = client
|
||||||
|
.post(base_url)
|
||||||
|
.header("Authorization", generate_authorization_header())
|
||||||
|
.json(&json!({"name": name}))
|
||||||
|
.send()?;
|
||||||
|
|
||||||
|
Ok(response.json()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn add_game_to_collection(
|
||||||
|
collection_id: String,
|
||||||
|
game_id: String,
|
||||||
|
) -> Result<(), RemoteAccessError> {
|
||||||
|
let client = DROP_CLIENT_SYNC.clone();
|
||||||
|
let url = Url::parse(&format!(
|
||||||
|
"{}api/v1/client/collection/{}/entry/",
|
||||||
|
DB.fetch_base_url(),
|
||||||
|
collection_id
|
||||||
|
))?;
|
||||||
|
|
||||||
|
client
|
||||||
|
.post(url)
|
||||||
|
.header("Authorization", generate_authorization_header())
|
||||||
|
.json(&json!({"id": game_id}))
|
||||||
|
.send()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn delete_collection(collection_id: String) -> Result<bool, RemoteAccessError> {
|
||||||
|
let client = DROP_CLIENT_SYNC.clone();
|
||||||
|
let base_url = Url::parse(&format!(
|
||||||
|
"{}api/v1/client/collection/{}",
|
||||||
|
DB.fetch_base_url(),
|
||||||
|
collection_id
|
||||||
|
))?;
|
||||||
|
|
||||||
|
let response = client
|
||||||
|
.delete(base_url)
|
||||||
|
.header("Authorization", generate_authorization_header())
|
||||||
|
.send()?;
|
||||||
|
|
||||||
|
Ok(response.json()?)
|
||||||
|
}
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn delete_game_in_collection(
|
||||||
|
collection_id: String,
|
||||||
|
game_id: String,
|
||||||
|
) -> Result<(), RemoteAccessError> {
|
||||||
|
let client = DROP_CLIENT_SYNC.clone();
|
||||||
|
let base_url = Url::parse(&format!(
|
||||||
|
"{}api/v1/client/collection/{}/entry",
|
||||||
|
DB.fetch_base_url(),
|
||||||
|
collection_id
|
||||||
|
))?;
|
||||||
|
|
||||||
|
client
|
||||||
|
.delete(base_url)
|
||||||
|
.header("Authorization", generate_authorization_header())
|
||||||
|
.json(&json!({"id": game_id}))
|
||||||
|
.send()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
2
src-tauri/src/games/collections/mod.rs
Normal file
2
src-tauri/src/games/collections/mod.rs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pub mod collection;
|
||||||
|
pub mod commands;
|
||||||
@ -3,33 +3,57 @@ use std::sync::Mutex;
|
|||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::db::GameVersion, error::{library_error::LibraryError, remote_access_error::RemoteAccessError}, games::library::{get_current_meta, uninstall_game_logic}, AppState
|
AppState,
|
||||||
|
database::{
|
||||||
|
db::borrow_db_checked,
|
||||||
|
models::data::GameVersion,
|
||||||
|
},
|
||||||
|
error::{library_error::LibraryError, remote_access_error::RemoteAccessError},
|
||||||
|
games::library::{
|
||||||
|
fetch_game_logic_offline, fetch_library_logic_offline, get_current_meta,
|
||||||
|
uninstall_game_logic,
|
||||||
|
},
|
||||||
|
offline,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
library::{
|
library::{
|
||||||
fetch_game_logic, fetch_game_verion_options_logic, fetch_library_logic, FetchGameStruct,
|
FetchGameStruct, Game, fetch_game_logic, fetch_game_verion_options_logic,
|
||||||
Game,
|
fetch_library_logic,
|
||||||
},
|
},
|
||||||
state::{GameStatusManager, GameStatusWithTransient},
|
state::{GameStatusManager, GameStatusWithTransient},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_library(app: AppHandle) -> Result<Vec<Game>, RemoteAccessError> {
|
pub fn fetch_library(
|
||||||
fetch_library_logic(app)
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
|
) -> Result<Vec<Game>, RemoteAccessError> {
|
||||||
|
offline!(
|
||||||
|
state,
|
||||||
|
fetch_library_logic,
|
||||||
|
fetch_library_logic_offline,
|
||||||
|
state
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_game(
|
pub fn fetch_game(
|
||||||
game_id: String,
|
game_id: String,
|
||||||
app: tauri::AppHandle,
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
) -> Result<FetchGameStruct, RemoteAccessError> {
|
) -> Result<FetchGameStruct, RemoteAccessError> {
|
||||||
fetch_game_logic(game_id, app)
|
offline!(
|
||||||
|
state,
|
||||||
|
fetch_game_logic,
|
||||||
|
fetch_game_logic_offline,
|
||||||
|
game_id,
|
||||||
|
state
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_game_status(id: String) -> GameStatusWithTransient {
|
pub fn fetch_game_status(id: String) -> GameStatusWithTransient {
|
||||||
GameStatusManager::fetch_state(&id)
|
let db_handle = borrow_db_checked();
|
||||||
|
GameStatusManager::fetch_state(&id, &db_handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -38,7 +62,6 @@ pub fn uninstall_game(game_id: String, app_handle: AppHandle) -> Result<(), Libr
|
|||||||
Some(data) => data,
|
Some(data) => data,
|
||||||
None => return Err(LibraryError::MetaNotFound(game_id)),
|
None => return Err(LibraryError::MetaNotFound(game_id)),
|
||||||
};
|
};
|
||||||
println!("{:?}", meta);
|
|
||||||
uninstall_game_logic(meta, &app_handle);
|
uninstall_game_logic(meta, &app_handle);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::{
|
||||||
|
path::PathBuf,
|
||||||
|
sync::{Arc, Mutex},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
database::{db::borrow_db_checked, models::data::GameDownloadStatus},
|
||||||
download_manager::{
|
download_manager::{
|
||||||
download_manager::DownloadManagerSignal, downloadable::Downloadable,
|
download_manager_frontend::DownloadManagerSignal, downloadable::Downloadable,
|
||||||
internal_error::InternalError,
|
|
||||||
},
|
},
|
||||||
|
error::download_manager_error::DownloadManagerError,
|
||||||
AppState,
|
AppState,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -16,9 +20,9 @@ pub fn download_game(
|
|||||||
game_version: String,
|
game_version: String,
|
||||||
install_dir: usize,
|
install_dir: usize,
|
||||||
state: tauri::State<'_, Mutex<AppState>>,
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
) -> Result<(), InternalError<DownloadManagerSignal>> {
|
) -> Result<(), DownloadManagerError<DownloadManagerSignal>> {
|
||||||
let sender = state.lock().unwrap().download_manager.get_sender();
|
let sender = state.lock().unwrap().download_manager.get_sender();
|
||||||
let game_download_agent = Arc::new(Box::new(GameDownloadAgent::new(
|
let game_download_agent = Arc::new(Box::new(GameDownloadAgent::new_from_index(
|
||||||
game_id,
|
game_id,
|
||||||
game_version,
|
game_version,
|
||||||
install_dir,
|
install_dir,
|
||||||
@ -30,3 +34,39 @@ pub fn download_game(
|
|||||||
.download_manager
|
.download_manager
|
||||||
.queue_download(game_download_agent)?)
|
.queue_download(game_download_agent)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn resume_download(
|
||||||
|
game_id: String,
|
||||||
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
|
) -> Result<(), DownloadManagerError<DownloadManagerSignal>> {
|
||||||
|
let s = borrow_db_checked()
|
||||||
|
.applications
|
||||||
|
.game_statuses
|
||||||
|
.get(&game_id)
|
||||||
|
.unwrap()
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
let (version_name, install_dir) = match s {
|
||||||
|
GameDownloadStatus::Remote {} => unreachable!(),
|
||||||
|
GameDownloadStatus::SetupRequired { .. } => unreachable!(),
|
||||||
|
GameDownloadStatus::Installed { .. } => unreachable!(),
|
||||||
|
GameDownloadStatus::PartiallyInstalled {
|
||||||
|
version_name,
|
||||||
|
install_dir,
|
||||||
|
} => (version_name, install_dir),
|
||||||
|
};
|
||||||
|
let sender = state.lock().unwrap().download_manager.get_sender();
|
||||||
|
let parent_dir: PathBuf = install_dir.into();
|
||||||
|
let game_download_agent = Arc::new(Box::new(GameDownloadAgent::new(
|
||||||
|
game_id,
|
||||||
|
version_name.clone(),
|
||||||
|
parent_dir.parent().unwrap().to_path_buf(),
|
||||||
|
sender,
|
||||||
|
)) as Box<dyn Downloadable + Send + Sync>);
|
||||||
|
Ok(state
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.download_manager
|
||||||
|
.queue_download(game_download_agent)?)
|
||||||
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user