fix steam integration

This commit is contained in:
2025-05-30 19:28:34 -05:00
parent f60f058cf9
commit b31aefe896
11 changed files with 93 additions and 22 deletions
+4
View File
@@ -0,0 +1,4 @@
[workspace]
members = ["frontend/src-tauri"]
resolver = "3"
+3 -1
View File
@@ -21,7 +21,9 @@ image = "0.24"
# Ensure "consoleapi" is in this features list # Ensure "consoleapi" is in this features list
winapi = { version = "0.3.9", features = ["winuser", "libloaderapi", "wingdi", "errhandlingapi", "consoleapi"] } winapi = { version = "0.3.9", features = ["winuser", "libloaderapi", "wingdi", "errhandlingapi", "consoleapi"] }
once_cell = "1.19.0" once_cell = "1.19.0"
steamworks = "0.10.0" steamworks = "0.11.0"
parking_lot = "0.12.3"
[features] [features]
# this feature is used for production builds or when `devPath` points to the filesystem # this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!! # DO NOT REMOVE!!
+41 -2
View File
@@ -1,3 +1,42 @@
fn main() { use std::{env, fs::{self, read_dir}, path::{Path, PathBuf}};
tauri_build::build()
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.
+44 -18
View File
@@ -1,11 +1,18 @@
use std::sync::Mutex; use integrations::steam::Steam;
use serde::{Serialize, Deserialize}; use parking_lot::Mutex;
use tauri::{Manager, AppHandle, CustomMenuItem, SystemTray, SystemTrayMenu, SystemTrayMenuItem, SystemTrayEvent, WindowEvent}; use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::env; 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 integrations;
mod platform;
static STEAM: LazyLock<Mutex<Steam>> = LazyLock::new(|| Mutex::new(Steam::new()));
// Define cursor structure // Define cursor structure
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -26,23 +33,27 @@ pub struct AppStateWrapper(Mutex<AppState>);
// Command to get all cursors // Command to get all cursors
#[tauri::command] #[tauri::command]
fn get_cursors(state: tauri::State<AppStateWrapper>) -> Vec<Cursor> { 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() app_state.cursors.clone()
} }
// Command to get current cursor index // Command to get current cursor index
#[tauri::command] #[tauri::command]
fn get_current_cursor_index(state: tauri::State<AppStateWrapper>) -> usize { 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 app_state.current_index
} }
// Command to select a cursor // Command to select a cursor
#[tauri::command] #[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] ==="); 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() { if index < app_state.cursors.len() {
app_state.current_index = index; 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 // Command to go to the next cursor
#[tauri::command] #[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] ==="); 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() { 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();
@@ -175,11 +189,14 @@ fn minimize_to_tray(app_handle: AppHandle) -> Result<(), String> {
println!("Minimizing to tray"); println!("Minimizing to tray");
// Get the main window // 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())?; .ok_or_else(|| "Failed to get main window".to_string())?;
// Hide the window // 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 // The tray should already be visible as configured in tauri.conf.json
println!("Window hidden, application should now be accessible from the system tray"); println!("Window hidden, application should now be accessible from the system tray");
@@ -217,8 +234,13 @@ fn load_cursor_files() -> Vec<Cursor> {
let path = entry.path(); let path = entry.path();
println!(" Found: {}", path.display()); println!(" Found: {}", path.display());
if path.is_file() && path.extension().map_or(false, |ext| ext == "png" || ext == "cur") { if path.is_file()
let name = path.file_stem() && path
.extension()
.map_or(false, |ext| ext == "png" || ext == "cur")
{
let name = path
.file_stem()
.and_then(|s| s.to_str()) .and_then(|s| s.to_str())
.unwrap_or("Unknown") .unwrap_or("Unknown")
.to_string(); .to_string();
@@ -278,6 +300,9 @@ fn load_cursor_files() -> Vec<Cursor> {
pub fn run() { pub fn run() {
println!("Starting Cursor Rush application"); println!("Starting Cursor Rush application");
// Get LazyLock to create steam
let _ = STEAM.lock();
// Initialize platform-specific cursor handling // Initialize platform-specific cursor handling
if let Err(e) = platform::initialize() { if let Err(e) = platform::initialize() {
eprintln!("Failed to initialize platform: {}", e); eprintln!("Failed to initialize platform: {}", e);
@@ -327,7 +352,7 @@ pub fn run() {
eprintln!("Failed to focus window: {}", e); eprintln!("Failed to focus window: {}", e);
} }
} }
}, }
Err(e) => { Err(e) => {
eprintln!("Failed to check window visibility: {}", e); eprintln!("Failed to check window visibility: {}", e);
// Try to show it anyway // Try to show it anyway
@@ -346,10 +371,11 @@ pub fn run() {
"next_cursor" => { "next_cursor" => {
println!("Next cursor requested from tray"); println!("Next cursor requested from tray");
let state = app.state::<AppStateWrapper>(); 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() { 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]; let cursor = &app_state.cursors[app_state.current_index];
if Path::new(&cursor.path).exists() { if Path::new(&cursor.path).exists() {