Skip to content

Commit

Permalink
Add: Unlock Idol Event and Support Event #20
Browse files Browse the repository at this point in the history
  • Loading branch information
chinosk6 committed May 5, 2024
1 parent 8e81d97 commit b6d35fd
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 16 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,22 @@

- 配置项位于 `scsp-config.json` 文件中

| 配置项 | 类型 | 默认值 | 说明 |
| --------------------- | ---------------------------------------- | -------------------------------------- | ---------------------------------------------------- |
| enableConsole | Bool | `true` | 是否开启控制台 |
| enableVSync | Bool | `false` | 是否启用垂直同步 |
| maxFps | Int | `60` | 最大帧数<br>当启用 `enableVSync` 时,此项配置失效 |
| 3DResolutionScale | Float | `1.0` | 3D 渲染分辨率倍率 |
| localifyBasePath | String | `scsp_localify` | 本地化文件目录 |
| hotKey | String (Char) | `u` | 按下 `Ctrl` + 此项配置的热键,**打开插件 GUI** |
| dumpUntransLyrics | Bool | `false` | dump 未翻译的歌词 |
| dumpUntransLocal2 | Bool | `false` | dump 未翻译的文本 |
| autoDumpAllJson | Bool | `false` | dump 所有游戏加载的 JSON |
| extraAssetBundlePaths | String[] | `["scsp_localify/scsp-bundle"]` | 自定义数据包路径 |
| customFontPath | String | `assets/font/sbtphumminge-regular.ttf` | 自定义数据包中字体路径<br>用于替换游戏内置字体 |
| blockOutOfFocus | Bool | `true` | 拦截窗口失焦事件<br>切换到其它窗口后不会触发游戏暂停 |
| baseFreeCamera | [BaseFreeCamera](#BaseFreeCamera) Object | [BaseFreeCamera](#BaseFreeCamera) | 自由视角配置 |
| 配置项 | 类型 | 默认值 | 说明 |
| -------------------------- | ---------------------------------------- | -------------------------------------- | ---------------------------------------------------- |
| enableConsole | Bool | `true` | 是否开启控制台 |
| enableVSync | Bool | `false` | 是否启用垂直同步 |
| maxFps | Int | `60` | 最大帧数<br>当启用 `enableVSync` 时,此项配置失效 |
| 3DResolutionScale | Float | `1.0` | 3D 渲染分辨率倍率 |
| localifyBasePath | String | `scsp_localify` | 本地化文件目录 |
| hotKey | String (Char) | `u` | 按下 `Ctrl` + 此项配置的热键,**打开插件 GUI** |
| dumpUntransLyrics | Bool | `false` | dump 未翻译的歌词 |
| dumpUntransLocal2 | Bool | `false` | dump 未翻译的文本 |
| autoDumpAllJson | Bool | `false` | dump 所有游戏加载的 JSON |
| extraAssetBundlePaths | String[] | `["scsp_localify/scsp-bundle"]` | 自定义数据包路径 |
| customFontPath | String | `assets/font/sbtphumminge-regular.ttf` | 自定义数据包中字体路径<br>用于替换游戏内置字体 |
| blockOutOfFocus | Bool | `true` | 拦截窗口失焦事件<br>切换到其它窗口后不会触发游戏暂停 |
| baseFreeCamera | [BaseFreeCamera](#BaseFreeCamera) Object | [BaseFreeCamera](#BaseFreeCamera) | 自由视角配置 |
| unlockPIdolAndSCharaEvents | Bool | `false` | 解锁 `角色` - `一览` 中的P卡和S卡事件 |



Expand Down
1 change: 1 addition & 0 deletions readme_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ iM@S SCSP localify plugin.
| customFontPath | String | `assets/font/sbtphumminge-regular.ttf` | Custom font path in asset bundles<br>Used for replacing built-in fonts in the game |
| blockOutOfFocus | Bool | `true` | Intercept window out-of-focus events<br>Game won't pause when switching to other windows |
| baseFreeCamera | [BaseFreeCamera](#BaseFreeCamera) Object | [BaseFreeCamera](#BaseFreeCamera) | Free camera configuration |
| unlockPIdolAndSCharaEvents | Bool | `false` | Unlock Idol Event (アイドルイベント) and Support Event (サポートイベント) in `Characters` - `Overview` |



Expand Down
3 changes: 2 additions & 1 deletion resources/scsp-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"enable": false,
"moveStep": 50,
"mouseSpeed": 35
}
},
"unlockPIdolAndSCharaEvents": false
}
53 changes: 53 additions & 0 deletions src/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,48 @@ namespace

}

