mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Experimental commit...
* spellbook displays only spells known by Hero * further fixes for leveling-up
This commit is contained in:
		| @@ -1947,7 +1947,6 @@ void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, int pskill, std: | |||||||
| 			showingDialog->cond.wait(un); | 			showingDialog->cond.wait(un); | ||||||
| 	} | 	} | ||||||
| 	boost::unique_lock<boost::recursive_mutex> un(*pim); | 	boost::unique_lock<boost::recursive_mutex> un(*pim); | ||||||
| 	LOCPLINT->showingDialog->setn(true); |  | ||||||
| 	CLevelWindow *lw = new CLevelWindow(hero,pskill,skills,callback); | 	CLevelWindow *lw = new CLevelWindow(hero,pskill,skills,callback); | ||||||
| 	curint->deactivate(); | 	curint->deactivate(); | ||||||
| 	lw->activate(); | 	lw->activate(); | ||||||
| @@ -2101,6 +2100,7 @@ void CPlayerInterface::actionStarted(const BattleAction* action) | |||||||
| 			battleInt->defendingHero->setPhase(4); | 			battleInt->defendingHero->setPhase(4); | ||||||
| 		else | 		else | ||||||
| 			battleInt->attackingHero->setPhase(4); | 			battleInt->attackingHero->setPhase(4); | ||||||
|  | 		return; | ||||||
| 	} | 	} | ||||||
| 	if(!stack) | 	if(!stack) | ||||||
| 	{ | 	{ | ||||||
| @@ -3582,18 +3582,17 @@ void CLevelWindow::close() | |||||||
| 	} | 	} | ||||||
| 	delete this; | 	delete this; | ||||||
| 	LOCPLINT->curint->activate(); | 	LOCPLINT->curint->activate(); | ||||||
|  | 	LOCPLINT->showingDialog->setn(false); | ||||||
| } | } | ||||||
| CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback) | CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback) | ||||||
| { | { | ||||||
|  | 	LOCPLINT->showingDialog->setn(true); | ||||||
| 	heroType = hero->subID; | 	heroType = hero->subID; | ||||||
| 	cb = callback; | 	cb = callback; | ||||||
| 	for(int i=0;i<skills.size();i++) | 	for(int i=0;i<skills.size();i++) | ||||||
| 		comps.push_back(new CSelectableComponent(SComponent::secskill44,skills[i],hero->getSecSkillLevel(skills[i])+1,boost::bind(&CLevelWindow::selectionChanged,this,i))); |  | ||||||
| 	if(comps.size()) |  | ||||||
| 	{ | 	{ | ||||||
| 		comps[0]->assignedKeys.insert(SDLK_1); | 		comps.push_back(new CSelectableComponent(SComponent::secskill44,skills[i],hero->getSecSkillLevel(skills[i])+1,boost::bind(&CLevelWindow::selectionChanged,this,i))); | ||||||
| 		if(comps.size() > 1) | 		comps.back()->assignedKeys.insert(SDLK_1 + i); | ||||||
| 			comps[1]->assignedKeys.insert(SDLK_2); |  | ||||||
| 	} | 	} | ||||||
| 	bitmap = BitmapHandler::loadBitmap("LVLUPBKG.bmp"); | 	bitmap = BitmapHandler::loadBitmap("LVLUPBKG.bmp"); | ||||||
| 	graphics->blueToPlayersAdv(bitmap,hero->tempOwner); | 	graphics->blueToPlayersAdv(bitmap,hero->tempOwner); | ||||||
| @@ -3603,7 +3602,6 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<u | |||||||
| 	pos.w = bitmap->w; | 	pos.w = bitmap->w; | ||||||
| 	pos.h = bitmap->h; | 	pos.h = bitmap->h; | ||||||
| 	ok = new AdventureMapButton("","",boost::bind(&CLevelWindow::close,this),pos.x+297,pos.y+413,"IOKAY.DEF",SDLK_RETURN); | 	ok = new AdventureMapButton("","",boost::bind(&CLevelWindow::close,this),pos.x+297,pos.y+413,"IOKAY.DEF",SDLK_RETURN); | ||||||
| 	ok->block(true); |  | ||||||
| 	//draw window | 	//draw window | ||||||
| 	char buf[100], buf2[100]; | 	char buf[100], buf2[100]; | ||||||
| 	strcpy(buf2,CGI->generaltexth->allTexts[444].c_str()); //%s has gained a level. | 	strcpy(buf2,CGI->generaltexth->allTexts[444].c_str()); //%s has gained a level. | ||||||
| @@ -3631,6 +3629,16 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<u | |||||||
| 			curx += ort->w + 18; | 			curx += ort->w + 18; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if(comps.size() > 1) | ||||||
|  | 	{ | ||||||
|  | 		ok->block(true); | ||||||
|  | 	} | ||||||
|  | 	else if(comps.size() == 1) | ||||||
|  | 	{ | ||||||
|  | 		comps[0]->select(true); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	SDL_FreeSurface(ort); | 	SDL_FreeSurface(ort); | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								README
									
									
									
									
									
								
							| @@ -0,0 +1,16 @@ | |||||||
|  |     VCMI Project | ||||||
|  |     Copyright (C) 2007-2009  VCMI Team (check AUTHORS file for the contributors list) | ||||||
|  |  | ||||||
|  |     This program is free software; you can redistribute it and/or modify | ||||||
|  |     it under the terms of the GNU General Public License as published by | ||||||
|  |     the Free Software Foundation; either version 2 (included in the license.txt) | ||||||
|  |     of the License, or (at your option) any later version. | ||||||
|  |  | ||||||
|  |     This program is distributed in the hope that it will be useful, | ||||||
|  |     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |     GNU General Public License for more details. | ||||||
|  |  | ||||||
|  |     You should have received a copy of the GNU General Public License along | ||||||
|  |     with this program; if not, write to the Free Software Foundation, Inc., | ||||||
|  |     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||||
| @@ -167,7 +167,7 @@ SDL_Surface * CPCXConv::getSurface() | |||||||
| { | { | ||||||
| 	SDL_Surface * ret; | 	SDL_Surface * ret; | ||||||
|  |  | ||||||
| 	BMPHeader bh; | 	int width = -1, height = -1; | ||||||
| 	Epcxformat format; | 	Epcxformat format; | ||||||
| 	int fSize,y;//,i; //TODO use me 'i' | 	int fSize,y;//,i; //TODO use me 'i' | ||||||
| 	bool check1, check2; | 	bool check1, check2; | ||||||
| @@ -175,13 +175,13 @@ SDL_Surface * CPCXConv::getSurface() | |||||||
| 	int it=0; | 	int it=0; | ||||||
|  |  | ||||||
| 	fSize = readNormalNr(it,4,pcx);it+=4; | 	fSize = readNormalNr(it,4,pcx);it+=4; | ||||||
| 	bh.x = readNormalNr(it,4,pcx);it+=4; | 	width = readNormalNr(it,4,pcx);it+=4; | ||||||
| 	bh.y = readNormalNr(it,4,pcx);it+=4; | 	height = readNormalNr(it,4,pcx);it+=4; | ||||||
| 	if (fSize==bh.x*bh.y*3) | 	if (fSize==width*height*3) | ||||||
| 		check1=true; | 		check1=true; | ||||||
| 	else  | 	else  | ||||||
| 		check1=false; | 		check1=false; | ||||||
| 	if (fSize==bh.x*bh.y) | 	if (fSize==width*height) | ||||||
| 		check2=true; | 		check2=true; | ||||||
| 	else  | 	else  | ||||||
| 		check2=false; | 		check2=false; | ||||||
| @@ -191,12 +191,12 @@ SDL_Surface * CPCXConv::getSurface() | |||||||
| 		format=PCX8B; | 		format=PCX8B; | ||||||
| 	else  | 	else  | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	add = 4 - bh.x%4; | 	add = 4 - width%4; | ||||||
| 	if (add==4) | 	if (add==4) | ||||||
| 		add=0; | 		add=0; | ||||||
| 	if (format==PCX8B) | 	if (format==PCX8B) | ||||||
| 	{ | 	{ | ||||||
| 		ret = SDL_CreateRGBSurface(SDL_SWSURFACE, bh.x+add, bh.y, 8, 0, 0, 0, 0); | 		ret = SDL_CreateRGBSurface(SDL_SWSURFACE, width+add, height, 8, 0, 0, 0, 0); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| @@ -209,7 +209,7 @@ SDL_Surface * CPCXConv::getSurface() | |||||||
| 		int gmask = 0x00ff00; | 		int gmask = 0x00ff00; | ||||||
| 		int rmask = 0xff0000; | 		int rmask = 0xff0000; | ||||||
| #endif | #endif | ||||||
| 		ret = SDL_CreateRGBSurface(SDL_SWSURFACE, bh.x+add, bh.y, 24, rmask, gmask, bmask, 0); | 		ret = SDL_CreateRGBSurface(SDL_SWSURFACE, width+add, height, 24, rmask, gmask, bmask, 0); | ||||||
| 	} | 	} | ||||||
| 	if (format==PCX8B) | 	if (format==PCX8B) | ||||||
| 	{ | 	{ | ||||||
| @@ -229,10 +229,10 @@ SDL_Surface * CPCXConv::getSurface() | |||||||
| 			tp.unused = 0; | 			tp.unused = 0; | ||||||
| 			*(ret->format->palette->colors+i) = tp; | 			*(ret->format->palette->colors+i) = tp; | ||||||
| 		} | 		} | ||||||
| 		for (y=bh.y;y>0;y--) | 		for (y=height;y>0;y--) | ||||||
| 		{ | 		{ | ||||||
| 			it=0xC+(y-1)*bh.x; | 			it=0xC+(y-1)*width; | ||||||
| 			for (int j=0;j<bh.x;j++) | 			for (int j=0;j<width;j++) | ||||||
| 			{ | 			{ | ||||||
| 				*((char*)ret->pixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * j) = pcx[it+j]; | 				*((char*)ret->pixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * j) = pcx[it+j]; | ||||||
| 			} | 			} | ||||||
| @@ -240,17 +240,17 @@ SDL_Surface * CPCXConv::getSurface() | |||||||
| 			{ | 			{ | ||||||
| 				for (int j=0;j<add;j++) | 				for (int j=0;j<add;j++) | ||||||
| 				{ | 				{ | ||||||
| 					*((char*)ret->pixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * (j+bh.x)) = 0; | 					*((char*)ret->pixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * (j+width)) = 0; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		for (y=bh.y; y>0; y--) | 		for (y=height; y>0; y--) | ||||||
| 		{ | 		{ | ||||||
| 			it=0xC+(y-1)*bh.x*3; | 			it=0xC+(y-1)*width*3; | ||||||
| 			for (int j=0;j<bh.x*3;j++) | 			for (int j=0;j<width*3;j++) | ||||||
| 			{ | 			{ | ||||||
| 				*((char*)ret->pixels + ret->pitch * (y-1) + j) = pcx[it+j]; | 				*((char*)ret->pixels + ret->pitch * (y-1) + j) = pcx[it+j]; | ||||||
| 			} | 			} | ||||||
| @@ -258,7 +258,7 @@ SDL_Surface * CPCXConv::getSurface() | |||||||
| 			{ | 			{ | ||||||
| 				for (int j=0;j<add*3;j++) | 				for (int j=0;j<add*3;j++) | ||||||
| 				{ | 				{ | ||||||
| 					*((char*)ret->pixels + ret->pitch * (y-1) + (j+bh.x*3)) = 0; | 					*((char*)ret->pixels + ret->pitch * (y-1) + (j+width*3)) = 0; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -269,7 +269,10 @@ SDL_Surface * CPCXConv::getSurface() | |||||||
| SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey) | SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey) | ||||||
| { | { | ||||||
| 	if(!fname.size()) | 	if(!fname.size()) | ||||||
|  | 	{ | ||||||
|  | 		tlog2 << "Call to loadBitmap with void fname!\n"; | ||||||
| 		return NULL; | 		return NULL; | ||||||
|  | 	} | ||||||
| 	unsigned char * pcx; | 	unsigned char * pcx; | ||||||
| 	std::transform(fname.begin(),fname.end(),fname.begin(),toupper); | 	std::transform(fname.begin(),fname.end(),fname.begin(),toupper); | ||||||
| 	fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX"); | 	fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX"); | ||||||
| @@ -295,7 +298,10 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey) | |||||||
| 			fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX"); | 			fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX"); | ||||||
| 			f = fopen(fname.c_str(),"r"); | 			f = fopen(fname.c_str(),"r"); | ||||||
| 			if(!f) | 			if(!f) | ||||||
|  | 			{ | ||||||
|  | 				tlog1 << "Cannot open " << fname << " - not present as bmp nor as pcx.\n"; | ||||||
| 				return NULL;  | 				return NULL;  | ||||||
|  | 			} | ||||||
| 			fread(sign,1,3,f); | 			fread(sign,1,3,f); | ||||||
| 			if(sign[0]=='B' && sign[1]=='M') //BMP named as PCX - people (eg. Kulex) sometimes use such files | 			if(sign[0]=='B' && sign[1]=='M') //BMP named as PCX - people (eg. Kulex) sometimes use such files | ||||||
| 			{ | 			{ | ||||||
| @@ -338,7 +344,7 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey) | |||||||
| 		int res=bitmaph->infs2(pcd,e->size,e->realSize,pcx); | 		int res=bitmaph->infs2(pcd,e->size,e->realSize,pcx); | ||||||
| 		if(res!=0) | 		if(res!=0) | ||||||
| 		{ | 		{ | ||||||
| 			tlog2<<"an error "<<res<<" occured while extracting file "<<fname<<std::endl; | 			tlog2<<"an error "<<res<<" occurred while extracting file "<<fname<<std::endl; | ||||||
| 		} | 		} | ||||||
| 		delete [] pcd; | 		delete [] pcd; | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -29,7 +29,6 @@ public: | |||||||
| 	void fromFile(std::string path); | 	void fromFile(std::string path); | ||||||
| 	void saveBMP(std::string path); | 	void saveBMP(std::string path); | ||||||
| 	void openPCX(char * PCX, int len); | 	void openPCX(char * PCX, int len); | ||||||
| 	void openPCX(); |  | ||||||
| 	void convert(); | 	void convert(); | ||||||
| 	SDL_Surface * getSurface(); //for standard H3 PCX | 	SDL_Surface * getSurface(); //for standard H3 PCX | ||||||
| 	//SDL_Surface * getSurfaceZ(); //for ZSoft PCX | 	//SDL_Surface * getSurfaceZ(); //for ZSoft PCX | ||||||
|   | |||||||
| @@ -70,13 +70,13 @@ CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHer | |||||||
| 	selectedTab(4), | 	selectedTab(4), | ||||||
| 	spellSite(0) | 	spellSite(0) | ||||||
| { | { | ||||||
|  | 	mySpells = myHero->spells; | ||||||
| 	//XXX for testing only | 	//XXX for testing only | ||||||
| 	//mySpells = myHero->spells; | 	//for(ui32 v=0; v<CGI->spellh->spells.size(); ++v) | ||||||
| 	for(ui32 v=0; v<CGI->spellh->spells.size(); ++v) | 	//{ | ||||||
| 	{ | 	//	if(!CGI->spellh->spells[v].creatureAbility) | ||||||
| 		if(!CGI->spellh->spells[v].creatureAbility) | 	//		mySpells.insert(v); | ||||||
| 			mySpells.insert(v); | 	//} | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	for(int b=0; b<4; ++b) schoolLvls[b] = 0; | 	for(int b=0; b<4; ++b) schoolLvls[b] = 0; | ||||||
| 	for(size_t b=0; b<myHero->secSkills.size(); ++b) | 	for(size_t b=0; b<myHero->secSkills.size(); ++b) | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								readme.txt
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								readme.txt
									
									
									
									
									
								
							| @@ -1,15 +0,0 @@ | |||||||
|     Copyright (C) 2007-2009  VCMI Team |  | ||||||
|  |  | ||||||
|     This program is free software; you can redistribute it and/or modify |  | ||||||
|     it under the terms of the GNU General Public License as published by |  | ||||||
|     the Free Software Foundation; either version 2 of the License, or |  | ||||||
|     (at your option) any later version. |  | ||||||
|  |  | ||||||
|     This program is distributed in the hope that it will be useful, |  | ||||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of |  | ||||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the |  | ||||||
|     GNU General Public License for more details. |  | ||||||
|  |  | ||||||
|     You should have received a copy of the GNU General Public License along |  | ||||||
|     with this program; if not, write to the Free Software Foundation, Inc., |  | ||||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |  | ||||||
| @@ -241,16 +241,18 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs) | |||||||
| 					expert.insert(hero->secSkills[i].first); | 					expert.insert(hero->secSkills[i].first); | ||||||
| 				none.erase(hero->secSkills[i].first); | 				none.erase(hero->secSkills[i].first); | ||||||
| 			} | 			} | ||||||
|  | 			//first offered skill | ||||||
| 			if(hero->secSkills.size() < hero->type->heroClass->skillLimit) //free skill slot | 			if(hero->secSkills.size() < hero->type->heroClass->skillLimit) //free skill slot | ||||||
| 			{ | 			{ | ||||||
| 				hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //new skill | 				hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //new skill | ||||||
| 			} | 			} | ||||||
| 			else | 			else if(basicAndAdv.size()) | ||||||
| 			{ | 			{ | ||||||
| 				int s = hero->type->heroClass->chooseSecSkill(basicAndAdv); | 				int s = hero->type->heroClass->chooseSecSkill(basicAndAdv); | ||||||
| 				hlu.skills.push_back(s); | 				hlu.skills.push_back(s); | ||||||
| 				basicAndAdv.erase(s); | 				basicAndAdv.erase(s); | ||||||
| 			} | 			} | ||||||
|  | 			//second offered skill | ||||||
| 			if(basicAndAdv.size()) | 			if(basicAndAdv.size()) | ||||||
| 			{ | 			{ | ||||||
| 				hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(basicAndAdv)); //new skill | 				hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(basicAndAdv)); //new skill | ||||||
| @@ -259,8 +261,21 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs) | |||||||
| 			{ | 			{ | ||||||
| 				hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //new skill | 				hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(none)); //new skill | ||||||
| 			} | 			} | ||||||
| 			boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind(callWith<ui16>,hlu.skills,boost::function<void(ui16)>(boost::bind(&CGameHandler::changeSecSkill,this,ID,_1,1,0)),_1)); | 			 | ||||||
| 			applyAndAsk(&hlu,hero->tempOwner,callback); //call changeSecSkill with appropriate args when client responds | 			if(hlu.skills.size() > 1) //apply and ask for secondary skill | ||||||
|  | 			{ | ||||||
|  | 				boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind(callWith<ui16>,hlu.skills,boost::function<void(ui16)>(boost::bind(&CGameHandler::changeSecSkill,this,ID,_1,1,0)),_1)); | ||||||
|  | 				applyAndAsk(&hlu,hero->tempOwner,callback); //call changeSecSkill with appropriate args when client responds | ||||||
|  | 			} | ||||||
|  | 			else if(hlu.skills.size() == 1) //apply, give only possible skill  and send info | ||||||
|  | 			{ | ||||||
|  | 				changeSecSkill(ID,hlu.skills.back(),1,false); | ||||||
|  | 				sendAndApply(&hlu); | ||||||
|  | 			} | ||||||
|  | 			else //apply and send info | ||||||
|  | 			{ | ||||||
|  | 				sendAndApply(&hlu); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user