CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/SDL/PPSSPPAboutViewController.m
Views: 1401
1
//
2
// PPSSPPAboutViewController.m
3
// PPSSPP
4
//
5
// Created by Serena on 23/04/2023.
6
//
7
8
#import <Cocoa/Cocoa.h> // AppKit ftw
9
#import "PPSSPPAboutViewController.h"
10
11
#if !__has_feature(objc_arc)
12
#error Caveman detected (warning emoji) please enable arc with -fobjc-arc
13
#endif
14
15
extern const char *PPSSPP_GIT_VERSION;
16
17
@implementation PPSSPPAboutViewController
18
- (void)loadView {
19
self.view = [[NSView alloc] init];
20
[self.view setFrameSize:CGSizeMake(500, 180)];
21
}
22
23
- (void)viewDidLoad {
24
[super viewDidLoad];
25
26
NSImageView *imageView = [[NSImageView alloc] init];
27
imageView.translatesAutoresizingMaskIntoConstraints = NO;
28
imageView.image = [NSImage imageNamed:@"ppsspp.icns"];;
29
[self.view addSubview:imageView];
30
31
NSTextField *titleLabel = [NSTextField labelWithString:@"PPSSPP"];
32
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
33
titleLabel.font = [NSFont systemFontOfSize:38];
34
[self.view addSubview:titleLabel];
35
36
NSTextField *versionLabel = [NSTextField labelWithString:@(PPSSPP_GIT_VERSION)];
37
versionLabel.translatesAutoresizingMaskIntoConstraints = NO;
38
versionLabel.textColor = [NSColor secondaryLabelColor];
39
versionLabel.selectable = YES; /* in case someone wants to copy the version */
40
[self.view addSubview:versionLabel];
41
42
NSTextField *descriptionLabel = [NSTextField wrappingLabelWithString:@"A PSP emulator for Android, Windows, Mac and Linux, written in C++"];
43
descriptionLabel.translatesAutoresizingMaskIntoConstraints = NO;
44
45
if (@available(macOS 11.0, *)) {
46
descriptionLabel.font = [NSFont preferredFontForTextStyle:NSFontTextStyleSubheadline options:@{}];
47
} else {
48
descriptionLabel.font = [NSFont systemFontOfSize:10];
49
}
50
51
descriptionLabel.textColor = [NSColor colorWithRed:0.60 green:0.60 blue:0.60 alpha:1.0];
52
[self.view addSubview:descriptionLabel];
53
54
NSButton *sourceCodeButton = [NSButton buttonWithTitle:@"Source Code" target:self action:@selector(sourceCodeButtonTapped)];
55
sourceCodeButton.bezelStyle = NSBezelStyleRounded;
56
57
NSButton *discordButton = [NSButton buttonWithTitle:@"Join Discord" target:self action: @selector(joinDiscord)];
58
discordButton.bezelStyle = NSBezelStyleRounded;
59
60
NSStackView *stackView = [NSStackView stackViewWithViews:@[discordButton, sourceCodeButton]];
61
stackView.translatesAutoresizingMaskIntoConstraints = NO;
62
[self.view addSubview:stackView];
63
64
[NSLayoutConstraint activateConstraints:@[
65
[imageView.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor],
66
[imageView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor constant:40],
67
68
[titleLabel.leadingAnchor constraintEqualToAnchor:imageView.trailingAnchor constant:15],
69
[titleLabel.centerYAnchor constraintEqualToAnchor:imageView.topAnchor constant:25],
70
71
[versionLabel.leadingAnchor constraintEqualToAnchor:titleLabel.leadingAnchor],
72
[versionLabel.centerYAnchor constraintEqualToAnchor:titleLabel.bottomAnchor constant:5],
73
74
[descriptionLabel.leadingAnchor constraintEqualToAnchor:versionLabel.leadingAnchor],
75
[descriptionLabel.trailingAnchor constraintLessThanOrEqualToAnchor: self.view.trailingAnchor],
76
[descriptionLabel.centerYAnchor constraintEqualToAnchor:versionLabel.bottomAnchor constant:20],
77
78
[stackView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor constant:-26.4],
79
[stackView.centerYAnchor constraintEqualToAnchor:self.view.bottomAnchor constant:-25]
80
]];
81
}
82
83
-(void)sourceCodeButtonTapped {
84
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/hrydgard/ppsspp"]];
85
}
86
87
-(void)joinDiscord {
88
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://discord.gg/5NJB6dD"]];
89
}
90
91
@end
92
93