// NOT HOOK
void* PIdolDetailPopupViewModel_Create_orig;
void* PIdolDetailPopupViewModel_Create_hook(void* produceIdol, void* costumeSetInfoList, void* idolBase, void* idolParameter, bool isChangeableIdolSkill, bool isChangeableFavorite, void* produceAdvStatusList, bool isPlayableAdv, bool inLive, bool upgradingButtonActive) {
auto ret = reinterpret_cast<decltype(PIdolDetailPopupViewModel_Create_hook)*>(PIdolDetailPopupViewModel_Create_orig)(
produceIdol, costumeSetInfoList, idolBase, idolParameter, isChangeableIdolSkill, isChangeableFavorite, produceAdvStatusList, isPlayableAdv, inLive, upgradingButtonActive
);
return ret;
/* // 功能被 EventModel_ctor_hook 替代
static auto get_EventList = reinterpret_cast<void* (*)(void*)>(
il2cpp_symbols::get_method_pointer("PRISM.Adapters.dll", "PRISM.Adapters",
"PIdolDetailPopupViewModel", "get_EventList", 0)
);
static auto EventModel_klass = il2cpp_symbols::get_class("PRISM.Adapters.dll", "PRISM.Adapters", "EventModel");
static auto Read_field = il2cpp_class_get_field_from_name(EventModel_klass, "<Read>k__BackingField");
static auto IsAdvPlayable_field = il2cpp_class_get_field_from_name(EventModel_klass, "<IsAdvPlayable>k__BackingField");
printf("PIdolDetailPopupViewModel_Create\n");
auto events = get_EventList(ret);
il2cpp_symbols::iterate_IEnumerable(events, [](void* event) {
const auto read = il2cpp_symbols::read_field<bool>(event, Read_field);
const auto isAdvPlayable = il2cpp_symbols::read_field<bool>(event, IsAdvPlayable_field);
printf("read: %d, isAdvPlayable: %d\n", read, isAdvPlayable);
il2cpp_symbols::write_field(event, Read_field, true);
});
return ret;*/
}

void* EventModel_ctor_orig;
void EventModel_ctor_hook(void* _this, void* scenarioID, Il2CppString* title, Il2CppString* summary, bool read, bool isAdvPlayable) {
if (g_unlock_PIdol_and_SChara_events) {
if (!read) {
wprintf(L"Force Unlock Event: %ls\n", title->start_char);
read = true;
}
}
return reinterpret_cast<decltype(EventModel_ctor_hook)*>(EventModel_ctor_orig)(_this, scenarioID, title, summary, read, isAdvPlayable);
}

void* LocalizationManager_GetTextOrNull_orig;
Il2CppString* LocalizationManager_GetTextOrNull_hook(void* _this, Il2CppString* category, int id) {
if (g_max_fps != -1) set_fps_hook(g_max_fps);
Expand Down Expand Up @@ -2025,6 +2067,15 @@ namespace
"TextLog", "AddLog", 4
);

auto PIdolDetailPopupViewModel_Create_addr = il2cpp_symbols::get_method_pointer(
"PRISM.Adapters.dll", "PRISM.Adapters",
"PIdolDetailPopupViewModel", "Create", 10
);
auto EventModel_ctor_addr = il2cpp_symbols::get_method_pointer(
"PRISM.Adapters.dll", "PRISM.Adapters",
"EventModel", ".ctor", 5
);

auto LocalizationManager_GetTextOrNull_addr = il2cpp_symbols::get_method_pointer(
"ENTERPRISE.Localization.dll", "ENTERPRISE.Localization",
"LocalizationManager", "GetTextOrNull", 2
Expand Down Expand Up @@ -2215,6 +2266,8 @@ namespace
);

#pragma endregion
// ADD_HOOK(PIdolDetailPopupViewModel_Create, "PIdolDetailPopupViewModel_Create at %p");
ADD_HOOK(EventModel_ctor, "EventModel_ctor at %p");
ADD_HOOK(LocalizationManager_GetTextOrNull, "LocalizationManager_GetTextOrNull at %p");
ADD_HOOK(get_NeedsLocalization, "get_NeedsLocalization at %p");
ADD_HOOK(GetResolutionSize, "GetResolutionSize at %p");
Expand Down
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ bool g_allow_same_idol = false;
bool g_unlock_all_dress = false;
bool g_unlock_all_headwear = false;
bool g_enable_chara_param_edit = false;
bool g_unlock_PIdol_and_SChara_events = false;

std::filesystem::path g_localify_base("scsp_localify");
constexpr const char ConfigJson[] = "scsp-config.json";
Expand Down Expand Up @@ -180,6 +181,9 @@ namespace
if (document.HasMember("unlockAllHeadwear")) {
g_unlock_all_headwear = document["unlockAllHeadwear"].GetBool() && g_unlock_all_dress;
}
if (document.HasMember("unlockPIdolAndSCharaEvents")) {
g_unlock_PIdol_and_SChara_events = document["unlockPIdolAndSCharaEvents"].GetBool();
}

}

Expand Down
4 changes: 4 additions & 0 deletions src/scgui/scGUILoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ namespace SCGUILoop {
ImGui::SameLine();
HELP_TOOLTIP("(?)", "启用角色身体参数编辑器")

ImGui::Checkbox("Unlock PIdol And SChara Events", &g_unlock_PIdol_and_SChara_events);
ImGui::SameLine();
HELP_TOOLTIP("(?)", "解锁 角色 - 一览 中的P卡和S卡事件\nUnlock Idol Event (アイドルイベント) and Support Event (サポートイベント)")

if (ImGui::CollapsingHeader("Resolution Settings", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Text("Window Resolution Settings");

Expand Down
1 change: 1 addition & 0 deletions src/stdinclude.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,4 @@ extern bool g_unlock_all_headwear;
extern bool g_enable_chara_param_edit;
extern float g_font_size_offset;
extern float g_3d_resolution_scale;
extern bool g_unlock_PIdol_and_SChara_events;

0 comments on commit b6d35fd

Please sign in to comment.