Skip to content

Commit

Permalink
0.1.15 (#53)
Browse files Browse the repository at this point in the history
Add app version to window title.
Show notification when running some steam commands.
Better detection of owned games.
Removed button to delete Steam's cache, since it's no longer needed.
  • Loading branch information
Raicuparta authored Oct 23, 2023
2 parents f01a5e8 + c15881b commit 52f43fd
Show file tree
Hide file tree
Showing 34 changed files with 362 additions and 281 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cSpell.words": [
"ctypes",
"flashbang",
"isfreeapp",
"shellapi",
"ureq",
"winapi",
Expand Down
20 changes: 10 additions & 10 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rai-pal"
version = "0.1.14"
version = "0.1.15"
authors = ["Raicuparta"]
license = "GPL-3.0-or-later"
repository = "https://github.com/Raicuparta/rai-pal"
Expand All @@ -17,20 +17,21 @@ glob = { git = "https://github.com/rust-lang/glob", version = "0.3.1" }

# Using the git version because I need a fix that isn't on the normal version.
# Something about the way the old version parses the manifests fails for some games.
steamlocate = { git = "https://github.com/WilliamVenner/steamlocate-rs", branch = "dev-v2.0" }
# Also I made my own fork to remove some annoying prints.
steamlocate = { git = "https://github.com/Raicuparta/steamlocate-rs", branch = "dev-v2.0" }

specta = "1.0.5"
tauri-specta = { version = "1.0.2", features = ["typescript"] }
serde = { version = "1.0", features = ["derive"] }
byteorder = "1.4.3"
tauri = { version = "1.5.1", features = [ "updater", "shell-open", "dialog"] }
byteorder = "1.5.0"
tauri = { version = "1.5.2", features = [ "updater", "shell-open", "dialog"] }
reqwest = "0.11.22"
goblin = "0.7.1"
open = "5.0.0"
directories = "5.0.1"
lazy-regex = "3.0.2"
enum_dispatch = "0.3.12"
thiserror = "1.0.49"
thiserror = "1.0.50"
zip = "0.6.6"
pelite = "0.10.0"
tauri-plugin-window-state = "0.1.0"
Expand Down
24 changes: 24 additions & 0 deletions backend/src/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use tauri::Manager;

use crate::{
result::Result,
serializable_enum,
};

serializable_enum!(AppEvent {
SyncInstalledGames,
SyncOwnedGames,
SyncDiscoverGames,
SyncMods,
ExecutedSteamCommand,
});

pub trait EventEmitter {
fn emit_event(&self, event: AppEvent) -> Result;
}

impl EventEmitter for tauri::AppHandle {
fn emit_event(&self, event: AppEvent) -> Result {
Ok(self.emit_all(&event.to_string(), ())?)
}
}
40 changes: 23 additions & 17 deletions backend/src/game.rs → backend/src/installed_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ use crate::{
mod_loaders::mod_loader,
paths::{self,},
serializable_struct,
steam::appinfo::SteamLaunchOption,
steam::{
self,
appinfo::SteamLaunchOption,
},
Result,
};

serializable_struct!(Game {
serializable_struct!(InstalledGame {
pub id: String,
pub name: String,
pub discriminator: Option<String>,
Expand All @@ -29,9 +32,9 @@ serializable_struct!(Game {
pub available_mods: HashMap<String, bool>,
});

pub type Map = HashMap<String, Game>;
pub type Map = HashMap<String, InstalledGame>;

impl Game {
impl InstalledGame {
pub fn new(
id: &str,
name: &str,
Expand Down Expand Up @@ -90,32 +93,35 @@ impl Game {
Ok(open::that_detached(self.get_installed_mods_folder()?)?)
}

pub fn start(&self) -> Result {
Ok(self.steam_launch.as_ref().map_or_else(
|| open::that_detached(&self.executable.path),
pub fn start(&self, handle: &tauri::AppHandle) -> Result {
self.steam_launch.as_ref().map_or_else(
|| Ok(open::that_detached(&self.executable.path)?),
|steam_launch| {
if self.discriminator.is_none() {
// If a game has no discriminator, it means we're probably using the default launch option.
// For those, we use the steam://rungameid command, since that one will make steam show a nice
// loading popup, wait for game updates, etc.
return open::that_detached(format!(
"steam://rungameid/{}",
steam_launch.app_id
));
return steam::command::run(
&format!("rungameid/{}", steam_launch.app_id),
handle,
);
}
// For the few cases where we're showing an alternative launch option, we use the steam://launch command.
// This one will show an error if the game needs an update, and doesn't show the nice loading popup,
// but it allows us to specify the specific launch option to run.
// This one also supports passing "dialog" instead of the app_type, (steam://launch/{app_id}/dialog)
// which makes Steam show the launch selection dialogue, but that dialogue stops showing if the user
// selects the "don't ask again" checkbox.
open::that_detached(format!(
"steam://launch/{}/{}",
steam_launch.app_id,
steam_launch.app_type.as_deref().unwrap_or("")
))
steam::command::run(
&format!(
"launch/{}/{}",
steam_launch.app_id,
steam_launch.app_type.as_deref().unwrap_or("")
),
handle,
)
},
)?)
)
}

pub fn uninstall_mod(&self, mod_id: &str) -> Result {
Expand Down
9 changes: 3 additions & 6 deletions backend/src/macros/set_up_api.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#[macro_export]
macro_rules! set_up_api {
( $builder:expr, [ $($func:ident),* $(,)? ] ) => {
{
$builder.invoke_handler(tauri::generate_handler![$($func),*])
.run(tauri::generate_context!())
.unwrap_or_else(|err| println!("Failed to run Tauri application: {err}"));

(
$builder.invoke_handler(tauri::generate_handler![$($func),*]),
specta::collect_types![$($func),*]
}
)
};
}
Loading

0 comments on commit 52f43fd

Please sign in to comment.