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 "global.h"
|
||||||
#include "message_data_fmt.h"
|
#include "message_data_fmt.h"
|
||||||
|
#include "message_data_textbox_types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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 {
|
typedef struct {
|
||||||
u16 textId;
|
u16 textId;
|
||||||
u8 typePos;
|
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 <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "../../../include/z64item.h"
|
#include "../../../include/z64item.h"
|
||||||
|
#include "../../../include/message_data_textbox_types.h"
|
||||||
|
|
||||||
#undef MESSAGE_END
|
#undef MESSAGE_END
|
||||||
|
|
||||||
@ -14,31 +15,6 @@
|
|||||||
#define QM_YELLOW 0x46
|
#define QM_YELLOW 0x46
|
||||||
#define QM_BLACK 0x47
|
#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 {
|
typedef struct {
|
||||||
TextBoxType textBoxType;
|
TextBoxType textBoxType;
|
||||||
TextBoxPosition textBoxPos;
|
TextBoxPosition textBoxPos;
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "3drando/rando_main.hpp"
|
#include "3drando/rando_main.hpp"
|
||||||
#include <soh/Enhancements/debugger/ImGuiHelpers.h>
|
#include <soh/Enhancements/debugger/ImGuiHelpers.h>
|
||||||
#include "Lib/ImGui/imgui_internal.h"
|
#include "Lib/ImGui/imgui_internal.h"
|
||||||
#include <soh/Enhancements/custom-message/CustomMessageManager.h>
|
|
||||||
#include <soh/Enhancements/custom-message/CustomMessageTypes.h>
|
#include <soh/Enhancements/custom-message/CustomMessageTypes.h>
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
@ -4629,27 +4628,76 @@ void CreateRupeeMessages() {
|
|||||||
for (u8 rupee : rupees) {
|
for (u8 rupee : rupees) {
|
||||||
switch (rupee) {
|
switch (rupee) {
|
||||||
case TEXT_BLUE_RUPEE:
|
case TEXT_BLUE_RUPEE:
|
||||||
rupeeText = "\x05\x03 5 %RUPEE% \x05\x00";
|
rupeeText = "\x05\x03 5 %RUPEE%\x05\x00";
|
||||||
break;
|
break;
|
||||||
case TEXT_RED_RUPEE:
|
case TEXT_RED_RUPEE:
|
||||||
rupeeText = "\x05\x01 20 %RUPEE% \x05\x00";
|
rupeeText = "\x05\x01 20 %RUPEE%\x05\x00";
|
||||||
break;
|
break;
|
||||||
case TEXT_PURPLE_RUPEE:
|
case TEXT_PURPLE_RUPEE:
|
||||||
rupeeText = "\x05\x05 50 %RUPEE% \x05\x00";
|
rupeeText = "\x05\x05 50 %RUPEE%\x05\x00";
|
||||||
break;
|
break;
|
||||||
case TEXT_HUGE_RUPEE:
|
case TEXT_HUGE_RUPEE:
|
||||||
rupeeText = "\x05\x06 200 %RUPEE% \x05\x00";
|
rupeeText = "\x05\x06 200 %RUPEE%\x05\x00";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
customMessageManager->CreateMessage(Randomizer::rupeeMessageTableID, rupee,
|
customMessageManager->CreateMessage(Randomizer::rupeeMessageTableID, rupee,
|
||||||
{ TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM,
|
{ TEXTBOX_TYPE_BLACK, TEXTBOX_POS_BOTTOM,
|
||||||
"You found" + rupeeText + "!",
|
"You found" + rupeeText + " !",
|
||||||
"Du hast" + rupeeText + " gefunden!",
|
"Du hast" + rupeeText + " gefunden!",
|
||||||
"Vous obtenez" + rupeeText + "!"
|
"Vous obtenez" + rupeeText + " !"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
void Randomizer::CreateCustomMessages() {
|
||||||
// RANDTODO: Translate into french and german and replace GIMESSAGE_UNTRANSLATED
|
// RANDTODO: Translate into french and german and replace GIMESSAGE_UNTRANSLATED
|
||||||
// with GIMESSAGE(getItemID, itemID, english, german, french).
|
// with GIMESSAGE(getItemID, itemID, english, german, french).
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "../../../include/z64item.h"
|
#include "../../../include/z64item.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <soh/Enhancements/randomizer/randomizerTypes.h>
|
#include <soh/Enhancements/randomizer/randomizerTypes.h>
|
||||||
|
#include <soh/Enhancements/custom-message/CustomMessageManager.h>
|
||||||
|
|
||||||
class Randomizer {
|
class Randomizer {
|
||||||
private:
|
private:
|
||||||
@ -47,6 +48,8 @@ class Randomizer {
|
|||||||
GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId);
|
GetItemID GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId);
|
||||||
GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum);
|
GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum);
|
||||||
static void CreateCustomMessages();
|
static void CreateCustomMessages();
|
||||||
|
std::string Randomizer_InsertRupeeName(std::string message, int language);
|
||||||
|
CustomMessageEntry Randomizer_GetRupeeMessage(u16 rupeeTextId);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "Enhancements/cosmetics/CosmeticsEditor.h"
|
#include "Enhancements/cosmetics/CosmeticsEditor.h"
|
||||||
#include "Enhancements/debugconsole.h"
|
#include "Enhancements/debugconsole.h"
|
||||||
#include "Enhancements/debugger/debugger.h"
|
#include "Enhancements/debugger/debugger.h"
|
||||||
|
#include <soh/Enhancements/randomizer/randomizer.h>
|
||||||
#include <soh/Enhancements/randomizer/randomizer_item_tracker.h>
|
#include <soh/Enhancements/randomizer/randomizer_item_tracker.h>
|
||||||
#include "Enhancements/n64_weird_frame_data.inc"
|
#include "Enhancements/n64_weird_frame_data.inc"
|
||||||
#include "soh/frame_interpolation.h"
|
#include "soh/frame_interpolation.h"
|
||||||
@ -1447,54 +1448,6 @@ extern "C" CustomMessageEntry Randomizer_GetScrubMessage(u16 scrubTextId) {
|
|||||||
return CustomMessageManager::Instance->RetrieveMessage(Randomizer::scrubMessageTableID, price);
|
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() {
|
extern "C" CustomMessageEntry Randomizer_GetAltarMessage() {
|
||||||
return (LINK_IS_ADULT)
|
return (LINK_IS_ADULT)
|
||||||
? CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_ALTAR_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) &&
|
} else if (!CVar_GetS32("gRandoDisableRandomRupeeNames", 0) &&
|
||||||
(textId == TEXT_BLUE_RUPEE || textId == TEXT_RED_RUPEE || textId == TEXT_PURPLE_RUPEE ||
|
(textId == TEXT_BLUE_RUPEE || textId == TEXT_RED_RUPEE || textId == TEXT_PURPLE_RUPEE ||
|
||||||
textId == TEXT_HUGE_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) {
|
if (textId == TEXT_GS_NO_FREEZE || textId == TEXT_GS_FREEZE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user