You've already forked AstralRinth
forked from didirus/AstralRinth
Merge commit '81ec068747a39e927c42273011252daaa58f1e14' into feature-clean
This commit is contained in:
33
apps/app/src/api/friends.rs
Normal file
33
apps/app/src/api/friends.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use tauri::plugin::TauriPlugin;
|
||||
use theseus::prelude::{UserFriend, UserStatus};
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("friends")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
friends,
|
||||
friend_statuses,
|
||||
add_friend,
|
||||
remove_friend
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn friends() -> crate::api::Result<Vec<UserFriend>> {
|
||||
Ok(theseus::friends::friends().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn friend_statuses() -> crate::api::Result<Vec<UserStatus>> {
|
||||
Ok(theseus::friends::friend_statuses().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn add_friend(user_id: &str) -> crate::api::Result<()> {
|
||||
Ok(theseus::friends::add_friend(user_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn remove_friend(user_id: &str) -> crate::api::Result<()> {
|
||||
Ok(theseus::friends::remove_friend(user_id).await?)
|
||||
}
|
||||
@@ -17,6 +17,7 @@ pub mod tags;
|
||||
pub mod utils;
|
||||
|
||||
pub mod cache;
|
||||
pub mod friends;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, TheseusSerializableError>;
|
||||
|
||||
|
||||
@@ -282,19 +282,59 @@ pub struct EditProfile {
|
||||
|
||||
pub game_version: Option<String>,
|
||||
pub loader: Option<ModLoader>,
|
||||
pub loader_version: Option<String>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
pub loader_version: Option<Option<String>>,
|
||||
|
||||
pub groups: Option<Vec<String>>,
|
||||
|
||||
pub linked_data: Option<LinkedData>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
pub linked_data: Option<Option<LinkedData>>,
|
||||
|
||||
pub java_path: Option<String>,
|
||||
pub extra_launch_args: Option<Vec<String>>,
|
||||
pub custom_env_vars: Option<Vec<(String, String)>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
pub java_path: Option<Option<String>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
pub extra_launch_args: Option<Option<Vec<String>>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
pub custom_env_vars: Option<Option<Vec<(String, String)>>>,
|
||||
|
||||
pub memory: Option<MemorySettings>,
|
||||
pub force_fullscreen: Option<bool>,
|
||||
pub game_resolution: Option<WindowSize>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
pub memory: Option<Option<MemorySettings>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
pub force_fullscreen: Option<Option<bool>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
pub game_resolution: Option<Option<WindowSize>>,
|
||||
pub hooks: Option<Hooks>,
|
||||
}
|
||||
|
||||
@@ -312,28 +352,40 @@ pub async fn profile_edit(path: &str, edit_profile: EditProfile) -> Result<()> {
|
||||
if let Some(loader) = edit_profile.loader {
|
||||
prof.loader = loader;
|
||||
}
|
||||
prof.loader_version.clone_from(&edit_profile.loader_version);
|
||||
prof.linked_data.clone_from(&edit_profile.linked_data);
|
||||
|
||||
if let Some(loader_version) = edit_profile.loader_version.clone() {
|
||||
prof.loader_version = loader_version;
|
||||
}
|
||||
if let Some(linked_data) = edit_profile.linked_data.clone() {
|
||||
prof.linked_data = linked_data;
|
||||
}
|
||||
if let Some(groups) = edit_profile.groups.clone() {
|
||||
prof.groups = groups;
|
||||
}
|
||||
|
||||
prof.java_path.clone_from(&edit_profile.java_path);
|
||||
prof.memory = edit_profile.memory;
|
||||
prof.game_resolution = edit_profile.game_resolution;
|
||||
prof.force_fullscreen = edit_profile.force_fullscreen;
|
||||
|
||||
if let Some(java_path) = edit_profile.java_path.clone() {
|
||||
prof.java_path = java_path;
|
||||
}
|
||||
if let Some(memory) = edit_profile.memory {
|
||||
prof.memory = memory;
|
||||
}
|
||||
if let Some(game_resolution) = edit_profile.game_resolution {
|
||||
prof.game_resolution = game_resolution;
|
||||
}
|
||||
if let Some(force_fullscreen) = edit_profile.force_fullscreen {
|
||||
prof.force_fullscreen = force_fullscreen;
|
||||
}
|
||||
if let Some(hooks) = edit_profile.hooks.clone() {
|
||||
prof.hooks = hooks;
|
||||
}
|
||||
|
||||
prof.modified = chrono::Utc::now();
|
||||
|
||||
prof.custom_env_vars
|
||||
.clone_from(&edit_profile.custom_env_vars);
|
||||
prof.extra_launch_args
|
||||
.clone_from(&edit_profile.extra_launch_args);
|
||||
if let Some(custom_env_vars) = edit_profile.custom_env_vars.clone() {
|
||||
prof.custom_env_vars = custom_env_vars;
|
||||
}
|
||||
if let Some(extra_launch_args) = edit_profile.extra_launch_args.clone()
|
||||
{
|
||||
prof.extra_launch_args = extra_launch_args;
|
||||
}
|
||||
|
||||
async { Ok(()) }
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ use tauri::{
|
||||
}; // 0.8
|
||||
|
||||
const WINDOW_CONTROL_PAD_X: f64 = 9.0;
|
||||
const WINDOW_CONTROL_PAD_Y: f64 = 16.0;
|
||||
const WINDOW_CONTROL_PAD_Y: f64 = 10.0;
|
||||
|
||||
struct UnsafeWindowHandle(*mut std::ffi::c_void);
|
||||
unsafe impl Send for UnsafeWindowHandle {}
|
||||
@@ -42,7 +42,7 @@ fn position_traffic_lights(
|
||||
let title_bar_container_view = close.superview().superview();
|
||||
|
||||
let close_rect: NSRect = msg_send![close, frame];
|
||||
let button_height = close_rect.size.height;
|
||||
let button_height = close_rect.size.height + 12.0;
|
||||
|
||||
let title_bar_frame_height = button_height + y;
|
||||
let mut title_bar_rect = NSView::frame(title_bar_container_view);
|
||||
@@ -58,7 +58,7 @@ fn position_traffic_lights(
|
||||
|
||||
for (i, button) in window_buttons.into_iter().enumerate() {
|
||||
let mut rect: NSRect = NSView::frame(button);
|
||||
rect.origin.x = x + (i as f64 * space_between);
|
||||
rect.origin.x = x + (i as f64 * space_between) + 6.0;
|
||||
button.setFrameOrigin(rect.origin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ extern crate objc;
|
||||
#[tracing::instrument(skip_all)]
|
||||
#[tauri::command]
|
||||
async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
tracing::info!("Initializing app event state...");
|
||||
theseus::EventState::init(app.clone()).await?;
|
||||
|
||||
// #[cfg(feature = "updater")]
|
||||
@@ -35,7 +36,8 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
|
||||
// let update_fut = updater.check();
|
||||
|
||||
// State::init().await?;
|
||||
// tracing::info!("Initializing app state...");
|
||||
State::init().await?;
|
||||
|
||||
// let check_bar = theseus::init_loading(
|
||||
// theseus::LoadingBarType::CheckingForUpdates,
|
||||
@@ -44,7 +46,8 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
// )
|
||||
// .await?;
|
||||
|
||||
// let update = update_fut.await;
|
||||
// tracing::info!("Checking for updates...");
|
||||
// let update = update_fut.await;
|
||||
|
||||
// drop(check_bar);
|
||||
|
||||
@@ -88,6 +91,7 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
State::init().await?;
|
||||
}
|
||||
|
||||
tracing::info!("Finished checking for updates!");
|
||||
let state = State::get().await?;
|
||||
app.asset_protocol_scope()
|
||||
.allow_directory(state.directories.caches_dir(), true)?;
|
||||
@@ -185,7 +189,7 @@ fn main() {
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_deep_link::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(
|
||||
tauri_plugin_window_state::Builder::default()
|
||||
.with_filename(
|
||||
@@ -244,12 +248,9 @@ fn main() {
|
||||
dbg!(url);
|
||||
});
|
||||
|
||||
if let Some(window) = app.get_window("main") {
|
||||
// Hide window to prevent white flash on startup
|
||||
let _ = window.hide();
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
if let Some(window) = app.get_window("main") {
|
||||
window.set_shadow(true).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -272,6 +273,7 @@ fn main() {
|
||||
.plugin(api::tags::init())
|
||||
.plugin(api::utils::init())
|
||||
.plugin(api::cache::init())
|
||||
.plugin(api::friends::init())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
initialize_state,
|
||||
is_dev,
|
||||
@@ -285,6 +287,7 @@ fn main() {
|
||||
builder = builder.plugin(macos::window_ext::init());
|
||||
}
|
||||
|
||||
tracing::info!("Initializing app...");
|
||||
let app = builder.build(tauri::generate_context!());
|
||||
|
||||
match app {
|
||||
@@ -346,6 +349,7 @@ fn main() {
|
||||
.show_alert()
|
||||
.unwrap();
|
||||
|
||||
tracing::error!("Error while running tauri application: {:?}", e);
|
||||
panic!("{1}: {:?}", e, "error while running tauri application")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user