Giter VIP home page Giter VIP logo

imgui-xeno's Introduction

imgui-xeno: Dear ImGui backend for Xenoblade games

A Dear ImGui backend that leverages NVN to support multiple Switch games.

Main Credits

This implementation is a fork of mp1r-practice-mod.
In particular, it extracts CraftyBoss's original NVN backend for use in other games.

It also includes some workarounds from the Super Mario Odyssey adaptation, made by Amethyst-szs.

Building

This backend should be exported as a static library, for use in other modding projects.
It is not recommended to use this repository as a base.

To get the library, install CMake, then run

make

The shared library (libimgui_xeno.a) can be found in the cmake-build-minsizerel directory.

API usage

The backend is meant to be launcher-agnostic, meaning it can be used on all environments with access to the NNSDK API: Skyline, exlaunch, etc.

To use the library in your project, you might also need to copy the include/ directory.

Example

#include <imgui_xeno.h>
#include <imgui.h>

void ImGuiNewFrameCallback() {}

void ImGuiRenderCallback() {
    // For example, render the demo window
    ImGui::ShowDemoWindow();
}

void ImGuiPreInitCallback() {}
void ImGuiPostInitCallback() {}

// Create a hook with your launcher of choice (e.g. skyline, exlaunch...)
// Replace the function "nvnBootstrapLoader" which has the same signature 
// as this hook.
void* NvnBootstrapHook(const char* name) {
    // get the pointer to the original function
    // (varies between launchers)
    void *originalFunction; 
    
    // let imgui_xeno handle it
    return imgui_xeno_bootstrap_hook(name, originalFunction);
}

int main() {
    // In your main function, initialize the library and register callbacks
    // (Make sure this is called before the nvnBootstrap hook)
    
    // Register any pre-init tasks here
    imgui_xeno_add_on_pre_init(&ImGuiPreInitCallback);
    // Register any new frame tasks here
    imgui_xeno_add_on_new_frame(&ImGuiNewFrameCallback);
    // Initialize the library
    imgui_xeno_init(&ImGuiPostInitCallback, &ImGuiRenderCallback);
    return 0;
}

skyline-rs

The library can also be statically linked to Rust code that uses skyline-rs.

A working example can be found in the examples/ directory.

// Also make sure the linker can find libimgui_xeno.a
#[link(name = "imgui_xeno")] 
extern "C" {
    fn imgui_xeno_init(post_init: *const c_void, render: *const c_void);
    fn imgui_xeno_bootstrap_hook(name: *const c_char, original_fn: *const c_void) -> *const c_void;
    fn imgui_xeno_add_on_pre_init(pre_init: *const c_void);
    fn imgui_xeno_add_on_new_frame(new_frame: *const c_void);
}

extern "C" {
    fn nvnBootstrapLoader(name: *const c_char) -> *const c_void;
}

unsafe extern "C" fn imgui_pre_init() {}
unsafe extern "C" fn imgui_post_init() {}
unsafe extern "C" fn imgui_new_frame() {}
unsafe extern "C" fn imgui_render() {}

#[skyline::hook(replace = nvnBootstrapLoader)]
unsafe fn nvn_bootstrap_hook(name: u64) -> u64 {
    imgui_xeno_bootstrap_hook(name, original!() as *const c_void)
}

#[skyline::main(name = "imgui_xeno_demo")]
pub fn main() {
    unsafe {
        imgui_xeno_add_on_pre_init(on_imgui_pre_init as *const c_void);
        imgui_xeno_add_on_new_frame(on_imgui_new_frame as *const c_void);
        imgui_xeno_init(
            on_imgui_post_init as *const c_void,
            on_imgui_render as *const c_void
        );
        skyline::install_hooks!(nvn_bootstrap_hook);
    }
}

Configuration

Most parameters can be configured in the user_config source directory.
Particularly, you can add ImGui directives in the imgui_user_config.h file.

Not Xenoblade?

Chances are this backend might also work in your game, even if it's not Xenoblade.
You can try the provided configuration options to improve compatibility, or patch the backend directly.
Note that if the required changes are too big to maintain for a non-Xenoblade title, it is probably best that you fork this repository instead.

Original repo credits

imgui-xeno's People

Contributors

alexcsdev avatar blockbuilder57 avatar encounter avatar pwootage avatar roccodev avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.