macOS bar button items

This commit is contained in:
Serena 2023-02-06 22:17:27 +03:00
parent 738b7fc630
commit 6d474ac59d
10 changed files with 420 additions and 24 deletions

View File

@ -1231,8 +1231,9 @@ elseif(TARGET SDL2::SDL2)
endif()
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
if(APPLE)
set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm SDL/SDLCocoaMetalLayer.h SDL/SDLCocoaMetalLayer.mm UI/DarwinFileSystemServices.mm UI/DarwinFileSystemServices.h Common/Battery/AppleBatteryClient.m)
set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm SDL/SDLCocoaMetalLayer.h SDL/SDLCocoaMetalLayer.mm SDL/MacOSBarItems.mm SDL/MacOSBarItems.h UI/DarwinFileSystemServices.mm UI/DarwinFileSystemServices.h Common/Battery/AppleBatteryClient.m)
set_source_files_properties(UI/DarwinFileSystemServices.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
set_source_files_properties(SDL/MacOSBarItems.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
set_source_files_properties(Common/Battery/AppleBatteryClient.m PROPERTIES COMPILE_FLAGS -fobjc-arc)
set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY})
elseif(USING_EGL)

View File

@ -1301,6 +1301,15 @@ void Config::SetAppendedConfigIni(const Path &path) {
appendedConfigFileName_ = path;
}
void Config::updateAfterSettingAutoFrameSkip() {
if (bAutoFrameSkip && iFrameSkip == 0) {
iFrameSkip = 1;
}
if (bAutoFrameSkip && bSkipBufferEffects) {
bSkipBufferEffects = false;
}
}
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
if (!bUpdatedInstanceCounter) {

View File

@ -572,7 +572,10 @@ public:
const std::map<std::string, std::pair<std::string, int>> &GetLangValuesMapping();
bool LoadAppendedConfig();
void SetAppendedConfigIni(const Path &path);
void updateAfterSettingAutoFrameSkip();
protected:
void LoadStandardControllerIni();
void LoadLangValuesMapping();

21
SDL/MacOSBarItems.h Normal file
View File

@ -0,0 +1,21 @@
//
// MacOSBarItems.h
// PPSSPP
//
// Created by Serena on 06/02/2023.
//
#ifndef MacOSBarItems_h
#define MacOSBarItems_h
#ifdef __cplusplus
extern "C" {
#endif
void initBarItemsForApp();
#ifdef __cplusplus
}
#endif
#endif /* MacOSBarItems_h */

326
SDL/MacOSBarItems.mm Normal file
View File

@ -0,0 +1,326 @@
//
// MacOSBarItems.mm
// PPSSPP
//
// Created by Serena on 06/02/2023.
//
#include "Common/System/System.h"
#include "Common/System/NativeApp.h"
#include "Core/Config.h"
#include "Common/Data/Text/I18n.h"
#include "Common/StringUtils.h"
#import <AppKit/AppKit.h>
#ifdef __cplusplus
extern "C" {
#endif
// NSMenuItem requires the use of an objective-c selector (aka the devil's greatest trick)
// So we have to make this class
@interface BarItemsManager : NSObject
+(instancetype)sharedInstance;
-(void)setupAppBarItems;
@property (assign) NSMenu *openMenu;
@property (assign) std::shared_ptr<I18NCategory> mainSettingsLocalization;
@end
void initBarItemsForApp() {
[[BarItemsManager sharedInstance] setupAppBarItems];
}
// im soooooo sorry for whoever had to read this impl
@implementation BarItemsManager
+ (instancetype)sharedInstance {
static BarItemsManager *stub;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
stub = [BarItemsManager new];
stub.mainSettingsLocalization = GetI18NCategory("MainSettings");
});
return stub;
}
-(void)setupAppBarItems {
NSMenuItem *openMenuItem = [[NSMenuItem alloc] init];
openMenuItem.submenu = [self makeOpenSubmenu];
NSMenuItem *graphicsMenuItem = [[NSMenuItem alloc] init];
graphicsMenuItem.submenu = [self makeGraphicsMenu];
NSMenuItem *audioMenuItem = [[NSMenuItem alloc] init];
audioMenuItem.submenu = [self makeAudioMenu];
[NSApplication.sharedApplication.menu addItem:openMenuItem];
[NSApplication.sharedApplication.menu addItem:graphicsMenuItem];
[NSApplication.sharedApplication.menu addItem:audioMenuItem];
}
-(NSMenu *)makeOpenSubmenu {
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"File"];
NSMenuItem *openWithSystemFolderBrowserItem = [[NSMenuItem alloc] initWithTitle:@"Open..." action:@selector(openSystemFileBrowser) keyEquivalent:@"o"];
openWithSystemFolderBrowserItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
openWithSystemFolderBrowserItem.enabled = YES;
openWithSystemFolderBrowserItem.target = self;
[menu addItem:openWithSystemFolderBrowserItem];
self.openMenu = menu;
[self addOpenRecentlyItem];
return menu;
}
-(NSMenu *)makeGraphicsMenu {
NSMenu *parent = [[NSMenu alloc] initWithTitle:@(self.mainSettingsLocalization->T("Graphics"))];
NSMenu *backendsMenu = [[NSMenu alloc] init];
auto graphicsLocalization = GetI18NCategory("Graphics");
#define GRAPHICS_LOCALIZED(key) @(graphicsLocalization->T(key))
NSMenuItem *gpuBackendItem = [[NSMenuItem alloc] initWithTitle:GRAPHICS_LOCALIZED("Backend") action:nil keyEquivalent:@""];
std::vector<GPUBackend> allowed = [self allowedGPUBackends];
for (int i = 0; i < allowed.size(); i++) {
NSMenuItem *backendMenuItem = [[NSMenuItem alloc] initWithTitle:@(GPUBackendToString(allowed[i]).c_str()) action: @selector(setCurrentGPUBackend:) keyEquivalent: @""];
backendMenuItem.tag = i;
backendMenuItem.target = self;
backendMenuItem.state = [self controlStateForBool: g_Config.iGPUBackend == (int)allowed[i]];
[backendsMenu addItem:backendMenuItem];
}
gpuBackendItem.submenu = backendsMenu;
[parent addItem:gpuBackendItem];
[parent addItem:[NSMenuItem separatorItem]];
#define MENU_ITEM(variableName, localizedTitleName, SEL, ConfigurationValueName) \
NSMenuItem *variableName = [[NSMenuItem alloc] initWithTitle:GRAPHICS_LOCALIZED(localizedTitleName) action:SEL keyEquivalent:@""]; \
variableName.target = self; \
variableName.state = [self controlStateForBool: ConfigurationValueName];
MENU_ITEM(softwareRendering, "Software Rendering", @selector(toggleSoftwareRendering:), g_Config.bSoftwareRendering)
[parent addItem:softwareRendering];
MENU_ITEM(vsyncItem, "VSync", @selector(toggleVSync:), g_Config.bVSync)
[parent addItem:vsyncItem];
MENU_ITEM(fullScreenItem, "Fullscreen", @selector(toggleFullScreen:), g_Config.bFullScreen)
[parent addItem:fullScreenItem];
[parent addItem:[NSMenuItem separatorItem]];
MENU_ITEM(autoFrameSkip, "Auto FrameSkip", @selector(toggleAutoFrameSkip:), g_Config.bAutoFrameSkip)
[parent addItem:autoFrameSkip];
[parent addItem:[NSMenuItem separatorItem]];
MENU_ITEM(fpsCounterItem, "Show FPS Counter", @selector(setToggleShowCounterItem:), g_Config.iShowStatusFlags & (int)ShowStatusFlags::FPS_COUNTER)
fpsCounterItem.tag = (int)ShowStatusFlags::FPS_COUNTER;
MENU_ITEM(speedCounterItem, "Show Speed", @selector(setToggleShowCounterItem:), g_Config.iShowStatusFlags & (int)ShowStatusFlags::SPEED_COUNTER)
speedCounterItem.tag = (int)ShowStatusFlags::SPEED_COUNTER;
MENU_ITEM(batteryPercentItem, "Show battery %", @selector(setToggleShowCounterItem:), g_Config.iShowStatusFlags & (int)ShowStatusFlags::BATTERY_PERCENT)
batteryPercentItem.tag = (int)ShowStatusFlags::BATTERY_PERCENT;
[parent addItem:[NSMenuItem separatorItem]];
[parent addItem:fpsCounterItem];
[parent addItem:speedCounterItem];
[parent addItem:batteryPercentItem];
[[NSNotificationCenter defaultCenter] addObserverForName:@"ConfigDidChange" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
NSString *value = [note object];
// NOTE: Though it may seem like it,
// the next few lines were not written by yandere dev
if ([value isEqualToString:@"VSync"]) {
vsyncItem.state = [self controlStateForBool: g_Config.bVSync];
} else if ([value isEqualToString:@"FullScreen"]) {
fullScreenItem.state = [self controlStateForBool: g_Config.bFullScreen];
} else if ([value isEqualToString:@"SoftwareRendering"]) {
softwareRendering.state = [self controlStateForBool: g_Config.bSoftwareRendering];
} else if ([value isEqualToString:@"AutoFrameSkip"]) {
autoFrameSkip.state = [self controlStateForBool: g_Config.bAutoFrameSkip];
} else if ([value isEqualToString:@"ShowFPSCounter"]) {
fpsCounterItem.state = [self controlStateForBool:g_Config.iShowStatusFlags & (int)ShowStatusFlags::FPS_COUNTER];
} else if ([value isEqualToString:@"ShowSpeed"]) {
speedCounterItem.state = [self controlStateForBool:g_Config.iShowStatusFlags & (int)ShowStatusFlags::SPEED_COUNTER];
} else if ([value isEqualToString:@"BatteryPercent"]) {
batteryPercentItem.state = [self controlStateForBool:g_Config.iShowStatusFlags & (int)ShowStatusFlags::BATTERY_PERCENT];
}
}];
#undef MENU_ITEM
#undef GRAPHICS_LOCALIZED
return parent;
}
-(NSMenu *)makeAudioMenu {
NSMenu *parent = [[NSMenu alloc] initWithTitle:@(self.mainSettingsLocalization->T("Audio"))];
auto audioLocalization = GetI18NCategory("Audio");
NSMenuItem *enableSoundItem = [[NSMenuItem alloc] initWithTitle:@(audioLocalization->T("Enable Sound")) action:@selector(toggleSound:) keyEquivalent:@""];
enableSoundItem.target = self;
enableSoundItem.state = [self controlStateForBool: g_Config.bEnableSound];
[parent addItem:enableSoundItem];
NSMenuItem *deviceListItem = [[NSMenuItem alloc] initWithTitle:@(audioLocalization->T("Device")) action:nil keyEquivalent:@""];
deviceListItem.submenu = [self makeAudioListMenuWithItem:deviceListItem];
[parent addItem:deviceListItem];
[[NSNotificationCenter defaultCenter] addObserverForName:@"AudioConfChanged" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
NSString *value = [note object];
if ([value isEqualToString:@"EnableSound"]) {
enableSoundItem.state = [self controlStateForBool:g_Config.bEnableSound];
}
}];
return parent;
}
-(NSMenu *)makeAudioListMenuWithItem: (NSMenuItem *)callerItem {
__block NSMenu *theMenu = [[NSMenu alloc] init];
std::vector<std::string> audioDeviceList;
SplitString(System_GetProperty(SYSPROP_AUDIO_DEVICE_LIST), '\0', audioDeviceList);
for (int i = 0; i < audioDeviceList.size(); i++) {
std::string itemName = audioDeviceList[i];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@(itemName.c_str()) action:@selector(setAudioItem:) keyEquivalent:@""];
item.tag = i;
item.target = self;
item.state = [self controlStateForBool:g_Config.sAudioDevice == itemName];
[theMenu addItem:item];
}
[[NSNotificationCenter defaultCenter] addObserverForName:@"AudioConfigurationHasChanged" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
NSString *value = [note object];
if ([value isEqualToString: @"DeviceAddedOrChanged"]) {
callerItem.submenu = [self makeAudioListMenuWithItem:callerItem];
} else if ([value isEqualToString:@"CurrentDeviceWasChanged"]) {
// set the new item to be the selected one
dispatch_async(dispatch_get_main_queue(), ^{
for (NSMenuItem *item in theMenu.itemArray)
item.state = [self controlStateForBool:g_Config.sAudioDevice == audioDeviceList[item.tag]];
});
}
}];
return theMenu;
}
-(void) setAudioItem: (NSMenuItem *)sender {
std::vector<std::string> audioDeviceList;
SplitString(System_GetProperty(SYSPROP_AUDIO_DEVICE_LIST), '\0', audioDeviceList);
std::string theItemSelected = audioDeviceList[sender.tag];
if (theItemSelected == g_Config.sAudioDevice)
return; // device already selected
g_Config.sAudioDevice = theItemSelected;
for (NSMenuItem *item in sender.menu.itemArray) {
item.state = [self controlStateForBool:g_Config.sAudioDevice == theItemSelected];
}
System_SendMessage("audio_resetDevice", "");
}
#define TOGGLE_METHOD(name, ConfigValueName, ...) \
-(void)toggle##name: (NSMenuItem *)item { \
ConfigValueName = !ConfigValueName; \
__VA_ARGS__; /* for any additional updates */ \
item.state = [self controlStateForBool: ConfigValueName]; \
}
TOGGLE_METHOD(Sound, g_Config.bEnableSound)
TOGGLE_METHOD(AutoFrameSkip, g_Config.bAutoFrameSkip, g_Config.updateAfterSettingAutoFrameSkip())
TOGGLE_METHOD(SoftwareRendering, g_Config.bSoftwareRendering)
TOGGLE_METHOD(FullScreen, g_Config.bFullScreen, System_SendMessage("toggle_fullscreen", g_Config.UseFullScreen() ? "1" : "0"))
TOGGLE_METHOD(VSync, g_Config.bVSync)
#undef TOGGLE_METHOD
-(void)setToggleShowCounterItem: (NSMenuItem *)item {
[self addOrRemoveInteger:(int)item.tag to:&g_Config.iShowStatusFlags];
item.state = [self controlStateForBool:g_Config.iShowStatusFlags & item.tag];
}
-(void)addOrRemoveInteger: (int)integer to: (int *)r {
if (integer & *r) {
*r -= integer;
} else {
*r |= integer;
}
}
-(void)setCurrentGPUBackend: (NSMenuItem *)sender {
std::vector<GPUBackend> allowed = [self allowedGPUBackends];
if (allowed.size() == 1) {
printf("only one item, bailing");
return;
}
g_Config.iGPUBackend = (int)(allowed[sender.tag]);
sender.state = NSControlStateValueOn;
for (NSMenuItem *item in sender.menu.itemArray) {
// deselect the previously selected item
if (item.state == NSControlStateValueOn && item.tag != sender.tag) {
item.state = NSControlStateValueOff;
break;
}
}
}
-(NSControlStateValue) controlStateForBool: (BOOL)boolValue {
return boolValue ? NSControlStateValueOn : NSControlStateValueOff;
}
-(std::vector<GPUBackend>)allowedGPUBackends {
std::vector<GPUBackend> allBackends = {
GPUBackend::OPENGL, GPUBackend::VULKAN,
GPUBackend::DIRECT3D11, GPUBackend::DIRECT3D9
};
std::vector<GPUBackend> allowed;
for (GPUBackend backend : allBackends) {
if (g_Config.IsBackendEnabled(backend)) {
allowed.push_back(backend);
}
}
return allowed;
}
-(void)addOpenRecentlyItem {
std::vector<std::string> recentIsos = g_Config.RecentIsos();
NSMenuItem *openRecent = [[NSMenuItem alloc] initWithTitle:@"Open Recent" action:nil keyEquivalent:@""];
NSMenu *recentsMenu = [[NSMenu alloc] init];
if (recentIsos.empty())
openRecent.enabled = NO;
for (int i = 0; i < recentIsos.size(); i++) {
std::string filename = Path(recentIsos[i]).GetFilename();
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@(filename.c_str()) action:@selector(openRecentItem:) keyEquivalent:@""];
item.target = self;
[recentsMenu addItem:item];
}
openRecent.submenu = recentsMenu;
[self.openMenu addItem:openRecent];
}
-(void)openRecentItem: (NSMenuItem *)item {
NativeMessageReceived("browse_fileSelect", g_Config.RecentIsos()[item.tag].c_str());
}
-(void)openSystemFileBrowser {
System_SendMessage("browse_folder", "");
}
- (void)dealloc {
[NSNotificationCenter.defaultCenter removeObserver:self];
}
@end
#ifdef __cplusplus
}
#endif

