Adds ability to store and retrieve textbox size and position.

This commit is contained in:
Christopher Leggett 2022-07-19 22:51:39 -04:00
parent 2d1aa1d13a
commit c5f66373c3
No known key found for this signature in database
GPG Key ID: 7093AE5FF7037D79
8 changed files with 50 additions and 29 deletions

View File

@ -30,6 +30,9 @@
#include "ichain.h"
#include "regs.h"
#define NOGDI
#define WIN32_LEAN_AND_MEAN
#if defined(_WIN64) || defined(__x86_64__) || defined(__arm64__)
#define _SOH64
#endif

View File

@ -100,7 +100,7 @@ bool CustomMessage::CreateMessage(std::string tableID, uint16_t textID, CustomMe
return InsertCustomMessage(tableID, textID, messages);
}
std::string CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID) {
std::string CustomMessage::RetrieveMessage(GlobalContext* globalCtx, std::string tableID, uint16_t textID) {
std::unordered_map<std::string, CustomMessageTable>::const_iterator result = messageTables.find(tableID);
if (result == messageTables.end()) {
return "";
@ -111,6 +111,9 @@ std::string CustomMessage::RetrieveMessage(std::string tableID, uint16_t textID)
return "";
}
CustomMessageEntry messages = message_pair->second;
MessageContext* msgCtx = &globalCtx->msgCtx;
Font* font = &msgCtx->font;
font->charTexBuf[0] = (messages.textBoxType << 4) | messages.textBoxPos;
switch (gSaveContext.language) {
case LANGUAGE_FRA:
return messages.french;

View File

@ -1,7 +1,8 @@
#pragma once
#include <string>
#include <unordered_map>
#include "variables.h"
#include "z64.h"
#include <message_data_static.h>
#undef MESSAGE_END
@ -15,6 +16,8 @@
#define QM_BLACK 0x47
typedef struct {
TextBoxType textBoxType;
TextBoxPosition textBoxPos;
std::string english;
std::string german;
std::string french;
@ -49,6 +52,6 @@ class CustomMessage {
bool CreateGetItemMessage(std::string tableID, GetItemID giid, ItemID iid, CustomMessageEntry messages);
bool CreateMessage(std::string tableID, uint16_t textID, CustomMessageEntry messages);
std::string RetrieveMessage(std::string tableID, uint16_t textID);
std::string RetrieveMessage(GlobalContext* globalCtx, std::string tableID, uint16_t textID);
bool AddCustomMessageTable(std::string tableID);
};

View File

@ -4,8 +4,8 @@
#include <string>
#include "../../../include/ultra64.h"
#include "../../../include/z64item.h"
#include <randomizerTypes.h>
#include <memory>
#include <soh/Enhancements/randomizer/randomizerTypes.h>
class Randomizer {
private:
@ -16,7 +16,6 @@ class Randomizer {
std::string ganonHintText;
std::string ganonText;
std::unordered_map<RandomizerSettingKey, u8> randoSettings;
static const std::string customMessageTableID;
GetItemID GetItemFromGet(RandomizerGet randoGet, GetItemID ogItemId);
GetItemID GetItemFromActor(s16 actorId, s16 actorParams, s16 sceneNum, GetItemID ogItemId);
void ParseRandomizerSettingsFile(const char* spoilerFileName);
@ -27,6 +26,8 @@ class Randomizer {
Randomizer();
~Randomizer();
static const std::string customMessageTableID;
static Sprite* GetSeedTexture(uint8_t index);
s16 GetItemModelFromId(s16 itemId);
s32 GetItemIDFromGetItemID(s32 getItemId);
@ -43,7 +44,7 @@ class Randomizer {
std::string GetHintFromCheck(RandomizerCheck check);
GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId);
GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum);
std::string GetCustomGetItemMessage(GetItemID giid);
//std::string GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid);
static void CreateCustomMessages();
};

View File

@ -1,44 +1,52 @@
#include "randomizer.h"
#include "soh/Enhancements/custom_message/CustomMessage.h"
#include <message_data_static.h>
#define MESSAGES(eng, ger, fra) {eng, ger, fra}
#define NOGDI
#define WIN32_LEAN_AND_MEAN
void Randomizer::CreateCustomMessages() {
CustomMessage* customMessage = CustomMessage::Instance;
customMessage->AddCustomMessageTable(Randomizer::customMessageTableID);
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_BLUE_FIRE, ITEM_BLUE_FIRE,
MESSAGES("You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", ""));
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM,
"You got a %rBottle with Blue &Fire%w! Use it to melt Red Ice!", "", "" });
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_BIG_POE, ITEM_BIG_POE,
MESSAGES("You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", "", ""));
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM,
"You got a %rBig Poe in a Bottle%w!&Sell it to the Ghost Shop!", "", "" });
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_BLUE_POTION, ITEM_POTION_BLUE,
MESSAGES("You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", ""));
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM,
"You got a %rBottle of Blue Potion%w!&Drink it to replenish your&%ghealth%w and %bmagic%w!", "", "" });
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_FISH, ITEM_FISH,
MESSAGES("You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", ""));
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM,
"You got a %rFish in a Bottle%w!&It looks fresh and delicious!&They say Jabu-Jabu loves them!", "", "" });
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_BUGS, ITEM_BUG,
{ "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", "", "" });
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rBug in a Bottle%w!&They love to burrow in&dirt holes!", "", "" });
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_FAIRY, ITEM_FAIRY,
{ "You got a %rFairy in a Bottle%w!&Use it wisely!", "", "" });
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rFairy in a Bottle%w!&Use it wisely!", "", "" });
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_RED_POTION, ITEM_POTION_RED,
{ "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", "", "" });
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM, "You got a %rBottle of Red Potion%w!&Drink it to replenish your&%ghealth%w!", "", "" });
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_GREEN_POTION, ITEM_POTION_GREEN,
{ "You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", "", "" });
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM,
"You got a %rBottle of Green Potion%w!&Drink it to replenish your&%bmagic%w!", "", "" });
customMessage->CreateGetItemMessage(
Randomizer::customMessageTableID, GI_BOTTLE_WITH_POE, ITEM_POE,
{ "You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", "", "" });
{ TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM,
"You got a %rPoe in a Bottle%w!&That creepy Ghost Shop might&be interested in this...", "", "" });
}
std::string Randomizer::GetCustomGetItemMessage(GetItemID giid) {
if (!gSaveContext.n64ddFlag) {
return "Not Randomized.";
}
return CustomMessage::Instance->RetrieveMessage(Randomizer::customMessageTableID, giid);
}
//std::string Randomizer::GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid) {
// if (!gSaveContext.n64ddFlag) {
// return "Not Randomized.";
// }
//
// return CustomMessage::Instance->RetrieveMessage(globalCtx, Randomizer::customMessageTableID, giid);
//}

