Skip to content

Commit

Permalink
feat: 自动打开文件添加配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselyuki committed Dec 18, 2023
1 parent e1ac19f commit e5a2522
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ path = "src/lib.rs"
[package]
authors = ["AnselYuki"]
name = "maimai-search"
version = "0.4.3"
version = "0.4.4"
edition = "2021"
repository = "https://github.com/Anselyuki/maimai-search-rs"

Expand Down
2 changes: 2 additions & 0 deletions src/config/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct RemoteAPIConfig {
pub struct MaimaiDXProberConfig {
pub data_url: String,
pub username: Option<String>,
pub open: bool,
}

/// markdown 配置
Expand Down Expand Up @@ -143,6 +144,7 @@ impl Profile {
data_url: "https://www.diving-fish.com/api/maimaidxprober/query/player"
.to_string(),
username: None,
open: true,
},
},
markdown: MarkdownConfig {
Expand Down
16 changes: 9 additions & 7 deletions src/service/maimai_best_50.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::ops::Index;
use std::path::PathBuf;

use image::imageops::{overlay, FilterType};
use image::{DynamicImage, ImageError, ImageFormat, Pixel, Rgba, RgbaImage};
use image::imageops::{FilterType, overlay};
use imageproc::drawing::{draw_filled_rect_mut, draw_polygon_mut, draw_text_mut};
use imageproc::map::map_colors_mut;
use imageproc::point::Point;
use imageproc::rect::Rect;
use rusttype::Scale;

use crate::clients::user_data::entity::{compute_ra, ChartInfoResponse};
use crate::config::consts::{CONFIG_PATH, LAUNCH_PATH};
use crate::clients::user_data::entity::{ChartInfoResponse, compute_ra};
use crate::config::consts::{CONFIG_PATH, LAUNCH_PATH, PROFILE};
use crate::utils::file::{get_adobe_simhei_font, get_msyh_font};
use crate::utils::image::{change_column_width, get_ra_pic, string_to_half_width};

Expand Down Expand Up @@ -159,7 +159,7 @@ impl DrawBest {
for num in 0..self.dx_best.len() {
let column = 75i64
+ (ITEM_WIDTH * (num % 3 + 7) as i32 + HORIZONTAL_SPACING * (num % 3) as i32)
as i64;
as i64;
let row = 120i64
+ (ITEM_HEIGHT * (num / 3) as i32 + VERTICAL_SPACING * (num / 3) as i32) as i64;
// 3 列一行排列的 B15
Expand Down Expand Up @@ -196,7 +196,7 @@ impl DrawBest {
for num in self.dx_best.len()..self.dx_best.size {
let column = 75i64
+ (ITEM_WIDTH * (num % 3 + 7) as i32 + HORIZONTAL_SPACING * (num % 3) as i32)
as i64;
as i64;
let row = 120i64
+ (ITEM_HEIGHT * (num / 3) as i32 + VERTICAL_SPACING * (num / 3) as i32) as i64;
self.draw_item_shadow_mut(column, row);
Expand Down Expand Up @@ -321,7 +321,7 @@ impl DrawBest {
chart.ds,
compute_ra(chart.ds, chart.achievements)
)
.as_str(),
.as_str(),
);
draw_text_mut(
&mut cover,
Expand Down Expand Up @@ -459,7 +459,9 @@ impl DrawBest {

let path = LAUNCH_PATH.join(format!("{}-b50.png", self.username));
self.img.save_with_format(&path, ImageFormat::Png)?;
open::that(&path).unwrap();
if PROFILE.remote_api.maimaidxprober.open {
open::that(&path).unwrap();
}
Ok(())
}
}

0 comments on commit e5a2522

Please sign in to comment.