Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3a510eee6 |
No files matched your search
@@ -197,6 +197,27 @@ export function useOnboardingTour(
|
||||
requestAnimationFrame(updateRect)
|
||||
}
|
||||
|
||||
// Bring the current step target into view when the tour jumps to a step
|
||||
// whose target lives inside a scrollable container (e.g. the settings
|
||||
// sidebar). Without this the bubble can point at an off-screen element.
|
||||
function ensureTargetVisible() {
|
||||
const target = targetElement.value
|
||||
if (!target) return
|
||||
const rect = target.getBoundingClientRect()
|
||||
const outOfView =
|
||||
rect.top < 0 ||
|
||||
rect.left < 0 ||
|
||||
rect.bottom > window.innerHeight ||
|
||||
rect.right > window.innerWidth
|
||||
if (!outOfView) return
|
||||
target.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' })
|
||||
requestAnimationFrame(() => {
|
||||
if (targetElement.value === target) {
|
||||
targetRect.value = target.getBoundingClientRect()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goTo(destination: StepDestination) {
|
||||
if (destination === 'complete') {
|
||||
events.complete()
|
||||
@@ -343,6 +364,7 @@ export function useOnboardingTour(
|
||||
await nextTick()
|
||||
updateBubbleSize()
|
||||
updateTarget()
|
||||
ensureTargetVisible()
|
||||
})
|
||||
|
||||
watch(mode, () => {
|
||||
|
||||
@@ -324,9 +324,12 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
/// external game-directory root for the one-click StarLight install flow.
|
||||
#[tauri::command]
|
||||
fn get_launcher_root_dir() -> api::Result<String> {
|
||||
let dir = theseus::default_game_dir_root().ok_or_else(|| {
|
||||
let exe = std::env::current_exe().map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::FSError(error.to_string()))
|
||||
})?;
|
||||
let dir = exe.parent().ok_or_else(|| {
|
||||
theseus::Error::from(theseus::ErrorKind::FSError(
|
||||
"Could not determine a default game directory root".to_string(),
|
||||
"Launcher executable has no parent directory".to_string(),
|
||||
))
|
||||
})?;
|
||||
Ok(dir.to_string_lossy().into_owned())
|
||||
|
||||
@@ -39,7 +39,7 @@ pub use state::{DirectoryInfo, State};
|
||||
pub use storage::*;
|
||||
pub use util::fetch::build_proxied_client;
|
||||
pub use util::file_lock::{LockingProcess, get_locking_processes};
|
||||
pub use util::platform::{default_game_dir_root, is_process_elevated};
|
||||
pub use util::platform::is_process_elevated;
|
||||
pub use util::proxy::{ProxyConfig, ProxyMode, ProxyTestResult};
|
||||
pub use util::symlink::SymlinkCapability;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//! Platform-related code
|
||||
use daedalus::minecraft::{Os, OsRule};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// (e.g. "Run as administrator" on Windows).
|
||||
#[cfg(target_os = "windows")]
|
||||
@@ -144,31 +143,3 @@ pub fn classpath_separator(java_arch: &str) -> &'static str {
|
||||
Os::Windows | Os::WindowsArm64 => ";",
|
||||
}
|
||||
}
|
||||
|
||||
/// Root directory used as the default for one-click StarLight instance
|
||||
/// installs. Portable builds live next to their executable, which is a fine
|
||||
/// place for game data. System installs (e.g. a Linux `.deb` under `/usr/bin`)
|
||||
/// do not, so fall back to the user's home directory there.
|
||||
pub fn default_game_dir_root() -> Option<PathBuf> {
|
||||
let exe_dir = std::env::current_exe().ok()?.parent()?.to_path_buf();
|
||||
if cfg!(target_os = "linux") && is_system_install_dir(&exe_dir) {
|
||||
return dirs::home_dir();
|
||||
}
|
||||
Some(exe_dir)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn is_system_install_dir(path: &std::path::Path) -> bool {
|
||||
const SYSTEM_PREFIXES: &[&str] = &[
|
||||
"/usr/", "/opt/", "/snap/", "/bin/", "/sbin/", "/lib/", "/lib64/",
|
||||
];
|
||||
let display = path.to_string_lossy();
|
||||
SYSTEM_PREFIXES
|
||||
.iter()
|
||||
.any(|prefix| display.starts_with(prefix))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn is_system_install_dir(_path: &std::path::Path) -> bool {
|
||||
false
|
||||
}
|
||||
Reference in new issue
Block a user