diff --git a/CMakeLists.txt b/CMakeLists.txt index 7628cea..e674c17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,12 +7,6 @@ set(GEODE_TARGET_PLATFORM "Win64") project(test VERSION 1.0.0) -# Set up the mod binary -add_library(${PROJECT_NAME} SHARED - src/main.cpp - # Add any extra C++ source files here -) - include(FetchContent) FetchContent_Declare( @@ -23,10 +17,20 @@ FetchContent_Declare( FetchContent_MakeAvailable(Corrosion) # Import targets defined in a package or workspace manifest `Cargo.toml` file -corrosion_import_crate(MANIFEST_PATH ${CMAKE_SOURCE_DIR}/Cargo.toml) +corrosion_import_crate(MANIFEST_PATH Cargo.toml) + +corrosion_experimental_cbindgen( + TARGET rusty + HEADER_NAME Rusty.h +) + +# Set up the mod binary +add_library(${PROJECT_NAME} SHARED + src/main.cpp + # Add any extra C++ source files here +) target_link_libraries(${PROJECT_NAME} rusty) -include_directories(${CMAKE_SOURCE_DIR}/target) if (NOT DEFINED ENV{GEODE_SDK}) message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode") diff --git a/Cargo.toml b/Cargo.toml index 8c55dd1..bf08d7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,4 @@ edition = "2021" path = "rusty-src/lib.rs" crate-type = ["staticlib"] -[dependencies] - -[build-dependencies] -cbindgen = "0.27" \ No newline at end of file +[dependencies] \ No newline at end of file diff --git a/build.rs b/build.rs deleted file mode 100644 index b4e4cd6..0000000 --- a/build.rs +++ /dev/null @@ -1,12 +0,0 @@ -extern crate cbindgen; - -use std::env; - -fn main() { - let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); - let mut config: cbindgen::Config = Default::default(); - config.language = cbindgen::Language::C; - cbindgen::generate_with_config(&crate_dir, config) - .unwrap() - .write_to_file("target/Rusty.h"); -} \ No newline at end of file diff --git a/rusty-src/lib.rs b/rusty-src/lib.rs index 7ec1c88..55cfcaa 100644 --- a/rusty-src/lib.rs +++ b/rusty-src/lib.rs @@ -1,6 +1,5 @@ -use std::ffi::c_int; - #[no_mangle] -pub extern "C" fn peepeepoopoo() -> c_int { - 69 +pub extern "C" fn bingus(this_ptr: isize, fn_ptr: isize) { + println!("Hello from rust!! >:) {:#06x} {:#06x}", this_ptr, fn_ptr); + unsafe { std::mem::transmute::<_, fn(isize)>(fn_ptr)(this_ptr); } } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 7673f0a..086a7c4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,10 @@ /** * Include the Geode headers. */ -#include "Geode/loader/ModEvent.hpp" +#include "Geode/binding/PlayLayer.hpp" #include +#include +#include "Rusty.h" /** * Brings cocos2d and all Geode namespaces to the current scope. @@ -103,12 +105,6 @@ class $modify(MyMenuLayer, MenuLayer) { #include "Geode/modify/PlayLayer.hpp" class $modify(PlayLayer) { void startGame() { - log::info("fuck you lmao"); - PlayLayer::startGame(); + bingus(getNonVirtual(this), getNonVirtual(&PlayLayer::startGame)); } -}; - -#include "Rusty.h" -$on_mod(Loaded) { - peepeepoopoo(); }; \ No newline at end of file