Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntu committed Feb 16, 2022
1 parent cf42e9d commit c33a999
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 183 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yas-lock"
version = "0.1.6"
name = "yas"
version = "1.0.1"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
181 changes: 5 additions & 176 deletions src/info/info.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::common::PixelRectBound;
use crate::info::window_info::{WINDOW_16_9, WINDOW_4_3, WINDOW_8_5};

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct ScanInfo {
// pub panel_height: u32,
// pub panel_width: u32,
Expand Down Expand Up @@ -48,188 +49,16 @@ pub struct ScanInfo {
pub pool_position: PixelRectBound,
}

fn get_scalar(value: f32, src: u32, dst: u32) -> u32 {
(value as f64 * (dst as f64) / (src as f64)).round() as u32
}

fn get_rect(
rect: (u32, u32, u32, u32),
src_h: u32,
src_w: u32,
dst_h: u32,
dst_w: u32,
) -> PixelRectBound {
let left = get_scalar(rect.0 as f32, src_w, dst_w);
let top = get_scalar(rect.1 as f32, src_h, dst_h);
let right = get_scalar(rect.2 as f32, src_w, dst_w);
let bottom = get_scalar(rect.3 as f32, src_h, dst_h);

PixelRectBound {
left: left as i32,
top: top as i32,
right: right as i32,
bottom: bottom as i32,
}
}

impl ScanInfo {
pub fn from_16_9(width: u32, height: u32, left: i32, top: i32) -> ScanInfo {
let w: u32 = 1600;
let h: u32 = 900;

let my_get_rect = |rect: (u32, u32, u32, u32)| get_rect(rect, h, w, height, width);

let info = ScanInfo {
// panel_height: get_scalar(700.0, w, width),
// panel_width: get_scalar(410.0, h, height),
title_position: my_get_rect((1099, 107, 1359, 139)),
main_stat_name_position: my_get_rect((1099, 211, 1230, 247)),
main_stat_value_position: my_get_rect((1099, 247, 1243, 290)),
level_position: my_get_rect((1104, 359, 1147, 378)),
panel_position: my_get_rect((1077, 100, 1487, 800)),

sub_stat1_position: my_get_rect((1118, 398, 1377, 426)),
sub_stat2_position: my_get_rect((1118, 431, 1377, 458)),
sub_stat3_position: my_get_rect((1118, 462, 1377, 490)),
sub_stat4_position: my_get_rect((1118, 496, 1377, 522)),

equip_position: my_get_rect((1143, 759, 1390, 791)),
art_count_position: my_get_rect((1315, 26, 1503, 51)),

art_width: get_scalar(102.5, w, width),
art_height: get_scalar(126.0, h, height),
art_gap_x: get_scalar(19.4, w, width),
art_gap_y: get_scalar(19.4, h, height),

art_row: 5,
art_col: 7,

left_margin: get_scalar(172.2, w, width),
top_margin: get_scalar(100.0, h, height),

width,
height,
left,
top,

flag_x: get_scalar(224.0, w, width),
flag_y: get_scalar(87.0, h, height),

star_x: get_scalar(1452.0, w, width),
star_y: get_scalar(124.0, h, height),

lock_x: get_scalar(1437.0, w, width),
lock_y: get_scalar(356.0, h, height),

pool_position: my_get_rect((1181, 117, 1210, 456)),
};

info
WINDOW_16_9.to_scan_info(height as f64, width as f64, left, top)
}

pub fn from_8_5(width: u32, height: u32, left: i32, top: i32) -> ScanInfo {
let w: u32 = 1440;
let h: u32 = 900;

let my_get_rect = |rect: (u32, u32, u32, u32)| get_rect(rect, h, w, height, width);

let info = ScanInfo {
// panel_height: get_scalar(700.0, w, width),
// panel_width: get_scalar(410.0, h, height),
title_position: my_get_rect((990, 95, 1240, 125)),
main_stat_name_position: my_get_rect((990, 194, 1105, 223)),
main_stat_value_position: my_get_rect((990, 223, 1105, 262)),
level_position: my_get_rect((993, 323, 1032, 340)),
panel_position: my_get_rect((969, 90, 1338, 810)),

sub_stat1_position: my_get_rect((1006, 356, 1188, 383)),
sub_stat2_position: my_get_rect((1006, 385, 1188, 411)),
sub_stat3_position: my_get_rect((1006, 413, 1188, 439)),
sub_stat4_position: my_get_rect((1006, 442, 1188, 467)),

equip_position: my_get_rect((1028, 777, 1189, 799)),
art_count_position: my_get_rect((1173, 25, 1351, 45)),

art_width: get_scalar(92.0, w, width),
art_height: get_scalar(115.0, h, height),
art_gap_x: get_scalar(17.0, w, width),
art_gap_y: get_scalar(17.0, h, height),

art_row: 6,
art_col: 7,

left_margin: get_scalar(155.0, w, width),
top_margin: get_scalar(90.0, h, height),

width,
height,
left,
top,

flag_x: get_scalar(312.0, w, width),
flag_y: get_scalar(87.0, h, height),

star_x: get_scalar(1310.0, w, width),
star_y: get_scalar(111.0, h, height),

lock_x: get_scalar(1294.0, w, width),
lock_y: get_scalar(320.0, h, height),

pool_position: my_get_rect((1081, 100, 1092, 408)),
};

info
WINDOW_8_5.to_scan_info(height as f64, width as f64, left, top)
}

pub fn from_4_3(width: u32, height: u32, left: i32, top: i32) -> ScanInfo {
let w: u32 = 1280;
let h: u32 = 960;

let my_get_rect = |rect: (u32, u32, u32, u32)| get_rect(rect, h, w, height, width);

let info = ScanInfo {
title_position: my_get_rect((880, 85, 1092, 110)),
main_stat_name_position: my_get_rect((880, 175, 984, 200)),
main_stat_value_position: my_get_rect((880, 200, 970, 233)),
level_position: my_get_rect((883, 287, 916, 303)),
panel_position: my_get_rect((862, 80, 1189, 879)),

sub_stat1_position: my_get_rect((894, 320, 1054, 339)),
sub_stat2_position: my_get_rect((894, 345, 1054, 365)),
sub_stat3_position: my_get_rect((894, 373, 1054, 392)),
sub_stat4_position: my_get_rect((894, 398, 1054, 418)),

equip_position: my_get_rect((913, 850, 1057, 870)),
art_count_position: my_get_rect((1057, 21, 1204, 41)),

art_width: get_scalar(82.0, w, width),
art_height: get_scalar(102.0, h, height),
art_gap_x: get_scalar(15.0, w, width),
art_gap_y: get_scalar(15.0, h, height),

art_row: 7,
art_col: 7,

left_margin: get_scalar(138.0, w, width),
top_margin: get_scalar(80.0, h, height),

width,
height,
left,
top,

flag_x: get_scalar(277.0, w, width),
flag_y: get_scalar(77.0, h, height),

star_x: get_scalar(1162.0, w, width),
star_y: get_scalar(100.0, h, height),

lock_x: get_scalar(1150.0, w, width),
lock_y: get_scalar(285.0, h, height),

pool_position: my_get_rect((959, 95, 974, 365)),
};

info
WINDOW_4_3.to_scan_info(height as f64, width as f64, left, top)
}
}
3 changes: 2 additions & 1 deletion src/info/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod info;
pub mod info;
pub mod window_info;
Loading

0 comments on commit c33a999

Please sign in to comment.