Skip to content

Commit

Permalink
Last few map fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
MunWolf committed Nov 18, 2023
1 parent 16e2498 commit bae4baf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions projects/Modloader/il2cpp_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ namespace il2cpp {
return components;
}

app::Component_1* get_component_in_children_untyped(app::GameObject* game_object, Il2CppClass* klass) {
return reinterpret_cast<app::Component_1*>(UnityEngine::GameObject::GetComponentInChildren_2(game_object, get_runtime_type(klass)));
app::Component_1* get_component_in_children_untyped(app::GameObject* game_object, Il2CppClass* klass, bool include_inactive) {
return reinterpret_cast<app::Component_1*>(UnityEngine::GameObject::GetComponentInChildren_1(game_object, get_runtime_type(klass), include_inactive));
}

app::ScriptableObject* create_scriptable_object_untyped(Il2CppClass* klass) {
Expand Down
10 changes: 5 additions & 5 deletions projects/Modloader/il2cpp_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace il2cpp {
IL2CPP_MODLOADER_DLLEXPORT app::Transform* get_transform(void* object);
IL2CPP_MODLOADER_DLLEXPORT app::GameObject* get_game_object(void* component);
IL2CPP_MODLOADER_DLLEXPORT app::Component_1* add_component_untyped(app::GameObject* game_object, Il2CppClass* klass);
IL2CPP_MODLOADER_DLLEXPORT app::Component_1* get_component_in_children_untyped(app::GameObject* game_object, Il2CppClass* klass);
IL2CPP_MODLOADER_DLLEXPORT app::Component_1* get_component_in_children_untyped(app::GameObject* game_object, Il2CppClass* klass, bool include_inactive = false);
IL2CPP_MODLOADER_DLLEXPORT std::vector<app::Component_1*> get_components_in_children_untyped(app::GameObject* game_object, Il2CppClass* klass);
IL2CPP_MODLOADER_DLLEXPORT std::string get_path(void* object);
IL2CPP_MODLOADER_DLLEXPORT std::vector<std::string> get_path_v(void* object);
Expand Down Expand Up @@ -285,13 +285,13 @@ namespace il2cpp {
}

template <typename Return = app::Component_1>
Return* get_component_in_children(app::GameObject* game_object, Il2CppClass* klass) {
return reinterpret_cast<Return*>(get_component_in_children_untyped(game_object, klass));
Return* get_component_in_children(app::GameObject* game_object, Il2CppClass* klass, bool include_inactive = false) {
return reinterpret_cast<Return*>(get_component_in_children_untyped(game_object, klass, include_inactive));
}

template <typename Return = app::Component_1>
Return* get_component_in_children(app::GameObject* game_object, void* klass) {
return get_component_in_children<Return>(game_object, reinterpret_cast<Il2CppClass*>(klass));
Return* get_component_in_children(app::GameObject* game_object, void* klass, bool include_inactive = false) {
return get_component_in_children<Return>(game_object, reinterpret_cast<Il2CppClass*>(klass), include_inactive);
}

template <typename Return = app::Component_1>
Expand Down
8 changes: 4 additions & 4 deletions projects/Randomizer/game/map/icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#include <Modloader/app/methods/UnityEngine/GameObject.h>
#include <Modloader/app/methods/UnityEngine/Object.h>
#include <Modloader/app/types/AreaMapUI.h>
#include <Modloader/app/types/GameObject.h>
#include <Modloader/app/types/Renderer.h>
#include <Modloader/app/types/RuntimeWorldMapIcon.h>
#include <Modloader/app/types/TextBox.h>

#include <utility>
Expand Down Expand Up @@ -60,7 +58,7 @@ namespace randomizer::game::map {
UnityEngine::Object::Instantiate_3(reinterpret_cast<app::Object_1*>(AreaMapIconManager::GetIcon(manager, m_icon)))
);

m_text_box = il2cpp::unity::get_component_in_children<app::TextBox>(m_game_object, types::TextBox::get_class());
m_text_box = il2cpp::unity::get_component_in_children<app::TextBox>(m_game_object, types::TextBox::get_class(), true);
if (m_text_box != nullptr && m_label.has_value()) {
CatlikeCoding::TextBox::TextBox::SetText_2(m_text_box, il2cpp::string_new(m_label.value()));
CatlikeCoding::TextBox::TextBox::RenderText(m_text_box);
Expand Down Expand Up @@ -102,7 +100,9 @@ namespace randomizer::game::map {
initialize_game_object();
}

UnityEngine::GameObject::set_active(m_game_object, value);
if (m_text_box != nullptr) {
UnityEngine::GameObject::set_active(il2cpp::unity::get_game_object(m_text_box), value);
}
}

void Icon::opacity(float value) {
Expand Down
16 changes: 16 additions & 0 deletions projects/Randomizer/game/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
#include <game/map/map.h>
#include <online/multiplayer.h>

#include <Core/api/game/ui.h>
#include <Core/settings.h>

#include <Modloader/app/methods/AreaMapIconManager.h>
#include <Modloader/app/methods/GameMapUI.h>
#include <Modloader/app/methods/Moon/uberSerializationWisp/PlayerUberStateAreaMapInformation.h>
#include <Modloader/app/methods/RuntimeWorldMapIcon.h>
#include <Modloader/app/structs/Boolean__Boxed.h>
#include <Modloader/app/types/AreaMapIconManager.h>
#include <Modloader/app/types/GameMapUI.h>
#include <Modloader/app/types/GameWorld.h>
#include <Modloader/app/types/PlayerUberStateGroup.h>
#include <Modloader/il2cpp_helpers.h>
Expand Down Expand Up @@ -53,6 +56,19 @@ namespace randomizer::game::map {
next::RuntimeWorldMapIcon::Show(this_ptr);
}

IL2CPP_INTERCEPT(AreaMapIconManager, void, UpdateLabelState, (app::AreaMapIconManager * this_ptr)) {
next::AreaMapIconManager::UpdateLabelState(this_ptr);
auto show_labels = core::api::game::ui::area_map_open() &&
GameMapUI::get_ShowIconLabels(types::GameMapUI::get_class()->static_fields->Instance);

for (auto filter : icons) {
auto active = filter.first == active_filter();
for (auto icon : filter.second) {
icon->label_visible(active && show_labels);
}
}
}

bool should_always_show_teleporters() {
return core::settings::always_show_warps() && (active_filter() > Filters::Collectibles);
}
Expand Down

0 comments on commit bae4baf

Please sign in to comment.