Translate load and save game menu

This commit is contained in:
James Lambert 2023-11-08 21:49:27 -07:00
parent 60a0e39d1d
commit 7a37be91c9
9 changed files with 87 additions and 41 deletions

View file

@ -327,11 +327,12 @@ build/src/menu/game_menu.o: build/src/audio/clips.h build/assets/materials/ui.h
build/src/menu/gameplay_options.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/menu/gameplay_options.o: build/assets/materials/ui.h build/src/audio/clips.h
build/src/menu/joystick_options.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/menu/joystick_options.o: build/assets/materials/ui.h build/src/audio/clips.h
build/src/menu/landing_menu.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/menu/landing_menu.o: build/assets/materials/ui.h build/src/audio/clips.h
build/src/menu/load_game.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/menu/load_game.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/audio/subtitles.h
build/src/menu/main_menu.o: build/src/audio/clips.h build/assets/materials/ui.h build/assets/materials/images.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h build/src/menu/main_menu.o: build/src/audio/clips.h build/assets/materials/ui.h build/assets/materials/images.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h
build/src/menu/new_game_menu.o: build/src/audio/clips.h build/assets/materials/ui.h build/assets/materials/images.h build/src/audio/subtitles.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h build/src/menu/new_game_menu.o: build/src/audio/clips.h build/assets/materials/ui.h build/assets/materials/images.h build/src/audio/subtitles.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h
build/src/menu/options_menu.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/audio/subtitles.h build/src/menu/options_menu.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/audio/subtitles.h
build/src/menu/save_game_menu.o: build/src/audio/clips.h build/src/menu/save_game_menu.o: build/src/audio/clips.h build/src/audio/subtitles.h
build/src/menu/text_manipulation.o: build/src/audio/subtitles.h
build/src/scene/scene_animator.o: build/src/audio/clips.h build/src/scene/scene_animator.o: build/src/audio/clips.h
build/src/menu/cheat_codes.o: build/src/audio/clips.h build/src/menu/cheat_codes.o: build/src/audio/clips.h
build/src/levels/intro.o: build/src/audio/clips.h build/assets/materials/images.h build/src/levels/intro.o: build/src/audio/clips.h build/assets/materials/images.h

View file

