فهرست منبع

Replaced SDL access with VCMI methods

Ivan Savenko 2 سال پیش
والد
کامیت
d87fb43dcd
4فایلهای تغییر یافته به همراه15 افزوده شده و 14 حذف شده
  1. 8 0
      client/renderSDL/SDL_Extensions.cpp
  2. 3 0
      client/renderSDL/SDL_Extensions.h
  3. 3 10
      client/widgets/CGarrisonInt.cpp
  4. 1 4
      client/windows/GUIClasses.cpp

+ 8 - 0
client/renderSDL/SDL_Extensions.cpp

@@ -66,6 +66,14 @@ SDL_Color CSDL_Ext::toSDL(const ColorRGBA & color)
 	return result;
 }
 
+Rect CSDL_Ext::getDisplayBounds()
+{
+	SDL_Rect displayBounds;
+	SDL_GetDisplayBounds(std::max(0, SDL_GetWindowDisplayIndex(mainWindow)), &displayBounds);
+
+	return fromSDL(displayBounds);
+}
+
 void CSDL_Ext::setColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors)
 {
 	SDL_SetPaletteColors(surface->format->palette,colors,firstcolor,ncolors);

+ 3 - 0
client/renderSDL/SDL_Extensions.h

@@ -108,6 +108,9 @@ typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_
 	uint32_t colorTouint32_t(const SDL_Color * color); //little endian only
 	SDL_Color makeColor(ui8 r, ui8 g, ui8 b, ui8 a);
 
+	/// returns dimensions of display on which VCMI window is located
+	Rect getDisplayBounds();
+
 	void update(SDL_Surface * what = screen); //updates whole surface (default - main screen)
 	void drawLine(SDL_Surface * sur, int x1, int y1, int x2, int y2, const SDL_Color & color1, const SDL_Color & color2);
 	void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const SDL_Color &color, int depth = 1);

+ 3 - 10
client/widgets/CGarrisonInt.cpp

@@ -28,12 +28,6 @@
 
 #include "../../lib/CGameState.h"
 
-#ifdef VCMI_MAC
-#define SDL_SCANCODE_LCTRL SDL_SCANCODE_LGUI
-#endif
-
-#include <SDL_keyboard.h>
-
 void CGarrisonSlot::setHighlight(bool on)
 {
 	if (on)
@@ -439,10 +433,9 @@ void CGarrisonSlot::splitIntoParts(CGarrisonSlot::EGarrisonType type, int amount
 
 bool CGarrisonSlot::handleSplittingShortcuts()
 {
-	const uint8_t * state = SDL_GetKeyboardState(NULL);
-	const bool isAlt = !!state[SDL_SCANCODE_LALT];
-	const bool isLShift = !!state[SDL_SCANCODE_LSHIFT];
-	const bool isLCtrl = !!state[SDL_SCANCODE_LCTRL];
+	const bool isAlt = GH.isKeyboardAltDown();
+	const bool isLShift = GH.isKeyboardShiftDown();
+	const bool isLCtrl = GH.isKeyboardCtrlDown();
 
 	if(!isAlt && !isLShift && !isLCtrl)
 		return false; // This is only case when return false

+ 1 - 4
client/windows/GUIClasses.cpp

@@ -63,8 +63,6 @@
 #include "../lib/NetPacksBase.h"
 #include "../lib/StartInfo.h"
 
-#include <SDL_video.h>
-
 using namespace CSDL_Ext;
 
 CRecruitmentWindow::CCreatureCard::CCreatureCard(CRecruitmentWindow * window, const CCreature * crea, int totalAmount)
@@ -561,8 +559,7 @@ void CSystemOptionsWindow::selectGameRes()
 	std::vector<std::string> items;
 
 #ifndef VCMI_IOS
-	SDL_Rect displayBounds;
-	SDL_GetDisplayBounds(std::max(0, SDL_GetWindowDisplayIndex(mainWindow)), &displayBounds);
+	Rect displayBounds = CSDL_Ext::getDisplayBounds();
 #endif
 
 	size_t currentResolutionIndex = 0;