mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	* new files (TownHandler) - add them to your project
* now you can choose castle in scenario options * function blitAtWR works as blitAt, and refreshes destination rect * vectorize function (on TowDragon's wish) - may be useful for debugging * as always- minor bigfixes
This commit is contained in:
		| @@ -13,6 +13,7 @@ | ||||
| #include "CSemiLodHandler.h" | ||||
| #include "CDefObjInfoHandler.h" | ||||
| #include "CLodHandler.h" | ||||
| #include "CTownHandler.h" | ||||
| #include "CGeneralTextHandler.h" | ||||
| #include "SDL.h" | ||||
| #include <vector> | ||||
| @@ -36,6 +37,7 @@ public: | ||||
| 	CMusicHandler * mush; | ||||
| 	CSemiLodHandler * sspriteh; | ||||
| 	CDefObjInfoHandler * dobjinfo; | ||||
| 	CTownHandler * townh; | ||||
| 	CLodHandler * spriteh; | ||||
| 	CLodHandler * bitmaph; | ||||
| 	CGeneralTextHandler * generaltexth; | ||||
|   | ||||
| @@ -33,7 +33,7 @@ void CPCXConv::fromFile(std::string path) | ||||
| { | ||||
| 	std::ifstream * is = new std::ifstream(); | ||||
| 	is -> open(path.c_str(),std::ios::binary); | ||||
| 	is->seekg(0,std::ios::end); // na koniec | ||||
| 	is->seekg(0,std::ios::end); // to the end | ||||
| 	pcxs = is->tellg();  // read length | ||||
| 	is->seekg(0,std::ios::beg); // wracamy na poczatek | ||||
| 	pcx = new unsigned char[pcxs]; // allocate memory  | ||||
| @@ -688,64 +688,13 @@ void CLodHandler::extract(std::string FName) | ||||
| 				std::cout<<"LOD Extraction error"<<"  "<<decRes<<" while extracting to "<<bufff<<std::endl; | ||||
| 			} | ||||
| 		} | ||||
| 		//for (int j=0; j<entries[i].size; j++) | ||||
| 		//	FOut << outp[j]; | ||||
| 		//FOut.flush(); | ||||
| 		delete outp; | ||||
| 		//FOut.close(); | ||||
| 		//std::cout<<"*** done\n"; | ||||
| 	} | ||||
| 	FLOD.close(); | ||||
| 	//std::cout<<"*** Archive: "+FName+" closed\n"; | ||||
| } | ||||
|  | ||||
| void CLodHandler::extractFile(std::string FName, std::string name) | ||||
| { | ||||
| 	//std::ifstream FLOD; | ||||
| 	std::ofstream FOut; | ||||
| 	int i; | ||||
|  | ||||
| 	//std::string Ts; | ||||
| 	////std::cout<<"*** Loading FAT ... \n"; | ||||
| 	//FLOD.open(FName.c_str(),std::ios::binary); | ||||
| 	////std::cout<<"*** Archive: "+FName+" loaded\n"; | ||||
| 	//FLOD.seekg(8,std::ios_base::beg); | ||||
| 	//unsigned char temp[4]; | ||||
| 	//FLOD.read((char*)temp,4); | ||||
| 	//totalFiles = readNormalNr(temp,4); | ||||
| 	//FLOD.seekg(0x5c,std::ios_base::beg); | ||||
| 	//entries.reserve(totalFiles); | ||||
| 	////std::cout<<"*** Loading FAT ...\n"; | ||||
| 	//for (int i=0; i<totalFiles; i++) | ||||
| 	//{ | ||||
| 	//	entries.push_back(Entry()); | ||||
| 	//	//FLOD.read((char*)entries[i].name,12); | ||||
| 	//	char * bufc = new char; | ||||
| 	//	bool appending = true; | ||||
| 	//	for(int kk=0; kk<12; ++kk) | ||||
| 	//	{ | ||||
| 	//		FLOD.read(bufc, 1); | ||||
| 	//		if(appending) | ||||
| 	//		{ | ||||
| 	//			entries[i].name[kk] = *bufc; | ||||
| 	//		} | ||||
| 	//		else | ||||
| 	//		{ | ||||
| 	//			entries[i].name[kk] = 0; | ||||
| 	//			appending = false; | ||||
| 	//		} | ||||
| 	//	} | ||||
| 	//	delete bufc; | ||||
| 	//	FLOD.read((char*)entries[i].hlam_1,4); | ||||
| 	//	FLOD.read((char*)temp,4); | ||||
| 	//	entries[i].offset=readNormalNr(temp,4); | ||||
| 	//	FLOD.read((char*)temp,4); | ||||
| 	//	entries[i].realSize=readNormalNr(temp,4); | ||||
| 	//	FLOD.read((char*)entries[i].hlam_2,4); | ||||
| 	//	FLOD.read((char*)temp,4); | ||||
| 	//	entries[i].size=readNormalNr(temp,4); | ||||
| 	//} | ||||
| 	//std::cout<<" done\n"; | ||||
| 	std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper); | ||||
| 	for (int i=0;i<totalFiles;i++) | ||||
| 	{ | ||||
| @@ -790,15 +739,9 @@ void CLodHandler::extractFile(std::string FName, std::string name) | ||||
| 				std::cout<<"LOD Extraction error"<<"  "<<decRes<<" while extracting to "<<bufff<<std::endl; | ||||
| 			} | ||||
| 		} | ||||
| 		//for (int j=0; j<entries[i].size; j++) | ||||
| 		//	FOut << outp[j]; | ||||
| 		//FOut.flush(); | ||||
| 		delete outp; | ||||
| 		//FOut.close(); | ||||
| 		//std::cout<<"*** done\n"; | ||||
| 	} | ||||
| 	FLOD.close(); | ||||
| 	//std::cout<<"*** Archive: "+FName+" closed\n"; | ||||
| } | ||||
|  | ||||
| int CLodHandler::readNormalNr (unsigned char* bufor, int bytCon, bool cyclic) | ||||
| @@ -892,7 +835,9 @@ std::string CLodHandler::getTextFile(std::string name) | ||||
| 			FLOD.seekg(0, std::ios_base::beg); | ||||
| 			unsigned char * decomp = NULL; | ||||
| 			int decRes = infs2(outp, entries[i].size, entries[i].realSize, decomp); | ||||
| 			std::string ret = std::string((char*)decomp); | ||||
| 			std::string ret; | ||||
| 			for (int itr=0;itr<entries[i].realSize;itr++) | ||||
| 				ret+= *((char*)decomp+itr); | ||||
| 			delete outp; | ||||
| 			delete decomp; | ||||
| 			return ret; | ||||
|   | ||||
							
								
								
									
										3
									
								
								CMT.cpp
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								CMT.cpp
									
									
									
									
									
								
							| @@ -29,6 +29,7 @@ | ||||
