mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-26 10:08:51 -05:00
Moved code to randomizer.cpp, fixes special chars
This commit is contained in:
parent
e500db810b
commit
7639c0f2ed
@ -3,32 +3,12 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "message_data_fmt.h"
|
||||
#include "message_data_textbox_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_TYPE_BLACK,
|
||||
/* 1 */ TEXTBOX_TYPE_WOODEN,
|
||||
/* 2 */ TEXTBOX_TYPE_BLUE,
|
||||
/* 3 */ TEXTBOX_TYPE_OCARINA,
|
||||
/* 4 */ TEXTBOX_TYPE_NONE_BOTTOM,
|
||||
/* 5 */ TEXTBOX_TYPE_NONE_NO_SHADOW,
|
||||
/* 11 */ TEXTBOX_TYPE_CREDITS = 11
|
||||
} TextBoxType;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_BG_CROSS
|
||||
} TextBoxBackground;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_POS_VARIABLE,
|
||||
/* 1 */ TEXTBOX_POS_TOP,
|
||||
/* 2 */ TEXTBOX_POS_MIDDLE,
|
||||
/* 3 */ TEXTBOX_POS_BOTTOM
|
||||
} TextBoxPosition;
|
||||
|
||||
typedef struct {
|
||||
u16 textId;
|
||||
u8 typePos;
|
||||
|
25
soh/include/message_data_textbox_types.h
Normal file
25
soh/include/message_data_textbox_types.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef MESSAGE_DATA_TEXTBOX_TYPES_H
|
||||
#define MESSAGE_DATA_TEXTBOX_TYPES_H
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_TYPE_BLACK,
|
||||
/* 1 */ TEXTBOX_TYPE_WOODEN,
|
||||
/* 2 */ TEXTBOX_TYPE_BLUE,
|
||||
/* 3 */ TEXTBOX_TYPE_OCARINA,
|
||||
/* 4 */ TEXTBOX_TYPE_NONE_BOTTOM,
|
||||
/* 5 */ TEXTBOX_TYPE_NONE_NO_SHADOW,
|
||||
/* 11 */ TEXTBOX_TYPE_CREDITS = 11
|
||||
} TextBoxType;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_BG_CROSS
|
||||
} TextBoxBackground;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_POS_VARIABLE,
|
||||
/* 1 */ TEXTBOX_POS_TOP,
|
||||
/* 2 */ TEXTBOX_POS_MIDDLE,
|
||||
/* 3 */ TEXTBOX_POS_BOTTOM
|
||||
} TextBoxPosition;
|
||||
|
||||
#endif
|
@ -2,6 +2,7 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "../../../include/z64item.h"
|
||||
#include "../../../include/message_data_textbox_types.h"
|
||||
|
||||
#undef MESSAGE_END
|
||||
|
||||
@ -14,31 +15,6 @@
|
||||
#define QM_YELLOW 0x46
|
||||
#define QM_BLACK 0x47
|
||||
|
||||
#ifndef MESSAGE_DATA_STATIC_H
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_TYPE_BLACK,
|
||||
/* 1 */ TEXTBOX_TYPE_WOODEN,
|
||||
/* 2 */ TEXTBOX_TYPE_BLUE,
|
||||
/* 3 */ TEXTBOX_TYPE_OCARINA,
|
||||
/* 4 */ TEXTBOX_TYPE_NONE_BOTTOM,
|
||||
/* 5 */ TEXTBOX_TYPE_NONE_NO_SHADOW,
|
||||
/* 11 */ TEXTBOX_TYPE_CREDITS = 11
|
||||
} TextBoxType;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_BG_CROSS
|
||||
} TextBoxBackground;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ TEXTBOX_POS_VARIABLE,
|
||||
/* 1 */ TEXTBOX_POS_TOP,
|
||||
/* 2 */ TEXTBOX_POS_MIDDLE,
|
||||
/* 3 */ TEXTBOX_POS_BOTTOM
|
||||
} TextBoxPosition;
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
TextBoxType textBoxType;
|
||||
TextBoxPosition textBoxPos;
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "3drando/rando_main.hpp"
|
||||
#include <soh/Enhancements/debugger/ImGuiHelpers.h>
|
||||
#include "Lib/ImGui/imgui_internal.h"
|
||||
#include <soh/Enhancements/custom-message/CustomMessageManager.h>
|
||||
#include <soh/Enhancements/custom-message/CustomMessageTypes.h>
|
||||
|
||||
using json = nlohmann::json;
|
||||
@ -4650,6 +4649,55 @@ void CreateRupeeMessages() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Randomizer::Randomizer_InsertRupeeName(std::string message, int language) {
|
||||
const char* englishRupeeNames[40] = {
|
||||
"Rupees", "Bitcoin", "Bananas", "Cornflakes", "Gummybears", "Floopies", "Dollars", "Lemmings",
|
||||
"Emeralds", "Bucks", "Rubles", "Diamonds", "Moons", "Stars", "Mana", "Doll Hairs",
|
||||
"Dogecoin", "Mushrooms", "Experience", "Friends", "Coins", "Rings", "Gil", "Pokédollars",
|
||||
"Bells", "Orbs", "Bottle Caps", "Simoleons", "Pokémon", "Toys", "Smackaroos", "Zorkmids",
|
||||
"Zenny", "Bones", "Souls", "Studs", "Munny", "Rubies", "Gald", "Gold"
|
||||
};
|
||||
const char* germanRupeeNames[1] = { "Rubine" };
|
||||
const char* frenchRupeeNames[36] = {
|
||||
"Rubis", "Bitcoin", "Bananes", "Euros", "Dollars", "Émeraudes", "Joyaux", "Diamants",
|
||||
"Balles", "Pokémon", "Pièces", "Lunes", "Étoiles", "Dogecoin", "Anneaux", "Radis",
|
||||
"Pokédollars", "Zennies", "Pépètes", "Mailles", "Éthers", "Clochettes", "Capsules", "Gils",
|
||||
"Champignons", "Blés", "Halos", "Munnies", "Orens", "Florens", "Crédits", "Galds",
|
||||
"Bling", "Orbes", "Baguettes", "Croissants"
|
||||
};
|
||||
int randomIndex;
|
||||
std::string replaceWith;
|
||||
switch (language) {
|
||||
case LANGUAGE_ENG:
|
||||
randomIndex = rand() % (sizeof(englishRupeeNames) / sizeof(englishRupeeNames[0]));
|
||||
replaceWith = englishRupeeNames[randomIndex];
|
||||
break;
|
||||
case LANGUAGE_GER:
|
||||
randomIndex = rand() % (sizeof(germanRupeeNames) / sizeof(germanRupeeNames[0]));
|
||||
replaceWith = germanRupeeNames[randomIndex];
|
||||
break;
|
||||
case LANGUAGE_FRA:
|
||||
randomIndex = rand() % (sizeof(frenchRupeeNames) / sizeof(frenchRupeeNames[0]));
|
||||
replaceWith = frenchRupeeNames[randomIndex];
|
||||
break;
|
||||
}
|
||||
std::string replaceString = "%RUPEE%";
|
||||
size_t pos = message.find(replaceString);
|
||||
size_t len = replaceString.length();
|
||||
message.replace(pos, len, replaceWith);
|
||||
CustomMessageManager::Instance->FormatCustomMessage(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
CustomMessageEntry Randomizer::Randomizer_GetRupeeMessage(u16 rupeeTextId) {
|
||||
CustomMessageEntry messageEntry =
|
||||
CustomMessageManager::Instance->RetrieveMessage(Randomizer::rupeeMessageTableID, rupeeTextId);
|
||||
messageEntry.english = Randomizer::Randomizer_InsertRupeeName(messageEntry.english, LANGUAGE_ENG);
|
||||
messageEntry.german = Randomizer::Randomizer_InsertRupeeName(messageEntry.german, LANGUAGE_GER);
|
||||
messageEntry.french = Randomizer::Randomizer_InsertRupeeName(messageEntry.french, LANGUAGE_FRA);
|
||||
return messageEntry;
|
||||
}
|
||||
|
||||
void Randomizer::CreateCustomMessages() {
|
||||
// RANDTODO: Translate into french and german and replace GIMESSAGE_UNTRANSLATED
|
||||
// with GIMESSAGE(getItemID, itemID, english, german, french).
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "../../../include/z64item.h"
|
||||
#include <memory>
|
||||
#include <soh/Enhancements/randomizer/randomizerTypes.h>
|
||||
#include <soh/Enhancements/custom-message/CustomMessageManager.h>
|
||||
|
||||
class Randomizer {
|
||||
private:
|
||||
@ -47,6 +48,8 @@ class Randomizer {
|
||||
GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId);
|
||||
GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum);
|
||||
static void CreateCustomMessages();
|
||||
std::string Randomizer_InsertRupeeName(std::string message, int language);
|
||||
CustomMessageEntry Randomizer_GetRupeeMessage(u16 rupeeTextId);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "Enhancements/cosmetics/CosmeticsEditor.h"
|
||||
#include "Enhancements/debugconsole.h"
|
||||
#include "Enhancements/debugger/debugger.h"
|
||||
#include <soh/Enhancements/randomizer/randomizer.h>
|
||||
#include <soh/Enhancements/randomizer/randomizer_item_tracker.h>
|
||||
#include "Enhancements/n64_weird_frame_data.inc"
|
||||
#include "soh/frame_interpolation.h"
|
||||
@ -1447,54 +1448,6 @@ extern "C" CustomMessageEntry Randomizer_GetScrubMessage(u16 scrubTextId) {
|
||||
return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price);
|
||||
}
|
||||
|
||||
extern "C" std::string Randomizer_InsertRupeeName(std::string message, int language) {
|
||||
const char* englishRupeeNames[40] = {
|
||||
"Rupees", "Bitcoin", "Bananas", "Cornflakes", "Gummybears", "Floopies", "Dollars", "Lemmings", "Emeralds", "Bucks",
|
||||
"Rubles", "Diamonds", "Moons", "Stars", "Mana", "Doll Hairs", "Dogecoin", "Mushrooms", "Experience", "Friends",
|
||||
"Coins", "Rings", "Gil", "Pokédollars", "Bells", "Orbs", "Bottle Caps", "Simoleons", "Pokémon", "Toys",
|
||||
"Smackaroos", "Zorkmids", "Zenny", "Bones", "Souls", "Studs", "Munny", "Rubies", "Gald", "Gold"
|
||||
};
|
||||
const char* germanRupeeNames[1] = {
|
||||
"Rubine"
|
||||
};
|
||||
const char* frenchRupeeNames[36] = {
|
||||
"Rubis", "Bitcoin", "Bananes", "Euros", "Dollars", "Émeraudes", "Joyaux",
|
||||
"Diamants", "Balles", "Pokémon", "Pièces", "Lunes", "Étoiles", "Dogecoin", "Anneaux", "Radis", "Pokédollars",
|
||||
"Zennies", "Pépètes", "Mailles", "Éthers", "Clochettes", "Capsules", "Gils", "Champignons", "Blés", "Halos",
|
||||
"Munnies", "Orens", "Florens", "Crédits", "Galds", "Bling", "Orbes", "Baguettes", "Croissants"
|
||||
};
|
||||
int randomIndex;
|
||||
std::string replaceWith;
|
||||
switch (language) {
|
||||
case LANGUAGE_ENG:
|
||||
randomIndex = rand() % (sizeof(englishRupeeNames) / sizeof(englishRupeeNames[0]));
|
||||
replaceWith = englishRupeeNames[randomIndex];
|
||||
break;
|
||||
case LANGUAGE_GER:
|
||||
randomIndex = rand() % (sizeof(germanRupeeNames) / sizeof(germanRupeeNames[0]));
|
||||
replaceWith = germanRupeeNames[randomIndex];
|
||||
break;
|
||||
case LANGUAGE_FRA:
|
||||
randomIndex = rand() % (sizeof(frenchRupeeNames) / sizeof(frenchRupeeNames[0]));
|
||||
replaceWith = frenchRupeeNames[randomIndex];
|
||||
break;
|
||||
}
|
||||
std::string replaceString = "%RUPEE%";
|
||||
size_t pos = message.find(replaceString);
|
||||
size_t len = replaceString.length();
|
||||
message.replace(pos, len, replaceWith);
|
||||
CustomMessageManager::Instance->FormatCustomMessage(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
extern "C" CustomMessageEntry Randomizer_GetRupeeMessage(u16 rupeeTextId) {
|
||||
CustomMessageEntry messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::rupeeMessageTableID, rupeeTextId);
|
||||
messageEntry.english = Randomizer_InsertRupeeName(messageEntry.english, LANGUAGE_ENG);
|
||||
messageEntry.german = Randomizer_InsertRupeeName(messageEntry.german, LANGUAGE_GER);
|
||||
messageEntry.french = Randomizer_InsertRupeeName(messageEntry.french, LANGUAGE_FRA);
|
||||
return messageEntry;
|
||||
}
|
||||
|
||||
extern "C" CustomMessageEntry Randomizer_GetAltarMessage() {
|
||||
return (LINK_IS_ADULT)
|
||||
? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_ALTAR_ADULT)
|
||||
@ -1591,7 +1544,8 @@ extern "C" int CustomMessage_RetrieveIfExists(GlobalContext* globalCtx) {
|
||||
} else if (!CVar_GetS32("gRandoDisableRandomRupeeNames", 0) &&
|
||||
(textId == TEXT_BLUE_RUPEE || textId == TEXT_RED_RUPEE || textId == TEXT_PURPLE_RUPEE ||
|
||||
textId == TEXT_HUGE_RUPEE)) {
|
||||
messageEntry = Randomizer_GetRupeeMessage(textId);
|
||||
Randomizer randomizerInstance;
|
||||
messageEntry = randomizerInstance.Randomizer_GetRupeeMessage(textId);
|
||||
}
|
||||
}
|
||||
if (textId == TEXT_GS_NO_FREEZE || textId == TEXT_GS_FREEZE) {
|
||||
|
Loading…
Reference in New Issue
Block a user