2023-01-17 14:44:11 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use anyhow::Result;
|
|
|
|
use rfactor_sm_reader::{rF2VehicleTelemetry, VehicleScoringInfoV01};
|
|
|
|
use ui::prelude::*;
|
|
|
|
|
2023-01-18 07:55:43 +00:00
|
|
|
use crate::overlay::{
|
|
|
|
rfactor_data::{DataReceiver, GamePhase},
|
|
|
|
UiOverlay,
|
|
|
|
};
|
2023-01-17 14:44:11 +00:00
|
|
|
|
|
|
|
pub struct Watermark {
|
2023-01-18 10:51:16 +00:00
|
|
|
gui: Arc<GuiBuilder>,
|
2023-01-17 14:44:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Watermark {
|
|
|
|
pub fn new(gui_handler: &Arc<GuiHandler>) -> Result<Self> {
|
2023-01-18 08:19:55 +00:00
|
|
|
const DESC: &str = include_str!("watermark.xml");
|
2023-01-17 14:44:11 +00:00
|
|
|
|
|
|
|
let gui = GuiBuilder::from_str(gui_handler, DESC)?;
|
|
|
|
|
2023-01-18 10:51:16 +00:00
|
|
|
Ok(Self { gui })
|
2023-01-17 14:44:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl UiOverlay for Watermark {}
|
|
|
|
|
|
|
|
impl DataReceiver for Watermark {
|
2023-01-18 07:55:43 +00:00
|
|
|
fn scoring_update(
|
|
|
|
&mut self,
|
2023-01-18 10:51:16 +00:00
|
|
|
phase: GamePhase,
|
2023-01-18 07:55:43 +00:00
|
|
|
_vehicle_scoring: &[VehicleScoringInfoV01],
|
|
|
|
) -> Result<()> {
|
2023-01-18 10:51:16 +00:00
|
|
|
match phase {
|
|
|
|
GamePhase::TestDay => self.gui.enable()?,
|
|
|
|
_ => self.gui.disable()?,
|
|
|
|
}
|
|
|
|
|
2023-01-17 14:44:11 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn telemetry_update(
|
|
|
|
&mut self,
|
|
|
|
_player_id: Option<i32>,
|
|
|
|
_telemetries: &[rF2VehicleTelemetry],
|
|
|
|
) -> Result<()> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|