~quf/er-tracker

32ca4d5b866907a74a4aaf55459a2cd9e9a85f44 — Lukas Himbert 6 months ago 28c90f7 trunk
hexhex
3 files changed, 40 insertions(+), 16 deletions(-)

M Cargo.lock
M Cargo.toml
M src/debug_gui.rs
M Cargo.lock => Cargo.lock +30 -5
@@ 149,7 149,7 @@ dependencies = [
 "csv",
 "fltk",
 "fltk-table",
 "hex",
 "hexhex",
 "md-5",
 "tracing",
 "tracing-subscriber",


@@ 178,6 178,12 @@ dependencies = [
]

[[package]]
name = "fallible-iterator"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"

[[package]]
name = "fltk"
version = "1.3.33"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 231,10 237,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"

[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
name = "hexhex"
version = "1.0.0"
source = "git+https://git.sr.ht/~quf/hexhex#b8ef1448e96840cfa98558532ec2ca0c442500a7"
dependencies = [
 "hexhex_impl",
 "hexhex_macros",
]

[[package]]
name = "hexhex_impl"
version = "0.1.0"
source = "git+https://git.sr.ht/~quf/hexhex#b8ef1448e96840cfa98558532ec2ca0c442500a7"
dependencies = [
 "fallible-iterator",
]

[[package]]
name = "hexhex_macros"
version = "1.0.0"
source = "git+https://git.sr.ht/~quf/hexhex#b8ef1448e96840cfa98558532ec2ca0c442500a7"
dependencies = [
 "hexhex_impl",
]

[[package]]
name = "io-lifetimes"

M Cargo.toml => Cargo.toml +2 -4
@@ 2,17 2,15 @@
name = "er-tracker"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
publish = false

[dependencies]
clap = { version = "4.1", features = ["derive"] }
csv = "1.2"
fltk = "1.3.33"
fltk-table = "0.2.2"
hex = "0.4.3"
hexhex = { git = "https://git.sr.ht/~quf/hexhex", version = "1.0.0" }
md-5 = "0.10.5"
#memmap2 = "0.5.10"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
utf16string = "0.2"

M src/debug_gui.rs => src/debug_gui.rs +8 -7
@@ 74,11 74,12 @@ impl InventoryTable {
    }

    pub fn append(&mut self, entry: &sl2::InventoryEntry) {
        self.table.append_row("", &[&hex::encode(entry.lookup_buf), &entry.amount.to_string(), &entry.handle.to_string()]);
        self.table
            .append_row("", &[&hexhex::Hex::new(entry.lookup_buf).to_string(), &entry.amount.to_string(), &entry.handle.to_string()]);
    }

    pub fn set_row(&mut self, row: usize, entry: &sl2::InventoryEntry) {
        self.table.set_cell_value(row.try_into().unwrap(), 0, &hex::encode(entry.lookup_buf));
        self.table.set_cell_value(row.try_into().unwrap(), 0, &hexhex::Hex::new(entry.lookup_buf).to_string());
        self.table.set_cell_value(row.try_into().unwrap(), 1, &entry.amount.to_string());
        self.table.set_cell_value(row.try_into().unwrap(), 2, &entry.handle.to_string());
    }


@@ 257,7 258,7 @@ fn update_table1(table: &mut Table<&'static str>, sl2: &sl2::Sl2) {
    table.insert("faith", faith.to_string());
    table.insert("arcane", arcane.to_string());

    table.insert("unknown stats 3", hex::encode(sl2.unknown_stats_3()));
    table.insert("unknown stats 3", hexhex::Hex::new(sl2.unknown_stats_3()).to_string());

    table.insert("rune level", sl2.rune_level().to_string());
    table.insert("held runes", sl2.held_runes().to_string());


@@ 307,10 308,10 @@ fn update_inventory(table: &mut InventoryTable, buf: &mut fltk::text::TextDispla
    let removed = previous_inventory.difference(&current_inventory);
    let added = current_inventory.difference(&previous_inventory);
    for entry in added {
        buf.insert(&format!("+ {} {} {}\n", hex::encode(entry.lookup_buf), entry.amount, entry.handle));
        buf.insert(&format!("+ {} {} {}\n", hexhex::Hex::new(entry.lookup_buf), entry.amount, entry.handle));
    }
    for entry in removed {
        buf.insert(&format!("- {} {} {}\n", hex::encode(entry.lookup_buf), entry.amount, entry.handle));
        buf.insert(&format!("- {} {} {}\n", hexhex::Hex::new(entry.lookup_buf), entry.amount, entry.handle));
    }
    *previous_inventory = current_inventory
}


@@ 333,10 334,10 @@ fn update_key_items(table: &mut InventoryTable, buf: &mut fltk::text::TextDispla
    let removed = previous_key_items.difference(&current_key_items);
    let added = current_key_items.difference(&previous_key_items);
    for entry in added {
        buf.insert(&format!("+ {} {} {}\n", hex::encode(entry.lookup_buf), entry.amount, entry.handle));
        buf.insert(&format!("+ {} {} {}\n", hexhex::Hex::new(entry.lookup_buf), entry.amount, entry.handle));
    }
    for entry in removed {
        buf.insert(&format!("- {} {} {}\n", hex::encode(entry.lookup_buf), entry.amount, entry.handle));
        buf.insert(&format!("- {} {} {}\n", hexhex::Hex::new(entry.lookup_buf), entry.amount, entry.handle));
    }
    *previous_key_items = current_key_items
}