mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-05 00:49:09 +02:00
Remove old code
This commit is contained in:
@ -34,7 +34,6 @@
|
|||||||
#include "../render/IImage.h"
|
#include "../render/IImage.h"
|
||||||
#include "../render/IRenderHandler.h"
|
#include "../render/IRenderHandler.h"
|
||||||
#include "../render/IScreenHandler.h"
|
#include "../render/IScreenHandler.h"
|
||||||
#include "../CMT.h"
|
|
||||||
#include "../PlayerLocalState.h"
|
#include "../PlayerLocalState.h"
|
||||||
#include "../CPlayerInterface.h"
|
#include "../CPlayerInterface.h"
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "../render/EFont.h"
|
#include "../render/EFont.h"
|
||||||
#include "../renderSDL/ScreenHandler.h"
|
#include "../renderSDL/ScreenHandler.h"
|
||||||
#include "../renderSDL/RenderHandler.h"
|
#include "../renderSDL/RenderHandler.h"
|
||||||
#include "../CMT.h"
|
|
||||||
#include "../CPlayerInterface.h"
|
#include "../CPlayerInterface.h"
|
||||||
#include "../battle/BattleInterface.h"
|
#include "../battle/BattleInterface.h"
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "../render/Canvas.h"
|
#include "../render/Canvas.h"
|
||||||
#include "../render/IScreenHandler.h"
|
#include "../render/IScreenHandler.h"
|
||||||
#include "../windows/CMessage.h"
|
#include "../windows/CMessage.h"
|
||||||
#include "../CMT.h"
|
|
||||||
|
|
||||||
CIntObject::CIntObject(int used_, Point pos_):
|
CIntObject::CIntObject(int used_, Point pos_):
|
||||||
parent_m(nullptr),
|
parent_m(nullptr),
|
||||||
|
@ -14,12 +14,10 @@
|
|||||||
#include "CIntObject.h"
|
#include "CIntObject.h"
|
||||||
#include "CursorHandler.h"
|
#include "CursorHandler.h"
|
||||||
|
|
||||||
#include "../CMT.h"
|
|
||||||
#include "../CGameInfo.h"
|
#include "../CGameInfo.h"
|
||||||
#include "../render/Canvas.h"
|
#include "../render/Canvas.h"
|
||||||
#include "../render/IScreenHandler.h"
|
#include "../render/IScreenHandler.h"
|
||||||
#include "../render/Colors.h"
|
#include "../render/Colors.h"
|
||||||
#include "../renderSDL/SDL_Extensions.h"
|
|
||||||
|
|
||||||
void WindowHandler::popWindow(std::shared_ptr<IShowActivatable> top)
|
void WindowHandler::popWindow(std::shared_ptr<IShowActivatable> top)
|
||||||
{
|
{
|
||||||
|
@ -324,10 +324,21 @@ void SDLImageShared::exportBitmap(const boost::filesystem::path& path, SDL_Palet
|
|||||||
bool SDLImageShared::isTransparent(const Point & coords) const
|
bool SDLImageShared::isTransparent(const Point & coords) const
|
||||||
{
|
{
|
||||||
assert(upscalingInProgress == false);
|
assert(upscalingInProgress == false);
|
||||||
if (surf)
|
if (!surf)
|
||||||
return CSDL_Ext::isTransparent(surf, coords.x - margins.x, coords.y - margins.y);
|
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
Point test = coords - margins;
|
||||||
|
|
||||||
|
if (test.x < 0 || test.y < 0 || test.x >= surf->w || test.y >= surf->h)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
SDL_Color color;
|
||||||
|
SDL_GetRGBA(CSDL_Ext::getPixel(surf, test.x, test.y), surf->format, &color.r, &color.g, &color.b, &color.a);
|
||||||
|
|
||||||
|
bool pixelTransparent = color.a < 128;
|
||||||
|
bool pixelCyan = (color.r == 0 && color.g == 255 && color.b == 255);
|
||||||
|
|
||||||
|
return pixelTransparent || pixelCyan;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect SDLImageShared::contentRect() const
|
Rect SDLImageShared::contentRect() const
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "SDL_Extensions.h"
|
#include "SDL_Extensions.h"
|
||||||
|
|
||||||
#include "../CMT.h"
|
|
||||||
#include "../xBRZ/xbrz.h"
|
#include "../xBRZ/xbrz.h"
|
||||||
|
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
|
@ -59,16 +59,6 @@ SDL_Color CSDL_Ext::toSDL(const ColorRGBA & color)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSDL_Ext::setColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors)
|
|
||||||
{
|
|
||||||
SDL_SetPaletteColors(surface->format->palette,colors,firstcolor,ncolors);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSDL_Ext::setAlpha(SDL_Surface * bg, int value)
|
|
||||||
{
|
|
||||||
SDL_SetSurfaceAlphaMod(bg, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Surface * CSDL_Ext::newSurface(const Point & dimensions)
|
SDL_Surface * CSDL_Ext::newSurface(const Point & dimensions)
|
||||||
{
|
{
|
||||||
return newSurface(dimensions, nullptr);
|
return newSurface(dimensions, nullptr);
|
||||||
@ -102,25 +92,6 @@ SDL_Surface * CSDL_Ext::newSurface(const Point & dimensions, SDL_Surface * mod)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface * CSDL_Ext::copySurface(SDL_Surface * mod) //returns copy of given surface
|
|
||||||
{
|
|
||||||
//return SDL_DisplayFormat(mod);
|
|
||||||
return SDL_ConvertSurface(mod, mod->format, mod->flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<int bpp>
|
|
||||||
SDL_Surface * CSDL_Ext::createSurfaceWithBpp(int width, int height)
|
|
||||||
{
|
|
||||||
uint32_t rMask = 0, gMask = 0, bMask = 0, aMask = 0;
|
|
||||||
|
|
||||||
Channels::px<bpp>::r.set((uint8_t*)&rMask, 255);
|
|
||||||
Channels::px<bpp>::g.set((uint8_t*)&gMask, 255);
|
|
||||||
Channels::px<bpp>::b.set((uint8_t*)&bMask, 255);
|
|
||||||
Channels::px<bpp>::a.set((uint8_t*)&aMask, 255);
|
|
||||||
|
|
||||||
return SDL_CreateRGBSurface(0, width, height, bpp * 8, rMask, gMask, bMask, aMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSDL_Ext::blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst)
|
void CSDL_Ext::blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst)
|
||||||
{
|
{
|
||||||
CSDL_Ext::blitSurface(src, dst, Point(x, y));
|
CSDL_Ext::blitSurface(src, dst, Point(x, y));
|
||||||
@ -542,54 +513,23 @@ void CSDL_Ext::drawBorder( SDL_Surface * sur, const Rect &r, const SDL_Color &co
|
|||||||
drawBorder(sur, r.x, r.y, r.w, r.h, color, depth);
|
drawBorder(sur, r.x, r.y, r.w, r.h, color, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSDL_Ext::TColorPutter CSDL_Ext::getPutterFor(SDL_Surface * const &dest)
|
|
||||||
{
|
|
||||||
switch(dest->format->BytesPerPixel)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
return ColorPutter<3>::PutColor;
|
|
||||||
case 4:
|
|
||||||
return ColorPutter<4>::PutColor;
|
|
||||||
default:
|
|
||||||
logGlobal->error("%d bpp is not supported!", (int)dest->format->BitsPerPixel);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t * CSDL_Ext::getPxPtr(const SDL_Surface * const &srf, const int x, const int y)
|
uint8_t * CSDL_Ext::getPxPtr(const SDL_Surface * const &srf, const int x, const int y)
|
||||||
{
|
{
|
||||||
return (uint8_t *)srf->pixels + y * srf->pitch + x * srf->format->BytesPerPixel;
|
return (uint8_t *)srf->pixels + y * srf->pitch + x * srf->format->BytesPerPixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSDL_Ext::isTransparent( SDL_Surface * srf, const Point & position )
|
|
||||||
{
|
|
||||||
return isTransparent(srf, position.x, position.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSDL_Ext::isTransparent( SDL_Surface * srf, int x, int y )
|
|
||||||
{
|
|
||||||
if (x < 0 || y < 0 || x >= srf->w || y >= srf->h)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
SDL_Color color;
|
|
||||||
|
|
||||||
SDL_GetRGBA(CSDL_Ext::getPixel(srf, x, y), srf->format, &color.r, &color.g, &color.b, &color.a);
|
|
||||||
|
|
||||||
bool pixelTransparent = color.a < 128;
|
|
||||||
bool pixelCyan = (color.r == 0 && color.g == 255 && color.b == 255);
|
|
||||||
|
|
||||||
return pixelTransparent || pixelCyan;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSDL_Ext::putPixelWithoutRefresh(SDL_Surface *ekran, const int & x, const int & y, const uint8_t & R, const uint8_t & G, const uint8_t & B, uint8_t A)
|
void CSDL_Ext::putPixelWithoutRefresh(SDL_Surface *ekran, const int & x, const int & y, const uint8_t & R, const uint8_t & G, const uint8_t & B, uint8_t A)
|
||||||
{
|
{
|
||||||
uint8_t *p = getPxPtr(ekran, x, y);
|
uint8_t *p = getPxPtr(ekran, x, y);
|
||||||
getPutterFor(ekran)(p, R, G, B);
|
|
||||||
|
|
||||||
switch(ekran->format->BytesPerPixel)
|
switch(ekran->format->BytesPerPixel)
|
||||||
{
|
{
|
||||||
case 3: Channels::px<3>::a.set(p, A); break;
|
case 3:
|
||||||
case 4: Channels::px<4>::a.set(p, A); break;
|
ColorPutter<3>::PutColor(p, R, G, B);
|
||||||
|
Channels::px<3>::a.set(p, A); break;
|
||||||
|
case 4:
|
||||||
|
ColorPutter<4>::PutColor(p, R, G, B);
|
||||||
|
Channels::px<4>::a.set(p, A); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,6 +664,3 @@ void CSDL_Ext::getClipRect(SDL_Surface * src, Rect & other)
|
|||||||
|
|
||||||
other = CSDL_Ext::fromSDL(rect);
|
other = CSDL_Ext::fromSDL(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<3>(int, int);
|
|
||||||
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<4>(int, int);
|
|
||||||
|
@ -13,20 +13,9 @@
|
|||||||
#include "../../lib/Color.h"
|
#include "../../lib/Color.h"
|
||||||
|
|
||||||
struct SDL_Rect;
|
struct SDL_Rect;
|
||||||
struct SDL_Window;
|
|
||||||
struct SDL_Renderer;
|
|
||||||
struct SDL_Texture;
|
|
||||||
struct SDL_Surface;
|
struct SDL_Surface;
|
||||||
struct SDL_Color;
|
struct SDL_Color;
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
|
||||||
|
|
||||||
class PlayerColor;
|
|
||||||
class Rect;
|
|
||||||
class Point;
|
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
|
||||||
|
|
||||||
namespace CSDL_Ext
|
namespace CSDL_Ext
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -42,12 +31,6 @@ ColorRGBA fromSDL(const SDL_Color & color);
|
|||||||
/// creates SDL_Color using provided Color
|
/// creates SDL_Color using provided Color
|
||||||
SDL_Color toSDL(const ColorRGBA & color);
|
SDL_Color toSDL(const ColorRGBA & color);
|
||||||
|
|
||||||
void setColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);
|
|
||||||
void setAlpha(SDL_Surface * bg, int value);
|
|
||||||
|
|
||||||
using TColorPutter = void (*)(uint8_t *&, const uint8_t &, const uint8_t &, const uint8_t &);
|
|
||||||
using TColorPutterAlpha = void (*)(uint8_t *&, const uint8_t &, const uint8_t &, const uint8_t &, const uint8_t &);
|
|
||||||
|
|
||||||
void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst);
|
void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst);
|
||||||
void blitAt(SDL_Surface * src, const Rect & pos, SDL_Surface * dst);
|
void blitAt(SDL_Surface * src, const Rect & pos, SDL_Surface * dst);
|
||||||
|
|
||||||
@ -67,11 +50,8 @@ using TColorPutterAlpha = void (*)(uint8_t *&, const uint8_t &, const uint8_t &,
|
|||||||
SDL_Surface * verticalFlip(SDL_Surface * toRot); //vertical flip
|
SDL_Surface * verticalFlip(SDL_Surface * toRot); //vertical flip
|
||||||
SDL_Surface * horizontalFlip(SDL_Surface * toRot); //horizontal flip
|
SDL_Surface * horizontalFlip(SDL_Surface * toRot); //horizontal flip
|
||||||
uint32_t getPixel(SDL_Surface * surface, const int & x, const int & y, bool colorByte = false);
|
uint32_t getPixel(SDL_Surface * surface, const int & x, const int & y, bool colorByte = false);
|
||||||
bool isTransparent(SDL_Surface * srf, int x, int y); //checks if surface is transparent at given position
|
|
||||||
bool isTransparent(SDL_Surface * srf, const Point & position); //checks if surface is transparent at given position
|
|
||||||
|
|
||||||
uint8_t * getPxPtr(const SDL_Surface * const & srf, const int x, const int y);
|
uint8_t * getPxPtr(const SDL_Surface * const & srf, const int x, const int y);
|
||||||
TColorPutter getPutterFor(SDL_Surface * const & dest);
|
|
||||||
|
|
||||||
template<int bpp, bool useAlpha>
|
template<int bpp, bool useAlpha>
|
||||||
int blit8bppAlphaTo24bppT(const SDL_Surface * src, const Rect & srcRect, SDL_Surface * dst, const Point & dstPoint, uint8_t alpha); //blits 8 bpp surface with alpha channel to 24 bpp surface
|
int blit8bppAlphaTo24bppT(const SDL_Surface * src, const Rect & srcRect, SDL_Surface * dst, const Point & dstPoint, uint8_t alpha); //blits 8 bpp surface with alpha channel to 24 bpp surface
|
||||||
@ -86,9 +66,6 @@ using TColorPutterAlpha = void (*)(uint8_t *&, const uint8_t &, const uint8_t &,
|
|||||||
|
|
||||||
SDL_Surface * newSurface(const Point & dimensions, SDL_Surface * mod); //creates new surface, with flags/format same as in surface given
|
SDL_Surface * newSurface(const Point & dimensions, SDL_Surface * mod); //creates new surface, with flags/format same as in surface given
|
||||||
SDL_Surface * newSurface(const Point & dimensions); //creates new surface, with flags/format same as in screen surface
|
SDL_Surface * newSurface(const Point & dimensions); //creates new surface, with flags/format same as in screen surface
|
||||||
SDL_Surface * copySurface(SDL_Surface * mod); //returns copy of given surface
|
|
||||||
template<int bpp>
|
|
||||||
SDL_Surface * createSurfaceWithBpp(int width, int height); //create surface with give bits per pixels value
|
|
||||||
|
|
||||||
template<int bpp>
|
template<int bpp>
|
||||||
void convertToGrayscaleBpp(SDL_Surface * surf, const Rect & rect);
|
void convertToGrayscaleBpp(SDL_Surface * surf, const Rect & rect);
|
||||||
@ -100,25 +77,4 @@ using TColorPutterAlpha = void (*)(uint8_t *&, const uint8_t &, const uint8_t &,
|
|||||||
void setDefaultColorKey(SDL_Surface * surface);
|
void setDefaultColorKey(SDL_Surface * surface);
|
||||||
///set key-color to 0,255,255 only if it exactly mapped
|
///set key-color to 0,255,255 only if it exactly mapped
|
||||||
void setDefaultColorKeyPresize(SDL_Surface * surface);
|
void setDefaultColorKeyPresize(SDL_Surface * surface);
|
||||||
|
|
||||||
/// helper that will safely set and un-set ClipRect for SDL_Surface
|
|
||||||
class CClipRectGuard: boost::noncopyable
|
|
||||||
{
|
|
||||||
SDL_Surface * surf;
|
|
||||||
Rect oldRect;
|
|
||||||
|
|
||||||
int getScalingFactor() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CClipRectGuard(SDL_Surface * surface, const Rect & rect): surf(surface)
|
|
||||||
{
|
|
||||||
CSDL_Ext::getClipRect(surf, oldRect);
|
|
||||||
CSDL_Ext::setClipRect(surf, rect * getScalingFactor());
|
|
||||||
}
|
|
||||||
|
|
||||||
~CClipRectGuard()
|
|
||||||
{
|
|
||||||
CSDL_Ext::setClipRect(surf, oldRect);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "../gui/CursorHandler.h"
|
#include "../gui/CursorHandler.h"
|
||||||
#include "../gui/WindowHandler.h"
|
#include "../gui/WindowHandler.h"
|
||||||
#include "../render/Canvas.h"
|
#include "../render/Canvas.h"
|
||||||
#include "../renderSDL/SDL_Extensions.h"
|
|
||||||
|
|
||||||
#include "../../lib/CConfigHandler.h"
|
#include "../../lib/CConfigHandler.h"
|
||||||
#include "../../lib/constants/StringConstants.h"
|
#include "../../lib/constants/StringConstants.h"
|
||||||
|
Reference in New Issue
Block a user