mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
make safeModeCheck return a boolean
This commit is contained in:
parent
e4905a0a20
commit
c2e9eb9718
3 changed files with 30 additions and 22 deletions
|
@ -84,21 +84,26 @@ void tryShowForwardCompat() {
|
|||
}
|
||||
|
||||
#ifdef GEODE_IS_WINDOWS
|
||||
void safeModeCheck() {
|
||||
// yes this is quite funny
|
||||
if (GetAsyncKeyState(VK_SHIFT) != 0) {
|
||||
auto choice = MessageBoxA(
|
||||
NULL,
|
||||
"(This has been triggered because you were holding SHIFT)\n"
|
||||
"Do you want to activate Geode Safe Mode? This disables loading any mods.",
|
||||
"Attention",
|
||||
MB_YESNO | MB_ICONINFORMATION
|
||||
);
|
||||
if (choice == IDYES) {
|
||||
LoaderImpl::get()->forceSafeMode();
|
||||
}
|
||||
}
|
||||
bool safeModeCheck() {
|
||||
// yes this is quite funny
|
||||
if (GetAsyncKeyState(VK_SHIFT) != 0) {
|
||||
auto choice = MessageBoxA(
|
||||
NULL,
|
||||
"(This has been triggered because you were holding SHIFT)\n"
|
||||
"Do you want to activate Geode Safe Mode? This disables loading any mods.",
|
||||
"Attention",
|
||||
MB_YESNO | MB_ICONINFORMATION
|
||||
);
|
||||
return choice == IDYES;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else !defined(GEODE_IS_MACOS)
|
||||
// macos is defined in load.mm, this is for android
|
||||
// on android the launcher just adds the launch args to enable safe mode
|
||||
bool safeModeCheck() {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
int geodeEntry(void* platformData) {
|
||||
|
@ -110,7 +115,9 @@ int geodeEntry(void* platformData) {
|
|||
console::openIfClosed();
|
||||
}
|
||||
|
||||
safeModeCheck();
|
||||
if (safeModeCheck()) {
|
||||
LoaderImpl::get()->forceSafeMode();
|
||||
}
|
||||
|
||||
std::string forwardCompatSuffix;
|
||||
if (LoaderImpl::get()->isForwardCompatMode())
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#pragma once
|
||||
void safeModeCheck();
|
||||
bool safeModeCheck();
|
||||
int geodeEntry(void* platformData);
|
|
@ -1,14 +1,15 @@
|
|||
#include "load.hpp"
|
||||
#include <loader/LoaderImpl.hpp>
|
||||
#include <loader/LogImpl.hpp>
|
||||
#include <Geode/platform/cplatform.h>
|
||||
|
||||
#ifdef GEODE_IS_MACOS
|
||||
|
||||
#include <loader/LoaderImpl.hpp>
|
||||
#include <loader/LogImpl.hpp>
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
void safeModeCheck() {
|
||||
bool safeModeCheck() {
|
||||
if (CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, (CGKeyCode)56)) { // 56 is Shift key
|
||||
NSAlert *alert = [NSAlert new];
|
||||
alert.messageText = @"The shift key was held down. Would you like to enable safe mode?";
|
||||
|
@ -16,10 +17,10 @@ void safeModeCheck() {
|
|||
NSButton *cancelButton = [alert addButtonWithTitle:@"No"];
|
||||
alert.window.defaultButtonCell = cancelButton.cell;
|
||||
NSModalResponse choice = [alert runModal];
|
||||
if (choice == NSAlertFirstButtonReturn) { // if Yes is clicked
|
||||
LoaderImpl::get()->forceSafeMode();
|
||||
}
|
||||
// if Yes is clicked
|
||||
return choice == NSAlertFirstButtonReturn;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue