diff --git a/README.md b/README.md index 804c6ad..567e80c 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ resolution = [854, 480] [ui] image_protocol = "auto" +hidden_shortcut_hints = [] # all, main, instances, content, accounts, settings, popups [content] preferred_provider = "modrinth" @@ -158,6 +159,9 @@ preferred_provider_only = false ask_on_provider_conflict = true ``` +Use `hidden_shortcut_hints = ["main"]` to keep only popup guides, +`["all"]` to hide every guide, or list individual areas to hide them selectively. + ### logs launcher logs are per-session and contain rmcl's own output. instance launch logs capture game stdout/stderr per launch. diff --git a/assets/config.toml b/assets/config.toml index e923cc7..04ef1e5 100644 --- a/assets/config.toml +++ b/assets/config.toml @@ -24,6 +24,9 @@ resolution = [854, 480] [ui] # image protocol: auto, halfblocks, quadrants, kitty, or iterm2 image_protocol = "auto" +# [] shows all guides; ["main"] keeps popup guides; ["all"] hides every guide +# areas can also be hidden selectively: instances, content, accounts, settings, popups +hidden_shortcut_hints = [] # error popup timing (in ms) error_auto_dismiss_ms = 5000 error_slide_start_ms = 3500 diff --git a/src/config/settings.rs b/src/config/settings.rs index aca8387..623d47b 100644 --- a/src/config/settings.rs +++ b/src/config/settings.rs @@ -4,7 +4,11 @@ // all the config structs that map to sections in config.toml. // everything has sane defaults so a blank file (or no file) still works. -use std::{collections::BTreeMap, fmt, path::PathBuf}; +use std::{ + collections::{BTreeMap, BTreeSet}, + fmt, + path::PathBuf, +}; use serde::{Deserialize, Serialize}; @@ -23,6 +27,28 @@ pub enum ImageProtocol { Iterm2, } +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum ShortcutHintScope { + All, + Main, + Instances, + Content, + Accounts, + Settings, + Popups, +} + +impl ShortcutHintScope { + pub const AREAS: [Self; 5] = [ + Self::Instances, + Self::Content, + Self::Accounts, + Self::Settings, + Self::Popups, + ]; +} + impl fmt::Display for ImageProtocol { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -299,6 +325,8 @@ impl Default for Defaults { pub struct Ui { #[serde(default)] pub image_protocol: ImageProtocol, + #[serde(default)] + pub hidden_shortcut_hints: BTreeSet, #[serde(default = "default_error_auto_dismiss_ms")] pub error_auto_dismiss_ms: u64, #[serde(default = "default_error_slide_start_ms")] @@ -326,6 +354,7 @@ impl Default for Ui { fn default() -> Self { Self { image_protocol: ImageProtocol::default(), + hidden_shortcut_hints: BTreeSet::new(), error_auto_dismiss_ms: default_error_auto_dismiss_ms(), error_slide_start_ms: default_error_slide_start_ms(), error_fly_out_ms: default_error_fly_out_ms(), @@ -334,6 +363,39 @@ impl Default for Ui { } } +impl Ui { + pub fn show_shortcut_hints(&self, scope: ShortcutHintScope) -> bool { + !self.hidden_shortcut_hints.contains(&ShortcutHintScope::All) + && !(scope != ShortcutHintScope::Popups + && self + .hidden_shortcut_hints + .contains(&ShortcutHintScope::Main)) + && !self.hidden_shortcut_hints.contains(&scope) + } + + pub fn set_shortcut_hints(&mut self, scope: ShortcutHintScope, visible: bool) { + let mut hidden = ShortcutHintScope::AREAS + .into_iter() + .filter(|area| !self.show_shortcut_hints(*area)) + .collect::>(); + if visible { + hidden.remove(&scope); + } else { + hidden.insert(scope); + } + self.hidden_shortcut_hints = if hidden.len() == ShortcutHintScope::AREAS.len() { + [ShortcutHintScope::All].into_iter().collect() + } else if ShortcutHintScope::AREAS[..4] + .iter() + .all(|area| hidden.contains(area)) + { + [ShortcutHintScope::Main].into_iter().collect() + } else { + hidden + }; + } +} + #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Config { #[serde(default)] diff --git a/src/config/tests/settings.rs b/src/config/tests/settings.rs index 21f26fb..3bb0496 100644 --- a/src/config/tests/settings.rs +++ b/src/config/tests/settings.rs @@ -110,3 +110,28 @@ memory_max = "8G" assert_eq!(config.defaults.memory_max, "8G"); assert_eq!(config.defaults.memory_min, "512M"); } + +#[test] +fn shortcut_hints_support_global_main_and_selective_hiding() { + let mut ui = Ui::default(); + assert!( + ShortcutHintScope::AREAS + .iter() + .all(|scope| ui.show_shortcut_hints(*scope)) + ); + + ui.hidden_shortcut_hints = [ShortcutHintScope::Main].into_iter().collect(); + assert!(!ui.show_shortcut_hints(ShortcutHintScope::Instances)); + assert!(ui.show_shortcut_hints(ShortcutHintScope::Popups)); + + ui.set_shortcut_hints(ShortcutHintScope::Content, true); + assert!(ui.show_shortcut_hints(ShortcutHintScope::Content)); + assert!(!ui.show_shortcut_hints(ShortcutHintScope::Accounts)); + + ui.hidden_shortcut_hints = [ShortcutHintScope::All].into_iter().collect(); + assert!( + ShortcutHintScope::AREAS + .iter() + .all(|scope| !ui.show_shortcut_hints(*scope)) + ); +} diff --git a/src/tui/render.rs b/src/tui/render.rs index af74840..6218de9 100644 --- a/src/tui/render.rs +++ b/src/tui/render.rs @@ -447,15 +447,18 @@ fn render_provider_conflict(frame: &mut Frame, conflict: &super::app::ProviderCo ))) }); let mut state = ListState::default().with_selected(Some(conflict.selected)); + let mut block = Block::default() + .title(Line::from(format!(" Choose provider for {title} "))) + .borders(Borders::ALL) + .border_type(BORDER_STYLE.to_border_type()) + .border_style(Style::default().fg(theme.accent())); + if crate::tui::widgets::popups::shortcut_hints_visible( + crate::config::settings::ShortcutHintScope::Popups, + ) { + block = block.title_bottom(Line::from(" [j/k] select [Enter] use [Esc] later ")); + } let list = List::new(items) - .block( - Block::default() - .title(Line::from(format!(" Choose provider for {title} "))) - .title_bottom(Line::from(" [j/k] select [Enter] use [Esc] later ")) - .borders(Borders::ALL) - .border_type(BORDER_STYLE.to_border_type()) - .border_style(Style::default().fg(theme.accent())), - ) + .block(block) .style(Style::default().fg(theme.text()).bg(theme.surface())) .highlight_style( Style::default() diff --git a/src/tui/tests/flows.rs b/src/tui/tests/flows.rs index e631e33..44e69fb 100644 --- a/src/tui/tests/flows.rs +++ b/src/tui/tests/flows.rs @@ -669,7 +669,7 @@ fn launcher_settings_expand_to_storage_and_confirm_cache_cleanup() { assert!(ui.screen().contains("Instances")); assert!(ui.screen().contains("Metadata")); - for _ in 18..23 { + for _ in 18..24 { ui.key(KeyCode::Char('j')); } ui.key(KeyCode::Enter); @@ -984,7 +984,7 @@ fn settings_use_java_memory_and_resolution_controls() { ui.key(KeyCode::Esc); ui.key(KeyCode::Char('G')); - for _ in 0..5 { + for _ in 0..6 { ui.key(KeyCode::Char('j')); } ui.key(KeyCode::Enter); diff --git a/src/tui/tests/widgets/popups/mod.rs b/src/tui/tests/widgets/popups/mod.rs index 37d9167..c063491 100644 --- a/src/tui/tests/widgets/popups/mod.rs +++ b/src/tui/tests/widgets/popups/mod.rs @@ -8,7 +8,11 @@ use super::{ #[test] fn fitted_keybinds_use_terminal_width_and_omit_overflow() { - let line = keybind_line_fitted(&[("⏎", " select"), ("a", " add")], 10); + let line = keybind_line_fitted( + crate::config::settings::ShortcutHintScope::Accounts, + &[("⏎", " select"), ("a", " add")], + 10, + ); assert_eq!(line.width(), 10); assert_eq!(line.to_string(), "[⏎] select"); diff --git a/src/tui/widgets/account.rs b/src/tui/widgets/account.rs index f569ca1..ff1e843 100644 --- a/src/tui/widgets/account.rs +++ b/src/tui/widgets/account.rs @@ -225,6 +225,7 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut A let keybind_line = if focused == FocusedArea::Account { Some(super::popups::keybind_line_fitted( + crate::config::settings::ShortcutHintScope::Accounts, &[ ("⏎", " select"), ("a", " add"), diff --git a/src/tui/widgets/content/tabs.rs b/src/tui/widgets/content/tabs.rs index a2963ed..35450b5 100644 --- a/src/tui/widgets/content/tabs.rs +++ b/src/tui/widgets/content/tabs.rs @@ -455,6 +455,11 @@ pub fn render( } // The main panel footer stays on its border; lower-priority hints are omitted when narrow. block = block.title_bottom(crate::tui::widgets::popups::keybind_line_fitted( + if focused == FocusedArea::Instances { + crate::config::settings::ShortcutHintScope::Instances + } else { + crate::config::settings::ShortcutHintScope::Content + }, &keybinds, area.width.saturating_sub(2), )); diff --git a/src/tui/widgets/popups/base.rs b/src/tui/widgets/popups/base.rs index 64b3389..d008657 100644 --- a/src/tui/widgets/popups/base.rs +++ b/src/tui/widgets/popups/base.rs @@ -13,7 +13,7 @@ use ratatui::{ widgets::{Block, Clear, Paragraph, Widget}, }; -use crate::config::theme::BORDER_STYLE; +use crate::config::{settings::ShortcutHintScope, theme::BORDER_STYLE}; type ContentFn<'a> = Box; @@ -56,7 +56,9 @@ impl<'a> Widget for PopupFrame<'a> { block = block.title_top(sl.alignment(Alignment::Right)); } - if let Some(kb) = self.keybinds { + if let Some(kb) = self.keybinds + && super::shortcut_hints_visible(ShortcutHintScope::Popups) + { block = block.title_bottom(kb.alignment(Alignment::Right)); } diff --git a/src/tui/widgets/popups/global_settings.rs b/src/tui/widgets/popups/global_settings.rs index 7acfd2e..f785767 100644 --- a/src/tui/widgets/popups/global_settings.rs +++ b/src/tui/widgets/popups/global_settings.rs @@ -16,7 +16,7 @@ use ratatui_textarea::TextArea; use crate::{ config::{ Config, - settings::{ContentProvider, DEFAULT_RESOLUTION, ImageProtocol}, + settings::{ContentProvider, DEFAULT_RESOLUTION, ImageProtocol, ShortcutHintScope}, theme::{BORDER_STYLE, BorderStyle, THEME, ThemeConfig}, }, instance::models::{memory_kib, normalize_memory_value, parse_resolution}, @@ -32,7 +32,9 @@ use crate::{ tui::widgets::status_badge, }; -const FIELD_COUNT: usize = 24; +const FIELD_ORDER: [usize; 25] = [ + 0, 1, 2, 24, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, +]; const MODRINTH_COLOR: Color = Color::Rgb(0x1B, 0xD9, 0x6A); const CURSEFORGE_COLOR: Color = Color::Rgb(0xF1, 0x64, 0x36); const PROVIDER_BADGE_TEXT: Color = Color::Rgb(0x10, 0x10, 0x10); @@ -41,6 +43,7 @@ const PROVIDER_BADGE_TEXT: Color = Color::Rgb(0x10, 0x10, 0x10); enum ChoicePicker { ImageProtocol, Resolution, + ShortcutHints, } pub struct State { @@ -153,6 +156,7 @@ impl State { 20 => self.config.ui.error_slide_start_ms.to_string(), 21 => self.config.ui.error_fly_out_ms.to_string(), 22 => self.config.ui.max_error_events.to_string(), + 24 => shortcut_hint_mode(&self.config.ui).to_owned(), _ => String::new(), } } @@ -403,6 +407,29 @@ impl State { .collect() } + fn shortcut_hint_options(&self) -> Vec { + [ + (ShortcutHintScope::Instances, "instances", "Instances"), + (ShortcutHintScope::Content, "content", "Content"), + (ShortcutHintScope::Accounts, "accounts", "Accounts"), + (ShortcutHintScope::Settings, "settings", "Settings"), + (ShortcutHintScope::Popups, "popups", "Popups"), + ] + .into_iter() + .map(|(scope, key, title)| { + let visible = self.config.ui.show_shortcut_hints(scope); + SettingsPickerOption { + key: key.to_owned(), + title: format!("{} {title}", if visible { "●" } else { "○" }), + detail: Some(if visible { "Shown" } else { "Hidden" }.to_owned()), + leading: None, + badge: None, + active: visible, + } + }) + .collect() + } + fn open_choice_picker(&mut self, picker: ChoicePicker) { match picker { ChoicePicker::ImageProtocol => { @@ -418,6 +445,11 @@ impl State { .position(|choice| choice.resolution() == self.config.defaults.resolution) .unwrap_or(0); } + ChoicePicker::ShortcutHints => { + self.settings_picker.reset(); + self.settings_picker + .sync(self.shortcut_hint_options(), None); + } } self.choice_picker = Some(picker); } @@ -456,6 +488,22 @@ impl State { let Some(value) = self.settings_picker.selected_key().map(str::to_owned) else { return; }; + if picker == ChoicePicker::ShortcutHints { + let scope = match value.as_str() { + "instances" => ShortcutHintScope::Instances, + "content" => ShortcutHintScope::Content, + "accounts" => ShortcutHintScope::Accounts, + "settings" => ShortcutHintScope::Settings, + "popups" => ShortcutHintScope::Popups, + _ => return, + }; + let visible = self.config.ui.show_shortcut_hints(scope); + self.config.ui.set_shortcut_hints(scope, !visible); + self.settings_picker + .sync(self.shortcut_hint_options(), Some(&value)); + self.save_pending = true; + return; + } if picker == ChoicePicker::ImageProtocol { let protocol = match value.as_str() { "kitty" => ImageProtocol::Kitty, @@ -511,6 +559,27 @@ impl State { self.error = None; } + fn cycle_shortcut_hints(&mut self, forward: bool) { + let current = shortcut_hint_mode(&self.config.ui); + let index = ["All", "Popups only", "Hidden"] + .iter() + .position(|mode| *mode == current); + let index = match (index, forward) { + (Some(2), true) | (Some(0), false) => 0, + (Some(index), true) => index + 1, + (Some(index), false) => index - 1, + (None, true) => 0, + (None, false) => 2, + }; + self.config.ui.hidden_shortcut_hints = match index { + 1 => [ShortcutHintScope::Main].into_iter().collect(), + 2 => [ShortcutHintScope::All].into_iter().collect(), + _ => Default::default(), + }; + self.save_pending = true; + self.error = None; + } + fn open_java_picker(&mut self) { self.java_picker .open(self.config.paths.java_path.as_deref()); @@ -659,9 +728,19 @@ impl State { } match key.code { KeyCode::Char('j') | KeyCode::Down => { - self.selected = (self.selected + 1).min(FIELD_COUNT - 1); + let position = FIELD_ORDER + .iter() + .position(|field| *field == self.selected) + .unwrap_or(0); + self.selected = FIELD_ORDER[(position + 1).min(FIELD_ORDER.len() - 1)]; + } + KeyCode::Char('k') | KeyCode::Up => { + let position = FIELD_ORDER + .iter() + .position(|field| *field == self.selected) + .unwrap_or(0); + self.selected = FIELD_ORDER[position.saturating_sub(1)]; } - KeyCode::Char('k') | KeyCode::Up => self.selected = self.selected.saturating_sub(1), KeyCode::Char('h') | KeyCode::Left if self.selected == 0 => self.cycle_theme(false), KeyCode::Char('l') | KeyCode::Right if self.selected == 0 => self.cycle_theme(true), KeyCode::Char('h') | KeyCode::Left if self.selected == 1 => self.cycle_border(false), @@ -676,6 +755,12 @@ impl State { KeyCode::Char('l') | KeyCode::Right if self.selected == 6 => self.cycle_window_mode(), KeyCode::Char('h') | KeyCode::Left if self.selected == 10 => self.cycle_provider(), KeyCode::Char('l') | KeyCode::Right if self.selected == 10 => self.cycle_provider(), + KeyCode::Char('h') | KeyCode::Left if self.selected == 24 => { + self.cycle_shortcut_hints(false); + } + KeyCode::Char('l') | KeyCode::Right if self.selected == 24 => { + self.cycle_shortcut_hints(true); + } KeyCode::Enter => match self.selected { 0 => self.theme_picker = true, 1 => self.cycle_border(true), @@ -688,6 +773,7 @@ impl State { 7 => self.open_choice_picker(ChoicePicker::Resolution), 10 => self.cycle_provider(), 11..=14 => self.toggle_selected(), + 24 => self.open_choice_picker(ChoicePicker::ShortcutHints), 23 => return Action::ClearCache, field => self.editing = Some(settings_text_area(vec![self.value(field)])), }, @@ -749,7 +835,7 @@ fn available_themes() -> Vec { pub fn popup_rect(area: Rect, state: &State) -> Rect { let form_width = (area.width * 86 / 100).saturating_sub(2); - let form_height = 37 + let form_height = 38 + tagged_row_count(&state.config.defaults.jvm_args, form_width).saturating_sub(1) as u16 + tagged_row_count( &environment_labels(&state.config.defaults.environment), @@ -767,7 +853,7 @@ pub fn popup_rect(area: Rect, state: &State) -> Rect { }; let width = match state.choice_picker { Some(ChoicePicker::Resolution) => 64, - Some(ChoicePicker::ImageProtocol) => 60, + Some(ChoicePicker::ImageProtocol | ChoicePicker::ShortcutHints) => 60, None if state.java_picker_open => 72, None if state.theme_picker => 52, None => 86, @@ -788,6 +874,8 @@ pub fn render(frame: &mut Frame, area: Rect, state: &mut State) { super::keybind_line(&[("Enter", " apply"), ("Esc", " cancel")]) } else if state.choice_picker == Some(ChoicePicker::Resolution) { super::keybind_line(&[("d", " default"), ("h", " back"), ("Enter", " select")]) + } else if state.choice_picker == Some(ChoicePicker::ShortcutHints) { + super::keybind_line(&[("Enter", " toggle"), ("h", " back")]) } else if state.java_picker_open || state.theme_picker || state.choice_picker.is_some() { super::keybind_line(&[("h", " back"), ("Enter", " select")]) } else if matches!(state.selected, 3 | 4) { @@ -833,6 +921,13 @@ pub fn render(frame: &mut Frame, area: Rect, state: &mut State) { ("E", " raw"), ("Esc", " back"), ]) + } else if state.selected == 24 { + super::keybind_line(&[ + ("h/l", " adjust"), + ("Enter", " customize"), + ("E", " raw"), + ("Esc", " back"), + ]) } else { super::keybind_line(&[ ("j/k", ""), @@ -849,6 +944,7 @@ pub fn render(frame: &mut Frame, area: Rect, state: &mut State) { match picker { ChoicePicker::ImageProtocol => " Image Rendering ", ChoicePicker::Resolution => " Default Resolution ", + ChoicePicker::ShortcutHints => " Shortcut Guides ", } } else { " Launcher Settings " @@ -918,7 +1014,7 @@ fn render_java_picker(frame: &mut Frame, area: Rect, state: &mut State) { fn render_settings_list(frame: &mut Frame, area: Rect, state: &State) { let theme = THEME.as_ref(); let sections: [(&str, &[usize]); 6] = [ - ("Appearance", &[0, 1, 2]), + ("Appearance", &[0, 1, 2, 24]), ("Launch Defaults", &[3, 4, 5, 6, 7, 8, 9]), ("Content", &[10, 11, 12, 13, 14, 15, 16]), ("Storage", &[17, 18]), @@ -1082,6 +1178,7 @@ fn field_label(index: usize) -> &'static str { 21 => "Fly-out ms", 22 => "Max notifications", 23 => "", + 24 => "Shortcut guides", _ => "", } } @@ -1208,6 +1305,16 @@ fn status(enabled: bool) -> String { if enabled { "enabled" } else { "disabled" }.to_owned() } +fn shortcut_hint_mode(ui: &crate::config::settings::Ui) -> &'static str { + let visible = ShortcutHintScope::AREAS.map(|scope| ui.show_shortcut_hints(scope)); + match visible { + [true, true, true, true, true] => "All", + [false, false, false, false, true] => "Popups only", + [false, false, false, false, false] => "Hidden", + _ => "Custom", + } +} + #[cfg(test)] mod tests { use super::*; @@ -1437,6 +1544,35 @@ mod tests { assert_eq!(state.themes[state.theme_index], active_theme); } + #[test] + fn shortcut_guides_offer_presets_and_selective_toggles() { + let mut state = State::new(); + state.config.ui.hidden_shortcut_hints.clear(); + state.selected = 2; + state.handle_key(&KeyEvent::from(KeyCode::Down)); + assert_eq!(state.selected, 24); + + assert!(matches!( + state.handle_key(&KeyEvent::from(KeyCode::Right)), + Action::Save(..) + )); + assert_eq!(shortcut_hint_mode(&state.config.ui), "Popups only"); + + state.handle_key(&KeyEvent::from(KeyCode::Enter)); + assert_eq!(state.choice_picker, Some(ChoicePicker::ShortcutHints)); + assert!(matches!( + state.handle_key(&KeyEvent::from(KeyCode::Enter)), + Action::Save(..) + )); + assert_eq!(shortcut_hint_mode(&state.config.ui), "Custom"); + assert!( + state + .config + .ui + .show_shortcut_hints(ShortcutHintScope::Instances) + ); + } + #[test] fn failed_launcher_save_remains_pending() { let mut state = State::new(); diff --git a/src/tui/widgets/popups/mod.rs b/src/tui/widgets/popups/mod.rs index 0f934ea..9cf6889 100644 --- a/src/tui/widgets/popups/mod.rs +++ b/src/tui/widgets/popups/mod.rs @@ -21,6 +21,8 @@ pub use load_state::LoadState; use ratatui::{layout::Rect, text::Span}; +use crate::config::settings::ShortcutHintScope; + pub(crate) fn compare_game_versions(a: &str, b: &str) -> std::cmp::Ordering { let parse_parts = |version: &str| { version @@ -85,6 +87,13 @@ pub fn top_right_rect(frame: Rect, inner_w: usize, inner_h: usize) -> Rect { } pub fn keybind_line(binds: &[(&str, &str)]) -> ratatui::text::Line<'static> { + if !shortcut_hints_visible(ShortcutHintScope::Popups) { + return ratatui::text::Line::default(); + } + styled_keybind_line(binds) +} + +fn styled_keybind_line(binds: &[(&str, &str)]) -> ratatui::text::Line<'static> { use crate::config::theme::THEME; use ratatui::{ style::{Modifier, Style}, @@ -109,7 +118,18 @@ pub fn keybind_line(binds: &[(&str, &str)]) -> ratatui::text::Line<'static> { Line::from(spans) } -pub fn keybind_line_fitted(binds: &[(&str, &str)], max_width: u16) -> ratatui::text::Line<'static> { +pub fn keybind_line_fitted( + scope: ShortcutHintScope, + binds: &[(&str, &str)], + max_width: u16, +) -> ratatui::text::Line<'static> { + if !shortcut_hints_visible(scope) { + return ratatui::text::Line::default(); + } + fitted_keybind_line(binds, max_width) +} + +fn fitted_keybind_line(binds: &[(&str, &str)], max_width: u16) -> ratatui::text::Line<'static> { let mut width = 0; let mut count = 0; for (key, label) in binds { @@ -121,7 +141,11 @@ pub fn keybind_line_fitted(binds: &[(&str, &str)], max_width: u16) -> ratatui::t count += 1; } - keybind_line(&binds[..count]).right_aligned() + styled_keybind_line(&binds[..count]).right_aligned() +} + +pub(crate) fn shortcut_hints_visible(scope: ShortcutHintScope) -> bool { + crate::config::SETTINGS.read().ui.show_shortcut_hints(scope) } #[cfg(test)] diff --git a/src/tui/widgets/popups/modpack_update.rs b/src/tui/widgets/popups/modpack_update.rs index 226fb17..0b6eb27 100644 --- a/src/tui/widgets/popups/modpack_update.rs +++ b/src/tui/widgets/popups/modpack_update.rs @@ -146,13 +146,17 @@ pub fn render(frame: &mut Frame, state: &State) { Action::Reinstall => (" Reinstalling modpack ", " Please wait "), }, }; - let block = Block::default() + let mut block = Block::default() .title(title) - .title_bottom(Line::from(footer).centered()) .borders(Borders::ALL) .border_type(BORDER_STYLE.to_border_type()) .border_style(Style::default().fg(theme.accent())) .style(Style::default().fg(theme.text()).bg(theme.surface())); + if state.phase == Phase::Applying + || super::shortcut_hints_visible(crate::config::settings::ShortcutHintScope::Popups) + { + block = block.title_bottom(Line::from(footer).centered()); + } match state.phase { Phase::Preparing => frame.render_widget( Paragraph::new(format!("Preparing the selected modpack {action}…")).block(block), diff --git a/src/tui/widgets/settings.rs b/src/tui/widgets/settings.rs index 335e7f3..206cbe0 100644 --- a/src/tui/widgets/settings.rs +++ b/src/tui/widgets/settings.rs @@ -222,6 +222,7 @@ pub fn render( ], }; Some(super::popups::keybind_line_fitted( + crate::config::settings::ShortcutHintScope::Settings, keybinds, area.width.saturating_sub(2), ))