summaryrefslogtreecommitdiff
path: root/src/factories/sf64/ScriptFactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/factories/sf64/ScriptFactory.cpp')
-rw-r--r--src/factories/sf64/ScriptFactory.cpp16
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");