Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data
8 changes: 4 additions & 4 deletions game/client-ui/src/emote_wheel/main_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>, ui_state: &m
);
}

ui.painter().circle(
ui_state.add_glass_elipse(
egui::pos2(mouse.x as f32, mouse.y as f32),
10.0,
Color32::from_white_alpha(100),
Stroke::NONE,
egui::vec2(75.0, 75.0),
2.2,
Color32::from_rgba_unmultiplied(200, 200, 255, 255),
);
}
2 changes: 1 addition & 1 deletion game/client-ui/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn render_tee_for_ui_with_skin(
let tee_render_info = TeeRenderInfo {
color_body,
color_feet,
got_air_jump: false,
got_air_jump: true,
feet_flipped: false,
size: self.size,
eye_left: self.eyes,
Expand Down
36 changes: 27 additions & 9 deletions game/client-ui/src/vote/main_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,24 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>, ui_state: &m
},
Color32::RED,
);
at.x -= no_size / 2.0 - 5.0;
ui.painter().text(
at,
egui::Align2::LEFT_CENTER,
at = rect.left_center();
let galley = ui.painter().layout_no_wrap(
format!("{:.1}%", no_perc * 100.0),
FontId::default(),
Color32::WHITE,
);
let size = galley.size();
ui.painter().galley(
if size.x + 10.0 < rect.width() {
at + egui::vec2(5.0, -size.y / 2.0)
} else {
rect.right_center()
- egui::vec2(size.x, size.y / 2.0)
- egui::vec2(5.0, 0.0)
},
galley,
Color32::WHITE,
);
}

if yes_perc > 0.0 {
Expand All @@ -142,13 +152,21 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>, ui_state: &m
},
Color32::GREEN,
);
at.x += yes_size / 2.0 - 5.0;
ui.painter().text(
at,
egui::Align2::RIGHT_CENTER,
at = rect.right_center();
let galley = ui.painter().layout_no_wrap(
format!("{:.1}%", yes_perc * 100.0),
FontId::default(),
Color32::BLACK,
Color32::DARK_GRAY,
);
let size = galley.size();
ui.painter().galley(
if size.x + 10.0 < rect.width() {
at - egui::vec2(size.x, size.y / 2.0) - egui::vec2(5.0, 0.0)
} else {
rect.left_center() + egui::vec2(5.0, -size.y / 2.0)
},
galley,
Color32::DARK_GRAY,
);
}

Expand Down
7 changes: 1 addition & 6 deletions game/legacy-proxy/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::BTreeMap, net::SocketAddr, time::Duration};
use std::{collections::BTreeMap, net::SocketAddr};

