feat(theme): add palette system and per-element theming
This commit is contained in:
1 parent
ecc2b2bb23
commit
80210364d5
40 files changed
+2900
-1120
No files matched your search
+3
-13
@@ -41,11 +41,7 @@ pub struct FabricLibrary {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub async fn fetch_fabric_game_versions(
|
||||
client: &HttpClient,
|
||||
) -> Result<Vec<GameVersion>, NetError> {
|
||||
pub async fn fetch_fabric_game_versions(client: &HttpClient) -> Result<Vec<GameVersion>, NetError> {
|
||||
let url = format!("{}/versions/game", FABRIC_META_BASE);
|
||||
let response = match client.inner().get(&url).send().await {
|
||||
Ok(r) => r,
|
||||
@@ -161,10 +157,7 @@ pub async fn download_fabric_libraries(
|
||||
let maven_path = match crate::net::maven_coord_to_path(&lib.name) {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
tracing::error!(
|
||||
"Invalid Maven coordinate in Fabric profile: {}",
|
||||
lib.name
|
||||
);
|
||||
tracing::error!("Invalid Maven coordinate in Fabric profile: {}", lib.name);
|
||||
return Err(NetError::Parse(format!(
|
||||
"Invalid Maven coordinate: {}",
|
||||
lib.name
|
||||
@@ -188,10 +181,7 @@ pub async fn download_fabric_libraries(
|
||||
match download_file(client, &download_url, &dest, |_, _| {}).await {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
tracing::error!(
|
||||
"Failed to download Fabric library {}: {}",
|
||||
lib.name, e
|
||||
);
|
||||
tracing::error!("Failed to download Fabric library {}: {}", lib.name, e);
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -186,8 +186,6 @@ pub async fn run_forge_installer(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -198,7 +196,10 @@ mod tests {
|
||||
let client = HttpClient::new();
|
||||
match fetch_forge_versions(&client, "1.20.1").await {
|
||||
Ok(versions) => {
|
||||
assert!(!versions.is_empty(), "Should have Forge versions for 1.20.1");
|
||||
assert!(
|
||||
!versions.is_empty(),
|
||||
"Should have Forge versions for 1.20.1"
|
||||
);
|
||||
}
|
||||
Err(e) => assert!(false, "fetch_forge_versions failed: {}", e),
|
||||
}
|
||||
|
||||
+8
-3
@@ -4,8 +4,8 @@ pub mod mojang;
|
||||
pub mod neoforge;
|
||||
pub mod quilt;
|
||||
|
||||
use std::path::Path;
|
||||
use reqwest::Client;
|
||||
use std::path::Path;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
@@ -35,7 +35,9 @@ impl HttpClient {
|
||||
Ok(client) => HttpClient { inner: client },
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to build HTTP client: {}", e);
|
||||
HttpClient { inner: Client::new() }
|
||||
HttpClient {
|
||||
inner: Client::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +68,10 @@ pub async fn download_file(
|
||||
if !response.status().is_success() {
|
||||
let status = response.status().as_u16();
|
||||
tracing::error!("HTTP {} for {}", status, url);
|
||||
return Err(NetError::StatusError { status, url: url.to_string() });
|
||||
return Err(NetError::StatusError {
|
||||
status,
|
||||
url: url.to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
let total = response.content_length().unwrap_or(0);
|
||||
|
||||
+8
-3
@@ -144,9 +144,14 @@ pub async fn download_client_jar(
|
||||
|
||||
set_action(format!("Downloading Minecraft {}...", meta.id));
|
||||
|
||||
let result = download_file(client, &meta.downloads.client.url, &jar_path, |current, total| {
|
||||
set_progress(current, total);
|
||||
})
|
||||
let result = download_file(
|
||||
client,
|
||||
&meta.downloads.client.url,
|
||||
&jar_path,
|
||||
|current, total| {
|
||||
set_progress(current, total);
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
clear();
|
||||
|
||||
+2
-8
@@ -6,8 +6,7 @@ use crate::instance::loader::GameVersion;
|
||||
use crate::net::{download_file, HttpClient, NetError};
|
||||
use crate::tui::progress::set_action;
|
||||
|
||||
const NEOFORGE_MAVEN_BASE: &str =
|
||||
"https://maven.neoforged.net/releases/net/neoforged/neoforge";
|
||||
const NEOFORGE_MAVEN_BASE: &str = "https://maven.neoforged.net/releases/net/neoforged/neoforge";
|
||||
const NEOFORGE_API_BASE: &str =
|
||||
"https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge";
|
||||
|
||||
@@ -163,10 +162,7 @@ pub async fn download_neoforge_installer(
|
||||
{
|
||||
Ok(()) => Ok(()),
|
||||
Err(e) => {
|
||||
tracing::error!(
|
||||
"Failed to download NeoForge installer from {}: {}",
|
||||
url, e
|
||||
);
|
||||
tracing::error!("Failed to download NeoForge installer from {}: {}", url, e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
@@ -214,8 +210,6 @@ pub async fn run_neoforge_installer(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
+7
-14
@@ -38,11 +38,7 @@ pub struct QuiltLibrary {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub async fn fetch_quilt_game_versions(
|
||||
client: &HttpClient,
|
||||
) -> Result<Vec<GameVersion>, NetError> {
|
||||
pub async fn fetch_quilt_game_versions(client: &HttpClient) -> Result<Vec<GameVersion>, NetError> {
|
||||
let url = format!("{}/versions/game", QUILT_META_BASE);
|
||||
|
||||
let response = match client.inner().get(&url).send().await {
|
||||
@@ -159,10 +155,7 @@ pub async fn download_quilt_libraries(
|
||||
let maven_path = match crate::net::maven_coord_to_path(&lib.name) {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
tracing::error!(
|
||||
"Invalid Maven coordinate in Quilt profile: {}",
|
||||
lib.name
|
||||
);
|
||||
tracing::error!("Invalid Maven coordinate in Quilt profile: {}", lib.name);
|
||||
return Err(NetError::Parse(format!(
|
||||
"Invalid Maven coordinate: {}",
|
||||
lib.name
|
||||
@@ -186,10 +179,7 @@ pub async fn download_quilt_libraries(
|
||||
match download_file(client, &download_url, &dest, |_, _| {}).await {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
tracing::error!(
|
||||
"Failed to download Quilt library {}: {}",
|
||||
lib.name, e
|
||||
);
|
||||
tracing::error!("Failed to download Quilt library {}: {}", lib.name, e);
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
@@ -208,7 +198,10 @@ mod tests {
|
||||
let client = HttpClient::new();
|
||||
match fetch_quilt_versions(&client, "1.20.1").await {
|
||||
Ok(versions) => {
|
||||
assert!(!versions.is_empty(), "Should have Quilt versions for 1.20.1");
|
||||
assert!(
|
||||
!versions.is_empty(),
|
||||
"Should have Quilt versions for 1.20.1"
|
||||
);
|
||||
}
|
||||
Err(e) => assert!(false, "fetch_quilt_versions failed: {}", e),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user