diff --git a/CCastleInterface.cpp b/CCastleInterface.cpp index 1356ad688..30a5115ac 100644 --- a/CCastleInterface.cpp +++ b/CCastleInterface.cpp @@ -7,7 +7,9 @@ #include "CAdvmapInterface.h" #include "hch/CTownHandler.h" #include "AdventureMapButton.h" +#include "hch/CBuildingHandler.h" #include +#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;iborder) blitAt(hBuild->border,hBuild->pos,to); } - //for(int i=0;idef->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() diff --git a/CCastleInterface.h b/CCastleInterface.h index ac395c993..cee2aaacb 100644 --- a/CCastleInterface.h +++ b/CCastleInterface.h @@ -37,7 +37,7 @@ public: unsigned char animval, count; CDefHandler *hall,*fort, *flag; - + CDefEssential* bicons; //150x70 buildings imgs CTownList * townlist; CGarrisonInt * garr; diff --git a/CMT.cpp b/CMT.cpp index 7b6597854..5fd766004 100644 --- a/CMT.cpp +++ b/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 diff --git a/CMessage.cpp b/CMessage.cpp index eff604471..7f33bc537 100644 --- a/CMessage.cpp +++ b/CMessage.cpp @@ -436,6 +436,32 @@ std::vector< std::vector > * 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 * tekst = breakText(text,charperline); + std::vector > * txtg = drawText(tekst); + std::pair 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 & comps, int owner) { CSelWindow * ret = new CSelWindow(); diff --git a/CMessage.h b/CMessage.h index 4b974601c..6ec362a3a 100644 --- a/CMessage.h +++ b/CMessage.h @@ -37,6 +37,7 @@ public: static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly, std::vector *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 * breakText(std::string text, int line=30, bool userBreak=true, bool ifor=true); //line - chars per line CMessage(); static void init(); diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index ad52bf338..d142268b9 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -378,6 +378,25 @@ CInfoWindow::~CInfoWindow() { } +void CRClickPopup::clickRight (tribool down) +{ + if(down) + return; + close(); +} + +void CRClickPopup::activate() +{ + ClickableR::activate(); + LOCPLINT->objsToBlit.push_back(this); +} + +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) { @@ -386,21 +405,6 @@ CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free) pos.h = bitmap->h; pos.w = bitmap->w; } -void CInfoPopup::clickRight (tribool down) -{ - //if(!down) - close(); -} -void CInfoPopup::activate() -{ - ClickableR::activate(); - LOCPLINT->objsToBlit.push_back(this); -} -void CInfoPopup::deactivate() -{ - ClickableR::deactivate(); - LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this)); -} void CInfoPopup::close() { deactivate(); diff --git a/CPlayerInterface.h b/CPlayerInterface.h index 3093364ff..30b798273 100644 --- a/CPlayerInterface.h +++ b/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(){}; }; diff --git a/h3m.txt b/h3m.txt index e3dfa98a7..e025647b3 100644 Binary files a/h3m.txt and b/h3m.txt differ diff --git a/hch/CDefHandler.cpp b/hch/CDefHandler.cpp index 31ab9ee41..a567453a7 100644 Binary files a/hch/CDefHandler.cpp and b/hch/CDefHandler.cpp differ diff --git a/hch/CDefHandler.h b/hch/CDefHandler.h index ac7f1ed72..e278fc62d 100644 Binary files a/hch/CDefHandler.h and b/hch/CDefHandler.h differ