From 2c51c98625b225cecfb9628c30d62d4e30f7e3e1 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 25 Jan 2024 15:41:57 +0100 Subject: Ported to SDL2 --- src/gui/setup_video.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'src/gui/setup_video.cpp') diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index c4fe60a1..c9d1dbc9 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -26,7 +26,6 @@ #include "game.h" #include "graphics.h" #include "localplayer.h" -#include "log.h" #include "main.h" #include "particle.h" @@ -91,26 +90,21 @@ class ModeListModel : public gcn::ListModel ModeListModel::ModeListModel() { /* Get available fullscreen/hardware modes */ - SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); - - /* Check which modes are available */ - if (modes == (SDL_Rect **)0) - logger->log("No modes available"); - else if (modes == (SDL_Rect **)-1) - logger->log("All resolutions available"); - else + const int numModes = SDL_GetNumDisplayModes(0); + for (int i = 0; i < numModes; i++) { - for (int i = 0; modes[i]; ++i) - { - const int width = modes[i]->w; - const int height = modes[i]->h; + SDL_DisplayMode mode; + if (SDL_GetDisplayMode(0, i, &mode) != 0) + continue; - // Skip the unreasonably small modes - if (width < 640 || height < 480) - continue; + // Skip the unreasonably small modes + if (mode.w < 640 || mode.h < 480) + continue; - mVideoModes.push_back(toString(width) + "x" + toString(height)); - } + // TODO_SDL2: Modes now dinstinguish between pixel format and refresh rate as well + // TODO_SDL2: Fullscreen mode needs display selection + + mVideoModes.push_back(toString(mode.w) + "x" + toString(mode.h)); } } @@ -326,9 +320,7 @@ void Setup_Video::apply() { if (!graphics->changeVideoMode(screenWidth, screenHeight, - graphics->getBpp(), - fullscreen, - graphics->getHWAccel())) + fullscreen)) { std::stringstream errorMessage; if (fullscreen) -- cgit v1.2.3-70-g09d2 From 5307b022f652ad34a8b2ef35d674817b7da33759 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 25 Jan 2024 15:44:38 +0100 Subject: Minor includes cleanup --- src/client.cpp | 5 ----- src/game.cpp | 2 -- src/gui/setup_video.cpp | 3 --- src/gui/socialwindow.cpp | 3 --- src/gui/widgets/textfield.cpp | 1 - src/sound.cpp | 1 - 6 files changed, 15 deletions(-) (limited to 'src/gui/setup_video.cpp') diff --git a/src/client.cpp b/src/client.cpp index 4030b042..ffea7a8a 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -34,7 +34,6 @@ #endif #include "playerrelations.h" #include "sound.h" -#include "statuseffect.h" #include "units.h" #include "gui/changeemaildialog.h" @@ -66,12 +65,8 @@ #include "resources/chardb.h" #include "resources/hairdb.h" -#include "resources/emotedb.h" #include "resources/image.h" #include "resources/itemdb.h" -#include "resources/monsterdb.h" -#include "resources/specialdb.h" -#include "resources/npcdb.h" #include "resources/resourcemanager.h" #include "resources/theme.h" #include "resources/userpalette.h" diff --git a/src/game.cpp b/src/game.cpp index f71d8575..c934ed69 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -42,7 +42,6 @@ #include "sound.h" #include "gui/chatwindow.h" -#include "gui/confirmdialog.h" #include "gui/debugwindow.h" #include "gui/equipmentwindow.h" #include "gui/gui.h" @@ -70,7 +69,6 @@ #include "gui/widgets/itemshortcutcontainer.h" #include "net/gamehandler.h" -#include "net/generalhandler.h" #include "net/net.h" #include "net/playerhandler.h" diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index c9d1dbc9..709a7685 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -26,7 +26,6 @@ #include "game.h" #include "graphics.h" #include "localplayer.h" -#include "main.h" #include "particle.h" #include "gui/okdialog.h" @@ -38,8 +37,6 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/slider.h" #include "gui/widgets/spacer.h" -#include "gui/widgets/textfield.h" -#include "gui/widgets/dropdown.h" #include "utils/gettext.h" #include "utils/stringutils.h" diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 1b960d64..7e074470 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -33,8 +33,6 @@ #include "gui/widgets/avatarlistbox.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" -#include "gui/widgets/container.h" -#include "gui/widgets/label.h" #include "gui/widgets/linkhandler.h" #include "gui/widgets/popup.h" #include "gui/widgets/scrollarea.h" @@ -47,7 +45,6 @@ #include "resources/theme.h" -#include "utils/dtor.h" #include "utils/gettext.h" #include "utils/stringutils.h" diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index c4c00ae4..35ce09c5 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -24,7 +24,6 @@ #include "configuration.h" #include "graphics.h" -#include "gui/palette.h" #include "gui/sdlinput.h" #include "resources/image.h" diff --git a/src/sound.cpp b/src/sound.cpp index 2fc4f87f..44f55cba 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -22,7 +22,6 @@ #include #include "configuration.h" -#include "game.h" #include "localplayer.h" #include "log.h" #include "sound.h" -- cgit v1.2.3-70-g09d2