mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	[new] dodanie do CPreGameTextHandlera funkcji wypruwających tytuł/treść danej opcji
[change] przesunięcie CPreGameTextHandlera do CPreGeme'a [new] Pomoc kontekstowa dlaw wszystkich opcji w menu głównym (plansza główna) [bugfix] Gdy okienko znika nie ma błędów w wyświetlaniu (przycięte przyciski) [new] Funkcja do wygodnego generowania kolorów w rozszerzeniach SDLa i odświeżania recta [new] Generowanie okien dwuprzyciskowych (sporo jest z tym związanych zmian) ***Uwaga - to okno dwuprzyciskowe (a właściwie jego obsługa) nie jest dokończone - jest parę bugów o których wiem. Nie mam siły ich teraz poprawiać, a Ty pewnie zaraz wejdziesz i będziesz ciekaw zmian, więc wgrywam, ale nie zdziw się, gdy jakiś odkryjesz.*** I musisz dodać nowe defy, które zaraz dostaniesz na pocztę.
This commit is contained in:
		
							
								
								
									
										5
									
								
								CMT.cpp
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								CMT.cpp
									
									
									
									
									
								
							| @@ -20,7 +20,6 @@ | ||||
| #include "CBuildingHandler.h" | ||||
| #include "CObjectHandler.h" | ||||
| #include "CGameInfo.h" | ||||
| #include "CPreGameTextHandler.h" //TODO - powinno by� w inicjowaniu preGame, ale to ty tam grzebiesz, wi�c ty to zr�b ;] | ||||
| #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) | ||||
| #  include <fcntl.h> | ||||
| #  include <io.h> | ||||
| @@ -213,7 +212,7 @@ int _tmain(int argc, _TCHAR* argv[]) | ||||
| 	{ | ||||
| 		TTF_Init(); | ||||
| 		atexit(TTF_Quit); | ||||
| 		TNRB = TTF_OpenFont("Fonts\\tnrb.ttf",18); | ||||
| 		TNRB = TTF_OpenFont("Fonts\\tnrb.ttf",16); | ||||
| 		screen = SDL_SetVideoMode(800,600,24,SDL_HWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); | ||||
| 		ekran = screen; | ||||
| 		//FILE * zr = fopen("mal.txt","r"); | ||||
| @@ -259,8 +258,6 @@ int _tmain(int argc, _TCHAR* argv[]) | ||||
| 		CObjectHandler * objh = new CObjectHandler; | ||||
| 		objh->loadObjects(); | ||||
| 		cgi->objh = objh; | ||||
| 		CPreGameTextHandler * preth = new CPreGameTextHandler; | ||||
| 		preth->loadTexts(); | ||||
| 		CAmbarCendamo * ac = new CAmbarCendamo("4gryf"); | ||||
| 		cgi->ac = ac; | ||||
| 		THC std::cout<<"Wczytywanie pliku: "<<tmh.getDif()<<std::endl; | ||||
|   | ||||
							
								
								
									
										31
									
								
								CMessage.cpp
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								CMessage.cpp
									
									
									
									
									
								
							| @@ -84,7 +84,8 @@ std::vector<std::string> * CMessage::breakText(std::string text) | ||||
| 		ret->push_back(text); | ||||
| 	return ret; | ||||
| } | ||||
| SDL_Surface * CMessage::genMessage(std::string title, std::string text, EWindowType type) | ||||
| SDL_Surface * CMessage::genMessage | ||||
| (std::string title, std::string text, EWindowType type, std::vector<CSemiDefHandler*> *addPics, void * cb) | ||||
| { | ||||
| //max x 320 okolo 30 znakow | ||||
| 	std::vector<std::string> * tekst; | ||||
| @@ -95,12 +96,17 @@ SDL_Surface * CMessage::genMessage(std::string title, std::string text, EWindowT | ||||
| 	} | ||||
| 	else tekst = breakText(text); | ||||
| 	int ww, hh; //wymiary boksa | ||||
| 	if (319>60*13*text.length()) | ||||
| 		ww = 60*13*text.length(); | ||||
| 	if (319>30+13*text.length()) | ||||
| 		ww = 30+13*text.length(); | ||||
| 	else ww = 319; | ||||
| 	if (title.length()) | ||||
| 		hh=130+(21*tekst->size()); | ||||
| 	else hh=80+(21*tekst->size()); | ||||
| 		hh=110+(21*tekst->size()); | ||||
| 	else hh=60+(21*tekst->size()); | ||||
| 	if (type==EWindowType::yesOrNO) //make place for buttons | ||||
| 	{ | ||||
| 		if (ww<200) ww=200;  | ||||
| 		hh+=70; | ||||
| 	} | ||||
|  | ||||
| 	SDL_Surface * ret = drawBox1(ww,hh); | ||||
| 	//prepare title text | ||||
| @@ -110,13 +116,26 @@ SDL_Surface * CMessage::genMessage(std::string title, std::string text, EWindowT | ||||
| 	SDL_BlitSurface(titleText,NULL,ret,&tytul); | ||||
| 	SDL_FreeSurface(titleText); | ||||
| 	//draw text | ||||
| 	for (int i=0; i<tekst->size(); i++) | ||||
| 	for (int i=0; i<tekst->size(); i++)  | ||||
| 	{ | ||||
| 		SDL_Surface * tresc = TTF_RenderText_Shaded(TNRB,(*tekst)[i].c_str(),zwykly,tlo); | ||||
| 		SDL_Rect trescRect = genRect(tresc->h,tresc->w,((ret->w/2)-(tresc->w/2)),77+i*21); | ||||
| 		SDL_BlitSurface(tresc,NULL,ret,&trescRect); | ||||
| 		SDL_FreeSurface(tresc); | ||||
| 	} | ||||
| 	if (type==EWindowType::yesOrNO) // add buttons | ||||
| 	{ | ||||
| 		int by = 40+77+tekst->size()*21; | ||||
| 		int hwo = (*addPics)[0]->ourImages[0].bitmap->w, hwc=(*addPics)[0]->ourImages[0].bitmap->w; | ||||
| 		//ok | ||||
| 		SDL_Rect trescRect = genRect((*addPics)[0]->ourImages[0].bitmap->h,hwo,((ret->w/2)-hwo-10),by); | ||||
| 		SDL_BlitSurface((*addPics)[0]->ourImages[0].bitmap,NULL,ret,&trescRect); | ||||
| 		((std::vector<SDL_Rect>*)(cb))->push_back(trescRect); | ||||
| 		//cancel | ||||
| 		trescRect = genRect((*addPics)[1]->ourImages[0].bitmap->h,hwc,((ret->w/2)+10),by); | ||||
| 		SDL_BlitSurface((*addPics)[1]->ourImages[0].bitmap,NULL,ret,&trescRect); | ||||
| 		((std::vector<SDL_Rect>*)(cb))->push_back(trescRect); | ||||
| 	} | ||||
| 	delete tekst; | ||||
| 	return ret; | ||||
| } | ||||
| @@ -10,7 +10,8 @@ public: | ||||
| 	std::vector<std::string> * breakText(std::string text); | ||||
| 	CSemiDefHandler * piecesOfBox; | ||||
| 	SDL_Surface * background; | ||||
| 	SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly); | ||||
| 	SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,  | ||||
| 								std::vector<CSemiDefHandler*> *addPics=NULL, void * cb=NULL); | ||||
| 	SDL_Surface * drawBox1(int w, int h); | ||||
| 	CMessage(); | ||||
| }; | ||||
							
								
								
									
										115
									
								
								CPreGame.cpp
									
									
									
									
									
								
							
							
						
						
									
										115
									
								
								CPreGame.cpp
									
									
									
									
									
								
							| @@ -4,6 +4,9 @@ | ||||
