mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	* "%s substitutions in Right-click information in town hall
* windmill won't give wood * hover text for heroes * good background for the town hall screen in Stronghold * fixed typo in hall.txt * support for ZSoft-style PCX files in /Data (using SDL_image) * minor improvements
This commit is contained in:
		| @@ -656,7 +656,11 @@ void CHallInterface::CBuildingBox::hover(bool on) | ||||
| 	Hoverable::hover(on); | ||||
| 	if(on) | ||||
| 	{ | ||||
| 		std::string toPrint = CGI->townh->hcommands[state]; | ||||
| 		std::string toPrint; | ||||
| 		if(state==8) | ||||
| 			toPrint = CGI->townh->hcommands[5]; | ||||
| 		else | ||||
| 			toPrint = CGI->townh->hcommands[state]; | ||||
| 		std::vector<std::string> name; | ||||
| 		name.push_back(CGI->buildh->buildings[LOCPLINT->castleInt->town->subID][BID]->name); | ||||
| 		LOCPLINT->statusbar->print(CSDL_Ext::processStr(toPrint,name)); | ||||
| @@ -929,7 +933,7 @@ std::string CHallInterface::CBuildWindow::getTextForState(int state) | ||||
| 		ret =  CGI->townh->hcommands[state]; | ||||
| 	switch (state) | ||||
| 	{ | ||||
| 	case 4: | ||||
| 	case 4:	case 5: case 6: | ||||
| 		ret.replace(ret.find_first_of("%s"),2,CGI->buildh->buildings[tid][bid]->name); | ||||
| 		break; | ||||
| 	case 7: | ||||
|   | ||||
							
								
								
									
										11
									
								
								CLua.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								CLua.cpp
									
									
									
									
									
								
							| @@ -356,7 +356,7 @@ void CVisitableOPW::onNAHeroVisit(CGObjectInstance *os, int heroID, bool already | ||||
| 			break; | ||||
| 		case 112: | ||||
| 			mid = 170; | ||||
| 			sub = rand() % 6; | ||||
| 			sub = (rand() % 5) + 1; | ||||
| 			val = (rand() % 4) + 3; | ||||
| 			break; | ||||
| 		case 109: | ||||
| @@ -651,7 +651,14 @@ std::vector<int> CHeroScript::yourObjects() //returns IDs of objects which are h | ||||
| 	ret.push_back(34); //hero | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| std::string CHeroScript::hoverText(CGObjectInstance *os) | ||||
| { | ||||
| 	CGHeroInstance* h = static_cast<CGHeroInstance*>(os); | ||||
| 	std::string ret = CGI->generaltexth->allTexts[15]; | ||||
| 	boost::algorithm::replace_first(ret,"%s",h->name); | ||||
| 	boost::algorithm::replace_first(ret,"%s",h->type->heroClass->name); | ||||
| 	return ret; | ||||
| } | ||||
| void CMonsterS::newObject(CGObjectInstance *os) | ||||
| { | ||||
| 	//os->blockVisit = true; | ||||
|   | ||||
							
								
								
									
										1
									
								
								CLua.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								CLua.h
									
									
									
									
									
								
							| @@ -171,6 +171,7 @@ class CHeroScript : public CCPPObjectScript | ||||
| 	void newObject(CGObjectInstance *os); | ||||
| 	void onHeroVisit(CGObjectInstance *os, int heroID); | ||||
| 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script | ||||
| 	std::string hoverText(CGObjectInstance *os); | ||||
|  | ||||
| 	friend void initGameState(CGameInfo * cgi); | ||||
| }; | ||||
|   | ||||
| @@ -4,7 +4,7 @@ TPTHBKCS.BMP | ||||
| 10 11 12 13 | 7 8 9 | 5 22 | 16 | ||||
| 14 15 | 0 1 2 3 | 6 | ||||
| 21 | 18 19 | ||||
| 30 37 | 31  38 | 32 39 | 33 40 | ||||
| 30 37 | 31 38 | 32 39 | 33 40 | ||||
| 34 41 | 35 42 | 36 43 | ||||
| 1 | ||||
| TPTHBKRM.BMP | ||||
| @@ -42,7 +42,7 @@ TPTHBKDG.BMP | ||||
| 30 37 | 31 38 | 32 39 | 33 40 | ||||
| 34 41 | 35 42 | 36 43 | ||||
| 6 | ||||
| TPTHBKST.BMP | ||||
| TPTHBKTW.BMP | ||||
| 10 11 12 13 | 7 8 9 | 5 | 16 | ||||
| 14 15 | 0 1 2 | 23 | 17 | ||||
| 21 | 22 | 18 19 | ||||
|   | ||||
| @@ -168,7 +168,7 @@ void CBuildingHandler::loadBuildings() | ||||
| 					(hall[tid].second)[j][box].push_back(last); | ||||
| 					areboxes = it; //wyzeruje jak nie znajdzie kolejnej spacji = koniec linii | ||||
| 					if(!it) | ||||
| 						it = seppos+1; | ||||
| 						it = seppos+1;  | ||||
| 				} | ||||
| 				box++; | ||||
| 				it+=2; | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| @@ -7,6 +7,7 @@ | ||||
| #include <cctype> | ||||
| #include <cstring> | ||||
| #include "boost/filesystem.hpp"   // includes all needed Boost.Filesystem declarations | ||||
| #include "SDL_image.h" | ||||
| int readNormalNr (int pos, int bytCon, unsigned char * str) | ||||
| { | ||||
| 	int ret=0; | ||||
| @@ -252,52 +253,6 @@ SDL_Surface * CPCXConv::getSurface() | ||||
| 	} | ||||
| 	return ret; | ||||
| } | ||||
| SDL_Surface * CPCXConv::getSurfaceZ() | ||||
| { | ||||
| 	//int i=1; | ||||
| 	//int type = pcx[i];i+=2;//0 -- Version 2.5	2 -- Version 2.8, palette included	3 -- Version 2.8, use default palette	5 -- Version 3.0 or better | ||||
| 	//int bpp = pcx[3];i++; | ||||
| 	//int xmin, ymin, xmax, ymax, w, h; | ||||
| 	//xmin = readNormalNr(i,2,pcx);i+=2; | ||||
| 	//ymin = readNormalNr(i,2,pcx);i+=2; | ||||
| 	//xmax = readNormalNr(i,2,pcx);i+=2; | ||||
| 	//ymax = readNormalNr(i,2,pcx);i+=2; | ||||
| 	//w = xmax - xmin + 1; h = ymax - ymin + 1; | ||||
| 	//i+=4; //DPI is not interesting | ||||
| 	//char palette[48]; | ||||
| 	//memcpy(palette,pcx+i,48); i+=48; | ||||
| 	//int reserved = pcx[i++]; | ||||
| 	//int planes = pcx[i++]; | ||||
| 	//int bytesPerLine = readNormalNr(i,2,pcx);i+=2; | ||||
| 	//i = 128; //to the end of header | ||||
| 	//int totalBytes = planes * bytesPerLine; | ||||
| 	//int padding = ((bytesPerLine * planes) * (8 / bpp)) - ((xmax - xmin) + 1); | ||||
| 	//char * buffer = new char[totalBytes]; | ||||
| 	//int index = 0, count, value, total=0; | ||||
| 	//do | ||||
| 	//{ | ||||
| 	//	count=0; value=0; | ||||
| 	//	unsigned char byte = pcx[i++]; | ||||
| 	//	if((byte & 0xC0) == 0xC0) //two top bits set | ||||
| 	//	{ | ||||
| 	//		count = byte & 0x3f; | ||||
| 	//		value = pcx[i++]; | ||||
| 	//	} | ||||
| 	//	else | ||||
| 	//	{ | ||||
| 	//		count = 1; | ||||
| 	//		value = byte; | ||||
| 	//	} | ||||
| 	//	for(total+=count; count && (index < totalBytes); index++) | ||||
| 	//	{ | ||||
| 	//		buffer[index] = value; | ||||
| 	//		count--; | ||||
| 	//	} | ||||
| 	//} while(index<totalBytes); | ||||
| 	//delete buffer; | ||||
| 	std::cout<<"Warning - not supported ZSoft-style .png file!!!"<<std::endl; | ||||
| 	return NULL; | ||||
| } | ||||
|  | ||||
| SDL_Surface * CLodHandler::loadBitmap(std::string fname) | ||||
| { | ||||
| @@ -324,32 +279,32 @@ SDL_Surface * CLodHandler::loadBitmap(std::string fname) | ||||
| 		} | ||||
| 		else  //file .bmp not present, check .pcx | ||||
| 		{ | ||||
| 			//TODO: zczytywanie nawala, dokonczyc wsparcie zsoftowych pcxow | ||||
| 			char sign[3]; | ||||
| 			fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX"); | ||||
| 			f = fopen(fname.c_str(),"r"); | ||||
| 			if(!f) | ||||
| 				return NULL;  | ||||
| 			fread(sign,1,3,f); | ||||
| 			if(sign[0]=='B' && sign[1]=='M') //BMP - �eby Kulex m�g� miesza� PCXy z BMPami | ||||
| 			if(sign[0]=='B' && sign[1]=='M') //BMP named as PCX - people (eg. Kulex) sometimes use such files | ||||
| 			{ | ||||
| 				fclose(f); | ||||
| 				return SDL_LoadBMP(fname.c_str()); | ||||
| 			} | ||||
| 			else //PCX | ||||
| 			else //PCX - but we don't know which | ||||
| 			{ | ||||
| 				CPCXConv cp; | ||||
| 				pcx = new unsigned char[e->realSize]; | ||||
| 				memcpy(pcx,sign,3); | ||||
| 				int res = fread((char*)pcx+3, 1, e->realSize-3, f); | ||||
| 				fclose(f); | ||||
| 				cp.openPCX((char*)pcx,e->realSize); | ||||
| 				if((sign[0]==10) && (sign[1]<6) && (sign[2]==1)) //ZSoft PCX | ||||
| 				{ | ||||
| 					return cp.getSurfaceZ(); | ||||
| 					fclose(f); | ||||
| 					return IMG_Load(fname.c_str()); | ||||
| 				} | ||||
| 				else //H3 PCX | ||||
| 				else //H3-style PCX | ||||
| 				{ | ||||
| 					CPCXConv cp; | ||||
| 					pcx = new unsigned char[e->realSize]; | ||||
| 					memcpy(pcx,sign,3); | ||||
| 					int res = fread((char*)pcx+3, 1, e->realSize-3, f); | ||||
| 					fclose(f); | ||||
| 					cp.openPCX((char*)pcx,e->realSize); | ||||
| 					return cp.getSurface(); | ||||
| 				} | ||||
| 			} | ||||
|   | ||||
| @@ -54,7 +54,7 @@ public: | ||||
| 	void openPCX(); | ||||
| 	void convert(); | ||||
| 	SDL_Surface * getSurface(); //for standard H3 PCX | ||||
| 	SDL_Surface * getSurfaceZ(); //for ZSoft PCX | ||||
| 	//SDL_Surface * getSurfaceZ(); //for ZSoft PCX | ||||
| 	CPCXConv(){pcx=bmp=NULL;pcxs=bmps=0;}; | ||||
| 	~CPCXConv(){if (pcxs) delete[] pcx; if(bmps) delete[] bmp;} | ||||
| }; | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| #include "../stdafx.h" | ||||
| #include "CSemiDefHandler.h" | ||||
| #include <fstream> | ||||
| #include "SDL_image.h" | ||||
| extern SDL_Surface * screen; | ||||
| std::string CSemiDefHandler::nameFromType (EterrainType typ) | ||||
| { | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| #include "../global.h" | ||||
| #include <string> | ||||
| #include "SDL.h" | ||||
| #include "SDL_image.h" | ||||
| //#include "SDL_image.h" | ||||
| #include <vector> | ||||
|  | ||||
| struct Cimage | ||||
|   | ||||
		Reference in New Issue
	
	Block a user