1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

* 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
This commit is contained in:
Michał W. Urbańczyk 2008-03-06 18:54:35 +00:00
parent f1e40d5e86
commit 23a7b708d8
10 changed files with 118 additions and 31 deletions

View File

@ -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,12 +125,18 @@ void CBuildingRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
if((*LOCPLINT->castleInt->hBuild)<(*this)) //ustawiamy sie, jesli jestesmy na wierzchu
{
LOCPLINT->castleInt->hBuild = this;
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;
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()

View File

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

View File

@ -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

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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(){};
};

BIN
h3m.txt

Binary file not shown.

Binary file not shown.

Binary file not shown.