push yuhko help patch fixes a few problems
This commit is contained in:
parent
182d5b255e
commit
37a4172f3c
5 changed files with 380 additions and 315 deletions
651
Cargo.lock
generated
651
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
directories = "6.0.0"
|
||||
iced = { git = "https://github.com/RabbyDevs/iced.git", features = ["tokio", "wgpu", "image"], default-features = false }
|
||||
iced = { git = "https://github.com/RabbyDevs/iced.git", features = ["tokio", "wgpu", "image", "crisp"], default-features = false }
|
||||
image = "0.25.6"
|
||||
serde = { version = "1.0.219", features = ["serde_derive"] }
|
||||
serde_json = "1.0.140"
|
||||
|
@ -14,7 +14,7 @@ iced_video_player = {path = "./iced_video_player"}
|
|||
url = "2.5.4"
|
||||
strum = "0.27.1"
|
||||
strum_macros = "0.27.1"
|
||||
reqwest = { version = "0.12.15", features = [
|
||||
reqwest = { version = "0.12.22", features = [
|
||||
# "blocking",
|
||||
"gzip",
|
||||
"json"] }
|
||||
|
|
|
@ -8,6 +8,8 @@ use reqwest::Client;
|
|||
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT_ENCODING};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{ORGANIZATION, PRODUCT};
|
||||
|
||||
const KURO_BASE_URL: &str = "https://prod-alicdn-gamestarter.kurogame.com/launcher/launcher/50004_obOHXFrFanqsaIEOmuKroCcbZkQRBC7c/G153";
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
@ -65,7 +67,7 @@ struct HoyoLauncherInformation {
|
|||
|
||||
pub async fn refresh_install() -> Result<(), String> {
|
||||
let reqwest_client = build_client()?;
|
||||
let proj_dirs = ProjectDirs::from("com", "RabbyDevs", "rr-launcher")
|
||||
let proj_dirs = ProjectDirs::from("com", ORGANIZATION, PRODUCT)
|
||||
.ok_or_else(|| "Failed to get project directories".to_string())?;
|
||||
|
||||
let (kuro_result, hoyo_result) = join!(
|
||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -17,6 +17,9 @@ use std::{
|
|||
collections::HashMap, env, fs::{self, create_dir_all, read_to_string}, io::{Cursor, Write}, path::PathBuf
|
||||
};
|
||||
|
||||
pub const ORGANIZATION: &str = "ReversedRooms";
|
||||
pub const PRODUCT: &str = "RoomsLauncher";
|
||||
|
||||
trait InterfaceImage {
|
||||
fn into_handle(self) -> image::Handle;
|
||||
}
|
||||
|
@ -184,7 +187,7 @@ impl State {
|
|||
}
|
||||
|
||||
fn path() -> PathBuf {
|
||||
let project_dirs = ProjectDirs::from("com", "RabbyDevs", "rr-launcher").unwrap();
|
||||
let project_dirs = ProjectDirs::from("com", ORGANIZATION, PRODUCT).unwrap();
|
||||
let path = project_dirs.data_dir();
|
||||
|
||||
path.join("launcher-state.json").to_path_buf()
|
||||
|
@ -293,14 +296,17 @@ async fn empty_option() -> Option<PossibleGames> {None}
|
|||
|
||||
impl Launcher {
|
||||
fn boot() -> (Self, Task<Message>) {
|
||||
(Self::Loaded(
|
||||
Box::new(State::default().load().unwrap())),
|
||||
Task::batch([
|
||||
Task::perform(refresh_install(), Message::RefreshInstall),
|
||||
Task::perform(empty_option(), Message::GameSelected),
|
||||
Task::perform(get_icons(), Message::LoadIcons),
|
||||
Task::perform(get_splashes(), Message::LoadSplashes),
|
||||
]))
|
||||
(
|
||||
Self::Loaded(Box::new(State::default().load().unwrap())),
|
||||
{
|
||||
let refresh_task = Task::perform(refresh_install(), Message::RefreshInstall);
|
||||
refresh_task.chain(Task::batch([
|
||||
Task::perform(empty_option(), Message::GameSelected),
|
||||
Task::perform(get_icons(), Message::LoadIcons),
|
||||
Task::perform(get_splashes(), Message::LoadSplashes),
|
||||
]))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
use std::{io::Cursor, path::PathBuf};
|
||||
use std::{fs::create_dir_all, io::Cursor, path::PathBuf};
|
||||
|
||||
use directories::ProjectDirs;
|
||||
use iced_video_player::Video;
|
||||
use ::image::{DynamicImage, ImageReader};
|
||||
use iced::{gradient, widget::container, Color};
|
||||
|
||||
use crate::{LauncherBackground, PossibleGames, VideoBackground};
|
||||
use crate::{LauncherBackground, PossibleGames, VideoBackground, ORGANIZATION, PRODUCT};
|
||||
|
||||
use super::img_utils::round_image;
|
||||
|
||||
pub fn get_game_background(game: &PossibleGames, make_video: bool) -> Result<LauncherBackground, std::io::Error> {
|
||||
let proj_dirs = ProjectDirs::from("com", "RabbyDevs", "rr-launcher").unwrap();
|
||||
let proj_dirs = ProjectDirs::from("com", ORGANIZATION, PRODUCT).unwrap();
|
||||
let background_path = get_asset_file(&proj_dirs, game, "background")?;
|
||||
|
||||
if background_path.extension().unwrap().to_str().unwrap() == "mp4" {
|
||||
|
@ -62,7 +62,7 @@ fn get_asset_file(proj_dirs: &ProjectDirs, game: &PossibleGames, identifier: &st
|
|||
PossibleGames::GenshinImpact => proj_dirs.data_dir().join("hoyoverse/gi"),
|
||||
};
|
||||
|
||||
if !game_dir.exists() {
|
||||
if create_dir_all(&game_dir).is_err() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
format!("Game directory does not exist: {:?}", game_dir)
|
||||
|
@ -87,7 +87,7 @@ fn get_asset_file(proj_dirs: &ProjectDirs, game: &PossibleGames, identifier: &st
|
|||
}
|
||||
|
||||
pub fn get_game_splash_dynamic_image(game: &PossibleGames) -> Option<DynamicImage> {
|
||||
let proj_dirs = ProjectDirs::from("com", "RabbyDevs", "rr-launcher").unwrap();
|
||||
let proj_dirs = ProjectDirs::from("com", ORGANIZATION, PRODUCT).unwrap();
|
||||
let file_path = get_asset_file(&proj_dirs, game, "splash");
|
||||
|
||||
if let Ok(path) = file_path {
|
||||
|
@ -102,7 +102,7 @@ pub fn get_game_splash_dynamic_image(game: &PossibleGames) -> Option<DynamicImag
|
|||
}
|
||||
|
||||
pub fn get_game_icon_dynamic_image(game: &PossibleGames) -> DynamicImage {
|
||||
let proj_dirs = ProjectDirs::from("com", "RabbyDevs", "rr-launcher").unwrap();
|
||||
let proj_dirs = ProjectDirs::from("com", ORGANIZATION, PRODUCT).unwrap();
|
||||
let file_data: &[u8] = match game {
|
||||
PossibleGames::WutheringWaves => include_bytes!("../../resources/wutheringwaves-icon.png"),
|
||||
PossibleGames::ZenlessZoneZero => &std::fs::read(get_asset_file(&proj_dirs, game, "icon").unwrap()).unwrap(),
|
||||
|
|
Loading…
Reference in a new issue