mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
fix compilation
* may not even run * text input disabled
This commit is contained in:
parent
796905ec42
commit
62d42465de
@ -177,7 +177,7 @@ CHeroList::CEmptyHeroItem::CEmptyHeroItem()
|
|||||||
auto mana = new CAnimImage("IMANA", 0, 0, move->pos.w + img->pos.w + 2, 1 );
|
auto mana = new CAnimImage("IMANA", 0, 0, move->pos.w + img->pos.w + 2, 1 );
|
||||||
|
|
||||||
pos.w = mana->pos.w + mana->pos.x - pos.x;
|
pos.w = mana->pos.w + mana->pos.x - pos.x;
|
||||||
pos.h = std::max(std::max<ui16>(move->pos.h + 1, mana->pos.h + 1), img->pos.h);
|
pos.h = std::max(std::max<SDLX_Size>(move->pos.h + 1, mana->pos.h + 1), img->pos.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHeroList::CHeroItem::CHeroItem(CHeroList *parent, const CGHeroInstance * Hero):
|
CHeroList::CHeroItem::CHeroItem(CHeroList *parent, const CGHeroInstance * Hero):
|
||||||
@ -190,7 +190,7 @@ CHeroList::CHeroItem::CHeroItem(CHeroList *parent, const CGHeroInstance * Hero):
|
|||||||
mana = new CAnimImage("IMANA", 0, 0, movement->pos.w + portrait->pos.w + 2, 1 );
|
mana = new CAnimImage("IMANA", 0, 0, movement->pos.w + portrait->pos.w + 2, 1 );
|
||||||
|
|
||||||
pos.w = mana->pos.w + mana->pos.x - pos.x;
|
pos.w = mana->pos.w + mana->pos.x - pos.x;
|
||||||
pos.h = std::max(std::max<ui16>(movement->pos.h + 1, mana->pos.h + 1), portrait->pos.h);
|
pos.h = std::max(std::max<SDLX_Size>(movement->pos.h + 1, mana->pos.h + 1), portrait->pos.h);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,12 @@ void CResDataBar::clickRight(tribool down, bool previousState)
|
|||||||
CResDataBar::CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist)
|
CResDataBar::CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist)
|
||||||
{
|
{
|
||||||
bg = BitmapHandler::loadBitmap(defname);
|
bg = BitmapHandler::loadBitmap(defname);
|
||||||
|
#if 0
|
||||||
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
||||||
|
#else
|
||||||
|
SDL_SetColorKey(bg,SDL_TRUE,SDL_MapRGB(bg->format,0,255,255));
|
||||||
|
#endif
|
||||||
|
|
||||||
graphics->blueToPlayersAdv(bg,LOCPLINT->playerID);
|
graphics->blueToPlayersAdv(bg,LOCPLINT->playerID);
|
||||||
pos = genRect(bg->h, bg->w, pos.x+x, pos.y+y);
|
pos = genRect(bg->h, bg->w, pos.x+x, pos.y+y);
|
||||||
|
|
||||||
@ -313,7 +318,11 @@ CResDataBar::CResDataBar(const std::string &defname, int x, int y, int offx, int
|
|||||||
CResDataBar::CResDataBar()
|
CResDataBar::CResDataBar()
|
||||||
{
|
{
|
||||||
bg = BitmapHandler::loadBitmap(ADVOPT.resdatabarG);
|
bg = BitmapHandler::loadBitmap(ADVOPT.resdatabarG);
|
||||||
|
#if 0
|
||||||
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
||||||
|
#else
|
||||||
|
SDL_SetColorKey(bg,SDL_TRUE,SDL_MapRGB(bg->format,0,255,255));
|
||||||
|
#endif
|
||||||
graphics->blueToPlayersAdv(bg,LOCPLINT->playerID);
|
graphics->blueToPlayersAdv(bg,LOCPLINT->playerID);
|
||||||
pos = genRect(bg->h,bg->w,ADVOPT.resdatabarX,ADVOPT.resdatabarY);
|
pos = genRect(bg->h,bg->w,ADVOPT.resdatabarX,ADVOPT.resdatabarY);
|
||||||
|
|
||||||
@ -922,7 +931,11 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|||||||
if(CGuiHandler::isArrowKey(SDLKey(k)))
|
if(CGuiHandler::isArrowKey(SDLKey(k)))
|
||||||
k = CGuiHandler::arrowToNum(SDLKey(k));
|
k = CGuiHandler::arrowToNum(SDLKey(k));
|
||||||
|
|
||||||
|
#if 0
|
||||||
k -= SDLK_KP0 + 1;
|
k -= SDLK_KP0 + 1;
|
||||||
|
#else
|
||||||
|
k -= SDL_SCANCODE_KP_0 + 1;
|
||||||
|
#endif // 0
|
||||||
if(k < 0 || k > 8)
|
if(k < 0 || k > 8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -157,7 +157,11 @@ CDefFile::CDefFile(std::string Name):
|
|||||||
palette[i].r = data[it++];
|
palette[i].r = data[it++];
|
||||||
palette[i].g = data[it++];
|
palette[i].g = data[it++];
|
||||||
palette[i].b = data[it++];
|
palette[i].b = data[it++];
|
||||||
|
#if 0
|
||||||
palette[i].unused = 255;
|
palette[i].unused = 255;
|
||||||
|
#else
|
||||||
|
palette[i].a = 255;
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
if (type == 71 || type == 64)//Buttons/buildings don't have shadows\semi-transparency
|
if (type == 71 || type == 64)//Buttons/buildings don't have shadows\semi-transparency
|
||||||
memset(palette, 0, sizeof(SDL_Color)*2);
|
memset(palette, 0, sizeof(SDL_Color)*2);
|
||||||
@ -356,7 +360,6 @@ void SDLImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_C
|
|||||||
//Prepare surface
|
//Prepare surface
|
||||||
SDL_SetColors(image->surf, pal, 0, 256);
|
SDL_SetColors(image->surf, pal, 0, 256);
|
||||||
SDL_LockSurface(image->surf);
|
SDL_LockSurface(image->surf);
|
||||||
|
|
||||||
lineStart = position = (ui8*)image->surf->pixels;
|
lineStart = position = (ui8*)image->surf->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +390,11 @@ inline void SDLImageLoader::EndLine()
|
|||||||
SDLImageLoader::~SDLImageLoader()
|
SDLImageLoader::~SDLImageLoader()
|
||||||
{
|
{
|
||||||
SDL_UnlockSurface(image->surf);
|
SDL_UnlockSurface(image->surf);
|
||||||
|
#if 0
|
||||||
SDL_SetColorKey(image->surf, SDL_SRCCOLORKEY, 0);
|
SDL_SetColorKey(image->surf, SDL_SRCCOLORKEY, 0);
|
||||||
|
#else
|
||||||
|
SDL_SetColorKey(image->surf, SDL_TRUE, 0);
|
||||||
|
#endif // 0
|
||||||
//TODO: RLE if compressed and bpp>1
|
//TODO: RLE if compressed and bpp>1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,8 +451,14 @@ inline ui8 CompImageLoader::typeOf(ui8 color)
|
|||||||
{
|
{
|
||||||
if (color == 0)
|
if (color == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
#if 0
|
||||||
if (image->palette[color].unused != 255)
|
if (image->palette[color].unused != 255)
|
||||||
return 1;
|
return 1;
|
||||||
|
#else
|
||||||
|
if (image->palette[color].a != 255)
|
||||||
|
return 1;
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,13 +810,21 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha)
|
|||||||
for (size_t i=0; i<size; i++)
|
for (size_t i=0; i<size; i++)
|
||||||
{
|
{
|
||||||
SDL_Color col = palette[*(data++)];
|
SDL_Color col = palette[*(data++)];
|
||||||
|
#if 0
|
||||||
col.unused = (ui32)col.unused*alpha/255;
|
col.unused = (ui32)col.unused*alpha/255;
|
||||||
|
#else
|
||||||
|
col.a = (ui32)col.a*alpha/255;
|
||||||
|
#endif // 0
|
||||||
ColorPutter<bpp, 1>::PutColorAlpha(dest, col);
|
ColorPutter<bpp, 1>::PutColorAlpha(dest, col);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (palette[color].unused == 255)
|
if (palette[color].unused == 255)
|
||||||
|
#else
|
||||||
|
if (palette[color].a == 255)
|
||||||
|
#endif // 0
|
||||||
{
|
{
|
||||||
//Put row of RGB data
|
//Put row of RGB data
|
||||||
for (size_t i=0; i<size; i++)
|
for (size_t i=0; i<size; i++)
|
||||||
@ -820,6 +841,7 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha)
|
|||||||
//RLE-d sequence
|
//RLE-d sequence
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (alpha != 255 && palette[type].unused !=0)//Per-surface alpha is set
|
if (alpha != 255 && palette[type].unused !=0)//Per-surface alpha is set
|
||||||
{
|
{
|
||||||
SDL_Color col = palette[type];
|
SDL_Color col = palette[type];
|
||||||
@ -830,6 +852,19 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (palette[type].unused)
|
switch (palette[type].unused)
|
||||||
|
|
||||||
|
#else
|
||||||
|
if (alpha != 255 && palette[type].a !=0)//Per-surface alpha is set
|
||||||
|
{
|
||||||
|
SDL_Color col = palette[type];
|
||||||
|
col.a = (int)col.a*(255-alpha)/255;
|
||||||
|
for (size_t i=0; i<size; i++)
|
||||||
|
ColorPutter<bpp, 1>::PutColorAlpha(dest, col);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (palette[type].a)
|
||||||
|
#endif // 0
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
@ -873,7 +908,11 @@ void CompImage::playerColored(PlayerColor player)
|
|||||||
palette[224+i].r = pal[i].r;
|
palette[224+i].r = pal[i].r;
|
||||||
palette[224+i].g = pal[i].g;
|
palette[224+i].g = pal[i].g;
|
||||||
palette[224+i].b = pal[i].b;
|
palette[224+i].b = pal[i].b;
|
||||||
|
#if 0
|
||||||
palette[224+i].unused = pal[i].unused;
|
palette[224+i].unused = pal[i].unused;
|
||||||
|
#else
|
||||||
|
palette[224+i].a = pal[i].a;
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,11 @@ SDL_Surface * BitmapHandler::loadH3PCX(ui8 * pcx, size_t size)
|
|||||||
tp.r = pcx[it++];
|
tp.r = pcx[it++];
|
||||||
tp.g = pcx[it++];
|
tp.g = pcx[it++];
|
||||||
tp.b = pcx[it++];
|
tp.b = pcx[it++];
|
||||||
|
#if 0
|
||||||
tp.unused = SDL_ALPHA_OPAQUE;
|
tp.unused = SDL_ALPHA_OPAQUE;
|
||||||
|
#else
|
||||||
|
tp.a = SDL_ALPHA_OPAQUE;
|
||||||
|
#endif // 0
|
||||||
ret->format->palette->colors[i] = tp;
|
ret->format->palette->colors[i] = tp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,7 +126,11 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
|
|||||||
if(ret->format->BytesPerPixel == 1 && setKey)
|
if(ret->format->BytesPerPixel == 1 && setKey)
|
||||||
{
|
{
|
||||||
const SDL_Color &c = ret->format->palette->colors[0];
|
const SDL_Color &c = ret->format->palette->colors[0];
|
||||||
|
#if 0
|
||||||
SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format, c.r, c.g, c.b));
|
SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format, c.r, c.g, c.b));
|
||||||
|
#else
|
||||||
|
SDL_SetColorKey(ret,SDL_TRUE,SDL_MapRGB(ret->format, c.r, c.g, c.b));
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -143,7 +151,11 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
|
|||||||
{
|
{
|
||||||
//set correct value for alpha\unused channel
|
//set correct value for alpha\unused channel
|
||||||
for (int i=0; i< ret->format->palette->ncolors; i++)
|
for (int i=0; i< ret->format->palette->ncolors; i++)
|
||||||
|
#if 0
|
||||||
ret->format->palette->colors[i].unused = 255;
|
ret->format->palette->colors[i].unused = 255;
|
||||||
|
#else
|
||||||
|
ret->format->palette->colors[i].a = 255;
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -166,11 +178,19 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
|
|||||||
|
|
||||||
// set color key only if exactly such color was found
|
// set color key only if exactly such color was found
|
||||||
if (color.r == 0 && color.g == 255 && color.b == 255)
|
if (color.r == 0 && color.g == 255 && color.b == 255)
|
||||||
|
#if 0
|
||||||
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, colorID);
|
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, colorID);
|
||||||
|
#else
|
||||||
|
SDL_SetColorKey(ret, SDL_TRUE, colorID);
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
else // always set
|
else // always set
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, colorID);
|
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, colorID);
|
||||||
|
#else
|
||||||
|
SDL_SetColorKey(ret, SDL_TRUE, colorID);
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,11 @@ void CDefHandler::openFromMemory(ui8 *table, const std::string & name)
|
|||||||
palette[it].r = de.palette[it].R;
|
palette[it].r = de.palette[it].R;
|
||||||
palette[it].g = de.palette[it].G;
|
palette[it].g = de.palette[it].G;
|
||||||
palette[it].b = de.palette[it].B;
|
palette[it].b = de.palette[it].B;
|
||||||
|
#if 0
|
||||||
palette[it].unused = 255;
|
palette[it].unused = 255;
|
||||||
|
#else
|
||||||
|
palette[it].a = 255;
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// The SDefEntryBlock starts just after the SDefEntry
|
// The SDefEntryBlock starts just after the SDefEntry
|
||||||
@ -179,7 +183,11 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const SDL_Co
|
|||||||
pr.r = palette[i].r;
|
pr.r = palette[i].r;
|
||||||
pr.g = palette[i].g;
|
pr.g = palette[i].g;
|
||||||
pr.b = palette[i].b;
|
pr.b = palette[i].b;
|
||||||
|
#if 0
|
||||||
pr.unused = palette[i].unused;
|
pr.unused = palette[i].unused;
|
||||||
|
#else
|
||||||
|
pr.a = palette[i].a;
|
||||||
|
#endif // 0
|
||||||
(*(ret->format->palette->colors+i))=pr;
|
(*(ret->format->palette->colors+i))=pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,8 +355,14 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const SDL_Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_Color ttcol = ret->format->palette->colors[0];
|
SDL_Color ttcol = ret->format->palette->colors[0];
|
||||||
|
#if 0
|
||||||
Uint32 keycol = SDL_MapRGBA(ret->format, ttcol.r, ttcol.b, ttcol.g, ttcol.unused);
|
Uint32 keycol = SDL_MapRGBA(ret->format, ttcol.r, ttcol.b, ttcol.g, ttcol.unused);
|
||||||
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, keycol);
|
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, keycol);
|
||||||
|
#else
|
||||||
|
Uint32 keycol = SDL_MapRGBA(ret->format, ttcol.r, ttcol.b, ttcol.g, ttcol.a);
|
||||||
|
SDL_SetColorKey(ret, SDL_TRUE, keycol);
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
181
client/CMT.cpp
181
client/CMT.cpp
@ -68,9 +68,16 @@ std::string NAME_AFFIX = "client";
|
|||||||
std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name
|
std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name
|
||||||
CGuiHandler GH;
|
CGuiHandler GH;
|
||||||
static CClient *client=nullptr;
|
static CClient *client=nullptr;
|
||||||
|
|
||||||
|
SDL_Window * mainWindow = nullptr;
|
||||||
|
SDL_Renderer * mainRenderer = nullptr;
|
||||||
|
|
||||||
SDL_Surface *screen = nullptr, //main screen surface
|
SDL_Surface *screen = nullptr, //main screen surface
|
||||||
*screen2 = nullptr,//and hlp surface (used to store not-active interfaces layer)
|
*screen2 = nullptr,//and hlp surface (used to store not-active interfaces layer)
|
||||||
*screenBuf = screen; //points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
|
*screenBuf = screen; //points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
|
||||||
|
|
||||||
|
SDL_Texture * screenTexture = nullptr;
|
||||||
|
|
||||||
static boost::thread *mainGUIThread;
|
static boost::thread *mainGUIThread;
|
||||||
|
|
||||||
std::queue<SDL_Event> events;
|
std::queue<SDL_Event> events;
|
||||||
@ -763,76 +770,153 @@ void dispose()
|
|||||||
CMessage::dispose();
|
CMessage::dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
//used only once during initialization
|
static bool checkVideoMode(int monitorIndex, int w, int h, int& bpp, bool fullscreen)
|
||||||
static void setScreenRes(int w, int h, int bpp, bool fullscreen, bool resetVideo)
|
{
|
||||||
|
SDL_DisplayMode mode;
|
||||||
|
const int modeCount = SDL_GetNumDisplayModes(monitorIndex);
|
||||||
|
for (int i = 0; i < modeCount; i++) {
|
||||||
|
SDL_GetDisplayMode(0, i, &mode);
|
||||||
|
if (!mode.w || !mode.h || (w >= mode.w && h >= mode.h)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// bpp = SDL_VideoModeOK(w, h, bpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0));
|
||||||
|
//return !(bpp==0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool recreateWindow(int w, int h, int bpp, bool fullscreen)
|
||||||
{
|
{
|
||||||
// VCMI will only work with 2, 3 or 4 bytes per pixel
|
// VCMI will only work with 2, 3 or 4 bytes per pixel
|
||||||
vstd::amax(bpp, 16);
|
vstd::amax(bpp, 16);
|
||||||
vstd::amin(bpp, 32);
|
vstd::amin(bpp, 32);
|
||||||
|
|
||||||
// Try to use the best screen depth for the display
|
int suggestedBpp = bpp;
|
||||||
int suggestedBpp = SDL_VideoModeOK(w, h, bpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0));
|
|
||||||
if(suggestedBpp == 0)
|
if(!checkVideoMode(0,w,h,suggestedBpp,fullscreen))
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: SDL says that " << w << "x" << h << " resolution is not available!";
|
logGlobal->errorStream() << "Error: SDL says that " << w << "x" << h << " resolution is not available!";
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nullptr != mainRenderer)
|
||||||
|
{
|
||||||
|
SDL_DestroyRenderer(mainRenderer);
|
||||||
|
mainRenderer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nullptr != mainWindow)
|
||||||
|
{
|
||||||
|
SDL_DestroyWindow(mainWindow);
|
||||||
|
mainWindow = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bufOnScreen = (screenBuf == screen);
|
bool bufOnScreen = (screenBuf == screen);
|
||||||
|
|
||||||
if(suggestedBpp != bpp)
|
mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED, w, h, (fullscreen?SDL_FULLSCREEN:0));
|
||||||
|
|
||||||
|
if(nullptr == mainWindow)
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << boost::format("Using %s bpp (bits per pixel) for the video mode. Default or overridden setting was %s bpp.") % suggestedBpp % bpp;
|
throw std::runtime_error("Unable to create window\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//For some reason changing fullscreen via config window checkbox result in SDL_Quit event
|
|
||||||
if (resetVideo)
|
//create first available renderer. Use no flags, so HW accelerated will be preferred but SW renderer also will possible
|
||||||
|
mainRenderer = SDL_CreateRenderer(mainWindow,-1,0);
|
||||||
|
|
||||||
|
if(nullptr == mainRenderer)
|
||||||
{
|
{
|
||||||
if(screen) //screen has been already initialized
|
throw std::runtime_error("Unable to create renderer\n");
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if((screen = SDL_SetVideoMode(w, h, suggestedBpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0))) == nullptr)
|
SDL_RenderSetLogicalSize(mainRenderer, w, h);
|
||||||
{
|
|
||||||
logGlobal->errorStream() << "Requested screen resolution is not available (" << w << "x" << h << "x" << suggestedBpp << "bpp)";
|
|
||||||
throw std::runtime_error("Requested screen resolution is not available\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
logGlobal->infoStream() << "New screen flags: " << screen->flags;
|
|
||||||
|
screenBuf = nullptr; //it`s a link - just nullify
|
||||||
|
|
||||||
if(screen2)
|
if(screen2)
|
||||||
SDL_FreeSurface(screen2);
|
SDL_FreeSurface(screen2);
|
||||||
screen2 = CSDL_Ext::copySurface(screen);
|
|
||||||
SDL_EnableUNICODE(1);
|
|
||||||
SDL_WM_SetCaption(NAME.c_str(),""); //set window title
|
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
|
||||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
//logGlobal->infoStream() << "New screen flags: " << screen->flags;
|
||||||
SDL_SysWMinfo wm;
|
SDL_FreeSurface(screen);
|
||||||
SDL_VERSION(&wm.version);
|
|
||||||
int getwm = SDL_GetWMInfo(&wm);
|
screen = SDL_CreateRGBSurface(0,w,h,bpp,0x00FF000,
|
||||||
if(getwm == 1)
|
0x0000FF00,
|
||||||
|
0x000000FF,
|
||||||
|
0xFF000000);
|
||||||
|
if(nullptr == screen)
|
||||||
{
|
{
|
||||||
int sw = GetSystemMetrics(SM_CXSCREEN),
|
throw std::runtime_error("Unable to create surface\n");
|
||||||
sh = GetSystemMetrics(SM_CYSCREEN);
|
|
||||||
RECT curpos;
|
|
||||||
GetWindowRect(wm.window,&curpos);
|
|
||||||
int ourw = curpos.right - curpos.left,
|
|
||||||
ourh = curpos.bottom - curpos.top;
|
|
||||||
SetWindowPos(wm.window, 0, (sw - ourw)/2, (sh - ourh)/2, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
screenTexture = SDL_CreateTexture(mainRenderer,
|
||||||
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
|
w, h);
|
||||||
|
|
||||||
|
if(nullptr == screenTexture)
|
||||||
{
|
{
|
||||||
logGlobal->warnStream() << "Something went wrong, getwm=" << getwm;
|
throw std::runtime_error("Unable to create screen texture\n");
|
||||||
logGlobal->warnStream() << "SDL says: " << SDL_GetError();
|
}
|
||||||
logGlobal->warnStream() << "Window won't be centered.";
|
|
||||||
|
screen2 = CSDL_Ext::copySurface(screen);
|
||||||
|
|
||||||
|
|
||||||
|
if(nullptr == screen2)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to copy surface\n");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
//TODO: centering game window on other platforms (or does the environment do their job correctly there?)
|
|
||||||
|
|
||||||
screenBuf = bufOnScreen ? screen : screen2;
|
screenBuf = bufOnScreen ? screen : screen2;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//used only once during initialization
|
||||||
|
static void setScreenRes(int w, int h, int bpp, bool fullscreen, bool resetVideo)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(!recreateWindow(w,h,bpp,fullscreen))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
SDL_EnableUNICODE(1);
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
//TODO: this shall be handled manually in SDL2
|
||||||
|
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||||
|
|
||||||
|
//#ifdef _WIN32
|
||||||
|
// SDL_SysWMinfo wm;
|
||||||
|
// SDL_VERSION(&wm.version);
|
||||||
|
// int getwm = SDL_GetWMInfo(&wm);
|
||||||
|
// if(getwm == 1)
|
||||||
|
// {
|
||||||
|
// int sw = GetSystemMetrics(SM_CXSCREEN),
|
||||||
|
// sh = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
// RECT curpos;
|
||||||
|
// GetWindowRect(wm.window,&curpos);
|
||||||
|
// int ourw = curpos.right - curpos.left,
|
||||||
|
// ourh = curpos.bottom - curpos.top;
|
||||||
|
// SetWindowPos(wm.window, 0, (sw - ourw)/2, (sh - ourh)/2, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// logGlobal->warnStream() << "Something went wrong, getwm=" << getwm;
|
||||||
|
// logGlobal->warnStream() << "SDL says: " << SDL_GetError();
|
||||||
|
// logGlobal->warnStream() << "Window won't be centered.";
|
||||||
|
// }
|
||||||
|
//#endif
|
||||||
|
//TODO: centering game window on other platforms (or does the environment do their job correctly there?)
|
||||||
|
|
||||||
|
|
||||||
//setResolution = true;
|
//setResolution = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,19 +927,16 @@ static void fullScreenChanged()
|
|||||||
Settings full = settings.write["video"]["fullscreen"];
|
Settings full = settings.write["video"]["fullscreen"];
|
||||||
const bool toFullscreen = full->Bool();
|
const bool toFullscreen = full->Bool();
|
||||||
|
|
||||||
int bitsPerPixel = screen->format->BitsPerPixel;
|
auto bitsPerPixel = screen->format->BitsPerPixel;
|
||||||
|
auto w = screen->w;
|
||||||
|
auto h = screen->h;
|
||||||
|
|
||||||
bitsPerPixel = SDL_VideoModeOK(screen->w, screen->h, bitsPerPixel, SDL_SWSURFACE|(toFullscreen?SDL_FULLSCREEN:0));
|
if(!recreateWindow(w,h,bitsPerPixel,(toFullscreen?SDL_FULLSCREEN:0)))
|
||||||
if(bitsPerPixel == 0)
|
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: SDL says that " << screen->w << "x" << screen->h << " resolution is not available!";
|
//will return false and report error if video mode is not supported
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bufOnScreen = (screenBuf == screen);
|
|
||||||
screen = SDL_SetVideoMode(screen->w, screen->h, bitsPerPixel, SDL_SWSURFACE|(toFullscreen?SDL_FULLSCREEN:0));
|
|
||||||
screenBuf = bufOnScreen ? screen : screen2;
|
|
||||||
|
|
||||||
GH.totalRedraw();
|
GH.totalRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL_render.h>
|
||||||
|
|
||||||
|
extern SDL_Window * mainWindow;
|
||||||
|
extern SDL_Renderer * mainRenderer;
|
||||||
|
|
||||||
extern SDL_Surface *screen; // main screen surface
|
extern SDL_Surface *screen; // main screen surface
|
||||||
extern SDL_Surface *screen2; // and hlp surface (used to store not-active interfaces layer)
|
extern SDL_Surface *screen2; // and hlp surface (used to store not-active interfaces layer)
|
||||||
extern SDL_Surface *screenBuf; // points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
|
extern SDL_Surface *screenBuf; // points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
|
||||||
|
|
||||||
|
extern SDL_Texture * screenTexture;
|
||||||
|
|
||||||
extern bool gNoGUI; //if true there is no client window and game is silently played between AIs
|
extern bool gNoGUI; //if true there is no client window and game is silently played between AIs
|
||||||
|
|
||||||
void handleQuit();
|
void handleQuit();
|
@ -481,6 +481,7 @@ void MusicEntry::load(std::string musicURI)
|
|||||||
|
|
||||||
data = CResourceHandler::get()->load(ResourceID(musicURI, EResType::MUSIC))->readAll();
|
data = CResourceHandler::get()->load(ResourceID(musicURI, EResType::MUSIC))->readAll();
|
||||||
musicFile = SDL_RWFromConstMem(data.first.get(), data.second);
|
musicFile = SDL_RWFromConstMem(data.first.get(), data.second);
|
||||||
|
#if 0
|
||||||
music = Mix_LoadMUS_RW(musicFile);
|
music = Mix_LoadMUS_RW(musicFile);
|
||||||
|
|
||||||
if(!music)
|
if(!music)
|
||||||
@ -491,6 +492,19 @@ void MusicEntry::load(std::string musicURI)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
music = Mix_LoadMUS_RW(musicFile, SDL_FALSE);
|
||||||
|
|
||||||
|
if(!music)
|
||||||
|
{
|
||||||
|
SDL_FreeRW(musicFile);
|
||||||
|
musicFile = nullptr;
|
||||||
|
logGlobal->warnStream() << "Warning: Cannot open " << currentName << ": " << Mix_GetError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//The assertion will fail if old MSVC libraries pack .dll is used
|
//The assertion will fail if old MSVC libraries pack .dll is used
|
||||||
assert(Mix_GetMusicType(music) != MUS_MP3);
|
assert(Mix_GetMusicType(music) != MUS_MP3);
|
||||||
|
@ -3990,6 +3990,7 @@ void CInGameConsole::keyPressed (const SDL_KeyboardEvent & key)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if(enteredText.size() > 0 && enteredText.size() < conf.go()->ac.inputLineLength)
|
if(enteredText.size() > 0 && enteredText.size() < conf.go()->ac.inputLineLength)
|
||||||
{
|
{
|
||||||
if( key.keysym.unicode < 0x80 && key.keysym.unicode > 0 )
|
if( key.keysym.unicode < 0x80 && key.keysym.unicode > 0 )
|
||||||
@ -3999,6 +4000,7 @@ void CInGameConsole::keyPressed (const SDL_KeyboardEvent & key)
|
|||||||
refreshEnteredText();
|
refreshEnteredText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // 0
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,11 @@ void Graphics::loadPaletteAndColors()
|
|||||||
col.r = pals[startPoint++];
|
col.r = pals[startPoint++];
|
||||||
col.g = pals[startPoint++];
|
col.g = pals[startPoint++];
|
||||||
col.b = pals[startPoint++];
|
col.b = pals[startPoint++];
|
||||||
|
#if 0
|
||||||
col.unused = 255;
|
col.unused = 255;
|
||||||
|
#else
|
||||||
|
col.a = 255;
|
||||||
|
#endif // 0
|
||||||
startPoint++;
|
startPoint++;
|
||||||
playerColorPalette[i] = col;
|
playerColorPalette[i] = col;
|
||||||
}
|
}
|
||||||
@ -77,12 +81,18 @@ void Graphics::loadPaletteAndColors()
|
|||||||
neutralColorPalette[i].r = reader.readUInt8();
|
neutralColorPalette[i].r = reader.readUInt8();
|
||||||
neutralColorPalette[i].g = reader.readUInt8();
|
neutralColorPalette[i].g = reader.readUInt8();
|
||||||
neutralColorPalette[i].b = reader.readUInt8();
|
neutralColorPalette[i].b = reader.readUInt8();
|
||||||
|
#if 0
|
||||||
neutralColorPalette[i].unused = reader.readUInt8();
|
neutralColorPalette[i].unused = reader.readUInt8();
|
||||||
neutralColorPalette[i].unused = !neutralColorPalette[i].unused;
|
neutralColorPalette[i].unused = !neutralColorPalette[i].unused;
|
||||||
|
#else
|
||||||
|
neutralColorPalette[i].a = reader.readUInt8();
|
||||||
|
neutralColorPalette[i].a = !neutralColorPalette[i].a;
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
//colors initialization
|
//colors initialization
|
||||||
int3 kolory[] = {int3(0xff,0,0),int3(0x31,0x52,0xff),int3(0x9c,0x73,0x52),int3(0x42,0x94,0x29),
|
int3 kolory[] = {int3(0xff,0,0),int3(0x31,0x52,0xff),int3(0x9c,0x73,0x52),int3(0x42,0x94,0x29),
|
||||||
int3(0xff,0x84,0x0),int3(0x8c,0x29,0xa5),int3(0x09,0x9c,0xa5),int3(0xc6,0x7b,0x8c)};
|
int3(0xff,0x84,0x0),int3(0x8c,0x29,0xa5),int3(0x09,0x9c,0xa5),int3(0xc6,0x7b,0x8c)};
|
||||||
|
#if 0
|
||||||
for(int i=0;i<8;i++)
|
for(int i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
playerColors[i].r = kolory[i].x;
|
playerColors[i].r = kolory[i].x;
|
||||||
@ -91,6 +101,16 @@ void Graphics::loadPaletteAndColors()
|
|||||||
playerColors[i].unused = 255;
|
playerColors[i].unused = 255;
|
||||||
}
|
}
|
||||||
neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84; neutralColor->unused = 255;//gray
|
neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84; neutralColor->unused = 255;//gray
|
||||||
|
#else
|
||||||
|
for(int i=0;i<8;i++)
|
||||||
|
{
|
||||||
|
playerColors[i].r = kolory[i].x;
|
||||||
|
playerColors[i].g = kolory[i].y;
|
||||||
|
playerColors[i].b = kolory[i].z;
|
||||||
|
playerColors[i].a = 255;
|
||||||
|
}
|
||||||
|
neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84; neutralColor->a = 255;//gray
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::initializeBattleGraphics()
|
void Graphics::initializeBattleGraphics()
|
||||||
|
@ -365,7 +365,11 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
|||||||
idToObstacle[ID] = CDefHandler::giveDef(elem->getInfo().defName);
|
idToObstacle[ID] = CDefHandler::giveDef(elem->getInfo().defName);
|
||||||
for(auto & _n : idToObstacle[ID]->ourImages)
|
for(auto & _n : idToObstacle[ID]->ourImages)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
SDL_SetColorKey(_n.bitmap, SDL_SRCCOLORKEY, SDL_MapRGB(_n.bitmap->format,0,255,255));
|
SDL_SetColorKey(_n.bitmap, SDL_SRCCOLORKEY, SDL_MapRGB(_n.bitmap->format,0,255,255));
|
||||||
|
#else
|
||||||
|
SDL_SetColorKey(_n.bitmap, SDL_TRUE, SDL_MapRGB(_n.bitmap->format,0,255,255));
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(elem->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
|
else if(elem->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
|
||||||
|
@ -178,7 +178,11 @@ CCreatureAnimation::CCreatureAnimation(std::string name, TSpeedController contro
|
|||||||
elem.r = reader.readUInt8();
|
elem.r = reader.readUInt8();
|
||||||
elem.g = reader.readUInt8();
|
elem.g = reader.readUInt8();
|
||||||
elem.b = reader.readUInt8();
|
elem.b = reader.readUInt8();
|
||||||
|
#if 0
|
||||||
elem.unused = 0;
|
elem.unused = 0;
|
||||||
|
#else
|
||||||
|
elem.a = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<totalBlocks; i++)
|
for (int i=0; i<totalBlocks; i++)
|
||||||
@ -267,7 +271,11 @@ static SDL_Color genShadow(ui8 alpha)
|
|||||||
|
|
||||||
static SDL_Color genBorderColor(ui8 alpha, const SDL_Color & base)
|
static SDL_Color genBorderColor(ui8 alpha, const SDL_Color & base)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
return CSDL_Ext::makeColor(base.r, base.g, base.b, ui8(base.unused * alpha / 256));
|
return CSDL_Ext::makeColor(base.r, base.g, base.b, ui8(base.unused * alpha / 256));
|
||||||
|
#else
|
||||||
|
return CSDL_Ext::makeColor(base.r, base.g, base.b, ui8(base.a * alpha / 256));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static ui8 mixChannels(ui8 c1, ui8 c2, ui8 a1, ui8 a2)
|
static ui8 mixChannels(ui8 c1, ui8 c2, ui8 a1, ui8 a2)
|
||||||
@ -277,12 +285,22 @@ static ui8 mixChannels(ui8 c1, ui8 c2, ui8 a1, ui8 a2)
|
|||||||
|
|
||||||
static SDL_Color addColors(const SDL_Color & base, const SDL_Color & over)
|
static SDL_Color addColors(const SDL_Color & base, const SDL_Color & over)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
return CSDL_Ext::makeColor(
|
return CSDL_Ext::makeColor(
|
||||||
mixChannels(over.r, base.r, over.unused, base.unused),
|
mixChannels(over.r, base.r, over.unused, base.unused),
|
||||||
mixChannels(over.g, base.g, over.unused, base.unused),
|
mixChannels(over.g, base.g, over.unused, base.unused),
|
||||||
mixChannels(over.b, base.b, over.unused, base.unused),
|
mixChannels(over.b, base.b, over.unused, base.unused),
|
||||||
ui8(over.unused + base.unused * (255 - over.unused) / 256)
|
ui8(over.unused + base.unused * (255 - over.unused) / 256)
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
|
return CSDL_Ext::makeColor(
|
||||||
|
mixChannels(over.r, base.r, over.a, base.a),
|
||||||
|
mixChannels(over.g, base.g, over.a, base.a),
|
||||||
|
mixChannels(over.b, base.b, over.a, base.a),
|
||||||
|
ui8(over.a + base.a * (255 - over.a) / 256)
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<SDL_Color, 8> CCreatureAnimation::genSpecialPalette()
|
std::array<SDL_Color, 8> CCreatureAnimation::genSpecialPalette()
|
||||||
@ -413,7 +431,11 @@ inline void CCreatureAnimation::putPixel(ui8 * dest, const SDL_Color & color, si
|
|||||||
if (index < 8)
|
if (index < 8)
|
||||||
{
|
{
|
||||||
const SDL_Color & pal = special[index];
|
const SDL_Color & pal = special[index];
|
||||||
|
#if 0
|
||||||
ColorPutter<bpp, 0>::PutColor(dest, pal.r, pal.g, pal.b, pal.unused);
|
ColorPutter<bpp, 0>::PutColor(dest, pal.r, pal.g, pal.b, pal.unused);
|
||||||
|
#else
|
||||||
|
ColorPutter<bpp, 0>::PutColor(dest, pal.r, pal.g, pal.b, pal.a);
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "CGuiHandler.h"
|
#include "CGuiHandler.h"
|
||||||
|
|
||||||
#include "SDL_Extensions.h"
|
|
||||||
#include "CIntObject.h"
|
#include "CIntObject.h"
|
||||||
#include "../CGameInfo.h"
|
#include "../CGameInfo.h"
|
||||||
#include "CCursorHandler.h"
|
#include "CCursorHandler.h"
|
||||||
@ -264,6 +264,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
else if(sEvent->button.button == SDL_BUTTON_WHEELDOWN || sEvent->button.button == SDL_BUTTON_WHEELUP)
|
else if(sEvent->button.button == SDL_BUTTON_WHEELDOWN || sEvent->button.button == SDL_BUTTON_WHEELUP)
|
||||||
{
|
{
|
||||||
std::list<CIntObject*> hlp = wheelInterested;
|
std::list<CIntObject*> hlp = wheelInterested;
|
||||||
@ -273,7 +274,20 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
|||||||
(*i)->wheelScrolled(sEvent->button.button == SDL_BUTTON_WHEELDOWN, isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y));
|
(*i)->wheelScrolled(sEvent->button.button == SDL_BUTTON_WHEELDOWN, isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
#else
|
||||||
|
else if ((sEvent->type == SDL_MOUSEWHEEL))
|
||||||
|
{
|
||||||
|
std::list<CIntObject*> hlp = wheelInterested;
|
||||||
|
for(auto i=hlp.begin(); i != hlp.end() && current; i++)
|
||||||
|
{
|
||||||
|
if(!vstd::contains(wheelInterested,*i)) continue;
|
||||||
|
(*i)->wheelScrolled(sEvent->wheel.y < 0, isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // 0
|
||||||
else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_LEFT))
|
else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
std::list<CIntObject*> hlp = lclickable;
|
std::list<CIntObject*> hlp = lclickable;
|
||||||
@ -387,6 +401,11 @@ void CGuiHandler::run()
|
|||||||
if(curInt)
|
if(curInt)
|
||||||
curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment
|
curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment
|
||||||
|
|
||||||
|
SDL_RenderClear(mainRenderer);
|
||||||
|
SDL_RenderCopy(mainRenderer, screenTexture, NULL, NULL);
|
||||||
|
|
||||||
|
SDL_RenderPresent(mainRenderer);
|
||||||
|
|
||||||
mainFPSmng->framerateDelay(); // holds a constant FPS
|
mainFPSmng->framerateDelay(); // holds a constant FPS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,6 +451,7 @@ void CGuiHandler::drawFPSCounter()
|
|||||||
|
|
||||||
SDLKey CGuiHandler::arrowToNum( SDLKey key )
|
SDLKey CGuiHandler::arrowToNum( SDLKey key )
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
case SDLK_DOWN:
|
case SDLK_DOWN:
|
||||||
@ -445,13 +465,33 @@ SDLKey CGuiHandler::arrowToNum( SDLKey key )
|
|||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case SDLK_DOWN:
|
||||||
|
return SDLK_KP_2;
|
||||||
|
case SDLK_UP:
|
||||||
|
return SDLK_KP_8;
|
||||||
|
case SDLK_LEFT:
|
||||||
|
return SDLK_KP_4;
|
||||||
|
case SDLK_RIGHT:
|
||||||
|
return SDLK_KP_6;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
#endif // 0
|
||||||
throw std::runtime_error("Wrong key!");
|
throw std::runtime_error("Wrong key!");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLKey CGuiHandler::numToDigit( SDLKey key )
|
SDLKey CGuiHandler::numToDigit( SDLKey key )
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if(key >= SDLK_KP0 && key <= SDLK_KP9)
|
if(key >= SDLK_KP0 && key <= SDLK_KP9)
|
||||||
return SDLKey(key - SDLK_KP0 + SDLK_0);
|
return SDLKey(key - SDLK_KP0 + SDLK_0);
|
||||||
|
#else
|
||||||
|
if(key >= SDLK_KP_0 && key <= SDLK_KP_9)
|
||||||
|
return SDLKey(key - SDLK_KP_0 + SDLK_0);
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
#define REMOVE_KP(keyName) case SDLK_KP_ ## keyName : return SDLK_ ## keyName;
|
#define REMOVE_KP(keyName) case SDLK_KP_ ## keyName : return SDLK_ ## keyName;
|
||||||
switch(key)
|
switch(key)
|
||||||
@ -475,10 +515,17 @@ SDLKey CGuiHandler::numToDigit( SDLKey key )
|
|||||||
|
|
||||||
bool CGuiHandler::isNumKey( SDLKey key, bool number )
|
bool CGuiHandler::isNumKey( SDLKey key, bool number )
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if(number)
|
if(number)
|
||||||
return key >= SDLK_KP0 && key <= SDLK_KP9;
|
return key >= SDLK_KP0 && key <= SDLK_KP9;
|
||||||
else
|
else
|
||||||
return key >= SDLK_KP0 && key <= SDLK_KP_EQUALS;
|
return key >= SDLK_KP0 && key <= SDLK_KP_EQUALS;
|
||||||
|
#else
|
||||||
|
if(number)
|
||||||
|
return key >= SDLK_KP_0 && key <= SDLK_KP_9;
|
||||||
|
else
|
||||||
|
return key >= SDLK_KP_0 && key <= SDLK_KP_EQUALS;
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGuiHandler::isArrowKey( SDLKey key )
|
bool CGuiHandler::isArrowKey( SDLKey key )
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "../../lib/CStopWatch.h"
|
#include "../../lib/CStopWatch.h"
|
||||||
#include "Geometries.h"
|
#include "Geometries.h"
|
||||||
|
#include "SDL_Extensions.h"
|
||||||
|
|
||||||
class CFramerateManager;
|
class CFramerateManager;
|
||||||
class CGStatusBar;
|
class CGStatusBar;
|
||||||
|
@ -134,7 +134,11 @@ void CPicture::convertToScreenBPP()
|
|||||||
|
|
||||||
void CPicture::setAlpha(int value)
|
void CPicture::setAlpha(int value)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
SDL_SetAlpha(bg, SDL_SRCALPHA, value);
|
SDL_SetAlpha(bg, SDL_SRCALPHA, value);
|
||||||
|
#else
|
||||||
|
SDL_SetSurfaceAlphaMod(bg,value);
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPicture::scaleTo(Point size)
|
void CPicture::scaleTo(Point size)
|
||||||
@ -285,7 +289,11 @@ void CButtonBase::block(bool on)
|
|||||||
CAdventureMapButton::CAdventureMapButton ()
|
CAdventureMapButton::CAdventureMapButton ()
|
||||||
{
|
{
|
||||||
hoverable = actOnDown = borderEnabled = soundDisabled = false;
|
hoverable = actOnDown = borderEnabled = soundDisabled = false;
|
||||||
|
#if 0
|
||||||
borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
|
borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
|
||||||
|
#else
|
||||||
|
borderColor.a = 1; // represents a transparent color, used for HighlightableButton
|
||||||
|
#endif // 0
|
||||||
addUsedEvents(LCLICK | RCLICK | HOVER | KEYBOARD);
|
addUsedEvents(LCLICK | RCLICK | HOVER | KEYBOARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +412,11 @@ void CAdventureMapButton::init(const CFunctionList<void()> &Callback, const std:
|
|||||||
addUsedEvents(LCLICK | RCLICK | HOVER | KEYBOARD);
|
addUsedEvents(LCLICK | RCLICK | HOVER | KEYBOARD);
|
||||||
callback = Callback;
|
callback = Callback;
|
||||||
hoverable = actOnDown = borderEnabled = soundDisabled = false;
|
hoverable = actOnDown = borderEnabled = soundDisabled = false;
|
||||||
|
#if 0
|
||||||
borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
|
borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
|
||||||
|
#else
|
||||||
|
borderColor.a = 1; // represents a transparent color, used for HighlightableButton
|
||||||
|
#endif // 0
|
||||||
hoverTexts = Name;
|
hoverTexts = Name;
|
||||||
helpBox=HelpBox;
|
helpBox=HelpBox;
|
||||||
|
|
||||||
@ -453,8 +465,13 @@ void CAdventureMapButton::showAll(SDL_Surface * to)
|
|||||||
{
|
{
|
||||||
CIntObject::showAll(to);
|
CIntObject::showAll(to);
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (borderEnabled && borderColor.unused == 0)
|
if (borderEnabled && borderColor.unused == 0)
|
||||||
CSDL_Ext::drawBorder(to, pos.x-1, pos.y-1, pos.w+2, pos.h+2, int3(borderColor.r, borderColor.g, borderColor.b));
|
CSDL_Ext::drawBorder(to, pos.x-1, pos.y-1, pos.w+2, pos.h+2, int3(borderColor.r, borderColor.g, borderColor.b));
|
||||||
|
#else
|
||||||
|
if (borderEnabled && borderColor.a == 0)
|
||||||
|
CSDL_Ext::drawBorder(to, pos.x-1, pos.y-1, pos.w+2, pos.h+2, int3(borderColor.r, borderColor.g, borderColor.b));
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHighlightableButton::select(bool on)
|
void CHighlightableButton::select(bool on)
|
||||||
@ -1604,19 +1621,24 @@ void CTextInput::keyPressed( const SDL_KeyboardEvent & key )
|
|||||||
text.resize(text.size()-1);
|
text.resize(text.size()-1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
#if 0
|
||||||
if (key.keysym.unicode < ' ')
|
if (key.keysym.unicode < ' ')
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
text += key.keysym.unicode; //TODO 16-/>8
|
text += key.keysym.unicode; //TODO 16-/>8
|
||||||
|
#endif // 0
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
filters(text, oldText);
|
filters(text, oldText);
|
||||||
if (text != oldText)
|
if (text != oldText)
|
||||||
{
|
{
|
||||||
redraw();
|
redraw();
|
||||||
cb(text);
|
cb(text);
|
||||||
}
|
}
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
|
//todo: handle text input for SDL2
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextInput::setText( const std::string &nText, bool callCb )
|
void CTextInput::setText( const std::string &nText, bool callCb )
|
||||||
@ -1631,11 +1653,15 @@ bool CTextInput::captureThisEvent(const SDL_KeyboardEvent & key)
|
|||||||
if(key.keysym.sym == SDLK_RETURN || key.keysym.sym == SDLK_KP_ENTER)
|
if(key.keysym.sym == SDLK_RETURN || key.keysym.sym == SDLK_KP_ENTER)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if 0
|
||||||
//this should allow all non-printable keys to go through (for example arrows)
|
//this should allow all non-printable keys to go through (for example arrows)
|
||||||
if (key.keysym.unicode < ' ')
|
if (key.keysym.unicode < ' ')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
return false; //todo:CTextInput::captureThisEvent
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextInput::filenameFilter(std::string & text, const std::string &)
|
void CTextInput::filenameFilter(std::string & text, const std::string &)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "../CMessage.h"
|
#include "../CMessage.h"
|
||||||
#include "../CDefHandler.h"
|
#include "../CDefHandler.h"
|
||||||
#include "../Graphics.h"
|
#include "../Graphics.h"
|
||||||
|
#include "../CMT.h"
|
||||||
|
|
||||||
const SDL_Color Colors::YELLOW = { 229, 215, 123, 0 };
|
const SDL_Color Colors::YELLOW = { 229, 215, 123, 0 };
|
||||||
const SDL_Color Colors::WHITE = { 255, 243, 222, 0 };
|
const SDL_Color Colors::WHITE = { 255, 243, 222, 0 };
|
||||||
@ -444,7 +445,11 @@ int CSDL_Ext::blit8bppAlphaTo24bppT(const SDL_Surface * src, const SDL_Rect * sr
|
|||||||
for(int x = w; x; x--)
|
for(int x = w; x; x--)
|
||||||
{
|
{
|
||||||
const SDL_Color &tbc = colors[*color++]; //color to blit
|
const SDL_Color &tbc = colors[*color++]; //color to blit
|
||||||
|
#if 0
|
||||||
ColorPutter<bpp, +1>::PutColorAlphaSwitch(p, tbc.r, tbc.g, tbc.b, tbc.unused);
|
ColorPutter<bpp, +1>::PutColorAlphaSwitch(p, tbc.r, tbc.g, tbc.b, tbc.unused);
|
||||||
|
#else
|
||||||
|
ColorPutter<bpp, +1>::PutColorAlphaSwitch(p, tbc.r, tbc.g, tbc.b, tbc.a);
|
||||||
|
#endif // 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_UnlockSurface(dst);
|
SDL_UnlockSurface(dst);
|
||||||
@ -469,7 +474,11 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(const SDL_Surface * src, const SDL_Rect * src
|
|||||||
Uint32 CSDL_Ext::colorToUint32(const SDL_Color * color)
|
Uint32 CSDL_Ext::colorToUint32(const SDL_Color * color)
|
||||||
{
|
{
|
||||||
Uint32 ret = 0;
|
Uint32 ret = 0;
|
||||||
|
#if 0
|
||||||
ret+=color->unused;
|
ret+=color->unused;
|
||||||
|
#else
|
||||||
|
ret+=color->a;
|
||||||
|
#endif // 0
|
||||||
ret<<=8; //*=256
|
ret<<=8; //*=256
|
||||||
ret+=color->b;
|
ret+=color->b;
|
||||||
ret<<=8; //*=256
|
ret<<=8; //*=256
|
||||||
@ -481,8 +490,12 @@ Uint32 CSDL_Ext::colorToUint32(const SDL_Color * color)
|
|||||||
|
|
||||||
void CSDL_Ext::update(SDL_Surface * what)
|
void CSDL_Ext::update(SDL_Surface * what)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if(what)
|
if(what)
|
||||||
SDL_UpdateRect(what, 0, 0, what->w, what->h);
|
SDL_UpdateRect(what, 0, 0, what->w, what->h);
|
||||||
|
#else
|
||||||
|
SDL_UpdateTexture(screenTexture, NULL, what->pixels, what->pitch);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void CSDL_Ext::drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color)
|
void CSDL_Ext::drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color)
|
||||||
{
|
{
|
||||||
@ -602,13 +615,21 @@ bool CSDL_Ext::isTransparent( SDL_Surface * srf, int x, int y )
|
|||||||
|
|
||||||
SDL_Color color;
|
SDL_Color color;
|
||||||
|
|
||||||
|
#if 0
|
||||||
SDL_GetRGBA(SDL_GetPixel(srf, x, y), srf->format, &color.r, &color.g, &color.b, &color.unused);
|
SDL_GetRGBA(SDL_GetPixel(srf, x, y), srf->format, &color.r, &color.g, &color.b, &color.unused);
|
||||||
|
#else
|
||||||
|
SDL_GetRGBA(SDL_GetPixel(srf, x, y), srf->format, &color.r, &color.g, &color.b, &color.a);
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
// color is considered transparent here if
|
// color is considered transparent here if
|
||||||
// a) image has aplha: less than 50% transparency
|
// a) image has aplha: less than 50% transparency
|
||||||
// b) no alpha: color is cyan
|
// b) no alpha: color is cyan
|
||||||
if (srf->format->Amask)
|
if (srf->format->Amask)
|
||||||
|
#if 0
|
||||||
return color.unused < 128; // almost transparent
|
return color.unused < 128; // almost transparent
|
||||||
|
#else
|
||||||
|
return color.a < 128; // almost transparent
|
||||||
|
#endif // 0
|
||||||
else
|
else
|
||||||
return (color.r == 0 && color.g == 255 && color.b == 255);
|
return (color.r == 0 && color.g == 255 && color.b == 255);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL_render.h>
|
||||||
#include <SDL_video.h>
|
#include <SDL_video.h>
|
||||||
#include <SDL_ttf.h>
|
#include <SDL_ttf.h>
|
||||||
#include "../../lib/int3.h"
|
#include "../../lib/int3.h"
|
||||||
@ -29,6 +30,53 @@
|
|||||||
#define SDL_GetKeyState SDL_GetKeyboardState
|
#define SDL_GetKeyState SDL_GetKeyboardState
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//compatibility stuff
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
typedef Sint16 SDLX_Coord;
|
||||||
|
typedef Uint16 SDLX_Size;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
extern SDL_Window * mainWindow;
|
||||||
|
extern SDL_Renderer * mainRenderer;
|
||||||
|
extern SDL_Texture * screenTexture;
|
||||||
|
|
||||||
|
|
||||||
|
typedef int SDLX_Coord;
|
||||||
|
typedef int SDLX_Size;
|
||||||
|
|
||||||
|
typedef SDL_Keycode SDLKey;
|
||||||
|
|
||||||
|
#define SDL_SRCCOLORKEY SDL_TRUE
|
||||||
|
|
||||||
|
#define SDL_FULLSCREEN SDL_WINDOW_FULLSCREEN
|
||||||
|
|
||||||
|
inline void SDL_SetColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors)
|
||||||
|
{
|
||||||
|
SDL_SetPaletteColors(surface->format->palette,colors,firstcolor,ncolors);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SDL_WarpMouse(int x, int y)
|
||||||
|
{
|
||||||
|
SDL_WarpMouseInWindow(mainWindow,x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SDL_UpdateRect(SDL_Surface *surface, int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
Rect rect(x,y,w,h);
|
||||||
|
SDL_UpdateTexture(screenTexture, &rect, surface->pixels, surface->pitch);
|
||||||
|
|
||||||
|
SDL_RenderClear(mainRenderer);
|
||||||
|
SDL_RenderCopy(mainRenderer, screenTexture, NULL, NULL);
|
||||||
|
|
||||||
|
SDL_RenderPresent(mainRenderer);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
struct Rect;
|
struct Rect;
|
||||||
|
|
||||||
extern SDL_Surface * screen, *screen2, *screenBuf;
|
extern SDL_Surface * screen, *screen2, *screenBuf;
|
||||||
|
@ -133,7 +133,11 @@ struct ColorPutter<2, incrementPtr>
|
|||||||
template<int bpp, int incrementPtr>
|
template<int bpp, int incrementPtr>
|
||||||
STRONG_INLINE void ColorPutter<bpp, incrementPtr>::PutColorAlpha(Uint8 *&ptr, const SDL_Color & Color)
|
STRONG_INLINE void ColorPutter<bpp, incrementPtr>::PutColorAlpha(Uint8 *&ptr, const SDL_Color & Color)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
PutColor(ptr, Color.r, Color.g, Color.b, Color.unused);
|
PutColor(ptr, Color.r, Color.g, Color.b, Color.unused);
|
||||||
|
#else
|
||||||
|
PutColor(ptr, Color.r, Color.g, Color.b, Color.a);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int bpp, int incrementPtr>
|
template<int bpp, int incrementPtr>
|
||||||
@ -262,7 +266,11 @@ STRONG_INLINE void ColorPutter<2, incrementPtr>::PutColor(Uint8 *&ptr, const Uin
|
|||||||
template <int incrementPtr>
|
template <int incrementPtr>
|
||||||
STRONG_INLINE void ColorPutter<2, incrementPtr>::PutColorAlpha(Uint8 *&ptr, const SDL_Color & Color)
|
STRONG_INLINE void ColorPutter<2, incrementPtr>::PutColorAlpha(Uint8 *&ptr, const SDL_Color & Color)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
PutColor(ptr, Color.r, Color.g, Color.b, Color.unused);
|
PutColor(ptr, Color.r, Color.g, Color.b, Color.unused);
|
||||||
|
#else
|
||||||
|
PutColor(ptr, Color.r, Color.g, Color.b, Color.a);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int incrementPtr>
|
template <int incrementPtr>
|
||||||
|
Loading…
Reference in New Issue
Block a user