diff --git a/CAdvmapInterface.cpp b/CAdvmapInterface.cpp index 0f7d5d697..6268465e1 100644 --- a/CAdvmapInterface.cpp +++ b/CAdvmapInterface.cpp @@ -1036,6 +1036,7 @@ endTurn(CGI->generaltexth->zelp[302].first,CGI->generaltexth->zelp[302].second, heroList(ADVOPT.hlistSize), townList(ADVOPT.tlistSize,ADVOPT.tlistX,ADVOPT.tlistY,ADVOPT.tlistAU,ADVOPT.tlistAD)//(5,&genRect(192,48,747,196),747,196,747,372), { + subInt = NULL; selection = NULL; townList.fun = boost::bind(&CAdvMapInt::selectionChanged,this); LOCPLINT->adventureInt=this; @@ -1110,7 +1111,7 @@ void CAdvMapInt::fshowSpellbok() LOCPLINT->curint->deactivate(); - CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, 90, 2), ((const CGHeroInstance*)LOCPLINT->adventureInt->selection)); + CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), ((const CGHeroInstance*)LOCPLINT->adventureInt->selection)); spellWindow->activate(); LOCPLINT->objsToBlit.push_back(spellWindow); } diff --git a/CBattleInterface.cpp b/CBattleInterface.cpp index a7b611440..e28063c3c 100644 --- a/CBattleInterface.cpp +++ b/CBattleInterface.cpp @@ -15,6 +15,7 @@ #include "client/CCreatureAnimation.h" #include "client/Graphics.h" #include "client/CSpellWindow.h" +#include "client/CConfigHandler.h" #include #include #include "lib/CondSh.h" @@ -344,6 +345,9 @@ void CBattleInterface::show(SDL_Surface * to) if(!to) //"evaluating" to to = screen; + SDL_Rect buf; + SDL_GetClipRect(to, &buf); + SDL_SetClipRect(to, &pos); //printing background and hexes if(activeStack != -1 && creAnims[activeStack]->getType() != 0) //show everything with range { @@ -489,7 +493,8 @@ void CBattleInterface::show(SDL_Surface * to) std::vector< std::list::iterator > toErase; for(std::list::iterator it = battleEffects.begin(); it!=battleEffects.end(); ++it) { - blitAt(it->anim->ourImages[(it->frame)%it->anim->ourImages.size()].bitmap, it->x + pos.x, it->y + pos.y, to); + SDL_Surface * bitmapToBlit = it->anim->ourImages[(it->frame)%it->anim->ourImages.size()].bitmap; + SDL_BlitSurface(bitmapToBlit, NULL, to, &genRect(bitmapToBlit->h, bitmapToBlit->w, pos.x + it->x, pos.y + it->y)); ++(it->frame); if(it->frame == it->maxFrame) @@ -559,6 +564,7 @@ void CBattleInterface::show(SDL_Surface * to) { resWindow->show(to); } + SDL_SetClipRect(to, &buf); //restoring previous clip_rect } void CBattleInterface::keyPressed(const SDL_KeyboardEvent & key) { @@ -773,7 +779,7 @@ void CBattleInterface::bSpellf() chi = attackingHeroInstance; else chi = defendingHeroInstance; - CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, 90, 2), chi); + CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), chi); spellWindow->activate(); LOCPLINT->objsToBlit.push_back(spellWindow); } @@ -1451,6 +1457,9 @@ void CBattleInterface::spellCasted(SpellCasted * sc) int dx = (destcoord.first - srccoord.first - animDef->ourImages[0].bitmap->w)/steps, dy = (destcoord.second - srccoord.second - animDef->ourImages[0].bitmap->h)/steps; + SDL_Rect buf; + SDL_GetClipRect(screen, &buf); + SDL_SetClipRect(screen, &pos); //setting rect we can blit to for(int g=0; gmainFPSmng); } + SDL_SetClipRect(screen, &buf); //restoring previous clip rect int b=0; //TODO use me break; //for 15 and 16 cases @@ -2009,7 +2019,7 @@ void CBattleHero::clickLeft(boost::logic::tribool down) CGI->curh->changeGraphic(0,0); LOCPLINT->curint->deactivate(); - CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, 90, 2), myHero); + CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), myHero); spellWindow->activate(); LOCPLINT->objsToBlit.push_back(spellWindow); } diff --git a/CHeroWindow.cpp b/CHeroWindow.cpp index aa6c2f2b2..926680f1f 100644 --- a/CHeroWindow.cpp +++ b/CHeroWindow.cpp @@ -11,6 +11,7 @@ #include "client/CBitmapHandler.h" #include "client/Graphics.h" #include "client/CSpellWindow.h" +#include "client/CConfigHandler.h" #include "global.h" #include "hch/CAbilityHandler.h" #include "hch/CArtHandler.h" @@ -24,6 +25,7 @@ #include #include #include + extern SDL_Surface * screen; extern TTF_Font * GEOR16; using namespace boost::assign; @@ -697,7 +699,7 @@ void CArtPlace::clickLeft(boost::logic::tribool down) { ourWindow->deactivate(); - CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, 90, 2), ourWindow->curHero); + CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), ourWindow->curHero); spellWindow->activate(); LOCPLINT->objsToBlit.push_back(spellWindow); } diff --git a/CMT.cpp b/CMT.cpp index 96859c420..1e30d06c9 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -82,7 +82,6 @@ int main(int argc, char** argv) CPG=NULL; atexit(SDL_Quit); CGameInfo * cgi = CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler itp.) - if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO)==0) { screen = SDL_SetVideoMode(conf.cc.resx,conf.cc.resy,conf.cc.bpp,SDL_SWSURFACE|SDL_DOUBLEBUF|(conf.cc.fullscreen?SDL_FULLSCREEN:0)); //initializing important global surface @@ -106,7 +105,7 @@ int main(int argc, char** argv) THC tlog0<<"\tInitializing fonts: "<initMusics(); - //audio initialized + //audio initialized cgi->mush = mush; tlog0<<"\tInitializing sound: "<mush = mush; StartInfo *options = new StartInfo(cpg->runLoop()); @@ -214,23 +213,20 @@ int main(int argc, char** argv) tlog0 << "Ending...\n"; exit(EXIT_SUCCESS); } - //else if(ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4) - //{ - // LOCPLINT->pim->lock(); - // screen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, screen->h, screen->format->BitsPerPixel, rmask, gmask, bmask, amask); - // SDL_SaveBMP(screen,"scra"); - // SDL_SaveBMP(screen2,"scr2a"); - // int hlp = SDL_BlitSurface(screen,0,screen2,0); - // SDL_SaveBMP(screen2,"scr2b"); - // screen = SDL_SetVideoMode(screen->w,screen->h,screen->format->BitsPerPixel, - // SDL_SWSURFACE|SDL_DOUBLEBUF|((screen->flags&SDL_FULLSCREEN) ? 0 : SDL_FULLSCREEN)); - // SDL_SaveBMP(screen,"scrb"); - // SDL_BlitSurface(screen2,0,screen,0); - // SDL_SaveBMP(screen,"scrc"); - // SDL_FreeSurface(screen2); - // SDL_Flip(screen); - // LOCPLINT->pim->unlock(); - //} + else if(ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4) + { + LOCPLINT->pim->lock(); + screen = SDL_SetVideoMode(screen->w,screen->h,screen->format->BitsPerPixel, + SDL_SWSURFACE|SDL_DOUBLEBUF|((screen->flags&SDL_FULLSCREEN) ? 0 : SDL_FULLSCREEN)); + LOCPLINT->curint->show(); + if(LOCPLINT->curint != LOCPLINT->adventureInt) + LOCPLINT->adventureInt->show(); + if(LOCPLINT->curint == LOCPLINT->castleInt) + LOCPLINT->castleInt->showAll(0,true); + if(LOCPLINT->curint->subInt) + LOCPLINT->curint->subInt->show(); + LOCPLINT->pim->unlock(); + } eventsM.lock(); events.push(ev); eventsM.unlock(); diff --git a/client/CSpellWindow.cpp b/client/CSpellWindow.cpp index 1ce5c59f3..5fdfbf4cb 100644 --- a/client/CSpellWindow.cpp +++ b/client/CSpellWindow.cpp @@ -218,34 +218,34 @@ CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHer - statusBar = new CStatusBar(97, 571, "Spelroll.bmp"); - SDL_Rect temp_rect = genRect(45, 35, 569, 407); + statusBar = new CStatusBar(7 + pos.x, 569 + pos.y, "Spelroll.bmp"); + SDL_Rect temp_rect = genRect(45, 35, 479 + pos.x, 405 + pos.y); exitBtn = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fexitb, this), CGI->generaltexth->zelp[460].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[460].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(45, 35, 311, 407); + temp_rect = genRect(45, 35, 221 + pos.x, 405 + pos.y); battleSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fbattleSpellsb, this), CGI->generaltexth->zelp[453].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[453].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(45, 35, 445, 407); + temp_rect = genRect(45, 35, 355 + pos.x, 405 + pos.y); adventureSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fadvSpellsb, this), CGI->generaltexth->zelp[452].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[452].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(45, 35, 508, 407); + temp_rect = genRect(45, 35, 418 + pos.x, 405 + pos.y); manaPoints = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fmanaPtsb, this), CGI->generaltexth->zelp[459].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[459].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(36, 56, 639, 96); + temp_rect = genRect(36, 56, 549 + pos.x, 94 + pos.y); selectSpellsA = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsAb, this), CGI->generaltexth->zelp[454].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[454].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(36, 56, 639, 153); + temp_rect = genRect(36, 56, 549 + pos.x, 151 + pos.y); selectSpellsE = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsEb, this), CGI->generaltexth->zelp[457].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[457].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(36, 56, 639, 212); + temp_rect = genRect(36, 56, 549 + pos.x, 210 + pos.y); selectSpellsF = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsFb, this), CGI->generaltexth->zelp[455].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[455].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(36, 56, 639, 272); + temp_rect = genRect(36, 56, 549 + pos.x, 270 + pos.y); selectSpellsW = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsWb, this), CGI->generaltexth->zelp[456].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[456].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(36, 56, 639, 332); + temp_rect = genRect(36, 56, 549 + pos.x, 330 + pos.y); selectSpellsAll = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsAllb, this), CGI->generaltexth->zelp[458].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[458].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(leftCorner->h, leftCorner->w, 187, 79); + temp_rect = genRect(leftCorner->h, leftCorner->w, 97 + pos.x, 77 + pos.y); lCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fLcornerb, this), CGI->generaltexth->zelp[450].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[450].first)), boost::bind(&CStatusBar::clear, statusBar)); - temp_rect = genRect(rightCorner->h, rightCorner->w, 577, 76); + temp_rect = genRect(rightCorner->h, rightCorner->w, 487 + pos.x, 72 + pos.y); rCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fRcornerb, this), CGI->generaltexth->zelp[451].second, boost::bind(&CStatusBar::print, statusBar, (CGI->generaltexth->zelp[451].first)), boost::bind(&CStatusBar::clear, statusBar)); //areas for spells - int xpos = 207, ypos = 92; + int xpos = 117 + pos.x, ypos = 90 + pos.y; for(int v=0; v<12; ++v) { @@ -254,7 +254,7 @@ CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHer if(v == 5) //to right page { - xpos = 426; ypos = 92; + xpos = 336 + pos.x; ypos = 90 + pos.y; } else { @@ -393,14 +393,14 @@ void CSpellWindow::show(SDL_Surface *to) to = screen; SDL_BlitSurface(background, NULL, to, &pos); - blitAt(spellTab->ourImages[selectedTab].bitmap, 614, 96, to); + blitAt(spellTab->ourImages[selectedTab].bitmap, 524 + pos.x, 94 + pos.y, to); statusBar->show(); //printing school images if(selectedTab!=4 && spellSite == 0) { - blitAt(schools->ourImages[selectedTab].bitmap, 207, 76, to); + blitAt(schools->ourImages[selectedTab].bitmap, 117 + pos.x, 74 + pos.y, to); } //printing corners diff --git a/mapHandler.cpp b/mapHandler.cpp index 667bdb5bb..81ef22e3e 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -199,7 +199,7 @@ void CMapHandler::roadsRiverTerrainInit() } for (int i=0-Woff;imh->map->height+Hoff;j++) + for (int j=0-Hoff;j<(int)CGI->mh->map->height+Hoff;j++) ttiles[i][j].resize(CGI->mh->map->twoLevel+1,0); }