Skip to content

Commit

Permalink
Merge pull request #78 from MikeIsAStar/translate-open-host-messages
Browse files Browse the repository at this point in the history
[MKW] Translate Open Host messages
  • Loading branch information
mkwcat authored Sep 12, 2024
2 parents 8a7e1c0 + bb21123 commit 236a2e0
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 10 deletions.
71 changes: 61 additions & 10 deletions payload/import/mkw/ui/page/openHostPage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "import/mkw/system/system.hpp"
#include "import/mkw/ui/multiMenuInputManager.hpp"
#include "import/mkw/ui/section/sectionManager.hpp"
#include "import/revolution.h"
#include "messagePopupPage.hpp"
#include "yesNoPopupPage.hpp"

Expand Down Expand Up @@ -62,6 +63,58 @@ class OpenHostPage : public Page
Result,
};

const wchar_t* openHostPromptMessage() const
{
u8 language = RVL::SCGetLanguage();

const wchar_t* openHostPromptMessage =
s_openHostPromptMessages[language];
if (openHostPromptMessage) {
return openHostPromptMessage;
}

return s_openHostPromptMessages[RVL::SCLanguageEnglish];
}

const wchar_t* connectionLostMessage() const
{
u8 language = RVL::SCGetLanguage();

const wchar_t* connectionLostMessage =
s_connectionLostMessages[language];
if (connectionLostMessage) {
return connectionLostMessage;
}

return s_connectionLostMessages[RVL::SCLanguageEnglish];
}

const wchar_t* openHostEnabledMessage() const
{
u8 language = RVL::SCGetLanguage();

const wchar_t* openHostEnabledMessage =
s_openHostEnabledMessages[language];
if (openHostEnabledMessage) {
return openHostEnabledMessage;
}

return s_openHostEnabledMessages[RVL::SCLanguageEnglish];
}

const wchar_t* openHostDisabledMessage() const
{
u8 language = RVL::SCGetLanguage();

const wchar_t* openHostDisabledMessage =
s_openHostDisabledMessages[language];
if (openHostDisabledMessage) {
return openHostDisabledMessage;
}

return s_openHostDisabledMessages[RVL::SCLanguageEnglish];
}

