Advertisement
dominus

Untitled

Jan 30th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.46 KB | None | 0 0
  1. diff --git a/cheat.cc b/cheat.cc
  2. index de111c8..6f052c3 100644
  3. --- a/cheat.cc
  4. +++ b/cheat.cc
  5. @@ -841,7 +841,12 @@ void Cheat::cursor_teleport(void) const {
  6.  
  7.     int x, y;
  8.     SDL_GetMouseState(&x, &y);
  9. +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
  10. +   gwin->get_win()->screen_to_game_hdpi(x, y, gwin->get_fastmouse(), x, y);
  11. +#else
  12.     gwin->get_win()->screen_to_game(x, y, gwin->get_fastmouse(), x, y);
  13. +#endif
  14. +  
  15.     Tile_coord t(gwin->get_scrolltx() + x / c_tilesize,
  16.                  gwin->get_scrollty() + y / c_tilesize, 0);
  17.     t.fixme();
  18. diff --git a/imagewin/imagewin.cc b/imagewin/imagewin.cc
  19. index de53848..8cd67ce 100644
  20. --- a/imagewin/imagewin.cc
  21. +++ b/imagewin/imagewin.cc
  22. @@ -104,6 +104,9 @@ int Image_window::desktop_depth = 0;
  23.  int Image_window::windowed_8 = 0;
  24.  int Image_window::windowed_16 = 0;
  25.  int Image_window::windowed_32 = 0;
  26. +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
  27. +float Image_window::nativescale = 1.0;
  28. +#endif
  29.  
  30.  const int Image_window::guard_band = 4;
  31.  
  32. @@ -696,6 +699,9 @@ bool Image_window::create_scale_surfaces(int w, int h, int bpp) {
  33.         h=dh;
  34.         Resolution res = { w, h, false, false, false};
  35.         p_resolutions[(w << 16) | h] = res;
  36. +       int sw;
  37. +       SDL_GetWindowSize(screen_window, &sw, 0);
  38. +       nativescale = dw / sw;
  39.  #endif
  40.         //high resolution fullscreen needs this to make the whole screen available
  41.         SDL_RenderSetLogicalSize(screen_renderer, w, h);
  42. diff --git a/imagewin/imagewin.h b/imagewin/imagewin.h
  43. index b19fe9e..4bd1544 100644
  44. --- a/imagewin/imagewin.h
  45. +++ b/imagewin/imagewin.h
  46. @@ -293,6 +293,9 @@ class Image_window {
  47.     static int windowed_8;
  48.     static int windowed_16;
  49.     static int windowed_32;
  50. +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
  51. +   static float nativescale;
  52. +#endif
  53.  
  54.  public:
  55.  #if SDL_VERSION_ATLEAST(2, 0, 0)
  56. @@ -334,6 +337,17 @@ class Image_window {
  57.             gy = (sy * inter_height) / (scale * get_display_height()) + get_start_y();
  58.         }
  59.     }
  60. +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
  61. +   void screen_to_game_hdpi(int sx, int sy, bool fast, int &gx, int &gy) {
  62. +       if (fast) {
  63. +           gx = sx + get_start_x();
  64. +           gy = sy + get_start_y();
  65. +       } else {
  66. +           gx = ((sx * inter_width) / (scale * get_display_width()) + get_start_x()) * nativescale;
  67. +           gy = ((sy * inter_height) / (scale * get_display_height()) + get_start_y()) * nativescale;
  68. +       }
  69. +   }
  70. +#endif
  71.     void game_to_screen(int gx, int gy, bool fast, int &sx, int &sy) {
  72.         if (fast) {
  73.             sx = gx - get_start_x();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement