mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Native 'About' panel
This commit is contained in:
parent
bd3ae4b074
commit
0830eb51fc
@ -1269,10 +1269,25 @@ elseif(TARGET SDL2::SDL2)
|
|||||||
endif()
|
endif()
|
||||||
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
|
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm SDL/SDLCocoaMetalLayer.h SDL/SDLCocoaMetalLayer.mm SDL/CocoaBarItems.mm SDL/CocoaBarItems.h UI/DarwinFileSystemServices.mm UI/DarwinFileSystemServices.h Common/Battery/AppleBatteryClient.m UI/PSPNSApplicationDelegate.mm UI/PSPNSApplicationDelegate.h)
|
set(nativeExtra ${nativeExtra}
|
||||||
|
SDL/SDLMain.h
|
||||||
|
SDL/SDLMain.mm
|
||||||
|
SDL/SDLCocoaMetalLayer.h
|
||||||
|
SDL/SDLCocoaMetalLayer.mm
|
||||||
|
SDL/CocoaBarItems.mm
|
||||||
|
SDL/CocoaBarItems.h
|
||||||
|
SDL/PPSSPPAboutViewController.m
|
||||||
|
SDL/PPSSPPAboutViewController.h
|
||||||
|
UI/DarwinFileSystemServices.mm
|
||||||
|
UI/DarwinFileSystemServices.h
|
||||||
|
Common/Battery/AppleBatteryClient.m
|
||||||
|
UI/PSPNSApplicationDelegate.mm
|
||||||
|
UI/PSPNSApplicationDelegate.h)
|
||||||
|
|
||||||
set_source_files_properties(UI/DarwinFileSystemServices.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
set_source_files_properties(UI/DarwinFileSystemServices.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||||
set_source_files_properties(UI/PSPNSApplicationDelegate.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
set_source_files_properties(UI/PSPNSApplicationDelegate.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||||
set_source_files_properties(SDL/CocoaBarItems.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
set_source_files_properties(SDL/CocoaBarItems.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||||
|
set_source_files_properties(SDL/PPSSPPAboutViewController.m PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||||
set_source_files_properties(Common/Battery/AppleBatteryClient.m 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})
|
set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY})
|
||||||
elseif(USING_EGL)
|
elseif(USING_EGL)
|
||||||
|
@ -6,9 +6,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "PPSSPPAboutViewController.h"
|
||||||
|
|
||||||
#include "UI/DarwinFileSystemServices.h"
|
#include "UI/DarwinFileSystemServices.h"
|
||||||
#include "UI/PSPNSApplicationDelegate.h"
|
#include "UI/PSPNSApplicationDelegate.h"
|
||||||
|
|
||||||
#include "Core/Debugger/SymbolMap.h"
|
#include "Core/Debugger/SymbolMap.h"
|
||||||
#include "Core/MemMap.h"
|
#include "Core/MemMap.h"
|
||||||
#include "GPU/GPUInterface.h"
|
#include "GPU/GPUInterface.h"
|
||||||
@ -96,15 +98,43 @@ void initializeOSXExtras() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IGNORE THE BELOW and eat some nice cherries :3
|
|
||||||
NSArray <NSMenuItem *> *firstSubmenu = NSApp.menu.itemArray.firstObject.submenu.itemArray;
|
NSArray <NSMenuItem *> *firstSubmenu = NSApp.menu.itemArray.firstObject.submenu.itemArray;
|
||||||
for (NSMenuItem *item in firstSubmenu) {
|
for (NSMenuItem *item in firstSubmenu) {
|
||||||
// about item, set action
|
// about item, set action
|
||||||
if ([item.title hasPrefix:@"About "]) {
|
if ([item.title hasPrefix:@"About "]) {
|
||||||
|
item.target = self;
|
||||||
|
item.action = @selector(presentAboutMenu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
-(void)presentAboutMenu {
|
||||||
|
NSWindow *window = [NSWindow windowWithContentViewController:[PPSSPPAboutViewController new]];
|
||||||
|
window.title = @"PPSSPP";
|
||||||
|
window.titleVisibility = NSWindowTitleHidden;
|
||||||
|
window.titlebarAppearsTransparent = YES;
|
||||||
|
window.styleMask &= ~NSWindowStyleMaskResizable;
|
||||||
|
[[window standardWindowButton:NSWindowMiniaturizeButton] setEnabled:NO];
|
||||||
|
|
||||||
|
if (@available(macOS 10.15, *)) {
|
||||||
|
window.backgroundColor = [NSColor colorWithName:nil dynamicProvider:^NSColor * _Nonnull(NSAppearance * _Nonnull appearance) {
|
||||||
|
// check for dark/light mode (dark mode is OS X 10.14+ only)
|
||||||
|
/* no I can't use switch statements here it's an NSString pointer */
|
||||||
|
if (appearance.name == NSAppearanceNameDarkAqua ||
|
||||||
|
appearance.name == NSAppearanceNameAccessibilityHighContrastVibrantDark ||
|
||||||
|
appearance.name == NSAppearanceNameAccessibilityHighContrastDarkAqua ||
|
||||||
|
appearance.name == NSAppearanceNameVibrantDark)
|
||||||
|
return [NSColor colorWithRed:0.19 green:0.19 blue:0.19 alpha:1];
|
||||||
|
|
||||||
|
// macOS pre 10.14 is always light mode
|
||||||
|
return [NSColor whiteColor];
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
window.backgroundColor = [NSColor whiteColor];
|
||||||
|
}
|
||||||
|
|
||||||
|
[[[NSWindowController alloc] initWithWindow:window] showWindow:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)menuNeedsUpdate:(NSMenu *)menu {
|
- (void)menuNeedsUpdate:(NSMenu *)menu {
|
||||||
|
13
SDL/PPSSPPAboutViewController.h
Normal file
13
SDL/PPSSPPAboutViewController.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
//
|
||||||
|
// PPSSPPAboutViewController.h
|
||||||
|
// PPSSPP
|
||||||
|
//
|
||||||
|
// Created by Serena on 23/04/2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
@interface PPSSPPAboutViewController : NSViewController
|
||||||
|
@end
|
91
SDL/PPSSPPAboutViewController.m
Normal file
91
SDL/PPSSPPAboutViewController.m
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
//
|
||||||
|
// PPSSPPAboutViewController.m
|
||||||
|
// PPSSPP
|
||||||
|
//
|
||||||
|
// Created by Serena on 23/04/2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> // AppKit ftw
|
||||||
|
#import "PPSSPPAboutViewController.h"
|
||||||
|
|
||||||
|
#if !__has_feature(objc_arc)
|
||||||
|
#error Caveman detected (warning emoji) please enable arc with -fobjc-arc
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern const char *PPSSPP_GIT_VERSION;
|
||||||
|
|
||||||
|
@implementation PPSSPPAboutViewController
|
||||||
|
- (void)loadView {
|
||||||
|
self.view = [[NSView alloc] init];
|
||||||
|
[self.view setFrameSize:CGSizeMake(500, 180)];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidLoad {
|
||||||
|
[super viewDidLoad];
|
||||||
|
|
||||||
|
NSImageView *imageView = [[NSImageView alloc] init];
|
||||||
|
imageView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
imageView.image = [NSImage imageNamed:@"ppsspp.icns"];;
|
||||||
|
[self.view addSubview:imageView];
|
||||||
|
|
||||||
|
NSTextField *titleLabel = [NSTextField labelWithString:@"PPSSPP"];
|
||||||
|
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
titleLabel.font = [NSFont systemFontOfSize:38];
|
||||||
|
[self.view addSubview:titleLabel];
|
||||||
|
|
||||||
|
NSTextField *versionLabel = [NSTextField labelWithString:@(PPSSPP_GIT_VERSION)];
|
||||||
|
versionLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
versionLabel.textColor = [NSColor secondaryLabelColor];
|
||||||
|
versionLabel.selectable = YES; /* in case someone wants to copy the version */
|
||||||
|
[self.view addSubview:versionLabel];
|
||||||
|
|
||||||
|
NSTextField *descriptionLabel = [NSTextField wrappingLabelWithString:@"A PSP emulator for Android, Windows, Mac and Linux, written in C++"];
|
||||||
|
descriptionLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
|
||||||
|
if (@available(macOS 11.0, *)) {
|
||||||
|
descriptionLabel.font = [NSFont preferredFontForTextStyle:NSFontTextStyleSubheadline options:@{}];
|
||||||
|
} else {
|
||||||
|
descriptionLabel.font = [NSFont systemFontOfSize:10];
|
||||||
|
}
|
||||||
|
|
||||||
|
descriptionLabel.textColor = [NSColor colorWithRed:0.60 green:0.60 blue:0.60 alpha:1.0];
|
||||||
|
[self.view addSubview:descriptionLabel];
|
||||||
|
|
||||||
|
NSButton *sourceCodeButton = [NSButton buttonWithTitle:@"Source Code" target:self action:@selector(sourceCodeButtonTapped)];
|
||||||
|
sourceCodeButton.bezelStyle = NSBezelStyleRounded;
|
||||||
|
|
||||||
|
NSButton *discordButton = [NSButton buttonWithTitle:@"Join Discord" target:self action: @selector(joinDiscord)];
|
||||||
|
discordButton.bezelStyle = NSBezelStyleRounded;
|
||||||
|
|
||||||
|
NSStackView *stackView = [NSStackView stackViewWithViews:@[discordButton, sourceCodeButton]];
|
||||||
|
stackView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
[self.view addSubview:stackView];
|
||||||
|
|
||||||
|
[NSLayoutConstraint activateConstraints:@[
|
||||||
|
[imageView.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor],
|
||||||
|
[imageView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor constant:40],
|
||||||
|
|
||||||
|
[titleLabel.leadingAnchor constraintEqualToAnchor:imageView.trailingAnchor constant:15],
|
||||||
|
[titleLabel.centerYAnchor constraintEqualToAnchor:imageView.topAnchor constant:25],
|
||||||
|
|
||||||
|
[versionLabel.leadingAnchor constraintEqualToAnchor:titleLabel.leadingAnchor],
|
||||||
|
[versionLabel.centerYAnchor constraintEqualToAnchor:titleLabel.bottomAnchor constant:5],
|
||||||
|
|
||||||
|
[descriptionLabel.leadingAnchor constraintEqualToAnchor:versionLabel.leadingAnchor],
|
||||||
|
[descriptionLabel.trailingAnchor constraintLessThanOrEqualToAnchor: self.view.trailingAnchor],
|
||||||
|
[descriptionLabel.centerYAnchor constraintEqualToAnchor:versionLabel.bottomAnchor constant:20],
|
||||||
|
|
||||||
|
[stackView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor constant:-26.4],
|
||||||
|
[stackView.centerYAnchor constraintEqualToAnchor:self.view.bottomAnchor constant:-25]
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)sourceCodeButtonTapped {
|
||||||
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/hrydgard/ppsspp"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)joinDiscord {
|
||||||
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://discord.gg/5NJB6dD"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in New Issue
Block a user