Ping arrow parameters & tweaks

This commit is contained in:
kcalbxof 2024-11-28 12:28:25 +03:00
parent 891c6d41ab
commit d8f8cfecb5
5 changed files with 75 additions and 8 deletions

View file

@ -151,4 +151,12 @@ info_stress_tests = We're doing public lobbies (a.k.a stress tests) every saturd
Info = Info Info = Info
## Local settings ## Local settings
connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy. connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy.
##Arrow UX settings
ping-note = Ping arrow parameters
ping-lifetime = Ping arrow lifetime in seconds.
ping-scale = Ping arrow size.
ping-lifetime-tooltip = This parameter changes how much frames (seconds*60, since game is supposed to run 60 fps?) ping arrow lives. Range: 0-60 seconds.
ping-scale-tooltip = This parameter changes size of ping arrow. I dont know which units it is, but range is 0-1.5 units.

View file

@ -149,4 +149,20 @@ info_stress_tests = We're doing public lobbies (a.k.a stress tests) every saturd
Info = Info Info = Info
## Local settings ## Local settings
connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy. connect_settings_random_ports = Don't use a predetermined port. Makes things a bit more robust and allows multiple proxies to be launched on the same computer, but Noita will have to be launched through the proxy.
##Arrow UX settings
ping-note = Параметры стрелочки-пинга
ping-lifetime = Время жизни стрелки в секундах.
ping-scale = Размер стрелки в юнитах.
ping-lifetime-tooltip = Этот параметр изменяет время жизни стрелочки (секунды*60, т.к. игра должна работать в 60 фпс?). Диапазон: 0-60 секунд.
ping-scale-tooltip = Этот параметр изменяет размер стрелочки. Не знаю какая единица измерения, но диапазон 0-1.5 юнита.

View file

