Skip to content

Commit

Permalink
Add Fast Forward and Rewind notifications. Closes #2432
Browse files Browse the repository at this point in the history
  • Loading branch information
clobber committed Apr 3, 2018
1 parent 383f1bb commit 1a0bda2
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 3 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Interface Graphics/hud_rewind_notification.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Interface Graphics/hud_rewind_notification@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion OpenEmu-SDK
2 changes: 2 additions & 0 deletions OpenEmu/OEGameCoreHelper.h
Expand Up @@ -70,6 +70,8 @@
- (void)resetEmulation;
- (void)toggleEmulationPaused;
- (void)takeScreenshot;
- (void)fastForwardGameplay:(BOOL)enable;
- (void)rewindGameplay:(BOOL)enable;

- (void)setEnableVSync:(BOOL)enable;
- (void)setAspectSize:(OEIntSize)newAspectSize;
Expand Down
10 changes: 10 additions & 0 deletions OpenEmu/OEGameDocument.m
Expand Up @@ -1494,6 +1494,16 @@ - (void)toggleEmulationPaused
[self toggleEmulationPaused:self];
}

- (void)fastForwardGameplay:(BOOL)enable
{
[[self gameViewController] fastForwardGameplay:enable];
}

- (void)rewindGameplay:(BOOL)enable
{
[[self gameViewController] rewindGameplay:enable];
}

- (void)setEnableVSync:(BOOL)enable
{
[_gameViewController setEnableVSync:enable];
Expand Down
2 changes: 2 additions & 0 deletions OpenEmu/OEGameView.h
Expand Up @@ -54,6 +54,8 @@ extern NSString * const OEDefaultVideoFilterKey;

- (void)showQuickSaveNotification;
- (void)showScreenShotNotification;
- (void)showFastForwardNotification:(BOOL)enable;
- (void)showRewindNotification:(BOOL)enable;

- (NSSize)correctScreenSize:(OEIntSize)screenSize forAspectSize:(OEIntSize)aspectSize returnVertices:(BOOL)flag;
@end
Expand Down
10 changes: 10 additions & 0 deletions OpenEmu/OEGameView.m
Expand Up @@ -354,6 +354,16 @@ - (void)showScreenShotNotification
[_notificationRenderer showScreenShotNotification];
}

- (void)showFastForwardNotification:(BOOL)enable
{
[_notificationRenderer showFastForwardNotification:enable];
}

- (void)showRewindNotification:(BOOL)enable
{
[_notificationRenderer showRewindNotification:enable];
}

