mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Nearly working borders of buildings.
This commit is contained in:
parent
315f92ef14
commit
8fea2b87b8
@ -242,7 +242,9 @@ const CGHeroInstance * CCallback::getHeroInfo(int player, int val, bool mode) //
|
||||
if (gs->currentPlayer!=player) //TODO: checking if we are allowed to give that info
|
||||
return NULL;
|
||||
if (!mode)
|
||||
return gs->players[player].heroes[val];
|
||||
if(val<gs->players[player].heroes.size())
|
||||
return gs->players[player].heroes[val];
|
||||
else return NULL;
|
||||
else
|
||||
{
|
||||
for (int i=0; i<gs->players[player].heroes.size();i++)
|
||||
|
@ -13,7 +13,14 @@ CBuildingRect::CBuildingRect(Structure *Str)
|
||||
:str(Str)
|
||||
{
|
||||
def = CGI->spriteh->giveDef(Str->defName);
|
||||
border = area = NULL;
|
||||
if (border = CGI->bitmaph->loadBitmap(str->borderName))
|
||||
SDL_SetColorKey(border,SDL_SRCCOLORKEY,SDL_MapRGB(border->format,0,255,255));
|
||||
else
|
||||
std::cout << "Warning: no border for "<<Str->ID<<std::endl;
|
||||
if (area = CGI->bitmaph->loadBitmap(str->areaName))
|
||||
;//SDL_SetColorKey(area,SDL_SRCCOLORKEY,SDL_MapRGB(area->format,0,255,255));
|
||||
else
|
||||
std::cout << "Warning: no area for "<<Str->ID<<std::endl;
|
||||
pos.x = str->pos.x;
|
||||
pos.y = str->pos.y;
|
||||
pos.w = def->ourImages[0].bitmap->w;
|
||||
@ -30,13 +37,13 @@ CBuildingRect::~CBuildingRect()
|
||||
}
|
||||
void CBuildingRect::activate()
|
||||
{
|
||||
MotionInterested::activate();
|
||||
Hoverable::activate();
|
||||
ClickableL::activate();
|
||||
ClickableR::activate();
|
||||
}
|
||||
void CBuildingRect::deactivate()
|
||||
{
|
||||
MotionInterested::deactivate();
|
||||
Hoverable::deactivate();
|
||||
ClickableL::deactivate();
|
||||
ClickableR::deactivate();
|
||||
}
|
||||
@ -47,9 +54,19 @@ bool CBuildingRect::operator<(const CBuildingRect & p2) const
|
||||
else
|
||||
return (str->ID) < (p2.str->ID);
|
||||
}
|
||||
void CBuildingRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
|
||||
void CBuildingRect::hover(bool on)
|
||||
{
|
||||
//todo - handle
|
||||
if(area)
|
||||
{
|
||||
if(CSDL_Ext::SDL_GetPixel(area,LOCPLINT->current->motion.x-pos.x,LOCPLINT->current->motion.y-pos.y) == 0)
|
||||
{
|
||||
Hoverable::hover(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Hoverable::hover(on);
|
||||
if(border)
|
||||
blitAt(border,pos.x,pos.y);
|
||||
}
|
||||
void CBuildingRect::clickLeft (tribool down)
|
||||
{
|
||||
@ -264,6 +281,8 @@ void CCastleInterface::show(SDL_Surface * to)
|
||||
animval++;
|
||||
}
|
||||
|
||||
blitAt(cityBg,0,0,to);
|
||||
|
||||
|
||||
//blit buildings
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
@ -275,6 +294,8 @@ void CCastleInterface::show(SDL_Surface * to)
|
||||
}
|
||||
else
|
||||
blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
|
||||
if(buildings[i]->hovered && buildings[i]->border)
|
||||
blitAt(buildings[i]->border,buildings[i]->pos.x,buildings[i]->pos.y);
|
||||
}
|
||||
//for(int i=0;i<buildings.size();i++)
|
||||
//{
|
||||
@ -287,10 +308,12 @@ void CCastleInterface::show(SDL_Surface * to)
|
||||
void CCastleInterface::activate()
|
||||
{
|
||||
LOCPLINT->curint = this;
|
||||
//for(int i=0;i<buildings.size();i++)
|
||||
// buildings[i]->activate();
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
buildings[i]->activate();
|
||||
}
|
||||
void CCastleInterface::deactivate()
|
||||
{
|
||||
exit->deactivate();
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
buildings[i]->deactivate();
|
||||
}
|
@ -7,7 +7,7 @@ class CGTownInstance;
|
||||
class CTownHandler;
|
||||
struct Structure;
|
||||
template <typename T> class AdventureMapButton;
|
||||
class CBuildingRect : public MotionInterested, public ClickableL, public ClickableR//, public TimeInterested
|
||||
class CBuildingRect : public Hoverable, public ClickableL, public ClickableR//, public TimeInterested
|
||||
{
|
||||
public:
|
||||
Structure* str;
|
||||
@ -19,7 +19,7 @@ public:
|
||||
void activate();
|
||||
void deactivate();
|
||||
bool operator<(const CBuildingRect & p2) const;
|
||||
void mouseMoved (SDL_MouseMotionEvent & sEvent);
|
||||
void hover(bool on);
|
||||
void clickLeft (tribool down);
|
||||
void clickRight (tribool down);
|
||||
};
|
||||
|
1
CMT.cpp
1
CMT.cpp
@ -276,6 +276,7 @@ void initGameState(CGameInfo * cgi)
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
//std::ios_base::sync_with_stdio(0);
|
||||
//CLuaHandler luatest;
|
||||
//luatest.test();
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "hch/CGeneralTextHandler.h"
|
||||
#include "CCastleInterface.h"
|
||||
#include "CHeroWindow.h"
|
||||
#include "timeHandler.h"
|
||||
using namespace CSDL_Ext;
|
||||
|
||||
class OCM_HLP_CGIN
|
||||
@ -1235,7 +1236,10 @@ SDL_Surface * CPlayerInterface::drawTownInfoWin(const CGTownInstance * curh)
|
||||
void CPlayerInterface::openTownWindow(const CGTownInstance * town)
|
||||
{
|
||||
adventureInt->hide();
|
||||
timeHandler t;
|
||||
t.getDif();
|
||||
castleInt = new CCastleInterface(town,true);
|
||||
std::cout << "Loading town screen: " << t.getDif() <<std::endl;
|
||||
}
|
||||
|
||||
SDL_Surface * CPlayerInterface::infoWin(const CGObjectInstance * specific) //specific=0 => draws info about selected town/hero
|
||||
|
37
config/buildings3.txt
Normal file
37
config/buildings3.txt
Normal file
@ -0,0 +1,37 @@
|
||||
0 16 TBCSBLAK.def TOCSBLAK.bmp TZCSBLAK.bmp
|
||||
0 20 TBCSBOAT.def TOCSDKMN.bmp TZCSDKMN.bmp
|
||||
0 8 TBCSCAS2.def TOCSCAS2.bmp TZCSCAS2.bmp
|
||||
0 9 TBCSCAS3.def TOCSCAS3.bmp TZCSCAS3.bmp
|
||||
0 7 TBCSCSTL.def TOCSCAS1.bmp TZCSCAS1.bmp
|
||||
0 6 TBCSDOCK.def TOCSDKMS.bmp TZCSDKMS.bmp
|
||||
0 30 TBCSDW0_.def TOCSPIK1.bmp TZCSPIK1.bmp
|
||||
0 31 TBCSDW_1.def TOCSCRS1.bmp TZCSCRS1.bmp
|
||||
0 32 TBCSDW_2.def TOCSGR1N.bmp TZCSGR1N.bmp
|
||||
0 33 TBCSDW_3.def TOCSSWD1.bmp TZCSSWD1.bmp
|
||||
0 34 TBCSDW_4.def TOCSMON1.bmp TZCSMON1.bmp
|
||||
0 35 TBCSDW_5.def TOCSC101.bmp TZCSCAV1.bmp
|
||||
0 36 TBCSDW_6.def TOCSANG1.bmp TZCSANG1.bmp
|
||||
0 21 TBCSEXT0.def TOCSCAVM.bmp TZCSCAVM.bmp
|
||||
0 22 TBCSEXT1.def TOCSTAV2.bmp TZCSTAV2.bmp
|
||||
0 11 TBCSHAL2.def TOCSH201.bmp TZCSH201.bmp
|
||||
0 12 TBCSHAL3.def TOCSH301.bmp TZCSH301.bmp
|
||||
0 13 TBCSHAL4.def TOCSH401.bmp TZCSH401.bmp
|
||||
0 10 TBCSHALL.def TOCSH101.bmp TZCSH101.bmp
|
||||
0 26 TBCSHOLY.def TOCSHOLY.bmp TZCSHOLY.bmp
|
||||
0 18 TBCSHRD1.def TOCSGR1H.bmp TZCSGR1H.bmp
|
||||
0 19 TBCSHRD2.def TOCSGR2H.bmp TZCSGR2H.bmp
|
||||
0 1 TBCSMAG2.def TOCSMAG2.bmp TZCSMAG2.bmp
|
||||
0 2 TBCSMAG3.def TOCSM301.bmp TZCSM301.bmp
|
||||
0 3 TBCSMAG4.def TOCSM401.bmp TZCSM401.bmp
|
||||
0 0 TBCSMAGE.def TOCSMAG1.bmp TZCSMAG1.bmp
|
||||
0 14 TBCSMARK.def TOCSMRK1.bmp TZCSMRK1.bmp
|
||||
0 15 TBCSSILO.def TOCSMRK2.bmp TZCSMRK2.bmp
|
||||
0 17 TBCSSPEC.def TOCSLT01.bmp TZCSLT01.bmp
|
||||
0 5 TBCSTVRN.def TOCSTAV1.bmp TZCSTAV1.bmp
|
||||
0 37 TBCSUP0_.def TOCSPIK2.bmp TZCSPIK2.bmp
|
||||
0 38 TBCSUP_1.def TOCSCRS2.bmp TZCSCRS2.bmp
|
||||
0 39 TBCSUP_2.def TOCSGR2N.bmp TZCSGR2N.bmp
|
||||
0 40 TBCSUP_3.def TOCSSWD2.bmp TZCSSWD2.bmp
|
||||
0 41 TBCSUP_4.def TOCSMON2.bmp TZCSMON2.bmp
|
||||
0 42 TBCSUP_5.def TOCSCAV2.bmp TZCSCAV2.bmp
|
||||
0 43 TBCSUP_6.def TOCSANG2.bmp TZCSANG2.bmp
|
@ -254,6 +254,8 @@ SDL_Surface * CPCXConv::getSurface()
|
||||
}
|
||||
SDL_Surface * CLodHandler::loadBitmap(std::string fname)
|
||||
{
|
||||
if(!fname.size())
|
||||
return NULL;
|
||||
unsigned char * pcx;
|
||||
std::transform(fname.begin(),fname.end(),fname.begin(),toupper);
|
||||
fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX");
|
||||
@ -270,6 +272,7 @@ SDL_Surface * CLodHandler::loadBitmap(std::string fname)
|
||||
if(index==-1)
|
||||
{
|
||||
std::cout<<"File "<<fname<<" not found"<<std::endl;
|
||||
return NULL;
|
||||
}
|
||||
fseek(FLOD, entries[index].offset, 0);
|
||||
if (entries[index].size==0) //file is not compressed
|
||||
|
@ -86,13 +86,38 @@ void CTownHandler::loadNames()
|
||||
if((i2=(i->second.find(buildingID=atoi(s.c_str()))))!=(i->second.end()))
|
||||
i2->second->pos.z=itr++;
|
||||
else
|
||||
std::cout << "Warning: No building "<<buildingID<<" in the castle "<<castleID<<std::endl;
|
||||
std::cout << "Warning1: No building "<<buildingID<<" in the castle "<<castleID<<std::endl;
|
||||
else
|
||||
std::cout << "Warning: Castle "<<castleID<<" not defined."<<std::endl;
|
||||
std::cout << "Warning1: Castle "<<castleID<<" not defined."<<std::endl;
|
||||
}
|
||||
}
|
||||
of.close();
|
||||
|
||||
of.clear();
|
||||
|
||||
of.open("config/buildings3.txt");
|
||||
while(!of.eof())
|
||||
{
|
||||
std::map<int,std::map<int, Structure*> >::iterator i;
|
||||
std::map<int, Structure*>::iterator i2;
|
||||
int town, id;
|
||||
std::string border, area;
|
||||
of >> town >> id >> border >> border >> area;
|
||||
|
||||
if((i=structures.find(town))!=structures.end())
|
||||
if((i2=(i->second.find(id)))!=(i->second.end()))
|
||||
{
|
||||
i2->second->borderName = border;
|
||||
i2->second->areaName = area;
|
||||
}
|
||||
else
|
||||
std::cout << "Warning2: No building "<<id<<" in the castle "<<town<<std::endl;
|
||||
else
|
||||
std::cout << "Warning2: Castle "<<town<<" not defined."<<std::endl;
|
||||
|
||||
}
|
||||
of.close();
|
||||
of.clear();
|
||||
|
||||
}
|
||||
SDL_Surface * CTownHandler::getPic(int ID, bool fort, bool builded)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ struct Structure
|
||||
{
|
||||
int ID;
|
||||
int3 pos;
|
||||
std::string defName;
|
||||
std::string defName, borderName, areaName;
|
||||
int townID;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user