State resolve() const
{
switch (s_state) {
Expand Down Expand Up @@ -93,11 +146,7 @@ class OpenHostPage : public Page
}
case State::Prompt: {
FormatParam formatParam{};
formatParam.strings[0] =
L"Enable Open Host?\n\n"
L"This feature allows players who\n"
L"add your friend code to meet up with you,\n"
L"even if you don't add them back.";
formatParam.strings[0] = openHostPromptMessage();

YesNoPopupPage* yesNoPopupPage =
section->page<YesNoPopupPage>(PageId::YesNoPopup);
Expand All @@ -117,14 +166,12 @@ class OpenHostPage : public Page
case State::Result: {
FormatParam formatParam{};
if (!s_sentOpenHostValue) {
formatParam.strings[0] = L"You have lost connection to\n"
L"the server.\n\n"
L"Please try again later.";
formatParam.strings[0] = connectionLostMessage();
} else {
if (s_openHostEnabled) {
formatParam.strings[0] = L"Open Host is now enabled!";
formatParam.strings[0] = openHostEnabledMessage();
} else {
formatParam.strings[0] = L"Open Host is now disabled!";
formatParam.strings[0] = openHostDisabledMessage();
}
}

Expand Down Expand Up @@ -172,6 +219,10 @@ class OpenHostPage : public Page
static mkw::UI::YesNoPage::Handler<OpenHostPage>* s_onYesOrNo;
static bool s_openHostEnabled;
static bool s_sentOpenHostValue;
static const wchar_t* s_openHostPromptMessages[RVL::SCLanguageCount];
static const wchar_t* s_connectionLostMessages[RVL::SCLanguageCount];
static const wchar_t* s_openHostEnabledMessages[RVL::SCLanguageCount];
static const wchar_t* s_openHostDisabledMessages[RVL::SCLanguageCount];
};

static_assert(sizeof(OpenHostPage) == sizeof(Page));
Expand Down
22 changes: 22 additions & 0 deletions payload/import/revolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ namespace RVL
{
#endif

typedef enum {
SCLanguageJapanese = 0x00,
SCLanguageEnglish = 0x01,
SCLanguageGerman = 0x02,
SCLanguageFrench = 0x03,
SCLanguageSpanish = 0x04,
SCLanguageItalian = 0x05,
SCLanguageDutch = 0x06,
SCLanguageSimplifiedChinese = 0x07,
SCLanguageTraditionalChinese = 0x08,
SCLanguageKorean = 0x09,
SCLanguageCount,
} SCLanguage;

LONGCALL void OSReport( //
const char* format, ...
) AT(ADDRESS_OSReport);
Expand Down Expand Up @@ -38,6 +52,14 @@ LONGCALL s32 IOS_Ioctlv( //
s32 fd, u32 cmd, u32 in_count, u32 out_count, IOVector* vec
) AT(ADDRESS_IOS_Ioctlv);

#if RMC

LONGCALL u8 SCGetLanguage( //
void
) AT(RMCXD_PORT(0x801B1D0C, 0x801B1C6C, 0x801B1C2C, 0x801B2068));

#endif

LONGCALL bool SCGetProductSN( //
u32* serial
) AT(ADDRESS_SCGetProductSN);
Expand Down
69 changes: 69 additions & 0 deletions payload/wwfcFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,75 @@ MenuInputManager::Handler<OpenHostPage>* OpenHostPage::s_onOption = nullptr;
YesNoPage::Handler<OpenHostPage>* OpenHostPage::s_onYesOrNo = nullptr;
bool OpenHostPage::s_openHostEnabled = false;
bool OpenHostPage::s_sentOpenHostValue = false;
const wchar_t* OpenHostPage::s_openHostPromptMessages[RVL::SCLanguageCount] = {
L"こうかいホストをゆうこうにしますか?\n"
L"\n"
L"この機能はあなたのフレンドコードを\n"
L"追加したプレイヤーはあなたが追加し返さなくても\n"
L"フレンドとしてあなたと会えるようになる機能です",
L"Enable Open Host?\n"
L"\n"
L"This feature allows players who\n"
L"add your friend code to meet up with you,\n"
L"even if you don't add them back.",
nullptr,
L"Activer l'Open Host?\n"
L"\n"
L"Cette fonctionnalité permet aux joueurs qui\n"
L"ajoutent votre code ami de vous rejoindre,\n"
L"même si vous ne les avez pas ajoutés.",
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
};
const wchar_t* OpenHostPage::s_connectionLostMessages[RVL::SCLanguageCount] = {
L"サーバーからの接続が切断されました\n"
L"\n"
L"もう一度やり直してください",
L"You have lost connection to\n"
L"the server.\n"
L"\n"
L"Please try again later.",
nullptr,
L"Vous avez perdu la connexion\n"
L"au serveur.\n"
L"\n"
L"Veuillez réessayer ultérieurement.",
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
};
const wchar_t* OpenHostPage::s_openHostEnabledMessages[RVL::SCLanguageCount] = {
L"こうかいホストをゆうこうにしました!",
L"Open Host is now enabled!",
nullptr,
L"Open Host est maintenant activé!",
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
};
const wchar_t* OpenHostPage::s_openHostDisabledMessages[RVL::SCLanguageCount] =
{
L"こうかいホストをむこうにしました!",
L"Open Host is now disabled!",
nullptr,
L"Open Host est maintenant désactivé!",
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
};

const wchar_t* WifiMenuPage::s_messageOfTheDay =
L"Welcome to\nWiiLink Wi-Fi Connection!";
Expand Down

0 comments on commit 236a2e0

Please sign in to comment.