Skip to content

Commit f9228a0

Browse files
authored
Custom message multilang backend finishing touches (#149)
* Add MakeColored function to Text class Surround each language's string with # to easily make a given string colored. Should be well suited to text meant for the start of a custom message. * Make Tingle and Clock Tower Door multilang-ready - Use full Text objects intead of regular strings - Only fetch them with GetEnglish in CreateMessage - Include some French strings as a bonus
1 parent 88244e9 commit f9228a0

2 files changed

Lines changed: 109 additions & 39 deletions

File tree

source/hints.cpp

Lines changed: 105 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -441,45 +441,48 @@ void CreateTingleHintText() {
441441
if (Settings::ShuffleTingleMaps.Is(true)) {
442442
// Logic: Get item names from location.
443443
// Create custom message for each tingle location (6)
444-
std::string clockTownMap = ItemTable(Location(TINGLE_N_CLOCK_TOWN_CT)->GetPlacedItemKey()).GetName().GetEnglish();
445-
std::string woodfallMap = ItemTable(Location(TINGLE_N_CLOCK_TOWN_WF)->GetPlacedItemKey()).GetName().GetEnglish();
446-
std::string snowHeadMap = ItemTable(Location(TINGLE_TWIN_ISLANDS_SH)->GetPlacedItemKey()).GetName().GetEnglish();
447-
std::string romaniMap = ItemTable(Location(TINGLE_TWIN_ISLANDS_RR)->GetPlacedItemKey()).GetName().GetEnglish();
448-
std::string greatBayMap = ItemTable(Location(TINGLE_GBC_GB)->GetPlacedItemKey()).GetName().GetEnglish();
449-
std::string stoneTowerMap = ItemTable(Location(TINGLE_GBC_ST)->GetPlacedItemKey()).GetName().GetEnglish();
450-
444+
Text clockTownMap = ItemTable(Location(TINGLE_N_CLOCK_TOWN_CT)->GetPlacedItemKey()).GetName().MakeColored();
445+
Text woodfallMap = ItemTable(Location(TINGLE_N_CLOCK_TOWN_WF)->GetPlacedItemKey()).GetName().MakeColored();
446+
Text snowHeadMap = ItemTable(Location(TINGLE_TWIN_ISLANDS_SH)->GetPlacedItemKey()).GetName().MakeColored();
447+
Text romaniMap = ItemTable(Location(TINGLE_TWIN_ISLANDS_RR)->GetPlacedItemKey()).GetName().MakeColored();
448+
Text greatBayMap = ItemTable(Location(TINGLE_GBC_GB)->GetPlacedItemKey()).GetName().MakeColored();
449+
Text ikanaMap = ItemTable(Location(TINGLE_GBC_ST)->GetPlacedItemKey()).GetName().MakeColored();
450+
451+
// {"English", "French", "Spanish"}
452+
Text priceFive = {" #5 Rupees#&", " #5 Rubis#&", ""};
453+
Text priceTwenty = {" #20 Rupees#&", " #20 Rubis#&", ""};
454+
Text priceForty = {" #40 Rupees#", " #40 Rubis#", ""};
455+
Text leaveShop = {"&#No thanks#", "&#Non merci#", ""};
456+
457+
Text tingleTextClockTown = clockTownMap+priceFive+woodfallMap+priceForty+leaveShop;
458+
Text tingleTextWoodfall = woodfallMap+priceTwenty+snowHeadMap+priceForty+leaveShop;
459+
Text tingleTextSnowhead = snowHeadMap+priceTwenty+romaniMap+priceForty+leaveShop;
460+
Text tingleTextMilkRoad = romaniMap+priceTwenty+greatBayMap+priceForty+leaveShop;
461+
Text tingleTextGreatBay = greatBayMap+priceTwenty+ikanaMap+priceForty+leaveShop;
462+
Text tingleTextIkana = ikanaMap+priceTwenty+clockTownMap+priceForty+leaveShop;
463+
451464
CustomMessages::CreateMessage(0x1D11, 0xFFFF, 0x3FF0A005, 0xFF1001,
452-
{clockTownMap.insert(0, "#").append("# #5 Rupees#&").append(woodfallMap.insert(0, "#").c_str()).append("# #40 Rupees#").append("&#No thanks#").c_str()},
465+
{tingleTextClockTown.GetEnglish().c_str()},
453466
{QM_GREEN, QM_RED, QM_GREEN, QM_RED, QM_GREEN}, {}, {}, 0x0, false, false);
454-
clockTownMap = ItemTable(Location(TINGLE_N_CLOCK_TOWN_CT)->GetPlacedItemKey()).GetName().GetEnglish();
455-
woodfallMap = ItemTable(Location(TINGLE_N_CLOCK_TOWN_WF)->GetPlacedItemKey()).GetName().GetEnglish();
456467

457468
CustomMessages::CreateMessage(0x1D12, 0xFFFF, 0x3FF0A014, 0xFF1001,
458-
{woodfallMap.insert(0, "#").append("# #20 Rupees#&").append(snowHeadMap.insert(0, "#").c_str()).append("# #40 Rupees#").append("&#No thanks#").c_str()},
469+
{tingleTextWoodfall.GetEnglish().c_str()},
459470
{QM_GREEN, QM_RED, QM_GREEN, QM_RED, QM_GREEN}, {}, {}, 0x0, false, false);
460-
woodfallMap = ItemTable(Location(TINGLE_N_CLOCK_TOWN_WF)->GetPlacedItemKey()).GetName().GetEnglish();
461-
snowHeadMap = ItemTable(Location(TINGLE_TWIN_ISLANDS_SH)->GetPlacedItemKey()).GetName().GetEnglish();
462471

463472
CustomMessages::CreateMessage(0x1D13, 0xFFFF, 0x3FF0A014, 0xFF1001,
464-
{snowHeadMap.insert(0, "#").append("# #20 Rupees#&").append(romaniMap.insert(0, "#").c_str()).append("# #40 Rupees#").append("&#No thanks#").c_str()},
473+
{tingleTextSnowhead.GetEnglish().c_str(),},
465474
{QM_GREEN, QM_RED, QM_GREEN, QM_RED, QM_GREEN}, {}, {}, 0x0, false, false);
466-
snowHeadMap = ItemTable(Location(TINGLE_TWIN_ISLANDS_SH)->GetPlacedItemKey()).GetName().GetEnglish();
467-
romaniMap = ItemTable(Location(TINGLE_TWIN_ISLANDS_RR)->GetPlacedItemKey()).GetName().GetEnglish();
468475

469476
CustomMessages::CreateMessage(0x1D14, 0xFFFF, 0x3FF0A014, 0xFF1001,
470-
{romaniMap.insert(0, "#").append("# #20 Rupees#&").append(greatBayMap.insert(0, "#").c_str()).append("# #40 Rupees#").append("&#No thanks#").c_str()},
477+
{tingleTextMilkRoad.GetEnglish().c_str()},
471478
{QM_GREEN, QM_RED, QM_GREEN, QM_RED, QM_GREEN}, {}, {}, 0x0, false, false);
472-
romaniMap = ItemTable(Location(TINGLE_TWIN_ISLANDS_RR)->GetPlacedItemKey()).GetName().GetEnglish();
473-
greatBayMap = ItemTable(Location(TINGLE_GBC_GB)->GetPlacedItemKey()).GetName().GetEnglish();
474479

475480
CustomMessages::CreateMessage(0x1D15, 0xFFFF, 0x3FF0A014, 0xFF1001,
476-
{greatBayMap.insert(0, "#").append("# #20 Rupees#&").append(stoneTowerMap.insert(0, "#").c_str()).append("# #40 Rupees#").append("&#No thanks#").c_str()},
481+
{tingleTextGreatBay.GetEnglish().c_str()},
477482
{QM_GREEN, QM_RED, QM_GREEN, QM_RED, QM_GREEN}, {}, {}, 0x0, false, false);
478-
greatBayMap = ItemTable(Location(TINGLE_GBC_GB)->GetPlacedItemKey()).GetName().GetEnglish();
479-
stoneTowerMap = ItemTable(Location(TINGLE_GBC_ST)->GetPlacedItemKey()).GetName().GetEnglish();
480483

481484
CustomMessages::CreateMessage(0x1D16, 0xFFFF, 0x3FF0A014, 0xFF1001,
482-
{stoneTowerMap.insert(0, "#").append("# #20 Rupees#&").append(clockTownMap.insert(0, "#").c_str()).append("# #40 Rupees#").append("&#No thanks#").c_str()},
485+
{tingleTextIkana.GetEnglish().c_str()},
483486
{QM_GREEN, QM_RED, QM_GREEN, QM_RED, QM_GREEN}, {}, {}, 0x0, false, false);
484487
}
485488
}
@@ -491,49 +494,112 @@ void CreateTingleHintText() {
491494
return Text()+ITEM_OBTAINED(itemID)+"#"+GetHintRegion(Location(location)->GetParentRegionKey())->GetHint().GetText()+"#...^";
492495
}*/
493496

494-
static std::string BuildDoorText(const ItemKey itemKey) {
497+
static Text BuildDoorText(const ItemKey itemKey) {
495498
LocationKey location = FilterFromPool(allLocations, [itemKey](const LocationKey loc){return Location(loc)->GetPlacedItemKey() == itemKey;})[0];
496499
if (Location(location)->GetParentRegionKey() == NONE) {
497500
Location(location)->SetParentRegion(LINKS_POCKET);
498501
}
499-
return "#"+GetHintRegion(Location(location)->GetParentRegionKey())->GetHint().GetText().GetEnglish()+"#.";
502+
return GetHintRegion(Location(location)->GetParentRegionKey())->GetHint().GetText().MakeColored()+".";
500503
}
501504

502505
void CreateClockTowerDoorHints() {
503506
// Create hint text
504-
std::string ocarinaHint = "Hey, didn't you have some sort of #musical instrument#?&If I know the Skull Kid, I bet he hid it at "+BuildDoorText(OCARINA_OF_TIME);
505-
std::string odolwaHint = "There's one with a #crown# and #jewellery# said to be found at "+BuildDoorText(ODOLWAS_REMAINS);
506-
std::string gohtHint = "Another #extremely sturdy# one with #huge horns# at "+BuildDoorText(GOHTS_REMAINS);
507-
std::string gyorgHint = "One with #giant fins# and #razor sharp teeth# at "+BuildDoorText(GYORGS_REMAINS);
508-
std::string twinmoldHint = "And one with #three eyes# and #enormous mandibles# at "+BuildDoorText(TWINMOLDS_REMAINS);
507+
Text ocarinaHint = Text{
508+
//English
509+
"Hey, didn't you have some sort of #musical instrument#?&If I know the Skull Kid, I bet he hid it at ",
510+
//French
511+
"Dis, t'avais pas un #instrument de musique#?&Je parie que Skull Kid, l'a caché vers ",
512+
//Spanish
513+
""
514+
}+BuildDoorText(OCARINA_OF_TIME);
515+
Text odolwaHint = Text{
516+
//English
517+
"There's one with a #crown# and #jewellery# said to be found at ",
518+
//French
519+
"Y'en a un avec une #couronne# et des #bijoux# situé vers ",
520+
//Spanish
521+
""
522+
}+BuildDoorText(ODOLWAS_REMAINS);
523+
Text gohtHint = Text{
524+
//English
525+
"Another #extremely sturdy# one with #huge horns# at ",
526+
//French
527+
"Un autre #très solide# avec des #cornes immenses# situé vers ",
528+
//Spanish
529+
""
530+
}+BuildDoorText(GOHTS_REMAINS);
531+
Text gyorgHint = Text{
532+
//English
533+
"One with #giant fins# and #razor sharp teeth# at ",
534+
//French
535+
"Un qui a des #nageoires géantes# et #dents acérées# situé vers ",
536+
//Spanish
537+
""
538+
}+BuildDoorText(GYORGS_REMAINS);
539+
Text twinmoldHint = Text{
540+
//English
541+
"And one with #three eyes# and #enormous mandibles# at ",
542+
//French
543+
"Et un avec #trois yeux# et d'#énormes mandibules# situé vers ",
544+
//Spanish
545+
""
546+
}+BuildDoorText(TWINMOLDS_REMAINS);
509547
if (StartingOdolwaRemains.Value<u8>() == 1) {
510-
odolwaHint = "There's one with a #crown# and #jewellery# said to be found in "+BuildDoorText(ODOLWAS_REMAINS);
548+
odolwaHint = Text{
549+
//English
550+
"There's one with a #crown# and #jewellery# said to be found in ",
551+
//French
552+
"Y'en a un avec une #couronne# et des #bijoux# situé dans ",
553+
//Spanish
554+
""
555+
}+BuildDoorText(ODOLWAS_REMAINS);
511556
}
512557
if (StartingGohtRemains.Value<u8>() == 1) {
513-
gohtHint = "Another #extremely sturdy# one with #huge horns# in "+BuildDoorText(GOHTS_REMAINS);
558+
gohtHint = Text{
559+
//English
560+
"Another #extremely sturdy# one with #huge horns# in ",
561+
//French
562+
"Un autre #très solide# avec des #cornes immenses# situé dans ",
563+
//Spanish
564+
""
565+
}+BuildDoorText(GOHTS_REMAINS);
514566
}
515567
if (StartingGyorgRemains.Value<u8>() == 1) {
516-
gyorgHint = "One with #giant fins# and #razor sharp teeth# in "+BuildDoorText(GYORGS_REMAINS);
568+
gyorgHint = Text{
569+
//English
570+
"One with #giant fins# and #razor sharp teeth# in ",
571+
//French
572+
"Un qui a des #nageoires géantes# et #dents acérées# situé dans ",
573+
//Spanish
574+
""
575+
}+BuildDoorText(GYORGS_REMAINS);
517576
}
518577
if (StartingTwinmoldRemains.Value<u8>() == 1){
519-
twinmoldHint = "And one with #three eyes# and #enormous mandibles# in "+BuildDoorText(TWINMOLDS_REMAINS);
578+
twinmoldHint = Text{
579+
//English
580+
"And one with #three eyes# and #enormous mandibles# in ",
581+
//French
582+
"Et un avec #trois yeux# et d'#énormes mandibules# situé dans ",
583+
//Spanish
584+
""
585+
}+BuildDoorText(TWINMOLDS_REMAINS);
520586
}
521587

522588
CustomMessages::CreateMessage(0x0630, (StartingOcarina.Value<u8>() == 0) ? 0x8000 : 0x8002, 0x3FFFFFFF, 0x0FF0211,
523589
{"Rooftop access strictly prohibited!&(Enforceable until #midnight# on the&#eve# of the carnival.)^"
524590
"#Notice of carnival activities:#&Musical Performance Contest&Unique Mask Contest&#Prizes available!#"},
525591
{QM_RED, QM_RED, QM_RED, QM_MAGENTA}, {}, {}, 0x0, false, false);
526-
CustomMessages::CreateMessage(0x8000, 0x8001, 0x3FFFFFFF, 0x1000000, {ocarinaHint.c_str()}, {QM_BLUE, QM_RED}, {}, {}, 0x083E, false, false);
592+
CustomMessages::CreateMessage(0x8000, 0x8001, 0x3FFFFFFF, 0x1000000, {ocarinaHint.GetEnglish().c_str()}, {QM_BLUE, QM_RED}, {}, {}, 0x083E, false, false);
527593
CustomMessages::CreateMessage(0x8001, 0x8003, 0x3FFFFFFF, 0x1FF0000,
528594
{"Also, that #mask competition# sounds interesting! I've heard rumours of some pretty #rare masks# around here, truly one of a kind stuff!"},
529595
{QM_RED, QM_RED}, {}, {}, 0x0, false, false);
530596
CustomMessages::CreateMessage(0x8002, 0x8003, 0x3FFFFFFF, 0x1FF0000,
531597
{"Hey, that #mask competition# sounds interesting! I've heard rumours of some pretty #rare masks# around here, truly one of a kind stuff!"},
532598
{QM_RED, QM_RED}, {}, {}, 0x083E, false, false);
533-
CustomMessages::CreateMessage(0x8003, 0x8004, 0x3FFFFFFF, 0x15D0000, {odolwaHint.c_str()}, {QM_GREEN, QM_GREEN, QM_RED}, {}, {}, 0x0, false, false);
534-
CustomMessages::CreateMessage(0x8004, 0x8005, 0x3FFFFFFF, 0x15E0000, {gohtHint.c_str()}, {QM_MAGENTA, QM_MAGENTA, QM_RED}, {}, {}, 0x0, false, false);
535-
CustomMessages::CreateMessage(0x8005, 0x8006, 0x3FFFFFFF, 0x15F0000, {gyorgHint.c_str()}, {QM_CYAN, QM_CYAN, QM_RED}, {}, {}, 0x0, false, false);
536-
CustomMessages::CreateMessage(0x8006, 0xFFFF, 0x3FFFFFFF, 0x0600000, {twinmoldHint.c_str()}, {QM_YELLOW, QM_YELLOW, QM_RED}, {}, {}, 0x0, false, false);
599+
CustomMessages::CreateMessage(0x8003, 0x8004, 0x3FFFFFFF, 0x15D0000, {odolwaHint.GetEnglish().c_str()}, {QM_GREEN, QM_GREEN, QM_RED}, {}, {}, 0x0, false, false);
600+
CustomMessages::CreateMessage(0x8004, 0x8005, 0x3FFFFFFF, 0x15E0000, {gohtHint.GetEnglish().c_str()}, {QM_MAGENTA, QM_MAGENTA, QM_RED}, {}, {}, 0x0, false, false);
601+
CustomMessages::CreateMessage(0x8005, 0x8006, 0x3FFFFFFF, 0x15F0000, {gyorgHint.GetEnglish().c_str()}, {QM_CYAN, QM_CYAN, QM_RED}, {}, {}, 0x0, false, false);
602+
CustomMessages::CreateMessage(0x8006, 0xFFFF, 0x3FFFFFFF, 0x0600000, {twinmoldHint.GetEnglish().c_str()}, {QM_YELLOW, QM_YELLOW, QM_RED}, {}, {}, 0x0, false, false);
537603
}
538604

539605
//insert the required number into the hint and set the singular/plural form

source/include/text.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class Text {
3939
return Text{english + right, french + right, spanish + right};
4040
}
4141

42+
Text MakeColored() const {
43+
return Text{"#" + english + "#", "#" + french + "#", "#" + spanish + "#"};
44+
}
45+
4246
bool operator==(const Text& right) const {
4347
return english == right.english;
4448
}

0 commit comments

Comments
 (0)