Skip to content

Commit 5edd547

Browse files
committed
Render mic icon if active
1 parent c3477f0 commit 5edd547

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

src/client/client.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,11 @@ impl ClientNativeImpl {
21512151
},
21522152
force_bottom: self.ui_manager.ui.ui_state.is_ui_open,
21532153
show_fps: self.config.game.cl.show_fps,
2154+
mic_active: if let Game::Active(game) = &self.game {
2155+
matches!(game.spatial_world, SpatialChatGameWorldTy::World(_))
2156+
} else {
2157+
false
2158+
},
21542159
});
21552160

21562161
self.sound.swap();

src/client/overlays/client_stats.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl ClientStatsData {
226226
}
227227

228228
pub fn render_fps(&mut self, ui: &mut egui::Ui, pipe: &mut UiRenderPipe<()>, bottom: bool) {
229-
let cur_time = pipe.cur_time;
229+
let cur_time: Duration = pipe.cur_time;
230230
let time_diff = cur_time - self.last_frame_time;
231231
self.last_frame_time = cur_time;
232232

@@ -262,6 +262,7 @@ pub struct ClientStatsRenderPipe<'a> {
262262
pub connection_issues: bool,
263263
pub force_bottom: bool,
264264
pub show_fps: bool,
265+
pub mic_active: bool,
265266
}
266267

267268
/// This component collects various client statistics and displays them optionally
@@ -318,6 +319,28 @@ impl ClientStats {
318319
);
319320
}
320321

322+
fn render_mic(ui: &mut egui::Ui, bottom: bool) {
323+
let (pos, anchor) = if bottom {
324+
(
325+
ui.ctx().screen_rect().right_bottom() - egui::vec2(-5.0, 20.0),
326+
egui::Align2::RIGHT_BOTTOM,
327+
)
328+
} else {
329+
(
330+
ui.ctx().screen_rect().right_top() + egui::vec2(-5.0, 20.0),
331+
egui::Align2::RIGHT_TOP,
332+
)
333+
};
334+
335+
ui.painter().text(
336+
pos,
337+
anchor,
338+
"\u{f130}",
339+
FontId::proportional(18.0),
340+
Color32::from_rgb(200, 200, 255),
341+
);
342+
}
343+
321344
#[instrument(level = "trace", skip_all)]
322345
pub fn render(&mut self, pipe: &mut ClientStatsRenderPipe) {
323346
let dbg_hud_open = self.ui.ui_state.is_ui_open;
@@ -343,12 +366,12 @@ impl ClientStats {
343366
},
344367
);
345368
}
369+
let bottom = dbg_hud_open || !game_active || pipe.force_bottom;
346370
if pipe.show_fps {
347-
self.stats.render_fps(
348-
ui,
349-
inner_pipe,
350-
dbg_hud_open || !game_active || pipe.force_bottom,
351-
);
371+
self.stats.render_fps(ui, inner_pipe, bottom);
372+
}
373+
if pipe.mic_active {
374+
Self::render_mic(ui, bottom);
352375
}
353376
if pipe.connection_issues {
354377
Self::render_connection_issues(ui);

0 commit comments

Comments
 (0)