Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Raidcore Nexus
https://github.com/zerthox/nexus-rs
Admin
Rust bindings for Raidcore Nexus.
Tokens:
32,190
Snippets:
397
Trust Score:
7.8
License:
MIT
Update:
2 months ago
Context
Chat
Benchmark
71
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Full Quick Access Integration Example Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/quick-access.md Demonstrates registering a keybind, adding a shortcut, and attaching a context menu in a single setup function. ```rust use nexus::{ quick_access::{add, add_context_menu, notify, quick_access_callback}, keybind::{register_keybind_with_string, keybind_handler}, imgui::Window, }; fn setup_quick_access() { // Register keybind let keybind_handler = keybind_handler!(|id, is_release| { if !is_release { notify("MY_SHORTCUT"); } }); register_keybind_with_string( "TOGGLE_UI", keybind_handler, "ALT+SHIFT+U" ).revert_on_unload(); // Add quick access shortcut add( "MY_SHORTCUT", "MY_ICON_ACTIVE", "MY_ICON_INACTIVE", "TOGGLE_UI" ).revert_on_unload(); // Add context menu let context_callback = quick_access_callback!(|ui| { if ui.menu_item("Toggle Settings") { // Toggle settings window } if ui.menu_item("About") { // Show about dialog } }); add_context_menu("MY_SHORTCUT", context_callback); } ``` -------------------------------- ### Define addon dependencies Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/API-OVERVIEW.md Example configuration for selecting specific features in Cargo.toml. ```toml [dependencies] nexus = { git = "...", features = ["rtapi", "log"] } ``` -------------------------------- ### texture_receive! Usage Example Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/textures.md Example of using the macro to handle texture loading results and logging the outcome. ```rust use nexus::texture::{load_texture_from_file, texture_receive}; use nexus::log::{log, LogLevel}; let callback = texture_receive!(|id, texture| { match texture { Some(tex) => log(LogLevel::Info, "Textures", format!("Loaded {} ({}x{})", id, tex.width, tex.height)), None => log(LogLevel::Warning, "Textures", format!("Failed to load {}", id)), } }); load_texture_from_file("MY_ICON", "icon.png", Some(callback)); ``` -------------------------------- ### Integrated Logging and Alerting Example Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/logging-alerts.md Demonstrates combining logging and alerts within a main loop context. ```rust use nexus::{log::{log, LogLevel}, alert::send_alert}; fn main_loop() { if let Some(error) = check_for_error() { log(LogLevel::Warning, "My Addon", format!("Error: {}", error)); send_alert("An error occurred!"); } } ``` -------------------------------- ### Verify RealTime API Signature Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Example usage for verifying the RealTime API signature. ```rust assert_eq!(RealTimeApi::SIG, -0x12345678); // Example signature ``` -------------------------------- ### Complete Path Initialization Example Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/paths.md Demonstrates retrieving multiple directory paths and performing basic file system operations. ```rust use nexus::paths::{get_game_dir, get_addon_dir, get_common_dir}; use std::fs; fn initialize_addon() -> std::io::Result<()> { // Get directories let game_dir = get_game_dir()?; let addon_dir = get_addon_dir("my_addon")?; let common_dir = get_common_dir()?; // Create addon directory if needed fs::create_dir_all(&addon_dir)?; // Load configuration let config_path = addon_dir.join("config.json"); if !config_path.exists() { // Create default config fs::write(&config_path, "{}")?; } // Access shared resources let shared_resources = common_dir.join("resources"); if shared_resources.exists() { // Use shared resources } Ok(()) } ``` -------------------------------- ### Attack Combo Example (Rust) Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/game-binds.md Demonstrates combining multiple bind operations to perform a sequence of actions. ```rust use nexus::gamebind::{is_bound, press, release, invoke_async}; fn perform_attack_combo() { if is_bound("action_button_1") { press("action_button_1"); std::thread::sleep(std::time::Duration::from_millis(200)); release("action_button_1"); std::thread::sleep(std::time::Duration::from_millis(300)); invoke_async("action_button_2", 100); } } ``` -------------------------------- ### Full resource sharing example Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/data-link.md Demonstrates initializing and reading a custom struct via the data link system. ```rust use nexus::data_link::{share_resource, read_resource}; struct PlayerStats { level: u8, experience: u32, } fn initialize_stats() { let ptr: *mut PlayerStats = share_resource("PLAYER_STATS"); unsafe { (*ptr).level = 80; (*ptr).experience = 0; } } fn read_stats() -> Option<()> { let stats: Option<PlayerStats> = unsafe { read_resource("PLAYER_STATS") }; if let Some(s) = stats { println!("Level: {}", s.level); } Some(()) } ``` -------------------------------- ### Implement RealTime API Usage Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Complete example demonstrating how to access the RealTime API, check activity status, and read group and player data. ```rust use nexus::rtapi::{RealTimeApi, GroupType}; use nexus::log::{log, LogLevel}; fn check_squad_state() { if let Some(rtapi) = RealTimeApi::get() { if !rtapi.is_active() { log(LogLevel::Warning, "My Addon", "RealTime API not active"); return; } if let Some(group) = rtapi.read_group() { let squad_type = match group.group_type { Ok(GroupType::Solo) => "Solo", Ok(GroupType::Squad) => "Squad", Ok(GroupType::RaidSquad) => "Raid Squad", Err(_) => "Unknown", }; log( LogLevel::Info, "My Addon", format!("Squad type: {}, Members: {}", squad_type, group.members.len()) ); } if let Some(player) = rtapi.read_player() { log( LogLevel::Debug, "My Addon", format!("Player health: {} / {}", player.current_health, player.max_health) ); } } } ``` -------------------------------- ### Usage of send_alert() Function Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/logging-alerts.md Examples of triggering user-facing notifications. ```rust use nexus::alert::send_alert; send_alert("Addon loaded successfully!"); send_alert("Action completed!"); ``` -------------------------------- ### Localization usage example Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/localization.md Demonstrates setting custom translations and rendering UI elements using both active and specific language translations. ```rust use nexus::localization::{translate, translate_to, set_translation}; fn setup_localization() { // Set custom translations set_translation("MY_ADDON_TITLE", "en", "My Addon"); set_translation("MY_ADDON_TITLE", "de", "Mein Addon"); set_translation("MY_ADDON_TITLE", "fr", "Mon Extension"); set_translation("BUTTON_OK", "en", "OK"); set_translation("BUTTON_OK", "de", "OK"); set_translation("BUTTON_OK", "fr", "OK"); } fn render_ui() { // Use current language if let Some(title) = translate("MY_ADDON_TITLE") { ui.text(&title); } if let Some(ok_text) = translate("BUTTON_OK") { if ui.button(&ok_text) { // Handle OK } } } fn render_multilingual() { // Render specific languages if let Some(german) = translate_to("MY_ADDON_TITLE", "de") { ui.text(&german); } } ``` -------------------------------- ### Configure Addon with Export Macro Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/configuration.md Examples of using the export! macro for minimal, complete, and logging-enabled addon configurations. ```rust use nexus::export; export! { name: "My Addon", signature: -0x12345678, } ``` ```rust use nexus::{export, AddonFlags, UpdateProvider}; export! { name: "My Addon", signature: -0x12345678, load: || { // Initialization code }, unload: || { // Cleanup code }, flags: AddonFlags::IsVolatile, provider: UpdateProvider::GitHub, update_link: "https://github.com/user/repo/releases/latest", } ``` ```rust #[cfg(feature = "log")] use nexus::export; #[cfg(feature = "log")] export! { name: "My Addon", signature: -0x12345678, log_filter: "my_addon=debug", load: || { use log::info; info!("Addon loaded"); }, } ``` -------------------------------- ### Register a keybind with a handler Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/keybinds.md Example showing the registration of a keybind using a handler created by the keybind_handler! macro. ```rust use nexus::keybind::{register_keybind_with_string, keybind_handler}; use nexus::log::{log, LogLevel}; let handler = keybind_handler!(|id, is_release| { log( LogLevel::Info, "My Addon", format!( "Keybind '{}' {}", id, if is_release { "released" } else { "pressed" } ) ); }); register_keybind_with_string("TOGGLE_UI", handler, "ALT+SHIFT+T") .revert_on_unload(); ``` -------------------------------- ### Implement font_receive! callback Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/fonts.md Example of wrapping a closure as a RawFontReceiveCallback and using it with add_font_from_file. ```rust use nexus::font::{add_font_from_file, font_receive}; let callback = font_receive!(|id, font_ptr| { if !font_ptr.is_null() { // Font is loaded and ready } }); add_font_from_file("MY_FONT", "myfont.ttf", 14.0, callback); ``` -------------------------------- ### Get RealTimeApi Instance Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Retrieves the API instance if the addon is loaded. ```rust pub fn get() -> Option<Self> ``` ```rust use nexus::rtapi::RealTimeApi; if let Some(rtapi) = RealTimeApi::get() { if let Some(player) = rtapi.read_player() { // Access player data } } ``` -------------------------------- ### Enable features in Cargo.toml Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/configuration.md Example of enabling specific optional features like logging and serialization support. ```toml [dependencies] nexus = { git = "https://github.com/zerthox/nexus-rs", features = ["log", "serde"] } ``` -------------------------------- ### get_game_dir() Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/paths.md Retrieves the path to the Guild Wars 2 game installation directory. ```APIDOC ## get_game_dir() ### Description Returns the PathBuf to the Guild Wars 2 game installation directory. ### Signature `pub fn get_game_dir() -> io::Result<PathBuf>` ### Returns - **PathBuf** - The path to the game installation directory. ### Errors - **io::Error** - Returned if the path is invalid or cannot be converted. ``` -------------------------------- ### Usage of register_wnd_proc Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/wnd-proc.md Example showing how to register a callback using the wnd_proc_callback macro and ensure it reverts on unload. ```rust use nexus::wnd_proc::{register_wnd_proc, wnd_proc_callback}; let callback = wnd_proc_callback!(|msg, wparam, lparam| { // Handle WM_* message false // Return true to consume message }); register_wnd_proc(callback).revert_on_unload(); ``` -------------------------------- ### Retrieve Game Directory Path Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/paths.md Returns the PathBuf for the Guild Wars 2 installation directory. Throws an io::Error if the path is invalid. ```rust pub fn get_game_dir() -> io::Result<PathBuf> ``` ```rust use nexus::paths::get_game_dir; let game_dir = get_game_dir()?; println!("Game directory: {}", game_dir.display()); let gfxsettings = game_dir.join("local.dat"); ``` -------------------------------- ### Usage of log() Function Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/logging-alerts.md Examples of logging messages with different severity levels and custom color formatting. ```rust use nexus::log::{log, LogLevel}; log(LogLevel::Info, "My Addon", "Initialization complete"); log(LogLevel::Warning, "My Addon", "Performance warning detected"); log(LogLevel::Debug, "My Addon", format!("Value: {}", value)); // With coloring log(LogLevel::Info, "My Addon", "<c=#FF0000>Error detected</c>"); ``` -------------------------------- ### Add a font from a file Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/fonts.md Defines the function signature for adding a font from a file and provides an example of usage. ```rust pub fn add_font_from_file( identifier: impl AsRef<str>, file: impl AsRef<Path>, size: f32, callback: RawFontReceiveCallback, ) -> Revertible<impl Fn() + Send + Sync + Clone + 'static> ``` ```rust use nexus::font::{add_font_from_file, font_receive}; let callback = font_receive!(|id, font| { // Font loaded and ready to use }); add_font_from_file("CUSTOM_FONT", "fonts/myfont.ttf", 16.0, callback) .revert_on_unload(); ``` -------------------------------- ### Register a WndProc callback Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/wnd-proc.md Example usage of the wnd_proc_callback! macro to handle specific Windows messages and register the callback. ```rust use nexus::wnd_proc::{register_wnd_proc, wnd_proc_callback}; let callback = wnd_proc_callback!(|msg, wparam, lparam| { match msg { 0x0100 => { // WM_KEYDOWN let key = wparam as u32; // Handle key true // Consume message }, 0x0200 => { // WM_MOUSEMOVE false // Don't consume }, _ => false, } }); register_wnd_proc(callback).revert_on_unload(); ``` -------------------------------- ### Add a font from a resource Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/fonts.md Defines the function signature for adding a font from a resource and provides an example of usage. ```rust pub fn add_font_from_resource( identifier: impl AsRef<str>, resource_id: u32, module: HMODULE, size: f32, callback: RawFontReceiveCallback, ) -> Revertible<impl Fn() + Send + Sync + Clone + 'static> ``` ```rust use nexus::font::add_font_from_resource; let callback = font_receive!(|id, font| { // Font loaded }); add_font_from_resource( "EMBEDDED_FONT", IDR_MYFONT, unsafe { windows::Win32::System::LibraryLoader::GetModuleHandleA(None)? }, 14.0, callback ).revert_on_unload(); ``` -------------------------------- ### Request a font Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/fonts.md Defines the function signature for requesting a font and provides an example of usage with a callback. ```rust pub fn get_font( identifier: impl AsRef<str>, callback: RawFontReceiveCallback, ) ``` ```rust use nexus::font::{get_font, font_receive}; let callback = font_receive!(|id, font_ptr| { // Font is now available }); get_font("MY_FONT", callback); ``` -------------------------------- ### Add a font from memory Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/fonts.md Defines the function signature for adding a font from memory and provides an example of usage. ```rust pub fn add_font_from_memory( identifier: impl AsRef<str>, data: impl AsRef<[u8]>, size: f32, callback: RawFontReceiveCallback, ) -> Revertible<impl Fn() + Send + Sync + Clone + 'static> ``` ```rust use nexus::font::add_font_from_memory; let font_data = include_bytes!("myfont.ttf"); let callback = font_receive!(|id, font| { // Font loaded }); add_font_from_memory("BUILTIN_FONT", font_data, 18.0, callback) .revert_on_unload(); ``` -------------------------------- ### Create a minimal addon Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/README.md Use the export macro to define your addon and register a basic ImGui window for rendering. ```rust use nexus::{ export, gui::{register_render, render, RenderType}, imgui::Window, }; export! { name: "My Addon", signature: -0x12345678, load: || { register_render(RenderType::Render, render!(|ui| { Window::new("My Window").build(ui, || { ui.text("Hello World!"); }); })).revert_on_unload(); }, } ``` -------------------------------- ### Get Texture Dimensions Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/textures.md Retrieve the texture width and height formatted for ImGui. ```rust pub fn size(&self) -> [f32; 2] ``` ```rust let texture = /* loaded texture */; let [w, h] = texture.size(); ``` -------------------------------- ### Get NonNull Pointer Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Retrieves the underlying data as a NonNull pointer wrapper. ```rust pub const fn as_non_null(&self) -> NonNull<RealTimeData> ``` -------------------------------- ### QuickAccessApi Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Integrates with the quick access menu. ```APIDOC ## QuickAccessApi ### Methods - **add** (RawQuickAccessAddShortcut) - Adds a shortcut icon to quick access. - **remove** (RawQuickAccessGeneric) - Removes a shortcut. - **notify** (RawQuickAccessGeneric) - Sends notification to shortcut. - **add_context_menu** (RawQuickAccessAddContextMenu2) - Adds right-click menu. - **remove_context_menu** (RawQuickAccessGeneric) - Removes context menu. ``` -------------------------------- ### Resize a font Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/fonts.md Defines the function signature for resizing a font and provides an example of usage. ```rust pub fn resize_font(identifier: impl AsRef<str>, size: f32) ``` ```rust use nexus::font::resize_font; resize_font("CUSTOM_FONT", 20.0); ``` -------------------------------- ### Release a font Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/fonts.md Defines the function signature for releasing a font and provides an example of usage. ```rust pub fn release_font( identifier: impl AsRef<str>, callback: RawFontReceiveCallback, ) ``` ```rust use nexus::font::release_font; release_font("MY_FONT", callback); ``` -------------------------------- ### Import ImGui components Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/gui-rendering.md Accessing ImGui-rs components through the nexus::imgui module. ```rust use nexus::imgui::{Window, CollapsingHeader, Button}; ``` -------------------------------- ### Registering UI with ImGui Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/README.md Uses the render! macro to define a UI window and registers it with the framework. Ensure the window state is tracked to handle closing correctly. ```rust use nexus::{gui::*, imgui::*}; let mut window_open = true; let render = render!(|ui| { let mut open = window_open; Window::new("Settings").opened(&mut open).build(ui, || { ui.text("Addon Settings"); if ui.button("Save") { // Save settings } }); window_open = open; }); register_render(RenderType::Render, render).revert_on_unload(); register_close_on_escape("Settings", &mut window_open); ``` -------------------------------- ### Get Scaled Texture Dimensions Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/textures.md Calculate texture dimensions scaled by a specific factor. ```rust pub fn size_resized(&self, factor: f32) -> [f32; 2] ``` ```rust let texture = /* loaded texture */; let half_size = texture.size_resized(0.5); ``` -------------------------------- ### add(identifier, texture_on, texture_off, keybind) Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/quick-access.md Adds an icon to the quick access menu. When clicked, the associated keybind is invoked. ```APIDOC ## fn add(identifier, texture_on, texture_off, keybind) ### Description Adds an icon to the quick access menu. When clicked, the associated keybind is invoked. ### Parameters - **identifier** (impl AsRef<str>) - Required - Unique shortcut identifier - **texture_on** (impl AsRef<str>) - Required - Texture ID for active state - **texture_off** (impl AsRef<str>) - Required - Texture ID for inactive state - **keybind** (impl AsRef<str>) - Required - Keybind identifier to invoke ### Returns - **Revertible** - Returns a Revertible object for automatic removal on addon unload. ``` -------------------------------- ### Get ImGui Texture ID Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/textures.md Retrieve the TextureId required for ImGui image rendering functions. ```rust pub fn id(&self) -> imgui::TextureId ``` ```rust use nexus::imgui::Image; let texture = /* loaded texture */; Image::new(texture.id(), texture.size()).build(ui); ``` -------------------------------- ### Get Raw Pointer to Data Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Accesses the underlying data structure via a raw pointer. ```rust pub const fn as_ptr(&self) -> *const RealTimeData ``` ```rust let ptr = rtapi.as_ptr(); ``` -------------------------------- ### Register and Render Custom Fonts in Rust Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/fonts.md Demonstrates loading fonts from files using add_font_from_file and applying them during UI rendering with ui.fonts_and_push_custom_font. ```rust use nexus::{ font::{add_font_from_file, font_receive, resize_font}, gui::{register_render, render, RenderType}, imgui::Window, }; fn setup_fonts() { // Load custom font let callback = font_receive!(|id, font_ptr| { if !font_ptr.is_null() { // Font is ready } }); add_font_from_file("TITLE_FONT", "fonts/title.ttf", 24.0, callback) .revert_on_unload(); add_font_from_file("BODY_FONT", "fonts/body.ttf", 14.0, font_receive!(|_, _| {})) .revert_on_unload(); } fn render_with_fonts() { let render = render!(|ui| { Window::new("Font Demo").build(ui, || { // Push custom font if available if let Some(font) = ui.fonts_and_push_custom_font("TITLE_FONT") { ui.text("Custom Title Font"); font.end(); } ui.text("Regular text"); }); }); register_render(RenderType::Render, render).revert_on_unload(); } ``` -------------------------------- ### Add Context Menu Usage Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/quick-access.md Attaches a right-click menu to a shortcut using an ImGui callback. ```rust use nexus::quick_access::{add_context_menu, quick_access_callback}; let callback = quick_access_callback!(|ui| { if ui.menu_item("Settings") { // Open settings } if ui.menu_item("About") { // Show about dialog } }); add_context_menu("ADDON_TOGGLE", callback); ``` -------------------------------- ### Define Nexus Addon Source: https://github.com/zerthox/nexus-rs/blob/main/README.md Use the nexus::export! macro to define the addon entry point and register GUI rendering callbacks. ```rust use nexus::{ gui::{register_render, render, RenderType}, imgui::Window, }; nexus::export! { name: "My Addon", signature: -0x12345678, load: || { register_render(RenderType::Render, render!(|ui| { Window::new("My Window").build(ui, || { ui.text("Hello World"); }); })); }, } ``` -------------------------------- ### RendererApi Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Manages ImGui rendering callbacks for custom UI elements. ```APIDOC ## RendererApi ### Methods - **register** (RawGuiAddRender) - Registers a new render callback. - **deregister** (RawGuiRemRender) - Removes a render callback. ``` -------------------------------- ### PathApi Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Provides file system access for addon and game directories. ```APIDOC ## PathApi ### Methods - **get_game_dir** (RawGetGameDir) - Returns the game installation directory. - **get_addon_dir** (RawGetAddonDir) - Returns addon-specific directory. - **get_common_dir** (RawGetCommonDir) - Returns common addon directory. ``` -------------------------------- ### Configure default panic features Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/API-OVERVIEW.md Default settings for panic handling behavior. ```text panic=true, panic_trace=true, panic_msgbox=true ``` -------------------------------- ### Callback Registration Patterns Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/API-OVERVIEW.md Demonstrates three ways to manage callback lifecycles: automatic cleanup on unload, manual reversion, and manual leakage for custom management. ```rust // Pattern 1: Auto-cleanup on unload register_render(RenderType::Render, callback).revert_on_unload(); // Pattern 2: Manual cleanup let revertible = register_render(RenderType::Render, callback); // Later... revertible.revert(); // Pattern 3: Leak (manual management) register_render(RenderType::Render, callback).leak(); // Call unregister_render() manually ``` -------------------------------- ### InputBindsApi Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Handles keybind registration and programmatic invocation. ```APIDOC ## InputBindsApi ### Methods - **invoke** (RawKeybindInvoke) - Invokes a keybind programmatically. - **register_with_string** (RawKeybindRegisterWithString) - Registers keybind from string format. - **register_with_struct** (RawKeybindRegisterWithStruct) - Registers keybind from struct. - **deregister** (RawKeybindDeregister) - Unregisters a keybind. ``` -------------------------------- ### Accessing the API Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md How to retrieve the global API instance for use within an addon. ```APIDOC ## Accessing the API All addon code uses `AddonApi::get()` to access the global API instance: ```rust use nexus::AddonApi; fn my_function() { let api = AddonApi::get(); // Use api.ui, api.event, api.texture, etc. } ``` ``` -------------------------------- ### AddonApi::get Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/README.md Access the Nexus API singleton to interact with core addon functionality. ```APIDOC ## AddonApi::get ### Description Retrieves the singleton instance of the AddonApi to access UI and system functions. ### Usage ```rust use nexus::AddonApi; let api = AddonApi::get(); api.ui.send_alert("Alert message"); ``` ``` -------------------------------- ### Define a GUI render callback with render! Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/gui-rendering.md Wraps a closure as a RawGuiRender callback compatible with Nexus. ```rust render!(|ui| { /* ImGui code */ }) ``` -------------------------------- ### Registering Render Callbacks Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/API-OVERVIEW.md Uses the render! macro to define a callback that receives an ImGui context, then registers it for the Render tier. ```rust let render = render!(|ui| { // ui is the ImGui::Ui context ui.text("Hello"); }); register_render(RenderType::Render, render).revert_on_unload(); ``` -------------------------------- ### Get Reference to Data Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Returns a reference to the underlying data. Note that this may violate aliasing rules due to volatile memory. ```rust pub unsafe fn as_ref(&self) -> &RealTimeData ``` -------------------------------- ### Define Addon Metadata with nexus::export! Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/API-OVERVIEW.md Use the export macro to define addon metadata and lifecycle callbacks. ```rust nexus::export! { name: "My Addon", signature: -0x12345678, load: || { // Initialize addon, register callbacks }, unload: || { // Cleanup (optional) }, } ``` -------------------------------- ### GameBindApi Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Provides game command binding for in-game actions. ```APIDOC ## GameBindApi ### Methods - **press_async** (RawGamebindPressAsync) - Asynchronously presses game bind keys. - **release_async** (RawGamebindReleaseAsync) - Asynchronously releases game bind keys. - **invoke_async** (RawGamebindInvokeAsync) - Asynchronously invokes game bind. - **press** (RawGamebindPress) - Presses game bind keys. - **release** (RawGamebindRelease) - Releases game bind keys. - **is_bound** (RawGamebindIsBound) - Checks if game bind is configured. ``` -------------------------------- ### RealTimeApi::get() Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Retrieves an instance of the RealTimeApi if the addon is loaded. ```APIDOC ## RealTimeApi::get() ### Description Retrieves the RealTimeApi instance. Returns Some(RealTimeApi) if the RealTime API addon is loaded, otherwise returns None. ### Signature `pub fn get() -> Option<Self>` ``` -------------------------------- ### Configure Log Filters in export! Macro Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/configuration.md Example usage of the log_filter field within the export! macro to set specific logging levels for addon components. ```rust export! { name: "My Addon", signature: -0x12345678, log_filter: "my_addon=info", log_filter: "my_addon::network=debug", log_filter: "debug,my_addon::io=trace", } ``` -------------------------------- ### Add Context Menu Function Definition Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/quick-access.md Defines the signature for adding an ImGui context menu to a shortcut. ```rust pub fn add_context_menu( identifier: impl AsRef<str>, callback: RawQuickAccessCallback, ) ``` -------------------------------- ### register_render() Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/gui-rendering.md Registers a render callback to be executed at a specific timing within the ImGui frame lifecycle. ```APIDOC ## register_render(render_type, callback) ### Description Registers a callback function to be executed during the rendering process. Returns a Revertible object for automatic unregistration. ### Parameters - **render_type** (RenderType) - Required - The timing phase for the callback (PreRender, Render, PostRender, OptionsRender). - **callback** (RawGuiRender) - Required - The C-unwind extern function to execute. ### Returns - **Revertible** - An object that handles automatic unregistration on addon unload. ``` -------------------------------- ### Accessing the Nexus API Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/README.md Use the AddonApi singleton to interact with the Nexus framework. Ensure the crate is imported correctly before calling API methods. ```rust use nexus::AddonApi; let api = AddonApi::get(); api.ui.send_alert("Alert message"); ``` -------------------------------- ### send_to_game(message: u32, wparam: usize, lparam: isize) Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/wnd-proc.md Sends a message directly to the game window, bypassing other hooks. ```APIDOC ## send_to_game ### Description Sends a message directly to the game window, bypassing other hooks. ### Parameters - **message** (u32) - Required - Windows message ID (WM_*) - **wparam** (usize) - Required - Word parameter - **lparam** (isize) - Required - Long parameter ``` -------------------------------- ### Add Shortcut Function Definition Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/quick-access.md Defines the signature for adding a new icon to the quick access menu. ```rust pub fn add( identifier: impl AsRef<str>, texture_on: impl AsRef<str>, texture_off: impl AsRef<str>, keybind: impl AsRef<str>, ) -> Revertible<impl Fn() + Send + Sync + Clone + 'static> ``` -------------------------------- ### press(identifier) Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/game-binds.md Immediately presses the keys associated with the specified game bind identifier. ```APIDOC ## fn press(identifier: impl AsRef<str>) ### Description Immediately presses the keys associated with the game bind. ### Parameters - **identifier** (impl AsRef<str>) - Required - Game bind identifier ### Usage ```rust use nexus::gamebind::press; press("dodge"); ``` ``` -------------------------------- ### read_game() Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Retrieves the current game data snapshot, including build, map, and version information. ```APIDOC ## read_game() ### Description Returns the current game data snapshot if active, containing game build, map, and version information. ### Signature `pub fn read_game(&self) -> Option<GameData>` ``` -------------------------------- ### Add Shortcut Usage Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/quick-access.md Registers a new shortcut that invokes a keybind when clicked. ```rust use nexus::quick_access::add; add("ADDON_TOGGLE", "ADDON_ICON_ON", "ADDON_ICON_OFF", "TOGGLE_UI") .revert_on_unload(); ``` -------------------------------- ### press_async(identifier) Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/game-binds.md Asynchronously presses the keys associated with the game bind, returning immediately. ```APIDOC ## fn press_async(identifier: impl AsRef<str>) ### Description Asynchronously presses the keys. Returns immediately without waiting. ### Parameters - **identifier** (impl AsRef<str>) - Required - Game bind identifier ``` -------------------------------- ### UiApi Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Provides user interface capabilities including alerts and window management. ```APIDOC ## UiApi ### Methods - **send_alert** (RawAlertNotify) - Sends a short-lived alert to the user. - **register_close_on_escape** (RawGuiRegisterCloseOnEscape) - Registers a window to be toggled on escape. - **deregister_close_on_escape** (RawGuiDeregisterCloseOnEscape) - Removes escape key toggle. ``` -------------------------------- ### Raw Type Definitions Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/quick-access.md FFI-compatible type definitions for quick access callbacks and registration. ```rust pub type RawQuickAccessCallback = extern "C-unwind" fn(); pub type RawQuickAccessGeneric = unsafe extern "C-unwind" fn(identifier: *const c_char); pub type RawQuickAccessAddShortcut = unsafe extern "C-unwind" fn( identifier: *const c_char, texture_on: *const c_char, texture_off: *const c_char, keybind: *const c_char, ); pub type RawQuickAccessAddContextMenu2 = unsafe extern "C-unwind" fn( identifier: *const c_char, callback: RawQuickAccessCallback, ); ``` -------------------------------- ### render! Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/gui-rendering.md The render! macro wraps a closure as a RawGuiRender callback, which is a function pointer compatible with the Nexus GUI system. ```APIDOC ## render! ### Description Wraps a closure as a `RawGuiRender` callback. The closure receives a reference to the ImGui `Ui` context and must capture variables with `move` semantics or be `'static`. ### Syntax `render!(|ui| { /* ImGui code */ })` ### Returns `RawGuiRender` - A function pointer compatible with Nexus. ### Usage ```rust use nexus::gui::{register_render, RenderType, render}; use nexus::imgui::Window; let callback = render!(|ui| { Window::new("Example").build(ui, || { ui.text("This is rendered!"); if ui.button("Click Me") { // Handle button press } }); }); register_render(RenderType::Render, callback).revert_on_unload(); ``` ``` -------------------------------- ### Loading Resources Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/README.md Loads a texture from a file path and retrieves its ID and size for use in ImGui rendering. ```rust use nexus::texture::*; let texture = get_texture_or_create_from_file( "MY_ICON", "textures/icon.png" )?; // Use in ImGui ui.image(texture.id(), texture.size()); ``` -------------------------------- ### RealTimeApi::as_ref() Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Returns a reference to the underlying data. ```APIDOC ## RealTimeApi::as_ref() ### Description Returns a reference to the underlying data. Note: The returned reference may violate aliasing rules due to volatile memory. ### Signature `pub unsafe fn as_ref(&self) -> &RealTimeData` ``` -------------------------------- ### Retrieve Addon Directory Path Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/paths.md Returns the PathBuf for a specific addon directory. Passing an empty string or null returns the base addons directory. ```rust pub fn get_addon_dir(name: impl AsRef<str>) -> io::Result<PathBuf> ``` ```rust use nexus::paths::get_addon_dir; let addon_dir = get_addon_dir("my_addon")?; let config_file = addon_dir.join("config.json"); // Get base addons directory let addons_base = get_addon_dir("")?; ``` -------------------------------- ### Load texture from URL Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/textures.md Downloads and loads a texture from a remote host and endpoint. ```rust pub fn get_texture_or_create_from_url( identifier: impl AsRef<str>, remote: impl AsRef<str>, endpoint: impl AsRef<str>, ) -> Option<Texture> ``` ```rust use nexus::texture::get_texture_or_create_from_url; let texture = get_texture_or_create_from_url( "GW2_ITEM_ICON", "https://render.guildwars2.com", "/file/943538394A94A491C8632FBEF6203C2013443555/102478.png" )?; ``` -------------------------------- ### release_async(identifier) Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/game-binds.md Asynchronously releases previously pressed keys for the game bind. ```APIDOC ## fn release_async(identifier: impl AsRef<str>) ### Description Asynchronously releases previously pressed keys. ### Parameters - **identifier** (impl AsRef<str>) - Required - Game bind identifier ``` -------------------------------- ### AddonApi::get_d3d11_device() Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Retrieves the DirectX 11 device associated with the current swap chain. ```APIDOC ## AddonApi::get_d3d11_device() ### Description Returns the DirectX 11 device associated with the swap chain if it is currently available. ### Signature `pub fn get_d3d11_device(&self) -> Option<ID3D11Device>` ### Usage ```rust let api = AddonApi::get(); if let Some(device) = api.get_d3d11_device() { // Use DirectX 11 device } ``` ``` -------------------------------- ### Implement Function Hooking Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/API-OVERVIEW.md Use the MinHook integration to create, enable, and disable function hooks when the hook feature is enabled. ```rust use nexus::hook::Hook; let original = unsafe { Hook::create(target_fn, hook_fn)? }; original.enable()?; // Later... original.disable()?; ``` -------------------------------- ### export! Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/configuration.md The export! macro is used to define the addon's entry point and configuration. It accepts a set of key-value pairs to configure the addon's name, signature, lifecycle hooks, and update settings. ```APIDOC ## export! ### Description Defines the addon configuration and entry point for the Nexus system. ### Parameters - **name** (string) - Required - The display name of the addon. - **signature** (i32) - Required - A unique identifier for the addon. - **load** (fn) - Optional - A closure or function executed when the addon is loaded. - **unload** (fn) - Optional - A closure or function executed when the addon is unloaded. - **flags** (AddonFlags) - Optional - Configuration flags for the addon (e.g., IsVolatile). - **provider** (UpdateProvider) - Optional - The update provider type (e.g., GitHub). - **update_link** (string) - Optional - The URL for checking updates. - **log_filter** (string) - Optional - The logging filter string for the addon. ``` -------------------------------- ### Define a WndProc callback using the wnd_proc_callback! macro Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/wnd-proc.md Syntax for wrapping a closure into a RawWndProcCallback. ```rust wnd_proc_callback!(|message, wparam, lparam| { /* handler */ }) ``` -------------------------------- ### AddonApi::get() Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Retrieves the global reference to the Nexus AddonApi instance. This must be called after addon initialization. ```APIDOC ## AddonApi::get() ### Description Returns a static reference to the Nexus AddonApi instance. This method will panic if called before the addon's load function has completed. ### Signature `pub fn get() -> &'static Self` ### Usage ```rust use nexus::AddonApi; let api = AddonApi::get(); ``` ``` -------------------------------- ### Read Game Data Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Retrieves the current game build, map, and version information. ```rust pub fn read_game(&self) -> Option<GameData> ``` ```rust if let Some(game) = rtapi.read_game() { println!("Game build: {}", game.game_build); } ``` -------------------------------- ### add_context_menu(identifier, callback) Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/quick-access.md Adds a right-click context menu to the shortcut. ```APIDOC ## fn add_context_menu(identifier, callback) ### Description Adds a right-click context menu to the shortcut. The callback receives an ImGui context for rendering the menu. ### Parameters - **identifier** (impl AsRef<str>) - Required - Shortcut identifier - **callback** (RawQuickAccessCallback) - Required - ImGui callback for menu ``` -------------------------------- ### Load texture from file Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/textures.md Loads a texture from a file path or returns the cached version. ```rust pub fn get_texture_or_create_from_file( identifier: impl AsRef<str>, file: impl AsRef<Path>, ) -> Option<Texture> ``` ```rust use nexus::texture::get_texture_or_create_from_file; use std::path::Path; let texture = get_texture_or_create_from_file( "MY_ICON", "textures/icon.png" )?; ``` -------------------------------- ### Handle File System Errors Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/README.md Propagate and handle io::Error when interacting with file system paths. ```rust use nexus::paths::get_game_dir; match get_game_dir() { Ok(path) => println!("Game dir: {}", path.display()), Err(e) => eprintln!("Failed to get game directory: {}", e), } ``` -------------------------------- ### texture_receive! Macro Syntax Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/textures.md Basic syntax for wrapping a closure as a RawTextureReceiveCallback. ```rust texture_receive!(|identifier, texture| { /* handler */ }) ``` -------------------------------- ### Retrieve Common Addon Directory Path Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/paths.md Returns the PathBuf for the common shared addon directory. ```rust pub fn get_common_dir() -> io::Result<PathBuf> ``` ```rust use nexus::paths::get_common_dir; let common_dir = get_common_dir()?; let shared_config = common_dir.join("shared_settings.json"); ``` -------------------------------- ### Configure RealTime API Feature Flag Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/realtime-api.md Dependency configuration required to enable the rtapi feature. ```toml [dependencies] nexus = { git = "https://github.com/zerthox/nexus-rs", features = ["rtapi"] } ``` -------------------------------- ### GUI Rendering and Management Type Definitions Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/gui-rendering.md Defines the function signatures for GUI rendering callbacks, window escape handling, and ImGui memory management. ```rust pub type RawGuiRender = extern "C-unwind" fn(); pub type RawGuiAddRender = unsafe extern "C-unwind" fn(render_type: RenderType, render_callback: RawGuiRender); pub type RawGuiRemRender = unsafe extern "C-unwind" fn(render_callback: RawGuiRender); pub type RawGuiRegisterCloseOnEscape = unsafe extern "C-unwind" fn(window_name: *const c_char, is_visible: *mut bool); pub type RawGuiDeregisterCloseOnEscape = unsafe extern "C-unwind" fn(window_name: *const c_char); pub type ImguiMalloc = unsafe extern "C" fn(size: usize, user_data: *mut c_void) -> *mut c_void; pub type ImguiFree = unsafe extern "C" fn(ptr: *mut c_void, user_data: *mut c_void); ``` -------------------------------- ### Register Window Procedure Callback Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/wnd-proc.md Defines the function signature for registering a window message callback. ```rust pub fn register_wnd_proc( callback: RawWndProcCallback, ) -> Revertible<impl Fn() + Send + Sync + Clone + 'static> ``` -------------------------------- ### Define AddonVersion structure Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/types.md Represents the versioning scheme for an addon, used in addon definitions. ```rust pub struct AddonVersion { pub major: i16, pub minor: i16, pub build: i16, pub revision: i16, } ``` -------------------------------- ### Accessing the Global Addon API in Rust Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Use AddonApi::get() to retrieve the global API instance. This instance is available throughout the addon lifecycle from load to unload. ```rust use nexus::AddonApi; fn my_function() { let api = AddonApi::get(); // Use api.ui, api.event, api.texture, etc. } ``` -------------------------------- ### Raw keybind type definitions Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/keybinds.md Core type definitions for raw keybind handlers and registration functions. ```rust pub type RawKeybindHandler = extern "C-unwind" fn(identifier: *const c_char, is_release: bool); pub type RawKeybindInvoke = unsafe extern "C-unwind" fn(identifier: *const c_char, is_release: bool); pub type RawKeybindRegisterWithString = unsafe extern "C-unwind" fn( identifier: *const c_char, keybind_handler: RawKeybindHandler, keybind: *const c_char, ); pub type RawKeybindRegisterWithStruct = unsafe extern "C-unwind" fn( identifier: *const c_char, keybind_handler: RawKeybindHandler, keybind: Keybind, ); pub type RawKeybindDeregister = unsafe extern "C-unwind" fn(identifier: *const c_char); ``` -------------------------------- ### TextureApi Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Handles texture loading and management from various sources. ```APIDOC ## TextureApi ### Methods - **get** (RawTextureGet) - Retrieves a cached texture. - **get_or_create_from_file** (RawTextureGetOrCreateFromFile) - Gets or loads from disk. - **get_or_create_from_resource** (RawTextureGetOrCreateFromResource) - Gets or loads from module resource. - **get_or_create_from_url** (RawTextureGetOrCreateFromUrl) - Gets or loads from remote URL. - **get_or_create_from_memory** (RawTextureGetOrCreateFromMemory) - Gets or loads from memory buffer. - **load_from_file** (RawTextureLoadFromFile) - Asynchronously loads from disk. - **load_from_resource** (RawTextureLoadFromResource) - Asynchronously loads from module resource. - **load_from_url** (RawTextureLoadFromUrl) - Asynchronously loads from remote URL. - **load_from_memory** (RawTextureLoadFromMemory) - Asynchronously loads from memory. ``` -------------------------------- ### Subscribe to Events with Macros Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/API-OVERVIEW.md Use event subscription macros to handle type-safe event data and ensure automatic cleanup on unload. ```rust // Type-safe subscription unsafe { event_subscribe!("EVENT" => i32, |data| { // Type inference from pattern }).revert_on_unload(); } ``` -------------------------------- ### Load texture from file Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/textures.md Defines the function signature and usage for loading a texture from a local file path. ```rust pub fn load_texture_from_file( identifier: impl AsRef<str>, file: impl AsRef<Path>, callback: Option<RawTextureReceiveCallback>, ) ``` ```rust use nexus::texture::{load_texture_from_file, texture_receive}; let callback = texture_receive!(|id, texture| { if let Some(tex) = texture { // Use loaded texture } }); load_texture_from_file("MY_TEXTURE", "icon.png", Some(callback)); ``` -------------------------------- ### EventApi Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/api-reference/addon-api.md Manages inter-addon communication through an event system. ```APIDOC ## EventApi ### Methods - **raise** (RawEventRaise) - Raises an event to all subscribers. - **raise_notification** (RawEventRaiseNotification) - Raises an event without payload. - **raise_targeted** (RawEventRaiseTargeted) - Raises an event to a specific addon. - **raise_notification_targeted** (RawEventRaiseNotificationTargeted) - Raises a notification to a specific addon. - **subscribe** (RawEventSubscribe) - Registers an event callback. - **unsubscribe** (RawEventSubscribe) - Removes an event callback. ``` -------------------------------- ### Retrieve game directory path Source: https://github.com/zerthox/nexus-rs/blob/main/_autodocs/API-OVERVIEW.md Returns an io::Result containing the PathBuf for the game directory. ```rust pub fn get_game_dir() -> io::Result<PathBuf> { ... } ```