Advertisement
Guest User

SDL 2.0.3 Exult-iOS hardcoded changes

a guest
Sep 26th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 9.27 KB | None | 0 0
  1. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m
  2. index 42303e3..1a969e4 100644
  3. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m
  4. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m
  5. @@ -111,13 +111,13 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
  6.          share_group = [view.context sharegroup];
  7.      }
  8.  
  9. -    /* construct our view, passing in SDL's OpenGL configuration data */
  10. -    CGRect frame;
  11. -    if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
  12. -        frame = [displaydata->uiscreen bounds];
  13. -    } else {
  14. -        frame = [displaydata->uiscreen applicationFrame];
  15. -    }
  16. +    /* construct our view, passing in SDL's OpenGL configuration data
  17. +     * In order to have the accurate size in real pixels,
  18. +     * we need to take the scaling (retina display) into account.
  19. +     */
  20. +    CGRect frame = CGRectMake(0, 0,
  21. +                              window->w / displaymodedata->scale,
  22. +                              window->h / displaymodedata->scale);
  23.      view = [[SDL_uikitopenglview alloc] initWithFrame: frame
  24.                                      scale: displaymodedata->scale
  25.                                      retainBacking: _this->gl_config.retained_backing
  26. @@ -136,10 +136,9 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
  27.      data->view = view;
  28.      view->viewcontroller = data->viewcontroller;
  29.      if (view->viewcontroller != nil) {
  30. -        [view->viewcontroller setView:view];
  31. +           view->viewcontroller.screenView = view;
  32.          [view->viewcontroller retain];
  33.      }
  34. -    [uiwindow addSubview: view];
  35.  
  36.      /* The view controller needs to be the root in order to control rotation on iOS 6.0 */
  37.      if (uiwindow.rootViewController == nil) {
  38. @@ -165,7 +164,7 @@ void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
  39.      /* the delegate has retained the view, this will release him */
  40.      SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
  41.      if (view->viewcontroller) {
  42. -        UIWindow *uiwindow = (UIWindow *)view.superview;
  43. +        UIWindow *uiwindow = (UIWindow *)view.window;
  44.          if (uiwindow.rootViewController == view->viewcontroller) {
  45.              uiwindow.rootViewController = nil;
  46.          }
  47. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m
  48. index 5c163c9..1074d3e 100644
  49. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m
  50. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m
  51. @@ -125,9 +125,6 @@
  52.  
  53.          glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
  54.          /* end create buffers */
  55. -
  56. -        self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
  57. -        self.autoresizesSubviews = YES;
  58.      }
  59.      return self;
  60.  }
  61. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h
  62. index e8d595d..0d06a57 100644
  63. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h
  64. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h
  65. @@ -26,9 +26,11 @@
  66.  @interface SDL_uikitviewcontroller : UIViewController {
  67.  @private
  68.      SDL_Window *window;
  69. +    UIView *screenView;
  70.  }
  71.  
  72.  @property (readwrite) SDL_Window *window;
  73. +@property (nonatomic,retain) UIView *screenView;
  74.  
  75.  - (id)initWithSDLWindow:(SDL_Window *)_window;
  76.  - (void)loadView;
  77. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
  78. index 447b80b..0a151ee 100644
  79. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
  80. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
  81. @@ -37,6 +37,7 @@
  82.  @implementation SDL_uikitviewcontroller
  83.  
  84.  @synthesize window;
  85. +@synthesize screenView;
  86.  
  87.  - (id)initWithSDLWindow:(SDL_Window *)_window
  88.  {
  89. @@ -49,13 +50,44 @@
  90.      return self;
  91.  }
  92.  
  93. +- (void)dealloc
  94. +{
  95. +   self.screenView = nil;
  96. +    [super dealloc];
  97. +}
  98. +
  99.  - (void)loadView
  100.  {
  101. -    /* do nothing. */
  102. +   self.view = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
  103. +    self.view.backgroundColor = [UIColor blueColor];
  104. +}
  105. +
  106. +- (void)setScreenView:(UIView *)_screenView
  107. +{
  108. +   if (screenView != nil) {
  109. +       [screenView removeFromSuperview];
  110. +       [screenView release];
  111. +    }
  112. +    screenView = [_screenView retain];
  113. +    [self.view addSubview:screenView];
  114. +    [self adjustScreenView];
  115. +}
  116. +
  117. +- (void)adjustScreenView
  118. +{
  119. +   if (screenView == nil)
  120. +       return;
  121. +    
  122. +    float scalex =self.view.frame.size.width/screenView.bounds.size.width;
  123. +    float scaley = self.view.frame.size.height/screenView.bounds.size.height;
  124. +    
  125. +    screenView.transform = CGAffineTransformMakeScale(scalex, scaley);
  126. +    screenView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
  127.  }
  128.  
  129.  - (void)viewDidLayoutSubviews
  130.  {
  131. +   [self adjustScreenView];
  132.      if (self->window->flags & SDL_WINDOW_RESIZABLE) {
  133.          SDL_WindowData *data = self->window->driverdata;
  134.          SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window);
  135. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
  136. index a1dd1a9..71ba74a 100644
  137. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
  138. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
  139. @@ -61,7 +61,8 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
  140.      data->view = nil;
  141.  
  142.      /* Fill in the SDL window with the window data */
  143. -    {
  144. +    if (0) { /* Don't do this because we want to honor the window size
  145. +              * request from apps */
  146.          window->x = 0;
  147.          window->y = 0;
  148.  
  149. --
  150. 2.7.4
  151. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h
  152. index d5430be..80b176b 100644
  153. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h
  154. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h
  155. @@ -22,8 +22,11 @@
  156.  #import <UIKit/UIKit.h>
  157.  
  158.  @interface SDLUIKitDelegate : NSObject<UIApplicationDelegate> {
  159. +   UIWindow *window;
  160.  }
  161.  
  162. +@property (nonatomic, retain) UIWindow *window;
  163. +
  164.  + (id) sharedAppDelegate;
  165.  + (NSString *)getAppDelegateClassName;
  166.  
  167. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m
  168. index a9924fb..8f9b858 100644
  169. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m
  170. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m
  171. @@ -161,6 +161,7 @@ SDL_IdleTimerDisabledChanged(void *userdata, const char *name, const char *oldVa
  172.  
  173.  
  174.  @implementation SDLUIKitDelegate
  175. +@synthesize window;
  176.  
  177.  /* convenience method */
  178.  + (id) sharedAppDelegate
  179. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m
  180. index f890b7a..f5d2f7a 100644
  181. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m
  182. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m
  183. @@ -411,6 +411,7 @@ void _uikit_keyboard_set_height(int height) {
  184.  }
  185.  
  186.  void _uikit_keyboard_init() {
  187. +#if 0
  188.      NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
  189.      NSOperationQueue *queue = [NSOperationQueue mainQueue];
  190.      [center addObserverForName:UIKeyboardWillShowNotification
  191. @@ -437,6 +438,7 @@ void _uikit_keyboard_init() {
  192.                          _uikit_keyboard_set_height(0);
  193.                      }
  194.       ];
  195. +#endif
  196.  }
  197.  
  198.  void
  199. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
  200. index 71ba74a..5c65463 100644
  201. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
  202. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m
  203. @@ -196,7 +196,8 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
  204.      /* !!! FIXME: can we have a smaller view? */
  205.      UIWindow *uiwindow = [UIWindow alloc];
  206.      uiwindow = [uiwindow initWithFrame:[data->uiscreen bounds]];
  207. -
  208. +   [[[UIApplication sharedApplication] delegate] setWindow:uiwindow];
  209. +    
  210.      /* put the window on an external display if appropriate. This implicitly
  211.       * does [uiwindow setframe:[uiscreen bounds]], so don't do it on the
  212.       * main display, where we land by default, as that would eat the
  213.  
  214. diff --git a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
  215. index 0a151ee..5755032 100644
  216. --- a/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
  217. +++ b/ios/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m
  218. @@ -78,11 +78,12 @@
  219.     if (screenView == nil)
  220.         return;
  221.      
  222. -    float scalex =self.view.frame.size.width/screenView.bounds.size.width;
  223. -    float scaley = self.view.frame.size.height/screenView.bounds.size.height;
  224. -    
  225. +    float availWidth = self.view.bounds.size.width;
  226. +    float availHeight = self.view.bounds.size.height;
  227. +    float scalex = availWidth/screenView.bounds.size.width;
  228. +    float scaley = availHeight/screenView.bounds.size.height;
  229.      screenView.transform = CGAffineTransformMakeScale(scalex, scaley);
  230. -    screenView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
  231. +    screenView.center = CGPointMake(availWidth/2, availHeight/2);
  232.  }
  233.  
  234.  - (void)viewDidLayoutSubviews
  235. --
  236. 2.7.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement