mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-26 04:06:32 +00:00
pull in project-slippi/Ishiiruka/pull/275
This commit is contained in:
parent
1f9217f7df
commit
1bc9f205f8
2 changed files with 33 additions and 11 deletions
|
@ -2448,15 +2448,23 @@ std::vector<u8> CEXISlippi::loadPremadeText(u8* payload)
|
|||
|
||||
u8 paramId = payload[1];
|
||||
|
||||
for (auto it = spt.unsupportedStringMap.begin(); it != spt.unsupportedStringMap.end(); it++)
|
||||
{
|
||||
playerName = ReplaceAll(playerName.c_str(), it->second, ""); // Remove unsupported chars
|
||||
playerName = ReplaceAll(playerName.c_str(), it->first,
|
||||
it->second); // Remap delimiters for premade text
|
||||
}
|
||||
|
||||
// Replaces spaces with premade text space
|
||||
playerName = ReplaceAll(playerName.c_str(), " ", "<S>");
|
||||
|
||||
if (paramId == SlippiPremadeText::CHAT_MSG_CHAT_DISABLED)
|
||||
{
|
||||
return premadeTextData =
|
||||
spt.GetPremadeTextData(SlippiPremadeText::SPT_CHAT_DISABLED, playerName.c_str());
|
||||
}
|
||||
|
||||
auto chatMessage = spt.premadeTextsParams[paramId];
|
||||
std::string param = ReplaceAll(chatMessage.c_str(), " ", "<S>");
|
||||
playerName = ReplaceAll(playerName.c_str(), " ", "<S>");
|
||||
premadeTextData = spt.GetPremadeTextData(textId, playerName.c_str(), param.c_str());
|
||||
}
|
||||
else
|
||||
|
|
|
@ -74,15 +74,21 @@ public:
|
|||
};
|
||||
|
||||
unordered_map<u8, string> premadeTexts = {
|
||||
{SPT_CHAT_P1, "<LEFT><KERN><COLOR, 229, 76, 76>%s-<S><COLOR, 255, 255, 255>%s<END>"},
|
||||
{SPT_CHAT_P2, "<LEFT><KERN><COLOR, 59, 189, 255>%s-<S><COLOR, 255, 255, 255>%s<END>"},
|
||||
{SPT_CHAT_P3, "<LEFT><KERN><COLOR, 255, 203, 4>%s-<S><COLOR, 255, 255, 255>%s<END>"},
|
||||
{SPT_CHAT_P4, "<LEFT><KERN><COLOR, 0, 178, 2>%s-<S><COLOR, 255, 255, 255>%s<END>"},
|
||||
{SPT_CHAT_P1, "<LEFT><KERN><COLOR, 229, 76, 76>%s:<S><COLOR, 255, 255, 255>%s<END>"},
|
||||
{SPT_CHAT_P2, "<LEFT><KERN><COLOR, 59, 189, 255>%s:<S><COLOR, 255, 255, 255>%s<END>"},
|
||||
{SPT_CHAT_P3, "<LEFT><KERN><COLOR, 255, 203, 4>%s:<S><COLOR, 255, 255, 255>%s<END>"},
|
||||
{SPT_CHAT_P4, "<LEFT><KERN><COLOR, 0, 178, 2>%s:<S><COLOR, 255, 255, 255>%s<END>"},
|
||||
{SPT_LOGOUT, "<FIT><COLOR, 243, 75, 75>Are<S>You<COLOR, 0, 175, 75><S>Sure?<END>"},
|
||||
{SPT_CHAT_DISABLED,
|
||||
"<LEFT><KERN><COLOR, 0, 178, 2>%s<S><COLOR, 255, 255, 255>has<S>chat<S>disabled<S><END>"},
|
||||
};
|
||||
|
||||
// This is just a map of delimiters and temporary replacements to remap them before the name is
|
||||
// converted to Slippi Premade Text format
|
||||
unordered_map<string, string> unsupportedStringMap = {
|
||||
{"<", "\\"}, {">", "`"}, {",", ""}, // DELETE U+007F
|
||||
};
|
||||
|
||||
// TODO: use va_list to handle any no. or args
|
||||
string GetPremadeTextString(u8 textId) { return premadeTexts[textId]; }
|
||||
|
||||
|
@ -190,6 +196,16 @@ public:
|
|||
{
|
||||
int chr = utfMatch[c];
|
||||
|
||||
// We are manually replacing "<" for "\" and ">" for "`" because I don't want to handle
|
||||
// vargs and we need to prevent "format injection" lol...
|
||||
for (auto it = unsupportedStringMap.begin(); it != unsupportedStringMap.end(); it++)
|
||||
{
|
||||
if (it->second.find(chr) != std::string::npos || (chr == U'Ç' && it->first[0] == ','))
|
||||
{ // Need to figure out how to find extended ascii chars (Ç)
|
||||
chr = it->first[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Yup, fuck strchr and cpp too, I'm not in the mood to spend 4 more hours researching
|
||||
// how to get Japanese characters properly working with a map, so I put everything on an
|
||||
// int array in hex
|
||||
|
@ -213,8 +229,7 @@ public:
|
|||
data.push_back(r);
|
||||
data.push_back(r2);
|
||||
}
|
||||
else
|
||||
return empty;
|
||||
// otherwise ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -415,11 +430,10 @@ private:
|
|||
U'ト', U'ド', U'ナ', U'ニ', U'ヌ', U'ネ', U'ノ', U'ハ', U'バ', U'パ', U'ヒ', U'ビ', U'ピ',
|
||||
U'フ', U'ブ', U'プ', U'ヘ', U'ベ', U'ペ', U'ホ', U'ボ', U'ポ', U'マ', U'ミ', U'ム', U'メ',
|
||||
U'モ', U'ャ', U'ヤ', U'ュ', U'ユ', U'ョ', U'ヨ', U'ラ', U'リ', U'ル', U'レ', U'ロ', U'ヮ',
|
||||
U'ワ', U'ヲ', U'ン', U'ヴ', U'ヵ', U'ヶ', U' ', U'、', U'。', U',', U'.', U'•', U',',
|
||||
U'ワ', U'ヲ', U'ン', U'ヴ', U'ヵ', U'ヶ', U' ', U'、', U'。', U',', U'.', U'•', U':',
|
||||
U';', U'?', U'!', U'^', U'_', U'—', U'/', U'~', U'|', U'\'', U'"', U'(', U')',
|
||||
U'[', U']', U'{', U'}', U'+', '-', U'×', U'=', U'<', U'>', U'¥', U'$', U'%',
|
||||
U'#', U'&', U'*', U'@', U'扱', U'押', U'軍', U'源', U'個', U'込', U'指', U'示', U'取',
|
||||
U'書', U'詳', U'人', U'生', U'説', U'体', U'団', U'電', U'読', U'発', U'抜', U'閑', U'本',
|
||||
U'明',
|
||||
};
|
||||
U'明'};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue