git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 3b1fc4106415947c297602a749d055139b405b0f
parent 00367a79b4721789d0436daaa7e908993d60e656
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Mon, 16 Jan 2023 23:07:41 +0200

Add about screen

Diffstat:
MLICENSE2+-
MMakefile2+-
AiOS/GBAboutController.h5+++++
AiOS/GBAboutController.m230+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MiOS/GBMenuViewController.m2+-
MiOS/GBViewController.h1+
MiOS/GBViewController.m6++++++
AiOS/logo@2x.png0
AiOS/logo@3x.png0
9 files changed, 245 insertions(+), 3 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2015-2022 Lior Halphon +Copyright (c) 2015-2023 Lior Halphon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile @@ -342,7 +342,7 @@ $(BIN)/SameBoy-iOS.app: $(BIN)/SameBoy-iOS.app/SameBoy \ $(MKDIR) -p $(BIN)/SameBoy-iOS.app cp iOS/*.png $(BIN)/SameBoy-iOS.app sed "s/@VERSION/$(VERSION)/;s/@COPYRIGHT_YEAR/$(COPYRIGHT_YEAR)/" < iOS/Info.plist > $(BIN)/SameBoy-iOS.app/Info.plist - sed "s/@COPYRIGHT_YEAR/$(COPYRIGHT_YEAR)/" < Cocoa/License.html > $(BIN)/SameBoy-iOS.app/Credits.html + sed "s/@COPYRIGHT_YEAR/$(COPYRIGHT_YEAR)/" < iOS/License.html > $(BIN)/SameBoy-iOS.app/License.html $(MKDIR) -p $(BIN)/SameBoy-iOS.app/Shaders cp Shaders/*.fsh Shaders/*.metal $(BIN)/SameBoy-iOS.app/Shaders $(CODESIGN) $@ diff --git a/iOS/GBAboutController.h b/iOS/GBAboutController.h @@ -0,0 +1,5 @@ +#import <UIKit/UIKit.h> + +@interface GBAboutController : UIViewController + +@end diff --git a/iOS/GBAboutController.m b/iOS/GBAboutController.m @@ -0,0 +1,230 @@ +#import "GBAboutController.h" + +@interface GBAboutController () + +@end + +@implementation GBAboutController +{ + UILabel *_titleLabel; + UILabel *_versionLabel; + UIImageView *_logo; + UITextView *_licenseView; + UILabel *_copyrightLabel; + UIView *_buttonsView; +} + +- (UIImage *)buttonImageNamed:(NSString *)name +{ + if (@available(iOS 13.0, *)) { + return [UIImage systemImageNamed:name withConfiguration:[UIImageSymbolConfiguration configurationWithScale:UIImageSymbolScaleLarge]]; + } + return nil; +} + +- (void)alignButton:(UIButton *)button +{ + if (!button.imageView.image) return; + CGSize imageSize = button.imageView.frame.size; + + button.imageEdgeInsets = UIEdgeInsetsMake(0, (32 - imageSize.width) / 2, 0, 0); + button.titleEdgeInsets = UIEdgeInsetsMake(0, 32 - imageSize.width, 0, 0); +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + UIVisualEffect *effect = [UIBlurEffect effectWithStyle:(UIBlurEffectStyle)UIBlurEffectStyleProminent]; + self.view = [[UIVisualEffectView alloc] initWithEffect:effect]; + UIView *root = ((UIVisualEffectView *)self.view).contentView; + + _titleLabel = [[UILabel alloc] init]; + _titleLabel.text = @"SameBoy"; + _titleLabel.font = [UIFont systemFontOfSize:34 weight:UIFontWeightHeavy]; + [root addSubview:_titleLabel]; + + _versionLabel = [[UILabel alloc] init]; + _versionLabel.text = @"Version " GB_VERSION; + _versionLabel.font = [UIFont systemFontOfSize:24 weight:UIFontWeightLight]; + [root addSubview:_versionLabel]; + + _logo = [[UIImageView alloc] init]; + _logo.image = [UIImage imageNamed:@"logo"]; + _logo.contentMode = UIViewContentModeCenter; + [root addSubview:_logo]; + + _licenseView = [[UITextView alloc] init]; + NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"License" ofType:@"html"]]; + _licenseView.attributedText = [[NSAttributedString alloc] initWithData:data + options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, + NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)} + documentAttributes:nil + error:nil]; + _licenseView.editable = false; + if (@available(iOS 13.0, *)) { + _licenseView.backgroundColor = [UIColor systemBackgroundColor]; + _licenseView.textColor = [UIColor labelColor]; + } + else { + _licenseView.backgroundColor = [UIColor whiteColor]; + } + _licenseView.hidden = true; + _licenseView.userInteractionEnabled = false; + [root addSubview:_licenseView]; + + _buttonsView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; + + UIButton *websiteButton = [[UIButton alloc] initWithFrame:CGRectMake(20, 0, 280, 37)]; + [websiteButton setTitle:@"Website" forState:UIControlStateNormal]; + [websiteButton setImage:[self buttonImageNamed:@"globe"] forState:UIControlStateNormal]; + websiteButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; + [websiteButton setTitleColor:websiteButton.tintColor forState:UIControlStateNormal]; + websiteButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; + [websiteButton addTarget:self action:@selector(openWebsite) forControlEvents:UIControlEventTouchUpInside]; + [self alignButton:websiteButton]; + [_buttonsView addSubview:websiteButton]; + + UIButton *sponsorButton = [[UIButton alloc] initWithFrame:CGRectMake(20, 45, 280, 37)]; + [sponsorButton setTitle:@"Sponsor SameBoy" forState:UIControlStateNormal]; + [sponsorButton setImage:[self buttonImageNamed:@"heart"] forState:UIControlStateNormal]; + sponsorButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; + [sponsorButton setTitleColor:sponsorButton.tintColor forState:UIControlStateNormal]; + sponsorButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; + [sponsorButton addTarget:self action:@selector(openSponsor) forControlEvents:UIControlEventTouchUpInside]; + [self alignButton:sponsorButton]; + [_buttonsView addSubview:sponsorButton]; + + UIButton *licenseButton = [[UIButton alloc] initWithFrame:CGRectMake(20, 90, 280, 37)]; + [licenseButton setTitle:@"License" forState:UIControlStateNormal]; + [licenseButton setImage:[self buttonImageNamed:@"doc.plaintext"] forState:UIControlStateNormal]; + licenseButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; + licenseButton.titleLabel.textColor = licenseButton.tintColor; + [licenseButton setTitleColor:licenseButton.tintColor forState:UIControlStateNormal]; + licenseButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; + [licenseButton addTarget:self action:@selector(showLicense) forControlEvents:UIControlEventTouchUpInside]; + [self alignButton:licenseButton]; + [_buttonsView addSubview:licenseButton]; + + [root addSubview:_buttonsView]; + + _copyrightLabel = [[UILabel alloc] init]; + _copyrightLabel.text = [[NSBundle mainBundle] infoDictionary][@"NSHumanReadableCopyright"]; + _copyrightLabel.textAlignment = NSTextAlignmentCenter; + _copyrightLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; + _copyrightLabel.font = [UIFont systemFontOfSize:13]; + [root addSubview:_copyrightLabel]; + + [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self + action:@selector(dismissSelf)]]; +} + +- (void)layoutForVerticalLayout +{ + CGRect savedFrame = self.view.frame; + self.view.frame = CGRectMake(0, 0, 320, 480); + + _titleLabel.frame = CGRectMake(0, 20, 320, 47); + _titleLabel.textAlignment = NSTextAlignmentCenter; + _titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; + + _versionLabel.frame = CGRectMake(0, 75, 320, 36); + _versionLabel.textAlignment = NSTextAlignmentCenter; + _versionLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; + + _logo.frame = CGRectMake(0, 119, 320, 128); + _logo.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; + + _buttonsView.frame = CGRectMake(0, 255, 320, 176); + _buttonsView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + + _licenseView.frame = CGRectMake(20, 255, 280, 176); + _licenseView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + + + _copyrightLabel.frame = CGRectMake(0, 439, 320, 21); + _copyrightLabel.textAlignment = NSTextAlignmentCenter; + _copyrightLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; + + self.view.frame = savedFrame; +} + +- (void)layoutForHorizontalLayout +{ + CGRect savedFrame = self.view.frame; + self.view.frame = CGRectMake(0, 0, 568, 320); + + _titleLabel.frame = CGRectMake(20, 20, 260, 47); + _titleLabel.textAlignment = NSTextAlignmentLeft; + _titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | + UIViewAutoresizingFlexibleBottomMargin | + UIViewAutoresizingFlexibleRightMargin; + + _versionLabel.frame = CGRectMake(20, 75, 260, 36); + _versionLabel.textAlignment = NSTextAlignmentLeft; + _versionLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | + UIViewAutoresizingFlexibleBottomMargin | + UIViewAutoresizingFlexibleRightMargin; + + _logo.frame = CGRectMake(0, 119, 284, 152); + _logo.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + + _buttonsView.frame = _licenseView.frame = CGRectMake(284, 20, 284, 280); + _buttonsView.autoresizingMask = UIViewAutoresizingFlexibleWidth | + UIViewAutoresizingFlexibleHeight | + UIViewAutoresizingFlexibleLeftMargin; + _licenseView.autoresizingMask = UIViewAutoresizingFlexibleWidth | + UIViewAutoresizingFlexibleHeight | + UIViewAutoresizingFlexibleLeftMargin; + + + _copyrightLabel.frame = CGRectMake(20, 279, 260, 21); + _copyrightLabel.textAlignment = NSTextAlignmentLeft; + _copyrightLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | + UIViewAutoresizingFlexibleTopMargin | + UIViewAutoresizingFlexibleRightMargin; + + self.view.frame = savedFrame; + CGRect licenseFrame = _licenseView.frame; + licenseFrame.size.width -= 40; + licenseFrame.origin.x += 20; + _licenseView.frame = licenseFrame; +} + +- (void)openWebsite +{ + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://sameboy.github.io"] options:nil completionHandler:nil]; +} + +- (void)openSponsor +{ + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/sponsors/LIJI32"] options:nil completionHandler:nil]; +} + +- (void)showLicense +{ + _buttonsView.hidden = true; + _licenseView.hidden = false; + _licenseView.userInteractionEnabled = true; +} + +- (void)viewDidLayoutSubviews +{ + [super viewDidLayoutSubviews]; + if (self.view.frame.size.width > self.view.frame.size.height) { + [self layoutForHorizontalLayout]; + } + else { + [self layoutForVerticalLayout]; + } +} + +- (void)dismissSelf +{ + [self.presentingViewController dismissViewControllerAnimated:true completion:nil]; +} + +- (UIModalPresentationStyle)modalPresentationStyle +{ + return UIModalPresentationFormSheet; +} +@end diff --git a/iOS/GBMenuViewController.m b/iOS/GBMenuViewController.m @@ -39,7 +39,7 @@ {@"Model", @"ModelTemplate", SelectorString(changeModel)}, {@"States", @"square.stack", nil}, {@"Settings", @"gear", nil}, - {@"About", @"info.circle", nil}, + {@"About", @"info.circle", SelectorString(showAbout)}, }; double width = self.view.frame.size.width / 3; diff --git a/iOS/GBViewController.h b/iOS/GBViewController.h @@ -7,4 +7,5 @@ - (void)start; - (void)stop; - (void)changeModel; +- (void)showAbout; @end diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m @@ -9,6 +9,7 @@ #import "GBHapticManager.h" #import "GBMenuViewController.h" #import "GBOptionViewController.h" +#import "GBAboutController.h" #include <Core/gb.h> @implementation GBViewController @@ -209,6 +210,11 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) [self presentViewController:controller animated:true completion:nil]; } +- (void)showAbout +{ + [self presentViewController:[[GBAboutController alloc] init] animated:true completion:nil]; +} + - (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion { [super dismissViewControllerAnimated:flag completion:^() { diff --git a/iOS/logo@2x.png b/iOS/logo@2x.png Binary files differ. diff --git a/iOS/logo@3x.png b/iOS/logo@3x.png Binary files differ.

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.