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