mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-20 18:09:59 -04:00
trigger safe mode on windows by holding shift on game launch
This commit is contained in:
parent
cc4c32e12f
commit
a327f722c8
5 changed files with 30 additions and 2 deletions
loader/src
|
@ -92,6 +92,20 @@ int geodeEntry(void* platformData) {
|
|||
if (LoaderImpl::get()->isForwardCompatMode()) {
|
||||
console::openIfClosed();
|
||||
}
|
||||
#ifdef GEODE_IS_WINDOWS
|
||||
// yes this is quite funny
|
||||
if (GetAsyncKeyState(VK_SHIFT) != 0) {
|
||||
LoaderImpl::get()->forceSafeMode();
|
||||
std::thread([] {
|
||||
MessageBoxA(
|
||||
NULL,
|
||||
"You have triggered Geode Safe Mode by holding SHIFT.\nGeode will not load any mods.",
|
||||
"Attention",
|
||||
MB_OK | MB_ICONINFORMATION
|
||||
);
|
||||
}).detach();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string forwardCompatSuffix;
|
||||
if (LoaderImpl::get()->isForwardCompatMode())
|
||||
|
|
|
@ -845,3 +845,11 @@ Result<tulip::hook::HandlerHandle> Loader::Impl::getOrCreateHandler(void* addres
|
|||
m_handlerHandles[address] = handle;
|
||||
return Ok(handle);
|
||||
}
|
||||
|
||||
bool Loader::Impl::isSafeMode() const {
|
||||
return m_forceSafeMode || this->getLaunchFlag("safe-mode");
|
||||
}
|
||||
|
||||
void Loader::Impl::forceSafeMode() {
|
||||
m_forceSafeMode = true;
|
||||
}
|
|
@ -135,6 +135,11 @@ namespace geode {
|
|||
bool userTriedToLoadDLLs() const;
|
||||
|
||||
void addProblem(LoadProblem const& problem);
|
||||
|
||||
bool m_forceSafeMode = false;
|
||||
bool isSafeMode() const;
|
||||
// enables safe mode, even if the launch arg wasnt provided
|
||||
void forceSafeMode();
|
||||
};
|
||||
|
||||
class LoaderImpl : public Loader::Impl {
|
||||
|
|
|
@ -357,7 +357,7 @@ bool Mod::Impl::getLaunchFlag(std::string_view const name) const {
|
|||
// Loading, Toggling, Installing
|
||||
|
||||
Result<> Mod::Impl::loadBinary() {
|
||||
if (!this->isInternal() && Loader::get()->getLaunchFlag("safe-mode")) {
|
||||
if (!this->isInternal() && LoaderImpl::get()->isSafeMode()) {
|
||||
// pretend to have loaded the mod, so that it still shows up on the mod list properly,
|
||||
// while the user can still toggle/uninstall it
|
||||
m_enabled = true;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <Geode/utils/ranges.hpp>
|
||||
#include <Geode/loader/Mod.hpp>
|
||||
#include <Geode/binding/CCContentLayer.hpp>
|
||||
#include <loader/LoaderImpl.hpp>
|
||||
|
||||
#define FTS_FUZZY_MATCH_IMPLEMENTATION
|
||||
#include <Geode/external/fts/fts_fuzzy_match.h>
|
||||
|
@ -365,7 +366,7 @@ bool ModListLayer::init() {
|
|||
this->onTab(nullptr);
|
||||
|
||||
// add safe mode label
|
||||
if (Loader::get()->getLaunchFlag("safe-mode")) {
|
||||
if (LoaderImpl::get()->isSafeMode()) {
|
||||
auto* label = CCLabelBMFont::create("Safe Mode Enabled", "bigFont.fnt");
|
||||
label->setPosition(winSize.width / 2.f, 17);
|
||||
label->setScale(0.625f);
|
||||
|
|
Loading…
Reference in a new issue