Skip to content

Commit a2fe267

Browse files
authored
Merge pull request #151 from Jupeyy/pr_client_improvements12
Various improvements
2 parents 6fe1cc9 + 329fedd commit a2fe267

File tree

17 files changed

+161
-92
lines changed

17 files changed

+161
-92
lines changed

DEVELOPMENT.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ cargo run --release --no-default-features --features bench_slow_paths
103103
```
104104

105105
which enables tracing support for the sync update code and prints how long paths took,
106-
as soon as the whole update took over a certain amount of time (e.g. 17ms which is slower than 1/60 fps).
106+
as soon as the whole update took over a certain amount of time.
107+
The threshold can be adjusted with the environment variable `BENCHMARK_IGNORE_UNDER_NS` in nanoseconds, the default
108+
is 17ms which is just above the frametime of a single frame in 60 fps.

examples/wasm-modules/hud/src/hud/page.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use api_ui_game::render::{create_ctf_container, create_skin_container};
22
use base::{linked_hash_map_view::FxLinkedHashMap, network_string::PoolNetworkString};
33
use client_containers::{ctf::CtfContainer, skins::SkinContainer};
44
use client_render_base::render::tee::RenderTee;
5+
use client_ui::hud::user_data::RenderDateTime;
56
use game_interface::types::{
67
character_info::{NetworkCharacterInfo, NetworkSkinInfo},
78
id_gen::IdGenerator,
@@ -18,7 +19,7 @@ use graphics::{
1819
graphics::graphics::Graphics,
1920
handles::{canvas::canvas::GraphicsCanvasHandle, stream::stream::GraphicsStreamHandle},
2021
};
21-
use pool::rc::PoolRc;
22+
use pool::{datatypes::PoolString, rc::PoolRc};
2223
use ui_base::types::{UiRenderPipe, UiState};
2324
use ui_generic::traits::UiPageInterface;
2425

@@ -108,6 +109,10 @@ impl HudPage {
108109
character_infos: &self.character_infos,
109110
canvas_handle: &self.canvas_handle,
110111
stream_handle: &self.stream_handle,
112+
date_time: &Some(RenderDateTime {
113+
time: PoolString::new_str_without_pool("22:14:14"),
114+
date: PoolString::new_str_without_pool("Saturday, 27. September 2025"),
115+
}),
111116
},
112117
),
113118
ui_state,

game/client-demo/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ impl DemoViewerImpl {
519519
let stages = game.all_stages(intra_tick_ratio);
520520

521521
let scoreboard_info = None; // game.collect_scoreboard_info();
522+
let date_time = None;
522523

523524
let load_events = !last_monotonic_tick.is_some_and(|tick| tick == monotonic_tick);
524525
last_monotonic_tick.replace(monotonic_tick);
@@ -560,6 +561,7 @@ impl DemoViewerImpl {
560561
character_infos,
561562
stages,
562563
scoreboard_info,
564+
date_time,
563565
chat_msgs,
564566
game_time_info,
565567
settings: if let Some(DemoEncoder {

game/client-render-game/src/components/hud.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use client_containers::{
1010
};
1111
use client_render::hud::page::{HudRender, HudRenderPipe};
1212
use client_render_base::render::tee::RenderTee;
13+
use client_ui::hud::user_data::RenderDateTime;
1314
use game_interface::types::{
1415
emoticons::{EnumCount, IntoEnumIterator},
1516
game::{GameTickType, NonZeroGameTickType},
@@ -53,6 +54,7 @@ pub struct RenderHudPipe<'a> {
5354
pub skin_renderer: &'a RenderTee,
5455
pub ctf_container: &'a mut CtfContainer,
5556
pub character_infos: &'a FxLinkedHashMap<CharacterId, CharacterInfo>,
57+
pub date_time: &'a Option<RenderDateTime>,
5658
}
5759

5860
pub struct RenderOffsetsVanilla {
@@ -803,6 +805,7 @@ impl RenderHud {
803805
skin_renderer: pipe.skin_renderer,
804806
ctf_container: pipe.ctf_container,
805807
character_infos: pipe.character_infos,
808+
date_time: pipe.date_time,
806809
});
807810

808811
let hud = pipe.hud_container.get_or_default_opt(pipe.hud_key);

game/client-render-game/src/render_game.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use client_types::{
4747
use client_ui::{
4848
chat::user_data::{ChatEvent, ChatMode, MsgInChat},
4949
emote_wheel::user_data::EmoteWheelEvent,
50+
hud::user_data::RenderDateTime,
5051
spectator_selection::user_data::SpectatorSelectionEvent,
5152
thumbnail_container::{
5253
DEFAULT_THUMBNAIL_CONTAINER_PATH, ThumbnailContainer, load_thumbnail_container,
@@ -402,6 +403,8 @@ pub struct RenderGameInput {
402403
pub stages: PoolFxLinkedHashMap<StageId, StageRenderInfo>,
403404
pub scoreboard_info: Option<Scoreboard>,
404405

406+
pub date_time: Option<RenderDateTime>,
407+
405408
pub game_time_info: GameTimeInfo,
406409

407410
pub settings: RenderGameSettings,
@@ -1008,6 +1011,7 @@ impl RenderGame {
10081011
skin_renderer: &self.players.tee_renderer,
10091012
ctf_container: &mut self.containers.ctf_container,
10101013
character_infos: &render_info.character_infos,
1014+
date_time: &render_info.date_time,
10111015
});
10121016
if let Some(scoreboard_info) = local_render_info
10131017
.scoreboard_active

game/client-render/src/hud/page.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use std::time::Duration;
33
use base::linked_hash_map_view::FxLinkedHashMap;
44
use client_containers::{ctf::CtfContainer, skins::SkinContainer};
55
use client_render_base::render::tee::RenderTee;
6-
use client_ui::hud::{page::HudUi, user_data::UserData};
6+
use client_ui::hud::{
7+
page::HudUi,
8+
user_data::{RenderDateTime, UserData},
9+
};
710
use egui::Color32;
811
use game_interface::types::{
912
game::{GameTickType, NonZeroGameTickType},
@@ -20,9 +23,8 @@ use graphics::{
2023
use ui_base::{
2124
types::UiRenderPipe,
2225
ui::{UiContainer, UiCreator},
23-
ui_render::render_ui,
2426
};
25-
use ui_generic::traits::UiPageInterface;
27+
use ui_generic::generic_ui_renderer;
2628

2729
pub struct HudRenderPipe<'a> {
2830
pub race_timer_counter: &'a GameTickType,
@@ -33,6 +35,7 @@ pub struct HudRenderPipe<'a> {
3335
pub skin_renderer: &'a RenderTee,
3436
pub ctf_container: &'a mut CtfContainer,
3537
pub character_infos: &'a FxLinkedHashMap<CharacterId, CharacterInfo>,
38+
pub date_time: &'a Option<RenderDateTime>,
3639
}
3740

3841
pub struct HudRender {
@@ -61,10 +64,6 @@ impl HudRender {
6164
}
6265

6366
pub fn render(&mut self, pipe: &mut HudRenderPipe) {
64-
let canvas_width = self.canvas_handle.canvas_width();
65-
let canvas_height = self.canvas_handle.canvas_height();
66-
let pixels_per_point = self.canvas_handle.pixels_per_point();
67-
6867
let mut user_data = UserData {
6968
race_round_timer_counter: pipe.race_timer_counter,
7069
ticks_per_second: pipe.ticks_per_second,
@@ -75,27 +74,19 @@ impl HudRender {
7574
character_infos: pipe.character_infos,
7675
canvas_handle: &self.canvas_handle,
7776
stream_handle: &self.stream_handle,
77+
date_time: pipe.date_time,
7878
};
7979
let mut dummy_pipe = UiRenderPipe::new(*pipe.cur_time, &mut user_data);
80-
let (screen_rect, full_output, zoom_level) = self.ui.render_cached(
81-
canvas_width,
82-
canvas_height,
83-
pixels_per_point,
84-
|ui, inner_pipe, ui_state| self.hud_ui.render(ui, inner_pipe, ui_state),
85-
&mut dummy_pipe,
86-
Default::default(),
87-
false,
88-
true,
89-
);
90-
render_ui(
91-
&mut self.ui,
92-
full_output,
93-
&screen_rect,
94-
zoom_level,
80+
81+
generic_ui_renderer::render(
9582
&self.backend_handle,
9683
&self.texture_handle,
9784
&self.stream_handle,
98-
false,
85+
&self.canvas_handle,
86+
&mut self.ui,
87+
&mut self.hud_ui,
88+
&mut dummy_pipe,
89+
Default::default(),
9990
);
10091
}
10192
}

game/client-ui/src/hud/main_frame.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,52 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>, ui_state: &m
384384
}
385385
};
386386

387+
// Floating overlay for date/time
388+
if let Some(dt) = pipe.user_data.date_time {
389+
let res = Window::new("date_time_overlay")
390+
.order(egui::Order::Tooltip)
391+
.interactable(false)
392+
.title_bar(false)
393+
.resizable(false)
394+
.frame(
395+
Frame::new()
396+
.fill(Color32::from_black_alpha(50))
397+
.inner_margin(10)
398+
.corner_radius(CornerRadius {
399+
nw: 0,
400+
ne: 0,
401+
sw: 10,
402+
se: 10,
403+
}),
404+
)
405+
.max_width(200.0)
406+
.anchor(Align2::CENTER_TOP, Vec2::new(400.0, 0.0))
407+
.show(ui.ctx(), |ui| {
408+
ui.with_layout(
409+
Layout::top_down(egui::Align::Center)
410+
.with_main_wrap(true)
411+
.with_main_justify(false)
412+
.with_cross_justify(false),
413+
|ui| {
414+
ui.label(RichText::new(dt.time.as_str()).color(Color32::WHITE));
415+
ui.label(RichText::new(dt.date.as_str()).color(Color32::LIGHT_GRAY));
416+
},
417+
);
418+
});
419+
420+
if let Some(res) = res {
421+
ui_state.add_blur_rect(
422+
res.response.rect,
423+
CornerRadius {
424+
nw: 0,
425+
ne: 0,
426+
sw: 10,
427+
se: 10,
428+
},
429+
);
430+
}
431+
}
432+
387433
let res = Window::new("")
388434
.resizable(false)
389435
.title_bar(false)

game/client-ui/src/hud/user_data.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ use game_interface::types::{
99
use graphics::handles::{
1010
canvas::canvas::GraphicsCanvasHandle, stream::stream::GraphicsStreamHandle,
1111
};
12+
use pool::datatypes::PoolString;
13+
use serde::{Deserialize, Serialize};
14+
15+
#[derive(Debug, Serialize, Deserialize)]
16+
pub struct RenderDateTime {
17+
pub time: PoolString,
18+
pub date: PoolString,
19+
}
1220

1321
pub struct UserData<'a> {
1422
pub canvas_handle: &'a GraphicsCanvasHandle,
@@ -23,4 +31,6 @@ pub struct UserData<'a> {
2331
pub ctf_container: &'a mut CtfContainer,
2432

2533
pub character_infos: &'a FxLinkedHashMap<CharacterId, CharacterInfo>,
34+
35+
pub date_time: &'a Option<RenderDateTime>,
2636
}

game/client-ui/src/main_menu/settings/list/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn render<'a>(
5454
|ui| {
5555
for (entry_index, (entry_name, ty)) in
5656
entries.enumerate().filter(|(_, (name, _))| {
57-
let matcher = fuzzy_matcher::skim::SkimMatcherV2::default();
57+
let matcher = fuzzy_matcher::skim::SkimMatcherV2::default().ignore_case();
5858
matcher.fuzzy_match(name, &search_str).is_some()
5959
})
6060
{

game/game-server/src/server.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,8 @@ impl Server {
27322732
|| config.client_server_sync_log.players
27332733
|| config.client_server_sync_log.projectiles
27342734
{
2735-
// breaks prediction, but currently only way to get useful information
2735+
// breaks prediction (except with instant input),
2736+
// but currently only way to get useful information
27362737
let cur_snap = game.snapshot_for(SnapshotClientInfo::Everything);
27372738
game.build_from_snapshot_for_prev(&cur_snap);
27382739

@@ -2764,9 +2765,14 @@ impl Server {
27642765
|| now.duration_since(dbg_game.time)
27652766
> Duration::from_millis(1000 / ticks_in_a_second))
27662767
&& config.client_server_sync_log.time
2768+
// for prediction times are wrong and this makes the check kinda useless
2769+
&& !caller_name.contains("pred")
2770+
&& !dbg_game.caller.contains("pred")
27672771
{
27682772
println!(
2769-
"out of sync: instant: {:?}, tick_time: {:?}, tick: {:?}",
2773+
"out of sync {} vs. {caller_name}: \
2774+
instant: {:?}, tick_time: {:?}, tick: {:?}",
2775+
dbg_game.caller,
27702776
now.duration_since(dbg_game.time),
27712777
(*last_tick_time).max(dbg_game.tick_time)
27722778
- (*last_tick_time).min(dbg_game.tick_time),

0 commit comments

Comments
 (0)