mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
* partially done support for resolutions smaller than 800x600 by screen scrolling
This commit is contained in:
parent
70a158ba55
commit
6b8718b046
@ -195,6 +195,8 @@ struct SettingsGrammar : public grammar<SettingsGrammar>
|
||||
fname = lexeme_d[+(alnum_p | '.')];
|
||||
clientOption
|
||||
= str_p("resolution=") >> (uint_p[assign_a(conf.cc.resx)] >> 'x' >> uint_p[assign_a(conf.cc.resy)] | eps_p[lerror("Wrong resolution!")])
|
||||
| str_p("pregameRes=") >> (uint_p[assign_a(conf.cc.pregameResx)] >> 'x' >> uint_p[assign_a(conf.cc.pregameResy)] | eps_p[lerror("Wrong pregame size!")])
|
||||
| str_p("screenSize=") >> (uint_p[assign_a(conf.cc.screenx)] >> 'x' >> uint_p[assign_a(conf.cc.screeny)] | eps_p[lerror("Wrong screen size!")])
|
||||
| str_p("port=") >> (uint_p[assign_a(conf.cc.port)] | eps_p[lerror("Wrong port!")])
|
||||
| str_p("bpp=") >> (uint_p[assign_a(conf.cc.bpp)] | eps_p[lerror("Wrong bpp!")])
|
||||
| str_p("localInformation=") >> (uint_p[assign_a(conf.cc.localInformation)] | eps_p[lerror("Wrong localInformation!")])
|
||||
|
@ -18,6 +18,8 @@ namespace config
|
||||
struct ClientConfig
|
||||
{
|
||||
int resx, resy, bpp, fullscreen; //client resolution/colours
|
||||
int screenx, screeny; //real screen resolution
|
||||
int pregameResx, pregameResy; //real screen resolution of preGame
|
||||
int port, localInformation;
|
||||
std::string server, //server address (e.g. 127.0.0.1)
|
||||
defaultAI; //dll name
|
||||
|
@ -57,17 +57,23 @@ void CCursorHandler::draw1()
|
||||
int x = xpos, y = ypos;
|
||||
shiftPos(x, y);
|
||||
SDL_BlitSurface(screen, &genRect(40,40,x,y), help, &genRect(40,40,0,0));
|
||||
// if (dndImage)
|
||||
// blitAt(dndImage, x - dndImage->w/2, y - dndImage->h/2);
|
||||
// else
|
||||
// blitAt(cursors[mode]->ourImages[number].bitmap,x,y);
|
||||
|
||||
if (dndImage)
|
||||
blitAt(dndImage, x - dndImage->w/2, y - dndImage->h/2);
|
||||
SDL_BlitSurface(dndImage, NULL, screen, &genRect(40, 40, x - dndImage->w/2, y - dndImage->h/2));
|
||||
else
|
||||
blitAt(cursors[mode]->ourImages[number].bitmap,x,y);
|
||||
SDL_BlitSurface(cursors[mode]->ourImages[number].bitmap, NULL, screen, &genRect(40,40,x,y));
|
||||
}
|
||||
void CCursorHandler::draw2()
|
||||
{
|
||||
if(!Show) return;
|
||||
int x = xpos, y = ypos;
|
||||
shiftPos(x, y);
|
||||
blitAt(help,x,y);
|
||||
SDL_BlitSurface(help, NULL, screen, &genRect(40, 40, x, y));
|
||||
//blitAt(help,x,y);
|
||||
}
|
||||
|
||||
void CCursorHandler::shiftPos( int &x, int &y )
|
||||
|
@ -71,8 +71,23 @@ static CClient *client;
|
||||
SDL_Surface *screen = NULL, //main screen surface
|
||||
*screen2 = NULL,//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
|
||||
int screenScrollingDir = 0; //used for displays smaller then selected resolution; 0 - no scrolling, & 1 - down, & 2 - up, & 4 - right, & 8 - left
|
||||
Point screenLT = Point(0, 0); //position of top left corner of the screen
|
||||
static boost::thread *mainGUIThread;
|
||||
|
||||
void updateScreenLT(int maxW, int maxH)
|
||||
{
|
||||
if (screenScrollingDir & 1) //down
|
||||
{
|
||||
screenLT.y = std::max<int>(screenLT.y - 5, screen->h - maxH);
|
||||
}
|
||||
else if (screenScrollingDir & 2) //up
|
||||
{
|
||||
screenLT.y = std::min<int>(screenLT.y + 5, 0);
|
||||
}
|
||||
GH.totalRedraw();
|
||||
}
|
||||
|
||||
SystemOptions GDefaultOptions;
|
||||
VCMIDirs GVCMIDirs;
|
||||
std::queue<SDL_Event*> events;
|
||||
@ -255,7 +270,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
atexit(SDL_Quit);
|
||||
|
||||
setScreenRes(800,600,conf.cc.bpp,conf.cc.fullscreen);
|
||||
setScreenRes(conf.cc.pregameResx, conf.cc.pregameResy, conf.cc.bpp, conf.cc.fullscreen);
|
||||
tlog0 <<"\tInitializing screen: "<<pomtime.getDif() << std::endl;
|
||||
|
||||
// Initialize video
|
||||
@ -606,6 +621,25 @@ static void listenForEvents()
|
||||
|
||||
delete ev;
|
||||
continue;
|
||||
} else if (ev->type == SDL_MOUSEMOTION)
|
||||
{
|
||||
if (conf.cc.resy > screen->h)
|
||||
{
|
||||
if (std::abs(ev->motion.y - screen->h) < 10 ) //scroll down
|
||||
{
|
||||
screenScrollingDir &= (~2);
|
||||
screenScrollingDir |= 1;
|
||||
}
|
||||
else if (std::abs(ev->motion.y) < 10) //scroll up
|
||||
{
|
||||
screenScrollingDir &= (~1);
|
||||
screenScrollingDir |= 2;
|
||||
}
|
||||
else //don't scroll vertically
|
||||
{
|
||||
screenScrollingDir &= (~3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//tlog0 << " pushing ";
|
||||
|
@ -105,7 +105,7 @@ SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) //draws box for
|
||||
{
|
||||
for (int j=0; j<w; j+=background->w)
|
||||
{
|
||||
SDL_BlitSurface(background,&genRect(background->h,background->w,0,0),ret,&genRect(h,w,j,i)); //FIXME taking address of temporary
|
||||
CSDL_Ext::blitSurface(background,&genRect(background->h,background->w,0,0),ret,&genRect(h,w,j,i)); //FIXME taking address of temporary
|
||||
}
|
||||
}
|
||||
drawBorder(playerColor, ret, w, h);
|
||||
@ -488,27 +488,27 @@ void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int
|
||||
//obwodka I-szego rzedu pozioma //border of 1st series, horizontal
|
||||
for (int i=0; i<w-piecesOfBox[playerColor][6]->w; i+=piecesOfBox[playerColor][6]->w)
|
||||
{
|
||||
SDL_BlitSurface
|
||||
CSDL_Ext::blitSurface
|
||||
(piecesOfBox[playerColor][6],NULL,ret,&genRect(piecesOfBox[playerColor][6]->h,piecesOfBox[playerColor][6]->w,x+i,y+0));
|
||||
SDL_BlitSurface
|
||||
CSDL_Ext::blitSurface
|
||||
(piecesOfBox[playerColor][7],NULL,ret,&genRect(piecesOfBox[playerColor][7]->h,piecesOfBox[playerColor][7]->w,x+i,y+h-piecesOfBox[playerColor][7]->h+1));
|
||||
}
|
||||
//obwodka I-szego rzedu pionowa //border of 1st series, vertical
|
||||
for (int i=0; i<h-piecesOfBox[playerColor][4]->h; i+=piecesOfBox[playerColor][4]->h)
|
||||
{
|
||||
SDL_BlitSurface
|
||||
CSDL_Ext::blitSurface
|
||||
(piecesOfBox[playerColor][4],NULL,ret,&genRect(piecesOfBox[playerColor][4]->h,piecesOfBox[playerColor][4]->w,x+0,y+i));
|
||||
SDL_BlitSurface
|
||||
CSDL_Ext::blitSurface
|
||||
(piecesOfBox[playerColor][5],NULL,ret,&genRect(piecesOfBox[playerColor][5]->h,piecesOfBox[playerColor][5]->w,x+w-piecesOfBox[playerColor][5]->w,y+i));
|
||||
}
|
||||
//corners
|
||||
SDL_BlitSurface
|
||||
CSDL_Ext::blitSurface
|
||||
(piecesOfBox[playerColor][0],NULL,ret,&genRect(piecesOfBox[playerColor][0]->h,piecesOfBox[playerColor][0]->w,x+0,y+0));
|
||||
SDL_BlitSurface
|
||||
CSDL_Ext::blitSurface
|
||||
(piecesOfBox[playerColor][1],NULL,ret,&genRect(piecesOfBox[playerColor][1]->h,piecesOfBox[playerColor][1]->w,x+w-piecesOfBox[playerColor][1]->w,y+0));
|
||||
SDL_BlitSurface
|
||||
CSDL_Ext::blitSurface
|
||||
(piecesOfBox[playerColor][2],NULL,ret,&genRect(piecesOfBox[playerColor][2]->h,piecesOfBox[playerColor][2]->w,x+0,y+h-piecesOfBox[playerColor][2]->h+1));
|
||||
SDL_BlitSurface
|
||||
CSDL_Ext::blitSurface
|
||||
(piecesOfBox[playerColor][3],NULL,ret,&genRect(piecesOfBox[playerColor][3]->h,piecesOfBox[playerColor][3]->w,x+w-piecesOfBox[playerColor][3]->w,y+h-piecesOfBox[playerColor][3]->h+1));
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,8 @@ namespace fs = boost::filesystem;
|
||||
using boost::bind;
|
||||
using boost::ref;
|
||||
|
||||
void updateScreenLT(int maxW, int maxH);
|
||||
|
||||
#if _MSC_VER >= 1600
|
||||
#define bind boost::bind
|
||||
#define ref boost::ref
|
||||
@ -301,6 +303,7 @@ void CGPreGame::update()
|
||||
CGI->curh->draw1();
|
||||
SDL_Flip(screen);
|
||||
CGI->curh->draw2();
|
||||
updateScreenLT(800, 600);
|
||||
GH.topInt()->show(screen);
|
||||
GH.updateTime();
|
||||
GH.handleEvents();
|
||||
|
@ -318,7 +318,7 @@ void CSpellWindow::fRcornerb()
|
||||
|
||||
void CSpellWindow::showAll(SDL_Surface *to)
|
||||
{
|
||||
SDL_BlitSurface(background, NULL, to, &pos);
|
||||
CSDL_Ext::blitSurface(background, NULL, to, &pos);
|
||||
blitAt(spellTab->ourImages[selectedTab].bitmap, 524 + pos.x, 88 + pos.y, to);
|
||||
|
||||
std::ostringstream mana;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
extern std::queue<SDL_Event*> events;
|
||||
extern boost::mutex eventsM;
|
||||
extern Point screenLT;
|
||||
|
||||
void KeyShortcut::keyPressed(const SDL_KeyboardEvent & key)
|
||||
{
|
||||
@ -177,10 +178,17 @@ 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;
|
||||
handleMouseMotion(sEvent);
|
||||
}
|
||||
else if (sEvent->type==SDL_MOUSEBUTTONDOWN)
|
||||
{
|
||||
//adjust mouse position according to screenLT
|
||||
sEvent->motion.x -= screenLT.x;
|
||||
sEvent->motion.y -= screenLT.y;
|
||||
|
||||
if(sEvent->button.button == SDL_BUTTON_LEFT)
|
||||
{
|
||||
|
||||
@ -239,6 +247,10 @@ 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;
|
||||
|
||||
std::list<CIntObject*> hlp = lclickable;
|
||||
for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
|
||||
{
|
||||
@ -255,6 +267,10 @@ 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;
|
||||
|
||||
std::list<CIntObject*> hlp = rclickable;
|
||||
for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
|
||||
{
|
||||
@ -602,19 +618,19 @@ CIntObject::~CIntObject()
|
||||
parent->children -= this;
|
||||
}
|
||||
|
||||
void CIntObject::printAtLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/, bool refresh /*= false*/ )
|
||||
void CIntObject::printAtLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ )
|
||||
{
|
||||
CSDL_Ext::printAt(text, pos.x + x, pos.y + y, font, kolor, dst, refresh);
|
||||
CSDL_Ext::printAt(text, pos.x + x, pos.y + y, font, kolor, dst);
|
||||
}
|
||||
|
||||
void CIntObject::printAtMiddleLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/, bool refresh /*= false*/ )
|
||||
void CIntObject::printAtMiddleLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ )
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(text, pos.x + x, pos.y + y, font, kolor, dst, refresh);
|
||||
CSDL_Ext::printAtMiddle(text, pos.x + x, pos.y + y, font, kolor, dst);
|
||||
}
|
||||
|
||||
void CIntObject::printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst, bool refresh /*= false*/)
|
||||
void CIntObject::printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst)
|
||||
{
|
||||
printAtMiddleLoc(text, p.x, p.y, font, kolor, dst, refresh);
|
||||
printAtMiddleLoc(text, p.x, p.y, font, kolor, dst);
|
||||
}
|
||||
|
||||
void CIntObject::blitAtLoc( SDL_Surface * src, int x, int y, SDL_Surface * dst )
|
||||
@ -627,14 +643,14 @@ void CIntObject::blitAtLoc(SDL_Surface * src, const Point &p, SDL_Surface * dst)
|
||||
blitAtLoc(src, p.x, p.y, dst);
|
||||
}
|
||||
|
||||
void CIntObject::printAtMiddleWBLoc( const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst, bool refrsh /*= false*/ )
|
||||
void CIntObject::printAtMiddleWBLoc( const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst)
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(text, pos.x + x, pos.y + y, font, charpr, kolor, dst, refrsh);
|
||||
CSDL_Ext::printAtMiddleWB(text, pos.x + x, pos.y + y, font, charpr, kolor, dst);
|
||||
}
|
||||
|
||||
void CIntObject::printToLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst, bool refresh /*= false*/ )
|
||||
void CIntObject::printToLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst )
|
||||
{
|
||||
CSDL_Ext::printTo(text, pos.x + x, pos.y + y, font, kolor, dst, refresh);
|
||||
CSDL_Ext::printTo(text, pos.x + x, pos.y + y, font, kolor, dst);
|
||||
}
|
||||
|
||||
void CIntObject::disable()
|
||||
@ -843,7 +859,7 @@ void CPicture::showAll( SDL_Surface * to )
|
||||
dstRect.x = pos.x;
|
||||
dstRect.y = pos.y;
|
||||
|
||||
SDL_BlitSurface(bg, &srcRectCpy, to, &dstRect);
|
||||
CSDL_Ext::blitSurface(bg, &srcRectCpy, to, &dstRect);
|
||||
}
|
||||
else
|
||||
blitAt(bg, pos, to);
|
||||
|
@ -388,11 +388,11 @@ public:
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
|
||||
void printAtLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst, bool refresh = false);
|
||||
void printToLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst, bool refresh = false);
|
||||
void printAtMiddleLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst, bool refresh = false);
|
||||
void printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst, bool refresh = false);
|
||||
void printAtMiddleWBLoc(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst, bool refrsh = false);
|
||||
void printAtLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printToLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printAtMiddleLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printAtMiddleWBLoc(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst);
|
||||
void blitAtLoc(SDL_Surface * src, int x, int y, SDL_Surface * dst);
|
||||
void blitAtLoc(SDL_Surface * src, const Point &p, SDL_Surface * dst);
|
||||
bool isItInLoc(const SDL_Rect &rect, int x, int y);
|
||||
|
@ -349,7 +349,7 @@ void CGarrisonSlot::show(SDL_Surface * to)
|
||||
pos1.x = owner->surOffset.x+ pos.x-owner->pos.x;
|
||||
pos1.y = owner->surOffset.y+ pos.y-owner->pos.y;
|
||||
|
||||
SDL_BlitSurface(owner->sur,&pos1,to,&pos2);
|
||||
CSDL_Ext::blitSurface(owner->sur,&pos1,to,&pos2);
|
||||
if(owner->splitting && owner->highlighted->our())
|
||||
blitAt(imgs[-1],pos,to);
|
||||
}
|
||||
@ -1179,7 +1179,7 @@ void CStatusBar::print(const std::string & text)
|
||||
void CStatusBar::show(SDL_Surface * to)
|
||||
{
|
||||
SDL_Rect pom = genRect(pos.h,pos.w,pos.x,pos.y);
|
||||
SDL_BlitSurface(bg,&genRect(pos.h,pos.w,0,0),to,&pom);
|
||||
CSDL_Ext::blitSurface(bg,&genRect(pos.h,pos.w,0,0),to,&pom);
|
||||
printAtMiddle(current,middlex,middley,FONT_SMALL,zwykly,to);
|
||||
}
|
||||
|
||||
@ -1261,7 +1261,7 @@ void CHeroList::init()
|
||||
{
|
||||
int w = pos.w+1, h = pos.h+4;
|
||||
bg = CSDL_Ext::newSurface(w,h,screen);
|
||||
SDL_BlitSurface(adventureInt->bg,&genRect(w,h,pos.x,pos.y),bg,&genRect(w,h,0,0));
|
||||
CSDL_Ext::blitSurface(adventureInt->bg,&genRect(w,h,pos.x,pos.y),bg,&genRect(w,h,0,0));
|
||||
}
|
||||
|
||||
void CHeroList::genList()
|
||||
@ -4121,7 +4121,7 @@ void CSystemOptionsWindow::deactivate()
|
||||
|
||||
void CSystemOptionsWindow::show(SDL_Surface *to)
|
||||
{
|
||||
SDL_BlitSurface(background, NULL, to, &pos);
|
||||
CSDL_Ext::blitSurface(background, NULL, to, &pos);
|
||||
|
||||
save->show(to);
|
||||
quitGame->show(to);
|
||||
@ -6547,8 +6547,8 @@ void CLabel::showAll(SDL_Surface * to)
|
||||
if(!toPrint.length())
|
||||
return;
|
||||
|
||||
static void (*printer[3])(const std::string &, int, int, EFonts, SDL_Color, SDL_Surface *, bool) = {&CSDL_Ext::printAt, &CSDL_Ext::printAtMiddle, &CSDL_Ext::printTo}; //array of printing functions
|
||||
printer[alignment](toPrint, pos.x + textOffset.x, pos.y + textOffset.y, font, color, to, false);
|
||||
static void (*printer[3])(const std::string &, int, int, EFonts, SDL_Color, SDL_Surface *) = {&CSDL_Ext::printAt, &CSDL_Ext::printAtMiddle, &CSDL_Ext::printTo}; //array of printing functions
|
||||
printer[alignment](toPrint, pos.x + textOffset.x, pos.y + textOffset.y, font, color, to);
|
||||
}
|
||||
|
||||
CLabel::CLabel(int x, int y, EFonts Font /*= FONT_SMALL*/, EAlignment Align, const SDL_Color &Color /*= zwykly*/, const std::string &Text /*= ""*/)
|
||||
@ -6760,7 +6760,7 @@ CTextInput::CTextInput(const Rect &Pos, SDL_Surface *srf)
|
||||
OBJ_CONSTRUCTION;
|
||||
bg = new CPicture(Pos, 0, true);
|
||||
Rect hlp = Pos;
|
||||
SDL_BlitSurface(srf, &hlp, *bg, NULL);
|
||||
CSDL_Ext::blitSurface(srf, &hlp, *bg, NULL);
|
||||
pos.w = bg->pos.w;
|
||||
pos.h = bg->pos.h;
|
||||
bg->pos = pos;
|
||||
|
@ -22,6 +22,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern Point screenLT;
|
||||
|
||||
template<int bpp, int incrementPtr>
|
||||
STRONG_INLINE void ColorPutter<bpp, incrementPtr>::PutColorAlpha(Uint8 *&ptr, const SDL_Color & Color)
|
||||
@ -180,23 +181,11 @@ bool isItIn(const SDL_Rect * rect, int x, int y)
|
||||
else return false;
|
||||
}
|
||||
|
||||
void blitAtWR(SDL_Surface * src, int x, int y, SDL_Surface * dst)
|
||||
{
|
||||
SDL_Rect pom = genRect(src->h,src->w,x,y);
|
||||
SDL_BlitSurface(src,NULL,dst,&pom);
|
||||
SDL_UpdateRect(dst,x,y,src->w,src->h);
|
||||
}
|
||||
|
||||
void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst)
|
||||
{
|
||||
if(!dst) dst = screen;
|
||||
SDL_Rect pom = genRect(src->h,src->w,x,y);
|
||||
SDL_BlitSurface(src,NULL,dst,&pom);
|
||||
}
|
||||
|
||||
void blitAtWR(SDL_Surface * src, const SDL_Rect & pos, SDL_Surface * dst)
|
||||
{
|
||||
blitAtWR(src,pos.x,pos.y,dst);
|
||||
CSDL_Ext::blitSurface(src,NULL,dst,&pom);
|
||||
}
|
||||
|
||||
void blitAt(SDL_Surface * src, const SDL_Rect & pos, SDL_Surface * dst)
|
||||
@ -268,7 +257,7 @@ void printAtWB(const std::string & text, int x, int y, TTF_Font * font, int char
|
||||
SDL_FreeSurface(wesu[i]);
|
||||
}
|
||||
|
||||
void CSDL_Ext::printAtWB(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst, bool refresh)
|
||||
void CSDL_Ext::printAtWB(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst)
|
||||
{
|
||||
if (graphics->fontsTrueType[font])
|
||||
{
|
||||
@ -281,13 +270,13 @@ void CSDL_Ext::printAtWB(const std::string & text, int x, int y, EFonts font, in
|
||||
int cury = y;
|
||||
for (size_t i=0; i < ws.size(); ++i)
|
||||
{
|
||||
printAt(ws[i], x, cury, font, kolor, dst, refresh);
|
||||
printAt(ws[i], x, cury, font, kolor, dst);
|
||||
cury += f->height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSDL_Ext::printAtMiddleWB( const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor/*=tytulowy*/, SDL_Surface * dst/*=screen*/, bool refrsh /*= false*/ )
|
||||
void CSDL_Ext::printAtMiddleWB( const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor/*=tytulowy*/, SDL_Surface * dst/*=screen*/ )
|
||||
{
|
||||
if (graphics->fontsTrueType[font])
|
||||
{
|
||||
@ -302,12 +291,12 @@ void CSDL_Ext::printAtMiddleWB( const std::string & text, int x, int y, EFonts f
|
||||
int cury = y - totalHeight/2;
|
||||
for (size_t i=0; i < ws.size(); ++i)
|
||||
{
|
||||
printAt(ws[i], x - f->getWidth(ws[i].c_str())/2, cury, font, kolor, dst, refrsh);
|
||||
printAt(ws[i], x - f->getWidth(ws[i].c_str())/2, cury, font, kolor, dst);
|
||||
cury += f->height;
|
||||
}
|
||||
}
|
||||
|
||||
void printAtMiddle(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2, bool refresh=false)
|
||||
void printAtMiddle(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2)
|
||||
{
|
||||
if(text.length()==0) return;
|
||||
SDL_Surface * temp;
|
||||
@ -331,13 +320,11 @@ void printAtMiddle(const std::string & text, int x, int y, TTF_Font * font, SDL_
|
||||
temp = TTF_RenderText_Blended(font,text.c_str(),kolor);
|
||||
break;
|
||||
}
|
||||
SDL_BlitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x-(temp->w/2),y-(temp->h/2)));
|
||||
if(refresh)
|
||||
SDL_UpdateRect(dst,x-(temp->w/2),y-(temp->h/2),temp->w,temp->h);
|
||||
CSDL_Ext::blitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x-(temp->w/2),y-(temp->h/2)));
|
||||
SDL_FreeSurface(temp);
|
||||
}
|
||||
|
||||
void CSDL_Ext::printAtMiddle( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/, bool refresh /*= false*/ )
|
||||
void CSDL_Ext::printAtMiddle( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ )
|
||||
{
|
||||
if (graphics->fontsTrueType[font])
|
||||
{
|
||||
@ -348,7 +335,7 @@ void CSDL_Ext::printAtMiddle( const std::string & text, int x, int y, EFonts fon
|
||||
int nx = x - f->getWidth(text.c_str())/2,
|
||||
ny = y - f->height/2;
|
||||
|
||||
printAt(text, nx, ny, font, kolor, dst, refresh);
|
||||
printAt(text, nx, ny, font, kolor, dst);
|
||||
}
|
||||
|
||||
void printAt(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2, bool refresh=false)
|
||||
@ -376,7 +363,7 @@ void printAt(const std::string & text, int x, int y, TTF_Font * font, SDL_Color
|
||||
temp = TTF_RenderText_Blended(font,text.c_str(),kolor);
|
||||
break;
|
||||
}
|
||||
SDL_BlitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x,y));
|
||||
CSDL_Ext::blitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x,y));
|
||||
if(refresh)
|
||||
SDL_UpdateRect(dst,x,y,temp->w,temp->h);
|
||||
SDL_FreeSurface(temp);
|
||||
@ -384,10 +371,18 @@ void printAt(const std::string & text, int x, int y, TTF_Font * font, SDL_Color
|
||||
|
||||
|
||||
|
||||
void CSDL_Ext::printAt( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/, bool refresh /*= false*/ )
|
||||
void CSDL_Ext::printAt( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ )
|
||||
{
|
||||
if(!text.size())
|
||||
return;
|
||||
|
||||
//adjust x and y
|
||||
if (dst == screen)
|
||||
{
|
||||
x += screenLT.x;
|
||||
y += screenLT.y;
|
||||
}
|
||||
|
||||
if (graphics->fontsTrueType[font])
|
||||
{
|
||||
printAt(text,x, y, graphics->fontsTrueType[font], kolor, dst);
|
||||
@ -417,14 +412,14 @@ void CSDL_Ext::printAt( const std::string & text, int x, int y, EFonts font, SDL
|
||||
const unsigned char c = text[txti];
|
||||
x += f->chars[c].unknown1;
|
||||
|
||||
for(int i = 0; i < f->height && (y + i) < (dst->h - 1); i++)
|
||||
for(int i = std::max(0, -y); i < f->height && (y + i) < (dst->h - 1); i++)
|
||||
{
|
||||
px = (Uint8*)dst->pixels;
|
||||
px += (y+i) * dst->pitch + x * bpp;
|
||||
src = f->chars[c].pixels;
|
||||
src += i * f->chars[c].width;//if we have reached end of surface in previous line
|
||||
|
||||
for(int j = 0; j < f->chars[c].width && (j + x) < (dst->w - 1); j++)
|
||||
for(int j = std::max(0, -x); j < f->chars[c].width && (j + x) < (dst->w - 1); j++)
|
||||
{
|
||||
switch(*src)
|
||||
{
|
||||
@ -443,11 +438,6 @@ void CSDL_Ext::printAt( const std::string & text, int x, int y, EFonts font, SDL
|
||||
x += f->chars[c].width;
|
||||
x += f->chars[c].unknown2;
|
||||
}
|
||||
|
||||
if(refresh)
|
||||
{
|
||||
SDL_UpdateRect(dst, x, y, f->getWidth(text.c_str()), f->height);
|
||||
}
|
||||
}
|
||||
|
||||
void printTo(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2)
|
||||
@ -475,12 +465,12 @@ void printTo(const std::string & text, int x, int y, TTF_Font * font, SDL_Color
|
||||
temp = TTF_RenderText_Blended(font,text.c_str(),kolor);
|
||||
break;
|
||||
}
|
||||
SDL_BlitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x-temp->w,y-temp->h));
|
||||
CSDL_Ext::blitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x-temp->w,y-temp->h));
|
||||
SDL_UpdateRect(dst,x-temp->w,y-temp->h,temp->w,temp->h);
|
||||
SDL_FreeSurface(temp);
|
||||
}
|
||||
|
||||
void CSDL_Ext::printTo( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/, bool refresh /*= false*/ )
|
||||
void CSDL_Ext::printTo( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ )
|
||||
{
|
||||
if (graphics->fontsTrueType[font])
|
||||
{
|
||||
@ -488,7 +478,7 @@ void CSDL_Ext::printTo( const std::string & text, int x, int y, EFonts font, SDL
|
||||
return;
|
||||
}
|
||||
const Font *f = graphics->fonts[font];
|
||||
printAt(text, x - f->getWidth(text.c_str()), y - f->height, font, kolor, dst, refresh);
|
||||
printAt(text, x - f->getWidth(text.c_str()), y - f->height, font, kolor, dst);
|
||||
}
|
||||
|
||||
void printToWR(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality=2)
|
||||
@ -516,23 +506,10 @@ void printToWR(const std::string & text, int x, int y, TTF_Font * font, SDL_Colo
|
||||
temp = TTF_RenderText_Blended(font,text.c_str(),kolor);
|
||||
break;
|
||||
}
|
||||
SDL_BlitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x-temp->w,y-temp->h));
|
||||
CSDL_Ext::blitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x-temp->w,y-temp->h));
|
||||
SDL_FreeSurface(temp);
|
||||
}
|
||||
|
||||
void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A)
|
||||
{
|
||||
Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel;
|
||||
|
||||
p[0] = B;
|
||||
p[1] = G;
|
||||
p[2] = R;
|
||||
if(ekran->format->BytesPerPixel==4)
|
||||
p[3] = A;
|
||||
|
||||
SDL_UpdateRect(ekran, x, y, 1, 1);
|
||||
}
|
||||
|
||||
// Vertical flip
|
||||
SDL_Surface * CSDL_Ext::rotate01(SDL_Surface * toRot)
|
||||
{
|
||||
@ -698,7 +675,7 @@ void CSDL_Ext::blitWithRotateClip(SDL_Surface *src,SDL_Rect * srcRect, SDL_Surfa
|
||||
static void (*blitWithRotate[])(const SDL_Surface *, const SDL_Rect *, SDL_Surface *, const SDL_Rect *) = {blitWithRotate1<bpp>, blitWithRotate2<bpp>, blitWithRotate3<bpp>};
|
||||
if(!rotation)
|
||||
{
|
||||
SDL_BlitSurface(src, srcRect, dst, dstRect);
|
||||
CSDL_Ext::blitSurface(src, srcRect, dst, dstRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1275,5 +1252,29 @@ void CSDL_Ext::applyEffect( SDL_Surface * surf, const SDL_Rect * rect, int mode
|
||||
}
|
||||
}
|
||||
|
||||
void CSDL_Ext::blitSurface( SDL_Surface * src, SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect )
|
||||
{
|
||||
if (dst != screen)
|
||||
{
|
||||
SDL_BlitSurface(src, srcRect, dst, dstRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Rect betterDst;
|
||||
if (dstRect)
|
||||
{
|
||||
betterDst = *dstRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
betterDst = Rect(0, 0, dst->w, dst->h);
|
||||
}
|
||||
|
||||
betterDst.x += screenLT.x;
|
||||
betterDst.y += screenLT.y;
|
||||
|
||||
SDL_BlitSurface(src, srcRect, dst, &betterDst);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Surface * CSDL_Ext::std32bppSurface = NULL;
|
||||
|
@ -31,9 +31,7 @@ struct Rect;
|
||||
|
||||
extern SDL_Surface * screen, *screen2, *screenBuf;
|
||||
extern SDL_Color tytulowy, tlo, zwykly ;
|
||||
void blitAtWR(SDL_Surface * src, int x, int y, SDL_Surface * dst=screen);
|
||||
void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst=screen);
|
||||
void blitAtWR(SDL_Surface * src, const SDL_Rect & pos, SDL_Surface * dst=screen);
|
||||
void blitAt(SDL_Surface * src, const SDL_Rect & pos, SDL_Surface * dst=screen);
|
||||
void updateRect (SDL_Rect * rect, SDL_Surface * scr = screen);
|
||||
bool isItIn(const SDL_Rect * rect, int x, int y);
|
||||
@ -115,12 +113,12 @@ 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);
|
||||
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);
|
||||
void SDL_PutPixelWithoutRefreshIfInSurf(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A = 255);
|
||||
|
||||
void SDL_PutPixel(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A = 255); //myC influences the start of reading pixels
|
||||
SDL_Surface * rotate01(SDL_Surface * toRot); //vertical flip
|
||||
SDL_Surface * hFlip(SDL_Surface * toRot); //horizontal flip
|
||||
SDL_Surface * rotate02(SDL_Surface * toRot); //rotate 90 degrees left
|
||||
@ -156,11 +154,11 @@ namespace CSDL_Ext
|
||||
int blit8bppAlphaTo24bpp(const SDL_Surface * src, const SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect); //blits 8 bpp surface with alpha channel to 24 bpp surface
|
||||
Uint32 colorToUint32(const SDL_Color * color); //little endian only
|
||||
|
||||
void printAtWB(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor=zwykly, SDL_Surface * dst=screen, bool refresh = false);
|
||||
void printAt(const std::string & text, int x, int y, EFonts font, SDL_Color kolor=zwykly, SDL_Surface * dst=screen, bool refresh = false);
|
||||
void printTo(const std::string & text, int x, int y, EFonts font, SDL_Color kolor=zwykly, SDL_Surface * dst=screen, bool refresh = false);
|
||||
void printAtMiddle(const std::string & text, int x, int y, EFonts font, SDL_Color kolor=zwykly, SDL_Surface * dst=screen, bool refresh = false);
|
||||
void printAtMiddleWB(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor=tytulowy, SDL_Surface * dst=screen, bool refrsh = false);
|
||||
void printAtWB(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor=zwykly, SDL_Surface * dst=screen);
|
||||
void printAt(const std::string & text, int x, int y, EFonts font, SDL_Color kolor=zwykly, SDL_Surface * dst=screen);
|
||||
void printTo(const std::string & text, int x, int y, EFonts font, SDL_Color kolor=zwykly, SDL_Surface * dst=screen);
|
||||
void printAtMiddle(const std::string & text, int x, int y, EFonts font, SDL_Color kolor=zwykly, SDL_Surface * dst=screen);
|
||||
void printAtMiddleWB(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor=tytulowy, SDL_Surface * dst=screen);
|
||||
|
||||
void update(SDL_Surface * what = screen); //updates whole surface (default - main screen)
|
||||
void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color);
|
||||
|
@ -4,6 +4,8 @@ clientSettings
|
||||
{
|
||||
port=3030;
|
||||
resolution=800x600; // format: WxH
|
||||
pregameRes=800x600; //WxH
|
||||
screenSize=800x600; //WxH
|
||||
bpp=24; // bits per pixels: 16, 24 or 32
|
||||
fullscreen=0; //0 - windowed mode, 1 - fullscreen
|
||||
server=127.0.0.1; //use 127.0.0.1 for localhost
|
||||
|
@ -341,7 +341,7 @@ int CSmackPlayer::frameCount() const
|
||||
|
||||
void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update )
|
||||
{
|
||||
int w = data->width, h = data->height;
|
||||
int w = std::min<int>(data->width, dst->w - x), h = std::min<int>(data->height, dst->h - y);
|
||||
/* Lock the screen for direct access to the pixels */
|
||||
if ( SDL_MUSTLOCK(dst) )
|
||||
{
|
||||
@ -819,7 +819,7 @@ void CVideoPlayer::show( int x, int y, SDL_Surface *dst, bool update )
|
||||
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
SDL_BlitSurface(dest, &destRect, dst, &pos);
|
||||
CSDL_Ext::blitSurface((dest, &destRect, dst, &pos);
|
||||
|
||||
if (update)
|
||||
SDL_UpdateRect(dst, pos.x, pos.y, pos.w, pos.h);
|
||||
|
Loading…
Reference in New Issue
Block a user