| #include "CMessage.h" | ||||
| extern SDL_Surface * ekran; | ||||
| SDL_Rect genRect(int hh, int ww, int xx, int yy); | ||||
| SDL_Color genRGB(int r, int g, int b, int a=0); | ||||
| CPreGame * CPG; | ||||
| void updateRect (SDL_Rect * rect, SDL_Surface * scr = ekran); | ||||
| bool isItIn(const SDL_Rect * rect, int x, int y) | ||||
| { | ||||
| 	if ((x>rect->x && x<rect->x+rect->w) && (y>rect->y && y<rect->y+rect->h)) | ||||
| @@ -12,9 +15,13 @@ bool isItIn(const SDL_Rect * rect, int x, int y) | ||||
| } | ||||
| CPreGame::CPreGame() | ||||
| { | ||||
| 	preth = new CPreGameTextHandler; | ||||
| 	preth->loadTexts(); | ||||
| 	currentMessage=NULL; | ||||
| 	behindCurMes=NULL; | ||||
| 	initMainMenu(); | ||||
| 	showMainMenu(); | ||||
| 	CPG=this; | ||||
| } | ||||
| void CPreGame::initMainMenu() | ||||
| { | ||||
| @@ -28,6 +35,8 @@ void CPreGame::initMainMenu() | ||||
| 	ourMainMenu->highScores = slh->giveDef("ZMENUHS.DEF"); | ||||
| 	ourMainMenu->credits = slh->giveDef("ZMENUCR.DEF"); | ||||
| 	ourMainMenu->quit = slh->giveDef("ZMENUQT.DEF"); | ||||
| 	ourMainMenu->ok = slh->giveDef("IOKAY.DEF"); | ||||
| 	ourMainMenu->cancel = slh->giveDef("ICANCEL.DEF"); | ||||
| 	// new game button location | ||||
| 	ourMainMenu->lNewGame.h=ourMainMenu->newGame->ourImages[0].bitmap->h; | ||||
| 	ourMainMenu->lNewGame.w=ourMainMenu->newGame->ourImages[0].bitmap->w; | ||||
| @@ -61,7 +70,6 @@ void CPreGame::initMainMenu() | ||||
| void CPreGame::showMainMenu() | ||||
| { | ||||
| 	SDL_BlitSurface(ourMainMenu->background,NULL,ekran,NULL); | ||||
| 	SDL_Flip(ekran); | ||||
| 	SDL_BlitSurface(ourMainMenu->newGame->ourImages[0].bitmap,NULL,ekran,&ourMainMenu->lNewGame); | ||||
| 	SDL_BlitSurface(ourMainMenu->loadGame->ourImages[0].bitmap,NULL,ekran,&ourMainMenu->lLoadGame); | ||||
| 	SDL_BlitSurface(ourMainMenu->highScores->ourImages[0].bitmap,NULL,ekran,&ourMainMenu->lHighScores); | ||||
| @@ -101,9 +109,59 @@ void CPreGame::highlightButton(int which, int on) | ||||
| 	} | ||||
| 	SDL_Flip(ekran); | ||||
| } | ||||
| void CPreGame::runLoop() | ||||
| void CPreGame::showCenBox (std::string data) | ||||
| { | ||||
| 	CMessage * cmh = new CMessage(); | ||||
| 	SDL_Surface * infoBox = cmh->genMessage(preth->getTitle(data), preth->getDescr(data)); | ||||
| 	behindCurMes = SDL_CreateRGBSurface(ekran->flags,infoBox->w,infoBox->h,ekran->format->BitsPerPixel,ekran->format->Rmask,ekran->format->Gmask,ekran->format->Bmask,ekran->format->Amask); | ||||
| 	SDL_Rect pos = genRect(infoBox->h,infoBox->w, | ||||
| 		(ekran->w/2)-(infoBox->w/2),(ekran->h/2)-(infoBox->h/2)); | ||||
| 	SDL_BlitSurface(ekran,&pos,behindCurMes,NULL); | ||||
| 	SDL_BlitSurface(infoBox,NULL,ekran,&pos); | ||||
| 	SDL_UpdateRect(ekran,pos.x,pos.y,pos.w,pos.h); | ||||
| 	SDL_FreeSurface(infoBox); | ||||
| 	currentMessage = new SDL_Rect(pos); | ||||
| 	delete cmh; | ||||
| } | ||||
| void CPreGame::showAskBox (std::string data, void(*f1)(),void(*f2)()) | ||||
| { | ||||
| 	CMessage * cmh = new CMessage(); | ||||
| 	std::vector<CSemiDefHandler*> * przyciski = new std::vector<CSemiDefHandler*>(0); | ||||
| 	std::vector<SDL_Rect> * btnspos= new std::vector<SDL_Rect>(0); | ||||
| 	przyciski->push_back(ourMainMenu->ok); | ||||
| 	przyciski->push_back(ourMainMenu->cancel); | ||||
| 	SDL_Surface * infoBox = cmh->genMessage(preth->getTitle(data), preth->getDescr(data), EWindowType::yesOrNO, przyciski, btnspos); | ||||
| 	behindCurMes = SDL_CreateRGBSurface(ekran->flags,infoBox->w,infoBox->h,ekran->format->BitsPerPixel,ekran->format->Rmask,ekran->format->Gmask,ekran->format->Bmask,ekran->format->Amask); | ||||
| 	SDL_Rect pos = genRect(infoBox->h,infoBox->w, | ||||
| 		(ekran->w/2)-(infoBox->w/2),(ekran->h/2)-(infoBox->h/2)); | ||||
| 	SDL_BlitSurface(ekran,&pos,behindCurMes,NULL); | ||||
| 	SDL_BlitSurface(infoBox,NULL,ekran,&pos); | ||||
| 	SDL_UpdateRect(ekran,pos.x,pos.y,pos.w,pos.h); | ||||
| 	SDL_FreeSurface(infoBox); | ||||
| 	currentMessage = new SDL_Rect(pos); | ||||
| 	(*btnspos)[0].x+=pos.x; | ||||
| 	(*btnspos)[0].y+=pos.y; | ||||
| 	(*btnspos)[1].x+=pos.x; | ||||
| 	(*btnspos)[1].y+=pos.y; | ||||
| 	btns.push_back(Button(1,(*btnspos)[0],&CPreGame::quit,ourMainMenu->ok)); | ||||
| 	btns.push_back(Button(2,(*btnspos)[1],(&CPreGame::hideBox),ourMainMenu->cancel)); | ||||
| 	delete cmh; | ||||
| 	delete przyciski; | ||||
| 	delete btnspos; | ||||
| } | ||||
| void CPreGame::hideBox () | ||||
| { | ||||
| 	SDL_BlitSurface(behindCurMes,NULL,ekran,currentMessage); | ||||
| 	SDL_UpdateRect | ||||
| 		(ekran,currentMessage->x,currentMessage->y,currentMessage->w,currentMessage->h); | ||||
| 	btns.clear(); | ||||
| 	SDL_FreeSurface(behindCurMes); | ||||
| 	delete currentMessage; | ||||
| 	currentMessage = NULL; | ||||
| 	behindCurMes=NULL; | ||||
| } | ||||
| void CPreGame::runLoop() | ||||
| { | ||||
| 	SDL_Event sEvent; | ||||
| 	while(true) | ||||
| 	{ | ||||
| @@ -204,6 +262,14 @@ void CPreGame::runLoop() | ||||
| 				} | ||||
| 				else if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_LEFT)) | ||||
| 				{ | ||||
| 					for (int i=0;i<btns.size(); i++) | ||||
| 					{ | ||||
| 						if (isItIn(&btns[i].pos,sEvent.motion.x,sEvent.motion.y)) | ||||
| 						{ | ||||
| 							SDL_BlitSurface((btns[i].imgs)->ourImages[1].bitmap,NULL,ekran,&btns[i].pos); | ||||
| 							updateRect(&btns[i].pos); | ||||
| 						} | ||||
| 					} | ||||
| 					if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 						highlightButton(1,1); | ||||
| @@ -232,6 +298,16 @@ void CPreGame::runLoop() | ||||
| 				} | ||||
| 				else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_LEFT)) | ||||
| 				{ | ||||
| 					for (int i=0;i<btns.size(); i++) | ||||
| 					{ | ||||
| 						if (isItIn(&btns[i].pos,sEvent.motion.x,sEvent.motion.y)) | ||||
| 							(this->*(btns[i].fun))(); | ||||
| 						else | ||||
| 						{ | ||||
| 							SDL_BlitSurface((btns[i].imgs)->ourImages[0].bitmap,NULL,ekran,&btns[i].pos); | ||||
| 							updateRect(&btns[i].pos); | ||||
| 						} | ||||
| 					} | ||||
| 					if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 						highlightButton(1,2); | ||||
| @@ -256,54 +332,35 @@ void CPreGame::runLoop() | ||||
| 					{ | ||||
| 						highlightButton(5,2); | ||||
| 						ourMainMenu->highlighted=5; | ||||
| 						showAskBox("\"{BBBB}BBDDDDDDDDDD\"",NULL,NULL); | ||||
| 					} | ||||
| 				} | ||||
| 				else if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_RIGHT)) | ||||
| 				{ | ||||
| 					if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 						showCenBox(preth->mainNewGame); | ||||
| 					} | ||||
| 					else if (isItIn(&ourMainMenu->lLoadGame,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 						showCenBox(preth->mainLoadGame); | ||||
| 					} | ||||
| 					else if (isItIn(&ourMainMenu->lHighScores,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 						showCenBox(preth->mainHighScores); | ||||
| 					} | ||||
| 					else if (isItIn(&ourMainMenu->lCredits,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 						showCenBox(preth->mainCredits); | ||||
| 					} | ||||
| 					else if (isItIn(&ourMainMenu->lQuit,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 						SDL_Surface * infoBox = cmh->genMessage("Quit", "Return to Windows"); | ||||
| 						//SDL_Surface * infoBox = cmh->genMessage("Quit", "View the legendary Heores of Might and Magic abbbba"); | ||||
| 						SDL_Rect pos = genRect(infoBox->h,infoBox->w, | ||||
| 							(ekran->w/2)-(infoBox->w/2),(ekran->h/2)-(infoBox->h/2)); | ||||
| 						SDL_BlitSurface(infoBox,NULL,ekran,&pos); | ||||
| 						SDL_UpdateRect(ekran,pos.x,pos.y,pos.w,pos.h); | ||||
| 						SDL_FreeSurface(infoBox); | ||||
| 						currentMessage = new SDL_Rect(pos); | ||||
| 						showCenBox(preth->mainQuit); | ||||
| 					} | ||||
| 				} | ||||
| 				else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_RIGHT)) | ||||
| 				else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_RIGHT) && currentMessage) | ||||
| 				{ | ||||
| 					if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 					} | ||||
| 					else if (isItIn(&ourMainMenu->lLoadGame,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 					} | ||||
| 					else if (isItIn(&ourMainMenu->lHighScores,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 					} | ||||
| 					else if (isItIn(&ourMainMenu->lCredits,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 					} | ||||
| 					else if (isItIn(&ourMainMenu->lQuit,sEvent.motion.x,sEvent.motion.y)) | ||||
| 					{ | ||||
| 						SDL_BlitSurface(ourMainMenu->background,currentMessage,ekran,currentMessage); | ||||
| 						SDL_UpdateRect | ||||
| 							(ekran,currentMessage->x,currentMessage->y,currentMessage->w,currentMessage->h); | ||||
| 					} | ||||
| 					hideBox(); | ||||
| 				} | ||||
| 				else if (sEvent.type==SDL_KEYDOWN) | ||||
| 				{ | ||||
|   | ||||
							
								
								
									
										35
									
								
								CPreGame.h
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								CPreGame.h
									
									
									
									
									
								
							| @@ -1,36 +1,43 @@ | ||||
| #include "SDL.h" | ||||
| #include "CSemiDefHandler.h" | ||||
| #include "CSemiLodHandler.h" | ||||
| //struct AnimatedPic | ||||
| //{ | ||||
| //	std::vector<SDL_Surface*> frames; | ||||
| //	~AnimatedPic() | ||||
| //	{ | ||||
| //		for (int i=0;i<frames.size();i++)  | ||||
| //		{ | ||||
| //			SDL_FreeSurface(frames[i]); | ||||
| //			delete frames[i]; | ||||
| //		} | ||||
| //	} | ||||
| //}; | ||||
| #include "CPreGameTextHandler.h"  | ||||
| class CPreGame; | ||||
| extern CPreGame * CPG; | ||||
| struct Button | ||||
| { | ||||
| 	int type; // 1=yes; 2=no | ||||
| 	SDL_Rect pos; | ||||
| 	(void)(CPreGame::*fun)(); | ||||
| 	CSemiDefHandler* imgs; | ||||
| 	Button(int Type, SDL_Rect Pos, void(CPreGame::*Fun)(),CSemiDefHandler* Imgs):imgs(Imgs),type(Type),pos(Pos),fun(Fun){}; | ||||
| 	Button(){}; | ||||
| }; | ||||
| class CPreGame | ||||
| { | ||||
| public: | ||||
| 	SDL_Rect * currentMessage; | ||||
| 	std::vector<Button> btns; | ||||
| 	CPreGameTextHandler * preth ; | ||||
| 	SDL_Rect * currentMessage;	 | ||||
| 	SDL_Surface * behindCurMes; | ||||
| 	enum EState { //where are we? | ||||
| 		mainMenu, ScenarioList | ||||
| 	} state; | ||||
| 	struct menuItems {  | ||||
| 		SDL_Surface * background; | ||||
| 		CSemiDefHandler *newGame, *loadGame, *highScores,*credits, *quit; | ||||
| 		CSemiDefHandler *newGame, *loadGame, *highScores,*credits, *quit, *ok, *cancel; | ||||
| 		SDL_Rect lNewGame, lLoadGame, lHighScores, lCredits, lQuit; | ||||
| 		int highlighted;//0=none; 1=new game; 2=load game; 3=high score; 4=credits; 5=quit | ||||
| 	} * ourMainMenu, * newGameManu; | ||||
| 	std::string map; //selected map | ||||
| 	std::vector<CSemiLodHandler *> handledLods;  | ||||
| 	CPreGame(); //c-tor | ||||
| 	void quit(){exit(0);};   | ||||
| 	void showMainMenu();   | ||||
| 	void runLoop(); // runs mainloop of PreGame | ||||
| 	void initMainMenu(); //loads components for main menu | ||||
| 	void highlightButton(int which, int on); | ||||
| 	void showCenBox (std::string data); | ||||
| 	void showAskBox (std::string data, void(*f1)(),void(*f2)()); | ||||
| 	void hideBox (); | ||||
| }; | ||||
| @@ -1,6 +1,24 @@ | ||||
| #include "CPreGameTextHandler.h" | ||||
| #include "stdafx.h" | ||||
|  | ||||
| #include "CPreGameTextHandler.h" | ||||
| std::string CPreGameTextHandler::getTitle(std::string text) | ||||
| { | ||||
| 	std::string ret; | ||||
| 	int i=0; | ||||
| 	while ((text[i++]!='{')); | ||||
| 	while ((text[i]!='}') && (i<text.length())) | ||||
| 		ret+=text[i++]; | ||||
| 	return ret; | ||||
| } | ||||
| std::string CPreGameTextHandler::getDescr(std::string text) | ||||
| { | ||||
| 	std::string ret; | ||||
| 	int i=0; | ||||
| 	while ((text[i++]!='}')); | ||||
| 	i+=2; | ||||
| 	while ((text[i]!='"') && (i<text.length())) | ||||
| 		ret+=text[i++]; | ||||
| 	return ret; | ||||
| } | ||||
| void CPreGameTextHandler::loadTexts() | ||||
| { | ||||
| 	std::ifstream inp("H3bitmap.lod\\ZELP.TXT", std::ios::in|std::ios::binary); | ||||
|   | ||||
| @@ -7,6 +7,8 @@ class CPreGameTextHandler //handles pre - game texts | ||||
| { | ||||
| public: | ||||
| 	std::string mainNewGame, mainLoadGame, mainHighScores, mainCredits, mainQuit; //right - click texts in main menu | ||||
| 	std::string getTitle(std::string text); | ||||
| 	std::string getDescr(std::string text); | ||||
| 	void loadTexts(); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| #include "stdafx.h" | ||||
| #include "SDL_Extensions.h" | ||||
| extern SDL_Surface * ekran; | ||||
| SDL_Rect genRect(int hh, int ww, int xx, int yy) | ||||
| { | ||||
| 	SDL_Rect ret; | ||||
| @@ -9,6 +10,19 @@ SDL_Rect genRect(int hh, int ww, int xx, int yy) | ||||
| 	ret.y=yy; | ||||
| 	return ret; | ||||
| } | ||||
| SDL_Color genRGB(int r, int g, int b, int a=0) | ||||
| { | ||||
| 	SDL_Color ret; | ||||
| 	ret.b=b; | ||||
| 	ret.g=g; | ||||
| 	ret.r=r; | ||||
| 	ret.unused=a; | ||||
| 	return ret; | ||||
| } | ||||
| void updateRect (SDL_Rect * rect, SDL_Surface * scr = ekran) | ||||
| { | ||||
| 	SDL_UpdateRect(scr,rect->x,rect->y,rect->w,rect->h); | ||||
| } | ||||
| void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC) | ||||
| { | ||||
|      Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user