mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-10-03 19:18:32 -04:00
convert jpn ui/text changes to runtime checks
This commit is contained in:
+203
-2
@@ -1,11 +1,12 @@
|
||||
#include "d/dolzel.h" // IWYU pragma: keep
|
||||
|
||||
#include "d/d_msg_unit.h"
|
||||
#include "d/d_com_inf_game.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "d/d_com_inf_game.h"
|
||||
#include "d/d_kankyo.h"
|
||||
#include "d/d_meter2_info.h"
|
||||
#include "d/d_msg_unit.h"
|
||||
#include "dusk/version.hpp"
|
||||
|
||||
// temporary until a better solution is found
|
||||
typedef struct dMsgUnit_inf1_entry {
|
||||
@@ -41,6 +42,199 @@ dMsgUnit_c::dMsgUnit_c() {}
|
||||
|
||||
dMsgUnit_c::~dMsgUnit_c() {}
|
||||
|
||||
#if TARGET_PC
|
||||
typedef struct dMsgUnit_inf1_entry_JPN {
|
||||
BE(u32) dat1EntryOffset;
|
||||
BE(u16) field_0x04;
|
||||
BE(u16) field_0x06;
|
||||
BE(u16) field_0x08;
|
||||
BE(u16) field_0x0a;
|
||||
BE(u16) field_0x0c;
|
||||
BE(u16) field_0x0e;
|
||||
BE(u16) field_0x10;
|
||||
BE(u16) field_0x12;
|
||||
BE(u16) field_0x14;
|
||||
BE(u16) field_0x16;
|
||||
BE(u16) field_0x18;
|
||||
BE(u16) startFrame;
|
||||
BE(u16) endFrame;
|
||||
} dMsgUnit_inf1_entry_JPN;
|
||||
|
||||
typedef struct dMsgUnit_inf1_section_JPN {
|
||||
/* 0x00 */ BE(u32) msgType; // sectionType
|
||||
/* 0x04 */ BE(u32) size; // total size of the section
|
||||
/* 0x08 */ BE(u16) entryCount;
|
||||
/* 0x0A */ BE(u16) entryLength;
|
||||
/* 0x0C */ BE(u16) msgArchiveId;
|
||||
/* 0x10 */ dMsgUnit_inf1_entry_JPN entries[0];
|
||||
} dMsgUnit_inf1_section_JPN;
|
||||
|
||||
void dMsgUnit_c::setTag_jpn(int i_type, int i_value, TEXT_SPAN o_buffer, bool param_4) {
|
||||
*o_buffer = 0;
|
||||
bool stack9 = false;
|
||||
bool stack8 = false;
|
||||
int value = i_value;
|
||||
|
||||
if (i_type == 0x10000) {
|
||||
SAFE_SPRINTF(o_buffer, "%d", i_value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (i_type == 0x10001) {
|
||||
int tens_digit = i_value / 10;
|
||||
int ones_digit = i_value % 10;
|
||||
SAFE_SPRINTF(o_buffer, "%d-%d", tens_digit, ones_digit);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((i_type == 4 && param_4 == true) || (i_type == 5 && param_4 == false)) {
|
||||
int seconds = i_value / 1000;
|
||||
int minutes = seconds / 60;
|
||||
seconds -= minutes * 60;
|
||||
if (minutes > 99) {
|
||||
minutes = 99;
|
||||
seconds = 59;
|
||||
}
|
||||
|
||||
if (minutes == 0 && seconds == 0) {
|
||||
if (strcmp(dComIfGp_getStartStageName(), "F_SP00") == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (i_type == 4) {
|
||||
i_value = minutes;
|
||||
if (minutes == 0) {
|
||||
stack9 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (i_type == 5) {
|
||||
if (seconds == 0 && minutes != 0) {
|
||||
return;
|
||||
}
|
||||
i_value = seconds;
|
||||
}
|
||||
}
|
||||
|
||||
if ((i_type == 3 && param_4 == true) || i_type == 4 && param_4 == false) {
|
||||
f32 dayTime = g_env_light.getDaytime();
|
||||
f32 hour = dayTime / 15.0f;
|
||||
|
||||
f32 iVar8b = ((s32)(1000000.0f * dayTime) % 15000000) / 1000000.0f;
|
||||
f32 minute = 60.0f * (iVar8b / 15.0f);
|
||||
// not sure why this affects codegen, in theory it should be optimized out
|
||||
f32 minute2 = 60.0f * (iVar8b / 15.0f);
|
||||
if (i_type == 3) {
|
||||
i_value = (s32)hour;
|
||||
}
|
||||
|
||||
if (i_type == 4) {
|
||||
i_value = (s32)minute;
|
||||
}
|
||||
}
|
||||
|
||||
if (i_type == 9 && param_4 == true) {
|
||||
SAFE_SPRINTF(o_buffer, "%d", i_value);
|
||||
stack8 = true;
|
||||
}
|
||||
|
||||
if (!stack9) {
|
||||
bmg_header_t* pHeader = (bmg_header_t*)dMeter2Info_getMsgUnitResource();
|
||||
dMsgUnit_inf1_section_JPN* pInfoBlock = NULL;
|
||||
const void* pMsgDataBlock = NULL;
|
||||
str1_section_t* pStrAttributeBlock = NULL;
|
||||
int filepos = sizeof(bmg_header_t);
|
||||
u32 filesize = pHeader->size;
|
||||
bmg_section_t* pSection = (bmg_section_t*)(((u8*)pHeader) + filepos);
|
||||
|
||||
for (; filepos < filesize; filepos += pSection->size) {
|
||||
switch(pSection->magic) {
|
||||
case 'FLW1':
|
||||
break;
|
||||
case 'FLI1':
|
||||
break;
|
||||
case 'INF1':
|
||||
pInfoBlock = (dMsgUnit_inf1_section_JPN*)pSection;
|
||||
break;
|
||||
case 'DAT1':
|
||||
pMsgDataBlock = pSection;
|
||||
break;
|
||||
case 'STR1':
|
||||
pStrAttributeBlock = (str1_section_t*)pSection;
|
||||
break;
|
||||
}
|
||||
pSection = (bmg_section_t*)((u8*)pSection + pSection->size);
|
||||
}
|
||||
|
||||
u16 vals[12];
|
||||
vals[0] = pInfoBlock->entries[i_type].field_0x04;
|
||||
vals[1] = pInfoBlock->entries[i_type].field_0x06;
|
||||
vals[2] = pInfoBlock->entries[i_type].field_0x08;
|
||||
vals[3] = pInfoBlock->entries[i_type].field_0x0a;
|
||||
vals[4] = pInfoBlock->entries[i_type].field_0x0c;
|
||||
vals[5] = pInfoBlock->entries[i_type].field_0x0e;
|
||||
vals[6] = pInfoBlock->entries[i_type].field_0x10;
|
||||
vals[7] = pInfoBlock->entries[i_type].field_0x12;
|
||||
vals[8] = pInfoBlock->entries[i_type].field_0x14;
|
||||
vals[9] = pInfoBlock->entries[i_type].field_0x16;
|
||||
vals[10] = pInfoBlock->entries[i_type].field_0x18;
|
||||
int entryOff = pInfoBlock->entries[i_type].dat1EntryOffset;
|
||||
|
||||
char* value2 = (char*)((uintptr_t)pMsgDataBlock + entryOff + 8);
|
||||
|
||||
const char* uVar5;
|
||||
if (i_value == 0) {
|
||||
uVar5 = pStrAttributeBlock->entries->str + vals[0];
|
||||
} else {
|
||||
if ((i_value % 10) == 0) {
|
||||
uVar5 = pStrAttributeBlock->entries->str + (vals[10]);
|
||||
} else {
|
||||
uVar5 = pStrAttributeBlock->entries->str + vals[i_value % 10];
|
||||
}
|
||||
}
|
||||
|
||||
int uVar5Len = strlen(uVar5);
|
||||
if (uVar5Len == 0) {
|
||||
if (stack8) {
|
||||
SAFE_STRCAT(o_buffer, value2);
|
||||
} else {
|
||||
SAFE_SPRINTF(o_buffer, "%d%s", i_value, value2);
|
||||
}
|
||||
} else {
|
||||
char unkCharArr[7];
|
||||
unkCharArr[0] = 26;
|
||||
unkCharArr[1] = uVar5Len + 6;
|
||||
unkCharArr[2] = -1;
|
||||
unkCharArr[3] = -1;
|
||||
unkCharArr[4] = 2;
|
||||
unkCharArr[5] = strlen(value2) / 2;
|
||||
unkCharArr[6] = 0;
|
||||
|
||||
if (stack8) {
|
||||
SAFE_STRCAT(o_buffer, unkCharArr);
|
||||
SAFE_STRCAT(o_buffer, uVar5);
|
||||
SAFE_STRCAT(o_buffer, value2);
|
||||
} else {
|
||||
SAFE_SPRINTF(o_buffer, "%d%s%s%s", i_value, unkCharArr, uVar5, value2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i_type == 3 && param_4 == true) {
|
||||
char buffer[20];
|
||||
setTag(4, 0, buffer, false);
|
||||
SAFE_STRCAT(o_buffer, buffer);
|
||||
}
|
||||
|
||||
if (i_type == 4 && param_4 == true) {
|
||||
char buffer[20];
|
||||
setTag(5, value, buffer, false);
|
||||
SAFE_STRCAT(o_buffer, buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if REGION_JPN
|
||||
void dMsgUnit_c::setTag(int i_type, int i_value, TEXT_SPAN o_buffer, bool param_4) {
|
||||
*o_buffer = 0;
|
||||
@@ -208,6 +402,13 @@ void dMsgUnit_c::setTag(int i_type, int i_value, TEXT_SPAN o_buffer, bool param_
|
||||
}
|
||||
#else
|
||||
void dMsgUnit_c::setTag(int i_type, int i_value, TEXT_SPAN o_buffer, bool param_4) {
|
||||
#if TARGET_PC
|
||||
if (dusk::version::isRegionJpn()) {
|
||||
setTag_jpn(i_type, i_value, o_buffer, param_4);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
*o_buffer = 0;
|
||||
bool stack9 = false;
|
||||
bool stack8 = false;
|
||||
|
||||
Reference in New Issue
Block a user