Skip to content

Commit

Permalink
Fix hidpi window size issue | clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ryumiyax committed Jan 1, 2025
1 parent 6a4814b commit 95b3fec
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 57 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,31 @@ version = "auto" # Patch version
# | - JPN39: For use with Taiko JPN 39.06
# | - CHN00: For use with Taiko CHN 00.32
unlock_songs = true # not active for JPN39 (see TestMode)
# More options are available in the ModManager, in the TestMode menu (Default key is F1)

[patches.chn00] # These patches are only available for version CHN00
fix_language = false # Sync test mode language to attract etc
demo_movie = true # Show demo movie
mode_collabo025 = false # Enable one piece collab mode
mode_collabo026 = false # Enable ai soshina mode

[patches.jpn39] # These patches are only available for version JPN39
chs_patch = false # Use Chinese font and Simplified Chinese values from the wordlist
# More options are available in the ModManager, in the TestMode menu (Default key is F1)

[emulation]
usio = true # If usio emulation is disabled, you need to place bnusio_original.dll (unmodified bnusio.dll) in the executable folder.
card_reader = true # Disable this if you have an original namco card reader
accept_invalid = false # Enable this if you want to accept cards incompatible with the original readers
qr = true # Disable this if you have an original namco qr code scanner


[graphics]
res = { x = 1920, y = 1080 }
windowed = false
cursor = true
vsync = false
fpslimit = 120
windowed = false # not windowed will automatically fullscreen
cursor = true # fullscreen will automatically hide cursor
vsync = false # enable this if you are using a 120fps screen (and use "Let Application Decide" in Nvidia panel)
# fpslimit = 0 # temporoly remove it, limit it to 120 in Nvidia panel instead!!!

[audio]
wasapi_shared = true # Wasapi shared mode, allows you to have multiple audio sources at once at a cost of having higher latency.
wasapi_shared = false # Wasapi shared mode, allows you to have multiple audio sources at once at a cost of having higher latency.
asio = false # Use asio audio mode
asio_driver = "ASIO4ALL v2" # Asio driver name
# | If you're not using asio4all, open up regedit then navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ASIO for your driver's name.
Expand All @@ -76,7 +75,7 @@ type = 0 # qr type
song_no = [] # Song noes used for custom folder

[controller]
wait_period = 4 # Input interval (if using taiko drum controller, should be set to 0)
wait_period = 0 # Input interval (if using taiko drum controller, should be set to 0)
analog_input = false # Use analog input (you need a compatible controller, this allows playing small and big notes like on arcade cabinets)

[keyboard]
Expand Down Expand Up @@ -105,17 +104,22 @@ The follow options are available in "MOD MANAGER" menu:
* FIX LANGUAGE (sync test mode language to attract etc)
* UNLOCK SONGS (show all of the songs)
* FREEZE TIMER (stop timer count down)
* KIMETSU MODE (enable collabo024, will show a blank title)
* KIMETSU MODE (enable collabo024, will show a blank title and crash when enter)
* ONE PIECE MODE (enable collabo025)
* AI SOSHINA MODE (enable collabo026)
* AOHARU MODE (enable aprilfool001)
* INSTANT RESULT (send result per song)
* INSTANT RESULT (send result per song, experimental not stable)

Enhanced original option:

* Louder volume (Speaker Volume is now up to 300%, **WARNING: May damage your speakers**)
* Attract demo (Only available if FIX LANGUAGE is ON)

With chs-patch (Only unlock while resource correctly settled):

* Add Language: zh-cn
* Add Voice Language (Could switch between JPN and CHN)

## Building Manually

To compile TaikoArcadeLoader, you'll need to install [MSVC](https://aka.ms/vs/17/release/vs_BuildTools.exe).
Expand Down
4 changes: 2 additions & 2 deletions dist/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ qr = true # Disable this if you want to use an original Namco
[graphics]
res = { x = 1920, y = 1080 }
windowed = false # not windowed will automatically fullscreen
cursor = true
cursor = true # fullscreen will automatically hide cursor
vsync = false # enable this if you are using a 120fps screen (and use "Let Application Decide" in Nvidia panel)
# fpslimit = 0 # temporoly remove it, limit it to 120 in Nvidia panel instead!
# fpslimit = 0 # temporoly remove it, limit it to 120 in Nvidia panel instead!!!


[audio]
Expand Down
16 changes: 8 additions & 8 deletions src/bnusio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void
Init () {
SetKeyboardButtons ();

int fpsLimit = 120;
int fpsLimit = 0;

const auto configPath = std::filesystem::current_path () / "config.toml";
const std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> config_ptr (openConfig (configPath), toml_free);
Expand All @@ -275,10 +275,10 @@ Init () {
analogInput = readConfigBool (controller, "analog_input", analogInput);
globalKeyboard = readConfigBool (controller, "global_keyboard", globalKeyboard);
}
auto graphics = openConfigSection (config, "graphics");
if (graphics) {
fpsLimit = (int)readConfigInt (graphics, "fpslimit", fpsLimit);
}
// auto graphics = openConfigSection (config, "graphics");
// if (graphics) {
// fpsLimit = (int)readConfigInt (graphics, "fpslimit", fpsLimit);
// }
}

