mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-04 00:21:57 +00:00
OverviewScreen now receives a CardTable instead of the loaded game.
This commit is contained in:
parent
992ad2b901
commit
b25b5e2fd8
@ -141,7 +141,7 @@ impl epi::App for CardEditor {
|
||||
egui::menu::menu(ui, "View", |ui| {
|
||||
if let Some(loaded_game) = loaded_game {
|
||||
if ui.button("Overview").clicked() {
|
||||
*overview_screen = Some(OverviewScreen::new(loaded_game));
|
||||
*overview_screen = Some(OverviewScreen::new(&loaded_game.card_table));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -166,7 +166,7 @@ impl epi::App for CardEditor {
|
||||
if let (Some(screen), Some(loaded_game)) = (overview_screen.as_mut(), loaded_game.as_mut()) {
|
||||
let mut is_open = true;
|
||||
egui::Window::new("Overview screen").open(&mut is_open).show(ctx, |ui| {
|
||||
screen.display(ui, loaded_game);
|
||||
screen.display(ui, &loaded_game.card_table);
|
||||
});
|
||||
|
||||
// If the window closed, destroy it
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
//! Overview screen
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
// Imports
|
||||
use crate::loaded_game::LoadedGame;
|
||||
use dcb::card::property::Speciality;
|
||||
use dcb::{card::property::Speciality, CardTable};
|
||||
use eframe::egui;
|
||||
use std::collections::HashMap;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
|
||||
@ -22,9 +20,8 @@ pub struct OverviewScreen {
|
||||
}
|
||||
|
||||
impl OverviewScreen {
|
||||
/// Creates a new screen
|
||||
pub fn new(loaded_game: &LoadedGame) -> Self {
|
||||
let card_table = &loaded_game.card_table;
|
||||
/// Creates a new overview screen
|
||||
pub fn new(card_table: &CardTable) -> Self {
|
||||
let total_digimons = card_table.digimons().count();
|
||||
let total_cards = card_table.cards.len();
|
||||
|
||||
@ -48,12 +45,12 @@ impl OverviewScreen {
|
||||
}
|
||||
|
||||
/// Reloads this screen
|
||||
pub fn reload(&mut self, loaded_game: &LoadedGame) {
|
||||
*self = Self::new(loaded_game);
|
||||
pub fn reload(&mut self, card_table: &CardTable) {
|
||||
*self = Self::new(card_table);
|
||||
}
|
||||
|
||||
/// Displays this swap screen
|
||||
pub fn display(&mut self, ui: &mut egui::Ui, loaded_game: &LoadedGame) {
|
||||
pub fn display(&mut self, ui: &mut egui::Ui, card_table: &CardTable) {
|
||||
let Self {
|
||||
total_cards,
|
||||
cards_per_speciality,
|
||||
@ -92,7 +89,7 @@ impl OverviewScreen {
|
||||
|
||||
// Reload if the users wants to
|
||||
if ui.button("Reload").clicked() {
|
||||
self.reload(loaded_game);
|
||||
self.reload(card_table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user