mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
add lukki sprite back, have map respect player colors, try to make colors more reliable, dont send adventure perk to peers
This commit is contained in:
parent
e673eb9930
commit
594af87651
14 changed files with 713 additions and 31 deletions
|
@ -353,7 +353,7 @@ impl NetManager {
|
|||
&self.init_settings.mod_path,
|
||||
&self.init_settings.player_path,
|
||||
&PlayerPngDesc::default(),
|
||||
self.is_host(),
|
||||
id == self.peer.host_id(),
|
||||
);
|
||||
info!("Sending PlayerColor to {id}");
|
||||
self.send(
|
||||
|
@ -361,6 +361,7 @@ impl NetManager {
|
|||
&NetMsg::PlayerColor(
|
||||
self.init_settings.player_png_desc,
|
||||
self.is_host(),
|
||||
Some(self.peer.my_id())
|
||||
),
|
||||
Reliability::Reliable,
|
||||
);
|
||||
|
@ -405,7 +406,7 @@ impl NetManager {
|
|||
}
|
||||
}
|
||||
NetMsg::WorldMessage(msg) => state.world.handle_msg(src, msg),
|
||||
NetMsg::PlayerColor(rgb, host) => {
|
||||
NetMsg::PlayerColor(rgb, host, pong) => {
|
||||
info!("Player appearance created for {}", src);
|
||||
// Create proper appearance files for new player.
|
||||
create_player_png(
|
||||
|
@ -415,6 +416,17 @@ impl NetManager {
|
|||
&rgb,
|
||||
host,
|
||||
);
|
||||
if let Some(id) = pong {
|
||||
self.send(
|
||||
id,
|
||||
&NetMsg::PlayerColor(
|
||||
self.init_settings.player_png_desc,
|
||||
self.is_host(),
|
||||
None
|
||||
),
|
||||
Reliability::Reliable,
|
||||
);
|
||||
}
|
||||
}
|
||||
NetMsg::Kick => std::process::exit(0),
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ pub(crate) enum NetMsg {
|
|||
ModRaw { data: Vec<u8> },
|
||||
ModCompressed { data: Vec<u8> },
|
||||
WorldMessage(WorldNetMessage),
|
||||
PlayerColor(PlayerPngDesc, bool),
|
||||
PlayerColor(PlayerPngDesc, bool, Option<OmniPeerId>),
|
||||
}
|
||||
|
||||
impl From<MessageRequest<WorldNetMessage>> for MessageRequest<NetMsg> {
|
||||
|
|
|
@ -5,7 +5,7 @@ use bitcode::{Decode, Encode};
|
|||
use eframe::egui;
|
||||
use eframe::egui::color_picker::{color_picker_color32, Alpha};
|
||||
use eframe::egui::{Color32, TextureHandle, TextureOptions, Ui};
|
||||
use image::{Rgba, RgbaImage};
|
||||
use image::{Pixel, Rgba, RgbaImage};
|
||||
use std::ffi::OsString;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
|
@ -16,7 +16,7 @@ pub fn player_path(path: PathBuf) -> PathBuf {
|
|||
path.join("files/system/player/unmodified.png")
|
||||
}
|
||||
|
||||
pub fn arrows_path(path: PathBuf, is_host: bool) -> (PathBuf, PathBuf) {
|
||||
pub fn arrows_path(path: PathBuf, is_host: bool) -> (PathBuf, PathBuf, PathBuf) {
|
||||
let parent = path.parent().unwrap();
|
||||
let p = parent.join("player_arrows");
|
||||
let o = parent.join("player_ping");
|
||||
|
@ -24,7 +24,7 @@ pub fn arrows_path(path: PathBuf, is_host: bool) -> (PathBuf, PathBuf) {
|
|||
p.join("arrow_host.png")
|
||||
} else {
|
||||
p.join("arrow.png")
|
||||
}, o.join("arrow.png"))
|
||||
}, o.join("arrow.png"), parent.join("map/icon.png"))
|
||||
}
|
||||
|
||||
pub fn cursor_path(path: PathBuf) -> PathBuf {
|
||||
|
@ -35,17 +35,27 @@ pub fn cursor_path(path: PathBuf) -> PathBuf {
|
|||
.join("resource/sprites/cursor.png")
|
||||
}
|
||||
|
||||
pub fn compare_rgb(a: Rgba<u8>, b: Rgba<u8>) -> bool {
|
||||
a.channels()[0..3] == b.channels()[0..3]
|
||||
}
|
||||
|
||||
pub fn set_rgb(a: &mut Rgba<u8>, b: Rgba<u8>) {
|
||||
for i in 0..3 {
|
||||
a.channels_mut()[i] = b.channels()[i];
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_color(image: &mut RgbaImage, main: Rgba<u8>, alt: Rgba<u8>, arm: Rgba<u8>) {
|
||||
let target_main = Rgba::from([155, 111, 154, 255]);
|
||||
let target_alt = Rgba::from([127, 84, 118, 255]);
|
||||
let target_arm = Rgba::from([89, 67, 84, 255]);
|
||||
for pixel in image.pixels_mut() {
|
||||
if *pixel == target_main {
|
||||
*pixel = main;
|
||||
} else if *pixel == target_alt {
|
||||
*pixel = alt
|
||||
} else if *pixel == target_arm {
|
||||
*pixel = arm
|
||||
if compare_rgb(*pixel, target_main) {
|
||||
set_rgb(pixel, main);
|
||||
} else if compare_rgb(*pixel, target_alt) {
|
||||
set_rgb(pixel, alt);
|
||||
} else if compare_rgb(*pixel, target_arm) {
|
||||
set_rgb(pixel, arm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +314,7 @@ pub fn create_player_png(
|
|||
let cosmetics = rgb.cosmetics;
|
||||
let rgb = rgb.colors;
|
||||
let tmp_path = player_path.parent().unwrap();
|
||||
let (arrows_path, ping_path) = arrows_path(tmp_path.into(), is_host);
|
||||
let (arrows_path, ping_path, map_icon) = arrows_path(tmp_path.into(), is_host);
|
||||
let cursor_path = cursor_path(tmp_path.into());
|
||||
let mut img = image::open(player_path).unwrap().into_rgba8();
|
||||
replace_color(
|
||||
|
@ -313,6 +323,14 @@ pub fn create_player_png(
|
|||
Rgba::from(to_u8(rgb.player_alt)),
|
||||
Rgba::from(to_u8(rgb.player_arm)),
|
||||
);
|
||||
let player_lukki = player_path.parent().unwrap().join("unmodified_lukki.png");
|
||||
let mut img_lukki = image::open(player_lukki).unwrap().into_rgba8();
|
||||
replace_color(
|
||||
&mut img_lukki,
|
||||
Rgba::from(to_u8(rgb.player_main)),
|
||||
Rgba::from(to_u8(rgb.player_alt)),
|
||||
Rgba::from(to_u8(rgb.player_arm)),
|
||||
);
|
||||
let mut img_arrow = image::open(arrows_path).unwrap().into_rgba8();
|
||||
replace_color(
|
||||
&mut img_arrow,
|
||||
|
@ -334,14 +352,25 @@ pub fn create_player_png(
|
|||
Rgba::from(to_u8(rgb.player_alt)),
|
||||
Rgba::from(to_u8(rgb.player_arm)),
|
||||
);
|
||||
let mut img_map_icon = image::open(map_icon).unwrap().into_rgba8();
|
||||
replace_color(
|
||||
&mut img_map_icon,
|
||||
Rgba::from(to_u8(rgb.player_main)),
|
||||
Rgba::from(to_u8(rgb.player_alt)),
|
||||
Rgba::from(to_u8(rgb.player_arm)),
|
||||
);
|
||||
let path = tmp_path.join(format!("tmp/{}.png", id));
|
||||
img.save(path).unwrap();
|
||||
let path = tmp_path.join(format!("tmp/{}_lukki.png", id));
|
||||
img_lukki.save(path).unwrap();
|
||||
let path = tmp_path.join(format!("tmp/{}_arrow.png", id));
|
||||
img_arrow.save(path).unwrap();
|
||||
let path = tmp_path.join(format!("tmp/{}_ping.png", id));
|
||||
img_ping.save(path).unwrap();
|
||||
let path = tmp_path.join(format!("tmp/{}_cursor.png", id));
|
||||
img_cursor.save(path).unwrap();
|
||||
let path = tmp_path.join(format!("tmp/{}_map.png", id));
|
||||
img_map_icon.save(path).unwrap();
|
||||
let img = create_arm(Rgba::from(to_u8(rgb.player_forearm)));
|
||||
let path = tmp_path.join(format!("tmp/{}_arm.png", id));
|
||||
img.save(path).unwrap();
|
||||
|
@ -368,6 +397,15 @@ pub fn create_player_png(
|
|||
id
|
||||
)],
|
||||
);
|
||||
edit_by_replacing(
|
||||
tmp_path.join("unmodified_lukki.xml"),
|
||||
tmp_path.join("tmp/".to_owned() + &id.clone() + "_lukki.xml"),
|
||||
&[
|
||||
(
|
||||
"MARKER_LUKKI_PNG",
|
||||
format!("mods/quant.ew/files/system/player/tmp/{}_lukki.png", id),
|
||||
),
|
||||
]);
|
||||
edit_by_replacing(
|
||||
tmp_path.join("unmodified_base.xml"),
|
||||
tmp_path.join("tmp/".to_owned() + &id.clone() + "_base.xml"),
|
||||
|
@ -403,6 +441,10 @@ pub fn create_player_png(
|
|||
"MARKER_MAIN_SPRITE",
|
||||
format!("mods/quant.ew/files/system/player/tmp/{}.xml", id),
|
||||
),
|
||||
(
|
||||
"MARKER_LUKKI_SPRITE",
|
||||
format!("mods/quant.ew/files/system/player/tmp/{}_lukki.xml", id),
|
||||
),
|
||||
(
|
||||
"MARKER_ARM_SPRITE",
|
||||
format!("mods/quant.ew/files/system/player/tmp/{}_arm.xml", id),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue