mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Buildings in town (tylko zamek, trzeba inaczej sortować, jeden budynek źle trafiony)
This commit is contained in:
parent
bce31ba91b
commit
4b772315bb
@ -34,6 +34,16 @@ std::string getBgName(int type) //TODO - co z tym zrobi
|
||||
throw new std::exception("std::string getBgName(int type): invalid type");
|
||||
}
|
||||
}
|
||||
class SORTHELP
|
||||
{
|
||||
public:
|
||||
bool operator ()
|
||||
(const boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*> *a ,
|
||||
const boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*> *b)
|
||||
{
|
||||
return (a->get<0>())<(b->get<0>());
|
||||
}
|
||||
} srthlp ;
|
||||
|
||||
CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
||||
{
|
||||
@ -47,6 +57,28 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
||||
CSDL_Ext::blueToPlayersAdv(townInt,LOCPLINT->playerID);
|
||||
exit = new AdventureMapButton<CCastleInterface>(CGI->townh->tcommands[8],"",&CCastleInterface::close,744,544,"TSBTNS.DEF",this,Activate);
|
||||
exit->bitmapOffset = 4;
|
||||
|
||||
for (std::set<int>::const_iterator i=town->builtBuildings.begin();i!=town->builtBuildings.end();i++)
|
||||
{
|
||||
if(CGI->townh->structures.find(town->subID) != CGI->townh->structures.end())
|
||||
{
|
||||
if(CGI->townh->structures[town->subID].find(*i)!=CGI->townh->structures[town->subID].end())
|
||||
{
|
||||
CDefHandler *b = CGI->spriteh->giveDef(CGI->townh->structures[town->subID][*i]->defName);
|
||||
boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*> *t
|
||||
= new boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*>
|
||||
(*i,b,CGI->townh->structures[town->subID][*i],NULL,NULL);
|
||||
//TODO: obwódki i pola
|
||||
buildings.push_back(t);
|
||||
}
|
||||
else continue;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
std::sort(buildings.begin(),buildings.end(),srthlp);
|
||||
|
||||
if(Activate)
|
||||
{
|
||||
activate();
|
||||
@ -62,6 +94,20 @@ CCastleInterface::~CCastleInterface()
|
||||
delete fort;
|
||||
delete bigTownPic;
|
||||
delete flag;
|
||||
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
{
|
||||
if (buildings[i]->get<1>())
|
||||
delete (buildings[i]->get<1>());
|
||||
//if (buildings[i]->get<2>())
|
||||
// delete (buildings[i]->get<2>());
|
||||
if (buildings[i]->get<3>())
|
||||
SDL_FreeSurface(buildings[i]->get<3>());
|
||||
if (buildings[i]->get<4>())
|
||||
SDL_FreeSurface(buildings[i]->get<4>());
|
||||
delete buildings[i];
|
||||
}
|
||||
|
||||
}
|
||||
void CCastleInterface::close()
|
||||
{
|
||||
@ -145,6 +191,12 @@ void CCastleInterface::show()
|
||||
itoa(i->second.second,temp,10);
|
||||
CSDL_Ext::printTo(temp,305+(62*(i->first))+57,387+61,GEOR13,zwykly);
|
||||
}
|
||||
|
||||
//blit buildings
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
{
|
||||
blitAt(buildings[i]->get<1>()->ourImages[0].bitmap,buildings[i]->get<2>()->x,buildings[i]->get<2>()->y);
|
||||
}
|
||||
|
||||
}
|
||||
void CCastleInterface::activate()
|
||||
|
@ -2,10 +2,14 @@
|
||||
#include "global.h"
|
||||
#include "SDL.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "boost/tuple/tuple.hpp"
|
||||
class CGTownInstance;
|
||||
class CTownHandler;
|
||||
struct Structure;
|
||||
template <typename T> class AdventureMapButton;
|
||||
class CBuildingRect : public MotionInterested, public ClickableL, public ClickableR, public TimeInterested
|
||||
class CBuildingRect : public MotionInterested, public ClickableL, public ClickableR//, public TimeInterested
|
||||
{
|
||||
|
||||
void activate();
|
||||
void deactivate();
|
||||
};
|
||||
@ -22,6 +26,8 @@ public:
|
||||
|
||||
AdventureMapButton<CCastleInterface> * exit;
|
||||
|
||||
std::vector<boost::tuples::tuple<int,CDefHandler*,Structure*,SDL_Surface*,SDL_Surface*> *> buildings; //building id, building def, structure struct, border, filling
|
||||
|
||||
CCastleInterface(const CGTownInstance * Town, bool Activate=true);
|
||||
~CCastleInterface();
|
||||
void show();
|
||||
|
37
config/buildings.txt
Normal file
37
config/buildings.txt
Normal file
@ -0,0 +1,37 @@
|
||||
0 16 TBCSBLAK.def 213 251
|
||||
0 8 TBCSCAS2.def 478 66
|
||||
0 9 TBCSCAS3.def 478 37
|
||||
0 7 TBCSCSTL.def 595 66
|
||||
0 6 TBCSDOCK.def 478 134
|
||||
0 30 TBCSDW_0.def 304 92
|
||||
0 31 TBCSDW_1.def 360 130
|
||||
0 32 TBCSDW_2.def 363 130
|
||||
0 33 TBCSDW_3.def 176 101
|
||||
0 34 TBCSDW_4.def 563 211
|
||||
0 35 TBCSDW_5.def 174 190
|
||||
0 36 TBCSDW_6.def 303 0
|
||||
0 21 TBCSEXT0.def 384 193
|
||||
0 22 TBCSEXT1.def 0 198
|
||||
0 11 TBCSHAL2.def 0 176
|
||||
0 12 TBCSHAL3.def 0 164
|
||||
0 13 TBCSHAL4.def 0 154
|
||||
0 10 TBCSHALL.def 0 209
|
||||
0 26 TBCSHOLY.def 456 109
|
||||
0 18 TBCSHRD1.def 76 53
|
||||
0 19 TBCSHRD2.def 76 35
|
||||
0 1 TBCSMAG2.def 706 135
|
||||
0 2 TBCSMAG3.def 704 107
|
||||
0 3 TBCSMAG4.def 704 76
|
||||
0 0 TBCSMAGE.def 707 166
|
||||
0 14 TBCSMARK.def 413 264
|
||||
0 15 TBCSSILO.def 488 228
|
||||
0 17 TBCSSPEC.def 533 71
|
||||
0 5 TBCSTVRN.def 0 230
|
||||
0 37 TBCSUP_0.def 304 65
|
||||
0 38 TBCSUP_1.def 360 115
|
||||
0 39 TBCSUP_2.def 76 35
|
||||
0 40 TBCSUP_3.def 176 85
|
||||
0 41 TBCSUP_4.def 563 173
|
||||
0 42 TBCSUP_5.def 160 190
|
||||
0 43 TBCSUP_6.def 303 0
|
||||
0 20 TBCSBOAT.def 478 134
|
@ -519,6 +519,7 @@ void CAmbarCendamo::deh3m()
|
||||
//{
|
||||
// vinya->bytes[v] = bufor[i++];
|
||||
//}
|
||||
std::transform(vinya->name.begin(),vinya->name.end(),vinya->name.begin(),(int(*)(int))toupper);
|
||||
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
||||
vinya->name);
|
||||
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
||||
@ -2229,6 +2230,12 @@ void CAmbarCendamo::deh3m()
|
||||
}
|
||||
}
|
||||
|
||||
for(int ww=0; ww<CGI->objh->objInstances.size(); ++ww)
|
||||
{
|
||||
if (CGI->objh->objInstances[ww]->defObjInfoNumber==-1)
|
||||
std::cout<<CGI->objh->objInstances[ww]->ID<<"\t" << CGI->objh->objInstances[ww]->subID<<"\t"<<CGI->objh->objInstances[ww]->defInfo->name<<std::endl;
|
||||
}
|
||||
|
||||
//assigned
|
||||
|
||||
//loading events
|
||||
|
@ -165,10 +165,10 @@ bool CGObjectInstance::operator<(const CGObjectInstance & cmp) const //screen p
|
||||
return true;
|
||||
if(!cmp.defInfo->isVisitable() && defInfo->isVisitable())
|
||||
return false;
|
||||
if(defInfo->isOnDefList && !(cmp.defInfo->isOnDefList))
|
||||
return true;
|
||||
if(cmp.defInfo->isOnDefList && !(defInfo->isOnDefList))
|
||||
return false;
|
||||
//if(defInfo->isOnDefList && !(cmp.defInfo->isOnDefList))
|
||||
// return true;
|
||||
//if(cmp.defInfo->isOnDefList && !(defInfo->isOnDefList))
|
||||
// return false;
|
||||
if(this->pos.x<cmp.pos.x)
|
||||
return true;
|
||||
return false;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "CTownHandler.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "CLodHandler.h"
|
||||
#include <sstream>
|
||||
#include <sstream>
|
||||
#include "CGeneralTextHandler.h"
|
||||
CTownHandler::CTownHandler()
|
||||
{
|
||||
@ -11,6 +11,7 @@ CTownHandler::CTownHandler()
|
||||
CTownHandler::~CTownHandler()
|
||||
{
|
||||
delete smallIcons;
|
||||
//todo - delete structures info
|
||||
}
|
||||
void CTownHandler::loadNames()
|
||||
{
|
||||
@ -42,8 +43,21 @@ void CTownHandler::loadNames()
|
||||
std::string tmp;
|
||||
CGeneralTextHandler::loadToIt(tmp, strs, itr, 3);
|
||||
tcommands.push_back(tmp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::ifstream of("config/buildings.txt");
|
||||
while(!of.eof())
|
||||
{
|
||||
Structure *vinya = new Structure;
|
||||
of >> vinya->townID;
|
||||
of >> vinya->ID;
|
||||
of >> vinya->defName;
|
||||
of >> vinya->x;
|
||||
of >> vinya->y;
|
||||
structures[vinya->townID][vinya->ID] = vinya;
|
||||
}
|
||||
|
||||
}
|
||||
SDL_Surface * CTownHandler::getPic(int ID, bool fort, bool builded)
|
||||
{
|
||||
|
@ -23,6 +23,12 @@ public:
|
||||
int typeID;
|
||||
};
|
||||
|
||||
struct Structure
|
||||
{
|
||||
std::string defName;
|
||||
int ID, townID, x, y;
|
||||
};
|
||||
|
||||
class CTownHandler
|
||||
{
|
||||
CDefHandler * smallIcons;
|
||||
@ -35,6 +41,9 @@ public:
|
||||
SDL_Surface * getPic(int ID, bool fort=true, bool builded=false); //ID=-1 - blank; -2 - border; -3 - random
|
||||
static int getTypeByDefName(std::string name);
|
||||
|
||||
std::map<int,std::map<int, Structure*> > structures;
|
||||
|
||||
|
||||
std::vector<CGTownInstance *> townInstances;
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user