diff options
| author | petrie911 <petrie911@yahoo.com> | 2024-04-24 05:05:49 -0500 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2024-04-24 13:41:23 -0600 |
| commit | df54367b676f44d2b925e681ae05eef665f7c45f (patch) | |
| tree | 50ba65d2ed4471fd3d2aad9316f1de24e06ed0a1 /src/factories/sf64/ScriptFactory.cpp | |
| parent | 91e834d819c82f0d64cf4f71ea9d1788c9135bda (diff) | |
message
Diffstat (limited to 'src/factories/sf64/ScriptFactory.cpp')
| -rw-r--r-- | src/factories/sf64/ScriptFactory.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/factories/sf64/ScriptFactory.cpp b/src/factories/sf64/ScriptFactory.cpp index b968e23..d925046 100644 --- a/src/factories/sf64/ScriptFactory.cpp +++ b/src/factories/sf64/ScriptFactory.cpp @@ -4,6 +4,7 @@ #include "Companion.h" #include "utils/Decompressor.h" #include "utils/TorchUtils.h" +#include "factories/sf64/MessageFactory.h" #include <regex> #include "storm/SWrapper.h" @@ -28,6 +29,17 @@ ExportResult SF64::ScriptHeaderExporter::Export(std::ostream &write, std::shared return std::nullopt; } +std::string GetMsg(uint16_t msgId) { + std::string msg = ""; + auto rawmsg = Companion::Instance->GetParseDataBySymbol("gMsg_ID_" + std::to_string(msgId)); + + if(rawmsg.has_value() && rawmsg.value().data.has_value()) { + auto msgData = std::static_pointer_cast<SF64::MessageData>(rawmsg.value().data.value()); + auto msg = std::regex_replace(msgData->mMesgStr, std::regex(R"(\n)"), " "); + } + return msg; +} + std::string MakeScriptCmd(uint16_t s1, uint16_t s2) { auto opcode = (s1 & 0xFE00) >> 9; auto arg1 = s1 & 0x1FF; @@ -136,6 +148,10 @@ std::string MakeScriptCmd(uint16_t s1, uint16_t s2) { case 120: { auto rcidName = VALUE_TO_ENUM(arg1, "RadioCharacterId", "RCID_UNK"); cmd << "EVENT_PLAY_MSG(" << rcidName << ", " << std::dec << s2; + auto msg = GetMsg(s2); + if(!msg.empty()) { + comment << " // " << msg; + } } break; case 121: { auto teamId = VALUE_TO_ENUM(s2, "TeamId", "TEAMID_UNK"); |
