浏览代码

* right click popups in towns
* drawing window text-bitmap-subtitle
* destructor for CDefEssential
* version changed to 0.5x (or maybe it should be 0.6 ?)
* minor changes

Michał W. Urbańczyk 17 年之前
父节点
当前提交
23a7b708d8
共有 10 个文件被更改,包括 116 次插入29 次删除
  1. 66 9
      CCastleInterface.cpp
  2. 1 1
      CCastleInterface.h
  3. 1 1
      CMT.cpp
  4. 26 0
      CMessage.cpp
  5. 1 0
      CMessage.h
  6. 17 13
      CPlayerInterface.cpp
  7. 4 5
      CPlayerInterface.h
  8. 二进制
      h3m.txt
  9. 二进制
      hch/CDefHandler.cpp
  10. 二进制
      hch/CDefHandler.h

+ 66 - 9
CCastleInterface.cpp

@@ -7,7 +7,9 @@
 #include "CAdvmapInterface.h"
 #include "hch/CTownHandler.h"
 #include "AdventureMapButton.h"
+#include "hch/CBuildingHandler.h"
 #include <sstream>
+#include "CMessage.h"
 CBuildingRect::CBuildingRect(Structure *Str)
 :str(Str)
 {	
@@ -77,11 +79,31 @@ void CBuildingRect::hover(bool on)
 }
 void CBuildingRect::clickLeft (tribool down)
 {
+	
+	if(area && (CSDL_Ext::SDL_GetPixel(area,LOCPLINT->current->motion.x-pos.x,LOCPLINT->current->motion.y-pos.y) != 0)) //na polu
+	{
+	}
+
+	
 	//todo - handle
 }
 void CBuildingRect::clickRight (tribool down)
 {
-	//todo - handle
+	if((!area) || (!((bool)down)))
+		return;
+	if((CSDL_Ext::SDL_GetPixel(area,LOCPLINT->current->motion.x-pos.x,LOCPLINT->current->motion.y-pos.y) != 0)) //na polu
+	{
+		CInfoPopup *vinya = new CInfoPopup();
+		vinya->free = true;
+		vinya->bitmap = CMessage::drawBoxTextBitmapSub
+			(LOCPLINT->playerID,
+			CGI->buildh->buildings[str->townID][str->ID]->description, 
+			LOCPLINT->castleInt->bicons->ourImages[str->ID].bitmap, 
+			CGI->buildh->buildings[str->townID][str->ID]->name);
+		vinya->pos.x = ekran->w/2 - vinya->bitmap->w/2;
+		vinya->pos.y = ekran->h/2 - vinya->bitmap->h/2;
+		vinya->activate();
+	}
 }
 
 void CBuildingRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
@@ -103,13 +125,19 @@ void CBuildingRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
 				if((*LOCPLINT->castleInt->hBuild)<(*this)) //ustawiamy sie, jesli jestesmy na wierzchu
 				{
 					LOCPLINT->castleInt->hBuild = this;
-					LOCPLINT->statusbar->print(str->name);
+					if(CGI->buildh->buildings[str->townID][str->ID] && CGI->buildh->buildings[str->townID][str->ID]->name.length())
+						LOCPLINT->statusbar->print(CGI->buildh->buildings[str->townID][str->ID]->name);
+					else
+						LOCPLINT->statusbar->print(str->name);
 				}
 			}
 			else //nie ma budynku, wiec damy nasz
 			{
 				LOCPLINT->castleInt->hBuild = this;
-				LOCPLINT->statusbar->print(str->name);
+				if(CGI->buildh->buildings[str->townID][str->ID] && CGI->buildh->buildings[str->townID][str->ID]->name.length())
+					LOCPLINT->statusbar->print(CGI->buildh->buildings[str->townID][str->ID]->name);
+				else
+					LOCPLINT->statusbar->print(str->name);
 			}
 		}
 	}
@@ -247,6 +275,40 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
 		showAll();
 	}
 
+	std::string defname;
+	switch (town->subID)
+	{
+	case 0:
+		defname = "HALLCSTL.DEF";
+		break;
+	case 1:
+		defname = "HALLRAMP.DEF";
+		break;
+	case 2:
+		defname = "HALLTOWR.DEF";
+		break;
+	case 3:
+		defname = "HALLINFR.DEF";
+		break;
+	case 4:
+		defname = "HALLNECR.DEF";
+		break;
+	case 5:
+		defname = "HALLDUNG.DEF";
+		break;
+	case 6:
+		defname = "HALLSTRN.DEF";
+		break;
+	case 7:
+		defname = "HALLFORT.DEF";
+		break;
+	case 8:
+		defname = "HALLELEM.DEF";
+		break;
+	default:
+		throw new std::exception("Bad town subID");
+	}
+	bicons = CGI->spriteh->giveDefEss(defname);
 	//blit buildings on bg
 	//for(int i=0;i<buildings.size();i++)
 	//{
@@ -269,6 +331,7 @@ CCastleInterface::~CCastleInterface()
 	{
 		delete buildings[i];
 	}
+	delete bicons;
 
 }
 void CCastleInterface::close()
@@ -407,12 +470,6 @@ void CCastleInterface::show(SDL_Surface * to)
 		if(hBuild==buildings[i] && hBuild->border)
 			blitAt(hBuild->border,hBuild->pos,to);
 	}
-	//for(int i=0;i<buildings.size();i++)
-	//{
-	//	if((animval)%(buildings[i]->def->ourImages.size())==0)
-	//		blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
-	//	else continue;
-	//}
 	
 }
 void CCastleInterface::activate()

+ 1 - 1
CCastleInterface.h

@@ -37,7 +37,7 @@ public:
 	unsigned char animval, count;
 
 	CDefHandler *hall,*fort, *flag;
-
+	CDefEssential* bicons; //150x70 buildings imgs
 	CTownList<CCastleInterface> * townlist;
 
 	CGarrisonInt * garr;

+ 1 - 1
CMT.cpp

@@ -62,7 +62,7 @@
 CGameInfo* CGI;
 #endif
 #define CHUNK 16384
-const char * NAME = "VCMI 0.55 \"Tirion\" Techdemo";
+const char * NAME = "VCMI 0.5x \"Tirion\" Techdemo";
 
 SDL_Color playerColorPalette[256]; //palette to make interface colors good
 

+ 26 - 0
CMessage.cpp

@@ -436,6 +436,32 @@ std::vector< std::vector<CSelectableComponent*> > * CMessage::breakComps(std::ve
 	}
 	return ret;
 }
+
+SDL_Surface * CMessage::drawBoxTextBitmapSub(int player, std::string text, SDL_Surface* bitmap, std::string sub, int charperline)
+{
+	int curh;
+	std::vector<std::string> * tekst = breakText(text,charperline);
+	std::vector<std::vector<SDL_Surface*> > * txtg = drawText(tekst);
+	std::pair<int,int> txts = getMaxSizes(txtg), boxs;
+	boxs.first = std::max(txts.first,bitmap->w) // text/bitmap max width
+		+ 50; //side margins
+	boxs.second = 
+		(curh=45) //top margin
+		+ txts.second //text total height
+		+ 55 //text <=> img
+		+ bitmap->h
+		+ 5 // to sibtitle
+		+ (*txtg)[0][0]->h
+		+ 30;
+	SDL_Surface *ret = drawBox1(boxs.first,boxs.second,player);
+	blitTextOnSur(txtg,curh,ret);
+	curh += 55;
+	blitAt(bitmap,(ret->w/2)-(bitmap->w/2),curh,ret);
+	curh += bitmap->h + 5;
+	CSDL_Ext::printAtMiddle(sub,ret->w/2,curh+(  ((*txtg)[0][0]->h) / 2  ),GEOR13,zwykly,ret);
+	return ret;
+}
+
 CSelWindow * CMessage::genSelWindow(std::string text, int player, int charperline, std::vector<CSelectableComponent*> & comps, int owner)
 {
 	CSelWindow * ret = new CSelWindow();

+ 1 - 0
CMessage.h

@@ -37,6 +37,7 @@ public:
 	static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly, 
 								std::vector<CDefHandler*> *addPics=NULL, void * cb=NULL);
 	static SDL_Surface * drawBox1(int w, int h, int playerColor=1);
+	static SDL_Surface * drawBoxTextBitmapSub(int player, std::string text, SDL_Surface* bitmap, std::string sub, int charperline=30);
 	static std::vector<std::string> * breakText(std::string text, int line=30, bool userBreak=true, bool ifor=true); //line - chars per line
 	CMessage();
 	static void init();

+ 17 - 13
CPlayerInterface.cpp

@@ -378,29 +378,33 @@ CInfoWindow::~CInfoWindow()
 {
 }
 
-CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free)
-:bitmap(Bitmap),free(Free)
+void CRClickPopup::clickRight (tribool down)
 {
-	pos.x = x;
-	pos.y = y;
-	pos.h = bitmap->h;
-	pos.w = bitmap->w;
-}
-void CInfoPopup::clickRight (tribool down)
-{
-	//if(!down)
-		close();
+	if(down)
+		return;
+	close();
 }
-void CInfoPopup::activate()
+
+void CRClickPopup::activate()
 {
 	ClickableR::activate();
 	LOCPLINT->objsToBlit.push_back(this);
 }
-void CInfoPopup::deactivate()
+
+void CRClickPopup::deactivate()
 {
 	ClickableR::deactivate();
 	LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
 }
+
+CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free)
+:bitmap(Bitmap),free(Free)
+{
+	pos.x = x;
+	pos.y = y;
+	pos.h = bitmap->h;
+	pos.w = bitmap->w;
+}
 void CInfoPopup::close()
 {
 	deactivate();

+ 4 - 5
CPlayerInterface.h

@@ -152,9 +152,10 @@ public:
 class CRClickPopup : public IShowable, public ClickableR
 {
 public:
-	virtual void activate()=0;
-	virtual void deactivate()=0;
+	virtual void activate();
+	virtual void deactivate();
 	virtual void close()=0;
+	void clickRight (tribool down);
 	virtual ~CRClickPopup(){};
 };
 
@@ -164,11 +165,9 @@ public:
 	bool free;
 	SDL_Surface * bitmap;
 	CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false);
-	void clickRight (tribool down);
-	void activate();
-	void deactivate();
 	void close();
 	void show(SDL_Surface * to = NULL);
+	CInfoPopup(){free=false;bitmap=NULL;}
 	~CInfoPopup(){};
 };
 

二进制
h3m.txt


二进制
hch/CDefHandler.cpp


二进制
hch/CDefHandler.h