浏览代码

* our changes
* centered spellBook
* magic arrow animation fits battle window
* preventing different battle animations from getting out of appropriate rect

mateuszb 17 年之前
父节点
当前提交
fa11c06bdc
共有 6 个文件被更改,包括 51 次插入42 次删除
  1. 2 1
      CAdvmapInterface.cpp
  2. 13 3
      CBattleInterface.cpp
  3. 3 1
      CHeroWindow.cpp
  4. 16 20
      CMT.cpp
  5. 16 16
      client/CSpellWindow.cpp
  6. 1 1
      mapHandler.cpp

+ 2 - 1
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);
 }

+ 13 - 3
CBattleInterface.cpp

@@ -15,6 +15,7 @@
 #include "client/CCreatureAnimation.h"
 #include "client/Graphics.h"
 #include "client/CSpellWindow.h"
+#include "client/CConfigHandler.h"
 #include <queue>
 #include <sstream>
 #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<SBattleEffect>::iterator > toErase;
 		for(std::list<SBattleEffect>::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; g<steps; ++g)
 			{
 				show();
@@ -1460,6 +1469,7 @@ void CBattleInterface::spellCasted(SpellCasted * sc)
 				CSDL_Ext::update();
 				SDL_framerateDelay(LOCPLINT->mainFPSmng);
 			}
+			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);
 	}

+ 3 - 1
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 <boost/assign/std/vector.hpp>
 #include <cstdlib>
 #include <sstream>
+
 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);
 		}

+ 16 - 20
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: "<<pomtime.getDif()<<std::endl;
 		CMusicHandler * mush = new CMusicHandler;  //initializing audio
 		mush->initMusics();
-		//audio initialized 
+		//audio initialized
 		cgi->mush = mush;
 		tlog0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
 		tlog0<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
@@ -149,7 +148,7 @@ int main(int argc, char** argv)
 		tlog0<<"Message handler: "<<tmh.getDif()<<std::endl;
 		CPreGame * cpg = new CPreGame(); //main menu and submenus
 		tlog0<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
-		tlog0<<"Initialization of VCMI (togeter): "<<total.getDif()<<std::endl;
+		tlog0<<"Initialization of VCMI (together): "<<total.getDif()<<std::endl;
 		cpg->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();

+ 16 - 16
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

+ 1 - 1
mapHandler.cpp

@@ -199,7 +199,7 @@ void CMapHandler::roadsRiverTerrainInit()
 	}
 	for (int i=0-Woff;i<ttiles.size()-Woff;i++)
 	{
-		for (int j=0-Hoff;j<CGI->mh->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);
 	}