Skip to content

Commit

Permalink
update st
Browse files Browse the repository at this point in the history
  • Loading branch information
chinosk6 committed Jan 19, 2024
1 parent ea6428a commit 566d5b9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
48 changes: 48 additions & 0 deletions src/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,37 @@ namespace
}
}

bool isCancelTryOn = false;
void* LiveCostumeChangeView_setTryOnMode_orig;
void LiveCostumeChangeView_setTryOnMode_hook(void* _this, void* idol, bool isTryOn) {
if (!isTryOn) isCancelTryOn = true;
reinterpret_cast<decltype(LiveCostumeChangeView_setTryOnMode_hook)*>(LiveCostumeChangeView_setTryOnMode_orig)(_this, idol, isTryOn);
isCancelTryOn = false;
}

void* LiveCostumeChangeView_setIdolCostume_orig;
void LiveCostumeChangeView_setIdolCostume_hook(void* _this, void* idol, int category, int costumeId) {
if (g_allow_use_tryon_costume) {
static auto iidol_klass = il2cpp_symbols::get_class_from_instance(idol);
static auto get_CharacterId_mtd = il2cpp_class_get_method_from_name(iidol_klass, "get_CharacterId", 0);
if (get_CharacterId_mtd) {
const auto idolId = reinterpret_cast<int (*)(void*)>(get_CharacterId_mtd->methodPointer)(idol);
printf("LiveCostumeChangeView_setIdolCostume idol: %d, category: %d, costumeId: %d\n", idolId, category, costumeId);
}
if (isCancelTryOn) return;
}

return reinterpret_cast<decltype(LiveCostumeChangeView_setIdolCostume_hook)*>(LiveCostumeChangeView_setIdolCostume_orig)(_this, idol, category, costumeId);
}

void* LiveMVUnit_GetMemberChangeRequestData_orig;
void* LiveMVUnit_GetMemberChangeRequestData_hook(void* _this, int position, void* idol, int exchangePosition) {
if (g_allow_same_idol) {
exchangePosition = -1;
}
return reinterpret_cast<decltype(LiveMVUnit_GetMemberChangeRequestData_hook)*>(LiveMVUnit_GetMemberChangeRequestData_orig)(_this, position, idol, exchangePosition);
}

void* CriWareErrorHandler_HandleMessage_orig;
void CriWareErrorHandler_HandleMessage_hook(void* _this, Il2CppString* msg) {
// wprintf(L"CriWareErrorHandler_HandleMessage: %ls\n%ls\n\n", msg->start_char, environment_get_stacktrace()->start_char);
Expand Down Expand Up @@ -1005,6 +1036,20 @@ namespace
"PRISM.Legacy.dll", "PRISM",
"LiveScene", "Update", 0
);
auto LiveCostumeChangeView_setTryOnMode_addr = il2cpp_symbols::get_method_pointer(
"PRISM.Interactions.Live.dll", "PRISM.Interactions",
"LiveCostumeChangeView", "_setTryOnMode", 2
);
auto LiveCostumeChangeView_setIdolCostume_addr = il2cpp_symbols::get_method_pointer(
"PRISM.Interactions.Live.dll", "PRISM.Interactions",
"LiveCostumeChangeView", "_setIdolCostume", 3
);

auto LiveMVUnit_GetMemberChangeRequestData_addr = il2cpp_symbols::get_method_pointer(
"PRISM.Legacy.dll", "PRISM.Live",
"LiveMVUnit", "GetMemberChangeRequestData", 3
);

auto CriWareErrorHandler_HandleMessage_addr = il2cpp_symbols::get_method_pointer(
"CriMw.CriWare.Runtime.dll", "CriWare",
"CriWareErrorHandler", "HandleMessage", 1
Expand Down Expand Up @@ -1062,6 +1107,9 @@ namespace
ADD_HOOK(InvokeMoveNext, "InvokeMoveNext at %p");
ADD_HOOK(Live_SetEnableDepthOfField, "Live_SetEnableDepthOfField at %p");
ADD_HOOK(Live_Update, "Live_Update at %p");
ADD_HOOK(LiveCostumeChangeView_setTryOnMode, "LiveCostumeChangeView_setTryOnMode at %p");
ADD_HOOK(LiveCostumeChangeView_setIdolCostume, "LiveCostumeChangeView_setIdolCostume at %p");
ADD_HOOK(LiveMVUnit_GetMemberChangeRequestData, "LiveMVUnit_GetMemberChangeRequestData at %p");
ADD_HOOK(CriWareErrorHandler_HandleMessage, "CriWareErrorHandler_HandleMessage at %p");
ADD_HOOK(GGIregualDetector_ShowPopup, "GGIregualDetector_ShowPopup at %p");
ADD_HOOK(DMMGameGuard_NPGameMonCallback, "DMMGameGuard_NPGameMonCallback at %p");
Expand Down
9 changes: 9 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ char hotKey = 'u';
bool g_enable_free_camera = false;
bool g_block_out_of_focus = false;
float g_free_camera_mouse_speed = 35;
bool g_allow_use_tryon_costume = false;
bool g_allow_same_idol = false;

std::filesystem::path g_localify_base("scsp_localify");
constexpr const char ConfigJson[] = "scsp-config.json";
Expand Down Expand Up @@ -154,6 +156,13 @@ namespace
}
}
}

if (document.HasMember("allowUseTryOnCostume")) {
g_allow_use_tryon_costume = document["allowUseTryOnCostume"].GetBool();
}
if (document.HasMember("allowSameIdol")) {
g_allow_same_idol = document["allowSameIdol"].GetBool();
}

}

Expand Down
2 changes: 2 additions & 0 deletions src/scgui/scGUILoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace SCGUILoop {
void mainLoop() {
if (ImGui::Begin("SC Plugin Config")) {
ImGui::Checkbox("Waiting Extract Text", &SCGUIData::needExtractText);
ImGui::Checkbox("Live Allow Same Idol (Dangerous)", &g_allow_same_idol);
ImGui::Checkbox("Live Allow Use Try On Costume (Dangerous)", &g_allow_use_tryon_costume);

if (ImGui::CollapsingHeader("Resolution Settings", ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::Button("720P")) {
Expand Down
2 changes: 1 addition & 1 deletion src/scgui/scGUIMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool guiDone = true;
bool attachToGame = false;

HWND hwnd;
RECT cacheRect{ 100, 100, 730, 730 };
RECT cacheRect{ 100, 100, 730, 790 };

void SetGuiDone(bool isDone) {
guiDone = isDone;
Expand Down
2 changes: 2 additions & 0 deletions src/stdinclude.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ extern char hotKey;
extern bool g_enable_free_camera;
extern bool g_block_out_of_focus;
extern float g_free_camera_mouse_speed;
extern bool g_allow_use_tryon_costume;
extern bool g_allow_same_idol;

0 comments on commit 566d5b9

Please sign in to comment.