Skip to content

Commit 50eb7ff

Browse files
committed
chore: Starting migrating references to database applications, auth, and base_url
Signed-off-by: quexeky <[email protected]>
1 parent a2d1a98 commit 50eb7ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+968
-623
lines changed

src-tauri/Cargo.lock

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ whoami = "1.6.0"
6565
filetime = "0.2.25"
6666
walkdir = "2.5.0"
6767
known-folders = "1.2.0"
68-
native_model = { version = "0.6.4", features = ["rmp_serde_1_3"], git = "https://github.com/Drop-OSS/native_model.git"}
68+
native_model = { version = "0.6.4", features = [
69+
"rmp_serde_1_3",
70+
], git = "https://github.com/Drop-OSS/native_model.git" }
6971
tauri-plugin-opener = "2.4.0"
7072
bitcode = "0.6.6"
7173
reqwest-websocket = "0.5.0"
@@ -149,6 +151,8 @@ members = [
149151
"cloud_saves",
150152
"download_manager",
151153
"games",
154+
"library",
155+
"drop-consts",
152156
]
153157

154-
resolver = "3"
158+
resolver = "3"

src-tauri/client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2024"
66
[dependencies]
77
bitcode = "0.6.7"
88
database = { version = "0.1.0", path = "../database" }
9+
drop-consts = { version = "0.1.0", path = "../drop-consts" }
910
log = "0.4.28"
1011
serde = { version = "1.0.228", features = ["derive"] }
1112
tauri = "2.8.5"

src-tauri/client/src/app_state.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use std::collections::HashMap;
2+
3+
use database::models::Game;
4+
use serde::Serialize;
5+
6+
use crate::{app_status::AppStatus, user::User};
7+
8+
#[derive(Clone, Serialize)]
9+
#[serde(rename_all = "camelCase")]
10+
pub struct AppState {
11+
status: AppStatus,
12+
user: Option<User>,
13+
games: HashMap<String, Game>,
14+
}
15+
impl AppState {
16+
pub fn new(status: AppStatus, user: Option<User>, games: HashMap<String, Game>) -> Self {
17+
Self {
18+
status,
19+
user,
20+
games,
21+
}
22+
}
23+
24+
pub fn status(&self) -> &AppStatus {
25+
&self.status
26+
}
27+
pub fn status_mut(&mut self) -> &mut AppStatus {
28+
&mut self.status
29+
}
30+
pub fn games(&self) -> &HashMap<String, Game> {
31+
&self.games
32+
}
33+
pub fn games_mut(&mut self) -> &mut HashMap<String, Game> {
34+
&mut self.games
35+
}
36+
pub fn user(&self) -> &Option<User> {
37+
&self.user
38+
}
39+
pub fn user_mut(&mut self) -> &mut Option<User> {
40+
&mut self.user
41+
}
42+
}

src-tauri/client/src/compat.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{
55
sync::LazyLock,
66
};
77

8+
use drop_consts::{UMU_BASE_LAUNCHER_EXECUTABLE, UMU_INSTALL_DIRS};
89
use log::info;
910

1011
pub static COMPAT_INFO: LazyLock<Option<CompatInfo>> = LazyLock::new(create_new_compat_info);
@@ -30,9 +31,6 @@ fn create_new_compat_info() -> Option<CompatInfo> {
3031
})
3132
}
3233

33-
const UMU_BASE_LAUNCHER_EXECUTABLE: &str = "umu-run";
34-
const UMU_INSTALL_DIRS: [&str; 4] = ["/app/share", "/use/local/share", "/usr/share", "/opt"];
35-
3634
fn get_umu_executable() -> Option<PathBuf> {
3735
if check_executable_exists(UMU_BASE_LAUNCHER_EXECUTABLE) {
3836
return Some(PathBuf::from(UMU_BASE_LAUNCHER_EXECUTABLE));

src-tauri/client/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
pub mod app_state;
12
pub mod app_status;
23
pub mod autostart;
34
pub mod compat;
4-
pub mod user;
5+
pub mod user;

src-tauri/cloud_saves/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2024"
66
[dependencies]
77
database = { version = "0.1.0", path = "../database" }
88
dirs = "6.0.0"
9+
drop-consts = { version = "0.1.0", path = "../drop-consts" }
910
log = "0.4.28"
1011
regex = "1.11.3"
1112
rustix = "1.1.2"

src-tauri/cloud_saves/src/backup_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{collections::HashMap, path::PathBuf, str::FromStr};
22

33
#[cfg(target_os = "linux")]
44
use database::platform::Platform;
5-
use database::{GameVersion, db::DATA_ROOT_DIR};
5+
use database::{db::DATA_ROOT_DIR, GameVersion};
66
use log::warn;
77

88
use crate::error::BackupError;

src-tauri/database/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7+
bitcode = "0.6.7"
78
chrono = "0.4.42"
89
dirs = "6.0.0"
10+
drop-consts = { version = "0.1.0", path = "../drop-consts" }
911
log = "0.4.28"
1012
native_model = { version = "0.6.4", features = ["rmp_serde_1_3"], git = "https://github.com/Drop-OSS/native_model.git"}
1113
rustbreak = "2.0.0"

src-tauri/database/src/db.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,18 @@ use std::{
33
sync::{Arc, LazyLock},
44
};
55

6+
use drop_consts::DATA_ROOT_PREFIX;
67
use rustbreak::{DeSerError, DeSerializer};
78
use serde::{Serialize, de::DeserializeOwned};
89

9-
use crate::interface::{DatabaseImpls, DatabaseInterface};
10+
use crate::{interface::DatabaseImpls, models::DatabaseInterface};
1011

1112
pub static DB: LazyLock<DatabaseInterface> = LazyLock::new(DatabaseInterface::set_up_database);
1213

13-
#[cfg(not(debug_assertions))]
14-
static DATA_ROOT_PREFIX: &str = "drop";
15-
#[cfg(debug_assertions)]
16-
static DATA_ROOT_PREFIX: &str = "drop-debug";
17-
18-
pub static DATA_ROOT_DIR: LazyLock<Arc<PathBuf>> = LazyLock::new(|| {
19-
Arc::new(
14+
pub static DATA_ROOT_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
2015
dirs::data_dir()
2116
.expect("Failed to get data dir")
22-
.join(DATA_ROOT_PREFIX),
23-
)
17+
.join(DATA_ROOT_PREFIX)
2418
});
2519

2620
// Custom JSON serializer to support everything we need

0 commit comments

Comments
 (0)