- (void)setEnableVSync:(BOOL)enable
{
GLint vSync = enable;
Expand Down
2 changes: 2 additions & 0 deletions OpenEmu/OEGameViewController.h
Expand Up @@ -92,6 +92,8 @@ extern NSString *const OEScreenshotPropertiesKey;
#pragma mark - Info
@property(readonly) NSSize defaultScreenSize;

- (void)fastForwardGameplay:(BOOL)enable;
- (void)rewindGameplay:(BOOL)enable;
- (void)setEnableVSync:(BOOL)enable;
- (void)setAspectSize:(OEIntSize)newAspectSize;
- (void)setScreenSize:(OEIntSize)newScreenSize withIOSurfaceID:(IOSurfaceID)newSurfaceID;
Expand Down
10 changes: 10 additions & 0 deletions OpenEmu/OEGameViewController.m
Expand Up @@ -288,6 +288,16 @@ - (void)takeScreenshot:(id)sender

#pragma mark - OEGameCoreOwner methods

- (void)fastForwardGameplay:(BOOL)enable
{
[[self gameView] showFastForwardNotification:enable];
}

- (void)rewindGameplay:(BOOL)enable
{
[[self gameView] showRewindNotification:enable];
}

- (void)setEnableVSync:(BOOL)enable;
{
[_gameView setEnableVSync:enable];
Expand Down
2 changes: 2 additions & 0 deletions OpenEmu/OEGameViewNotificationRenderer.h
Expand Up @@ -35,6 +35,8 @@ extern NSString * const OEShowNotificationsKey;

- (void)showQuickStateNotification;
- (void)showScreenShotNotification;
- (void)showFastForwardNotification:(BOOL)enable;
- (void)showRewindNotification:(BOOL)enable;

@property GLfloat scaleFactor;
@property BOOL disableNotifications;
Expand Down
79 changes: 77 additions & 2 deletions OpenEmu/OEGameViewNotificationRenderer.m
Expand Up @@ -33,6 +33,8 @@ typedef NS_ENUM(NSInteger, OEGameViewNotificationName) {
OENotificationNone,
OENotificationQuickSave,
OENotificationScreenShot,
OENotificationFastForward,
OENotificationRewind,

OENotificationCount
};
Expand All @@ -47,9 +49,9 @@ + (instancetype)notificationWithNotification:(OEGameViewNotificationName)notific
@end

@interface OEGameViewNotificationRenderer ()
@property GLuint quickSaveTexture, screenShotTexture, textureToRender;
@property GLuint quickSaveTexture, screenShotTexture, fastForwardTexture, rewindTexture, textureToRender;
@property NSTimeInterval visibleTimeInSeconds, lastNotificationTime;
@property OEGameViewNotification *notificationQuickSave, *notificationScreenShot;
@property OEGameViewNotification *notificationQuickSave, *notificationScreenShot, *notificationFastForward, *notificationRewind;
@end

@implementation OEGameViewNotificationRenderer
Expand All @@ -67,6 +69,8 @@ - (void)setupInContext:(NSOpenGLContext*)context

_quickSaveTexture = [self loadImageNamed:@"hud_quicksave_notification" inContext:cgl_ctx];
_screenShotTexture = [self loadImageNamed:@"hud_screenshot_notification" inContext:cgl_ctx];
_fastForwardTexture = [self loadImageNamed:@"hud_fastforward_notification" inContext:cgl_ctx];
_rewindTexture = [self loadImageNamed:@"hud_rewind_notification" inContext:cgl_ctx];
_textureToRender = 0;

_visibleTimeInSeconds = 0.0;
Expand All @@ -78,6 +82,12 @@ - (void)setupInContext:(NSOpenGLContext*)context
_notificationScreenShot = [OEGameViewNotification notificationWithNotification:OENotificationScreenShot
texture:_screenShotTexture
seconds:1.25];
_notificationFastForward = [OEGameViewNotification notificationWithNotification:OENotificationFastForward
texture:_fastForwardTexture
seconds:DBL_MAX];
_notificationRewind = [OEGameViewNotification notificationWithNotification:OENotificationRewind
texture:_rewindTexture
seconds:DBL_MAX];

_scaleFactor = 1.0;

Expand Down Expand Up @@ -131,6 +141,8 @@ - (void)render
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_RECTANGLE_EXT);
}
else
[self OE_resumeNotification];
}

- (void)OE_renderTexture:(GLuint)texture withAlpha:(CGFloat)alpha inRect:(NSRect)rect {
Expand All @@ -150,6 +162,14 @@ - (void)OE_showNotification:(OEGameViewNotification *)notification
{
if (![notification isKindOfClass:[OEGameViewNotification class]]) return;

// Only need to set for key-repeating notifications
if (notification.seconds == DBL_MAX)
notification.state = YES;

// Rewind + Fast Forward = Fast Rewind
BOOL isRewinding = _notificationRewind.state;
if ((notification.type == OENotificationFastForward) && isRewinding) return;

_textureToRender = notification.texture;
_visibleTimeInSeconds = notification.seconds;
_lastNotificationTime = [NSDate timeIntervalSinceReferenceDate];
Expand All @@ -161,9 +181,26 @@ - (void)OE_hideNotification:(OEGameViewNotification *)notification

notification.state = NO;

// Rewind + Fast Forward = Fast Rewind
BOOL isRewinding = _notificationRewind.state;
if ((notification.type == OENotificationFastForward) && isRewinding) return;

_textureToRender = notification.texture;
_visibleTimeInSeconds = 0.0;
_lastNotificationTime = [NSDate timeIntervalSinceReferenceDate];

[self OE_resumeNotification];
}

- (void)OE_resumeNotification
{
// E.g. resume fast forward notification after rewind ends if fast forward is still pressed
BOOL isFastForwarding = _notificationFastForward.state;
BOOL isRewinding = _notificationRewind.state;
if (isFastForwarding)
[self OE_showNotification:_notificationFastForward];
if (isRewinding)
[self OE_showNotification:_notificationRewind];
}

- (void)cleanUp
Expand All @@ -179,6 +216,18 @@ - (void)cleanUp
glDeleteTextures(1, &_screenShotTexture);
_screenShotTexture = 0;
}

