Skip to content

Commit 2d9ac1b

Browse files
committed
passion-industry
1 parent fceed8f commit 2d9ac1b

12 files changed

Lines changed: 143 additions & 160 deletions

File tree

.idea/markdown.xml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
Floating mod menu for il2cpp base on [ByNameModding](https://github.com/ByNameModding/BNM-Android)
44

5-
Build APK with [apk-build](https://github.com/fourcels/apk-build)
6-
75
![preview.gif](images/preview.gif)
86

97
# Getting Start

app/src/main/cpp/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ set(LIBDOBBY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Dobby/${CMAKE_ANDROID_ARCH_ABI}/li
4040
# used in the AndroidManifest.xml file.
4141
add_library(${CMAKE_PROJECT_NAME} SHARED
4242
# List C/C++ source files with relative paths to this CMakeLists.txt.
43-
utils/utils.cpp
4443
passion-industry.cpp
4544
)
4645

@@ -57,7 +56,6 @@ target_link_libraries(${CMAKE_PROJECT_NAME}
5756
# horny-villa
5857
set(LIB_NAME horny-villa)
5958
add_library(${LIB_NAME} SHARED
60-
utils/utils.cpp
6159
${LIB_NAME}.cpp)
6260

6361
target_link_libraries(${LIB_NAME}
@@ -70,7 +68,6 @@ target_link_libraries(${LIB_NAME}
7068
# ark-recode
7169
set(LIB_NAME ark-recode)
7270
add_library(${LIB_NAME} SHARED
73-
utils/utils.cpp
7471
${LIB_NAME}.cpp)
7572

7673
target_link_libraries(${LIB_NAME}
@@ -83,7 +80,6 @@ target_link_libraries(${LIB_NAME}
8380
# mafia-queens
8481
set(LIB_NAME mafia-queens)
8582
add_library(${LIB_NAME} SHARED
86-
utils/utils.cpp
8783
${LIB_NAME}.cpp)
8884

8985
target_link_libraries(${LIB_NAME}
@@ -96,7 +92,6 @@ target_link_libraries(${LIB_NAME}
9692
# wet-wealth
9793
set(LIB_NAME wet-wealth)
9894
add_library(${LIB_NAME} SHARED
99-
utils/utils.cpp
10095
${LIB_NAME}.cpp)
10196

10297
target_link_libraries(${LIB_NAME}
@@ -109,7 +104,6 @@ target_link_libraries(${LIB_NAME}
109104
# passion-industry
110105
set(LIB_NAME passion-industry)
111106
add_library(${LIB_NAME} SHARED
112-
utils/utils.cpp
113107
${LIB_NAME}.cpp)
114108

115109
target_link_libraries(${LIB_NAME}

app/src/main/cpp/ark-recode.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,36 @@ JNI_OnLoad(JavaVM *vm, void *reserved) {
3030
// Category:CategoryName
3131
extern "C" JNIEXPORT jobjectArray JNICALL
3232
Java_com_android_support_Menu_getFeatureList(JNIEnv *env, jobject thiz) {
33-
std::vector<std::string> feats = {
33+
std::string feats[] = {
3434
"Seekbar:Attack:1_20",
3535
"Seekbar:Defence:1_20",
3636
};
3737
return toJobjectArray(env, feats);
3838
}
3939

40-
int attack = 1;
41-
int defence = 1;
40+
struct Feature {
41+
int attack{1};
42+
int defence{1};
43+
};
44+
45+
Feature feature{};
46+
4247
extern "C" JNIEXPORT void JNICALL
4348
Java_com_android_support_Menu_valueChange(
4449
JNIEnv *env,
4550
jobject thiz,
4651
jint featIdx,
4752
jstring featName,
48-
jobject value
53+
jint value
4954
) {
5055
// featIdx: index in feature list
5156
switch (featIdx) {
5257
case 0: {
53-
attack = toJint(env, value);
58+
feature.attack = value;
5459
break;
5560
}
5661
case 1: {
57-
defence = toJint(env, value);
62+
feature.defence = value;
5863
break;
5964
}
6065
default:
@@ -64,34 +69,34 @@ Java_com_android_support_Menu_valueChange(
6469

6570
BNM::Field<int> Camp{};
6671

67-
float (*old_GetSkillConditionAttack)(void *instance, void *inSource,
68-
void *inSkillProcessContext,
69-
void *inSourceSkillFunctionInfos);
72+
double (*old_GetSkillConditionAttack)(void *instance, void *inSource,
73+
void *inSkillProcessContext,
74+
void *inSourceSkillFunctionInfos);
7075

71-
float new_GetSkillConditionAttack(void *instance, void *inSource,
72-
void *inSkillProcessContext,
73-
void *inSourceSkillFunctionInfos) {
76+
double new_GetSkillConditionAttack(void *instance, void *inSource,
77+
void *inSkillProcessContext,
78+
void *inSourceSkillFunctionInfos) {
7479
auto ret = old_GetSkillConditionAttack(instance, inSource, inSkillProcessContext,
7580
inSourceSkillFunctionInfos);
7681
auto camp = Camp[inSource]();
7782
if (camp == 1) {
78-
ret = ret * attack;
83+
ret = ret * feature.attack;
7984
}
8085
return ret;
8186
}
8287

83-
float (*old_GetDefenceRate)(void *instance, void *inSource,
84-
void *inSkillProcessContext,
85-
void *inSourceSkillFunctionInfos);
88+
double (*old_GetDefenceRate)(void *instance, void *inSource,
89+
void *inSkillProcessContext,
90+
void *inSourceSkillFunctionInfos);
8691

87-
float new_GetDefenceRate(void *instance, void *inSource,
88-
void *inSkillProcessContext,
89-
void *inSourceSkillFunctionInfos) {
92+
double new_GetDefenceRate(void *instance, void *inSource,
93+
void *inSkillProcessContext,
94+
void *inSourceSkillFunctionInfos) {
9095
auto ret = old_GetDefenceRate(instance, inSource, inSkillProcessContext,
9196
inSourceSkillFunctionInfos);
9297
auto camp = Camp[inSource]();
9398
if (camp == 2) {
94-
ret = ret * defence;
99+
ret = ret * feature.defence;
95100
}
96101
return ret;
97102
}

app/src/main/cpp/horny-villa.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ JNI_OnLoad(JavaVM *vm, void *reserved) {
3030
// Category:CategoryName
3131
extern "C" JNIEXPORT jobjectArray JNICALL
3232
Java_com_android_support_Menu_getFeatureList(JNIEnv *env, jobject thiz) {
33-
std::vector<std::string> feats = {
33+
std::string feats[] = {
3434
"Toggle:Currencies",
3535
"Toggle:Cards Progress",
3636
"Seekbar:Reward:1_10",
@@ -39,33 +39,33 @@ Java_com_android_support_Menu_getFeatureList(JNIEnv *env, jobject thiz) {
3939
}
4040

4141
struct Feature {
42-
bool currencies{};
43-
bool progress{};
44-
int reward{};
42+
bool currencies{false};
43+
bool progress{false};
44+
int reward{1};
4545
};
4646

47-
Feature feature{false, true, 1};
47+
Feature feature{};
4848

4949
extern "C" JNIEXPORT void JNICALL
5050
Java_com_android_support_Menu_valueChange(
5151
JNIEnv *env,
5252
jobject thiz,
5353
jint featIdx,
5454
jstring featName,
55-
jobject value
55+
jint value
5656
) {
5757
// featIdx: index in feature list
5858
switch (featIdx) {
5959
case 0: {
60-
feature.currencies = toJboolean(env, value);
60+
feature.currencies = value;
6161
break;
6262
}
6363
case 1: {
64-
feature.progress = toJboolean(env, value);
64+
feature.progress = value;
6565
break;
6666
}
6767
case 2: {
68-
feature.reward = toJint(env, value);
68+
feature.reward = value;
6969
break;
7070
}
7171
default:

app/src/main/cpp/include/utils.h

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,34 @@
1313
#include <BNM/Field.hpp>
1414
#include <BNM/Property.hpp>
1515

16-
jboolean toJboolean(JNIEnv *env, jobject obj);
16+
template<std::size_t N>
17+
jobjectArray toJobjectArray(JNIEnv *env, std::string (&feats)[N]) {
18+
jclass stringClass = env->FindClass("java/lang/String");
19+
if (stringClass == nullptr) {
20+
return nullptr;
21+
}
22+
jobjectArray ret = env->NewObjectArray(
23+
N,
24+
stringClass,
25+
nullptr
26+
);
27+
if (ret == nullptr) {
28+
return nullptr;
29+
}
1730

18-
jint toJint(JNIEnv *env, jobject obj);
31+
for (int i = 0; i < N; ++i) {
32+
jstring javaString = env->NewStringUTF(feats[i].c_str());
33+
if (javaString == nullptr) {
34+
// Handle error: String conversion failed
35+
// You might need to release previously created objects here
36+
return nullptr;
37+
}
38+
env->SetObjectArrayElement(ret, i, javaString);
39+
env->DeleteLocalRef(javaString); // Release local reference
40+
}
1941

20-
jobjectArray toJobjectArray(JNIEnv *env, const std::vector<std::string> &feats);
42+
return ret;
43+
}
2144

2245

2346
template<typename T>

app/src/main/cpp/mafia-queens.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,29 @@ JNI_OnLoad(JavaVM *vm, void *reserved) {
3030
// Category:CategoryName
3131
extern "C" JNIEXPORT jobjectArray JNICALL
3232
Java_com_android_support_Menu_getFeatureList(JNIEnv *env, jobject thiz) {
33-
std::vector<std::string> feats = {
33+
std::string feats[] = {
3434
"Toggle:Infinite Moves",
3535
};
3636
return toJobjectArray(env, feats);
3737
}
3838

39-
bool moves = false;
39+
struct Feature {
40+
bool moves{false};
41+
};
42+
43+
Feature feature{};
4044
extern "C" JNIEXPORT void JNICALL
4145
Java_com_android_support_Menu_valueChange(
4246
JNIEnv *env,
4347
jobject thiz,
4448
jint featIdx,
4549
jstring featName,
46-
jobject value
50+
jint value
4751
) {
4852
// featIdx: index in feature list
4953
switch (featIdx) {
5054
case 0: {
51-
moves = toJboolean(env, value);
55+
feature.moves = value;
5256
break;
5357
}
5458
default:
@@ -61,7 +65,7 @@ BNM::Method<void> AddMoves{};
6165
float (*old_PlayerMove)();
6266

6367
float new_PlayerMove() {
64-
if (moves) {
68+
if (feature.moves) {
6569
AddMoves(1);
6670
}
6771
return old_PlayerMove();

0 commit comments

Comments
 (0)