feat(worlds): add metadata cards and quick launch
This commit is contained in:
1 parent
4eed312c3d
commit
ea7478eb27
22 files changed
+585
-88
No files matched your search
@@ -32,6 +32,41 @@ fn global_navigation_returns_from_log_overlay() {
|
||||
assert!(ui.app.exit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn worlds_reserves_q_for_available_quick_launch() {
|
||||
let mut ui = UiHarness::new();
|
||||
ui.add_instance("Test Instance");
|
||||
ui.app.focused = FocusedArea::Content;
|
||||
ui.app.content_tab = ContentTab::Worlds;
|
||||
|
||||
ui.key(KeyCode::Char('q'));
|
||||
assert!(!ui.app.exit, "unsupported Quick Play must not quit rmcl");
|
||||
|
||||
let meta = serde_json::json!({
|
||||
"id": "1.21.1",
|
||||
"mainClass": "net.minecraft.client.main.Main",
|
||||
"arguments": {
|
||||
"game": [{
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"features": { "is_quick_play_singleplayer": true }
|
||||
}],
|
||||
"value": ["--quickPlaySingleplayer", "${quickPlaySingleplayer}"]
|
||||
}],
|
||||
"jvm": []
|
||||
}
|
||||
});
|
||||
let meta_path = crate::storage::MetadataPaths::new(&ui.app.instance_manager.meta_dir)
|
||||
.versions()
|
||||
.join("1.21.1/meta.json");
|
||||
std::fs::create_dir_all(meta_path.parent().unwrap()).unwrap();
|
||||
std::fs::write(meta_path, serde_json::to_vec(&meta).unwrap()).unwrap();
|
||||
ui.app.world_quick_play_support = None;
|
||||
ui.draw();
|
||||
|
||||
assert!(ui.screen().contains("quick launch"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mouse_wheel_uses_the_focused_views_scroll_navigation() {
|
||||
let mut ui = UiHarness::new();
|
||||
|
||||
@@ -66,6 +66,7 @@ impl UiHarness {
|
||||
crate::instance::ContentKind::Shader,
|
||||
),
|
||||
worlds_state: widgets::content::ContentListState::default(),
|
||||
world_quick_play_support: None,
|
||||
screenshots_state: {
|
||||
let mut state = widgets::screenshots_grid::ScreenshotsState::default();
|
||||
state.font_size = (font_size.width, font_size.height);
|
||||
|
||||
@@ -417,6 +417,7 @@ fn rendering_visible_entries_restores_the_first_selection() {
|
||||
"Empty",
|
||||
&picker,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
@@ -424,6 +425,37 @@ fn rendering_visible_entries_restores_the_first_selection() {
|
||||
assert_eq!(state.list_state.selected, Some(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiline_rendering_uses_the_space_beside_large_icons() {
|
||||
let mut world = entry("World");
|
||||
world.description =
|
||||
"Last played\nDifficulty: Normal\nMinecraft: 1.21.1\nCreated\nApprox. size".to_owned();
|
||||
world.icon_lines = Some(crate::instance::content::fallback_icon_large());
|
||||
let mut state = ContentListState::default();
|
||||
state.entries.push(world);
|
||||
state.rebuild_display_metadata();
|
||||
let picker = ratatui_image::picker::Picker::halfblocks();
|
||||
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(50, 6)).unwrap();
|
||||
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
super::render(
|
||||
frame,
|
||||
frame.area(),
|
||||
&mut state,
|
||||
true,
|
||||
"Loading...",
|
||||
"Empty",
|
||||
&picker,
|
||||
false,
|
||||
true,
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
insta::assert_snapshot!(terminal.backend().to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pager_tracks_viewport_pages_and_jumps_to_their_first_item() {
|
||||
assert_eq!(
|
||||
@@ -470,6 +502,7 @@ fn pager_tracks_viewport_pages_and_jumps_to_their_first_item() {
|
||||
"Empty",
|
||||
&picker,
|
||||
true,
|
||||
false,
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
---
|
||||
source: src/tui/tests/widgets/content/list.rs
|
||||
expression: terminal.backend().to_string()
|
||||
---
|
||||
"▌▄▄▄▄▄▄▄▄▄▄▄▄ World "
|
||||
"▌▄▄▄▄▄▄▄▄▄▄▄▄ Last played "
|
||||
"▌▄▄▄▄▄▄▄▄▄▄▄▄ Difficulty: Normal "
|
||||
"▌▄▄▄▄▄▄▄▄▄▄▄▄ Minecraft: 1.21.1 "
|
||||
"▌▄▄▄▄▄▄▄▄▄▄▄▄ Created "
|
||||
"▌▄▄▄▄▄▄▄▄▄▄▄▄ Approx. size "
|
||||
Reference in new issue
Block a user