View File

@ -62,6 +62,10 @@ SDLJoystick *joystick = NULL;
#include "UI/DarwinFileSystemServices.h"
#endif
#if PPSSPP_PLATFORM(MAC)
#include "MacOSBarItems.h"
#endif
GlobalUIState lastUIState = UISTATE_MENU;
GlobalUIState GetUIState();
@ -846,6 +850,12 @@ int main(int argc, char *argv[]) {
int mouseWheelMovedDownFrames = 0;
bool mouseCaptured = false;
bool windowHidden = false;
#if PPSSPP_PLATFORM(MAC)
// setup menu items for macOS
initBarItemsForApp();
#endif
while (true) {
double startTime = time_now_d();
@ -1144,6 +1154,7 @@ int main(int argc, char *argv[]) {
if (doAutoSwitch || g_Config.sAudioDevice == name) {
StopSDLAudioDevice();
InitSDLAudioDevice(name ? name : "");
PostDarwinNotificationIfPossible("AudioConfigurationHasChanged", "DeviceAddedOrChanged");
}
}
break;
@ -1151,6 +1162,7 @@ int main(int argc, char *argv[]) {
if (event.adevice.iscapture == 0 && event.adevice.which == audioDev) {
StopSDLAudioDevice();
InitSDLAudioDevice();
PostDarwinNotificationIfPossible("AudioConfigurationHasChanged", "DeviceAddedOrChanged");
}
break;
#endif

View File

@ -32,3 +32,13 @@ private:
void *__pickerDelegate = NULL;
#endif // PPSSPP_PLATFORM(IOS)
};
void PostDarwinNotification(const char *name, const char *value);
#if PPSSPP_PLATFORM(MAC)
// Currently, this is just macOS only
// to update the top bar
#define PostDarwinNotificationIfPossible(name, value) PostDarwinNotification(name, value)
#else
#define PostDarwinNotificationIfPossible(name, value)
#endif

View File

@ -109,3 +109,7 @@ void DarwinFileSystemServices::setUserPreferredMemoryStickDirectory(Path path) {
forKey:@(PreferredMemoryStickUserDefaultsKey)];
g_Config.memStickDirectory = path;
}
void PostDarwinNotification(const char *name, const char *value) {
[[NSNotificationCenter defaultCenter] postNotificationName:@(name) object: @(value)];
}

View File

@ -95,6 +95,17 @@ extern AndroidAudioState *g_audioState;
#endif
#if PPSSPP_PLATFORM(MAC)
#define OnClickPostDarwinNotification(Target, NotifName, NotifValue) \
Target->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn { \
PostDarwinNotificationIfPossible(NotifName, NotifValue); \
return UI::EVENT_DONE; \
});
#else
#define OnClickPostDarwinNotification
#endif
GameSettingsScreen::GameSettingsScreen(const Path &gamePath, std::string gameID, bool editThenRestore)
: UIDialogScreenWithGameBackground(gamePath), gameID_(gameID), editThenRestore_(editThenRestore) {
prevInflightFrames_ = g_Config.iInflightFrames;
@ -347,6 +358,7 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
if (deviceType != DEVICE_TYPE_VR) {
CheckBox *softwareGPU = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareRendering, gr->T("Software Rendering", "Software Rendering (slow)")));
OnClickPostDarwinNotification(softwareGPU, "ConfigDidChange", "SoftwareRendering")
softwareGPU->SetEnabled(!PSP_IsInited());
}
@ -381,10 +393,7 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
#if !(PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS))
CheckBox *vSync = graphicsSettings->Add(new CheckBox(&g_Config.bVSync, gr->T("VSync")));
vSync->OnClick.Add([=](EventParams &e) {
NativeResized();
return UI::EVENT_CONTINUE;
});
OnClickPostDarwinNotification(vSync, "ConfigDidChange", "VSync")
#endif
#if PPSSPP_PLATFORM(ANDROID)
@ -601,10 +610,13 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
});
graphicsSettings->Add(new ItemHeader(gr->T("Overlay Information")));
graphicsSettings->Add(new BitCheckBox(&g_Config.iShowStatusFlags, (int)ShowStatusFlags::FPS_COUNTER, gr->T("Show FPS Counter")));
graphicsSettings->Add(new BitCheckBox(&g_Config.iShowStatusFlags, (int)ShowStatusFlags::SPEED_COUNTER, gr->T("Show Speed")));
BitCheckBox *showFPSCtr = graphicsSettings->Add(new BitCheckBox(&g_Config.iShowStatusFlags, (int)ShowStatusFlags::FPS_COUNTER, gr->T("Show FPS Counter")));
OnClickPostDarwinNotification(showFPSCtr, "ConfigDidChange", "ShowFPSCounter")
BitCheckBox *showSpeed = graphicsSettings->Add(new BitCheckBox(&g_Config.iShowStatusFlags, (int)ShowStatusFlags::SPEED_COUNTER, gr->T("Show Speed")));
OnClickPostDarwinNotification(showSpeed, "ConfigDidChange", "ShowSpeed")
#ifdef CAN_DISPLAY_CURRENT_BATTERY_CAPACITY
graphicsSettings->Add(new BitCheckBox(&g_Config.iShowStatusFlags, (int)ShowStatusFlags::BATTERY_PERCENT, gr->T("Show Battery %")));
BitCheckBox *showBattery = graphicsSettings->Add(new BitCheckBox(&g_Config.iShowStatusFlags, (int)ShowStatusFlags::BATTERY_PERCENT, gr->T("Show Battery %")));
OnClickPostDarwinNotification(showBattery, "ConfigDidChange", "BatteryPercent")
#endif
graphicsSettings->Add(new CheckBox(&g_Config.bShowDebugStats, gr->T("Show Debug Statistics")))->OnClick.Handle(this, &GameSettingsScreen::OnJitAffectingSetting);
@ -617,8 +629,9 @@ void GameSettingsScreen::CreateAudioSettings(UI::ViewGroup *audioSettings) {
auto ms = GetI18NCategory("MainSettings");
audioSettings->Add(new ItemHeader(ms->T("Audio")));
audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound")));
CheckBox *enableSound = audioSettings->Add(new CheckBox(&g_Config.bEnableSound,a->T("Enable Sound")));
OnClickPostDarwinNotification(enableSound, "AudioConfChanged", "EnableSound")
PopupSliderChoice *volume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGlobalVolume, VOLUME_OFF, VOLUME_FULL, a->T("Global volume"), screenManager()));
volume->SetEnabledPtr(&g_Config.bEnableSound);
volume->SetZeroLabel(a->T("Mute"));
@ -1163,7 +1176,7 @@ UI::LinearLayout *GameSettingsScreen::AddTab(const char *tag, const std::string
contents->SetSpacing(0);
scroll->Add(contents);
tabHolder_->AddTab(title, scroll);
if (!isSearch) {
settingTabContents_.push_back(contents);
@ -1176,12 +1189,8 @@ UI::LinearLayout *GameSettingsScreen::AddTab(const char *tag, const std::string
}
UI::EventReturn GameSettingsScreen::OnAutoFrameskip(UI::EventParams &e) {
if (g_Config.bAutoFrameSkip && g_Config.iFrameSkip == 0) {
g_Config.iFrameSkip = 1;
}
if (g_Config.bAutoFrameSkip && g_Config.bSkipBufferEffects) {
g_Config.bSkipBufferEffects = false;
}
g_Config.updateAfterSettingAutoFrameSkip();
PostDarwinNotificationIfPossible("ConfigChanged", "AutoFrameSkip");
return UI::EVENT_DONE;
}
@ -1326,12 +1335,14 @@ UI::EventReturn GameSettingsScreen::OnChangeBackground(UI::EventParams &e) {
}
UI::EventReturn GameSettingsScreen::OnFullscreenChange(UI::EventParams &e) {
PostDarwinNotificationIfPossible("ConfigDidChange", "FullScreen");
g_Config.iForceFullScreen = -1;
System_SendMessage("toggle_fullscreen", g_Config.UseFullScreen() ? "1" : "0");
return UI::EVENT_DONE;
}
UI::EventReturn GameSettingsScreen::OnFullscreenMultiChange(UI::EventParams &e) {
PostDarwinNotificationIfPossible("ConfigDidChange", "FullScreen");
System_SendMessage("toggle_fullscreen", g_Config.UseFullScreen() ? "1" : "0");
return UI::EVENT_DONE;
}
@ -1563,6 +1574,7 @@ UI::EventReturn GameSettingsScreen::OnAudioDevice(UI::EventParams &e) {
g_Config.sAudioDevice.clear();
}
System_SendMessage("audio_resetDevice", "");
PostDarwinNotificationIfPossible("AudioConfigurationHasChanged", "CurrentDeviceWasChanged");
return UI::EVENT_DONE;
}

View File

@ -1260,12 +1260,10 @@ void MainScreen::sendMessage(const char *message, const char *value) {
}
if (!strcmp(message, "browse_folderSelect")) {
std::string filename = value;
INFO_LOG(SYSTEM, "Got folder: '%s'", filename.c_str());
int tab = tabHolder_->GetCurrentTab();
// Don't allow browsing in the other tabs (I don't think it's possible to reach the option though)
if (tab == 1) {
gameBrowsers_[tab]->SetPath(Path(filename));
}
INFO_LOG(SYSTEM, "Got folder: '%s'", filename.c_str());;
// switch to the 'Games' tab which has the file browser
tabHolder_->SetCurrentTab(1);
gameBrowsers_[1]->SetPath(Path(filename));
}
}
if (!strcmp(message, "permission_granted") && !strcmp(value, "storage")) {