Skip to content

Commit

Permalink
[BACKPORT] Fix empty message providers showing a message
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschwarzer committed Dec 16, 2024
1 parent 12ce1f8 commit 75bfbc1
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions projects/Randomizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ set(
"uber_states/uber_state_initialization.cpp"
"uber_states/uber_state_intercepts.cpp"
"ui/always_show_keystones.cpp"
"ui/empty_message_provider_fix.cpp"
"ui/main_menu_seed_info.cpp"
)

Expand Down
67 changes: 67 additions & 0 deletions projects/Randomizer/ui/empty_message_provider_fix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <Modloader/app/methods/CatlikeCoding/TextBox/TextBox.h>
#include <Modloader/app/methods/Moon/UI/Text.h>
#include <Modloader/app/methods/TranslatedMessageProvider_MessageItem.h>
#include <Modloader/interception_macros.h>
#include <Modloader/modloader.h>
#include <optional>

namespace {
using namespace app::classes;

app::String* get_string_for_language(app::TranslatedMessageProvider_MessageItem* message_item, app::Language__Enum language) {
switch (language) {
case app::Language__Enum::French:
return message_item->fields.French;
case app::Language__Enum::Italian:
return message_item->fields.Italian;
case app::Language__Enum::German:
return message_item->fields.German;
case app::Language__Enum::Spanish:
return message_item->fields.Spanish;
case app::Language__Enum::Japanese:
return message_item->fields.Japanese;
case app::Language__Enum::Portuguese:
return message_item->fields.Portuguese;
case app::Language__Enum::Chinese:
return message_item->fields.Chinese;
case app::Language__Enum::Russian:
return message_item->fields.Russian;
case app::Language__Enum::TraditionalChinese:
return message_item->fields.TraditionalChinese;
case app::Language__Enum::Czech:
return message_item->fields.Czech;
case app::Language__Enum::Danish:
return message_item->fields.Danish;
case app::Language__Enum::Dutch:
return message_item->fields.Dutch;
case app::Language__Enum::Finnish:
return message_item->fields.Finnish;
case app::Language__Enum::Hungarian:
return message_item->fields.Hungarian;
case app::Language__Enum::Korean:
return message_item->fields.Korean;
case app::Language__Enum::Norwegian:
return message_item->fields.Norwegian;
case app::Language__Enum::Polish:
return message_item->fields.Polish;
case app::Language__Enum::SpanishSpain:
return message_item->fields.SpanishSpain;
case app::Language__Enum::Swedish:
return message_item->fields.Swedish;
case app::Language__Enum::Turkish:
return message_item->fields.Turkish;
case app::Language__Enum::English:
default:
return message_item->fields.English;
}
}

IL2CPP_INTERCEPT(TranslatedMessageProvider_MessageItem, app::MessageDescriptor, GetDescriptor, (app::TranslatedMessageProvider_MessageItem * this_ptr, app::Language__Enum language)) {
return {
get_string_for_language(this_ptr, language),
this_ptr->fields.Emotion,
this_ptr->fields.Sound,
this_ptr->fields.WWiseEvent,
};
}
}

0 comments on commit 75bfbc1

Please sign in to comment.