Add rlwinm decoder window (#83)

* Add rlwinm decoder window

* Remove extra files

* Create Cargo.lock

* Make fmt happy

* Update Cargo.lock

* Update Cargo.lock

* Update Cargo.lock
This commit is contained in:
Amber Brault 2024-07-21 19:56:46 -04:00 committed by GitHub
parent d9fb48853e
commit 9f71ce9fea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 69 additions and 13 deletions

36
Cargo.lock generated
View File

@ -110,9 +110,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.82" version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]] [[package]]
name = "arboard" name = "arboard"
@ -524,9 +524,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.6.0" version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952"
[[package]] [[package]]
name = "calloop" name = "calloop"
@ -2274,9 +2274,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.154" version = "0.2.155"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -2295,7 +2295,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-targets 0.52.5", "windows-targets 0.48.5",
] ]
[[package]] [[package]]
@ -2863,6 +2863,7 @@ dependencies = [
"pollster", "pollster",
"reqwest", "reqwest",
"rfd", "rfd",
"rlwinmdec",
"ron", "ron",
"self_update", "self_update",
"serde", "serde",
@ -2905,9 +2906,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.64" version = "0.10.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1"
dependencies = [ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"cfg-if", "cfg-if",
@ -2937,9 +2938,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.102" version = "0.9.103"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -3509,6 +3510,15 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "rlwinmdec"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2076dbc187938f3db71c03c85d143febf01026631189dc8ca85f8c886d90ea12"
dependencies = [
"anyhow",
]
[[package]] [[package]]
name = "ron" name = "ron"
version = "0.8.1" version = "0.8.1"
@ -4743,9 +4753,9 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-hal" name = "wgpu-hal"
version = "0.19.4" version = "0.19.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc1a4924366df7ab41a5d8546d6534f1f33231aa5b3f72b9930e300f254e39c3" checksum = "bfabcfc55fd86611a855816326b2d54c3b2fd7972c27ce414291562650552703"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec",

View File

@ -29,6 +29,7 @@ bytes = "1.6.0"
cfg-if = "1.0.0" cfg-if = "1.0.0"
const_format = "0.2.32" const_format = "0.2.32"
cwdemangle = "1.0.0" cwdemangle = "1.0.0"
rlwinmdec = "1.0.1"
dirs = "5.0.1" dirs = "5.0.1"
egui = "0.27.2" egui = "0.27.2"
egui_extras = "0.27.2" egui_extras = "0.27.2"

View File

@ -39,6 +39,7 @@ use crate::{
function_diff::function_diff_ui, function_diff::function_diff_ui,
graphics::{graphics_window, GraphicsConfig, GraphicsViewState}, graphics::{graphics_window, GraphicsConfig, GraphicsViewState},
jobs::jobs_ui, jobs::jobs_ui,
rlwinm::{rlwinm_decode_window, RlwinmDecodeViewState},
symbol_diff::{symbol_diff_ui, DiffViewState, View}, symbol_diff::{symbol_diff_ui, DiffViewState, View},
}, },
}; };
@ -48,11 +49,13 @@ pub struct ViewState {
pub jobs: JobQueue, pub jobs: JobQueue,
pub config_state: ConfigViewState, pub config_state: ConfigViewState,
pub demangle_state: DemangleViewState, pub demangle_state: DemangleViewState,
pub rlwinm_decode_state: RlwinmDecodeViewState,
pub diff_state: DiffViewState, pub diff_state: DiffViewState,
pub graphics_state: GraphicsViewState, pub graphics_state: GraphicsViewState,
pub frame_history: FrameHistory, pub frame_history: FrameHistory,
pub show_appearance_config: bool, pub show_appearance_config: bool,
pub show_demangle: bool, pub show_demangle: bool,
pub show_rlwinm_decode: bool,
pub show_project_config: bool, pub show_project_config: bool,
pub show_arch_config: bool, pub show_arch_config: bool,
pub show_debug: bool, pub show_debug: bool,
@ -450,11 +453,13 @@ impl eframe::App for App {
jobs, jobs,
config_state, config_state,
demangle_state, demangle_state,
rlwinm_decode_state,
diff_state, diff_state,
graphics_state, graphics_state,
frame_history, frame_history,
show_appearance_config, show_appearance_config,
show_demangle, show_demangle,
show_rlwinm_decode,
show_project_config, show_project_config,
show_arch_config, show_arch_config,
show_debug, show_debug,
@ -513,6 +518,10 @@ impl eframe::App for App {
*show_demangle = !*show_demangle; *show_demangle = !*show_demangle;
ui.close_menu(); ui.close_menu();
} }
if ui.button("Rlwinm Decoder…").clicked() {
*show_rlwinm_decode = !*show_rlwinm_decode;
ui.close_menu();
}
}); });
ui.menu_button("Diff Options", |ui| { ui.menu_button("Diff Options", |ui| {
if ui.button("Arch Settings…").clicked() { if ui.button("Arch Settings…").clicked() {
@ -598,6 +607,7 @@ impl eframe::App for App {
project_window(ctx, config, show_project_config, config_state, appearance); project_window(ctx, config, show_project_config, config_state, appearance);
appearance_window(ctx, show_appearance_config, appearance); appearance_window(ctx, show_appearance_config, appearance);
demangle_window(ctx, show_demangle, demangle_state, appearance); demangle_window(ctx, show_demangle, demangle_state, appearance);
rlwinm_decode_window(ctx, show_rlwinm_decode, rlwinm_decode_state, appearance);
arch_config_window(ctx, config, show_arch_config, appearance); arch_config_window(ctx, config, show_arch_config, appearance);
debug_window(ctx, show_debug, frame_history, appearance); debug_window(ctx, show_debug, frame_history, appearance);
graphics_window(ctx, show_graphics, frame_history, graphics_state, appearance); graphics_window(ctx, show_graphics, frame_history, graphics_state, appearance);

View File

@ -10,6 +10,7 @@ pub(crate) mod frame_history;
pub(crate) mod function_diff; pub(crate) mod function_diff;
pub(crate) mod graphics; pub(crate) mod graphics;
pub(crate) mod jobs; pub(crate) mod jobs;
pub(crate) mod rlwinm;
pub(crate) mod symbol_diff; pub(crate) mod symbol_diff;
#[inline] #[inline]

View File

@ -0,0 +1,34 @@
use egui::TextStyle;
use crate::views::appearance::Appearance;
#[derive(Default)]
pub struct RlwinmDecodeViewState {
pub text: String,
}
pub fn rlwinm_decode_window(
ctx: &egui::Context,
show: &mut bool,
state: &mut RlwinmDecodeViewState,
appearance: &Appearance,
) {
egui::Window::new("Rlwinm Decoder").open(show).show(ctx, |ui| {
ui.text_edit_singleline(&mut state.text);
ui.add_space(10.0);
if let Some(demangled) = rlwinmdec::decode(&state.text) {
ui.scope(|ui| {
ui.style_mut().override_text_style = Some(TextStyle::Monospace);
ui.colored_label(appearance.replace_color, &demangled);
});
if ui.button("Copy").clicked() {
ui.output_mut(|output| output.copied_text = demangled);
}
} else {
ui.scope(|ui| {
ui.style_mut().override_text_style = Some(TextStyle::Monospace);
ui.colored_label(appearance.replace_color, "[invalid]");
});
}
});
}