diff --git a/.cargo/config.toml b/.cargo/config.toml index 6f1209c..85e33de 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,6 +2,8 @@ rustflags = ["-C", "link-args=-Wl,--subsystem,windows"] [alias] -brl = "build --release --lib" -xtask = "run --package xtask --" -r = "run --package xtask -- run" +xtask = "run --package xtask --release --" +t = "xwin test --target x86_64-pc-windows-msvc --" +c = "xwin clippy --target x86_64-pc-windows-msvc" +d = "xtask dist" +r = "xtask run" diff --git a/justfile b/justfile index b7d4777..51fb5a4 100644 --- a/justfile +++ b/justfile @@ -1,11 +1,5 @@ set dotenv-load := true -check: - cargo +nightly xwin clippy --target x86_64-pc-windows-msvc --all - -test *args: - cargo xwin test --target x86_64-pc-windows-msvc {{args}} -- --nocapture - install: cargo xtask dist cp jdsd_dsiii_practice_tool.toml \ diff --git a/practice-tool/Cargo.toml b/practice-tool/Cargo.toml index c5bd660..4df51f8 100644 --- a/practice-tool/Cargo.toml +++ b/practice-tool/Cargo.toml @@ -13,21 +13,23 @@ crate-type = ["cdylib", "rlib"] name = "libjdsd_dsiii_practice_tool" [dependencies] -libds3 = { path = "../lib/libds3" } +const_format = "0.2.26" +hex = "0.4.3" log-panics = "2.0.0" -toml = "0.5.6" +open = "1.4.0" +parking_lot = "0.11.2" +pkg-version = "1.0.0" +regex = "1" +semver = "0.11.0" serde = { version = "1.0.130", features = ["derive"] } serde_json = "1.0.57" -pkg-version = "1.0.0" +toml = "0.5.6" +tracing-subscriber = "0.3.17" ureq = { version = "2.8.0", features = ["json"] } -open = "1.4.0" -semver = "0.11.0" -regex = "1" widestring = "0.5.1" -parking_lot = "0.11.2" -hex = "0.4.3" -const_format = "0.2.26" -tracing-subscriber = "0.3.17" + +libds3 = { path = "../lib/libds3" } + hudhook.workspace = true imgui.workspace = true imgui-sys.workspace = true diff --git a/practice-tool/src/config.rs b/practice-tool/src/config.rs index c399f34..b2713a7 100644 --- a/practice-tool/src/config.rs +++ b/practice-tool/src/config.rs @@ -73,7 +73,7 @@ enum CfgCommand { CycleSpeed { #[serde(rename = "cycle_speed")] values: Vec, - hotkey: Key, + hotkey: Option, }, CharacterStats { #[serde(rename = "character_stats")] @@ -82,7 +82,7 @@ enum CfgCommand { Souls { #[serde(rename = "souls")] amount: u32, - hotkey: Key, + hotkey: Option, }, OpenMenu { #[serde(rename = "open_menu")] diff --git a/practice-tool/src/lib.rs b/practice-tool/src/lib.rs index 9eef151..372783f 100644 --- a/practice-tool/src/lib.rs +++ b/practice-tool/src/lib.rs @@ -1,3 +1,19 @@ +// johndisandonato's Dark Souls III Practice Tool +// Copyright (C) 2022-2024 johndisandonato +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + mod config; mod practice_tool; mod util; diff --git a/practice-tool/src/util/vk.rs b/practice-tool/src/util/vk.rs deleted file mode 100644 index 5c9ad28..0000000 --- a/practice-tool/src/util/vk.rs +++ /dev/null @@ -1,195 +0,0 @@ -use std::collections::HashMap; - -use once_cell::sync::Lazy; -use windows::Win32::UI::Input::KeyboardAndMouse::*; - -pub(crate) fn get_key_code(k: &str) -> Option { - VK_SYMBOL_MAP.get(&k.to_lowercase()).copied() -} - -pub(crate) fn get_key_repr(k: i32) -> Option<&'static str> { - VK_SYMBOL_MAP_INV.get(&k).map(String::as_str) -} - -pub static VK_SYMBOL_MAP: Lazy> = Lazy::new(|| { - [ - ("lbutton", VK_LBUTTON), - ("rbutton", VK_RBUTTON), - ("cancel", VK_CANCEL), - ("mbutton", VK_MBUTTON), - ("xbutton1", VK_XBUTTON1), - ("xbutton2", VK_XBUTTON2), - ("back", VK_BACK), - ("tab", VK_TAB), - ("clear", VK_CLEAR), - ("return", VK_RETURN), - ("shift", VK_SHIFT), - ("control", VK_CONTROL), - ("menu", VK_MENU), - ("pause", VK_PAUSE), - ("capital", VK_CAPITAL), - ("kana", VK_KANA), - ("hangul", VK_HANGUL), - ("junja", VK_JUNJA), - ("final", VK_FINAL), - ("hanja", VK_HANJA), - ("kanji", VK_KANJI), - ("escape", VK_ESCAPE), - ("convert", VK_CONVERT), - ("nonconvert", VK_NONCONVERT), - ("accept", VK_ACCEPT), - ("modechange", VK_MODECHANGE), - ("space", VK_SPACE), - ("prior", VK_PRIOR), - ("next", VK_NEXT), - ("end", VK_END), - ("home", VK_HOME), - ("left", VK_LEFT), - ("up", VK_UP), - ("right", VK_RIGHT), - ("down", VK_DOWN), - ("select", VK_SELECT), - ("print", VK_PRINT), - ("execute", VK_EXECUTE), - ("snapshot", VK_SNAPSHOT), - ("insert", VK_INSERT), - ("delete", VK_DELETE), - ("help", VK_HELP), - ("0", VIRTUAL_KEY('0' as _)), - ("1", VIRTUAL_KEY('1' as _)), - ("2", VIRTUAL_KEY('2' as _)), - ("3", VIRTUAL_KEY('3' as _)), - ("4", VIRTUAL_KEY('4' as _)), - ("5", VIRTUAL_KEY('5' as _)), - ("6", VIRTUAL_KEY('6' as _)), - ("7", VIRTUAL_KEY('7' as _)), - ("8", VIRTUAL_KEY('8' as _)), - ("9", VIRTUAL_KEY('9' as _)), - ("a", VIRTUAL_KEY('A' as _)), - ("b", VIRTUAL_KEY('B' as _)), - ("c", VIRTUAL_KEY('C' as _)), - ("d", VIRTUAL_KEY('D' as _)), - ("e", VIRTUAL_KEY('E' as _)), - ("f", VIRTUAL_KEY('F' as _)), - ("g", VIRTUAL_KEY('G' as _)), - ("h", VIRTUAL_KEY('H' as _)), - ("i", VIRTUAL_KEY('I' as _)), - ("j", VIRTUAL_KEY('J' as _)), - ("k", VIRTUAL_KEY('K' as _)), - ("l", VIRTUAL_KEY('L' as _)), - ("m", VIRTUAL_KEY('M' as _)), - ("n", VIRTUAL_KEY('N' as _)), - ("o", VIRTUAL_KEY('O' as _)), - ("p", VIRTUAL_KEY('P' as _)), - ("q", VIRTUAL_KEY('Q' as _)), - ("r", VIRTUAL_KEY('R' as _)), - ("s", VIRTUAL_KEY('S' as _)), - ("t", VIRTUAL_KEY('T' as _)), - ("u", VIRTUAL_KEY('U' as _)), - ("v", VIRTUAL_KEY('V' as _)), - ("w", VIRTUAL_KEY('W' as _)), - ("x", VIRTUAL_KEY('X' as _)), - ("y", VIRTUAL_KEY('Y' as _)), - ("z", VIRTUAL_KEY('Z' as _)), - ("lwin", VK_LWIN), - ("rwin", VK_RWIN), - ("apps", VK_APPS), - ("sleep", VK_SLEEP), - ("numpad0", VK_NUMPAD0), - ("numpad1", VK_NUMPAD1), - ("numpad2", VK_NUMPAD2), - ("numpad3", VK_NUMPAD3), - ("numpad4", VK_NUMPAD4), - ("numpad5", VK_NUMPAD5), - ("numpad6", VK_NUMPAD6), - ("numpad7", VK_NUMPAD7), - ("numpad8", VK_NUMPAD8), - ("numpad9", VK_NUMPAD9), - ("multiply", VK_MULTIPLY), - ("add", VK_ADD), - ("separator", VK_SEPARATOR), - ("subtract", VK_SUBTRACT), - ("decimal", VK_DECIMAL), - ("divide", VK_DIVIDE), - ("f1", VK_F1), - ("f2", VK_F2), - ("f3", VK_F3), - ("f4", VK_F4), - ("f5", VK_F5), - ("f6", VK_F6), - ("f7", VK_F7), - ("f8", VK_F8), - ("f9", VK_F9), - ("f10", VK_F10), - ("f11", VK_F11), - ("f12", VK_F12), - ("f13", VK_F13), - ("f14", VK_F14), - ("f15", VK_F15), - ("f16", VK_F16), - ("f17", VK_F17), - ("f18", VK_F18), - ("f19", VK_F19), - ("f20", VK_F20), - ("f21", VK_F21), - ("f22", VK_F22), - ("f23", VK_F23), - ("f24", VK_F24), - ("numlock", VK_NUMLOCK), - ("scroll", VK_SCROLL), - ("lshift", VK_LSHIFT), - ("rshift", VK_RSHIFT), - ("lcontrol", VK_LCONTROL), - ("rcontrol", VK_RCONTROL), - ("lmenu", VK_LMENU), - ("rmenu", VK_RMENU), - ("browser_back", VK_BROWSER_BACK), - ("browser_forward", VK_BROWSER_FORWARD), - ("browser_refresh", VK_BROWSER_REFRESH), - ("browser_stop", VK_BROWSER_STOP), - ("browser_search", VK_BROWSER_SEARCH), - ("browser_favorites", VK_BROWSER_FAVORITES), - ("browser_home", VK_BROWSER_HOME), - ("volume_mute", VK_VOLUME_MUTE), - ("volume_down", VK_VOLUME_DOWN), - ("volume_up", VK_VOLUME_UP), - ("media_next_track", VK_MEDIA_NEXT_TRACK), - ("media_prev_track", VK_MEDIA_PREV_TRACK), - ("media_stop", VK_MEDIA_STOP), - ("media_play_pause", VK_MEDIA_PLAY_PAUSE), - ("launch_mail", VK_LAUNCH_MAIL), - ("launch_media_select", VK_LAUNCH_MEDIA_SELECT), - ("launch_app1", VK_LAUNCH_APP1), - ("launch_app2", VK_LAUNCH_APP2), - ("oem_1", VK_OEM_1), - ("oem_plus", VK_OEM_PLUS), - ("oem_comma", VK_OEM_COMMA), - ("oem_minus", VK_OEM_MINUS), - ("oem_period", VK_OEM_PERIOD), - ("oem_2", VK_OEM_2), - ("oem_3", VK_OEM_3), - ("[", VK_OEM_4), - ("oem_5", VK_OEM_5), - ("]", VK_OEM_6), - ("oem_7", VK_OEM_7), - ("oem_8", VK_OEM_8), - ("oem_102", VK_OEM_102), - ("processkey", VK_PROCESSKEY), - ("packet", VK_PACKET), - ("attn", VK_ATTN), - ("crsel", VK_CRSEL), - ("exsel", VK_EXSEL), - ("ereof", VK_EREOF), - ("play", VK_PLAY), - ("zoom", VK_ZOOM), - ("noname", VK_NONAME), - ("pa1", VK_PA1), - ("oem_clear", VK_OEM_CLEAR), - ] - .iter() - .map(|&(k, v)| (String::from(k).to_lowercase(), v.0 as i32)) - .collect() -}); - -pub static VK_SYMBOL_MAP_INV: Lazy> = - Lazy::new(|| VK_SYMBOL_MAP.iter().map(|(k, &v)| (v, k.clone())).collect()); diff --git a/practice-tool/src/widgets/cycle_speed.rs b/practice-tool/src/widgets/cycle_speed.rs index 50f6794..ec05939 100644 --- a/practice-tool/src/widgets/cycle_speed.rs +++ b/practice-tool/src/widgets/cycle_speed.rs @@ -50,6 +50,10 @@ impl ReadWrite for CycleSpeed { } } -pub(crate) fn cycle_speed(values: &[f32], ptr: PointerChain, key: Key) -> Box { - Box::new(StoreValue::new(CycleSpeed::new(values, ptr), Some(key))) +pub(crate) fn cycle_speed( + values: &[f32], + ptr: PointerChain, + key: Option, +) -> Box { + Box::new(StoreValue::new(CycleSpeed::new(values, ptr), key)) } diff --git a/practice-tool/src/widgets/souls.rs b/practice-tool/src/widgets/souls.rs index ce82848..ab4759b 100644 --- a/practice-tool/src/widgets/souls.rs +++ b/practice-tool/src/widgets/souls.rs @@ -35,6 +35,6 @@ impl ReadWrite for Souls { } } -pub(crate) fn souls(amount: u32, ptr: PointerChain, key: Key) -> Box { - Box::new(StoreValue::new(Souls::new(amount, ptr), Some(key))) +pub(crate) fn souls(amount: u32, ptr: PointerChain, key: Option) -> Box { + Box::new(StoreValue::new(Souls::new(amount, ptr), key)) } diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index 1c46ffd..d1f6ada 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs @@ -1,4 +1,4 @@ -use std::fs::File; +use std::fs::{self, File}; use std::io::{Read, Write}; use std::path::PathBuf; @@ -28,8 +28,8 @@ pub(crate) fn dist() -> Result<()> { return Err("cargo build failed".into()); } - std::fs::remove_dir_all(dist_dir()).ok(); - std::fs::create_dir_all(dist_dir())?; + fs::remove_dir_all(dist_dir()).ok(); + fs::create_dir_all(dist_dir())?; let mut zip = ZipWriter::new(File::create(dist_dir().join("jdsd_dsiii_practice_tool.zip"))?); let file_options = FileOptions::default().compression_method(CompressionMethod::Deflated); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 7afb2f5..880de6b 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1,4 +1,5 @@ mod codegen; +mod dist; use std::ffi::OsStr; use std::fs::File; @@ -7,8 +8,6 @@ use std::path::{Path, PathBuf}; use std::process::Command; use std::{env, iter}; -mod dist; - type DynError = Box; type Result = std::result::Result;