View File

@ -1505,8 +1505,8 @@ extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerChec
return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId);
}
extern "C" int Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize) {
const std::string& getItemText = OTRGlobals::Instance->gRandomizer->GetCustomGetItemMessage(giid);
extern "C" int Randomizer_GetCustomGetItemMessage(GlobalContext* globalCtx, GetItemID giid, char* buffer, const int maxBufferSize) {
const std::string& getItemText = CustomMessage::Instance->RetrieveMessage(globalCtx, Randomizer::customMessageTableID, giid);
if (getItemText == "") {
return false;
}
@ -1523,7 +1523,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) {
if (textId == 0xF8) {
font->charTexBuf[0] = 0x23;
if (msgCtx->msgLength = font->msgLength = Randomizer_GetCustomGetItemMessage(
(GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) {
globalCtx, (GetItemID)GET_PLAYER(globalCtx)->getItemId, buffer, maxBufferSize)) {
return true;
} else {
switch (gSaveContext.language) {
@ -1551,7 +1551,7 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) {
} else {
textId = 0x00B5;
}
message = CustomMessage::Instance->RetrieveMessage("BaseGameOverrides", textId);
message = CustomMessage::Instance->RetrieveMessage(globalCtx, "BaseGameOverrides", textId);
if (message != "") {
return msgCtx->msgLength = font->msgLength = CopyStringToCharBuffer(message, buffer, maxBufferSize);
}

View File

@ -100,6 +100,7 @@ extern "C" void OTRMessage_Init()
CustomMessage::Instance->CreateGetItemMessage(
customMessageTableID, (GetItemID)0x00B4, ITEM_SKULL_TOKEN,
{
TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM,
"You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!\x0E\x3C",
"Du erhälst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!\x0E\x3C",
"Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collecté %r\x19\%w symboles en tout!\x0E\x3C"
@ -107,7 +108,9 @@ extern "C" void OTRMessage_Init()
);
CustomMessage::Instance->CreateGetItemMessage(
customMessageTableID, (GetItemID)0x00B5, ITEM_SKULL_TOKEN,
{ "You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!",
{
TEXTBOX_TYPE_BLUE, TEXTBOX_POS_BOTTOM,
"You got a %rGold Skulltula Token%w!&You've collected %r\x19%w tokens&in total!",
"Du erhälst ein %rGoldene&Skulltula-Symbol%w! Du hast&insgesamt %r\x19%w symbol gesammelt!",
"Vous obtenez un %rSymbole de&Skulltula d'or%w! Vous avez&collecté %r\x19\%w symboles en tout!" });
}

View File

@ -1709,7 +1709,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) {
msgCtx->msgLength = font->msgLength = Randomizer_CopyHintFromCheck(hintCheck, font->msgBuf, sizeof(font->msgBuf));
} else if (gSaveContext.n64ddFlag && (textId == 0x7040 || textId == 0x7088)) {
// rando hints at altar
msgCtx->msgLength = font->msgLength = CopyAltarMessage(font->msgBuf, sizeof(font->msgBuf));
msgCtx->msgLength = font->msgLength = Randomizer_CopyAltarMessage(font->msgBuf, sizeof(font->msgBuf));
} else if (gSaveContext.n64ddFlag && (textId == 0x10A2 || textId == 0x10DC || textId == 0x10DD)) {
msgCtx->msgLength = font->msgLength = CopyScrubMessage(textId, font->msgBuf, sizeof(font->msgBuf));
} else if (gSaveContext.n64ddFlag && textId == 0x70CC) {