convert jpn ui/text changes to runtime checks

This commit is contained in:
TakaRikka
2026-07-17 18:12:28 -07:00
parent 1654d256ec
commit ce386d8dbd
37 changed files with 2467 additions and 442 deletions
+106 -30
View File
@@ -1,23 +1,33 @@
#include "d/dolzel.h" // IWYU pragma: keep
#include "d/d_msg_class.h"
#include <cstdio>
#include <cstring>
#include "d/d_meter2_info.h"
#include "d/d_msg_object.h"
#include "d/d_msg_unit.h"
#include "JSystem/J2DGraph/J2DTextBox.h"
#include "d/d_msg_out_font.h"
#include "m_Do/m_Do_graphic.h"
#include "d/d_lib.h"
#include "JSystem/JUtility/JUTFont.h"
#include "d/d_lib.h"
#include "d/d_meter2_info.h"
#include "d/d_msg_class.h"
#include "d/d_msg_object.h"
#include "d/d_msg_out_font.h"
#include "d/d_msg_unit.h"
#include "dusk/version.hpp"
#include "m_Do/m_Do_graphic.h"
#if TARGET_PC
#include "dusk/menu_pointer.h"
#include "dusk/scope_guard.hpp"
#endif
#if REGION_JPN
#if TARGET_PC
#define CHAR_CODE_MALE_ICON (dusk::version::isRegionJpn() ? 0x8189 : 0xB2)
#define CHAR_CODE_FEMALE_ICON (dusk::version::isRegionJpn() ? 0x818A : 0xB3)
#define CHAR_CODE_STAR_ICON (dusk::version::isRegionJpn() ? 0x819A : 0xB1)
#define CHAR_CODE_REFMARK (dusk::version::isRegionJpn() ? 0x81A6 : 0x89)
#define CHAR_CODE_THIN_LEFT_ARROW (dusk::version::isRegionJpn() ? 0x81A9 : 0xB9)
#define CHAR_CODE_THIN_RIGHT_ARROW (dusk::version::isRegionJpn() ? 0x81A8 : 0xBC)
#define CHAR_CODE_THIN_UP_ARROW (dusk::version::isRegionJpn() ? 0x81AA : 0xBD)
#define CHAR_CODE_THIN_DOWN_ARROW (dusk::version::isRegionJpn() ? 0x81AB : 0xBE)
#elif REGION_JPN
#define CHAR_CODE_MALE_ICON 0x8189
#define CHAR_CODE_FEMALE_ICON 0x818A
#define CHAR_CODE_STAR_ICON 0x819A
@@ -431,8 +441,33 @@ void jmessage_tReference::calcDistance() {
u8 jmessage_tReference::getLineMax() {
int line_max;
#if REGION_JPN
#if TARGET_PC
if (dusk::version::isRegionJpn()) {
if (isKanban()) {
line_max = 6;
} else if (isBook()) {
line_max = 7;
} else if (isStaffRoll()) {
line_max = 10;
} else if (isSaveSeq()) {
line_max = 5;
} else {
line_max = 3;
}
} else {
if (isKanban()) {
line_max = 7;
} else if (isBook()) {
line_max = 9;
} else if (isStaffRoll()) {
line_max = 10;
} else if (isSaveSeq()) {
line_max = 6;
} else {
line_max = 4;
}
}
#elif REGION_JPN
if (isKanban()) {
line_max = 6;
} else if (isBook()) {
@@ -895,7 +930,7 @@ void jmessage_tMeasureProcessor::do_begin(void const* pEntry, char const* pszTex
mSeSpeaker = ((JMSMesgEntry_c*)pEntry)->se_speaker;
mSeMood = ((JMSMesgEntry_c*)pEntry)->se_mood;
for (int i = 0; i < D_MSG_CLASS_PAGE_CNT_MAX; i++) {
for (int i = 0; i < DUSK_IF_ELSE((dusk::version::isRegionJpn() ? 30 : D_MSG_CLASS_PAGE_CNT_MAX), D_MSG_CLASS_PAGE_CNT_MAX); i++) {
pReference->setLineLength(i, 0.0f, 0.0f);
pReference->setPageLine(i, 0);
pReference->setPageLineMax(i, 0);
@@ -912,7 +947,11 @@ void jmessage_tMeasureProcessor::do_begin(void const* pEntry, char const* pszTex
pReference->setLineArrange(i, 1);
}
#if !REGION_JPN
#if TARGET_PC
if (!dusk::version::isRegionJpn() && ((JMSMesgEntry_c*)pEntry)->unk_0xd == 0) {
pReference->setLineArrange(i, 1);
}
#elif !REGION_JPN
if (((JMSMesgEntry_c*)pEntry)->unk_0xd == 0) {
pReference->setLineArrange(i, 1);
}
@@ -1591,8 +1630,8 @@ void jmessage_tMeasureProcessor::do_scale(f32 i_scale) {
mPageLineMax--;
JUT_ASSERT(0x930, mPageLineMax > 0);
#if REGION_JPN
if (field_0x3e == 0) {
#if TARGET_PC || REGION_JPN
if (IF_DUSK(dusk::version::isRegionJpn() &&) field_0x3e == 0) {
pReference->setPageType(field_0x40, 2);
}
#else
@@ -1762,7 +1801,10 @@ void jmessage_tMeasureProcessor::do_pageType(int param_0) {
void jmessage_tMeasureProcessor::do_name1() {
const char* name = dComIfGs_getPlayerName();
#if REGION_JPN
#if TARGET_PC || REGION_JPN
if (!dusk::version::isRegionJpn())
return;
int c = (((char)name[0] & 0xFF) << 8) | ((char)name[1] & 0xFF);
// if first character is hiragana or katakana
if ((c >= 0x829F && c <= 0x82F1) || (c >= 0x8340 && c <= 0x8396)) {
@@ -2041,7 +2083,7 @@ bool jmessage_tSequenceProcessor::do_isReady() {
field_0xae = 1;
field_0xa4 = 0;
pReference->onBatchFlag();
pReference->setCharCnt(D_MSG_CLASS_CHAR_CNT_MAX);
pReference->setCharCnt(DUSK_IF_ELSE(dusk::version::isRegionJpn() ? D_MSG_CLASS_CHAR_CNT_MAX : 0x200, D_MSG_CLASS_CHAR_CNT_MAX));
field_0xa4 = field_0xa8;
return true;
}
@@ -2061,7 +2103,7 @@ bool jmessage_tSequenceProcessor::do_isReady() {
field_0xae = 1;
field_0xa4 = 0;
pReference->onBatchFlag();
pReference->setCharCnt(D_MSG_CLASS_CHAR_CNT_MAX);
pReference->setCharCnt(DUSK_IF_ELSE(dusk::version::isRegionJpn() ? D_MSG_CLASS_CHAR_CNT_MAX : 0x200, D_MSG_CLASS_CHAR_CNT_MAX));
return true;
}
@@ -2084,7 +2126,7 @@ bool jmessage_tSequenceProcessor::do_isReady() {
if (mDoCPd_c::getTrigA(PAD_1) || field_0xb2 != 0 IF_DUSK(|| (dusk::getSettings().game.instantText && mDoCPd_c::getHoldB(0)))) {
field_0xa4 = 0;
pReference->onBatchFlag();
pReference->setCharCnt(D_MSG_CLASS_CHAR_CNT_MAX);
pReference->setCharCnt(DUSK_IF_ELSE(dusk::version::isRegionJpn() ? D_MSG_CLASS_CHAR_CNT_MAX : 0x200, D_MSG_CLASS_CHAR_CNT_MAX));
}
break;
case 1:
@@ -2093,7 +2135,7 @@ bool jmessage_tSequenceProcessor::do_isReady() {
case 9:
field_0xa4 = 0;
pReference->onBatchFlag();
pReference->setCharCnt(D_MSG_CLASS_CHAR_CNT_MAX);
pReference->setCharCnt(DUSK_IF_ELSE(dusk::version::isRegionJpn() ? D_MSG_CLASS_CHAR_CNT_MAX : 0x200, D_MSG_CLASS_CHAR_CNT_MAX));
break;
case 2:
if (field_0xb2 != 0) {
@@ -2108,8 +2150,8 @@ bool jmessage_tSequenceProcessor::do_isReady() {
}
field_0xa6++;
#if REGION_JPN
if (field_0xa6 >= 1) {
#if TARGET_PC || REGION_JPN
if (IF_DUSK(dusk::version::isRegionJpn() &&) field_0xa6 >= 1) {
#else
if (field_0xa6 >= 2) {
#endif
@@ -2533,7 +2575,10 @@ bool jmessage_tSequenceProcessor::do_jump_isReady() {
void jmessage_tSequenceProcessor::do_name1() {
const char* name = dComIfGs_getPlayerName();
#if REGION_JPN
#if TARGET_PC || REGION_JPN
if (!dusk::version::isRegionJpn())
return;
int c = (((char)name[0] & 0xFF) << 8) | ((char)name[1] & 0xFF);
// if first character is hiragana or katakana
if ((c >= 0x829F && c <= 0x82F1) || (c >= 0x8340 && c <= 0x8396)) {
@@ -3357,9 +3402,9 @@ void jmessage_tRenderingProcessor::do_heightcenter() {
}
break;
}
#if REGION_JPN
#if TARGET_PC || REGION_JPN
case 2:
if ((s8)pReference->getLineMax() == 3) {
if (IF_DUSK(dusk::version::isRegionJpn() &&) (s8)pReference->getLineMax() == 3) {
int nowPageLine = pReference->getNowPageLine();
field_0x138 = pReference->getLineSpace() * (0.5f * (pReference->getLineMax() - (s16)nowPageLine));
var_f31 += field_0x138;
@@ -3368,13 +3413,24 @@ void jmessage_tRenderingProcessor::do_heightcenter() {
if (field_0x142 == 0) {
field_0x138 = pReference->getLineSpace();
var_f31 += field_0x138;
} else if (field_0x142 == 1) {
}
#if TARGET_PC
else if (!dusk::version::isRegionJpn() || (dusk::version::isRegionJpn() && field_0x142 == 1))
#else
else if (field_0x142 == 1)
#endif
{
field_0x138 = 0.5f * pReference->getLineSpace();
var_f31 += field_0x138;
}
break;
case 3: {
if (field_0x142 == 1) {
#if TARGET_PC
if (!dusk::version::isRegionJpn() || (dusk::version::isRegionJpn() && field_0x142 == 1))
#else
if (field_0x142 == 1)
#endif
{
int nowPageLine = pReference->getNowPageLine();
field_0x138 = pReference->getLineSpace() * (0.5f * (pReference->getLineMax() - (s16)nowPageLine));
var_f31 += field_0x138;
@@ -3383,8 +3439,25 @@ void jmessage_tRenderingProcessor::do_heightcenter() {
break;
}
case 4: {
#if TARGET_PC
if (!dusk::version::isRegionJpn() && field_0x142 == 0) {
int nowPageLine = pReference->getNowPageLine();
field_0x138 = pReference->getLineSpace() * (0.5f * (pReference->getLineMax() - (s16)nowPageLine));
var_f31 += field_0x138;
}
#endif
if (field_0x142 == 1) {
#if TARGET_PC
if (!dusk::version::isRegionJpn()) {
field_0x138 = 0.5f * pReference->getLineSpace();
var_f31 += field_0x138;
} else {
var_f31 += 0.5f * pReference->getLineSpace();
}
#else
var_f31 += 0.5f * pReference->getLineSpace();
#endif
}
f32 sp8 = pReference->getLineScale(field_0x142) / 100.0f;
@@ -3662,7 +3735,7 @@ void jmessage_tRenderingProcessor::do_strcat(char* i_str, bool param_2, bool par
} else {
JUT_WARN(5316, "%s", "TextBox Alloc Byte Over!!");
}
} else if (field_0x11c < D_MSG_CLASS_CHAR_CNT_MAX) {
} else if (field_0x11c < DUSK_IF_ELSE((dusk::version::isRegionJpn() ? D_MSG_CLASS_CHAR_CNT_MAX : 0x200), D_MSG_CLASS_CHAR_CNT_MAX)) {
if (param_2) {
field_0x146++;
if (pReference->getBatchColorFlag() != 0) {
@@ -3697,7 +3770,7 @@ void jmessage_tRenderingProcessor::do_strcat(char* i_str, bool param_2, bool par
int length = 0;
length = strlen(buffer);
if (field_0x11c + length < D_MSG_CLASS_CHAR_CNT_MAX) {
if (field_0x11c + length < DUSK_IF_ELSE((dusk::version::isRegionJpn() ? D_MSG_CLASS_CHAR_CNT_MAX : 0x200), D_MSG_CLASS_CHAR_CNT_MAX)) {
field_0x148 = strlen(pReference->getTextPtr());
field_0x14a = strlen(pReference->getTextSPtr());
@@ -3792,7 +3865,10 @@ void jmessage_tRenderingProcessor::do_rubystrcat(char* i_src, TEXT_SPAN i_dst, f
void jmessage_tRenderingProcessor::do_name1() {
const char* name = dComIfGs_getPlayerName();
#if REGION_JPN
#if TARGET_PC || REGION_JPN
if (!dusk::version::isRegionJpn())
return;
int c = (((char)name[0] & 0xFF) << 8) | ((char)name[1] & 0xFF);
// if first character is hiragana or katakana
if ((c >= 0x829F && c <= 0x82F1) || (c >= 0x8340 && c <= 0x8396)) {
@@ -3889,7 +3965,7 @@ void jmessage_string_tReference::init(J2DTextBox* panePtr, J2DTextBox* runyPaneP
mRubyPanePtr = runyPanePtr;
mOutFontPtr = outFontPtr;
mLineCount = 0;
mLineMax = D_MSG_CLASS_LINE_MAX;
mLineMax = DUSK_IF_ELSE(dusk::version::isRegionJpn() ? 9 : D_MSG_CLASS_LINE_MAX, D_MSG_CLASS_LINE_MAX);
mNowPage = 0;
mFlags = flags;
if (font != NULL) {