| #include "CLodHandler.h" | ||||
| #include "CDefHandler.h" | ||||
| #include "CSndHandler.h" | ||||
| #include "CTownHandler.h" | ||||
| #include "CDefObjInfoHandler.h" | ||||
| #include "CAmbarCendamo.h" | ||||
| #include "mapHandler.h" | ||||
| @@ -265,6 +266,8 @@ int _tmain(int argc, _TCHAR* argv[]) | ||||
| 		cgi->neutralColor = p;//gray | ||||
| 		//colors initialized | ||||
|  | ||||
| 		cgi->townh = new CTownHandler; | ||||
| 		cgi->townh->loadNames(); | ||||
| 		THC std::cout<<"Loading .lods: "<<tmh.getDif()<<std::endl; | ||||
| 		CPreGame * cpg = new CPreGame(); //main menu and submenus | ||||
| 		THC std::cout<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl; | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								CPreGame.cpp
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								CPreGame.cpp
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -46,8 +46,8 @@ class Options : public PreGameTab | ||||
| 	{ | ||||
| 		void hover(bool on=true){}; | ||||
| 		void select(bool on=true){}; | ||||
| 		OptionSwitch( SDL_Rect Pos, CDefHandler* Imgs) | ||||
| 			:HighButton(Pos,Imgs,false,7) | ||||
| 		OptionSwitch( SDL_Rect Pos, CDefHandler* Imgs, bool Left, int Which) | ||||
| 			:HighButton(Pos,Imgs,false,7),left(Left),which(Which) | ||||
| 			{selectable=false;highlightable=false;} | ||||
| 		void press(bool down=true); | ||||
| 		bool left; | ||||
| @@ -74,6 +74,7 @@ public: | ||||
| 	void show(); | ||||
| 	void hide(); | ||||
| 	void init(); | ||||
| 	void showIcon (int what, int nr, bool abs); //what: -1=castle, 0=hero, 1=bonus, 2=all; abs=true -> nr is absolute | ||||
| 	Options(){inited=showed=false;}; | ||||
| 	~Options(); | ||||
| }; | ||||
|   | ||||
| @@ -21,7 +21,13 @@ SDL_Rect genRect(int hh, int ww, int xx, int yy) | ||||
| 	ret.y=yy; | ||||
| 	return ret; | ||||
| } | ||||
| void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran) | ||||
| 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) | ||||
| { | ||||
| 	SDL_Rect pom = genRect(src->h,src->w,x,y); | ||||
| 	SDL_BlitSurface(src,NULL,dst,&pom); | ||||
|   | ||||
| @@ -6,6 +6,7 @@ | ||||
|  | ||||
| extern SDL_Surface * ekran; | ||||
| extern SDL_Color tytulowy, tlo, zwykly ; | ||||
| void blitAtWR(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran); | ||||
| namespace CSDL_Ext | ||||
| { | ||||
| 	void SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC=0, Uint8 A = 255); //myC influences the start of reading pixels | ||||
|   | ||||
							
								
								
									
										9
									
								
								nodrze.h
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								nodrze.h
									
									
									
									
									
								
							| @@ -7,6 +7,7 @@ | ||||
|  | ||||
| #include <iostream> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| #define LOGUJ ; | ||||
| #define CLOG ; | ||||
| @@ -112,6 +113,7 @@ public: | ||||
| 										//print all elements postorder | ||||
| 	void wypiszObficie(std::ostream & strum); //wypisuje dane o kazdym wezle -- wymaga operatora >> dla zawartosci | ||||
| 										//prints info about all nodes - >> operator for T needed | ||||
| 	std::vector<T> vectorize(); //returns vector with all nodrze elements | ||||
| 	T * znajdz (T co, bool iter = true); // wyszukuje zadany element | ||||
| 										//search for T | ||||
| 	int size(); //ilosc elementow | ||||
| @@ -132,6 +134,13 @@ public: | ||||
| 	template <typename Y, class X> friend Y* operator%(nodrze<Y> & drzewko, X co); // search and return pointer | ||||
| 	void push_back(T co){(*this)+=co;}; // add | ||||
| }; | ||||
| template <typename T> std::vector<T> nodrze<T>::vectorize() | ||||
| { | ||||
| 	std::vector<T> ret; | ||||
| 	for (int i=0; i<ile; i++) | ||||
| 		ret.push_back((*this)[i]); | ||||
| 	return ret; | ||||
| } | ||||
| template <typename T> void nodrze<T>::wypisuj(wezel<T> * w, std::ostream & strum) | ||||
| { | ||||
| 	if (w==NIL) return; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user