Get watermark working in first stage
This commit is contained in:
parent
b0b2b3e847
commit
171cedf181
4 changed files with 52 additions and 58 deletions
|
@ -28,7 +28,7 @@ impl UiOverlay for Watermark {}
|
|||
impl DataReceiver for Watermark {
|
||||
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
||||
match phase {
|
||||
GamePhase::None => self.gui.enable()?,
|
||||
GamePhase::None | GamePhase::TestDay => self.gui.enable()?,
|
||||
_ => self.gui.disable()?,
|
||||
}
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ impl Overlay {
|
|||
write_log!("created RFactorData");
|
||||
|
||||
for receiver in self.ui_elements.iter() {
|
||||
data.add_receiver(receiver.clone());
|
||||
data.add_receiver(receiver.clone())?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ pub struct Rendering {
|
|||
queue: Arc<Mutex<Queue>>,
|
||||
|
||||
signal_semaphore: Arc<Semaphore>,
|
||||
fence: Arc<Fence>,
|
||||
|
||||
render_callbacks: Vec<Box<dyn Fn(u32) -> Result<Arc<CommandBuffer>> + Send + Sync>>,
|
||||
}
|
||||
|
@ -45,6 +46,7 @@ impl Rendering {
|
|||
|
||||
Ok(Self {
|
||||
signal_semaphore: Semaphore::new(swapchain.device().clone())?,
|
||||
fence: Fence::builder().build(swapchain.device().clone())?,
|
||||
|
||||
swapchain,
|
||||
images,
|
||||
|
@ -95,7 +97,10 @@ impl Rendering {
|
|||
wait_semaphores.len()
|
||||
));
|
||||
|
||||
self.queue.lock().unwrap().submit(None, &[submit])?;
|
||||
self.queue
|
||||
.lock()
|
||||
.unwrap()
|
||||
.submit(Some(&self.fence), &[submit])?;
|
||||
|
||||
write_log!("submitted layer queue");
|
||||
|
||||
|
|
|
@ -88,8 +88,15 @@ impl RFactorData {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn add_receiver(&mut self, receiver: Arc<Mutex<dyn UiOverlay>>) {
|
||||
pub fn add_receiver(&mut self, receiver: Arc<Mutex<dyn UiOverlay>>) -> Result<()> {
|
||||
receiver
|
||||
.lock()
|
||||
.unwrap()
|
||||
.game_phase_change(self.previous_game_phase)?;
|
||||
|
||||
self.receivers.push(receiver);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn now(&self) -> f32 {
|
||||
|
@ -100,8 +107,9 @@ impl RFactorData {
|
|||
write_log!(" =================== update RFactorData ===================");
|
||||
|
||||
// get scoring info
|
||||
match self.scoring_reader.vehicle_scoring(self.now()) {
|
||||
Some((scoring_info, vehicle_scorings)) => {
|
||||
if let Some((scoring_info, vehicle_scorings)) =
|
||||
self.scoring_reader.vehicle_scoring(self.now())
|
||||
{
|
||||
self.last_scoring_read = self.start_time.elapsed();
|
||||
|
||||
write_log!(format!(
|
||||
|
@ -122,7 +130,6 @@ impl RFactorData {
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
let phase = GamePhase::try_from(scoring_info.mSession)?;
|
||||
|
||||
if self.previous_game_phase != phase {
|
||||
|
@ -137,7 +144,6 @@ impl RFactorData {
|
|||
}
|
||||
|
||||
write_log!(format!("GamePhase: {:?}", self.previous_game_phase));
|
||||
}
|
||||
|
||||
for receiver in self.receivers.iter() {
|
||||
let mut rec_mut = receiver.lock().unwrap();
|
||||
|
@ -147,23 +153,6 @@ impl RFactorData {
|
|||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let now = self.start_time.elapsed();
|
||||
|
||||
if now > (self.last_scoring_read + GAME_PHASE_TIME_OUT) {
|
||||
if self.previous_game_phase != GamePhase::None {
|
||||
self.previous_game_phase = GamePhase::None;
|
||||
|
||||
for receiver in self.receivers.iter() {
|
||||
receiver
|
||||
.lock()
|
||||
.unwrap()
|
||||
.game_phase_change(self.previous_game_phase)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check telemetry data
|
||||
write_log!("before telemetry update");
|
||||
|
|
Loading…
Reference in a new issue