Skip to content

Commit

Permalink
make formmater happy
Browse files Browse the repository at this point in the history
  • Loading branch information
bgkillas committed Dec 4, 2024
1 parent f88437f commit 0aac5dd
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 24 deletions.
24 changes: 12 additions & 12 deletions noita-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ impl GameSettings {
.radio_value(&mut temp, GameMode::SharedHealth, tr("Shared-health"))
.changed()
|| ui
.radio_value(&mut temp, GameMode::LocalHealth, tr("Local-health"))
.changed()
.radio_value(&mut temp, GameMode::LocalHealth, tr("Local-health"))
.changed()
{
game_settings.game_mode = Some(temp)
}
Expand Down Expand Up @@ -134,7 +134,8 @@ impl GameSettings {
}
}
{
let mut temp = game_settings.global_hp_loss.unwrap_or(def.global_hp_loss);
let mut temp =
game_settings.global_hp_loss.unwrap_or(def.global_hp_loss);
if ui.checkbox(&mut temp, tr("global_hp_loss")).changed() {
game_settings.global_hp_loss = Some(temp)
}
Expand All @@ -156,7 +157,8 @@ impl GameSettings {
}
ui.add_space(1.0);
{
let mut temp = game_settings.physics_damage.unwrap_or(def.physics_damage);
let mut temp =
game_settings.physics_damage.unwrap_or(def.physics_damage);
if ui.checkbox(&mut temp, tr("physics_damage")).changed() {
game_settings.physics_damage = Some(temp)
}
Expand Down Expand Up @@ -543,11 +545,7 @@ fn settings_get() -> Settings {
}
}

fn settings_set(
app: AppSavedState,
color: PlayerAppearance,
modmanager: ModmanagerSettings,
) {
fn settings_set(app: AppSavedState, color: PlayerAppearance, modmanager: ModmanagerSettings) {
if let Ok(s) = std::env::current_exe() {
let settings = Settings {
app,
Expand Down Expand Up @@ -1262,7 +1260,9 @@ impl App {
}
}
ConnectedMenu::Settings => {
self.app_saved_state.game_settings.show_editor(ui, netman.peer.is_host());
self.app_saved_state
.game_settings
.show_editor(ui, netman.peer.is_host());
if netman.peer.is_host() {
self.end_run_button.show(ui, netman);
}
Expand Down Expand Up @@ -1581,7 +1581,7 @@ fn cli_setup() -> (steam_helper::SteamState, NetManagerInit) {
let appearance: PlayerAppearance = settings.color;
let mut state = steam_helper::SteamState::new(false).unwrap();
let my_nickname = saved_state.nickname;
;

mod_manager.try_find_game_path(Some(&mut state));
mod_manager.try_find_save_path();
let run_save_state = if let Ok(path) = std::env::current_exe() {
Expand Down Expand Up @@ -1655,4 +1655,4 @@ pub fn host_cli(port: u16) {
let player_path = netmaninit.player_path.clone();
let netman = net::NetManager::new(varient, netmaninit);
netman.start_inner(player_path, true).unwrap();
}
}
2 changes: 1 addition & 1 deletion noita-proxy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ async fn main() {
)
.unwrap()
}
}
}
4 changes: 2 additions & 2 deletions noita-proxy/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::mod_manager::ModmanagerSettings;
use crate::player_cosmetics::{create_player_png, PlayerPngDesc};
use crate::{
bookkeeping::save_state::{SaveState, SaveStateEntry},
DefaultSettings, GameSettings, PlayerColor,
DefaultSettings, GameSettings,
};
pub mod messages;
mod proxy_opt;
Expand Down Expand Up @@ -724,4 +724,4 @@ impl Drop for NetManager {
info!("Skip saving run info: not a host");
}
}
}
}
52 changes: 43 additions & 9 deletions noita-proxy/src/player_cosmetics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,57 @@ pub fn create_player_png(
let (arrows_path, ping_path, map_icon) = arrows_path(tmp_path.into(), is_host);
let cursor_path = cursor_path(tmp_path.into());
let player_lukki = tmp_path.join("unmodified_lukki.png");
replace_colors(player_path.into(), tmp_path.join(format!("tmp/{}.png", id)), &rgb);
replace_colors(player_lukki, tmp_path.join(format!("tmp/{}_lukki.png", id)), &rgb);
replace_colors(arrows_path, tmp_path.join(format!("tmp/{}_arrow.png", id)), &rgb);
replace_colors(ping_path, tmp_path.join(format!("tmp/{}_ping.png", id)), &rgb);
replace_colors(cursor_path, tmp_path.join(format!("tmp/{}_cursor.png", id)), &rgb);
replace_colors(
player_path.into(),
tmp_path.join(format!("tmp/{}.png", id)),
&rgb,
);
replace_colors(
player_lukki,
tmp_path.join(format!("tmp/{}_lukki.png", id)),
&rgb,
);
replace_colors(
arrows_path,
tmp_path.join(format!("tmp/{}_arrow.png", id)),
&rgb,
);
replace_colors(
ping_path,
tmp_path.join(format!("tmp/{}_ping.png", id)),
&rgb,
);
replace_colors(
cursor_path,
tmp_path.join(format!("tmp/{}_cursor.png", id)),
&rgb,
);
replace_colors(map_icon, tmp_path.join(format!("tmp/{}_map.png", id)), &rgb);
let ragdoll_path = tmp_path.join(format!("tmp/{}_ragdoll.txt", id));
if ragdoll_path.exists() {
remove_file(ragdoll_path.clone()).unwrap()
}
let mut ragdoll = File::create_new(ragdoll_path).unwrap();
let mut files = String::new();
for s in ["head.png", "left_hand.png", "left_arm.png", "left_thigh.png",
"right_hand.png", "right_arm.png", "right_thigh.png", "torso.png"].iter().rev() {
for s in [
"head.png",
"left_hand.png",
"left_arm.png",
"left_thigh.png",
"right_hand.png",
"right_arm.png",
"right_thigh.png",
"torso.png",
]
.iter()
.rev()
{
let f = tmp_path.join(s);
replace_colors(f, tmp_path.join(format!("tmp/{}_ragdoll_{}", id, s)), &rgb);
files = format!("{}mods/quant.ew/files/system/player/tmp/{}_ragdoll_{}\n", files, id, s);
files = format!(
"{}mods/quant.ew/files/system/player/tmp/{}_ragdoll_{}\n",
files, id, s
);
}
ragdoll.write_all(files.as_bytes()).unwrap();
let img = create_arm(Rgba::from(to_u8(rgb.player_forearm)));
Expand Down Expand Up @@ -493,4 +527,4 @@ fn edit_by_replacing(

fn rgb_to_hex(rgb: [u8; 4]) -> String {
format!("{:02X}{:02X}{:02X}", rgb[0], rgb[1], rgb[2])
}
}

0 comments on commit 0aac5dd

Please sign in to comment.