Merge branch 'main' into new-index-but-better

This commit is contained in:
HJfod 2024-03-13 22:51:11 +02:00
commit f685fa0c4f
7 changed files with 44 additions and 23 deletions

View file

@ -428,6 +428,7 @@ enum class IconType {
Jetpack = 8,
DeathEffect = 98,
Special = 99,
ShipFire = 101,
};
enum class GJChallengeType {

View file

@ -2,6 +2,7 @@
#include "Event.hpp"
#include "Loader.hpp"
#include "Mod.hpp"
#include <matjson.hpp>
namespace geode::ipc {
@ -64,5 +65,9 @@ namespace geode::ipc {
IPCFilter(IPCFilter const&) = default;
};
std::monostate listen(std::string const& messageID, matjson::Value(*callback)(IPCEvent*));
inline void listen(std::string const& messageID, matjson::Value(*callback)(IPCEvent*)) {
(void) new EventListener(
callback, IPCFilter(getMod()->getID(), messageID)
);
}
}

View file

@ -0,0 +1,12 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/CCMenuItem.hpp>
using namespace geode::prelude;
class $modify(CCMenuItem) {
void activate() {
this->retain();
CCMenuItem::activate();
this->release();
}
};

View file

@ -10,6 +10,8 @@ using namespace geode::prelude;
// This workaround solves the issue by making it impossible to start the level during a transition.
struct CustomLevelPage : Modify<CustomLevelPage, LevelPage> {
GEODE_FORWARD_COMPAT_DISABLE_HOOKS("Impostor PlayLayer fix")
void onPlay(cocos2d::CCObject* sender) {
if (!typeinfo_cast<CCTransitionScene*>(CCScene::get())) {
LevelPage::onPlay(sender);

View file

@ -7,8 +7,9 @@ using namespace geode::prelude;
struct CustomProfilePage : Modify<CustomProfilePage, ProfilePage> {
GEODE_FORWARD_COMPAT_DISABLE_HOOKS("ProfilePage fix")
virtual TodoReturn getUserInfoFinished(GJUserScore* info) {
ProfilePage::getUserInfoFinished(info);
virtual void getUserInfoFinished(GJUserScore* info) {
m_usernameLabel->setString(info->m_userName.c_str());
m_usernameLabel->limitLabelWidth(info->m_modBadge > 0 ? 140.f : 160.0f, 0.8f, 0.0f);
ProfilePage::getUserInfoFinished(info);
}
};

View file

@ -5,13 +5,6 @@
using namespace geode::prelude;
std::monostate ipc::listen(std::string const& messageID, matjson::Value(*callback)(IPCEvent*)) {
(void) new EventListener(
callback, IPCFilter(getMod()->getID(), messageID)
);
return std::monostate();
}
ipc::IPCEvent::IPCEvent(
void* rawPipeHandle,
std::string const& targetModID,

View file

@ -77,22 +77,29 @@ std::string utils::clipboard::read() {
}
bool utils::file::openFolder(ghc::filesystem::path const& path) {
// mods can (and do) keep CoInitializeEx initialized on the main thread
// which results in this function just not doing anything
// which is why we're using a separate thread
// feel free to rework later, im just tired of reports of this not working
auto success = false;
if (CoInitializeEx(nullptr, COINIT_MULTITHREADED) == S_OK) {
if (auto id = ILCreateFromPathW(path.wstring().c_str())) {
ghc::filesystem::path selectPath = path / ".";
std::error_code whatever;
if (!ghc::filesystem::is_directory(path, whatever)) {
selectPath = path;
auto thread = std::thread([](auto const& path, bool& success) {
if (CoInitializeEx(nullptr, COINIT_MULTITHREADED) == S_OK) {
if (auto id = ILCreateFromPathW(path.wstring().c_str())) {
ghc::filesystem::path selectPath = path / ".";
std::error_code whatever;
if (!ghc::filesystem::is_directory(path, whatever)) {
selectPath = path;
}
auto selectEntry = ILCreateFromPathW(selectPath.wstring().c_str());
if (SHOpenFolderAndSelectItems(id, 1, (PCUITEMID_CHILD_ARRAY)(&selectEntry), 0) == S_OK) {
success = true;
}
ILFree(id);
}
auto selectEntry = ILCreateFromPathW(selectPath.wstring().c_str());
if (SHOpenFolderAndSelectItems(id, 1, (PCUITEMID_CHILD_ARRAY)(&selectEntry), 0) == S_OK) {
success = true;
}
ILFree(id);
CoUninitialize();
}
CoUninitialize();
}
}, path, std::ref(success));
thread.join();
return success;
}