@ -395,6 +395,21 @@ struct PlayerAppearance {
cosmetics: (bool, bool, bool), cosmetics: (bool, bool, bool),
} }
#[derive(Debug, Serialize, Deserialize, Decode, Encode, Copy, Clone)]
pub struct UXSettings {
ping_lifetime: u32,
ping_scale: f32,
}
impl Default for UXSettings {
fn default() -> Self {
Self {
ping_lifetime: 5,
ping_scale: 0.5,
}
}
}
impl Default for PlayerAppearance { impl Default for PlayerAppearance {
fn default() -> Self { fn default() -> Self {
Self { Self {
@ -524,6 +539,7 @@ pub struct App {
appearance: PlayerAppearance, appearance: PlayerAppearance,
connected_menu: ConnectedMenu, connected_menu: ConnectedMenu,
show_host_settings: bool, show_host_settings: bool,
ux_settings: UXSettings
} }
fn filled_group<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> { fn filled_group<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
@ -563,6 +579,7 @@ pub struct Settings {
color: PlayerAppearance, color: PlayerAppearance,
app: AppSavedState, app: AppSavedState,
modmanager: ModmanagerSettings, modmanager: ModmanagerSettings,
ux: UXSettings,
} }
fn settings_get() -> Settings { fn settings_get() -> Settings {
@ -580,12 +597,13 @@ fn settings_get() -> Settings {
} }
} }
fn settings_set(app: AppSavedState, color: PlayerAppearance, modmanager: ModmanagerSettings) { fn settings_set(app: AppSavedState, color: PlayerAppearance, modmanager: ModmanagerSettings, ux: UXSettings) {
if let Ok(s) = std::env::current_exe() { if let Ok(s) = std::env::current_exe() {
let settings = Settings { let settings = Settings {
app, app,
color, color,
modmanager, modmanager,
ux
}; };
let file = s.parent().unwrap().join("proxy.ron"); let file = s.parent().unwrap().join("proxy.ron");
let settings = ron::to_string(&settings).unwrap(); let settings = ron::to_string(&settings).unwrap();
@ -603,6 +621,7 @@ impl App {
let mut saved_state: AppSavedState = settings.app; let mut saved_state: AppSavedState = settings.app;
let modmanager_settings: ModmanagerSettings = settings.modmanager; let modmanager_settings: ModmanagerSettings = settings.modmanager;
let appearance: PlayerAppearance = settings.color; let appearance: PlayerAppearance = settings.color;
let ux_settings: UXSettings = settings.ux;
saved_state.times_started += 1; saved_state.times_started += 1;
info!("Setting fonts..."); info!("Setting fonts...");
@ -661,6 +680,7 @@ impl App {
appearance, appearance,
connected_menu: ConnectedMenu::Normal, connected_menu: ConnectedMenu::Normal,
show_host_settings: false, show_host_settings: false,
ux_settings,
} }
} }
@ -669,6 +689,7 @@ impl App {
self.app_saved_state.clone(), self.app_saved_state.clone(),
self.appearance.clone(), self.appearance.clone(),
self.modmanager_settings.clone(), self.modmanager_settings.clone(),
self.ux_settings.clone(),
) )
} }
@ -706,6 +727,7 @@ impl App {
my_nickname, my_nickname,
save_state: self.run_save_state.clone(), save_state: self.run_save_state.clone(),
player_color: self.appearance.player_color, player_color: self.appearance.player_color,
ux_settings: self.ux_settings.clone(),
cosmetics, cosmetics,
mod_path, mod_path,
player_path: player_path(self.modmanager_settings.mod_path()), player_path: player_path(self.modmanager_settings.mod_path()),
@ -1081,6 +1103,17 @@ impl App {
self.appearance.cosmetics = old.cosmetics; self.appearance.cosmetics = old.cosmetics;
self.appearance.player_picker = old.player_picker; self.appearance.player_picker = old.player_picker;
} }
ui.add_space(10.0);
ui.label(tr("ping-note"));
ui.add_space(10.0);
ui.add(egui::Slider::new(&mut self.ux_settings.ping_lifetime, 1..=60).text(tr("ping-lifetime"))
.min_decimals(0)
.max_decimals(0)
.step_by(1.0)).on_hover_text(tr("ping-lifetime-tooltip"));
ui.add(egui::Slider::new(&mut self.ux_settings.ping_scale, 0.0..=1.5).text(tr("ping-scale"))
.min_decimals(0)
.max_decimals(1)
.step_by(0.1)).on_hover_text(tr("ping-scale-tooltip"));
} }
fn connect_to_steam_lobby(&mut self, lobby_id: String) { fn connect_to_steam_lobby(&mut self, lobby_id: String) {
@ -1663,6 +1696,7 @@ fn cli_setup() -> (steam_helper::SteamState, NetManagerInit) {
my_nickname, my_nickname,
save_state: run_save_state, save_state: run_save_state,
player_color: PlayerColor::default(), player_color: PlayerColor::default(),
ux_settings: UXSettings::default(),
cosmetics, cosmetics,
mod_path: mod_manager.mod_path(), mod_path: mod_manager.mod_path(),
player_path, player_path,

View file

@ -26,7 +26,7 @@ use crate::player_cosmetics::{create_player_png, PlayerPngDesc};
use crate::{ use crate::{
bookkeeping::save_state::{SaveState, SaveStateEntry}, bookkeeping::save_state::{SaveState, SaveStateEntry},
recorder::Recorder, recorder::Recorder,
DefaultSettings, GameSettings, PlayerColor, DefaultSettings, GameSettings, PlayerColor, UXSettings,
}; };
pub mod messages; pub mod messages;
mod proxy_opt; mod proxy_opt;
@ -105,6 +105,7 @@ pub struct NetManagerInit {
pub my_nickname: Option<String>, pub my_nickname: Option<String>,
pub save_state: SaveState, pub save_state: SaveState,
pub player_color: PlayerColor, pub player_color: PlayerColor,
pub ux_settings: UXSettings,
pub cosmetics: (bool, bool, bool), pub cosmetics: (bool, bool, bool),
pub mod_path: PathBuf, pub mod_path: PathBuf,
pub player_path: PathBuf, pub player_path: PathBuf,
@ -599,6 +600,10 @@ impl NetManager {
"mina_color", "mina_color",
rgb[0] as u32 + ((rgb[1] as u32) << 8) + ((rgb[2] as u32) << 16), rgb[0] as u32 + ((rgb[1] as u32) << 8) + ((rgb[2] as u32) << 16),
); );
state.try_ws_write_option("ping_lifetime", self.init_settings.ux_settings.ping_lifetime);
state.try_ws_write_option("ping_scale", self.init_settings.ux_settings.ping_scale);
let progress = settings.progress.join(","); let progress = settings.progress.join(",");
state.try_ws_write_option("progress", progress.as_str()); state.try_ws_write_option("progress", progress.as_str());

View file

@ -63,11 +63,15 @@ function module.on_world_update()
end end
local i = 1 local i = 1
--ternary operators ahead
local lifetime = (ctx.proxy_opt.ping_lifetime ~= nil and {ctx.proxy_opt.ping_lifetime} or {900})[1]*60
local custom_scale = (ctx.proxy_opt.ping_scale ~= nil and {ctx.proxy_opt.ping_scale} or {0.5})[1]
while i <= #pings do while i <= #pings do
local pos = pings[i] local pos = pings[i]
local frame = pos[3] local frame = pos[3]
local peer_id = pos[4] local peer_id = pos[4]
if frame + 300 < GameGetFrameNum() then local alpha = 1 - ((GameGetFrameNum() - frame) / lifetime)
if frame + lifetime < GameGetFrameNum() then
table.remove(pings, i) table.remove(pings, i)
goto continue goto continue
end end
@ -107,12 +111,12 @@ function module.on_world_update()
local img_path = "mods/quant.ew/files/system/player/tmp/".. peer_id .."_ping.png" local img_path = "mods/quant.ew/files/system/player/tmp/".. peer_id .."_ping.png"
if outside then if outside then
local scale = math.max(1 / 6, 0.75 - math.atan((math.sqrt(dist_sq) - tch) / 1280) / math.pi) local scale = math.max(1 / 6, 0.75 - math.atan((math.sqrt(dist_sq) - tch) / 1280) / math.pi) + custom_scale
local x, y = world2gui(ccx+player_dir_x, ccy+player_dir_y) local x, y = world2gui(ccx+player_dir_x, ccy+player_dir_y)
GuiImage(gui, gui_id, x, y, img_path, 1, scale, 0, math.atan2(player_dir_y, player_dir_x) + math.pi/2) GuiImage(gui, gui_id, x, y, img_path, alpha, scale, 0, math.atan2(player_dir_y, player_dir_x) + math.pi/2)
else else
local x, y = world2gui(pos[1], pos[2]) local x, y = world2gui(pos[1], pos[2])
GuiImage(gui, gui_id, x, y, img_path, 1, 0.75, 0, math.pi) GuiImage(gui, gui_id, x, y, img_path, alpha, 0.75 + custom_scale, 0, math.pi)
end end
gui_id = gui_id + 1 gui_id = gui_id + 1
i = i + 1 i = i + 1