fix steam integration
This commit is contained in:
@@ -21,7 +21,9 @@ image = "0.24"
|
||||
# Ensure "consoleapi" is in this features list
|
||||
winapi = { version = "0.3.9", features = ["winuser", "libloaderapi", "wingdi", "errhandlingapi", "consoleapi"] }
|
||||
once_cell = "1.19.0"
|
||||
steamworks = "0.10.0"
|
||||
steamworks = "0.11.0"
|
||||
parking_lot = "0.12.3"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
||||
# DO NOT REMOVE!!
|
||||
|
||||
@@ -1,3 +1,42 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
use std::{env, fs::{self, read_dir}, path::{Path, PathBuf}};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tauri_build::build();
|
||||
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
|
||||
|
||||
let profile_target_dir = out_dir
|
||||
.ancestors()
|
||||
.nth(3)
|
||||
.ok_or("Failed to determine profile target directory from OUT_DIR")?;
|
||||
|
||||
println!(
|
||||
"cargo:info=Build script running for target OS: {}",
|
||||
env::var("CARGO_CFG_TARGET_OS").unwrap_or_default()
|
||||
);
|
||||
println!(
|
||||
"cargo:info=Final libraries will be copied to: {}",
|
||||
profile_target_dir.display()
|
||||
);
|
||||
|
||||
// --- Define libraries and their source locations based on OS ---
|
||||
let target_os = env::var("CARGO_CFG_TARGET_OS")?;
|
||||
|
||||
let source_subdir = if target_os == "windows" {
|
||||
"lib/win64"
|
||||
} else if target_os == "linux" {
|
||||
"lib/linux64"
|
||||
} else if target_os == "macos" {
|
||||
"lib/osx"
|
||||
} else {
|
||||
return Err("Unsupported target".into());
|
||||
};
|
||||
|
||||
for f in read_dir(source_subdir)? {
|
||||
let f = f?;
|
||||
println!("cargo:rerun-if-changed={}", f.path().display());
|
||||
fs::copy(f.path(), profile_target_dir.join(f.file_name()))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,11 +1,18 @@
|
||||
use std::sync::Mutex;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use tauri::{Manager, AppHandle, CustomMenuItem, SystemTray, SystemTrayMenu, SystemTrayMenuItem, SystemTrayEvent, WindowEvent};
|
||||
use std::path::{Path, PathBuf};
|
||||
use integrations::steam::Steam;
|
||||
use parking_lot::Mutex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::LazyLock;
|
||||
use tauri::{
|
||||
AppHandle, CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu,
|
||||
SystemTrayMenuItem, WindowEvent,
|
||||
};
|
||||
|
||||
mod platform;
|
||||
mod integrations;
|
||||
mod platform;
|
||||
|
||||
static STEAM: LazyLock<Mutex<Steam>> = LazyLock::new(|| Mutex::new(Steam::new()));
|
||||
|
||||
// Define cursor structure
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -26,23 +33,27 @@ pub struct AppStateWrapper(Mutex<AppState>);
|
||||
// Command to get all cursors
|
||||
#[tauri::command]
|
||||
fn get_cursors(state: tauri::State<AppStateWrapper>) -> Vec<Cursor> {
|
||||
let app_state = state.0.lock().unwrap();
|
||||
let app_state = state.0.lock();
|
||||
app_state.cursors.clone()
|
||||
}
|
||||
|
||||
// Command to get current cursor index
|
||||
#[tauri::command]
|
||||
fn get_current_cursor_index(state: tauri::State<AppStateWrapper>) -> usize {
|
||||
let app_state = state.0.lock().unwrap();
|
||||
let app_state = state.0.lock();
|
||||
app_state.current_index
|
||||
}
|
||||
|
||||
// Command to select a cursor
|
||||
#[tauri::command]
|
||||
fn select_cursor(index: usize, state: tauri::State<AppStateWrapper>, app_handle: AppHandle) -> Result<(), String> {
|
||||
fn select_cursor(
|
||||
index: usize,
|
||||
state: tauri::State<AppStateWrapper>,
|
||||
app_handle: AppHandle,
|
||||
) -> Result<(), String> {
|
||||
println!("=== RESOURCE DEBUG [select_cursor] ===");
|
||||
|
||||
let mut app_state = state.0.lock().unwrap();
|
||||
let mut app_state = state.0.lock();
|
||||
if index < app_state.cursors.len() {
|
||||
app_state.current_index = index;
|
||||
|
||||
@@ -110,10 +121,13 @@ fn select_cursor(index: usize, state: tauri::State<AppStateWrapper>, app_handle:
|
||||
|
||||
// Command to go to the next cursor
|
||||
#[tauri::command]
|
||||
fn next_cursor(state: tauri::State<AppStateWrapper>, app_handle: AppHandle) -> Result<usize, String> {
|
||||
fn next_cursor(
|
||||
state: tauri::State<AppStateWrapper>,
|
||||
app_handle: AppHandle,
|
||||
) -> Result<usize, String> {
|
||||
println!("=== RESOURCE DEBUG [next_cursor] ===");
|
||||
|
||||
let mut app_state = state.0.lock().unwrap();
|
||||
let mut app_state = state.0.lock();
|
||||
if !app_state.cursors.is_empty() {
|
||||
app_state.current_index = (app_state.current_index + 1) % app_state.cursors.len();
|
||||
|
||||
@@ -175,11 +189,14 @@ fn minimize_to_tray(app_handle: AppHandle) -> Result<(), String> {
|
||||
println!("Minimizing to tray");
|
||||
|
||||
// Get the main window
|
||||
let window = app_handle.get_window("main")
|
||||
let window = app_handle
|
||||
.get_window("main")
|
||||
.ok_or_else(|| "Failed to get main window".to_string())?;
|
||||
|
||||
// Hide the window
|
||||
window.hide().map_err(|e| format!("Failed to hide window: {}", e))?;
|
||||
window
|
||||
.hide()
|
||||
.map_err(|e| format!("Failed to hide window: {}", e))?;
|
||||
|
||||
// The tray should already be visible as configured in tauri.conf.json
|
||||
println!("Window hidden, application should now be accessible from the system tray");
|
||||
@@ -206,7 +223,7 @@ fn load_cursor_files() -> Vec<Cursor> {
|
||||
|
||||
println!("CHECKING FOR PNG/CUR FILES IN MULTIPLE DIRECTORIES:");
|
||||
for (i, cursors_dir) in possible_cursor_dirs.iter().enumerate() {
|
||||
println!("Checking dir {}: {}", i+1, cursors_dir.display());
|
||||
println!("Checking dir {}: {}", i + 1, cursors_dir.display());
|
||||
println!(" Directory exists: {}", cursors_dir.exists());
|
||||
|
||||
if cursors_dir.exists() {
|
||||
@@ -217,8 +234,13 @@ fn load_cursor_files() -> Vec<Cursor> {
|
||||
let path = entry.path();
|
||||
println!(" Found: {}", path.display());
|
||||
|
||||
if path.is_file() && path.extension().map_or(false, |ext| ext == "png" || ext == "cur") {
|
||||
let name = path.file_stem()
|
||||
if path.is_file()
|
||||
&& path
|
||||
.extension()
|
||||
.map_or(false, |ext| ext == "png" || ext == "cur")
|
||||
{
|
||||
let name = path
|
||||
.file_stem()
|
||||
.and_then(|s| s.to_str())
|
||||
.unwrap_or("Unknown")
|
||||
.to_string();
|
||||
@@ -278,6 +300,9 @@ fn load_cursor_files() -> Vec<Cursor> {
|
||||
pub fn run() {
|
||||
println!("Starting Cursor Rush application");
|
||||
|
||||
// Get LazyLock to create steam
|
||||
let _ = STEAM.lock();
|
||||
|
||||
// Initialize platform-specific cursor handling
|
||||
if let Err(e) = platform::initialize() {
|
||||
eprintln!("Failed to initialize platform: {}", e);
|
||||
@@ -327,7 +352,7 @@ pub fn run() {
|
||||
eprintln!("Failed to focus window: {}", e);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to check window visibility: {}", e);
|
||||
// Try to show it anyway
|
||||
@@ -346,10 +371,11 @@ pub fn run() {
|
||||
"next_cursor" => {
|
||||
println!("Next cursor requested from tray");
|
||||
let state = app.state::<AppStateWrapper>();
|
||||
let mut app_state = state.0.lock().unwrap();
|
||||
let mut app_state = state.0.lock();
|
||||
|
||||
if !app_state.cursors.is_empty() {
|
||||
app_state.current_index = (app_state.current_index + 1) % app_state.cursors.len();
|
||||
app_state.current_index =
|
||||
(app_state.current_index + 1) % app_state.cursors.len();
|
||||
let cursor = &app_state.cursors[app_state.current_index];
|
||||
|
||||
if Path::new(&cursor.path).exists() {
|
||||
|
||||
Reference in New Issue
Block a user