if(_fastForwardTexture)
{
glDeleteTextures(1, &_fastForwardTexture);
_fastForwardTexture = 0;
}

if(_rewindTexture)
{
glDeleteTextures(1, &_rewindTexture);
_rewindTexture = 0;
}
}

- (void)showQuickStateNotification
Expand All @@ -191,6 +240,32 @@ - (void)showScreenShotNotification
[self OE_showNotification:_notificationScreenShot];
}

- (void)showFastForwardNotification:(BOOL)enable
{
BOOL isFastForwarding = _notificationFastForward.state;
if (enable && isFastForwarding) return;

if (enable) {
[self OE_showNotification:_notificationFastForward];
}
else {
[self OE_hideNotification:_notificationFastForward];
}
}

- (void)showRewindNotification:(BOOL)enable
{
BOOL isRewinding = _notificationRewind.state;
if (enable && isRewinding) return;

if (enable) {
[self OE_showNotification:_notificationRewind];
}
else {
[self OE_hideNotification:_notificationRewind];
}
}

- (GLuint)loadImageNamed:(NSString*)name inContext:(CGLContextObj)cgl_ctx
{
NSURL *imageURL = [[NSBundle mainBundle] URLForImageResource:name];
Expand Down
16 changes: 16 additions & 0 deletions OpenEmu/OpenEmu.xcodeproj/project.pbxproj
Expand Up @@ -515,6 +515,10 @@
877EDD231E24BEE0004D68E7 /* Controller-Preferences-JAP.plist in Resources */ = {isa = PBXBuildFile; fileRef = 877EDD1E1E24BEE0004D68E7 /* Controller-Preferences-JAP.plist */; };
879243B41C0DA5910064C515 /* controller_5200_mask@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 879243B21C0DA5910064C515 /* controller_5200_mask@2x.png */; };
879243B51C0DA5910064C515 /* controller_5200@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 879243B31C0DA5910064C515 /* controller_5200@2x.png */; };
87AA7D082071870F00E5DB80 /* hud_fastforward_notification@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 87AA7D032071870D00E5DB80 /* hud_fastforward_notification@2x.png */; };
87AA7D092071870F00E5DB80 /* hud_fastforward_notification.png in Resources */ = {isa = PBXBuildFile; fileRef = 87AA7D072071870E00E5DB80 /* hud_fastforward_notification.png */; };
87AA7D0C2071871E00E5DB80 /* hud_rewind_notification.png in Resources */ = {isa = PBXBuildFile; fileRef = 87AA7D0A2071871E00E5DB80 /* hud_rewind_notification.png */; };
87AA7D0D2071871E00E5DB80 /* hud_rewind_notification@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 87AA7D0B2071871E00E5DB80 /* hud_rewind_notification@2x.png */; };
87B3DC0A1C644BCC003C65E4 /* controller_3do_mask@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 87B3DC081C644BCC003C65E4 /* controller_3do_mask@2x.png */; };
87B3DC0B1C644BCC003C65E4 /* controller_3do@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 87B3DC091C644BCC003C65E4 /* controller_3do@2x.png */; };
87BC4DA21BA3A88600BF1F86 /* controller_7800_mask@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 87BC4DA01BA3A88600BF1F86 /* controller_7800_mask@2x.png */; };
Expand Down Expand Up @@ -2213,6 +2217,10 @@
877EDD1E1E24BEE0004D68E7 /* Controller-Preferences-JAP.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Controller-Preferences-JAP.plist"; sourceTree = "<group>"; };
879243B21C0DA5910064C515 /* controller_5200_mask@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "controller_5200_mask@2x.png"; sourceTree = "<group>"; };
879243B31C0DA5910064C515 /* controller_5200@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "controller_5200@2x.png"; sourceTree = "<group>"; };
87AA7D032071870D00E5DB80 /* hud_fastforward_notification@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "hud_fastforward_notification@2x.png"; sourceTree = "<group>"; };
87AA7D072071870E00E5DB80 /* hud_fastforward_notification.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = hud_fastforward_notification.png; sourceTree = "<group>"; };
87AA7D0A2071871E00E5DB80 /* hud_rewind_notification.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = hud_rewind_notification.png; sourceTree = "<group>"; };
87AA7D0B2071871E00E5DB80 /* hud_rewind_notification@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "hud_rewind_notification@2x.png"; sourceTree = "<group>"; };
87ACB6BD1D2509B300138B7E /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/OEMigrationWindowController.strings; sourceTree = "<group>"; };
87ACB6BE1D2509B500138B7E /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/OELibraryGamesViewController.strings; sourceTree = "<group>"; };
87ACB6BF1D2509B600138B7E /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/OEPrefControlsController.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4072,8 +4080,12 @@
53439B9D13B93920005C0CC8 /* Interface Graphics */ = {
isa = PBXGroup;
children = (
87AA7D072071870E00E5DB80 /* hud_fastforward_notification.png */,
87AA7D032071870D00E5DB80 /* hud_fastforward_notification@2x.png */,
83F6076F1BD3E4C9001236FC /* hud_quicksave_notification.png */,
83F607701BD3E4C9001236FC /* hud_quicksave_notification@2x.png */,
87AA7D0A2071871E00E5DB80 /* hud_rewind_notification.png */,
87AA7D0B2071871E00E5DB80 /* hud_rewind_notification@2x.png */,
83F607711BD3E4C9001236FC /* hud_screenshot_notification.png */,
83F607721BD3E4C9001236FC /* hud_screenshot_notification@2x.png */,
83338C2117A281C7007E32E9 /* secret.mp3 */,
Expand Down Expand Up @@ -7050,7 +7062,9 @@
833ADC4D196B078E00217D9A /* OECollectionViewController.xib in Resources */,
83F607761BD3E4C9001236FC /* hud_screenshot_notification@2x.png in Resources */,
83F607751BD3E4C9001236FC /* hud_screenshot_notification.png in Resources */,
87AA7D0D2071871E00E5DB80 /* hud_rewind_notification@2x.png in Resources */,
8F071F3B1C255362007B76DA /* Credits.rtf in Resources */,
87AA7D082071870F00E5DB80 /* hud_fastforward_notification@2x.png in Resources */,
83DEF7C1196C403400C7DF57 /* ControlLabels.strings in Resources */,
83B04E421968610F00CB985E /* Localizable.strings in Resources */,
87191CC61F6F5524006D2EE3 /* dsa_pub.pem in Resources */,
Expand All @@ -7069,13 +7083,15 @@
83F607731BD3E4C9001236FC /* hud_quicksave_notification.png in Resources */,
838E2A231600A05C00CF7198 /* Theme.plist in Resources */,
C6F696C01648F64B00B243DB /* Controller-Database.plist in Resources */,
87AA7D092071870F00E5DB80 /* hud_fastforward_notification.png in Resources */,
83FE965919685F6700DD8DB9 /* OEGameScanner.xib in Resources */,
83B04E411968610F00CB985E /* InfoPlist.strings in Resources */,
83F607741BD3E4C9001236FC /* hud_quicksave_notification@2x.png in Resources */,
83FE963C1968596C00DD8DB9 /* OEMigrationWindowController.xib in Resources */,
83495DD819A38F3D009DB6E5 /* OEPrefBiosController.xib in Resources */,
83338C2217A281C7007E32E9 /* secret.mp3 in Resources */,
94AE2C1017B07D450018DFBB /* cheats-database.xml in Resources */,
87AA7D0C2071871E00E5DB80 /* hud_rewind_notification.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
10 changes: 10 additions & 0 deletions OpenEmu/OpenEmuHelperApp.m
Expand Up @@ -744,4 +744,14 @@ - (void)takeScreenshot:(id)sender
[self.gameCoreOwner takeScreenshot];
}

- (void)fastForwardGameplay:(BOOL)enable
{
[self.gameCoreOwner fastForwardGameplay:enable];
}

- (void)rewindGameplay:(BOOL)enable
{
[self.gameCoreOwner rewindGameplay:enable];
}

@end

0 comments on commit 1a0bda2

Please sign in to comment.