1
1
mirror of synced 2025-01-21 09:43:42 +01:00

Merge branch 'esuo1198:Refactor' into Refactor

This commit is contained in:
ptmaster 2024-03-27 20:59:12 +08:00 committed by GitHub
commit f807b5df9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 27 deletions

View File

@ -36,17 +36,11 @@ res = { x = 1920, y = 1080 }
windowed = false
# vertical sync
vsync = false
# auto change to english ime mode
auto_ime = false
# unlock all songs
unlock_songs = true
[patches.audio]
# wasapi shared mode
wasapi_shared = true
# use asio
asio = false
# asio driver name
asio_driver = ""
[patches.cn_jun_2023]
# sync test mode language to attract etc.
fix_language = false
@ -56,7 +50,15 @@ unlock_songs = true
mode_collabo025 = false
# enable ai soshina mode
mode_collabo026 = false
[audio]
# wasapi shared mode
wasapi_shared = true
# use asio
asio = false
# asio driver name
asio_driver = ""
[card_reader]
# enable card reader emulation
enabled = true

11
dist/config.toml vendored
View File

@ -11,19 +11,20 @@ version = "auto"
res = { x = 1920, y = 1080 }
windowed = false
vsync = false
auto_ime = false
unlock_songs = true
[patches.audio]
wasapi_shared = true
asio = false
asio_driver = ""
[patches.cn_jun_2023]
fix_language = false
demo_movie = true
mode_collabo025 = false
mode_collabo026 = false
[audio]
wasapi_shared = true
asio = false
asio_driver = ""
[card_reader]
enabled = true

View File

@ -3,12 +3,13 @@
#include "patches/patches.h"
#include "poll.h"
extern GameVersion version;
extern std::vector<HMODULE> plugins;
extern char accessCode1[21];
extern char chipId1[33];
extern char accessCode2[21];
extern char chipId1[33];
extern char chipId2[33];
extern GameVersion version;
extern bool autoIME;
typedef i32 (*callbackAttach) (i32, i32, i32 *);
typedef void (*callbackTouch) (i32, i32, u8[168], u64);
@ -162,14 +163,20 @@ bnusio_GetAnalogIn (u8 which) {
bool testEnabled = false;
int coin_count = 0;
bool inited = false;
HWND windowHandle = 0;
HWND windowHandle = nullptr;
HKL currentLayout;
u16 __fastcall bnusio_GetCoin (i32 a1) {
if (a1 != 1) return coin_count;
if (!inited) {
windowHandle = FindWindowA ("nuFoundation.Window", 0);
windowHandle = FindWindowA ("nuFoundation.Window", nullptr);
InitializePoll (windowHandle);
if (autoIME) {
currentLayout = GetKeyboardLayout (0);
auto engLayout = LoadKeyboardLayout (TEXT ("00000409"), KLF_ACTIVATE);
ActivateKeyboardLayout (engLayout, KLF_SETFORPROCESS);
}
for (auto plugin : plugins) {
auto initEvent = GetProcAddress (plugin, "Init");
@ -253,6 +260,7 @@ bnusio_GetSwIn () {
i64
bnusio_Close () {
if (autoIME) ActivateKeyboardLayout (currentLayout, KLF_SETFORPROCESS);
for (auto plugin : plugins) {
FARPROC exitEvent = GetProcAddress (plugin, "Exit");
if (exitEvent) ((event *)exitEvent) ();

View File

@ -19,6 +19,7 @@ char accessCode1[21] = "00000000000000000001";
char accessCode2[21] = "00000000000000000002";
char chipId1[33] = "00000000000000000000000000000001";
char chipId2[33] = "00000000000000000000000000000002";
bool autoIME = false;
HOOK (i32, ShowMouse, PROC_ADDRESS ("user32.dll", "ShowCursor"), bool) { return originalShowMouse (true); }
HOOK (i32, ExitWindows, PROC_ADDRESS ("user32.dll", "ExitWindowsEx")) { ExitProcess (0); }
@ -121,7 +122,10 @@ DllMain (HMODULE module, DWORD reason, LPVOID reserved) {
std::strcat (placeId, "0FF0");
}
auto patches = openConfigSection (config, "patches");
if (patches) version = readConfigString (patches, "version", version);
if (patches) {
version = readConfigString (patches, "version", version);
autoIME = readConfigBool (patches, "auto_ime", autoIME);
}
}
if (version == "auto") {

View File

@ -42,14 +42,11 @@ Init () {
auto configPath = std::filesystem::current_path () / "config.toml";
std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> config_ptr (openConfig (configPath), toml_free);
if (config_ptr) {
auto patches = openConfigSection (config_ptr.get (), "patches");
if (patches) {
auto audio = openConfigSection (patches, "audio");
if (audio) {
wasapiShared = readConfigBool (audio, "wasapi_shared", wasapiShared);
asio = readConfigBool (audio, "asio", asio);
asioDriver = readConfigString (audio, "asio_driver", asioDriver);
}
auto audio = openConfigSection (config_ptr.get (), "audio");
if (audio) {
wasapiShared = readConfigBool (audio, "wasapi_shared", wasapiShared);
asio = readConfigBool (audio, "asio", asio);
asioDriver = readConfigString (audio, "asio_driver", asioDriver);
}
}