use std::collections::HashMap;
use steam_enums::EPersonaState;
#[derive(Debug, Clone, Default)]
pub struct SessionRecovery {
pub last_playing_app_ids: Vec<u32>,
pub last_custom_game_name: Option<String>,
pub last_rich_presence: HashMap<u32, HashMap<String, String>>,
pub last_persona_state: Option<EPersonaState>,
pub last_player_name: Option<String>,
}
impl SessionRecovery {
pub fn new() -> Self {
Self::default()
}
pub fn record_playing(&mut self, app_ids: Vec<u32>, custom_game_name: Option<String>) {
self.last_playing_app_ids = app_ids;
self.last_custom_game_name = custom_game_name;
}
pub fn record_rich_presence(&mut self, app_id: u32, data: HashMap<String, String>) {
if data.is_empty() {
self.last_rich_presence.remove(&app_id);
} else {
self.last_rich_presence.insert(app_id, data);
}
}
pub fn record_persona_state(&mut self, state: EPersonaState, name: Option<String>) {
self.last_persona_state = Some(state);
if name.is_some() {
self.last_player_name = name;
}
}
pub fn clear(&mut self) {
self.last_playing_app_ids.clear();
self.last_custom_game_name = None;
self.last_rich_presence.clear();
self.last_persona_state = None;
self.last_player_name = None;
}
}