if (analogInput) {
Expand All @@ -296,9 +296,9 @@ Init () {
}

updateByCoin = fpsLimit == 0;
if (updateByCoin) {
LogMessage (LogLevel::INFO, "fpsLimit is set to 0, bnusio::Update() will invoke in getCoin callback");
}
// if (updateByCoin) {
// LogMessage (LogLevel::INFO, "fpsLimit is set to 0, bnusio::Update() will invoke in getCoin callback");
// }
const auto keyConfigPath = std::filesystem::current_path () / "keyconfig.toml";
const std::unique_ptr<toml_table_t, void (*) (toml_table_t *)> keyConfig_ptr (openConfig (keyConfigPath), toml_free);
if (keyConfig_ptr) {
Expand Down
6 changes: 5 additions & 1 deletion src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {
}
}

SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
auto activeWindow = GetActiveWindow();
HMONITOR monitor = MonitorFromWindow(activeWindow, MONITOR_DEFAULTTONEAREST);

Expand All @@ -232,12 +233,15 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {
auto horizontalScale = (static_cast<double> (cxPhysical) / static_cast<double> (cxLogical));
auto verticalScale = (static_cast<double> (cyPhysical) / static_cast<double> (cyLogical));
if (windowed) {
// Game will automatically adjust scale
xRes = (int)(xRes / horizontalScale);
yRes = (int)(yRes / verticalScale);
} else {
xRes = cxLogical;
yRes = cyLogical;
}

LogMessage (LogLevel::INFO, "Scale Rate: x={} y={}", horizontalScale, verticalScale);
LogMessage (LogLevel::INFO, "Boot with {} mode ({}x{})", windowed ? "window" : "fullscreen", xRes, yRes);

if (autoIme) {
Expand Down Expand Up @@ -279,7 +283,7 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {

LogMessage (LogLevel::INFO, "==== Loading patches, please wait...");

if (cursor) INSTALL_FAST_HOOK (ShowMouse);
if (windowed && cursor) INSTALL_FAST_HOOK (ShowMouse);
INSTALL_FAST_HOOK (ExitWindows);
INSTALL_FAST_HOOK (CreateWindow);
INSTALL_FAST_HOOK (SetWindowPosition);
Expand Down
73 changes: 38 additions & 35 deletions src/patches/language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,43 +428,46 @@ Init () {
if (std::filesystem::exists (fileName)) return fileName;
return "";
});

std::string base[] = {"..\\..\\Data\\x64\\lumen\\000_default\\attract\\", "..\\..\\Data_mods\\x64\\lumen\\000_default\\attract\\"};
std::string baseCn[] = {"..\\..\\Data\\x64\\lumen_cn\\000_default\\attract\\", "..\\..\\Data_mods\\x64\\lumen_cn\\000_default\\attract\\"};
for (std::string prefix : baseCn) {
if (!seasonNulm.starts_with ("..\\") && std::filesystem::exists (prefix + seasonNulm)) seasonNulm = prefix + seasonNulm;
if (!seasonNutexb.starts_with ("..\\") && std::filesystem::exists (prefix + seasonNutexb)) seasonNutexb = prefix + seasonNutexb;
}
if (!seasonNulm.starts_with ("..\\") || !seasonNutexb.starts_with ("..\\")) titleExistSeason = false;
for (std::string prefix : baseCn) {
if (!maidNulmCn.starts_with ("..\\") && std::filesystem::exists (prefix + maidNulmCn)) maidNulmCn = prefix + maidNulmCn;
if (!maidNutexbCn.starts_with ("..\\") && std::filesystem::exists (prefix + maidNutexbCn)) maidNutexbCn = prefix + maidNutexbCn;
}
if (!maidNulmCn.starts_with ("..\\") || !maidNutexbCn.starts_with ("..\\")) titleExistMaidCn = false;
for (std::string prefix : base) {
if (!maidNulm.starts_with ("..\\") && std::filesystem::exists (prefix + maidNulm)) maidNulm = prefix + maidNulm;
if (!maidNutexb.starts_with ("..\\") && std::filesystem::exists (prefix + maidNutexb)) maidNutexb = prefix + maidNutexb;
}
if (!maidNulm.starts_with ("..\\") || !maidNutexb.starts_with ("..\\")) titleExistMaid = false;

TestMode::RegisterItem (
L"<select-item label=\"TITLE SCREEN(NEED FILES)\" param-offset-x=\"35\" replace-text=\"0:DEFAULT, 1:SEASON(CHN), "
L"2:MAID\" group=\"Setting\" id=\"ModTitleScreen\" max=\"2\" min=\"0\" default=\"0\"/>",
[&](){
std::string base[] = {"..\\..\\Data\\x64\\lumen\\000_default\\attract\\", "..\\..\\Data_mods\\x64\\lumen\\000_default\\attract\\"};
std::string baseCn[] = {"..\\..\\Data\\x64\\lumen_cn\\000_default\\attract\\", "..\\..\\Data_mods\\x64\\lumen_cn\\000_default\\attract\\"};
for (std::string prefix : baseCn) {
if (!seasonNulm.starts_with ("..\\") && std::filesystem::exists (prefix + seasonNulm)) seasonNulm = prefix + seasonNulm;
if (!seasonNutexb.starts_with ("..\\") && std::filesystem::exists (prefix + seasonNutexb)) seasonNutexb = prefix + seasonNutexb;
}
if (!seasonNulm.starts_with ("..\\") || !seasonNutexb.starts_with ("..\\")) titleExistSeason = false;
for (std::string prefix : baseCn) {
if (!maidNulmCn.starts_with ("..\\") && std::filesystem::exists (prefix + maidNulmCn)) maidNulmCn = prefix + maidNulmCn;
if (!maidNutexbCn.starts_with ("..\\") && std::filesystem::exists (prefix + maidNutexbCn)) maidNutexbCn = prefix + maidNutexbCn;
}
if (!maidNulmCn.starts_with ("..\\") || !maidNutexbCn.starts_with ("..\\")) titleExistMaidCn = false;
for (std::string prefix : base) {
if (!maidNulm.starts_with ("..\\") && std::filesystem::exists (prefix + maidNulm)) maidNulm = prefix + maidNulm;
if (!maidNutexb.starts_with ("..\\") && std::filesystem::exists (prefix + maidNutexb)) maidNutexb = prefix + maidNutexb;
}
if (!maidNulm.starts_with ("..\\") || !maidNutexb.starts_with ("..\\")) titleExistMaid = false;
LayeredFs::RegisterBefore ([&] (const std::string &originalFileName, const std::string &currentFileName) -> std::string {
if (currentFileName.starts_with ("F:\\lumen\\") || currentFileName.find ("title") == std::string::npos) return "";
if (currentFileName.ends_with ("title.nulm")) {
if (language == 4 && titleScreen->Read () == 1 && titleExistSeason) return seasonNulm;
if (language == 4 && titleScreen->Read () == 2 && titleExistMaidCn) return maidNulmCn;
if (titleScreen->Read () == 2 && titleExistMaid) return maidNulm;
} else if (currentFileName.ends_with ("title.nutexb")) {
LogMessage (LogLevel::DEBUG, "nutexb");
if (language == 4 && titleScreen->Read () == 1 && titleExistSeason) return seasonNutexb;
if (language == 4 && titleScreen->Read () == 2 && titleExistMaidCn) return maidNutexbCn;
if (titleScreen->Read () == 2 && titleExistMaid) return maidNutexb;
}
return "";
if (titleExistSeason || (titleExistMaid && titleExistMaidCn)) {
TestMode::RegisterItem (
L"<select-item label=\"TITLE SCREEN(NEED FILES)\" param-offset-x=\"35\" replace-text=\"0:DEFAULT, 1:SEASON(CHN), "
L"2:MAID\" group=\"Setting\" id=\"ModTitleScreen\" max=\"2\" min=\"0\" default=\"0\"/>",
[&](){
LayeredFs::RegisterBefore ([&] (const std::string &originalFileName, const std::string &currentFileName) -> std::string {
if (currentFileName.starts_with ("F:\\lumen\\") || currentFileName.find ("title") == std::string::npos) return "";
if (currentFileName.ends_with ("title.nulm")) {
if (language == 4 && titleScreen->Read () == 1 && titleExistSeason) return seasonNulm;
if (language == 4 && titleScreen->Read () == 2 && titleExistMaidCn) return maidNulmCn;
if (titleScreen->Read () == 2 && titleExistMaid) return maidNulm;
} else if (currentFileName.ends_with ("title.nutexb")) {
LogMessage (LogLevel::DEBUG, "nutexb");
if (language == 4 && titleScreen->Read () == 1 && titleExistSeason) return seasonNutexb;
if (language == 4 && titleScreen->Read () == 2 && titleExistMaidCn) return maidNutexbCn;
if (titleScreen->Read () == 2 && titleExistMaid) return maidNutexb;
}
return "";
});
});
});
}
} break;
}
}
Expand Down

0 comments on commit 95b3fec

Please sign in to comment.