generated from GarandPLG/rust-flake-template
Remove unused lifetimes from app structs
This commit is contained in:
+5
-5
@@ -10,16 +10,16 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
pub struct App<'a> {
|
||||
pub struct App {
|
||||
pub exit: bool,
|
||||
pub view: View,
|
||||
pub window_area: Rect,
|
||||
pub args: Cli,
|
||||
pub states: Option<GameStates<'a>>,
|
||||
pub states: Option<GameStates>,
|
||||
pub audio_tx: Sender<AudioCmd>,
|
||||
}
|
||||
|
||||
impl<'a> App<'a> {
|
||||
impl App {
|
||||
pub fn new(args: Cli, audio_tx: Sender<AudioCmd>) -> Self {
|
||||
Self {
|
||||
exit: false,
|
||||
@@ -31,11 +31,11 @@ impl<'a> App<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn states_ref(&self) -> Option<&GameStates<'a>> {
|
||||
pub fn states_ref(&self) -> Option<&GameStates> {
|
||||
self.states.as_ref()
|
||||
}
|
||||
|
||||
pub fn states_mut(&mut self) -> Option<&mut GameStates<'a>> {
|
||||
pub fn states_mut(&mut self) -> Option<&mut GameStates> {
|
||||
self.states.as_mut()
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -8,15 +8,15 @@ use crate::{
|
||||
use ratatui::layout::Rect;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct GameStates<'a> {
|
||||
pub struct GameStates {
|
||||
pub main_menu: MainMenuState,
|
||||
pub skirmish: SkirmishState<'a>,
|
||||
pub skirmish: SkirmishState,
|
||||
pub perk_decks: PerkDecksState,
|
||||
pub skills_config: SkillsConfigState,
|
||||
pub settings: SettingsState,
|
||||
}
|
||||
|
||||
impl GameStates<'_> {
|
||||
impl GameStates {
|
||||
pub fn new(args: &Cli, area: &Rect) -> Self {
|
||||
Self {
|
||||
main_menu: MainMenuState {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
use crate::app::states::skirmish_states::BoardState;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct SkirmishState<'a> {
|
||||
pub struct SkirmishState {
|
||||
pub id: usize,
|
||||
pub name: &'static str,
|
||||
pub board: BoardState<'a>,
|
||||
pub board: BoardState,
|
||||
pub side_panel: bool,
|
||||
pub turn_counter: u64,
|
||||
}
|
||||
|
||||
impl SkirmishState<'_> {
|
||||
impl SkirmishState {
|
||||
pub fn tick_update(&mut self) {
|
||||
// self.board.advance_turn();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use ratatui::layout::Rect;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct BoardState<'a> {
|
||||
pub struct BoardState {
|
||||
cells_area: Rect,
|
||||
pub cell_width: usize,
|
||||
pub cell_height: usize,
|
||||
@@ -31,10 +31,10 @@ pub struct BoardState<'a> {
|
||||
enemy_base_coords: (usize, usize),
|
||||
// pub marking_cells: bool,
|
||||
// marked_cells: VecDeque<(usize, usize)>,
|
||||
pub marked_cells: MarkedCells<'a>,
|
||||
pub marked_cells: MarkedCells,
|
||||
}
|
||||
|
||||
impl BoardState<'_> {
|
||||
impl BoardState {
|
||||
pub fn new(
|
||||
area: &Rect,
|
||||
map_width: usize,
|
||||
@@ -106,7 +106,7 @@ impl BoardState<'_> {
|
||||
cells.push(rows);
|
||||
}
|
||||
|
||||
let marked_cells: MarkedCells<'_> = MarkedCells::new();
|
||||
let marked_cells: MarkedCells = MarkedCells::new();
|
||||
|
||||
Self {
|
||||
cells_area,
|
||||
@@ -204,6 +204,7 @@ impl BoardState<'_> {
|
||||
|
||||
let cell: &mut CellWidget = self.get_mut_cell(row, col);
|
||||
cell.set_marked(true);
|
||||
self.marked_cells.selected_unit = cell.get_option_unit();
|
||||
|
||||
self.marked_cells.marked_cells.push_back((row, col));
|
||||
}
|
||||
|
||||
@@ -2,18 +2,18 @@ use crate::app::states::skirmish_states::units::Units;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct MarkedCells<'a> {
|
||||
pub struct MarkedCells {
|
||||
pub marking_cells: bool,
|
||||
pub marked_cells: VecDeque<(usize, usize)>,
|
||||
pub selected_unit: &'a Option<Units>,
|
||||
pub selected_unit: Option<Units>,
|
||||
}
|
||||
|
||||
impl MarkedCells<'_> {
|
||||
impl MarkedCells {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
marking_cells: false,
|
||||
marked_cells: VecDeque::new(),
|
||||
selected_unit: &None,
|
||||
selected_unit: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ pub enum View {
|
||||
SkillsConfig,
|
||||
}
|
||||
|
||||
impl Widget for &mut App<'_> {
|
||||
impl Widget for &mut App {
|
||||
fn render(self, area: Rect, buf: &mut Buffer)
|
||||
where
|
||||
Self: Sized,
|
||||
|
||||
@@ -7,7 +7,7 @@ use ratatui::{
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct BoardWidget<'a> {
|
||||
state: &'a BoardState<'a>,
|
||||
state: &'a BoardState,
|
||||
}
|
||||
|
||||
impl<'a> BoardWidget<'a> {
|
||||
|
||||
Reference in New Issue
Block a user