mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Replaced SDL access with VCMI methods
This commit is contained in:
@@ -66,6 +66,14 @@ SDL_Color CSDL_Ext::toSDL(const ColorRGBA & color)
|
|||||||
return result;
|
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)
|
void CSDL_Ext::setColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors)
|
||||||
{
|
{
|
||||||
SDL_SetPaletteColors(surface->format->palette,colors,firstcolor,ncolors);
|
SDL_SetPaletteColors(surface->format->palette,colors,firstcolor,ncolors);
|
||||||
|
@@ -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
|
uint32_t colorTouint32_t(const SDL_Color * color); //little endian only
|
||||||
SDL_Color makeColor(ui8 r, ui8 g, ui8 b, ui8 a);
|
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 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 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);
|
void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const SDL_Color &color, int depth = 1);
|
||||||
|
@@ -28,12 +28,6 @@
|
|||||||
|
|
||||||
#include "../../lib/CGameState.h"
|
#include "../../lib/CGameState.h"
|
||||||
|
|
||||||
#ifdef VCMI_MAC
|
|
||||||
#define SDL_SCANCODE_LCTRL SDL_SCANCODE_LGUI
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <SDL_keyboard.h>
|
|
||||||
|
|
||||||
void CGarrisonSlot::setHighlight(bool on)
|
void CGarrisonSlot::setHighlight(bool on)
|
||||||
{
|
{
|
||||||
if (on)
|
if (on)
|
||||||
@@ -439,10 +433,9 @@ void CGarrisonSlot::splitIntoParts(CGarrisonSlot::EGarrisonType type, int amount
|
|||||||
|
|
||||||
bool CGarrisonSlot::handleSplittingShortcuts()
|
bool CGarrisonSlot::handleSplittingShortcuts()
|
||||||
{
|
{
|
||||||
const uint8_t * state = SDL_GetKeyboardState(NULL);
|
const bool isAlt = GH.isKeyboardAltDown();
|
||||||
const bool isAlt = !!state[SDL_SCANCODE_LALT];
|
const bool isLShift = GH.isKeyboardShiftDown();
|
||||||
const bool isLShift = !!state[SDL_SCANCODE_LSHIFT];
|
const bool isLCtrl = GH.isKeyboardCtrlDown();
|
||||||
const bool isLCtrl = !!state[SDL_SCANCODE_LCTRL];
|
|
||||||
|
|
||||||
if(!isAlt && !isLShift && !isLCtrl)
|
if(!isAlt && !isLShift && !isLCtrl)
|
||||||
return false; // This is only case when return false
|
return false; // This is only case when return false
|
||||||
|
@@ -63,8 +63,6 @@
|
|||||||
#include "../lib/NetPacksBase.h"
|
#include "../lib/NetPacksBase.h"
|
||||||
#include "../lib/StartInfo.h"
|
#include "../lib/StartInfo.h"
|
||||||
|
|
||||||
#include <SDL_video.h>
|
|
||||||
|
|
||||||
using namespace CSDL_Ext;
|
using namespace CSDL_Ext;
|
||||||
|
|
||||||
CRecruitmentWindow::CCreatureCard::CCreatureCard(CRecruitmentWindow * window, const CCreature * crea, int totalAmount)
|
CRecruitmentWindow::CCreatureCard::CCreatureCard(CRecruitmentWindow * window, const CCreature * crea, int totalAmount)
|
||||||
@@ -561,8 +559,7 @@ void CSystemOptionsWindow::selectGameRes()
|
|||||||
std::vector<std::string> items;
|
std::vector<std::string> items;
|
||||||
|
|
||||||
#ifndef VCMI_IOS
|
#ifndef VCMI_IOS
|
||||||
SDL_Rect displayBounds;
|
Rect displayBounds = CSDL_Ext::getDisplayBounds();
|
||||||
SDL_GetDisplayBounds(std::max(0, SDL_GetWindowDisplayIndex(mainWindow)), &displayBounds);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t currentResolutionIndex = 0;
|
size_t currentResolutionIndex = 0;
|
||||||
|
Reference in New Issue
Block a user