From 23a7b708d870b966e95ec6f00186a634e677c5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Thu, 6 Mar 2008 18:54:35 +0000 Subject: [PATCH] * 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 --- CCastleInterface.cpp | 75 +++++++++++++++++++++++++++++++++++++------ CCastleInterface.h | 2 +- CMT.cpp | 2 +- CMessage.cpp | 26 +++++++++++++++ CMessage.h | 1 + CPlayerInterface.cpp | 34 +++++++++++--------- CPlayerInterface.h | 9 +++--- h3m.txt | Bin 108670 -> 108246 bytes hch/CDefHandler.cpp | Bin 27212 -> 27448 bytes hch/CDefHandler.h | Bin 3494 -> 3534 bytes 10 files changed, 118 insertions(+), 31 deletions(-) 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 e3dfa98a7d3c760e6c99d0d29a7c74904e91d94d..e025647b316faf08679bc295fca9f3bc7096c4f8 100644 GIT binary patch delta 55 zcmex&f$iE^whi05+`8S;QQnL&Y}grSn507&ODWHKZ&6a)E*n?HAHGBz*k-M*}s H@rD!t4)_wa delta 383 zcmYLF%SyvQ6g?vttu!D=7wx74ZZe<}7Ybb!6vPkE4~V2lv>Hi9N<`?QyB4aDMSr6p z=-Lku+$i`Rt}C895#%zjd+s^+-1&U-e%`(L^SGREwp3a^oHqObA;X|6@$@k^O2A=? z9cY}Oha46u28eK=dbncNB4Z}U9WK#S8Ue9BD>bf>@Eo|k%4{<$+{~$HoS|UmhJ5>1 zmm#K7f)!_!5nKPAXm_>RZ9b%7 diff --git a/hch/CDefHandler.cpp b/hch/CDefHandler.cpp index 31ab9ee412eff08c1749677147b22ee8ca60e4e5..a567453a7712106933b60199121e317cc05e8e08 100644 GIT binary patch delta 66 zcmV-I0KNar)B(8G0kAR&lcH%F1v&sa0DhC9X&VVB04V?s015zmli?K~lkiXklR_61 YlNc5blO#?MlaL5blej1=1fp9zcr diff --git a/hch/CDefHandler.h b/hch/CDefHandler.h index ac7f1ed721d66d61c1b931f862290fc5a29099bb..e278fc62de7ac6dd5fcd8a7fc99de1c6677f8cc8 100644 GIT binary patch delta 22 ecmZ1`eNK8q4)0_Q4xWj(gqSrLG$*I>IsyP!{|34M delta 11 ScmX>ny-a#T4)5eCyjB1lmIOio