From 51968df11c4b03740d9e96474dc99d63e3d489cf Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 17 Jan 2017 19:05:44 +0500 Subject: [PATCH] adjust scrolling and fix some bugs --- proj.ios/AppDelegate.swift | 1 + proj.ios/CustomGLKView.h | 13 -- proj.ios/CustomGLKView.mm | 5 - proj.ios/CustomGLKView.swift | 58 +++++-- proj.ios/LaunchScreen.storyboard | 45 +++++ proj.ios/en.lproj/ViewController_iPad.xib | 162 ++++-------------- proj.ios/en.lproj/ViewController_iPhone.xib | 142 ++++----------- .../salmontemplate.xcodeproj/project.pbxproj | 10 +- proj.ios/template-Info.plist | 2 + 9 files changed, 157 insertions(+), 281 deletions(-) delete mode 100755 proj.ios/CustomGLKView.h delete mode 100755 proj.ios/CustomGLKView.mm create mode 100644 proj.ios/LaunchScreen.storyboard diff --git a/proj.ios/AppDelegate.swift b/proj.ios/AppDelegate.swift index 22abb53..c3de21d 100644 --- a/proj.ios/AppDelegate.swift +++ b/proj.ios/AppDelegate.swift @@ -10,6 +10,7 @@ import Foundation import UIKit @UIApplicationMain + class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? diff --git a/proj.ios/CustomGLKView.h b/proj.ios/CustomGLKView.h deleted file mode 100755 index 77acd11..0000000 --- a/proj.ios/CustomGLKView.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// CustomGLKView.h -// doublehitballs -// -// Created by vvv ооо on 15.07.12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "include/Utils/IosApi/ObjC/GLKViewTemplate.h" - -@interface CustomGLKView : GLKViewTemplate - -@end diff --git a/proj.ios/CustomGLKView.mm b/proj.ios/CustomGLKView.mm deleted file mode 100755 index 5b9214c..0000000 --- a/proj.ios/CustomGLKView.mm +++ /dev/null @@ -1,5 +0,0 @@ -#import "CustomGLKView.h" - -@implementation CustomGLKView - -@end \ No newline at end of file diff --git a/proj.ios/CustomGLKView.swift b/proj.ios/CustomGLKView.swift index c071e34..248944c 100644 --- a/proj.ios/CustomGLKView.swift +++ b/proj.ios/CustomGLKView.swift @@ -10,15 +10,16 @@ import Foundation import GLKit struct TTouchHashData { - var first: CGPoint! - var second: Bool! - var number: Int! + var first: CGPoint? + var second: Bool? + var number: Int? } - - class GLKViewTemplate: GLKView { + let xCoef: CGFloat = 480 / UIScreen.main.bounds.size.width + let yCoef: CGFloat = 320 / UIScreen.main.bounds.size.height + var touchDict: [UITouch: TTouchHashData] = [:] override init(frame: CGRect) { @@ -59,28 +60,53 @@ class GLKViewTemplate: GLKView { override func touchesBegan(_ touches: Set, with event: UIEvent?) { for touch in touches { - let location = touch.location(in: self) - let prevLocation = touch.previousLocation(in: self) + let location = CGPoint(x: touch.location(in: self).x * xCoef, y: touch.location(in: self).y * yCoef) + addTouchToHash(touch: touch) - if abs(touchDict[touch]!.first!.x - location.x) > 10 || abs(touchDict[touch]!.first!.y - location.y) > 10 { + guard let n = touchDict[touch]?.number else { + return + } + + let number = Int32(n) + print(bounds.size.height * yCoef - location.y) + SE_AppOnTapDown(Int32(location.x), Int32(bounds.size.height * yCoef - location.y), number) + } + } + + override func touchesMoved(_ touches: Set, with event: UIEvent?) { + for touch in touches { + let location = CGPoint(x: touch.location(in: self).x * xCoef, y: touch.location(in: self).y * yCoef) + let prevLocation = CGPoint(x: touch.previousLocation(in: self).x * xCoef, y: touch.previousLocation(in: self).y * yCoef) + + guard let x = touchDict[touch]?.first?.x, let y = touchDict[touch]?.first?.y, let n = touchDict[touch]?.number else { + return + } + if abs(x - location.x) > 10 || abs(y - location.y) > 10 { touchDict[touch]?.second = true } - let number = Int32(touchDict[touch]!.number) + let number = Int32(n) SE_AppOnScroll(Int32(Float(prevLocation.x) - Float(location.x)), -Int32(Float(prevLocation.y) - Float(location.y)), number) + print("location is:\(location)!!!!") } } override func touchesEnded(_ touches: Set, with event: UIEvent?) { for touch in touches { - let location = touch.location(in: self) - let number = Int32(touchDict[touch]!.number) + let location = CGPoint(x: touch.location(in: self).x * xCoef, y: touch.location(in: self).y * yCoef) + print("location is:\(location)!!!!") + + guard let n = touchDict[touch]?.number else { + return + } + + let number = Int32(n) if touchDict[touch]!.second == true { - SE_AppOnTapUpAfterMove(Int32(location.x), Int32(bounds.size.height - location.y), number) + SE_AppOnTapUpAfterMove(Int32(location.x), Int32(bounds.size.height * yCoef - location.y), number) } else { - SE_AppOnTapUp(Int32(location.x), Int32(bounds.size.height - location.y), number) + SE_AppOnTapUp(Int32(location.x), Int32(bounds.size.height * yCoef - location.y), number) } touchDict.removeValue(forKey: touch) } @@ -93,3 +119,9 @@ class GLKViewTemplate: GLKView { } } + +class CustomGLKView: GLKViewTemplate { + required init?(coder aDecoder: NSCoder) { + super.init(frame: UIScreen.main.bounds) + } +} diff --git a/proj.ios/LaunchScreen.storyboard b/proj.ios/LaunchScreen.storyboard new file mode 100644 index 0000000..4341f2e --- /dev/null +++ b/proj.ios/LaunchScreen.storyboard @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proj.ios/en.lproj/ViewController_iPad.xib b/proj.ios/en.lproj/ViewController_iPad.xib index eb81e88..8f94e41 100755 --- a/proj.ios/en.lproj/ViewController_iPad.xib +++ b/proj.ios/en.lproj/ViewController_iPad.xib @@ -1,133 +1,29 @@ - - - - 1296 - 11E53 - 2182 - 1138.47 - 569.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 1181 - - - IBProxyObject - IBUIView - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - PluginDependencyRecalculationVersion - - - - - IBFilesOwner - IBIPadFramework - - - IBFirstResponder - IBIPadFramework - - - - 274 - {{0, 20}, {768, 1004}} - - - - 3 - MQA - - 2 - - - - 2 - - IBIPadFramework - - - - - - - view - - - - 3 - - - - - - 0 - - - - - - 1 - - - - - -1 - - - File's Owner - - - -2 - - - - - - - ViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UIResponder - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - CustomGLKView - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - - - 3 - - - - - CustomGLKView - GLKView - - IBProjectSource - ./Classes/CustomGLKView.h - - - - ViewController - GLKViewController - - IBProjectSource - ./Classes/ViewController.h - - - - - 0 - IBIPadFramework - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - YES - 3 - 1181 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proj.ios/en.lproj/ViewController_iPhone.xib b/proj.ios/en.lproj/ViewController_iPhone.xib index 96a4a92..a6e33b1 100755 --- a/proj.ios/en.lproj/ViewController_iPhone.xib +++ b/proj.ios/en.lproj/ViewController_iPhone.xib @@ -1,111 +1,31 @@ - - - - 1296 - 11E53 - 2182 - 1138.47 - 569.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 1181 - - - IBProxyObject - IBUIView - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - PluginDependencyRecalculationVersion - - - - - IBFilesOwner - IBCocoaTouchFramework - - - IBFirstResponder - IBCocoaTouchFramework - - - - 274 - {320, 460} - - - 3 - MQA - - 2 - - - NO - IBCocoaTouchFramework - - - - - - - view - - - - 3 - - - - - - 0 - - - - - - -1 - - - File's Owner - - - -2 - - - - - 2 - - - - - - - ViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UIResponder - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - CustomGLKView - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - - - 4 - - - 0 - IBCocoaTouchFramework - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - YES - 3 - 1181 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proj.ios/salmontemplate.xcodeproj/project.pbxproj b/proj.ios/salmontemplate.xcodeproj/project.pbxproj index d2c9cd6..4b151b8 100755 --- a/proj.ios/salmontemplate.xcodeproj/project.pbxproj +++ b/proj.ios/salmontemplate.xcodeproj/project.pbxproj @@ -21,7 +21,6 @@ 4C77831815BABE26003D5142 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77831415BABD8B003D5142 /* AudioToolbox.framework */; }; 4C77831915BABE26003D5142 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77831515BABD8B003D5142 /* OpenAL.framework */; }; 4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7AD44B15B1D77700A599F6 /* ios_api.cpp */; }; - 4CCC0ECC15B30D6B005432FB /* CustomGLKView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4CCC0ECB15B30D6B005432FB /* CustomGLKView.mm */; }; 4CE6A9D215B2F979006A3965 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 4CE6A9D115B2F979006A3965 /* assets */; }; 74AC9EBD1E2CE407003C9749 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74AC9EBC1E2CE407003C9749 /* ViewController.swift */; }; 74AC9EC11E2CF533003C9749 /* SENamespaceWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC9EBF1E2CF533003C9749 /* SENamespaceWrapper.cpp */; }; @@ -29,6 +28,7 @@ 74C3AE2F1E2E2A40003C07F2 /* gamecode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74C3AE281E2E2A40003C07F2 /* gamecode.cpp */; }; 74C3AE301E2E2A40003C07F2 /* loadingcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74C3AE2A1E2E2A40003C07F2 /* loadingcode.cpp */; }; 74C3AE311E2E2A40003C07F2 /* menucode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74C3AE2C1E2E2A40003C07F2 /* menucode.cpp */; }; + 74C3AE4D1E2E4194003C07F2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 74C3AE4C1E2E4194003C07F2 /* LaunchScreen.storyboard */; }; 74EEBAEF1E2D13A6004C6C65 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74EEBAEE1E2D13A6004C6C65 /* AppDelegate.swift */; }; 74EEBAF11E2D1C7C004C6C65 /* CustomGLKView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74EEBAF01E2D1C7C004C6C65 /* CustomGLKView.swift */; }; 84D0FEBE1E274DDD00EC3FE5 /* libSalmon Engine.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C902A7815C5735700FBC901 /* libSalmon Engine.a */; }; @@ -86,8 +86,6 @@ 4C77831515BABD8B003D5142 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 4C7AD44B15B1D77700A599F6 /* ios_api.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ios_api.cpp; sourceTree = ""; }; 4C902A7015C5735500FBC901 /* Salmon Engine.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Salmon Engine.xcodeproj"; path = "../../Engine/iOS/Salmon Engine/Salmon Engine.xcodeproj"; sourceTree = ""; }; - 4CCC0ECA15B30D6A005432FB /* CustomGLKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomGLKView.h; sourceTree = ""; }; - 4CCC0ECB15B30D6B005432FB /* CustomGLKView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomGLKView.mm; sourceTree = ""; }; 4CCC0ECD15B310FB005432FB /* ios_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ios_api.h; sourceTree = ""; }; 4CE6A9D115B2F979006A3965 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = ../assets; sourceTree = ""; }; 74AC9EBB1E2CE407003C9749 /* salmontemplate-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "salmontemplate-Bridging-Header.h"; sourceTree = ""; }; @@ -103,6 +101,7 @@ 74C3AE2B1E2E2A40003C07F2 /* loadingcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = loadingcode.h; path = ../game/loadingcode.h; sourceTree = ""; }; 74C3AE2C1E2E2A40003C07F2 /* menucode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = menucode.cpp; path = ../game/menucode.cpp; sourceTree = ""; }; 74C3AE2D1E2E2A40003C07F2 /* menucode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = menucode.h; path = ../game/menucode.h; sourceTree = ""; }; + 74C3AE4C1E2E4194003C07F2 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 74EEBAEE1E2D13A6004C6C65 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 74EEBAF01E2D1C7C004C6C65 /* CustomGLKView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomGLKView.swift; sourceTree = ""; }; 84D0FEC11E274E3700EC3FE5 /* vorbis-tremor-ios.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "vorbis-tremor-ios.xcodeproj"; path = "../../libs/vorbis-tremor-ios/vorbis-tremor-ios.xcodeproj"; sourceTree = ""; }; @@ -176,9 +175,8 @@ 74EEBAF01E2D1C7C004C6C65 /* CustomGLKView.swift */, 4C49B2DA15B0991B003512CD /* ViewController_iPhone.xib */, 4C49B2DD15B0991B003512CD /* ViewController_iPad.xib */, + 74C3AE4C1E2E4194003C07F2 /* LaunchScreen.storyboard */, 4C49B2C815B0991B003512CD /* Supporting Files */, - 4CCC0ECA15B30D6A005432FB /* CustomGLKView.h */, - 4CCC0ECB15B30D6B005432FB /* CustomGLKView.mm */, ); name = Sources; sourceTree = ""; @@ -334,6 +332,7 @@ buildActionMask = 2147483647; files = ( 4C49B2CC15B0991B003512CD /* InfoPlist.strings in Resources */, + 74C3AE4D1E2E4194003C07F2 /* LaunchScreen.storyboard in Resources */, 4C49B2DC15B0991B003512CD /* ViewController_iPhone.xib in Resources */, 4C49B2DF15B0991B003512CD /* ViewController_iPad.xib in Resources */, 4CE6A9D215B2F979006A3965 /* assets in Resources */, @@ -360,7 +359,6 @@ 74AC9EC11E2CF533003C9749 /* SENamespaceWrapper.cpp in Sources */, 74C3AE311E2E2A40003C07F2 /* menucode.cpp in Sources */, 4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */, - 4CCC0ECC15B30D6B005432FB /* CustomGLKView.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/proj.ios/template-Info.plist b/proj.ios/template-Info.plist index 6ba4026..2f9b20a 100755 --- a/proj.ios/template-Info.plist +++ b/proj.ios/template-Info.plist @@ -28,6 +28,8 @@ UILaunchImageFile Splash-landscape.png + UILaunchStoryboardName + LaunchScreen UIPrerenderedIcon UIRequiredDeviceCapabilities