mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* minor fixes for screen scrolling
This commit is contained in:
parent
6b8718b046
commit
7cad2364fe
@ -647,7 +647,7 @@ void CSlider::setAmount( int to )
|
||||
|
||||
void CSlider::showAll(SDL_Surface * to)
|
||||
{
|
||||
SDL_FillRect(to, &pos, 0);
|
||||
CSDL_Ext::fillRect(to, &pos, 0);
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
|
@ -528,6 +528,8 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen)
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
|
||||
screenLT = Point(0, 0);
|
||||
|
||||
#ifdef _WIN32
|
||||
SDL_SysWMinfo wm;
|
||||
SDL_VERSION(&wm.version);
|
||||
|
@ -279,7 +279,7 @@ SDL_Surface * FNT_RenderText (EFonts font, std::string text, SDL_Color kolor= zw
|
||||
int w = f->getWidth(text.c_str()),
|
||||
h = f->height;
|
||||
SDL_Surface * ret = CSDL_Ext::newSurface(w, h, screen);
|
||||
SDL_FillRect (ret, NULL, SDL_MapRGB(ret->format,128,128,128));//if use default black - no shadowing
|
||||
CSDL_Ext::fillRect (ret, NULL, SDL_MapRGB(ret->format,128,128,128));//if use default black - no shadowing
|
||||
SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format,128,128,128));
|
||||
CSDL_Ext::printAt(text.c_str(), 0, 0, font, kolor, ret);
|
||||
return ret;
|
||||
|
@ -66,6 +66,7 @@ using namespace boost::assign;
|
||||
using namespace CSDL_Ext;
|
||||
|
||||
void processCommand(const std::string &message, CClient *&client);
|
||||
void updateScreenLT(int maxW, int maxH);
|
||||
|
||||
extern std::queue<SDL_Event*> events;
|
||||
extern boost::mutex eventsM;
|
||||
@ -1331,6 +1332,8 @@ void CPlayerInterface::update()
|
||||
CSDL_Ext::update(screen);
|
||||
CGI->curh->draw2();
|
||||
|
||||
updateScreenLT(conf.cc.resx, conf.cc.resy);
|
||||
|
||||
pim->unlock();
|
||||
|
||||
SDL_framerateDelay(mainFPSmng);
|
||||
|
@ -150,6 +150,16 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
||||
current = sEvent;
|
||||
bool prev;
|
||||
|
||||
struct HLP
|
||||
{
|
||||
static void adjustMousePos(SDL_Event * ev)
|
||||
{
|
||||
//adjust mouse position according to screenLT
|
||||
ev->motion.x -= screenLT.x;
|
||||
ev->motion.y -= screenLT.y;
|
||||
}
|
||||
};
|
||||
|
||||
if (sEvent->type==SDL_KEYDOWN || sEvent->type==SDL_KEYUP)
|
||||
{
|
||||
SDL_KeyboardEvent key = sEvent->key;
|
||||
@ -178,16 +188,12 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
||||
else if(sEvent->type==SDL_MOUSEMOTION)
|
||||
{
|
||||
CGI->curh->cursorMove(sEvent->motion.x, sEvent->motion.y);
|
||||
//adjust mouse position according to screenLT
|
||||
sEvent->motion.x -= screenLT.x;
|
||||
sEvent->motion.y -= screenLT.y;
|
||||
HLP::adjustMousePos(sEvent);
|
||||
handleMouseMotion(sEvent);
|
||||
}
|
||||
else if (sEvent->type==SDL_MOUSEBUTTONDOWN)
|
||||
{
|
||||
//adjust mouse position according to screenLT
|
||||
sEvent->motion.x -= screenLT.x;
|
||||
sEvent->motion.y -= screenLT.y;
|
||||
HLP::adjustMousePos(sEvent);
|
||||
|
||||
if(sEvent->button.button == SDL_BUTTON_LEFT)
|
||||
{
|
||||
@ -247,9 +253,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
||||
}
|
||||
else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_LEFT))
|
||||
{
|
||||
//adjust mouse position according to screenLT
|
||||
sEvent->motion.x -= screenLT.x;
|
||||
sEvent->motion.y -= screenLT.y;
|
||||
HLP::adjustMousePos(sEvent);
|
||||
|
||||
std::list<CIntObject*> hlp = lclickable;
|
||||
for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
|
||||
@ -267,9 +271,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
||||
}
|
||||
else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_RIGHT))
|
||||
{
|
||||
//adjust mouse position according to screenLT
|
||||
sEvent->motion.x -= screenLT.x;
|
||||
sEvent->motion.y -= screenLT.y;
|
||||
HLP::adjustMousePos(sEvent);
|
||||
|
||||
std::list<CIntObject*> hlp = rclickable;
|
||||
for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
|
||||
|
@ -1277,4 +1277,23 @@ void CSDL_Ext::blitSurface( SDL_Surface * src, SDL_Rect * srcRect, SDL_Surface *
|
||||
}
|
||||
}
|
||||
|
||||
void CSDL_Ext::fillRect( SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color )
|
||||
{
|
||||
SDL_Rect newRect;
|
||||
if (dstrect)
|
||||
{
|
||||
newRect = *dstrect;
|
||||
}
|
||||
else
|
||||
{
|
||||
newRect = Rect(0, 0, dst->w, dst->h);
|
||||
}
|
||||
if (dst == screen)
|
||||
{
|
||||
newRect.x += screenLT.x;
|
||||
newRect.y += screenLT.y;
|
||||
}
|
||||
SDL_FillRect(dst, &newRect, color);
|
||||
}
|
||||
|
||||
SDL_Surface * CSDL_Ext::std32bppSurface = NULL;
|
||||
|
@ -114,6 +114,7 @@ typedef void (*BlitterWithRotationVal)(SDL_Surface *src,SDL_Rect srcRect, SDL_Su
|
||||
namespace CSDL_Ext
|
||||
{
|
||||
void blitSurface(SDL_Surface * src, SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect);
|
||||
void fillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
|
||||
extern SDL_Surface * std32bppSurface;
|
||||
|
||||
void SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A = 255);
|
||||
|
Loading…
Reference in New Issue
Block a user