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]
|
[dependencies]
|
||||||
directories = "6.0.0"
|
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"
|
image = "0.25.6"
|
||||||
serde = { version = "1.0.219", features = ["serde_derive"] }
|
serde = { version = "1.0.219", features = ["serde_derive"] }
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
|
@ -14,7 +14,7 @@ iced_video_player = {path = "./iced_video_player"}
|
||||||
url = "2.5.4"
|
url = "2.5.4"
|
||||||
strum = "0.27.1"
|
strum = "0.27.1"
|
||||||
strum_macros = "0.27.1"
|
strum_macros = "0.27.1"
|
||||||
reqwest = { version = "0.12.15", features = [
|
reqwest = { version = "0.12.22", features = [
|
||||||
# "blocking",
|
# "blocking",
|
||||||
"gzip",
|
"gzip",
|
||||||
"json"] }
|
"json"] }
|
||||||
|
|
|
@ -8,6 +8,8 @@ use reqwest::Client;
|
||||||
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT_ENCODING};
|
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT_ENCODING};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::{ORGANIZATION, PRODUCT};
|
||||||
|
|
||||||
const KURO_BASE_URL: &str = "https://prod-alicdn-gamestarter.kurogame.com/launcher/launcher/50004_obOHXFrFanqsaIEOmuKroCcbZkQRBC7c/G153";
|
const KURO_BASE_URL: &str = "https://prod-alicdn-gamestarter.kurogame.com/launcher/launcher/50004_obOHXFrFanqsaIEOmuKroCcbZkQRBC7c/G153";
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
@ -65,7 +67,7 @@ struct HoyoLauncherInformation {
|
||||||
|
|
||||||
pub async fn refresh_install() -> Result<(), String> {
|
pub async fn refresh_install() -> Result<(), String> {
|
||||||
let reqwest_client = build_client()?;
|
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())?;
|
.ok_or_else(|| "Failed to get project directories".to_string())?;
|
||||||
|
|
||||||
let (kuro_result, hoyo_result) = join!(
|
let (kuro_result, hoyo_result) = join!(
|
||||||
|
|
16
src/main.rs
16
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
|
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 {
|
trait InterfaceImage {
|
||||||
fn into_handle(self) -> image::Handle;
|
fn into_handle(self) -> image::Handle;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +187,7 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path() -> PathBuf {
|
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();
|
let path = project_dirs.data_dir();
|
||||||
|
|
||||||
path.join("launcher-state.json").to_path_buf()
|
path.join("launcher-state.json").to_path_buf()
|
||||||
|
@ -293,15 +296,18 @@ async fn empty_option() -> Option<PossibleGames> {None}
|
||||||
|
|
||||||
impl Launcher {
|
impl Launcher {
|
||||||
fn boot() -> (Self, Task<Message>) {
|
fn boot() -> (Self, Task<Message>) {
|
||||||
(Self::Loaded(
|
(
|
||||||
Box::new(State::default().load().unwrap())),
|
Self::Loaded(Box::new(State::default().load().unwrap())),
|
||||||
Task::batch([
|
{
|
||||||
Task::perform(refresh_install(), Message::RefreshInstall),
|
let refresh_task = Task::perform(refresh_install(), Message::RefreshInstall);
|
||||||
|
refresh_task.chain(Task::batch([
|
||||||
Task::perform(empty_option(), Message::GameSelected),
|
Task::perform(empty_option(), Message::GameSelected),
|
||||||
Task::perform(get_icons(), Message::LoadIcons),
|
Task::perform(get_icons(), Message::LoadIcons),
|
||||||
Task::perform(get_splashes(), Message::LoadSplashes),
|
Task::perform(get_splashes(), Message::LoadSplashes),
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn title(&self) -> String {
|
fn title(&self) -> String {
|
||||||
format!("RR Launcher v{}", env!("CARGO_PKG_VERSION"))
|
format!("RR Launcher v{}", env!("CARGO_PKG_VERSION"))
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use std::{io::Cursor, path::PathBuf};
|
use std::{fs::create_dir_all, io::Cursor, path::PathBuf};
|
||||||
|
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
use iced_video_player::Video;
|
use iced_video_player::Video;
|
||||||
use ::image::{DynamicImage, ImageReader};
|
use ::image::{DynamicImage, ImageReader};
|
||||||
use iced::{gradient, widget::container, Color};
|
use iced::{gradient, widget::container, Color};
|
||||||
|
|
||||||
use crate::{LauncherBackground, PossibleGames, VideoBackground};
|
use crate::{LauncherBackground, PossibleGames, VideoBackground, ORGANIZATION, PRODUCT};
|
||||||
|
|
||||||
use super::img_utils::round_image;
|
use super::img_utils::round_image;
|
||||||
|
|
||||||
pub fn get_game_background(game: &PossibleGames, make_video: bool) -> Result<LauncherBackground, std::io::Error> {
|
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")?;
|
let background_path = get_asset_file(&proj_dirs, game, "background")?;
|
||||||
|
|
||||||
if background_path.extension().unwrap().to_str().unwrap() == "mp4" {
|
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"),
|
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(
|
return Err(std::io::Error::new(
|
||||||
std::io::ErrorKind::NotFound,
|
std::io::ErrorKind::NotFound,
|
||||||
format!("Game directory does not exist: {:?}", game_dir)
|
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> {
|
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");
|
let file_path = get_asset_file(&proj_dirs, game, "splash");
|
||||||
|
|
||||||
if let Ok(path) = file_path {
|
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 {
|
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 {
|
let file_data: &[u8] = match game {
|
||||||
PossibleGames::WutheringWaves => include_bytes!("../../resources/wutheringwaves-icon.png"),
|
PossibleGames::WutheringWaves => include_bytes!("../../resources/wutheringwaves-icon.png"),
|
||||||
PossibleGames::ZenlessZoneZero => &std::fs::read(get_asset_file(&proj_dirs, game, "icon").unwrap()).unwrap(),
|
PossibleGames::ZenlessZoneZero => &std::fs::read(get_asset_file(&proj_dirs, game, "icon").unwrap()).unwrap(),
|
||||||
|
|
Loading…
Reference in a new issue