From 9cc2c6cc4d8f6510d834afbadaa39e2257499239 Mon Sep 17 00:00:00 2001 From: Michael Nguyen Date: Wed, 27 Nov 2013 22:25:22 -0800 Subject: [PATCH] updated iOS UI issues: * fixed status bar issue on iOS7, where status bar information was invisible on iOS7 devices * fixed some font issues on the Shop screens to make them more legible for iOS users. ( changed font size for Interactive Buttons and card list) * added new gesture for opening up the menu screen for iOS. Since there are no external buttons on iOS devices, we need either on-screen buttons or gestures to compensate. Using the pinch or zoom gesture will simulate pressing the "MENU" button on the PSP on all screens now. Not ideal, but something for now until we can work in a new button or way to open up the menu. --- JGE/src/iOS/EAGLView.m | 22 +++++++++++++++---- JGE/src/iOS/EAGLViewController.m | 6 +++-- JGE/src/iOS/ES2Renderer.m | 3 ++- projects/mtg/iOS/UI/UIScreen+Util.h | 14 ++++++++++++ projects/mtg/iOS/UI/UIScreen+Util.m | 23 ++++++++++++++++++++ projects/mtg/src/GameStateShop.cpp | 12 ++++++---- projects/mtg/wagic.xcodeproj/project.pbxproj | 16 +++++--------- 7 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 projects/mtg/iOS/UI/UIScreen+Util.h create mode 100644 projects/mtg/iOS/UI/UIScreen+Util.m diff --git a/JGE/src/iOS/EAGLView.m b/JGE/src/iOS/EAGLView.m index 35e164f59..a9f25cd29 100755 --- a/JGE/src/iOS/EAGLView.m +++ b/JGE/src/iOS/EAGLView.m @@ -166,11 +166,12 @@ void DestroyGame(void) [menuKeyRecognizer requireGestureRecognizerToFail: selectKeyRecognizer]; [self addGestureRecognizer:menuKeyRecognizer]; - /* + // initialize the scaling factor + lastScale = 1.f; UIPinchGestureRecognizer *pinchZoomRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchZoom:)]; [self addGestureRecognizer:pinchZoomRecognizer]; [pinchZoomRecognizer release]; - */ + /* Create a single tap recognizer to select the nearest object. @@ -391,8 +392,6 @@ void DestroyGame(void) } - - - (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; @@ -425,6 +424,21 @@ void DestroyGame(void) } #pragma mark Gesture Recognizer callbacks +- (void)handlePinchZoom: (UIPinchGestureRecognizer *) pinchGesture { + [[[pinchGesture view] layer] removeAllAnimations]; + CGFloat currentScaleFactor = [pinchGesture scale]; + + if (pinchGesture.state == UIGestureRecognizerStateEnded) { + if (lastScale < 1.3f) { + lastScale *= currentScaleFactor; + } + else { + lastScale = 1; + [self displayGameMenu]; + } + pinchGesture.scale = 1.f; + } +} - (void)handlePanMotion: (UIPanGestureRecognizer *) panGesture { diff --git a/JGE/src/iOS/EAGLViewController.m b/JGE/src/iOS/EAGLViewController.m index 4ad3950b1..dac9522a0 100755 --- a/JGE/src/iOS/EAGLViewController.m +++ b/JGE/src/iOS/EAGLViewController.m @@ -47,7 +47,6 @@ - (void)viewDidLoad { NSLog(@"EAGL ViewController - view Did Load"); - [super viewDidLoad]; } @@ -56,7 +55,6 @@ [self.view resumeGame]; } - - (void)viewWillDisappear:(BOOL)animated { [self.view pauseGame]; @@ -77,6 +75,10 @@ [self.view endGame]; } +- (UIStatusBarStyle)preferredStatusBarStyle { + return UIStatusBarStyleLightContent; +} + - (void)viewDidAppear:(BOOL)animated { NSLog(@"EAGL ViewController - view Did Appear"); diff --git a/JGE/src/iOS/ES2Renderer.m b/JGE/src/iOS/ES2Renderer.m index d49e33735..782373314 100755 --- a/JGE/src/iOS/ES2Renderer.m +++ b/JGE/src/iOS/ES2Renderer.m @@ -7,6 +7,7 @@ #include "JFileSystem.h" #include "JRenderer.h" #include "JGameLauncher.h" +#include "UIScreen+Util.h" #define ACTUAL_SCREEN_WIDTH (SCREEN_WIDTH) #define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT) @@ -61,7 +62,7 @@ bool checkFramebufferStatus(); // for retina devices. because of the 568 px, the ratio between height-width skews the // frame a bit - if ( backingHeight == 568 || backingWidth == 568) { + if ( [UIScreen isRetinaDisplay]) { viewPort.left = 0; viewPort.top = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + 22; // account for status bar viewPort.right = backingWidth; diff --git a/projects/mtg/iOS/UI/UIScreen+Util.h b/projects/mtg/iOS/UI/UIScreen+Util.h new file mode 100644 index 000000000..242306c22 --- /dev/null +++ b/projects/mtg/iOS/UI/UIScreen+Util.h @@ -0,0 +1,14 @@ +// +// UIScreen+Util.h +// wagic +// +// Created by Michael Nguyen on 11/27/13. +// +// + +#import + +@interface UIScreen (Util) + ++(BOOL)isRetinaDisplay; +@end diff --git a/projects/mtg/iOS/UI/UIScreen+Util.m b/projects/mtg/iOS/UI/UIScreen+Util.m new file mode 100644 index 000000000..b555e36bd --- /dev/null +++ b/projects/mtg/iOS/UI/UIScreen+Util.m @@ -0,0 +1,23 @@ +// +// UIScreen+Util.m +// wagic +// +// Created by Michael Nguyen on 11/27/13. +// +// +#include "UIScreen+Util.h" + +static BOOL isRetinaScreen = NO; +static BOOL didRetinaCheck = NO; + +@implementation UIScreen (Util) ++ (BOOL)isRetinaDisplay +{ + if (!didRetinaCheck) { + isRetinaScreen = ([[self mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && + ([self mainScreen].scale == 2.0)); + didRetinaCheck = YES; + } + return isRetinaScreen; +} +@end \ No newline at end of file diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 2b780f5c7..2caea20cb 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -79,7 +79,7 @@ GameStateShop::GameStateShop(GameApp* parent) : kCreditsString = _(kCreditsString); cycleCardsButton = NEW InteractiveButton(NULL, kCycleCardsButtonId, Fonts::MAIN_FONT, "New Cards", SCREEN_WIDTH_F - 80, SCREEN_HEIGHT_F - 20, JGE_BTN_PRI); - + showCardListButton = NEW InteractiveButton(NULL, kShowCardListButtonId, Fonts::MAIN_FONT, "Show List", SCREEN_WIDTH_F - 150, SCREEN_HEIGHT_F - 20, JGE_BTN_SEC); disablePurchase = false; clearInput = false; @@ -768,17 +768,21 @@ void GameStateShop::Render() r->FillRect(0, SCREEN_HEIGHT - 17, SCREEN_WIDTH, 17, ARGB(128,0,0,0)); std::ostringstream stream; stream << kCreditsString << playerdata->credits; - mFont->SetColor(ARGB(255,255,255,255)); - mFont->DrawString(stream.str(), 5, SCREEN_HEIGHT - 14); #ifndef TOUCH_ENABLED float len = 4 + mFont->GetStringWidth(kOtherCardsString.c_str()); r->RenderQuad(pspIcons[6].get(), SCREEN_WIDTH - len - 0.5 - 10, SCREEN_HEIGHT - 8, 0, kPspIconScaleFactor, kPspIconScaleFactor); mFont->DrawString(kOtherCardsString, SCREEN_WIDTH - len, SCREEN_HEIGHT - 14); #else +#ifdef IOS + mFont->SetScale(1.2f); // for iOS devices. +#endif + enableButtons(); #endif - + mFont->SetColor(ARGB(255,255,255,255)); + mFont->DrawString(stream.str(), 5, SCREEN_HEIGHT - 14); + mFont->SetColor(ARGB(255,255,255,0)); mFont->DrawString(descPurchase(bigSync.getPos()).c_str(), SCREEN_WIDTH / 2, SCREEN_HEIGHT - 14, JGETEXT_CENTER); mFont->SetColor(ARGB(255,255,255,255)); diff --git a/projects/mtg/wagic.xcodeproj/project.pbxproj b/projects/mtg/wagic.xcodeproj/project.pbxproj index 6f4b9057d..af64e1ce4 100755 --- a/projects/mtg/wagic.xcodeproj/project.pbxproj +++ b/projects/mtg/wagic.xcodeproj/project.pbxproj @@ -67,7 +67,6 @@ 12059DA814980B7300DAC43B /* AllAbilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F41291C60500B9016A /* AllAbilities.cpp */; }; 12059DA914980B7300DAC43B /* CardDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F51291C60500B9016A /* CardDescriptor.cpp */; }; 12059DAA14980B7300DAC43B /* CardDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F61291C60500B9016A /* CardDisplay.cpp */; }; - 12059DAB14980B7300DAC43B /* CardEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F71291C60500B9016A /* CardEffect.cpp */; }; 12059DAC14980B7300DAC43B /* CardGui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F81291C60500B9016A /* CardGui.cpp */; }; 12059DAD14980B7300DAC43B /* CardPrimitive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F91291C60500B9016A /* CardPrimitive.cpp */; }; 12059DAE14980B7300DAC43B /* CardSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376FA1291C60500B9016A /* CardSelector.cpp */; }; @@ -217,7 +216,6 @@ 12059E5D14980B7300DAC43B /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 128ED50B148BCBBC00C58E83 /* MapKit.framework */; }; 12059E5E14980B7300DAC43B /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 128ED518148BF0E000C58E83 /* MediaPlayer.framework */; }; 1216D633148F7411000F2295 /* libc++abi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1216D632148F7411000F2295 /* libc++abi.dylib */; settings = {ATTRIBUTES = (Weak, ); }; }; - 1216D634148F747D000F2295 /* libGoogleAdMobAds.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 128ED379148BAE7B00C58E83 /* libGoogleAdMobAds.a */; settings = {ATTRIBUTES = (Weak, ); }; }; 12211E7914931CBB00641703 /* ASIAuthenticationDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 12211E2814931CBB00641703 /* ASIAuthenticationDialog.m */; }; 12211E7A14931CBB00641703 /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = 12211E2B14931CBB00641703 /* ASIDataCompressor.m */; }; 12211E7B14931CBB00641703 /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = 12211E2D14931CBB00641703 /* ASIDataDecompressor.m */; }; @@ -285,6 +283,7 @@ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD14FF0DC6FC520079059D /* OpenGLES.framework */; }; 28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD15070DC6FC5B0079059D /* QuartzCore.framework */; }; + 75877A32184714BF0076B4A2 /* UIScreen+Util.m in Sources */ = {isa = PBXBuildFile; fileRef = 75877A31184714BF0076B4A2 /* UIScreen+Util.m */; }; 75D209D3181D54FD009916AC /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 75D209D1181D54FD009916AC /* Default-568h@2x.png */; }; 75D209D4181D54FD009916AC /* wagic-80x80.png in Resources */ = {isa = PBXBuildFile; fileRef = 75D209D2181D54FD009916AC /* wagic-80x80.png */; }; CE97CD1E1295AB4300FDFD3B /* SimplePopup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE97CD1D1295AB4300FDFD3B /* SimplePopup.cpp */; }; @@ -307,7 +306,6 @@ CEA3775E1291C60500B9016A /* AllAbilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F41291C60500B9016A /* AllAbilities.cpp */; }; CEA3775F1291C60500B9016A /* CardDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F51291C60500B9016A /* CardDescriptor.cpp */; }; CEA377601291C60500B9016A /* CardDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F61291C60500B9016A /* CardDisplay.cpp */; }; - CEA377611291C60500B9016A /* CardEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F71291C60500B9016A /* CardEffect.cpp */; }; CEA377621291C60500B9016A /* CardGui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F81291C60500B9016A /* CardGui.cpp */; }; CEA377631291C60500B9016A /* CardPrimitive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376F91291C60500B9016A /* CardPrimitive.cpp */; }; CEA377641291C60500B9016A /* CardSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEA376FA1291C60500B9016A /* CardSelector.cpp */; }; @@ -578,6 +576,8 @@ 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 28FD14FF0DC6FC520079059D /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 28FD15070DC6FC5B0079059D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 75877A30184714BF0076B4A2 /* UIScreen+Util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIScreen+Util.h"; path = "UI/UIScreen+Util.h"; sourceTree = ""; }; + 75877A31184714BF0076B4A2 /* UIScreen+Util.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIScreen+Util.m"; path = "UI/UIScreen+Util.m"; sourceTree = ""; }; 75D209D1181D54FD009916AC /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = SOURCE_ROOT; }; 75D209D2181D54FD009916AC /* wagic-80x80.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "wagic-80x80.png"; sourceTree = SOURCE_ROOT; }; 8D1107310486CEB800E47090 /* wagic-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "wagic-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; @@ -609,7 +609,6 @@ CEA3768C1291C60500B9016A /* AllAbilities.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = AllAbilities.h; sourceTree = ""; }; CEA3768D1291C60500B9016A /* CardDescriptor.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = CardDescriptor.h; sourceTree = ""; }; CEA3768E1291C60500B9016A /* CardDisplay.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = CardDisplay.h; sourceTree = ""; }; - CEA3768F1291C60500B9016A /* CardEffect.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = CardEffect.h; sourceTree = ""; }; CEA376901291C60500B9016A /* CardGui.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = CardGui.h; sourceTree = ""; }; CEA376911291C60500B9016A /* CardPrimitive.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = CardPrimitive.h; sourceTree = ""; }; CEA376921291C60500B9016A /* CardSelector.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = CardSelector.h; sourceTree = ""; }; @@ -711,7 +710,6 @@ CEA376F41291C60500B9016A /* AllAbilities.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = AllAbilities.cpp; sourceTree = ""; }; CEA376F51291C60500B9016A /* CardDescriptor.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = CardDescriptor.cpp; sourceTree = ""; }; CEA376F61291C60500B9016A /* CardDisplay.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = CardDisplay.cpp; sourceTree = ""; }; - CEA376F71291C60500B9016A /* CardEffect.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = CardEffect.cpp; sourceTree = ""; }; CEA376F81291C60500B9016A /* CardGui.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = CardGui.cpp; sourceTree = ""; }; CEA376F91291C60500B9016A /* CardPrimitive.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = CardPrimitive.cpp; sourceTree = ""; }; CEA376FA1291C60500B9016A /* CardSelector.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = CardSelector.cpp; sourceTree = ""; }; @@ -922,7 +920,6 @@ 12D095E114417D0500F69056 /* libstdc++.dylib in Frameworks */, 12211EBB14934A2C00641703 /* CFNetwork.framework in Frameworks */, 12211EB914934A1900641703 /* MobileCoreServices.framework in Frameworks */, - 1216D634148F747D000F2295 /* libGoogleAdMobAds.a in Frameworks */, 1216D633148F7411000F2295 /* libc++abi.dylib in Frameworks */, 128ED510148BCC1900C58E83 /* libsqlite3.dylib in Frameworks */, 129654D1148A52740031100B /* iAd.framework in Frameworks */, @@ -1017,6 +1014,8 @@ children = ( CE9A477512B514BA00C9F38A /* EAGLView.h */, CE9A477612B514BA00C9F38A /* EAGLView.m */, + 75877A30184714BF0076B4A2 /* UIScreen+Util.h */, + 75877A31184714BF0076B4A2 /* UIScreen+Util.m */, ); name = UI; sourceTree = ""; @@ -1306,7 +1305,6 @@ CEA3768C1291C60500B9016A /* AllAbilities.h */, CEA3768D1291C60500B9016A /* CardDescriptor.h */, CEA3768E1291C60500B9016A /* CardDisplay.h */, - CEA3768F1291C60500B9016A /* CardEffect.h */, CEA376901291C60500B9016A /* CardGui.h */, CEA376911291C60500B9016A /* CardPrimitive.h */, CEA376921291C60500B9016A /* CardSelector.h */, @@ -1427,7 +1425,6 @@ CEA376F41291C60500B9016A /* AllAbilities.cpp */, CEA376F51291C60500B9016A /* CardDescriptor.cpp */, CEA376F61291C60500B9016A /* CardDisplay.cpp */, - CEA376F71291C60500B9016A /* CardEffect.cpp */, CEA376F81291C60500B9016A /* CardGui.cpp */, CEA376F91291C60500B9016A /* CardPrimitive.cpp */, CEA376FA1291C60500B9016A /* CardSelector.cpp */, @@ -1827,7 +1824,6 @@ 12059DA814980B7300DAC43B /* AllAbilities.cpp in Sources */, 12059DA914980B7300DAC43B /* CardDescriptor.cpp in Sources */, 12059DAA14980B7300DAC43B /* CardDisplay.cpp in Sources */, - 12059DAB14980B7300DAC43B /* CardEffect.cpp in Sources */, 12059DAC14980B7300DAC43B /* CardGui.cpp in Sources */, 12059DAD14980B7300DAC43B /* CardPrimitive.cpp in Sources */, 12059DAE14980B7300DAC43B /* CardSelector.cpp in Sources */, @@ -2009,7 +2005,6 @@ CEA3775E1291C60500B9016A /* AllAbilities.cpp in Sources */, CEA3775F1291C60500B9016A /* CardDescriptor.cpp in Sources */, CEA377601291C60500B9016A /* CardDisplay.cpp in Sources */, - CEA377611291C60500B9016A /* CardEffect.cpp in Sources */, CEA377621291C60500B9016A /* CardGui.cpp in Sources */, CEA377631291C60500B9016A /* CardPrimitive.cpp in Sources */, CEA377641291C60500B9016A /* CardSelector.cpp in Sources */, @@ -2099,6 +2094,7 @@ CEA377BE1291C60500B9016A /* WFilter.cpp in Sources */, CEA377BF1291C60500B9016A /* WFont.cpp in Sources */, CEA377C01291C60500B9016A /* WGui.cpp in Sources */, + 75877A32184714BF0076B4A2 /* UIScreen+Util.m in Sources */, CEA377C11291C60500B9016A /* WResourceManager.cpp in Sources */, CE97CD1E1295AB4300FDFD3B /* SimplePopup.cpp in Sources */, CE9A478512B514BA00C9F38A /* EAGLView.m in Sources */,