Skip to content

Commit

Permalink
add resolution config #25, fix start resolution #29
Browse files Browse the repository at this point in the history
  • Loading branch information
chinosk6 committed Jul 1, 2024
1 parent bf0a406 commit 8f2f97f
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 11 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
| blockOutOfFocus | Bool | `true` | 拦截窗口失焦事件<br>切换到其它窗口后不会触发游戏暂停 |
| baseFreeCamera | [BaseFreeCamera](#BaseFreeCamera) Object | [BaseFreeCamera](#BaseFreeCamera) | 自由视角配置 |
| unlockPIdolAndSCharaEvents | Bool | `false` | 解锁 `角色` - `一览` 中的P卡和S卡事件 |
| startResolution | [Resolution](#Resolution) Object | [Resolution](#Resolution) | 启动游戏初始分辨率 |



Expand All @@ -69,6 +70,16 @@



### Resolution

| 配置项 | 类型 | 默认值 | 说明 |
| ------ | ---- | ------- | -------- |
| w | Int | `1280` | 窗口宽度 |
| h | Int | `720` | 窗口高度 |
| isFull | Bool | `false` | 是否全屏 |



# 自由视角说明 (Free Camera)

-`scsp-config.json``baseFreeCamera` - `enable` 设置为 `true` 即可。
Expand Down
11 changes: 11 additions & 0 deletions readme_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ iM@S SCSP localify plugin.
| 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` |
| startResolution | [Resolution](#Resolution) Object | [Resolution](#Resolution) | Game window resolution |



Expand All @@ -68,6 +69,16 @@ iM@S SCSP localify plugin.



### Resolution

| Configuration Item | Type | Default Value | Description |
| ------------------ | ---- | ------------- | -------------- |
| w | Int | `1280` | Window width |
| h | Int | `720` | Window height |
| isFull | Bool | `false` | Is full screen |



# Free Camera Instructions

- Set `enable` under `baseFreeCamera` in `scsp-config.json` to `true`.
Expand Down
7 changes: 6 additions & 1 deletion resources/scsp-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@
"moveStep": 50,
"mouseSpeed": 35
},
"unlockPIdolAndSCharaEvents": false
"unlockPIdolAndSCharaEvents": false,
"startResolution": {
"w": 1280,
"h": 720,
"isFull": false
}
}
34 changes: 24 additions & 10 deletions src/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,19 @@ namespace
return ret;
}

bool isFirstTimeSetResolution = true;
void SetResolution_hook(int width, int height, bool fullscreen) {
// printf("SetResolution: %d, %d, %d, isFirstTimeSetResolution: %d\n", width, height, fullscreen, isFirstTimeSetResolution);
if (isFirstTimeSetResolution) {
isFirstTimeSetResolution = false;
if ((g_start_resolution_w < 0) || (g_start_resolution_h < 0)) {
g_start_resolution_w = width;
g_start_resolution_h = height;
g_start_resolution_fullScreen = fullscreen;
}
return reinterpret_cast<decltype(SetResolution_hook)*>(SetResolution_orig)(g_start_resolution_w,
g_start_resolution_h, g_start_resolution_fullScreen);
}
return;
/*
width = SCGUIData::screenW;
Expand Down Expand Up @@ -2006,7 +2018,9 @@ namespace
void* Unity_Quit_orig;
void Unity_Quit_hook(int code) {
printf("Quit code: %d\n", code);
TerminateProcess(GetCurrentProcess(), 0);
// printf("Quit code: %d\n%ls\n\n", code, environment_get_stacktrace()->start_char);
// return reinterpret_cast<decltype(Unity_Quit_hook)*>(Unity_Quit_orig)(code);
}

void* SetCallbackToGameMon_orig;
Expand Down Expand Up @@ -2204,20 +2218,20 @@ namespace
"Screen", "SetResolution", 3
);

auto UnsafeLoadBytesFromKey_addr = il2cpp_symbols::get_method_pointer(
"PRISM.ResourceManagement.dll", "PRISM.ResourceManagement",
"ResourceLoader", "UnsafeLoadBytesFromKey", 2
);
//auto UnsafeLoadBytesFromKey_addr = il2cpp_symbols::get_method_pointer(
// "PRISM.ResourceManagement.dll", "PRISM.ResourceManagement",
// "ResourceLoader", "UnsafeLoadBytesFromKey", 2
//);

auto TextLog_AddLog_addr = il2cpp_symbols::get_method_pointer(
"PRISM.Legacy.dll", "PRISM.Scenario",
"TextLog", "AddLog", 4
);

auto PIdolDetailPopupViewModel_Create_addr = il2cpp_symbols::get_method_pointer(
"PRISM.Adapters.dll", "PRISM.Adapters",
"PIdolDetailPopupViewModel", "Create", 10
);
//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
Expand Down Expand Up @@ -2413,6 +2427,7 @@ namespace
);

#pragma endregion
ADD_HOOK(SetResolution, "SetResolution at %p");
// ADD_HOOK(PIdolDetailPopupViewModel_Create, "PIdolDetailPopupViewModel_Create at %p");
ADD_HOOK(EventModel_ctor, "EventModel_ctor at %p");
ADD_HOOK(LocalizationManager_GetTextOrNull, "LocalizationManager_GetTextOrNull at %p");
Expand All @@ -2438,9 +2453,8 @@ namespace
ADD_HOOK(UITextMeshProUGUI_Awake, "UITextMeshProUGUI_Awake at %p");
ADD_HOOK(ScenarioManager_Init, "ScenarioManager_Init at %p");
ADD_HOOK(DataFile_GetBytes, "DataFile_GetBytes at %p");
ADD_HOOK(UnsafeLoadBytesFromKey, "UnsafeLoadBytesFromKey at %p");
//ADD_HOOK(UnsafeLoadBytesFromKey, "UnsafeLoadBytesFromKey at %p");
ADD_HOOK(TextLog_AddLog, "TextLog_AddLog at %p");
ADD_HOOK(SetResolution, "SetResolution at %p");
ADD_HOOK(InvokeMoveNext, "InvokeMoveNext at %p");
ADD_HOOK(Live_SetEnableDepthOfField, "Live_SetEnableDepthOfField at %p");
ADD_HOOK(Live_Update, "Live_Update at %p");
Expand Down
10 changes: 10 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ 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;
int g_start_resolution_w = -1;
int g_start_resolution_h = -1;
bool g_start_resolution_fullScreen = false;

std::filesystem::path g_localify_base("scsp_localify");
constexpr const char ConfigJson[] = "scsp-config.json";
Expand Down Expand Up @@ -184,6 +187,13 @@ namespace
if (document.HasMember("unlockPIdolAndSCharaEvents")) {
g_unlock_PIdol_and_SChara_events = document["unlockPIdolAndSCharaEvents"].GetBool();
}

if (document.HasMember("startResolution")) {
auto& startResolution = document["startResolution"];
g_start_resolution_w = startResolution["w"].GetInt();
g_start_resolution_h = startResolution["h"].GetInt();
g_start_resolution_fullScreen = startResolution["isFull"].GetBool();
}

}

Expand Down
3 changes: 3 additions & 0 deletions src/stdinclude.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,6 @@ 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;
extern int g_start_resolution_w;
extern int g_start_resolution_h;
extern bool g_start_resolution_fullScreen;

0 comments on commit 8f2f97f

Please sign in to comment.