mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-24 03:47:18 +02:00
* next part of campaigns. Now all campaigns all available via custom campaign menu.
* puzzleMap now works
This commit is contained in:
parent
921b5e0c09
commit
80d42a5313
@ -925,7 +925,14 @@ void CCallback::calculatePaths( const CGHeroInstance *hero, CPathsInfo &out, int
|
||||
|
||||
int3 CCallback::getGrailPos( float &outKnownRatio )
|
||||
{
|
||||
outKnownRatio = (float)CGObelisk::visited[player] / CGObelisk::obeliskCount;
|
||||
if (CGObelisk::obeliskCount == 0)
|
||||
{
|
||||
outKnownRatio = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
outKnownRatio = (float)CGObelisk::visited[player] / CGObelisk::obeliskCount;
|
||||
}
|
||||
return gs->map->grailPos;
|
||||
}
|
||||
|
||||
|
@ -613,7 +613,7 @@ void SelectionTab::parseCampaigns( std::vector<FileInfo> & files )
|
||||
{
|
||||
for(int i=0; i<files.size(); i++)
|
||||
{
|
||||
allItems[i].date = std::asctime(std::localtime(&files[i].date));
|
||||
//allItems[i].date = std::asctime(std::localtime(&files[i].date));
|
||||
allItems[i].filename = files[i].name;
|
||||
allItems[i].lodCmpgn = files[i].inLod;
|
||||
allItems[i].campaignInit();
|
||||
@ -683,12 +683,13 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::function<void(
|
||||
cpm = CCampaignHandler::getCampaignHeaders(CCampaignHandler::ALL);
|
||||
for (int g = 0; g < cpm.size(); g++)
|
||||
{
|
||||
FileInfo fi;
|
||||
fi.inLod = cpm[g].loadFromLod;
|
||||
fi.name = cpm[g].filename;
|
||||
toParse.push_back(fi);
|
||||
if (cpm[g].loadFromLod)
|
||||
{
|
||||
FileInfo fi;
|
||||
fi.inLod = true;
|
||||
fi.name = cpm[g].name;
|
||||
toParse.push_back(fi);
|
||||
allItems.push_back(CMapInfo(false));
|
||||
}
|
||||
}
|
||||
parseCampaigns(toParse);
|
||||
|
@ -4733,6 +4733,9 @@ CShipyardWindow::CShipyardWindow(const std::vector<si32> &cost, int state, int b
|
||||
CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio)
|
||||
:animCount(0)
|
||||
{
|
||||
CDefHandler * arrows = CDefHandler::giveDef("ADAG.DEF");
|
||||
alphaTransform(arrows->ourImages[0].bitmap);
|
||||
|
||||
SDL_Surface * back = BitmapHandler::loadBitmap("PUZZLE.BMP", false);
|
||||
graphics->blueToPlayersAdv(back, LOCPLINT->playerID);
|
||||
//make transparency black
|
||||
@ -4745,13 +4748,28 @@ CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio)
|
||||
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;
|
||||
|
||||
//printing necessary thinks to background
|
||||
|
||||
//printing necessary things to background
|
||||
int3 moveInt = int3(8, 9, 0);
|
||||
CGI->mh->terrainRect
|
||||
(grailPos, LOCPLINT->adventureInt->anim,
|
||||
(grailPos - moveInt, LOCPLINT->adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
|
||||
background, &genRect(544, 591, 8, 8), 0, 0, true);
|
||||
|
||||
//printing X sign
|
||||
{
|
||||
int x = 32*moveInt.x + 8,
|
||||
y = 32*moveInt.y + 8;
|
||||
if (x<0 || y<0 || x>pos.w || y>pos.h)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[0].bitmap, NULL, background, &genRect(32, 32, x, y));
|
||||
}
|
||||
}
|
||||
|
||||
delete arrows;
|
||||
|
||||
int faction = LOCPLINT->cb->getStartInfo()->playerInfos[LOCPLINT->serialID].castle;
|
||||
|
||||
std::vector<SPuzzleInfo> puzzlesToPrint;
|
||||
|
@ -50,8 +50,8 @@ std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders(GetMode mode)
|
||||
{
|
||||
for(int g=0; g<bitmaph->entries.size(); ++g)
|
||||
{
|
||||
std::string rn = bitmaph->entries[g].nameStr;
|
||||
if( boost::ends_with(bitmaph->entries[g].nameStr, ext) )
|
||||
const std::string & nameS = bitmaph->entries[g].nameStr;
|
||||
if( boost::ends_with(nameS, ext) && nameS != "TOSBLK1.H3C" )
|
||||
{
|
||||
ret.push_back( getHeader(bitmaph->entries[g].nameStr, true) );
|
||||
}
|
||||
@ -66,12 +66,12 @@ std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders(GetMode mode)
|
||||
CCampaignHeader CCampaignHandler::getHeader( const std::string & name, bool fromLod )
|
||||
{
|
||||
int realSize;
|
||||
unsigned char * cmpgn = CLodHandler::getUnpackedFile(name, &realSize);
|
||||
unsigned char * cmpgn = getFile(name, fromLod, realSize);
|
||||
|
||||
int it = 0;//iterator for reading
|
||||
CCampaignHeader ret = readHeaderFromMemory(cmpgn, it);
|
||||
ret.filename = name;
|
||||
ret.loadFromLod = false;
|
||||
ret.loadFromLod = fromLod;
|
||||
|
||||
delete [] cmpgn;
|
||||
|
||||
@ -83,15 +83,7 @@ CCampaign * CCampaignHandler::getCampaign( const std::string & name, bool fromLo
|
||||
CCampaign * ret = new CCampaign();
|
||||
|
||||
int realSize;
|
||||
unsigned char * cmpgn;
|
||||
if (fromLod)
|
||||
{
|
||||
cmpgn = bitmaph->giveFile(name, &realSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmpgn = CLodHandler::getUnpackedFile(name, &realSize);
|
||||
}
|
||||
unsigned char * cmpgn = getFile(name, fromLod, realSize);
|
||||
|
||||
int it = 0; //iterator for reading
|
||||
ret->header = readHeaderFromMemory(cmpgn, it);
|
||||
@ -410,6 +402,25 @@ bool CCampaignHandler::startsAt( const unsigned char * buffer, int size, int pos
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned char * CCampaignHandler::getFile( const std::string & name, bool fromLod, int & outSize )
|
||||
{
|
||||
unsigned char * cmpgn;
|
||||
if(fromLod)
|
||||
{
|
||||
cmpgn = bitmaph->giveFile(name, &outSize);
|
||||
FILE * tmp = fopen("tmp_cmpgn", "wb");
|
||||
fwrite(cmpgn, 1, outSize, tmp);
|
||||
fclose(tmp);
|
||||
delete [] cmpgn;
|
||||
cmpgn = CLodHandler::getUnpackedFile("tmp_cmpgn", &outSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmpgn = CLodHandler::getUnpackedFile(name, &outSize);
|
||||
}
|
||||
return cmpgn;
|
||||
}
|
||||
|
||||
bool CCampaign::conquerable( int whichScenario ) const
|
||||
{
|
||||
if (scenarios[whichScenario].conquered)
|
||||
|
@ -123,6 +123,7 @@ class DLL_EXPORT CCampaignHandler
|
||||
static CScenarioTravel readScenarioTravelFromMemory( const unsigned char * buffer, int & outIt , int version);
|
||||
static std::vector<ui32> locateH3mStarts(const unsigned char * buffer, int start, int size);
|
||||
static bool startsAt( const unsigned char * buffer, int size, int pos ); //a simple heuristic that checks if a h3m starts at given pos
|
||||
static unsigned char * getFile(const std::string & name, bool fromLod, int & outSize);
|
||||
public:
|
||||
enum GetMode {RoE, AB, SoD, WoG, Custom, ALL};
|
||||
static std::vector<CCampaignHeader> getCampaignHeaders(GetMode mode);
|
||||
|
@ -302,6 +302,7 @@ unsigned char * CLodHandler::getUnpackedFile( const std::string & path, int * si
|
||||
int mapsize = 0;
|
||||
|
||||
gzFile map = gzopen(path.c_str(), "rb");
|
||||
assert(map);
|
||||
std::vector<unsigned char *> mapstr;
|
||||
|
||||
// Read a map by chunks
|
||||
|
@ -687,15 +687,19 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
else
|
||||
{
|
||||
//blitting Fog of War
|
||||
if (pos.x >= 0 &&
|
||||
pos.y >= 0 &&
|
||||
pos.x < CGI->mh->map->width &&
|
||||
pos.y < CGI->mh->map->height &&
|
||||
!(*visibilityMap)[pos.x][pos.y][top_tile.z])
|
||||
if (!puzzleMode)
|
||||
{
|
||||
SDL_Surface * hide = getVisBitmap(pos.x, pos.y, *visibilityMap, top_tile.z);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(hide, &rtile, extSurf, &sr);
|
||||
if (pos.x >= 0 &&
|
||||
pos.y >= 0 &&
|
||||
pos.x < CGI->mh->map->width &&
|
||||
pos.y < CGI->mh->map->height &&
|
||||
!(*visibilityMap)[pos.x][pos.y][top_tile.z])
|
||||
{
|
||||
SDL_Surface * hide = getVisBitmap(pos.x, pos.y, *visibilityMap, top_tile.z);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(hide, &rtile, extSurf, &sr);
|
||||
}
|
||||
}
|
||||
|
||||
//FoW blitted
|
||||
|
||||
// TODO: these should be activable by the console
|
||||
|
Loading…
x
Reference in New Issue
Block a user