mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-04 00:21:57 +00:00
Moved card searching to LoadedGame.
This commit is contained in:
parent
6ef468cc06
commit
93f70ada9a
@ -26,6 +26,9 @@ pub struct LoadedGame {
|
||||
|
||||
/// Hash of `card_table` within disk
|
||||
file_card_table_hash: Cell<u64>,
|
||||
|
||||
/// Card search
|
||||
card_search: String,
|
||||
}
|
||||
|
||||
impl LoadedGame {
|
||||
@ -47,6 +50,7 @@ impl LoadedGame {
|
||||
card_table,
|
||||
file,
|
||||
file_card_table_hash: Cell::new(file_card_table_hash),
|
||||
card_search: String::new(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -93,9 +97,17 @@ impl LoadedGame {
|
||||
|
||||
/// Displays the card selection menu
|
||||
pub fn display_card_selection(
|
||||
&mut self, card_search: &str, ui: &mut egui::Ui, open_edit_screens: &mut Vec<EditScreen>,
|
||||
tex_allocator: &mut dyn TextureAllocator,
|
||||
&mut self, ui: &mut egui::Ui, open_edit_screens: &mut Vec<EditScreen>, tex_allocator: &mut dyn TextureAllocator,
|
||||
) {
|
||||
ui.heading("Card list");
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.label("Search");
|
||||
ui.text_edit_singleline(&mut self.card_search);
|
||||
});
|
||||
ui.separator();
|
||||
|
||||
let card_search = &self.card_search;
|
||||
let names = self
|
||||
.card_table
|
||||
.cards
|
||||
|
||||
@ -62,9 +62,6 @@ pub struct CardEditor {
|
||||
/// Loaded game
|
||||
loaded_game: Option<LoadedGame>,
|
||||
|
||||
/// Card search
|
||||
card_search: String,
|
||||
|
||||
/// All selected edit screens
|
||||
open_edit_screens: Vec<EditScreen>,
|
||||
|
||||
@ -79,7 +76,6 @@ impl Default for CardEditor {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
loaded_game: None,
|
||||
card_search: String::new(),
|
||||
open_edit_screens: vec![],
|
||||
swap_screen: None,
|
||||
overview_screen: None,
|
||||
@ -91,7 +87,6 @@ impl epi::App for CardEditor {
|
||||
fn update(&mut self, ctx: &egui::CtxRef, frame: &mut epi::Frame<'_>) {
|
||||
let Self {
|
||||
loaded_game,
|
||||
card_search,
|
||||
open_edit_screens,
|
||||
swap_screen,
|
||||
overview_screen,
|
||||
@ -173,19 +168,12 @@ impl epi::App for CardEditor {
|
||||
}
|
||||
}
|
||||
|
||||
egui::SidePanel::left("side_panel").show(ctx, |ui| {
|
||||
ui.heading("Card list");
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.label("Search");
|
||||
ui.text_edit_singleline(card_search);
|
||||
// If we have a loaded game, display all cards
|
||||
if let Some(loaded_game) = loaded_game {
|
||||
egui::SidePanel::left("card-selection").show(ctx, |ui| {
|
||||
loaded_game.display_card_selection(ui, open_edit_screens, frame.tex_allocator());
|
||||
});
|
||||
|
||||
// If we have a loaded game, display all cards
|
||||
if let Some(loaded_game) = loaded_game {
|
||||
loaded_game.display_card_selection(card_search, ui, open_edit_screens, frame.tex_allocator());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Display all screens
|
||||
if let Some(loaded_game) = loaded_game {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user