mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
* next part of campaign support
This commit is contained in:
@ -52,11 +52,12 @@ struct PlayerSettings
|
|||||||
|
|
||||||
struct StartInfo
|
struct StartInfo
|
||||||
{
|
{
|
||||||
ui8 mode; //0 - new game; 1 - load game
|
ui8 mode; //0 - new game; 1 - load game; 2 - campaign
|
||||||
ui8 difficulty; //0=easy; 4=impossible
|
ui8 difficulty; //0=easy; 4=impossible
|
||||||
std::vector<PlayerSettings> playerInfos; //serial indexed
|
std::vector<PlayerSettings> playerInfos; //serial indexed
|
||||||
ui8 turnTime; //in minutes, 0=unlimited
|
ui8 turnTime; //in minutes, 0=unlimited
|
||||||
std::string mapname;
|
std::string mapname;
|
||||||
|
ui8 whichMapInCampaign; //used only for mode 2
|
||||||
PlayerSettings & getIthPlayersSettings(int no)
|
PlayerSettings & getIthPlayersSettings(int no)
|
||||||
{
|
{
|
||||||
for(unsigned int i=0; i<playerInfos.size(); ++i)
|
for(unsigned int i=0; i<playerInfos.size(); ++i)
|
||||||
@ -82,6 +83,7 @@ struct StartInfo
|
|||||||
h & playerInfos;
|
h & playerInfos;
|
||||||
h & turnTime;
|
h & turnTime;
|
||||||
h & mapname;
|
h & mapname;
|
||||||
|
h & whichMapInCampaign;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,7 +139,8 @@ void CBuildingRect::hover(bool on)
|
|||||||
}
|
}
|
||||||
void CBuildingRect::clickLeft(tribool down, bool previousState)
|
void CBuildingRect::clickLeft(tribool down, bool previousState)
|
||||||
{
|
{
|
||||||
if(area && (LOCPLINT->castleInt->hBuild==this) && !(indeterminate(down)) && (CSDL_Ext::SDL_GetPixel(area,GH.current->motion.x-pos.x,GH.current->motion.y-pos.y) != 0)) //na polu
|
if( area && (LOCPLINT->castleInt->hBuild==this) && !(indeterminate(down)) &&
|
||||||
|
!CSDL_Ext::isTransparent(area, GH.current->motion.x-pos.x, GH.current->motion.y-pos.y) ) //inside building image
|
||||||
{
|
{
|
||||||
if(previousState && !down)
|
if(previousState && !down)
|
||||||
LOCPLINT->castleInt->buildingClicked(str->ID);
|
LOCPLINT->castleInt->buildingClicked(str->ID);
|
||||||
@ -150,7 +151,7 @@ void CBuildingRect::clickRight(tribool down, bool previousState)
|
|||||||
{
|
{
|
||||||
if((!area) || (!((bool)down)) || (this!=LOCPLINT->castleInt->hBuild))
|
if((!area) || (!((bool)down)) || (this!=LOCPLINT->castleInt->hBuild))
|
||||||
return;
|
return;
|
||||||
if((CSDL_Ext::SDL_GetPixel(area,GH.current->motion.x-pos.x,GH.current->motion.y-pos.y) != 0)) //na polu
|
if( !CSDL_Ext::isTransparent(area, GH.current->motion.x-pos.x, GH.current->motion.y-pos.y) ) //inside building image
|
||||||
{
|
{
|
||||||
CBuilding *bld = CGI->buildh->buildings[str->townID][str->ID];
|
CBuilding *bld = CGI->buildh->buildings[str->townID][str->ID];
|
||||||
assert(bld);
|
assert(bld);
|
||||||
|
@ -110,7 +110,7 @@ CMapInfo::~CMapInfo()
|
|||||||
|
|
||||||
void CMapInfo::campaignInit()
|
void CMapInfo::campaignInit()
|
||||||
{
|
{
|
||||||
campaignHeader = new CCampaignHeader( CCampaignHandler::getHeader(filename) );
|
campaignHeader = new CCampaignHeader( CCampaignHandler::getHeader(filename, lodCmpgn) );
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuScreen::CMenuScreen( EState which )
|
CMenuScreen::CMenuScreen( EState which )
|
||||||
@ -158,10 +158,6 @@ CMenuScreen::CMenuScreen( EState which )
|
|||||||
buttons[3] = new AdventureMapButton("", "", bind(&CGPreGame::openSel, CGP, campaignList), 550, 358, "ZSSCUS.DEF", SDLK_t);
|
buttons[3] = new AdventureMapButton("", "", bind(&CGPreGame::openSel, CGP, campaignList), 550, 358, "ZSSCUS.DEF", SDLK_t);
|
||||||
buttons[4] = new AdventureMapButton("", "", bind(&CMenuScreen::moveTo, this, CGP->scrs[newGame]), 582, 464, "ZSSEXIT.DEF", SDLK_ESCAPE);
|
buttons[4] = new AdventureMapButton("", "", bind(&CMenuScreen::moveTo, this, CGP->scrs[newGame]), 582, 464, "ZSSEXIT.DEF", SDLK_ESCAPE);
|
||||||
|
|
||||||
////just for testing
|
|
||||||
CCampaignHandler * ch = new CCampaignHandler();
|
|
||||||
ch->getCampaignHeaders();
|
|
||||||
//ch->getCampaign("./Maps/ALEXIS.h3c");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -387,7 +383,7 @@ void CSelectionScreen::changeSelection( const CMapInfo *to )
|
|||||||
curOpts->difficulty = to->seldiff;
|
curOpts->difficulty = to->seldiff;
|
||||||
if(type != CMenuScreen::campaignList)
|
if(type != CMenuScreen::campaignList)
|
||||||
{
|
{
|
||||||
updateStartInfo(to);
|
updateStartInfo(to, sInfo, to->mapHeader);
|
||||||
}
|
}
|
||||||
card->changeSelection(to);
|
card->changeSelection(to);
|
||||||
if(type != CMenuScreen::campaignList)
|
if(type != CMenuScreen::campaignList)
|
||||||
@ -415,7 +411,7 @@ void setPlayer(PlayerSettings &pset, unsigned player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSelectionScreen::updateStartInfo( const CMapInfo * to )
|
void CSelectionScreen::updateStartInfo( const CMapInfo * to, StartInfo & sInfo, const CMapHeader * mapHeader )
|
||||||
{
|
{
|
||||||
sInfo.playerInfos.clear();
|
sInfo.playerInfos.clear();
|
||||||
if(!to)
|
if(!to)
|
||||||
@ -429,7 +425,7 @@ void CSelectionScreen::updateStartInfo( const CMapInfo * to )
|
|||||||
int serialC=0;
|
int serialC=0;
|
||||||
for (int i = 0; i < PLAYER_LIMIT; i++)
|
for (int i = 0; i < PLAYER_LIMIT; i++)
|
||||||
{
|
{
|
||||||
const PlayerInfo &pinfo = to->mapHeader->players[i];
|
const PlayerInfo &pinfo = mapHeader->players[i];
|
||||||
|
|
||||||
//neither computer nor human can play - no player
|
//neither computer nor human can play - no player
|
||||||
if (!(pinfo.canComputerPlay || pinfo.canComputerPlay))
|
if (!(pinfo.canComputerPlay || pinfo.canComputerPlay))
|
||||||
@ -452,7 +448,7 @@ void CSelectionScreen::updateStartInfo( const CMapInfo * to )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pinfo.generateHeroAtMainTown || to->mapHeader->version==CMapHeader::RoE) && pinfo.hasMainTown //we will generate hero in front of main town
|
if ((pinfo.generateHeroAtMainTown || mapHeader->version==CMapHeader::RoE) && pinfo.hasMainTown //we will generate hero in front of main town
|
||||||
|| pinfo.p8) //random hero
|
|| pinfo.p8) //random hero
|
||||||
pset.hero = -1;
|
pset.hero = -1;
|
||||||
else
|
else
|
||||||
@ -470,7 +466,7 @@ void CSelectionScreen::updateStartInfo( const CMapInfo * to )
|
|||||||
|
|
||||||
void CSelectionScreen::startCampaign()
|
void CSelectionScreen::startCampaign()
|
||||||
{
|
{
|
||||||
CCampaign * ourCampaign = CCampaignHandler::getCampaign(curMap->filename);
|
CCampaign * ourCampaign = CCampaignHandler::getCampaign(curMap->filename, curMap->lodCmpgn);
|
||||||
GH.pushInt( new CBonusSelection(ourCampaign, 0) );
|
GH.pushInt( new CBonusSelection(ourCampaign, 0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,6 +615,7 @@ void SelectionTab::parseCampaigns( std::vector<FileInfo> & files )
|
|||||||
{
|
{
|
||||||
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].filename = files[i].name;
|
||||||
|
allItems[i].lodCmpgn = files[i].inLod;
|
||||||
allItems[i].campaignInit();
|
allItems[i].campaignInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -652,6 +649,7 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::function<void(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<FileInfo> toParse;
|
std::vector<FileInfo> toParse;
|
||||||
|
std::vector<CCampaignHeader> cpm;
|
||||||
switch(tabType)
|
switch(tabType)
|
||||||
{
|
{
|
||||||
case CMenuScreen::newGame:
|
case CMenuScreen::newGame:
|
||||||
@ -677,6 +675,22 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::function<void(
|
|||||||
break;
|
break;
|
||||||
case CMenuScreen::campaignList:
|
case CMenuScreen::campaignList:
|
||||||
getFiles(toParse, DATA_DIR "/Maps", "h3c"); //get all campaigns
|
getFiles(toParse, DATA_DIR "/Maps", "h3c"); //get all campaigns
|
||||||
|
for (int g=0; g<toParse.size(); ++g)
|
||||||
|
{
|
||||||
|
toParse[g].inLod = false;
|
||||||
|
}
|
||||||
|
//add lod cmpgns
|
||||||
|
cpm = CCampaignHandler::getCampaignHeaders(CCampaignHandler::ALL);
|
||||||
|
for (int g = 0; g < cpm.size(); g++)
|
||||||
|
{
|
||||||
|
if (cpm[g].loadFromLod)
|
||||||
|
{
|
||||||
|
FileInfo fi;
|
||||||
|
fi.inLod = true;
|
||||||
|
fi.name = cpm[g].name;
|
||||||
|
toParse.push_back(fi);
|
||||||
|
}
|
||||||
|
}
|
||||||
parseCampaigns(toParse);
|
parseCampaigns(toParse);
|
||||||
positions = 18;
|
positions = 18;
|
||||||
break;
|
break;
|
||||||
@ -2059,7 +2073,7 @@ void CHotSeatPlayers::enterSelectionScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap )
|
CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap )
|
||||||
: ourCampaign(_ourCampaign), whichMap(_whichMap), highlightedRegion(NULL)
|
: ourCampaign(_ourCampaign), whichMap(_whichMap), highlightedRegion(NULL), ourHeader(NULL)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION;
|
OBJ_CONSTRUCTION;
|
||||||
static const std::string bgNames [] = {"E1_BG.BMP", "G2_BG.BMP", "E2_BG.BMP", "G1_BG.BMP", "G3_BG.BMP", "N1_BG.BMP",
|
static const std::string bgNames [] = {"E1_BG.BMP", "G2_BG.BMP", "E2_BG.BMP", "G1_BG.BMP", "G3_BG.BMP", "N1_BG.BMP",
|
||||||
@ -2077,10 +2091,6 @@ CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap
|
|||||||
startB = new AdventureMapButton("", "", 0 /*cb*/, 475, 536, "SCNRBEG.DEF", SDLK_RETURN);
|
startB = new AdventureMapButton("", "", 0 /*cb*/, 475, 536, "SCNRBEG.DEF", SDLK_RETURN);
|
||||||
backB = new AdventureMapButton("", "", boost::bind(&CBonusSelection::goBack, this), 624, 536, "SCNRBACK.DEF", SDLK_ESCAPE);
|
backB = new AdventureMapButton("", "", boost::bind(&CBonusSelection::goBack, this), 624, 536, "SCNRBACK.DEF", SDLK_ESCAPE);
|
||||||
|
|
||||||
CMapHeader ourHeader;
|
|
||||||
int _it=0;
|
|
||||||
ourHeader.initFromMemory((const unsigned char*)ourCampaign->mapPieces[whichMap].c_str(), _it);
|
|
||||||
|
|
||||||
//campaign name
|
//campaign name
|
||||||
if (ourCampaign->header.name.length())
|
if (ourCampaign->header.name.length())
|
||||||
printAtLoc(ourCampaign->header.name, 481, 28, FONT_BIG, tytulowy, background);
|
printAtLoc(ourCampaign->header.name, 481, 28, FONT_BIG, tytulowy, background);
|
||||||
@ -2088,28 +2098,8 @@ CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap
|
|||||||
printAtLoc("Unnamed", 481, 28, FONT_BIG, tytulowy, background);
|
printAtLoc("Unnamed", 481, 28, FONT_BIG, tytulowy, background);
|
||||||
|
|
||||||
//map size icon
|
//map size icon
|
||||||
CDefHandler *sizes = CDefHandler::giveDef("SCNRMPSZ.DEF");
|
sizes = CDefHandler::giveDef("SCNRMPSZ.DEF");
|
||||||
int temp;
|
|
||||||
switch (ourHeader.width)
|
|
||||||
{
|
|
||||||
case 36:
|
|
||||||
temp=0;
|
|
||||||
break;
|
|
||||||
case 72:
|
|
||||||
temp=1;
|
|
||||||
break;
|
|
||||||
case 108:
|
|
||||||
temp=2;
|
|
||||||
break;
|
|
||||||
case 144:
|
|
||||||
temp=3;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
temp=4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
blitAtLoc(sizes->ourImages[temp].bitmap, 735, 26, background);
|
|
||||||
delete sizes;
|
|
||||||
|
|
||||||
//campaign description
|
//campaign description
|
||||||
printAtLoc(CGI->generaltexth->allTexts[38], 481, 63, FONT_SMALL, tytulowy, background);
|
printAtLoc(CGI->generaltexth->allTexts[38], 481, 63, FONT_SMALL, tytulowy, background);
|
||||||
@ -2119,27 +2109,31 @@ CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap
|
|||||||
printAtLoc((*desc)[i], 481, 86 + i*16, FONT_SMALL, zwykly, background);
|
printAtLoc((*desc)[i], 481, 86 + i*16, FONT_SMALL, zwykly, background);
|
||||||
delete desc;
|
delete desc;
|
||||||
|
|
||||||
//map name
|
//set left part of window
|
||||||
std::string mapDesc = ourHeader.description, mapName = ourHeader.name;
|
for (int g=0; g<ourCampaign->scenarios.size(); ++g)
|
||||||
|
{
|
||||||
if (mapName.length())
|
if(ourCampaign->conquerable(g))
|
||||||
printAtLoc(mapName, 481, 219, FONT_BIG, tytulowy, background);
|
{
|
||||||
else
|
regions.push_back(new CRegion(this, true, true, g));
|
||||||
printAtLoc("Unnamed", 481, 219, FONT_BIG, tytulowy, background);
|
regions[regions.size()-1]->rclickText = ourCampaign->scenarios[g].regionText;
|
||||||
|
if (highlightedRegion == NULL)
|
||||||
//map description
|
{
|
||||||
printAtLoc(CGI->generaltexth->allTexts[496], 481, 253, FONT_SMALL, tytulowy, background);
|
highlightedRegion = regions.back();
|
||||||
|
selectMap(g);
|
||||||
desc = CMessage::breakText(mapDesc, 45);
|
}
|
||||||
for (int i=0; i<desc->size(); i++)
|
}
|
||||||
printAtLoc((*desc)[i], 481, 281 + i*16, FONT_SMALL, zwykly, background);
|
else if (ourCampaign->scenarios[g].conquered) //display as striped
|
||||||
delete desc;
|
{
|
||||||
|
regions.push_back(new CRegion(this, false, false, g));
|
||||||
|
regions[regions.size()-1]->rclickText = ourCampaign->scenarios[g].regionText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//allies / enemies
|
//allies / enemies
|
||||||
printAtLoc(CGI->generaltexth->allTexts[390] + ":", 486, 407, FONT_SMALL, zwykly, background); //Allies
|
printAtLoc(CGI->generaltexth->allTexts[390] + ":", 486, 407, FONT_SMALL, zwykly, background); //Allies
|
||||||
printAtLoc(CGI->generaltexth->allTexts[391] + ":", 619, 407, FONT_SMALL, zwykly, background); //Enemies
|
printAtLoc(CGI->generaltexth->allTexts[391] + ":", 619, 407, FONT_SMALL, zwykly, background); //Enemies
|
||||||
int fx=64, ex=244, myT;
|
int fx=64, ex=244, myT;
|
||||||
myT = ourHeader.players[playerColor].team;
|
myT = ourHeader->players[playerColor].team;
|
||||||
/*for (std::vector<PlayerSettings>::const_iterator i = curOpts->playerInfos.begin(); i != curOpts->playerInfos.end(); i++)
|
/*for (std::vector<PlayerSettings>::const_iterator i = curOpts->playerInfos.begin(); i != curOpts->playerInfos.end(); i++)
|
||||||
{
|
{
|
||||||
int *myx = ((i->color == playerColor || ourHeader.players[i->color].team == myT) ? &fx : &ex);
|
int *myx = ((i->color == playerColor || ourHeader.players[i->color].team == myT) ? &fx : &ex);
|
||||||
@ -2155,28 +2149,13 @@ CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap
|
|||||||
//difficulty
|
//difficulty
|
||||||
printAtLoc("Difficulty", 691, 431, FONT_MEDIUM, zwykly, background); //Difficulty
|
printAtLoc("Difficulty", 691, 431, FONT_MEDIUM, zwykly, background); //Difficulty
|
||||||
|
|
||||||
//set left part of window
|
|
||||||
for (int g=0; g<ourCampaign->scenarios.size(); ++g)
|
|
||||||
{
|
|
||||||
if(ourCampaign->conquerable(g))
|
|
||||||
{
|
|
||||||
regions.push_back(new CRegion(this, true, true, g));
|
|
||||||
if (highlightedRegion == NULL)
|
|
||||||
{
|
|
||||||
highlightedRegion = regions.back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (ourCampaign->scenarios[g].conquered) //display as striped
|
|
||||||
{
|
|
||||||
regions.push_back(new CRegion(this, false, false, g));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CBonusSelection::~CBonusSelection()
|
CBonusSelection::~CBonusSelection()
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(background);
|
SDL_FreeSurface(background);
|
||||||
|
delete sizes;
|
||||||
|
delete ourHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBonusSelection::goBack()
|
void CBonusSelection::goBack()
|
||||||
@ -2222,10 +2201,76 @@ void CBonusSelection::loadPositionsOfGraphics()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBonusSelection::selectMap( int whichOne )
|
||||||
|
{
|
||||||
|
sInfo.difficulty = ourCampaign->scenarios[whichOne].difficulty;
|
||||||
|
sInfo.mapname = ourCampaign->header.name;
|
||||||
|
sInfo.mode = 2;
|
||||||
|
|
||||||
|
//get header
|
||||||
|
int i = 0;
|
||||||
|
delete ourHeader;
|
||||||
|
ourHeader = new CMapHeader();
|
||||||
|
ourHeader->initFromMemory((const unsigned char*)ourCampaign->mapPieces[whichOne].c_str(), i);
|
||||||
|
const_cast<CMapInfo *>(curMap)->playerAmnt = ourHeader->players.size();
|
||||||
|
|
||||||
|
CSelectionScreen::updateStartInfo(curMap, *curOpts, ourHeader);
|
||||||
|
sInfo.turnTime = 0;
|
||||||
|
sInfo.whichMapInCampaign = whichOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBonusSelection::show( SDL_Surface * to )
|
||||||
|
{
|
||||||
|
blitAt(background, pos.x, pos.y, to);
|
||||||
|
|
||||||
|
//map name
|
||||||
|
std::string mapDesc = ourHeader->description,
|
||||||
|
mapName = ourHeader->name;
|
||||||
|
|
||||||
|
if (mapName.length())
|
||||||
|
printAtLoc(mapName, 481, 219, FONT_BIG, tytulowy, to);
|
||||||
|
else
|
||||||
|
printAtLoc("Unnamed", 481, 219, FONT_BIG, tytulowy, to);
|
||||||
|
|
||||||
|
//map description
|
||||||
|
printAtLoc(CGI->generaltexth->allTexts[496], 481, 253, FONT_SMALL, tytulowy, to);
|
||||||
|
|
||||||
|
std::vector<std::string> *desc = CMessage::breakText(mapDesc, 45);
|
||||||
|
for (int i=0; i<desc->size(); i++)
|
||||||
|
printAtLoc((*desc)[i], 481, 281 + i*16, FONT_SMALL, zwykly, to);
|
||||||
|
delete desc;
|
||||||
|
|
||||||
|
//map size icon
|
||||||
|
int temp;
|
||||||
|
switch (ourHeader->width)
|
||||||
|
{
|
||||||
|
case 36:
|
||||||
|
temp=0;
|
||||||
|
break;
|
||||||
|
case 72:
|
||||||
|
temp=1;
|
||||||
|
break;
|
||||||
|
case 108:
|
||||||
|
temp=2;
|
||||||
|
break;
|
||||||
|
case 144:
|
||||||
|
temp=3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
temp=4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
blitAtLoc(sizes->ourImages[temp].bitmap, 735, 26, to);
|
||||||
|
|
||||||
|
CIntObject::show(to);
|
||||||
|
}
|
||||||
|
|
||||||
CBonusSelection::CRegion::CRegion( CBonusSelection * _owner, bool _accessible, bool _selectable, int _myNumber )
|
CBonusSelection::CRegion::CRegion( CBonusSelection * _owner, bool _accessible, bool _selectable, int _myNumber )
|
||||||
: owner(_owner), accessible(_accessible), selectable(_selectable), myNumber(_myNumber)
|
: owner(_owner), accessible(_accessible), selectable(_selectable), myNumber(_myNumber)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION;
|
OBJ_CONSTRUCTION;
|
||||||
|
used = LCLICK | RCLICK;
|
||||||
|
|
||||||
static const std::string colors[2][8] = {
|
static const std::string colors[2][8] = {
|
||||||
{"R", "B", "N", "G", "O", "V", "T", "P"},
|
{"R", "B", "N", "G", "O", "V", "T", "P"},
|
||||||
{"Re", "Bl", "Br", "Gr", "Or", "Vi", "Te", "Pi"}};
|
{"Re", "Bl", "Br", "Gr", "Or", "Vi", "Te", "Pi"}};
|
||||||
@ -2245,6 +2290,8 @@ CBonusSelection::CRegion::CRegion( CBonusSelection * _owner, bool _accessible, b
|
|||||||
{
|
{
|
||||||
graphics[g] = BitmapHandler::loadBitmap(prefix + infix[g] + suffix + ".BMP");
|
graphics[g] = BitmapHandler::loadBitmap(prefix + infix[g] + suffix + ".BMP");
|
||||||
}
|
}
|
||||||
|
pos.w = graphics[0]->w;
|
||||||
|
pos.h = graphics[0]->h;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2259,15 +2306,23 @@ CBonusSelection::CRegion::~CRegion()
|
|||||||
void CBonusSelection::CRegion::clickLeft( tribool down, bool previousState )
|
void CBonusSelection::CRegion::clickLeft( tribool down, bool previousState )
|
||||||
{
|
{
|
||||||
//select if selectable & clicked inside our graphic
|
//select if selectable & clicked inside our graphic
|
||||||
if(!down && selectable)
|
if( !down && selectable && !CSDL_Ext::isTransparent(graphics[0], GH.current->motion.x-pos.x, GH.current->motion.y-pos.y) )
|
||||||
{
|
{
|
||||||
//owner->highlightedRegion = this;
|
owner->selectMap(myNumber);
|
||||||
|
owner->highlightedRegion = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBonusSelection::CRegion::clickRight( tribool down, bool previousState )
|
void CBonusSelection::CRegion::clickRight( tribool down, bool previousState )
|
||||||
{
|
{
|
||||||
//show r-click text
|
//show r-click text
|
||||||
|
if( down && !CSDL_Ext::isTransparent(graphics[0], GH.current->motion.x-pos.x, GH.current->motion.y-pos.y) &&
|
||||||
|
rclickText.size() )
|
||||||
|
{
|
||||||
|
CSimpleWindow * temp = CMessage::genWindow(rclickText, 0, true);
|
||||||
|
CRClickPopupInt *rcpi = new CRClickPopupInt(temp, true);
|
||||||
|
GH.pushInt(rcpi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBonusSelection::CRegion::show( SDL_Surface * to )
|
void CBonusSelection::CRegion::show( SDL_Surface * to )
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
CCampaignHeader * campaignHeader; //may be NULL if scenario
|
CCampaignHeader * campaignHeader; //may be NULL if scenario
|
||||||
ui8 seldiff; //selected difficulty (only in saved games)
|
ui8 seldiff; //selected difficulty (only in saved games)
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
bool lodCmpgn; //tells if this campaign is located in Lod file
|
||||||
std::string date;
|
std::string date;
|
||||||
int playerAmnt, humenPlayers;
|
int playerAmnt, humenPlayers;
|
||||||
CMapInfo(bool map = true);
|
CMapInfo(bool map = true);
|
||||||
@ -73,12 +74,13 @@ struct FileInfo
|
|||||||
{
|
{
|
||||||
std::string name; // file name with full path and extension
|
std::string name; // file name with full path and extension
|
||||||
std::time_t date;
|
std::time_t date;
|
||||||
|
bool inLod; //tells if this file is located in Lod
|
||||||
};
|
};
|
||||||
|
|
||||||
class InfoCard : public CIntObject
|
class InfoCard : public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
CPicture *bg;
|
CPicture *bg;
|
||||||
|
public:
|
||||||
CMenuScreen::EState type;
|
CMenuScreen::EState type;
|
||||||
|
|
||||||
CHighlightableButtonsGroup *difficulty;
|
CHighlightableButtonsGroup *difficulty;
|
||||||
@ -139,6 +141,7 @@ public:
|
|||||||
|
|
||||||
class OptionsTab : public CIntObject
|
class OptionsTab : public CIntObject
|
||||||
{
|
{
|
||||||
|
CPicture *bg;
|
||||||
public:
|
public:
|
||||||
enum SelType {TOWN, HERO, BONUS};
|
enum SelType {TOWN, HERO, BONUS};
|
||||||
struct SelectedBox : public CIntObject //img with current town/hero/bonus
|
struct SelectedBox : public CIntObject //img with current town/hero/bonus
|
||||||
@ -170,7 +173,6 @@ public:
|
|||||||
void showAll(SDL_Surface * to);
|
void showAll(SDL_Surface * to);
|
||||||
};
|
};
|
||||||
CMenuScreen::EState type;
|
CMenuScreen::EState type;
|
||||||
CPicture *bg;
|
|
||||||
CSlider *turnDuration;
|
CSlider *turnDuration;
|
||||||
|
|
||||||
std::set<int> usedHeroes;
|
std::set<int> usedHeroes;
|
||||||
@ -195,13 +197,13 @@ public:
|
|||||||
|
|
||||||
class CSelectionScreen : public CIntObject
|
class CSelectionScreen : public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
CPicture *bg; //general bg image
|
CPicture *bg; //general bg image
|
||||||
AdventureMapButton *start, *back;
|
|
||||||
InfoCard *card;
|
InfoCard *card;
|
||||||
SelectionTab *sel;
|
|
||||||
OptionsTab *opt;
|
OptionsTab *opt;
|
||||||
|
public:
|
||||||
|
AdventureMapButton *start, *back;
|
||||||
|
|
||||||
|
SelectionTab *sel;
|
||||||
CMenuScreen::EState type; //new/save/load#Game
|
CMenuScreen::EState type; //new/save/load#Game
|
||||||
const CMapInfo *current;
|
const CMapInfo *current;
|
||||||
StartInfo sInfo;
|
StartInfo sInfo;
|
||||||
@ -211,7 +213,7 @@ public:
|
|||||||
~CSelectionScreen();
|
~CSelectionScreen();
|
||||||
void toggleTab(CIntObject *tab);
|
void toggleTab(CIntObject *tab);
|
||||||
void changeSelection(const CMapInfo *to);
|
void changeSelection(const CMapInfo *to);
|
||||||
void updateStartInfo(const CMapInfo * to);
|
static void updateStartInfo( const CMapInfo * to, StartInfo & sInfo, const CMapHeader * mapHeader );
|
||||||
void startCampaign();
|
void startCampaign();
|
||||||
void startGame();
|
void startGame();
|
||||||
void difficultyChange(int to);
|
void difficultyChange(int to);
|
||||||
@ -282,6 +284,7 @@ class CBonusSelection : public CIntObject
|
|||||||
bool selectable; //true if region should be selectable
|
bool selectable; //true if region should be selectable
|
||||||
int myNumber; //number of region
|
int myNumber; //number of region
|
||||||
public:
|
public:
|
||||||
|
std::string rclickText;
|
||||||
CRegion(CBonusSelection * _owner, bool _accessible, bool _selectable, int _myNumber);
|
CRegion(CBonusSelection * _owner, bool _accessible, bool _selectable, int _myNumber);
|
||||||
~CRegion();
|
~CRegion();
|
||||||
|
|
||||||
@ -295,12 +298,18 @@ class CBonusSelection : public CIntObject
|
|||||||
|
|
||||||
void loadPositionsOfGraphics();
|
void loadPositionsOfGraphics();
|
||||||
const CCampaign * ourCampaign;
|
const CCampaign * ourCampaign;
|
||||||
|
CMapHeader *ourHeader;
|
||||||
|
CDefHandler *sizes; //icons of map sizes
|
||||||
int whichMap;
|
int whichMap;
|
||||||
public:
|
public:
|
||||||
|
StartInfo sInfo;
|
||||||
|
void selectMap(int whichOne);
|
||||||
|
|
||||||
CBonusSelection(const CCampaign * _ourCampaign, int _whichMap);
|
CBonusSelection(const CCampaign * _ourCampaign, int _whichMap);
|
||||||
~CBonusSelection();
|
~CBonusSelection();
|
||||||
|
|
||||||
void showAll(SDL_Surface * to);
|
void showAll(SDL_Surface * to);
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
|
||||||
void goBack();
|
void goBack();
|
||||||
void startMap();
|
void startMap();
|
||||||
|
@ -1046,4 +1046,16 @@ std::string CSDL_Ext::processStr(std::string str, std::vector<std::string> & tor
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSDL_Ext::isTransparent( SDL_Surface * srf, int x, int y )
|
||||||
|
{
|
||||||
|
if(srf->format->BytesPerPixel == 1)
|
||||||
|
{
|
||||||
|
return ((ui8*)srf->pixels)[x + srf->pitch * y] == 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert(!"isTransparent called with non-8bpp surface!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Surface * CSDL_Ext::std32bppSurface = NULL;
|
SDL_Surface * CSDL_Ext::std32bppSurface = NULL;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
clientSettings
|
clientSettings
|
||||||
{
|
{
|
||||||
port=3030;
|
port=3030;
|
||||||
resolution=800x600; // format: WxH
|
resolution=1024x768; // format: WxH
|
||||||
bpp=24; // bytes per pixels: 24 or 32
|
bpp=24; // bytes per pixels: 24 or 32
|
||||||
fullscreen=0; //0 - windowed mode, 1 - fullscreen
|
fullscreen=0; //0 - windowed mode, 1 - fullscreen
|
||||||
server=127.0.0.1; //use 127.0.0.1 for localhost
|
server=127.0.0.1; //use 127.0.0.1 for localhost
|
||||||
|
@ -21,18 +21,20 @@ namespace fs = boost::filesystem;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders()
|
std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders(GetMode mode)
|
||||||
{
|
{
|
||||||
std::vector<CCampaignHeader> ret;
|
std::vector<CCampaignHeader> ret;
|
||||||
|
|
||||||
std::string dirname = DATA_DIR "/Maps";
|
std::string dirname = DATA_DIR "/Maps";
|
||||||
std::string ext = ".h3c";
|
std::string ext = ".H3C";
|
||||||
|
|
||||||
if(!boost::filesystem::exists(dirname))
|
if(!boost::filesystem::exists(dirname))
|
||||||
{
|
{
|
||||||
tlog1 << "Cannot find " << dirname << " directory!\n";
|
tlog1 << "Cannot find " << dirname << " directory!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode == Custom || mode == ALL) //add custom campaigns
|
||||||
|
{
|
||||||
fs::path tie(dirname);
|
fs::path tie(dirname);
|
||||||
fs::directory_iterator end_iter;
|
fs::directory_iterator end_iter;
|
||||||
for ( fs::directory_iterator file (tie); file!=end_iter; ++file )
|
for ( fs::directory_iterator file (tie); file!=end_iter; ++file )
|
||||||
@ -40,35 +42,61 @@ std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders()
|
|||||||
if(fs::is_regular_file(file->status())
|
if(fs::is_regular_file(file->status())
|
||||||
&& boost::ends_with(file->path().filename(), ext))
|
&& boost::ends_with(file->path().filename(), ext))
|
||||||
{
|
{
|
||||||
ret.push_back( getHeader( file->path().string() ) );
|
ret.push_back( getHeader( file->path().string(), false ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (mode == ALL) //add all lod campaigns
|
||||||
|
{
|
||||||
|
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) )
|
||||||
|
{
|
||||||
|
ret.push_back( getHeader(bitmaph->entries[g].nameStr, true) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCampaignHeader CCampaignHandler::getHeader( const std::string & name )
|
CCampaignHeader CCampaignHandler::getHeader( const std::string & name, bool fromLod )
|
||||||
{
|
{
|
||||||
int realSize;
|
int realSize;
|
||||||
unsigned char * cmpgn = CLodHandler::getUnpackedFile(name, &realSize);
|
unsigned char * cmpgn = CLodHandler::getUnpackedFile(name, &realSize);
|
||||||
|
|
||||||
int it = 0;//iterator for reading
|
int it = 0;//iterator for reading
|
||||||
CCampaignHeader ret = readHeaderFromMemory(cmpgn, it);
|
CCampaignHeader ret = readHeaderFromMemory(cmpgn, it);
|
||||||
|
ret.filename = name;
|
||||||
|
ret.loadFromLod = false;
|
||||||
|
|
||||||
delete [] cmpgn;
|
delete [] cmpgn;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCampaign * CCampaignHandler::getCampaign( const std::string & name )
|
CCampaign * CCampaignHandler::getCampaign( const std::string & name, bool fromLod )
|
||||||
{
|
{
|
||||||
CCampaign * ret = new CCampaign();
|
CCampaign * ret = new CCampaign();
|
||||||
|
|
||||||
int realSize;
|
int realSize;
|
||||||
unsigned char * cmpgn = CLodHandler::getUnpackedFile(name, &realSize);
|
unsigned char * cmpgn;
|
||||||
|
if (fromLod)
|
||||||
|
{
|
||||||
|
cmpgn = bitmaph->giveFile(name, &realSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmpgn = CLodHandler::getUnpackedFile(name, &realSize);
|
||||||
|
}
|
||||||
|
|
||||||
int it = 0; //iterator for reading
|
int it = 0; //iterator for reading
|
||||||
ret->header = readHeaderFromMemory(cmpgn, it);
|
ret->header = readHeaderFromMemory(cmpgn, it);
|
||||||
|
ret->header.filename = name;
|
||||||
|
ret->header.loadFromLod = fromLod;
|
||||||
|
|
||||||
int howManyScenarios = VLC->generaltexth->campaignRegionNames[ret->header.mapVersion].size();
|
int howManyScenarios = VLC->generaltexth->campaignRegionNames[ret->header.mapVersion].size();
|
||||||
for(int g=0; g<howManyScenarios; ++g)
|
for(int g=0; g<howManyScenarios; ++g)
|
||||||
|
@ -24,9 +24,12 @@ public:
|
|||||||
ui8 difficultyChoosenByPlayer;
|
ui8 difficultyChoosenByPlayer;
|
||||||
ui8 music; //CmpMusic.txt, start from 0
|
ui8 music; //CmpMusic.txt, start from 0
|
||||||
|
|
||||||
|
std::string filename;
|
||||||
|
ui8 loadFromLod; //if true, this campaign must be loaded fro, .lod file
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
||||||
{
|
{
|
||||||
h & version & mapVersion & name & description & difficultyChoosenByPlayer & music;
|
h & version & mapVersion & name & description & difficultyChoosenByPlayer & music & filename & loadFromLod;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -121,10 +124,11 @@ class DLL_EXPORT CCampaignHandler
|
|||||||
static std::vector<ui32> locateH3mStarts(const unsigned char * buffer, int start, int size);
|
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 bool startsAt( const unsigned char * buffer, int size, int pos ); //a simple heuristic that checks if a h3m starts at given pos
|
||||||
public:
|
public:
|
||||||
static std::vector<CCampaignHeader> getCampaignHeaders();
|
enum GetMode {RoE, AB, SoD, WoG, Custom, ALL};
|
||||||
static CCampaignHeader getHeader( const std::string & name ); //name - name of appropriate file
|
static std::vector<CCampaignHeader> getCampaignHeaders(GetMode mode);
|
||||||
|
static CCampaignHeader getHeader( const std::string & name, bool fromLod ); //name - name of appropriate file
|
||||||
|
|
||||||
static CCampaign * getCampaign(const std::string & name); //name - name of appropriate file
|
static CCampaign * getCampaign(const std::string & name, bool fromLod); //name - name of appropriate file
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user