mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Lacking files.
This commit is contained in:
		
							
								
								
									
										50
									
								
								CTownHandler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								CTownHandler.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| #include "stdafx.h" | ||||
| #include "CTownHandler.h" | ||||
| #include "CGameInfo.h" | ||||
| #include <sstream> | ||||
| #define CGI (CGameInfo::mainObj) | ||||
|  | ||||
|  | ||||
| CTownHandler::CTownHandler() | ||||
| { | ||||
| 	smallIcons = CGI->spriteh->giveDef("ITPA.DEF"); | ||||
| } | ||||
| CTownHandler::~CTownHandler() | ||||
| { | ||||
| 	delete smallIcons; | ||||
| } | ||||
| void CTownHandler::loadNames() | ||||
| { | ||||
| 	std::istringstream ins; | ||||
| 	ins.str(CGI->bitmaph->getTextFile("TOWNTYPE.TXT")); | ||||
| 	while (!ins.eof()) | ||||
| 	{ | ||||
| 		CTown town; | ||||
| 		ins >> town.name; | ||||
| 		town.bonus=towns.size(); | ||||
| 		if (town.bonus==8) town.bonus=3;  | ||||
| 		if (town.name.length()) | ||||
| 			towns.push_back(town); | ||||
| 	} | ||||
| } | ||||
| SDL_Surface * CTownHandler::getPic(int ID, bool fort, bool builded) | ||||
| { | ||||
| 	if (ID==-1) | ||||
| 		return smallIcons->ourImages[0].bitmap; | ||||
| 	else if (ID==-2) | ||||
| 		return smallIcons->ourImages[1].bitmap; | ||||
| 	else if (ID==-3) | ||||
| 		return smallIcons->ourImages[2+F_NUMBER*4].bitmap; | ||||
| 	else if (ID>F_NUMBER || ID<-3) | ||||
| 		throw new std::exception("Invalid ID"); | ||||
| 	else | ||||
| 	{ | ||||
| 		int pom = 3; | ||||
| 		if(!fort) | ||||
| 			pom+=F_NUMBER*2; | ||||
| 		pom += ID*2; | ||||
| 		if (!builded) | ||||
| 			pom--; | ||||
| 		return smallIcons->ourImages[pom].bitmap; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										24
									
								
								CTownHandler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								CTownHandler.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| #ifndef CTOWNHANDLER_H | ||||
| #define CTOWNHANDLER_H | ||||
| #include "CDefHandler.h" | ||||
| #include "SDL.h" | ||||
| #include <string> | ||||
| #include <vector> | ||||
| class CTown | ||||
| { | ||||
| public: | ||||
| 	std::string name; | ||||
| 	int bonus; //pic number | ||||
| }; | ||||
| class CTownHandler | ||||
| { | ||||
| 	CDefHandler * smallIcons; | ||||
| public: | ||||
| 	CTownHandler(); | ||||
| 	~CTownHandler(); | ||||
| 	std::vector<CTown> towns; | ||||
| 	void loadNames(); | ||||
| 	SDL_Surface * getPic(int ID, bool fort=true, bool builded=false); //ID=-1 - blank; -2 - border; -3 - random | ||||
| }; | ||||
|  | ||||
| #endif //CTOWNHANDLER_H | ||||
		Reference in New Issue
	
	Block a user