mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
* improved support for bigger resolutions (border around castle interface)
* shots proper initialization
This commit is contained in:
parent
05e25ed3ea
commit
7387d2905e
@ -765,6 +765,23 @@ void CResDataBar::deactivate()
|
||||
{
|
||||
ClickableR::deactivate();
|
||||
}
|
||||
CResDataBar::CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist)
|
||||
{
|
||||
bg = BitmapHandler::loadBitmap(defname);
|
||||
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
||||
graphics->blueToPlayersAdv(bg,LOCPLINT->playerID);
|
||||
pos = genRect(bg->h,bg->w,x,y);
|
||||
|
||||
txtpos.resize(8);
|
||||
for (int i = 0; i < 8 ; i++)
|
||||
{
|
||||
txtpos[i].first = pos.x + offx + resdist*i;
|
||||
txtpos[i].second = pos.y + offy;
|
||||
}
|
||||
txtpos[7].first = txtpos[6].first + datedist;
|
||||
datetext = CGI->generaltexth->allTexts[62]+": %s, " + CGI->generaltexth->allTexts[63]
|
||||
+ ": %s, " + CGI->generaltexth->allTexts[64] + ": %s";
|
||||
}
|
||||
CResDataBar::CResDataBar()
|
||||
{
|
||||
bg = BitmapHandler::loadBitmap(ADVOPT.resdatabarG);
|
||||
@ -779,14 +796,10 @@ CResDataBar::CResDataBar()
|
||||
txtpos[i].second = pos.y + ADVOPT.resOffsetY;
|
||||
}
|
||||
txtpos[7].first = txtpos[6].first + ADVOPT.resDateDist;
|
||||
//txtpos += (std::pair<int,int>(32+pos.x,2+pos.y)),(std::pair<int,int>(117+pos.x,2+pos.y)),
|
||||
// (std::pair<int,int>(202+pos.x,2+pos.y)),(std::pair<int,int>(287+pos.x,2+pos.y)),
|
||||
// (std::pair<int,int>(372+pos.x,2+pos.y)),(std::pair<int,int>(457+pos.x,2+pos.y)),
|
||||
// (std::pair<int,int>(542+pos.x,2+pos.y)),(std::pair<int,int>(617+pos.x,2+pos.y));
|
||||
datetext = CGI->generaltexth->allTexts[62]+": %s, " + CGI->generaltexth->allTexts[63]
|
||||
+ ": %s, " + CGI->generaltexth->allTexts[64] + ": %s";
|
||||
|
||||
}
|
||||
|
||||
CResDataBar::~CResDataBar()
|
||||
{
|
||||
SDL_FreeSurface(bg);
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
void activate();
|
||||
void deactivate();
|
||||
CResDataBar();
|
||||
CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist);
|
||||
~CResDataBar();
|
||||
|
||||
void draw();
|
||||
|
@ -142,7 +142,6 @@ void CBuildingRect::clickRight (tribool down)
|
||||
vinya->activate();
|
||||
}
|
||||
}
|
||||
|
||||
void CBuildingRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
{
|
||||
if(area)
|
||||
@ -368,6 +367,8 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
|
||||
split = new AdventureMapButton
|
||||
(CGI->townh->tcommands[3],"",boost::bind(&CGarrisonInt::splitClick,garr),pos.x+744,pos.y+382,"TSBTNS.DEF");
|
||||
statusbar = new CStatusBar(pos.x+7,pos.y+555,"TSTATBAR.bmp",732);
|
||||
resdatabar = new CResDataBar("ZRESBAR.bmp",pos.x+3,pos.y+575,32,2,85,85);
|
||||
resdatabar->pos.x = pos.x+3; resdatabar->pos.y = pos.y+575;
|
||||
|
||||
townlist->fun = boost::bind(&CCastleInterface::townChange,this);
|
||||
townlist->genList();
|
||||
@ -436,6 +437,7 @@ CCastleInterface::~CCastleInterface()
|
||||
delete garr;
|
||||
delete townlist;
|
||||
delete statusbar;
|
||||
delete resdatabar;
|
||||
for(int i=0;i<buildings.size();i++)
|
||||
{
|
||||
delete buildings[i];
|
||||
@ -568,11 +570,14 @@ void CCastleInterface::showAll( SDL_Surface * to/*=NULL*/, bool forceTotalRedraw
|
||||
{
|
||||
if (!to)
|
||||
to=screen;
|
||||
|
||||
|
||||
blitAt(cityBg,pos,to);
|
||||
blitAt(townInt,pos.x,pos.y+374,to);
|
||||
LOCPLINT->adventureInt->resdatabar.draw();
|
||||
townlist->draw();
|
||||
statusbar->show();
|
||||
resdatabar->draw();
|
||||
|
||||
garr->show();
|
||||
int pom;
|
||||
@ -643,6 +648,8 @@ void CCastleInterface::showAll( SDL_Surface * to/*=NULL*/, bool forceTotalRedraw
|
||||
show();
|
||||
if(pom)
|
||||
showing = false;
|
||||
|
||||
CMessage::drawBorder(LOCPLINT->playerID,to,828,628,pos.x-14,pos.y-15);
|
||||
}
|
||||
void CCastleInterface::townChange()
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ class CHallInterface;
|
||||
struct Structure;
|
||||
class CSpell;
|
||||
class AdventureMapButton;
|
||||
class CResDataBar;
|
||||
class CBuildingRect : public Hoverable, public MotionInterested, public ClickableL, public ClickableR//, public TimeInterested
|
||||
{
|
||||
public:
|
||||
@ -56,6 +57,7 @@ public:
|
||||
SDL_Surface * cityBg;
|
||||
const CGTownInstance * town;
|
||||
CStatusBar * statusbar;
|
||||
CResDataBar *resdatabar;
|
||||
unsigned char animval, count;
|
||||
|
||||
CDefHandler *hall,*fort;
|
||||
|
@ -187,10 +187,11 @@ bool BattleInfo::isStackBlocked(int ID)
|
||||
if( !stacks[i]->alive()
|
||||
|| stacks[i]->owner==our->owner
|
||||
)
|
||||
continue; //we ommit dead and allied stacks
|
||||
continue; //we omit dead and allied stacks
|
||||
if(stacks[i]->creature->isDoubleWide())
|
||||
{
|
||||
if( mutualPosition(stacks[i]->position, our->position) >= 0 || mutualPosition(stacks[i]->position + (stacks[i]->attackerOwned ? -1 : 1), our->position) >= 0)
|
||||
if( mutualPosition(stacks[i]->position, our->position) >= 0
|
||||
|| mutualPosition(stacks[i]->position + (stacks[i]->attackerOwned ? -1 : 1), our->position) >= 0)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -250,7 +251,8 @@ std::vector<int> BattleInfo::getPath(int start, int dest, bool*accessibility)
|
||||
}
|
||||
|
||||
CStack::CStack(CCreature * C, int A, int O, int I, bool AO, int S)
|
||||
:creature(C),amount(A), baseAmount(A), owner(O), position(-1), ID(I), attackerOwned(AO), firstHPleft(C->hitPoints), slot(S), counterAttacks(1), effects(), state()
|
||||
:creature(C),amount(A), baseAmount(A), owner(O), position(-1), ID(I), attackerOwned(AO), firstHPleft(C->hitPoints),
|
||||
shots(C->shots), slot(S), counterAttacks(1), effects(), state()
|
||||
{
|
||||
abilities = C->abilities;
|
||||
state.insert(ALIVE);
|
||||
|
@ -128,11 +128,11 @@ public:
|
||||
h & id;
|
||||
creature = &VLC->creh->creatures[id];
|
||||
abilities = creature->abilities;
|
||||
shots = creature->shots;
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & ID & amount & baseAmount & firstHPleft & owner & slot & attackerOwned & position & state & counterAttacks;
|
||||
h & ID & amount & baseAmount & firstHPleft & owner & slot & attackerOwned & position & state & counterAttacks
|
||||
& shots;
|
||||
if(h.saving)
|
||||
save(h,version);
|
||||
else
|
||||
|
57
CMessage.cpp
57
CMessage.cpp
@ -92,33 +92,7 @@ SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) //draws box for
|
||||
for (int j=0; j<w; j+=background->w-1)
|
||||
SDL_BlitSurface(background,&genRect(background->h,background->w-1,1,0),ret,&genRect(h,w,j,i));
|
||||
}
|
||||
|
||||
//obwodka I-szego rzedu pozioma
|
||||
for (int i=0; i<w; i+=piecesOfBox[playerColor][6]->w)
|
||||
{
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][6],NULL,ret,&genRect(piecesOfBox[playerColor][6]->h,piecesOfBox[playerColor][6]->w,i,0));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][7],NULL,ret,&genRect(piecesOfBox[playerColor][7]->h,piecesOfBox[playerColor][7]->w,i,h-piecesOfBox[playerColor][7]->h));
|
||||
}
|
||||
//obwodka I-szego rzedu pionowa
|
||||
for (int i=0; i<h; i+=piecesOfBox[playerColor][4]->h)
|
||||
{
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][4],NULL,ret,&genRect(piecesOfBox[playerColor][4]->h,piecesOfBox[playerColor][4]->w,0,i));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][5],NULL,ret,&genRect(piecesOfBox[playerColor][5]->h,piecesOfBox[playerColor][5]->w,w-piecesOfBox[playerColor][5]->w,i));
|
||||
}
|
||||
//corners
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][0],NULL,ret,&genRect(piecesOfBox[playerColor][0]->h,piecesOfBox[playerColor][0]->w,0,0));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][1],NULL,ret,&genRect(piecesOfBox[playerColor][1]->h,piecesOfBox[playerColor][1]->w,w-piecesOfBox[playerColor][1]->w,0));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][2],NULL,ret,&genRect(piecesOfBox[playerColor][2]->h,piecesOfBox[playerColor][2]->w,0,h-piecesOfBox[playerColor][2]->h));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][3],NULL,ret,&genRect(piecesOfBox[playerColor][3]->h,piecesOfBox[playerColor][3]->w,w-piecesOfBox[playerColor][3]->w,h-piecesOfBox[playerColor][3]->h));
|
||||
//box gotowy!
|
||||
drawBorder(playerColor, ret, w, h);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -563,3 +537,32 @@ SDL_Surface * CMessage::genMessage
|
||||
delete tekst;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int x, int y)
|
||||
{
|
||||
//obwodka I-szego rzedu pozioma
|
||||
for (int i=0; i<w-piecesOfBox[playerColor][6]->w; i+=piecesOfBox[playerColor][6]->w)
|
||||
{
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][6],NULL,ret,&genRect(piecesOfBox[playerColor][6]->h,piecesOfBox[playerColor][6]->w,x+i,y+0));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][7],NULL,ret,&genRect(piecesOfBox[playerColor][7]->h,piecesOfBox[playerColor][7]->w,x+i,y+h-piecesOfBox[playerColor][7]->h));
|
||||
}
|
||||
//obwodka I-szego rzedu pionowa
|
||||
for (int i=0; i<h-piecesOfBox[playerColor][4]->h; i+=piecesOfBox[playerColor][4]->h)
|
||||
{
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][4],NULL,ret,&genRect(piecesOfBox[playerColor][4]->h,piecesOfBox[playerColor][4]->w,x+0,y+i));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][5],NULL,ret,&genRect(piecesOfBox[playerColor][5]->h,piecesOfBox[playerColor][5]->w,x+w-piecesOfBox[playerColor][5]->w,y+i));
|
||||
}
|
||||
//corners
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][0],NULL,ret,&genRect(piecesOfBox[playerColor][0]->h,piecesOfBox[playerColor][0]->w,x+0,y+0));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][1],NULL,ret,&genRect(piecesOfBox[playerColor][1]->h,piecesOfBox[playerColor][1]->w,x+w-piecesOfBox[playerColor][1]->w,y+0));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][2],NULL,ret,&genRect(piecesOfBox[playerColor][2]->h,piecesOfBox[playerColor][2]->w,x+0,y+h-piecesOfBox[playerColor][2]->h));
|
||||
SDL_BlitSurface
|
||||
(piecesOfBox[playerColor][3],NULL,ret,&genRect(piecesOfBox[playerColor][3]->h,piecesOfBox[playerColor][3]->w,x+w-piecesOfBox[playerColor][3]->w,y+h-piecesOfBox[playerColor][3]->h));
|
||||
}
|
@ -39,6 +39,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 void drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int x=0, int y=0);
|
||||
static SDL_Surface * drawBoxTextBitmapSub(int player, std::string text, SDL_Surface* bitmap, std::string sub, int charperline=30, int imgToBmp=55);
|
||||
static std::vector<std::string> * breakText(std::string text, int line=30, bool userBreak=true, bool ifor=true); //line - chars per line
|
||||
CMessage();
|
||||
|
@ -43,7 +43,7 @@
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="G:\vcmt\repa\include"
|
||||
GeneratePreprocessedFile="0"
|
||||
MinimalRebuild="true"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
WarningLevel="1"
|
||||
|
@ -10,6 +10,9 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
DLL_EXPORT int readNormalNr (int pos, int bytCon, unsigned char * str)
|
||||
{
|
||||
int ret=0;
|
||||
@ -44,7 +47,7 @@ unsigned char * CLodHandler::giveFile(std::string defName, int * length)
|
||||
char name[30];memset(name,0,30);
|
||||
strcat(name, myDir.c_str());
|
||||
strcat(name, PATHSEPARATOR);
|
||||
strcat(name,(char*)ourEntry->name);
|
||||
strcat(name,ourEntry->nameStr.c_str());
|
||||
FILE * f = fopen(name,"rb");
|
||||
int result = fread(outp,1,ourEntry->realSize,f);
|
||||
mutex->unlock();
|
||||
@ -391,11 +394,11 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
|
||||
}
|
||||
else //file not present in lod - add entry for it
|
||||
{
|
||||
Entry e;
|
||||
e.offset = -1;
|
||||
e.nameStr = name;
|
||||
e.realSize = e.size = boost::filesystem::file_size(dir->path());
|
||||
entries.push_back(e);
|
||||
Entry e2;
|
||||
e2.offset = -1;
|
||||
e2.nameStr = name;
|
||||
e2.realSize = e2.size = boost::filesystem::file_size(dir->path());
|
||||
entries.push_back(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user