use anyhow::anyhow;
use arrayvec::ArrayVec;
Expand Down Expand Up @@ -208,8 +208,6 @@ pub struct ClientData {
pub latest_input: snap_obj::PlayerInput,
pub latest_char_input: CharacterInput,

pub connect_time: Duration,

pub player_info: NetworkCharacterInfo,

pub latest_inputs: BTreeMap<i32, (CharacterInput, snap_obj::PlayerInput)>,
Expand All @@ -226,7 +224,6 @@ impl ProxyClient {
pub fn new(
player_info: NetworkCharacterInfo,
socket: SocketClient,
connect_time: Duration,
id: u64,
secondary_player: bool,
) -> Self {
Expand Down Expand Up @@ -255,8 +252,6 @@ impl ProxyClient {
inp
},

connect_time,

player_info,

latest_inputs: Default::default(),
Expand Down
62 changes: 26 additions & 36 deletions game/legacy-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ struct Client {
log: ConnectingLog,

last_snapshot: Snapshot,

start_time: Duration,
}

impl Client {
Expand All @@ -356,6 +358,7 @@ impl Client {
addr: SocketAddr,
log: ConnectingLog,
) -> anyhow::Result<LegacyProxy> {
let proxy_start = time.now();
let fs = io.fs.clone();

log.log("Preparing proxy socket");
Expand Down Expand Up @@ -437,7 +440,7 @@ impl Client {
Connless::RequestInfo(msg::connless::RequestInfo { token: tokens[0] }),
);
let start_time = time.now();
let mut last_req = start_time;
let mut last_req = None;
let mut last_reconnect = start_time;
while server_info.is_none()
&& !is_finished_thread.load(std::sync::atomic::Ordering::SeqCst)
Expand Down Expand Up @@ -511,8 +514,12 @@ impl Client {

let cur_time = time.now();
// send new request
if cur_time.saturating_sub(last_req) > Duration::from_secs(5) {
log.log("Sending new info request after 5s timeout");
if last_req.is_none_or(|last_req| {
cur_time.saturating_sub(last_req) > Duration::from_secs(1)
}) {
if last_req.is_some() {
log.log("Sending new info request after 1s timeout");
}
let token = rand::rng().next_u32() as u8;
conless.sendc(
addr,
Expand All @@ -521,7 +528,7 @@ impl Client {

tokens.push(token);

last_req = cur_time;
last_req = Some(cur_time);
}

// try to reconnect
Expand Down Expand Up @@ -675,6 +682,8 @@ impl Client {
is_finished: is_finished_thread,

log,

start_time: proxy_start,
};

app.run_loop().unwrap();
Expand Down Expand Up @@ -1584,7 +1593,7 @@ impl Client {
}
}
SnapObj::ClientInfo(client_info) => {
if let Some((character_id, info)) = Self::player_info_mut(id, base, snapshot) {
if let Some((_, info)) = Self::player_info_mut(id, base, snapshot) {
fn ints_to_net_str<const MAX_LENGTH: usize>(
int_arr: &[i32],
) -> NetworkString<MAX_LENGTH> {
Expand All @@ -1596,14 +1605,14 @@ impl Client {
.map(NetworkString::new_lossy)
.unwrap_or_default()
}
let mut player_info = (*info.player_info).clone();

// Apply as much info from known player info as possible
if character_id == player_id {
player_info = player.player_info.clone();
} else if let Some(dummy) = base.local_players.get(&id) {
player_info = dummy.player_info.clone();
}
let mut player_info = if let Some(dummy) = base.local_players.get(&id) {
dummy.player_info.clone()
} else {
// fall back to player info, since legacy servers don't send enough info
player.player_info.clone()
};

// Then overwrite the info the server knows about
player_info.name = ints_to_net_str(client_info.name.as_slice());
Expand Down Expand Up @@ -3528,13 +3537,7 @@ impl Client {

self.players.insert(
self.base.id_generator.next_id(),
ProxyClient::new(
Default::default(),
sock_loop,
self.time.now(),
0,
false,
),
ProxyClient::new(Default::default(), sock_loop, 0, false),
);
}
}
Expand Down Expand Up @@ -3564,13 +3567,7 @@ impl Client {

self.players.insert(
self.base.id_generator.next_id(),
ProxyClient::new(
Default::default(),
sock_loop,
self.time.now(),
0,
false,
),
ProxyClient::new(Default::default(), sock_loop, 0, false),
);
}
ClientToServerMessage::Ready(msg) => {
Expand Down Expand Up @@ -3619,13 +3616,7 @@ impl Client {
let player_id = self.base.id_generator.next_id();
self.players.insert(
player_id,
ProxyClient::new(
ev.player_info,
sock_loop,
self.time.now(),
ev.id,
true,
),
ProxyClient::new(ev.player_info, sock_loop, ev.id, true),
);
if let Some(con_id) = self.con_id {
self.server_network.send_unordered_to(
Expand Down Expand Up @@ -4531,10 +4522,9 @@ impl Client {
self.server_network.send_unordered_to(
&ServerToClientMessage::ServerInfo {
info: server_info,
overhead: self
.time
.now()
.saturating_sub(player.data.connect_time),
// the proxy is not really good at estimating the first ping
// so give it the whole startup time as overhead instead
overhead: self.time.now().saturating_sub(self.start_time),
},
&con_id,
);
Expand Down
9 changes: 6 additions & 3 deletions lib/api-ui/src/ui_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use api::{GRAPHICS, GRAPHICS_BACKEND, read_param_from_host, upload_return_val};

use graphics_types::types::WindowProps;
use ui_base::{
types::{BlurShape, RawInputWrapper, RawOutputWrapper, UiFonts, UiRenderPipe},
types::{BlurShape, GlassShape, RawInputWrapper, RawOutputWrapper, UiFonts, UiRenderPipe},
ui::UiContainer,
ui_render::render_ui,
};
Expand Down Expand Up @@ -44,7 +44,7 @@ fn ui_run_impl(
inp: RawInputWrapper,
zoom_level: Option<f32>,
mut user_data: U,
) -> (egui::PlatformOutput, Vec<BlurShape>) {
) -> (egui::PlatformOutput, Vec<BlurShape>, Vec<GlassShape>) {
API_UI.with(|g| g.borrow_mut().zoom_level.set(zoom_level));
GRAPHICS.with(|g| g.resized(window_props));

Expand Down Expand Up @@ -88,6 +88,7 @@ fn ui_run_impl(
(
platform_output,
API_UI.with(|ui| std::mem::take(&mut ui.borrow_mut().ui_state.blur_shapes)),
API_UI.with(|ui| std::mem::take(&mut ui.borrow_mut().ui_state.glass_shapes)),
)
}

Expand All @@ -108,10 +109,12 @@ pub fn ui_run() {
let inp = read_param_from_host::<RawInputWrapper>(2);
let zoom_level = read_param_from_host::<Option<f32>>(3);

let (output, blur_shapes) = ui_run_impl(cur_time, window_props, inp, zoom_level, ());
let (output, blur_shapes, glass_shapes) =
ui_run_impl(cur_time, window_props, inp, zoom_level, ());
upload_return_val(RawOutputWrapper {
output,
blur_shapes,
glass_shapes,
zoom_level: API_UI.with(|g| g.borrow().zoom_level.get()),
});
}
1 change: 1 addition & 0 deletions lib/graphics-backend-traits/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub enum SubRenderPassAttributes {
StandardBlurPipeline,
Standard3dPipeline,
BlurPipeline,
GlassPipeline,
PrimExPipeline,
PrimExRotationlessPipeline,
SpriteMultiPipeline,
Expand Down
Loading
Loading