From b63f89c89d81a7990d381fc87370e8ff070d429e Mon Sep 17 00:00:00 2001 From: Neo Date: Sun, 26 Mar 2023 02:51:49 +0100 Subject: [PATCH] Fix subtitle alignment --- src/Config.h | 2 +- src/MagiaClient.cpp | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Config.h b/src/Config.h index e08d432..fd1d4de 100644 --- a/src/Config.h +++ b/src/Config.h @@ -7,6 +7,6 @@ /************************** * Magia Translate Ver * **************************/ -#define MT_VERSION 118 +#define MT_VERSION 119 #endif diff --git a/src/MagiaClient.cpp b/src/MagiaClient.cpp index 0bd2242..d67643c 100644 --- a/src/MagiaClient.cpp +++ b/src/MagiaClient.cpp @@ -320,19 +320,20 @@ void *setPositionNew(uintptr_t label, cocos2d::Vec2 const& position) { LOGD("LOG MESSAGE: %.2f %.2f", position.x, position.y); LOGD("Difference: %p", (void *)difference); //if (position.y >= 55.50 && position.y <= 56.50 && difference <= 0x1000) { - if (position.y >= 37.5 && position.y <= 39.5 && difference <= 0x1000) { + if ((position.y >= 37.5 && position.y <= 39.5 && difference <= 0x1300) + || (position.y >= 55.00 && position.y <= 56.00 && difference <= 0x1300)) { float newPosX = position.x + 125.0; - LOGD("Moved log text from %.2f to %.2f", position.x, newPosX); + LOGD("Moved log text from %.2f to %.2f", position.x, newPosX); cocos2d::Vec2 newPosition = cocos2d::Vec2(newPosX, 66.50); return setPositionHooked(label, newPosition); } - else if (difference <= 0x200 && position.x == 70.00) { + else if (difference <= 0x400 && position.x == 70.00) { LOGD("Moving left-aligned name down in the log."); auto newY = position.y; cocos2d::Vec2 newPosition = cocos2d::Vec2(position.x, newY); return setPositionHooked(label, newPosition); } - else if (difference <= 0x200 && position.x == 500.00) { // Names on the right + else if (difference <= 0x400 && position.x == 500.00) { // Names on the right LOGD("Moving name further to the right in log."); auto newX = position.x + 200; //auto newY = position.y - 15.0; @@ -340,7 +341,7 @@ void *setPositionNew(uintptr_t label, cocos2d::Vec2 const& position) { cocos2d::Vec2 newPosition = cocos2d::Vec2(newX, newY); return setPositionHooked(label, newPosition); } - else if (difference <= 0x200 && position.x == 280.00) { // Names in the center, 280.00? + else if (difference <= 0x400 && position.x == 280.00) { // Names in the center, 280.00? LOGD("Moving center name to the left in the log."); auto newX = 71.50; auto newY = position.y; @@ -390,12 +391,18 @@ cocos2d::Size (*lbGetViewPositionHooked)(float x, float y); cocos2d::Size lbGetViewPositionNew(float x, float y) { uintptr_t addr = reinterpret_cast(__builtin_extract_return_addr(__builtin_return_address(0))); uintptr_t difference = addr - storyCharaUnitonTextHomeOffset; - //LOGI("Difference (viewPos): %p, addr: %p", (void*)difference, (void*)addr); + //LOGD("Difference (viewPos): %p, addr: %p", (void*)difference, (void*)addr); if (storyCharaUnitonTextHomeOffset != 0 && addr >= storyCharaUnitonTextHomeOffset) { - if (difference <= 0x1000) { + if (difference <= 0x1300) { auto oldx = x; auto oldy = y; + if (x > -100.0) { + x = -120.0; + } + if (x == -100.0) { + x = -250.0; + } x = x - 30.0; y = y - 30.0; LOGD("Set live2d subtitle dimensions from (%f, %f) to (%f, %f).", oldx, oldy, x, y);