feat: complete in-game commands, GUIs, admin panel fixes, and launcher enhancements

This commit is contained in:
scoped committed 2026-09-29 12:14:16 -04:00
1 parent a9ff92e1d1
commit 752f0cc43d
34 files changed
+4170 -181

No files matched your search

+67 -11
View File
@@ -7,9 +7,9 @@ use crate::state::{build, AppState};
use crate::updater;
use scopenet_core::ping::ServerStatus;
use scopenet_shared::{
Achievement, DirectMessage, FriendInfo, GameInvite, Guild, GuildClaim, GuildMember, GuildPost,
LauncherManifest, PlayerProfile, SkinProfile, UserLevelInfo, UserPost, UserProfileView,
UserQuest,
Achievement, BaltopEntry, DirectMessage, EconomyTransaction, FriendInfo, GameInvite, Guild,
GuildClaim, GuildMember, GuildPost, LauncherManifest, MemberProfile, PlayerProfile,
ServerEconomyBalance, SkinProfile, UserLevelInfo, UserPost, UserProfileView, UserQuest,
};
use serde::Serialize;
use tauri::{AppHandle, Manager, State};
@@ -550,14 +550,14 @@ pub async fn get_my_quests(state: State<'_, AppState>) -> Res<Vec<UserQuest>> {
}
#[tauri::command]
pub async fn claim_quest(state: State<'_, AppState>, quest_id: String) -> Res<UserQuest> {
pub async fn claim_quest(state: State<'_, AppState>, quest_id: String) -> Res<UserLevelInfo> {
let req = account_api(&state, reqwest::Method::POST, &format!("/quests/{quest_id}/claim")).await?;
let resp = req.send().await.map_err(err)?;
if !resp.status().is_success() {
let body: serde_json::Value = resp.json().await.unwrap_or_default();
return Err(body["error"].as_str().unwrap_or("unable to claim quest").to_string());
}
resp.json().await.map_err(err)
get_my_level(state).await
}
// ---------------------------------------------------------------------------
@@ -738,9 +738,14 @@ pub async fn get_friends(state: State<'_, AppState>) -> Res<Vec<FriendInfo>> {
}
#[tauri::command]
pub async fn send_friend_request(state: State<'_, AppState>, username: String) -> Res<()> {
pub async fn send_friend_request(
state: State<'_, AppState>,
friend_username: Option<String>,
username: Option<String>,
) -> Res<()> {
let target = friend_username.or(username).ok_or("username is required")?;
let req = account_api(&state, reqwest::Method::POST, "/friends/request").await?;
let resp = req.json(&serde_json::json!({ "username": username })).send().await.map_err(err)?;
let resp = req.json(&serde_json::json!({ "username": target })).send().await.map_err(err)?;
if !resp.status().is_success() {
let body: serde_json::Value = resp.json().await.unwrap_or_default();
return Err(body["error"].as_str().unwrap_or("unable to send friend request").to_string());
@@ -749,9 +754,15 @@ pub async fn send_friend_request(state: State<'_, AppState>, username: String) -
}
#[tauri::command]
pub async fn respond_friend_request(state: State<'_, AppState>, target_uuid: String, accept: bool) -> Res<()> {
pub async fn respond_friend_request(
state: State<'_, AppState>,
friend_uuid: Option<String>,
target_uuid: Option<String>,
accept: bool,
) -> Res<()> {
let target = friend_uuid.or(target_uuid).ok_or("target_uuid is required")?;
let req = account_api(&state, reqwest::Method::POST, "/friends/respond").await?;
let resp = req.json(&serde_json::json!({ "target_uuid": target_uuid, "accept": accept })).send().await.map_err(err)?;
let resp = req.json(&serde_json::json!({ "target_uuid": target, "accept": accept })).send().await.map_err(err)?;
if !resp.status().is_success() {
let body: serde_json::Value = resp.json().await.unwrap_or_default();
return Err(body["error"].as_str().unwrap_or("unable to respond to friend request").to_string());
@@ -760,8 +771,13 @@ pub async fn respond_friend_request(state: State<'_, AppState>, target_uuid: Str
}
#[tauri::command]
pub async fn remove_friend(state: State<'_, AppState>, target_uuid: String) -> Res<()> {
let req = account_api(&state, reqwest::Method::DELETE, &format!("/friends/{target_uuid}")).await?;
pub async fn remove_friend(
state: State<'_, AppState>,
friend_uuid: Option<String>,
target_uuid: Option<String>,
) -> Res<()> {
let target = friend_uuid.or(target_uuid).ok_or("target_uuid is required")?;
let req = account_api(&state, reqwest::Method::DELETE, &format!("/friends/{target}")).await?;
let resp = req.send().await.map_err(err)?;
if !resp.status().is_success() {
let body: serde_json::Value = resp.json().await.unwrap_or_default();
@@ -770,6 +786,46 @@ pub async fn remove_friend(state: State<'_, AppState>, target_uuid: String) -> R
Ok(())
}
#[tauri::command]
pub async fn search_members(state: State<'_, AppState>, query: String) -> Res<Vec<MemberProfile>> {
let req = account_api(&state, reqwest::Method::GET, &format!("/social/members?q={query}")).await?;
let resp = req.send().await.map_err(err)?;
if !resp.status().is_success() {
return Err("unable to search members".into());
}
resp.json().await.map_err(err)
}
#[tauri::command]
pub async fn get_economy_balances(state: State<'_, AppState>) -> Res<Vec<ServerEconomyBalance>> {
let req = account_api(&state, reqwest::Method::GET, "/economy/me").await?;
let resp = req.send().await.map_err(err)?;
if !resp.status().is_success() {
return Err("unable to load economy balances".into());
}
resp.json().await.map_err(err)
}
#[tauri::command]
pub async fn get_server_baltop(state: State<'_, AppState>, server_id: i64) -> Res<Vec<BaltopEntry>> {
let req = account_api(&state, reqwest::Method::GET, &format!("/servers/{server_id}/economy/baltop")).await?;
let resp = req.send().await.map_err(err)?;
if !resp.status().is_success() {
return Err("unable to load baltop leaderboard".into());
}
resp.json().await.map_err(err)
}
#[tauri::command]
pub async fn get_transactions(state: State<'_, AppState>) -> Res<Vec<EconomyTransaction>> {
let req = account_api(&state, reqwest::Method::GET, "/economy/transactions").await?;
let resp = req.send().await.map_err(err)?;
if !resp.status().is_success() {
return Err("unable to load transactions".into());
}
resp.json().await.map_err(err)
}
#[tauri::command]
pub async fn get_direct_messages(state: State<'_, AppState>, friend_uuid: String) -> Res<Vec<DirectMessage>> {
let req = account_api(&state, reqwest::Method::GET, &format!("/messages/{friend_uuid}")).await?;