1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

SDL1 wipe, part 4. Codebase cleanup finished. Untested.

This commit is contained in:
AlexVinS 2015-06-21 01:38:05 +03:00
parent 8c236e30bb
commit ed281a3cc6
7 changed files with 18 additions and 23 deletions

View File

@ -387,7 +387,7 @@ inline void SDLImageLoader::EndLine()
SDLImageLoader::~SDLImageLoader()
{
SDL_UnlockSurface(image->surf);
SDL_SetColorKey(image->surf, SDL_SRCCOLORKEY, 0);
SDL_SetColorKey(image->surf, SDL_TRUE, 0);
//TODO: RLE if compressed and bpp>1
}

View File

@ -193,7 +193,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
//translate numpad keys
if(key.keysym.sym == SDLK_KP_ENTER)
{
key.keysym.sym = (SDLKey)SDLK_RETURN;
key.keysym.sym = SDLK_RETURN;
key.keysym.scancode = SDL_SCANCODE_RETURN;
}
@ -445,7 +445,7 @@ void CGuiHandler::drawFPSCounter()
graphics->fonts[FONT_BIG]->renderTextLeft(screen, fps, yellow, Point(10, 10));
}
SDLKey CGuiHandler::arrowToNum( SDLKey key )
SDL_Keycode CGuiHandler::arrowToNum(SDL_Keycode key )
{
switch(key)
{
@ -462,7 +462,7 @@ SDLKey CGuiHandler::arrowToNum( SDLKey key )
}
}
SDLKey CGuiHandler::numToDigit( SDLKey key )
SDL_Keycode CGuiHandler::numToDigit(SDL_Keycode key)
{
#define REMOVE_KP(keyName) case SDLK_KP_ ## keyName : return SDLK_ ## keyName;
@ -495,7 +495,7 @@ SDLKey CGuiHandler::numToDigit( SDLKey key )
#undef REMOVE_KP
}
bool CGuiHandler::isNumKey( SDLKey key, bool number )
bool CGuiHandler::isNumKey(SDL_Keycode key, bool number)
{
if(number)
return key >= SDLK_KP_1 && key <= SDLK_KP_0;
@ -503,7 +503,7 @@ bool CGuiHandler::isNumKey( SDLKey key, bool number )
return (key >= SDLK_KP_1 && key <= SDLK_KP_0) || key == SDLK_KP_MINUS || key == SDLK_KP_PLUS || key == SDLK_KP_EQUALS;
}
bool CGuiHandler::isArrowKey( SDLKey key )
bool CGuiHandler::isArrowKey(SDL_Keycode key)
{
return key == SDLK_UP || key == SDLK_DOWN || key == SDLK_LEFT || key == SDLK_RIGHT;
}

View File

@ -103,10 +103,10 @@ public:
ui8 captureChildren; //all newly created objects will get their parents from stack and will be added to parents children list
std::list<CIntObject *> createdObj; //stack of objs being created
static SDLKey arrowToNum(SDLKey key); //converts arrow key to according numpad key
static SDLKey numToDigit(SDLKey key);//converts numpad digit key to normal digit key
static bool isNumKey(SDLKey key, bool number = true); //checks if key is on numpad (numbers - check only for numpad digits)
static bool isArrowKey(SDLKey key);
static SDL_Keycode arrowToNum(SDL_Keycode key); //converts arrow key to according numpad key
static SDL_Keycode numToDigit(SDL_Keycode key);//converts numpad digit key to normal digit key
static bool isNumKey(SDL_Keycode key, bool number = true); //checks if key is on numpad (numbers - check only for numpad digits)
static bool isArrowKey(SDL_Keycode key);
static bool amIGuiThread();
static void pushSDLEvent(int type, int usercode = 0);
};

View File

@ -18,11 +18,6 @@
typedef int SDLX_Coord;
typedef int SDLX_Size;
typedef SDL_Keycode SDLKey;
#define SDL_SRCCOLORKEY SDL_TRUE
#define SDL_FULLSCREEN SDL_WINDOW_FULLSCREEN
#else
#error "unknown or unsupported SDL version"

View File

@ -169,7 +169,7 @@ void CSDL_Ext::alphaTransform(SDL_Surface *src)
SDL_Color & palColor = src->format->palette->colors[i];
palColor = colors[i];
}
SDL_SetColorKey(src, SDL_SRCCOLORKEY, 0);
SDL_SetColorKey(src, SDL_TRUE, 0);
}
static void prepareOutRect(SDL_Rect *src, SDL_Rect *dst, const SDL_Rect & clip_rect)
@ -988,7 +988,7 @@ STRONG_INLINE static uint32_t mapColor(SDL_Surface * surface, SDL_Color color)
void CSDL_Ext::setColorKey(SDL_Surface * surface, SDL_Color color)
{
uint32_t key = mapColor(surface,color);
SDL_SetColorKey(surface, SDL_SRCCOLORKEY, key);
SDL_SetColorKey(surface, SDL_TRUE, key);
}
void CSDL_Ext::setDefaultColorKey(SDL_Surface * surface)
@ -1003,7 +1003,7 @@ void CSDL_Ext::setDefaultColorKeyPresize(SDL_Surface * surface)
// set color key only if exactly such color was found
if (color.r == Colors::DEFAULT_KEY_COLOR.r && color.g == Colors::DEFAULT_KEY_COLOR.g && color.b == Colors::DEFAULT_KEY_COLOR.b)
SDL_SetColorKey(surface, SDL_SRCCOLORKEY, key);
SDL_SetColorKey(surface, SDL_TRUE, key);
}

View File

@ -1029,7 +1029,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
return;
ui8 Dir = 0;
int k = key.keysym.sym;
SDL_Keycode k = key.keysym.sym;
const CGHeroInstance *h = curHero(); //selected hero
const CGTownInstance *t = curTown(); //selected town
@ -1156,8 +1156,8 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
int3(-1, -1, 0), int3(0, -1, 0), int3(+1, -1, 0) };
//numpad arrow
if(CGuiHandler::isArrowKey(SDLKey(k)))
k = CGuiHandler::arrowToNum(SDLKey(k));
if(CGuiHandler::isArrowKey(k))
k = CGuiHandler::arrowToNum(k);
k -= SDLK_KP_1;

View File

@ -571,7 +571,7 @@ void CSpellWindow::keyPressed(const SDL_KeyboardEvent & key)
//alt + 1234567890-= casts spell from 1 - 12 slot
if(LOCPLINT->altPressed())
{
SDLKey hlpKey = key.keysym.sym;
SDL_Keycode hlpKey = key.keysym.sym;
if(CGuiHandler::isNumKey(hlpKey, false))
{
if(hlpKey == SDLK_KP_PLUS)
@ -580,7 +580,7 @@ void CSpellWindow::keyPressed(const SDL_KeyboardEvent & key)
hlpKey = CGuiHandler::numToDigit(hlpKey);
}
static const SDLKey spellSelectors[] = {SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_0, SDLK_MINUS, SDLK_EQUALS};
static const SDL_Keycode spellSelectors[] = {SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_0, SDLK_MINUS, SDLK_EQUALS};
int index = -1;
while(++index < ARRAY_COUNT(spellSelectors) && spellSelectors[index] != hlpKey);