mirror of
https://github.com/GearsProgress/Poke_Transporter_GB.git
synced 2026-03-21 17:34:42 -05:00
Fully adding scroll support
This commit is contained in:
parent
304880f7d0
commit
aff5709717
|
|
@ -2,7 +2,7 @@
|
|||
#define DEBUG_MODE_H
|
||||
|
||||
#define VERSION "v1.2.1"
|
||||
#define PTGB_BUILD_LANGUAGE 1
|
||||
#define PTGB_BUILD_LANGUAGE 2
|
||||
|
||||
#define DEBUG_MODE true
|
||||
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#define INSTANT_TEXT_SPEED (false && DEBUG_MODE)
|
||||
#define IGNORE_GAME_PAK (true && DEBUG_MODE)
|
||||
#define IGNORE_GAME_PAK_SPRITES (false && DEBUG_MODE)
|
||||
#define IGNORE_LINK_CABLE (false && DEBUG_MODE)
|
||||
#define IGNORE_LINK_CABLE (true && DEBUG_MODE)
|
||||
#define IGNORE_MG_E4_FLAGS (true && DEBUG_MODE)
|
||||
#define IGNORE_UNRECEIVED_PKMN (false && DEBUG_MODE)
|
||||
#define FORCE_TUTORIAL (false && DEBUG_MODE)
|
||||
|
|
|
|||
|
|
@ -30,5 +30,6 @@ int ptgb_write(const byte *text, bool instant);
|
|||
int ptgb_write(const byte *text, bool instant, int length);
|
||||
int ptgb_write_debug(const u16* charset, const char *text, bool instant);
|
||||
void wait_for_user_to_continue(bool clear_text);
|
||||
void scroll_text(const byte *text, bool instant, int length, int curr_index, TTC *tc);
|
||||
|
||||
#endif
|
||||
|
|
@ -62,9 +62,9 @@ static __attribute__((noinline)) const u8 *read_dialogue_text_entry(uint8_t inde
|
|||
// Maybe combine Japanese and Latin into one larger font?
|
||||
|
||||
#if PTGB_BUILD_LANGUAGE == 1
|
||||
#define BUILD_FONT &japanese_normalFont
|
||||
#define BUILD_FONT &japanese_normalFont
|
||||
#else
|
||||
#define BUILD_FONT &latin_normalFont
|
||||
#define BUILD_FONT &latin_normalFont
|
||||
#endif
|
||||
|
||||
void init_text_engine()
|
||||
|
|
@ -134,6 +134,7 @@ int text_loop(int script)
|
|||
{
|
||||
tte_set_pos(LEFT, TOP);
|
||||
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
REG_BG3VOFS = 0;
|
||||
ptgb_write(curr_text, false);
|
||||
}
|
||||
|
||||
|
|
@ -238,12 +239,14 @@ int text_loop(int script)
|
|||
}
|
||||
show_text_box();
|
||||
tte_erase_rect(0, 0, 240, 160);
|
||||
ptgb_write(curr_text, true);
|
||||
ptgb_write(curr_text, false);
|
||||
}
|
||||
|
||||
wait_for_user_to_continue(false);
|
||||
update_text = true;
|
||||
hide_text_box();
|
||||
REG_BG3VOFS = 0;
|
||||
|
||||
|
||||
if (text_exit)
|
||||
{
|
||||
|
|
@ -323,6 +326,16 @@ int ptgb_write(const byte *text, bool instant, int length)
|
|||
str++;
|
||||
switch (ch)
|
||||
{
|
||||
case 0xFA:
|
||||
if (DISPLAY_CONTROL_CHAR)
|
||||
{
|
||||
tc->drawgProc(0x79);
|
||||
}
|
||||
wait_for_user_to_continue(false);
|
||||
scroll_text(text, instant, length, num, tc);
|
||||
tc->cursorY += tc->font->charH;
|
||||
tc->cursorX = tc->marginLeft;
|
||||
break;
|
||||
case 0xFB:
|
||||
if (DISPLAY_CONTROL_CHAR)
|
||||
{
|
||||
|
|
@ -428,5 +441,26 @@ void wait_for_user_to_continue(bool clear_text)
|
|||
{
|
||||
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
tte_set_pos(LEFT, TOP);
|
||||
REG_BG3VOFS = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void scroll_text(const byte *text, bool instant, int length, int curr_index, TTC *tc)
|
||||
{
|
||||
for (int i = 1; i <= tc->font->charH; i++)
|
||||
{
|
||||
REG_BG3VOFS = i;
|
||||
tte_erase_rect(LEFT, TOP - tc->font->charH, RIGHT, TOP + i);
|
||||
global_next_frame();
|
||||
}
|
||||
//wait_for_user_to_continue(true);
|
||||
// Remove current text
|
||||
//tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
// Write old text offset up one line
|
||||
//tte_set_pos(LEFT, TOP - tc->font->charH);
|
||||
//ptgb_write(text, true, curr_index);
|
||||
// Remove text that went outside of the box
|
||||
tte_erase_rect(LEFT, TOP - tc->font->charH, RIGHT, TOP);
|
||||
// Prepare to continue
|
||||
//tte_set_pos(LEFT, TOP);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
|
@ -20,7 +20,7 @@ class Languages(Enum):
|
|||
SpanishEU = 5
|
||||
SpanishLA = 6
|
||||
|
||||
FIRST_TRANSLATION_COL_INDEX = 8
|
||||
FIRST_TRANSLATION_COL_INDEX = 9
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
|
||||
# read by default 1st sheet of an excel file
|
||||
|
|
@ -101,7 +101,7 @@ def split_sentence_into_lines(sentence, offset, pixelsPerChar, pixelsInLine, lan
|
|||
lineLength = 0
|
||||
spaceLength = 0
|
||||
for char in splitChars:
|
||||
sentence.replace(char, " ")
|
||||
sentence = sentence.replace(char, " ")
|
||||
words = sentence.split()
|
||||
|
||||
|
||||
|
|
@ -124,9 +124,12 @@ def split_sentence_into_lines(sentence, offset, pixelsPerChar, pixelsInLine, lan
|
|||
wordLength += 6
|
||||
spaceLength = 6
|
||||
|
||||
# See if the whole sentence is a newline
|
||||
if (sentence == "Ň"):
|
||||
outStr += "Ň"
|
||||
# See if the whole sentence is a newline or scroll
|
||||
if (sentence == "Ň" or sentence == "Ş"):
|
||||
if (sentence == "Ň"):
|
||||
outStr += "Ň"
|
||||
elif (sentence == "Ş"):
|
||||
outStr += "Ş"
|
||||
currLine = ""
|
||||
lineCount += 1
|
||||
offset = 0
|
||||
|
|
@ -204,11 +207,12 @@ def convert_item(ogDict, lang):
|
|||
pixelsPerChar = ogDict["pixelsPerChar"]
|
||||
pixelsInLine = ogDict["pixelsInLine"]
|
||||
include_box_breaks = ogDict["includeBoxBreaks"]
|
||||
include_scrolling = ogDict["includeScrolling"]
|
||||
|
||||
arr = charArrayOfLanguage[lang]["array"]
|
||||
list = charArrayOfLanguage[lang]["escape"]
|
||||
escape_list = charArrayOfLanguage[lang]["escape"]
|
||||
|
||||
for pair in list:
|
||||
for pair in escape_list:
|
||||
if pair[0] in line:
|
||||
escapeString = ""
|
||||
for char in pair[1]:
|
||||
|
|
@ -234,7 +238,7 @@ def convert_item(ogDict, lang):
|
|||
outStr = outStr[:-1]
|
||||
outStr += "ȼ"
|
||||
index += 1
|
||||
elif (currLine < numLines):
|
||||
elif (currLine < (numLines + int(include_scrolling))):
|
||||
#print(split_sents[index])
|
||||
index += 1
|
||||
outStr += out
|
||||
|
|
@ -255,7 +259,30 @@ def convert_item(ogDict, lang):
|
|||
# Some cases that should be fixed
|
||||
exitLoop = False
|
||||
while(not exitLoop):
|
||||
newStr = outStr
|
||||
newStr = ""
|
||||
|
||||
splitBoxes = outStr.split('ȼ')
|
||||
outIndex = 0
|
||||
for box in splitBoxes:
|
||||
# Make sure both kinds of newlines are being accounted for
|
||||
box = box.replace('Ş', 'Ň')
|
||||
splitLines = box.split('Ň')
|
||||
outBox = ""
|
||||
i = 1
|
||||
for split in splitLines:
|
||||
outIndex += len(split)
|
||||
if split == splitLines[-1]:
|
||||
breakChar = ""
|
||||
elif ((i >= numLines) and include_scrolling):
|
||||
breakChar = 'Ş'
|
||||
else:
|
||||
breakChar = outStr[outIndex]
|
||||
outBox += split + breakChar
|
||||
outIndex += 1
|
||||
i += 1
|
||||
newStr += f'{outBox}ȼ'
|
||||
newStr = newStr[:-1] # remove the last ȼ
|
||||
|
||||
# A space right before a newline just takes up space
|
||||
newStr = newStr.replace(" Ň", "Ň")
|
||||
# Newlines shouldn't happen right after a new textbox
|
||||
|
|
@ -269,6 +296,7 @@ def convert_item(ogDict, lang):
|
|||
# Nor should a new scroll be after a new textbox
|
||||
newStr = newStr.replace("ȼŞ", "ȼ")
|
||||
|
||||
|
||||
if len(newStr) > 1023:
|
||||
newStr = newStr[:1023]
|
||||
log_warning_error(lang, "Warning", f"String {newStr} exceeds character limit of 1023 and has been truncated.")
|
||||
|
|
@ -352,7 +380,10 @@ def download_xlsx_file():
|
|||
if offline:
|
||||
# XML exists (guaranteed here)
|
||||
if json_file_path.exists():
|
||||
print("Offline mode: trusting cached XML + JSON. Skipping parse.\n")
|
||||
print("Offline mode: trusting cached XML + JSON. Skipping parse.")
|
||||
if os.path.getmtime(f'{textDir}/main.py') > os.path.getmtime(f'{textDir}/output.json'):
|
||||
print("\t...but the python file is new, so we're doing it anyway!")
|
||||
return
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("Offline mode: XML present but JSON missing. Rebuilding.")
|
||||
|
|
@ -366,7 +397,7 @@ def download_xlsx_file():
|
|||
new_file_path.unlink()
|
||||
if json_file_path.exists():
|
||||
print("Skipping parse")
|
||||
if os.path.getmtime(f'{textDir}/main.py') > os.path.getmtime(f'{textDir}/text.xlsx'):
|
||||
if os.path.getmtime(f'{textDir}/main.py') > os.path.getmtime(f'{textDir}/output.json'):
|
||||
print("\t...but the python file is new, so we're doing it anyway!")
|
||||
return
|
||||
sys.exit(0)
|
||||
|
|
@ -424,6 +455,7 @@ def transfer_xlsx_to_dict():
|
|||
"pixelsPerChar": currRow.iloc[3],
|
||||
"pixelsInLine" : currRow.iloc[4],
|
||||
"includeBoxBreaks": currRow.iloc[5],
|
||||
"includeScrolling": currRow.iloc[6],
|
||||
}
|
||||
|
||||
def generate_header_file():
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user