Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/cheat.cc b/cheat.cc
- index c542eb75..d0af000d 100644
- --- a/cheat.cc
- +++ b/cheat.cc
- @@ -842,7 +842,11 @@ void Cheat::cursor_teleport(void) const {
- int x, y;
- SDL_GetMouseState(&x, &y);
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + gwin->get_win()->screen_to_game_hdpi(x, y, gwin->get_fastmouse(), x, y);
- + #else
- gwin->get_win()->screen_to_game(x, y, gwin->get_fastmouse(), x, y);
- +#endif
- Tile_coord t(gwin->get_scrolltx() + x / c_tilesize,
- gwin->get_scrollty() + y / c_tilesize, 0);
- t.fixme();
- diff --git a/exult.cc b/exult.cc
- index 4a9405d8..a40a6840 100644
- --- a/exult.cc
- +++ b/exult.cc
- @@ -2318,6 +2318,10 @@ void setup_video(bool fullscreen, int setup_video_type, int resx, int resy,
- config->value("config/video/share_video_settings", share_settings, true);
- const string vidStr((fullscreen || share_settings) ?
- "config/video" : "config/video/window");
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + bool high_dpi;
- + config->value("config/video/highdpi", high_dpi, true);
- + #endif
- if (read_config) {
- #ifdef DEBUG
- cout << "Reading video menu adjustable configuration options" << endl;
- @@ -2360,6 +2364,12 @@ void setup_video(bool fullscreen, int setup_video_type, int resx, int resy,
- config->value(vidStr + "/display/height", resy, resy * scaleval);
- config->value(vidStr + "/game/width", gw, 320);
- config->value(vidStr + "/game/height", gh, 200);
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + if (high_dpi)
- + SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
- + else
- + SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1");
- + #endif
- config->value(vidStr + "/fill_mode", fmode_string, "Centre");
- fillmode = Image_window::string_to_fillmode(fmode_string.c_str());
- if (fillmode == 0)
- @@ -2389,6 +2399,10 @@ void setup_video(bool fullscreen, int setup_video_type, int resx, int resy,
- config->set((vidStr + "/scale_method").c_str(), scalerName , false);
- config->set((vidStr + "/fill_mode").c_str(), fmode_string, false);
- config->set((vidStr + "/fill_scaler").c_str(), fillScalerName, false);
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + config->set("config/video/highdpi", high_dpi ?
- + "yes" : "no", false);
- + #endif
- }
- if (video_init) {
- #ifdef DEBUG
- diff --git a/gumps/VideoOptions_gump.cc b/gumps/VideoOptions_gump.cc
- index 7cfdca6f..7404e270 100644
- --- a/gumps/VideoOptions_gump.cc
- +++ b/gumps/VideoOptions_gump.cc
- @@ -136,6 +136,10 @@ void VideoOptions_gump::toggle(Gump_button *btn, int state) {
- fill_mode = static_cast<Image_window::FillMode>((fill_mode&~1) | (has_ac ? 1 : 0));
- } else if (btn == buttons[id_share_settings])
- share_settings = state;
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + else if (btn == buttons[id_high_dpi])
- + highdpi = state;
- + #endif
- paint();
- }
- @@ -336,6 +340,9 @@ void VideoOptions_gump::load_settings(bool Fullscreen) {
- o_fill_scaler = fill_scaler;
- o_fill_mode = fill_mode;
- o_game_resolution = game_resolution;
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + o_highdpi = highdpi;
- + #endif
- }
- VideoOptions_gump::VideoOptions_gump() : Modal_gump(0, EXULT_FLX_VIDEOOPTIONS_SHP, SF_EXULT_FLX) {
- @@ -349,6 +356,16 @@ VideoOptions_gump::VideoOptions_gump() : Modal_gump(0, EXULT_FLX_VIDEOOPTIONS_SH
- enabledtext[1] = "Enabled";
- buttons[id_fullscreen] = new VideoTextToggle(this, enabledtext, colx[2], rowy[0], 74,
- fullscreen, 2);
- +
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + config->value("config/video/highdpi", highdpi, false);
- + std::string *hdpi_text = new std::string[2];
- + hdpi_text[0] = "Disabled";
- + hdpi_text[1] = "Enabled";
- + buttons[id_high_dpi] = new VideoTextToggle(this, hdpi_text, colx[2], rowy[2], 74,
- + highdpi, 2);
- +#endif
- +
- config->value("config/video/share_video_settings", share_settings, false);
- std::string *yesNO = new std::string[2];
- yesNO[0] = "No";
- @@ -385,6 +402,12 @@ void VideoOptions_gump::save_settings() {
- if (!Yesno_gump::ask("Scaled size less than 320x200.\nExult may be unusable.\nApply anyway?", "TINY_BLACK_FONT"))
- return;
- }
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + if (highdpi != o_highdpi) {
- + if (!Yesno_gump::ask("After toggling HighDPi you will need to restart Exult!\nApply anyway?", "TINY_BLACK_FONT"))
- + return;
- + }
- + #endif
- gwin->resized(resx, resy, fullscreen != 0, gw, gh, scaling + 1, scaler, fill_mode,
- fill_scaler ? Image_window::bilinear : Image_window::point);
- gclock->set_palette();
- @@ -411,6 +434,9 @@ void VideoOptions_gump::save_settings() {
- config->set("config/video/share_video_settings", share_settings ? "yes" : "no", false);
- setup_video(fullscreen != 0, SET_CONFIG, resx, resy, gw, gh, scaling + 1, scaler, fill_mode,
- fill_scaler ? Image_window::bilinear : Image_window::point);
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + config->set("config/video/highdpi", highdpi ? "yes" : "no", false);
- +#endif
- config->write_back();
- o_resolution = resolution;
- o_scaling = scaling;
- @@ -419,6 +445,9 @@ void VideoOptions_gump::save_settings() {
- o_fill_mode = fill_mode;
- o_fill_scaler = fill_scaler;
- o_share_settings = share_settings;
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + o_highdpi = highdpi;
- + #endif
- }
- }
- @@ -433,6 +462,9 @@ void VideoOptions_gump::paint() {
- font->paint_text(iwin->get_ib8(), "Full Screen:", x + colx[0], y + rowy[0] + 1);
- if (fullscreen) font->paint_text(iwin->get_ib8(), "Display Mode:", x + colx[0], y + rowy[1] + 1);
- else font->paint_text(iwin->get_ib8(), "Window Size:", x + colx[0], y + rowy[1] + 1);
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + font->paint_text(iwin->get_ib8(), "HighDpi:", x + colx[0], y + rowy[2] + 1);
- + #endif
- font->paint_text(iwin->get_ib8(), "Scaler:", x + colx[0], y + rowy[3] + 1);
- if (buttons[id_scaling]) font->paint_text(iwin->get_ib8(), "Scaling:", x + colx[0], y + rowy[4] + 1);
- font->paint_text(iwin->get_ib8(), "Game Area:", x + colx[0], y + rowy[6] + 1);
- diff --git a/gumps/VideoOptions_gump.h b/gumps/VideoOptions_gump.h
- index 87a19127..74004acc 100644
- --- a/gumps/VideoOptions_gump.h
- +++ b/gumps/VideoOptions_gump.h
- @@ -47,6 +47,10 @@ class VideoOptions_gump : public Modal_gump {
- uint32 o_game_resolution;
- int o_fill_scaler;
- Image_window::FillMode o_fill_mode;
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + bool highdpi;
- + bool o_highdpi;
- +#endif
- static uint32 *resolutions;
- static int num_resolutions;
- @@ -64,6 +68,9 @@ class VideoOptions_gump : public Modal_gump {
- id_apply = id_first,
- id_fullscreen,
- id_share_settings,
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + id_high_dpi,
- +#endif
- id_resolution, // id_resolution and all past it
- id_scaler, // are deleted by rebuild_buttons
- id_scaling,
- diff --git a/imagewin/imagewin.cc b/imagewin/imagewin.cc
- index 0f6779fc..8759cf99 100644
- --- a/imagewin/imagewin.cc
- +++ b/imagewin/imagewin.cc
- @@ -102,6 +102,9 @@ int Image_window::desktop_depth = 0;
- int Image_window::windowed_8 = 0;
- int Image_window::windowed_16 = 0;
- int Image_window::windowed_32 = 0;
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- +float Image_window::nativescale = 1.0;
- +#endif
- const int Image_window::guard_band = 4;
- @@ -691,6 +694,11 @@ bool Image_window::create_scale_surfaces(int w, int h, int bpp) {
- h=dh;
- Resolution res = { w, h, false, false, false};
- p_resolutions[(w << 16) | h] = res;
- + //getting new native scale when highdpi is active
- + int sw;
- + SDL_GetWindowSize(screen_window, &sw, 0);
- + nativescale = dw / sw;
- +
- //high resolution fullscreen needs this to make the whole screen available
- SDL_RenderSetLogicalSize(screen_renderer, w, h);
- } else
- diff --git a/imagewin/imagewin.h b/imagewin/imagewin.h
- index 8e018612..a422637a 100644
- --- a/imagewin/imagewin.h
- +++ b/imagewin/imagewin.h
- @@ -293,6 +293,9 @@ class Image_window {
- static int windowed_8;
- static int windowed_16;
- static int windowed_32;
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + static float nativescale;
- +#endif
- public:
- #if SDL_VERSION_ATLEAST(2, 0, 0)
- @@ -334,6 +337,19 @@ class Image_window {
- gy = (sy * inter_height) / (scale * get_display_height()) + get_start_y();
- }
- }
- +
- +#if SDL_VERSION_ATLEAST(2, 0, 0) && defined(MACOSX)
- + void screen_to_game_hdpi(int sx, int sy, bool fast, int &gx, int &gy) {
- + if (fast) {
- + gx = (sx + get_start_x())* nativescale;
- + gy = (sy + get_start_y())* nativescale;
- + } else {
- + gx = ((sx * inter_width) / (scale * get_display_width()) + get_start_x()) * nativescale;
- + gy = ((sy * inter_height) / (scale * get_display_height()) + get_start_y()) * nativescale;
- + }
- + }
- + #endif
- +
- void game_to_screen(int gx, int gy, bool fast, int &sx, int &sy) {
- if (fast) {
- sx = gx - get_start_x();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement