mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* resource bar
* function in CCallback for getting onfo about res * giving resources at the beginning of game * moved several txt files to /config subfolder * minor changes
This commit is contained in:
parent
3ce6c4bf70
commit
7d4aa0c803
@ -385,7 +385,7 @@ CMinimap::CMinimap(bool draw)
|
||||
pos.y=26;
|
||||
pos.h=pos.w=144;
|
||||
radar = CGI->spriteh->giveDef("RADAR.DEF");
|
||||
std::ifstream is("minimap.txt",std::ifstream::in);
|
||||
std::ifstream is("config/minimap.txt",std::ifstream::in);
|
||||
for (int i=0;i<TERRAIN_TYPES;i++)
|
||||
{
|
||||
std::pair<int,SDL_Color> vinya;
|
||||
@ -451,7 +451,10 @@ void CMinimap::clickLeft (tribool down)
|
||||
if (down && (!pressedL))
|
||||
MotionInterested::activate();
|
||||
else if (!down)
|
||||
MotionInterested::deactivate();
|
||||
{
|
||||
if (std::find(LOCPLINT->motioninterested.begin(),LOCPLINT->motioninterested.end(),this)!=LOCPLINT->motioninterested.end())
|
||||
MotionInterested::deactivate();
|
||||
}
|
||||
ClickableL::clickLeft(down);
|
||||
if (!((bool)down))
|
||||
return;
|
||||
@ -734,6 +737,46 @@ void CTerrainRect::show()
|
||||
} // if (currentPath)
|
||||
}
|
||||
|
||||
|
||||
void CResDataBar::clickRight (tribool down)
|
||||
{
|
||||
}
|
||||
void CResDataBar::activate()
|
||||
{
|
||||
ClickableR::activate();
|
||||
}
|
||||
void CResDataBar::deactivate()
|
||||
{
|
||||
ClickableR::deactivate();
|
||||
}
|
||||
CResDataBar::CResDataBar()
|
||||
{
|
||||
bg = CGI->bitmaph->loadBitmap("ZRESBAR.bmp");
|
||||
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
||||
blueToPlayersAdv(bg,LOCPLINT->playerID);
|
||||
pos = genRect(bg->h,bg->w,3,575);
|
||||
|
||||
txtpos += (std::pair<int,int>(35,577)),(std::pair<int,int>(120,577)),(std::pair<int,int>(205,577)),
|
||||
(std::pair<int,int>(290,577)),(std::pair<int,int>(375,577)),(std::pair<int,int>(460,577)),(std::pair<int,int>(545,577));
|
||||
|
||||
}
|
||||
CResDataBar::~CResDataBar()
|
||||
{
|
||||
SDL_FreeSurface(bg);
|
||||
}
|
||||
void CResDataBar::draw()
|
||||
{
|
||||
blitAt(bg,pos.x,pos.y);
|
||||
char * buf = new char[15];
|
||||
for (int i=0;i<7;i++)
|
||||
{
|
||||
itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
|
||||
printAt(buf,txtpos[i].first,txtpos[i].second,GEOR13,zwykly);
|
||||
}
|
||||
delete buf;
|
||||
updateRect(&pos,ekran);
|
||||
}
|
||||
|
||||
CAdvMapInt::CAdvMapInt(int Player)
|
||||
:player(Player),
|
||||
statusbar(7,556),
|
||||
@ -864,6 +907,8 @@ void CAdvMapInt::show()
|
||||
heroList.activate();
|
||||
heroList.draw();
|
||||
|
||||
resdatabar.draw();
|
||||
|
||||
statusbar.show();
|
||||
|
||||
SDL_Flip(ekran);
|
||||
|
@ -159,6 +159,21 @@ public:
|
||||
void keyPressed (SDL_KeyboardEvent & key);
|
||||
void show();
|
||||
};
|
||||
class CResDataBar
|
||||
:public ClickableR, public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg;
|
||||
std::vector<std::pair<int,int> > txtpos;
|
||||
|
||||
void clickRight (tribool down);
|
||||
void activate();
|
||||
void deactivate();
|
||||
CResDataBar();
|
||||
~CResDataBar();
|
||||
|
||||
void draw();
|
||||
};
|
||||
/*****************************/
|
||||
class CAdvMapInt //adventure map interface
|
||||
{
|
||||
@ -198,6 +213,7 @@ public:
|
||||
CTerrainRect terrain; //visible terrain
|
||||
|
||||
CStatusBar statusbar;
|
||||
CResDataBar resdatabar;
|
||||
|
||||
CHeroList heroList;
|
||||
CTownList townList;
|
||||
|
@ -72,4 +72,8 @@ const CHeroInstance * CCallback::getHeroInfo(int player, int val, bool mode) //m
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
int CCallback::getResourceAmount(int type)
|
||||
{
|
||||
return gs->players[gs->currentPlayer].resources[type];
|
||||
}
|
@ -22,6 +22,7 @@ public:
|
||||
|
||||
int howManyHeroes(int player);
|
||||
const CHeroInstance * getHeroInfo(int player, int val, bool mode); //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
int getResourceAmount(int type);
|
||||
};
|
||||
|
||||
#endif //CCALLBACK_H
|
27
CMT.cpp
27
CMT.cpp
@ -85,7 +85,32 @@ TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM;
|
||||
|
||||
void initGameState(CGameInfo * cgi)
|
||||
{
|
||||
cgi->state->currentPlayer = 0;
|
||||
/******************RESOURCES****************************************************/
|
||||
//TODO: zeby komputer dostawal inaczej niz gracz
|
||||
std::vector<int> startres;
|
||||
std::ifstream tis("config/startres.txt");
|
||||
int k;
|
||||
for (int j=0;j<cgi->scenarioOps.difficulty;j++)
|
||||
{
|
||||
tis >> k;
|
||||
for (int z=0;z<RESOURCE_QUANTITY;z++)
|
||||
tis>>k;
|
||||
}
|
||||
tis >> k;
|
||||
for (int i=0;i<RESOURCE_QUANTITY;i++)
|
||||
{
|
||||
tis >> k;
|
||||
startres.push_back(k);
|
||||
}
|
||||
tis.close();
|
||||
for (std::map<int,PlayerState>::iterator i = cgi->state->players.begin(); i!=cgi->state->players.end(); i++)
|
||||
{
|
||||
(*i).second.resources.resize(RESOURCE_QUANTITY);
|
||||
for (int x=0;x<RESOURCE_QUANTITY;x++)
|
||||
(*i).second.resources[x] = startres[x];
|
||||
|
||||
}
|
||||
|
||||
/*************************HEROES************************************************/
|
||||
for (int i=0; i<cgi->heroh->heroInstances.size();i++) //heroes instances
|
||||
{
|
||||
|
BIN
CPreGame.cpp
BIN
CPreGame.cpp
Binary file not shown.
@ -258,7 +258,7 @@ public:
|
||||
menuItems * currentItems();
|
||||
void(CPreGame::*handleOther)(SDL_Event&);
|
||||
void scenHandleEv(SDL_Event& sEvent);
|
||||
void begin(){run=false;};
|
||||
void begin(){run=false;ret.difficulty=ourScenSel->selectedDiff;};
|
||||
void quitAskBox();
|
||||
void quit(){exit(0);};
|
||||
void initScenSel();
|
||||
|
@ -18,6 +18,7 @@ struct StartInfo
|
||||
int handicap;//0-no, 1-mild, 2-severe
|
||||
std::string name;
|
||||
};
|
||||
int difficulty; //0=easy; 4=impossible
|
||||
std::vector<PlayerSettings> playerInfos;
|
||||
int turnTime; //in minutes, 0=unlimited
|
||||
PlayerSettings & getIthPlayersSettings(int no)
|
||||
|
8
config/startres.txt
Normal file
8
config/startres.txt
Normal file
@ -0,0 +1,8 @@
|
||||
0 30 15 30 15 15 15 30000 0
|
||||
1 20 10 20 10 10 10 20000 0
|
||||
2 15 7 15 7 7 7 15000 0
|
||||
3 10 4 10 4 4 4 10000 0
|
||||
4 0 0 0 0 0 0 0 0
|
||||
|
||||
Resources on start. Format:
|
||||
Difficulty wood mercury ore sulfur crystal gems gold mithril
|
3
global.h
3
global.h
@ -37,9 +37,12 @@ const int HEROES_PER_TYPE=8; //amount of heroes of each type
|
||||
const int SKILL_QUANTITY=28;
|
||||
const int ARTIFACTS_QUANTITY=171;
|
||||
const int HEROES_QUANTITY=156;
|
||||
const int RESOURCE_QUANTITY=8;
|
||||
const int TERRAIN_TYPES=10;
|
||||
const int PRIMARY_SKILLS=4;
|
||||
|
||||
const int NAMES_PER_TOWN=16;
|
||||
|
||||
#define MARK_BLOCKED_POSITIONS false
|
||||
#define MARK_VISITABLE_POSITIONS false
|
||||
|
||||
|
@ -447,7 +447,7 @@ void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int
|
||||
|
||||
void CCreatureHandler::loadUnitAnimations()
|
||||
{
|
||||
std::ifstream inp("CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
|
||||
std::ifstream inp("config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
|
||||
inp.seekg(0,std::ios::end); // na koniec
|
||||
int andame = inp.tellg(); // read length
|
||||
inp.seekg(0,std::ios::beg); // wracamy na poczatek
|
||||
|
@ -21,7 +21,7 @@ CHeroHandler::~CHeroHandler()
|
||||
}
|
||||
void CHeroHandler::loadPortraits()
|
||||
{
|
||||
std::ifstream of("portrety.txt");
|
||||
std::ifstream of("config/portrety.txt");
|
||||
for (int j=0;j<heroes.size();j++)
|
||||
{
|
||||
int ID;
|
||||
|
@ -14,12 +14,19 @@ CTownHandler::~CTownHandler()
|
||||
}
|
||||
void CTownHandler::loadNames()
|
||||
{
|
||||
std::istringstream ins;
|
||||
std::istringstream ins, names;
|
||||
ins.str(CGI->bitmaph->getTextFile("TOWNTYPE.TXT"));
|
||||
names.str(CGI->bitmaph->getTextFile("TOWNNAME.TXT"));
|
||||
while (!ins.eof())
|
||||
{
|
||||
CTown town;
|
||||
ins >> town.name;
|
||||
char bufname[50];
|
||||
for (int i=0; i<NAMES_PER_TOWN; i++)
|
||||
{
|
||||
names.getline(bufname,50);
|
||||
town.names.push_back(std::string(bufname));
|
||||
}
|
||||
town.bonus=towns.size();
|
||||
if (town.bonus==8) town.bonus=3;
|
||||
if (town.name.length())
|
||||
|
@ -15,7 +15,8 @@ class CHero;
|
||||
class CTown
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
std::string name; //name of type
|
||||
std::vector<std::string> names; //names of the town instances
|
||||
int bonus; //pic number
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user