@ -5,8 +5,10 @@
#include "../levels/levels.h" #include "../levels/levels.h"
#include "../util/memory.h" #include "../util/memory.h"
#include "../audio/soundplayer.h" #include "../audio/soundplayer.h"
#include "./translations.h"
#include "../build/src/audio/clips.h" #include "../build/src/audio/clips.h"
#include "../build/src/audio/subtitles.h"
void loadGameMenuInit(struct LoadGameMenu* loadGame, struct SavefileListMenu* savefileList) { void loadGameMenuInit(struct LoadGameMenu* loadGame, struct SavefileListMenu* savefileList) {
loadGame->savefileList = savefileList; loadGame->savefileList = savefileList;
@ -21,11 +23,11 @@ void loadGamePopulate(struct LoadGameMenu* loadGame) {
for (int i = 0; i < numberOfSaves; ++i) { for (int i = 0; i < numberOfSaves; ++i) {
savefileInfo[i].slotIndex = saveSlots[i].saveSlot; savefileInfo[i].slotIndex = saveSlots[i].saveSlot;
savefileInfo[i].testchamberIndex = saveSlots[i].testChamber; savefileInfo[i].testchamberIndex = saveSlots[i].testChamber;
savefileInfo[i].savefileName = saveSlots[i].saveSlot == 0 ? "AUTO" : NULL; savefileInfo[i].savefileName = saveSlots[i].saveSlot == 0 ? translationsGet(GAMEUI_AUTOSAVE) : NULL;
savefileInfo[i].screenshot = (u16*)SCREEN_SHOT_SRAM(saveSlots[i].saveSlot); savefileInfo[i].screenshot = (u16*)SCREEN_SHOT_SRAM(saveSlots[i].saveSlot);
} }
savefileUseList(loadGame->savefileList, "LOAD GAME", savefileInfo, numberOfSaves); savefileUseList(loadGame->savefileList, translationsGet(GAMEUI_LOADGAME), savefileInfo, numberOfSaves);
} }
enum MenuDirection loadGameUpdate(struct LoadGameMenu* loadGame) { enum MenuDirection loadGameUpdate(struct LoadGameMenu* loadGame) {

View file

@ -11,6 +11,7 @@
#include "../util/memory.h" #include "../util/memory.h"
#include "../util/rom.h" #include "../util/rom.h"
#include "../audio/soundplayer.h" #include "../audio/soundplayer.h"
#include "./text_manipulation.h"
#include "../build/assets/materials/ui.h" #include "../build/assets/materials/ui.h"
#include "../build/assets/materials/images.h" #include "../build/assets/materials/images.h"
@ -76,12 +77,7 @@ void chapterMenuSetChapter(struct ChapterMenu* chapterMenu, struct Chapter* chap
sprintf(chapterText, "%s %d", translationsGet(GAMEUI_CHAPTER), chapterIndex + 1); sprintf(chapterText, "%s %d", translationsGet(GAMEUI_CHAPTER), chapterIndex + 1);
chapterMenu->chapterText = menuBuildPrerenderedText(&gDejaVuSansFont, chapterText, chapterMenu->x, chapterMenu->y, SCREEN_WD); chapterMenu->chapterText = menuBuildPrerenderedText(&gDejaVuSansFont, chapterText, chapterMenu->x, chapterMenu->y, SCREEN_WD);
strcpy(chapterText, translationsGet(PORTAL_CHAPTER1_TITLE)); textManipTestChamberMessage(chapterText, gChapters[chapterIndex].testChamberDisplayNumber);
int len = strlen(chapterText);
// this is dumb, but it works
chapterText[len - 1] += chapterIndex % 10;
chapterText[len - 2] += chapterIndex / 10;
chapterMenu->testChamberText = menuBuildPrerenderedText(&gDejaVuSansFont, chapterText, chapterMenu->x, chapterMenu->y + 14, 100); chapterMenu->testChamberText = menuBuildPrerenderedText(&gDejaVuSansFont, chapterText, chapterMenu->x, chapterMenu->y + 14, 100);

View file

@ -5,8 +5,10 @@
#include "../controls/controller.h" #include "../controls/controller.h"
#include "../util/memory.h" #include "../util/memory.h"
#include "../audio/soundplayer.h" #include "../audio/soundplayer.h"
#include "./translations.h"
#include "../build/src/audio/clips.h" #include "../build/src/audio/clips.h"
#include "../build/src/audio/subtitles.h"
void saveGameMenuInit(struct SaveGameMenu* saveGame, struct SavefileListMenu* savefileList) { void saveGameMenuInit(struct SaveGameMenu* saveGame, struct SavefileListMenu* savefileList) {
saveGame->savefileList = savefileList; saveGame->savefileList = savefileList;
@ -36,7 +38,7 @@ void saveGamePopulate(struct SaveGameMenu* saveGame, int includeNew) {
if (includeNew && freeSlot != SAVEFILE_NO_SLOT) { if (includeNew && freeSlot != SAVEFILE_NO_SLOT) {
savefileInfo[numberOfSaves].slotIndex = freeSlot; savefileInfo[numberOfSaves].slotIndex = freeSlot;
savefileInfo[numberOfSaves].savefileName = "NEW SAVE"; savefileInfo[numberOfSaves].savefileName = translationsGet(GAMEUI_NEWSAVEGAME);
savefileInfo[numberOfSaves].testchamberIndex = levelGetChamberNumber(gCurrentLevelIndex, gScene.player.body.currentRoom); savefileInfo[numberOfSaves].testchamberIndex = levelGetChamberNumber(gCurrentLevelIndex, gScene.player.body.currentRoom);
savefileInfo[numberOfSaves].screenshot = gScreenGrabBuffer; savefileInfo[numberOfSaves].screenshot = gScreenGrabBuffer;
@ -47,7 +49,7 @@ void saveGamePopulate(struct SaveGameMenu* saveGame, int includeNew) {
++numberOfSaves; ++numberOfSaves;
} }
savefileUseList(saveGame->savefileList, "SAVE GAME", savefileInfo, numberOfSaves); savefileUseList(saveGame->savefileList, translationsGet(GAMEUI_SAVEGAME), savefileInfo, numberOfSaves);
if (startSelection == -1) { if (startSelection == -1) {
saveGame->savefileList->selectedSave = numberOfSaves - 1; saveGame->savefileList->selectedSave = numberOfSaves - 1;

View file

@ -5,6 +5,7 @@
#include "../util/rom.h" #include "../util/rom.h"
#include "../graphics/image.h" #include "../graphics/image.h"
#include "../audio/soundplayer.h" #include "../audio/soundplayer.h"
#include "./text_manipulation.h"
#include <string.h> #include <string.h>
#include "../build/assets/materials/ui.h" #include "../build/assets/materials/ui.h"
@ -20,21 +21,27 @@
#define ROW_HEIGHT (BORDER_HEIGHT + 8) #define ROW_HEIGHT (BORDER_HEIGHT + 8)
void savefileListSlotUseInfo(struct SavefileListSlot* savefileListSlot, struct SavefileInfo* savefileInfo, int x, int y) { void savefileListSlotUseInfo(struct SavefileListSlot* savefileListSlot, struct SavefileInfo* savefileInfo, int x, int y) {
char message[16]; if (savefileListSlot->testChamberText) {
sprintf(message, "Testchamber %02d", savefileInfo->testchamberIndex); menuFreePrerenderedDeferred(savefileListSlot->testChamberText);
fontRender(&gDejaVuSansFont, message, x + BORDER_WIDTH + 8, y, savefileListSlot->testChamberText); savefileListSlot->testChamberText = NULL;
}
if (savefileListSlot->gameId) { if (savefileListSlot->gameId) {
free(savefileListSlot->gameId); menuFreePrerenderedDeferred(savefileListSlot->testChamberText);
savefileListSlot->gameId = NULL;
} }
char message[64];
textManipTestChamberMessage(message, savefileInfo->testchamberIndex);
savefileListSlot->testChamberText = menuBuildPrerenderedText(&gDejaVuSansFont, message, x + BORDER_WIDTH + 8, y, 120);
if (savefileInfo->savefileName) { if (savefileInfo->savefileName) {
strcpy(message, savefileInfo->savefileName); strcpy(message, savefileInfo->savefileName);
} else { } else {
sprintf(message, "Subject %02d", gSaveData.saveSlotMetadata[savefileInfo->slotIndex].testSubjectNumber); textManipSubjectMessage(message, gSaveData.saveSlotMetadata[savefileInfo->slotIndex].testSubjectNumber);
} }
savefileListSlot->gameId = menuBuildText(&gDejaVuSansFont, message, x + BORDER_WIDTH + 8, y + 16); savefileListSlot->gameId = menuBuildPrerenderedText(&gDejaVuSansFont, message, x + BORDER_WIDTH + 8, y + savefileListSlot->testChamberText->height + 4, 120);
menuRerenderSolidBorder( menuRerenderSolidBorder(
x, y, x, y,
@ -51,7 +58,7 @@ void savefileListSlotUseInfo(struct SavefileListSlot* savefileListSlot, struct S
} }
void savefileListSlotInit(struct SavefileListSlot* savefileListSlot, int x, int y) { void savefileListSlotInit(struct SavefileListSlot* savefileListSlot, int x, int y) {
savefileListSlot->testChamberText = menuBuildText(&gDejaVuSansFont, "Testchamber 00", x + BORDER_WIDTH + 8, y); savefileListSlot->testChamberText = NULL;
savefileListSlot->gameId = NULL; savefileListSlot->gameId = NULL;
savefileListSlot->border = menuBuildSolidBorder( savefileListSlot->border = menuBuildSolidBorder(
x, y, BORDER_WIDTH, BORDER_HEIGHT, x, y, BORDER_WIDTH, BORDER_HEIGHT,
@ -125,10 +132,10 @@ void savefileListMenuInit(struct SavefileListMenu* savefileList) {
void savefileUseList(struct SavefileListMenu* savefileList, char* title, struct SavefileInfo* savefileInfo, int slotCount) { void savefileUseList(struct SavefileListMenu* savefileList, char* title, struct SavefileInfo* savefileInfo, int slotCount) {
if (savefileList->savefileListTitleText) { if (savefileList->savefileListTitleText) {
free(savefileList->savefileListTitleText); prerenderedTextFree(savefileList->savefileListTitleText);
} }
savefileList->savefileListTitleText = menuBuildText(&gDejaVuSansFont, title, 48, LOAD_GAME_TOP + 4); savefileList->savefileListTitleText = menuBuildPrerenderedText(&gDejaVuSansFont, title, 48, LOAD_GAME_TOP + 4, SCREEN_WD);
for (int i = 0; i < slotCount; ++i) { for (int i = 0; i < slotCount; ++i) {
savefileList->savefileInfo[i] = savefileInfo[i]; savefileList->savefileInfo[i] = savefileInfo[i];
@ -211,18 +218,22 @@ void savefileListRender(struct SavefileListMenu* savefileList, struct RenderStat
} }
gSPDisplayList(renderState->dl++, ui_material_revert_list[SOLID_ENV_INDEX]); gSPDisplayList(renderState->dl++, ui_material_revert_list[SOLID_ENV_INDEX]);
gSPDisplayList(renderState->dl++, ui_material_list[DEJAVU_SANS_0_INDEX]);
gDPPipeSync(renderState->dl++); gDPPipeSync(renderState->dl++);
gDPSetScissor(renderState->dl++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WD, SCREEN_HT); gDPSetScissor(renderState->dl++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WD, SCREEN_HT);
struct PrerenderedTextBatch* batch = prerenderedBatchStart();
if (savefileList->savefileListTitleText) { if (savefileList->savefileListTitleText) {
gSPDisplayList(renderState->dl++, savefileList->savefileListTitleText); prerenderedBatchAdd(batch, savefileList->savefileListTitleText, NULL);
} }
renderState->dl = prerenderedBatchFinish(batch, gDejaVuSansImages, renderState->dl);
gDPPipeSync(renderState->dl++); gDPPipeSync(renderState->dl++);
gDPSetScissor(renderState->dl++, G_SC_NON_INTERLACE, CONTENT_X, CONTENT_Y, CONTENT_X + CONTENT_WIDTH, CONTENT_Y + CONTENT_HEIGHT); gDPSetScissor(renderState->dl++, G_SC_NON_INTERLACE, CONTENT_X, CONTENT_Y, CONTENT_X + CONTENT_WIDTH, CONTENT_Y + CONTENT_HEIGHT);
batch = prerenderedBatchStart();
for (int i = 0; i < MAX_VISIBLE_SLOTS; ++i) { for (int i = 0; i < MAX_VISIBLE_SLOTS; ++i) {
struct SavefileListSlot* slot = &savefileList->slots[i]; struct SavefileListSlot* slot = &savefileList->slots[i];
@ -230,12 +241,16 @@ void savefileListRender(struct SavefileListMenu* savefileList, struct RenderStat
continue; continue;
} }
gDPPipeSync(renderState->dl++); struct Coloru8* color = savefileList->indexOffset + i == savefileList->selectedSave ? &gSelectionOrange : &gColorWhite;
menuSetRenderColor(renderState, savefileList->indexOffset + i == savefileList->selectedSave, &gSelectionOrange, &gColorWhite);
renderStateInlineBranch(renderState, slot->testChamberText); prerenderedBatchAdd(batch, slot->testChamberText, color);
renderStateInlineBranch(renderState, slot->gameId);
if (slot->gameId) {
prerenderedBatchAdd(batch, slot->gameId, color);
} }
}
renderState->dl = prerenderedBatchFinish(batch, gDejaVuSansImages, renderState->dl);
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_0_INDEX]); gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_0_INDEX]);

View file

@ -2,6 +2,7 @@
#define __MENU_SAVEFILE_LIST_H__ #define __MENU_SAVEFILE_LIST_H__
#include "./menu.h" #include "./menu.h"
#include "../font/font.h"
#include "../graphics/graphics.h" #include "../graphics/graphics.h"
#include "../savefile/savefile.h" #include "../savefile/savefile.h"
#include "./new_game_menu.h" #include "./new_game_menu.h"
@ -14,9 +15,9 @@ struct SavefileInfo {
}; };
struct SavefileListSlot { struct SavefileListSlot {
Gfx* testChamberText; struct PrerenderedText* testChamberText;
Gfx* border; Gfx* border;
Gfx* gameId; struct PrerenderedText* gameId;
short x, y; short x, y;
short slotIndex; short slotIndex;
void* imageData; void* imageData;
@ -26,7 +27,7 @@ struct SavefileListSlot {
struct SavefileListMenu { struct SavefileListMenu {
Gfx* menuOutline; Gfx* menuOutline;
Gfx* savefileListTitleText; struct PrerenderedText* savefileListTitleText;
struct SavefileInfo savefileInfo[MAX_SAVE_SLOTS]; struct SavefileInfo savefileInfo[MAX_SAVE_SLOTS];
struct SavefileListSlot slots[MAX_VISIBLE_SLOTS]; struct SavefileListSlot slots[MAX_VISIBLE_SLOTS];
short numberOfSaves; short numberOfSaves;

View file

@ -0,0 +1,19 @@
#include "text_manipulation.h"
#include "./translations.h"
#include "../build/src/audio/subtitles.h"
#include <string.h>
#include <ultra64.h>
void textManipTestChamberMessage(char* result, int testChamber) {
strcpy(result, translationsGet(PORTAL_CHAPTER1_TITLE));
int len = strlen(result);
// this is dumb, but it works
result[len - 1] += testChamber % 10;
result[len - 2] += testChamber / 10;
}
void textManipSubjectMessage(char* result, int subjectIndex) {
sprintf(result, "%s %02d", translationsGet(GAMEUI_PLAYERNAME), subjectIndex);
}

View file

@ -0,0 +1,7 @@
#ifndef __MENU_TEXT_MANIPULATION_H__
#define __MENU_TEXT_MANIPULATION_H__
void textManipTestChamberMessage(char* result, int testChamber);
void textManipSubjectMessage(char* result, int subjectIndex);
#endif

View file

@ -6,20 +6,23 @@ import json
from os.path import exists from os.path import exists
hl_gameui_whitelist = { hl_gameui_whitelist = {
"GAMEUI_GAMEMENU_RESUMEGAME",
"GAMEUI_SAVEGAME",
"GAMEUI_LOADGAME",
"GAMEUI_NEWGAME",
"GAMEUI_OPTIONS",
"GAMEUI_GAMEMENU_QUIT",
"GAMEUI_VIDEO",
"GAMEUI_AUDIO", "GAMEUI_AUDIO",
"GAMEUI_PORTAL", "GAMEUI_AUTOSAVE",
"GAMEUI_JOYSTICK",
"GAMEUI_CHAPTER", "GAMEUI_CHAPTER",
"GAMEUI_SOUNDEFFECTVOLUME", "GAMEUI_GAMEMENU_QUIT",
"GAMEUI_GAMEMENU_RESUMEGAME",
"GAMEUI_JOYSTICK",
"GAMEUI_LOADGAME",
"GAMEUI_MUSICVOLUME", "GAMEUI_MUSICVOLUME",
"GAMEUI_NEWGAME",
"GAMEUI_NEWSAVEGAME",
"GAMEUI_OPTIONS",
"GAMEUI_PLAYERNAME",
"GAMEUI_PORTAL",
"GAMEUI_SAVEGAME",
"GAMEUI_SOUNDEFFECTVOLUME",
"GAMEUI_SUBTITLESANDSOUNDEFFECTS", "GAMEUI_SUBTITLESANDSOUNDEFFECTS",
"GAMEUI_VIDEO",
} }
portal_whitelist = { portal_whitelist = {