Skip to content

Commit

Permalink
fix dir for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
cangzhang committed Jan 17, 2024
1 parent 2d51dc2 commit cd8ad39
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 43 deletions.
1 change: 1 addition & 0 deletions assets/star.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions crates/lcu/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lazy_static! {
static ref REGION_REGEXP: regex::Regex = regex::Regex::new(r"--region=\S+").unwrap();
static ref DIR_REGEXP: regex::Regex =
regex::Regex::new(r#"--install-directory=(.*?)""#).unwrap();
static ref MAC_DIR_REGEXP: regex::Regex = regex::Regex::new(r"--install-directory=([^\s]+).*?--").unwrap();
}

pub fn make_auth_url(token: &String, port: &String) -> String {
Expand Down Expand Up @@ -89,6 +90,7 @@ pub fn get_commandline() -> CommandLineOutput {
let mut auth_url = String::new();
let mut token = String::new();
let mut port = String::new();
let mut dir = String::new();
let mut is_tencent = false;
{
let stdout = cmd.stdout.as_mut().unwrap();
Expand All @@ -106,6 +108,11 @@ pub fn get_commandline() -> CommandLineOutput {
port,
..
} = match_stdout(&s);
dir = if let Some(dir_match) = MAC_DIR_REGEXP.find(&s) {
dir_match.as_str().replace(DIR_KEY, "").replace(" --", "")
} else {
"".to_string()
};
break;
}
}
Expand All @@ -122,6 +129,7 @@ pub fn get_commandline() -> CommandLineOutput {
is_tencent,
token,
port,
dir,
..Default::default()
}
}
Expand Down
28 changes: 0 additions & 28 deletions crates/lcu/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,3 @@ pub struct SourceItem {
#[serde(rename(serialize = "isUrf", deserialize = "isURF"))]
pub is_urf: Option<bool>,
}

const SR_ICON: &[u8] = include_bytes!("../../../assets/sr.png");
const ARAM_ICON: &[u8] = include_bytes!("../../../assets/aram.png");
const URF_ICON: &[u8] = include_bytes!("../../../assets/urf.png");

impl SourceItem {
pub fn get_mode_text(s: &Self) -> &'static str {
if let Some(true) = s.is_aram {
return "ARAM";
}
if let Some(true) = s.is_urf {
return "URF";
}

"SR"
}

pub fn get_mode_icon(s: &Self) -> &'static [u8] {
if let Some(true) = s.is_aram {
return ARAM_ICON;
}
if let Some(true) = s.is_urf {
return URF_ICON;
}

SR_ICON
}
}
38 changes: 23 additions & 15 deletions crates/source_gui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ impl eframe::App for SourceWindow {
self.show_rune_viewport.store(true, Ordering::Relaxed);
}

if self
.show_rune_viewport
.load(Ordering::Relaxed)
{
if self.show_rune_viewport.load(Ordering::Relaxed) {
let rune_ui_state = self.rune_ui_state.clone();
let show_rune_viewport = self.show_rune_viewport.clone();
let lcu_auth = self.lcu_auth.clone();
Expand Down Expand Up @@ -158,10 +155,12 @@ impl eframe::App for SourceWindow {
}
}

if item.is_aram.unwrap_or_default() {
if item.value.ends_with("aram")
|| item.value.starts_with("murderbridge")
{
ui.image(egui::include_image!("../../../assets/aram.png"))
.on_hover_text("All Random All Mid");
} else if item.is_urf.unwrap_or_default() {
} else if item.value.ends_with("urf") {
ui.image(egui::include_image!("../../../assets/urf.png"))
.on_hover_text("Ultra Rapid Fire");
} else {
Expand Down Expand Up @@ -205,11 +204,14 @@ impl eframe::App for SourceWindow {
}
});

let random_mode = self.random_mode.clone();
ui.horizontal(|ui| {
ui.label("Random mode");
toogle_ui::make_toggle(ui, &mut random_mode.lock().unwrap());
});
#[cfg(debug_assertions)]
{
let random_mode = self.random_mode.clone();
ui.horizontal(|ui| {
ui.label("Random mode");
toogle_ui::make_toggle(ui, &mut random_mode.lock().unwrap());
});
}
} else {
ui.horizontal(|ui| {
ui.label("Is League client running?");
Expand All @@ -222,7 +224,15 @@ impl eframe::App for SourceWindow {
ui.add_space(8.);
ui.vertical_centered(|ui| {
ui.hyperlink("https://github.com/cangzhang/champ-r");
ui.label("If you like it, please star ⭐ on GitHub");
ui.spacing();
ui.horizontal_top(|ui| {
ui.label("If you like it, please star");
ui.add(
egui::Image::new(egui::include_image!("../../../assets/star.svg"))
.fit_to_exact_size(egui::vec2(16., 16.)),
);
ui.label("on GitHub");
});
});
ui.add_space(8.);
});
Expand All @@ -235,9 +245,7 @@ pub fn setup_custom_fonts(ctx: &egui::Context) {

fonts.font_data.insert(
"Inter-Regular".to_owned(),
egui::FontData::from_static(include_bytes!(
"../../../assets/fonts/Inter-Regular.ttf"
)),
egui::FontData::from_static(include_bytes!("../../../assets/fonts/Inter-Regular.ttf")),
);

// Put font first (highest priority) for proportional text:
Expand Down

0 comments on commit cd8ad39

Please sign in to comment.