1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* campaigns, part 1

* minor changes
This commit is contained in:
mateuszb 2010-02-08 14:38:06 +00:00
parent ba51824710
commit 4d9d54735f
7 changed files with 73 additions and 56 deletions

View File

@ -26,6 +26,8 @@
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include <sstream>
#include <SDL.h>
using namespace boost::assign;
using namespace CSDL_Ext;

View File

@ -2,9 +2,7 @@
#define __CKINGDOMINTERFACE_H__
#include "../global.h"
#include <SDL.h>
#include "GUIBase.h"
#include "GUIClasses.h"
#include "../hch/CMusicBase.h"

View File

@ -42,6 +42,7 @@
#include "../lib/VCMIDirs.h"
#include <cstdlib>
#include "../lib/NetPacks.h"
#include "CMessage.h"
#ifdef _WIN32
#include "SDL_syswm.h"

View File

@ -30,6 +30,10 @@
#include "CPlayerInterface.h"
#include "../CCallback.h"
#include <boost/lexical_cast.hpp>
#include <cstdlib>
#include "CMessage.h"
#include "../lib/map.h"
#include "../hch/CCampaignHandler.h"
/*
* CPreGame.cpp, part of VCMI engine
*
@ -80,7 +84,7 @@ CMenuScreen::CMenuScreen( EState which )
bgAd = new CPicture(BitmapHandler::loadBitmap("ZNEWGAM.bmp"), 114, 312, true);
buttons[0] = new AdventureMapButton("", CGI->generaltexth->zelp[10].second, bind(&CGPreGame::openSel, CGP, newGame), 545, 4, "ZTSINGL.DEF", SDLK_s);
buttons[1] = new AdventureMapButton("", CGI->generaltexth->zelp[11].second, 0 /*cb*/, 568, 120, "ZTMULTI.DEF", SDLK_m);
buttons[2] = new AdventureMapButton("", CGI->generaltexth->zelp[12].second, 0 /*cb*/, 541, 233, "ZTCAMPN.DEF", SDLK_c);
buttons[2] = new AdventureMapButton("", CGI->generaltexth->zelp[12].second, bind(&CMenuScreen::moveTo, this, ref(CGP->scrs[campaignMain])), 541, 233, "ZTCAMPN.DEF", SDLK_c);
buttons[3] = new AdventureMapButton("", CGI->generaltexth->zelp[13].second, 0 /*cb*/, 545, 358, "ZTTUTOR.DEF", SDLK_t);
buttons[4] = new AdventureMapButton("", CGI->generaltexth->zelp[14].second, bind(&CMenuScreen::moveTo, this, CGP->scrs[mainMenu]), 582, 464, "ZTBACK.DEF", SDLK_ESCAPE);
}
@ -95,6 +99,16 @@ CMenuScreen::CMenuScreen( EState which )
buttons[4] = new AdventureMapButton("", CGI->generaltexth->zelp[14].second, bind(&CMenuScreen::moveTo, this, CGP->scrs[mainMenu]), 582, 464, "ZTBACK.DEF", SDLK_ESCAPE);
}
break;
case campaignMain:
{
buttons[0] = new AdventureMapButton("", "", 0 /*cb*/, 535, 8, "ZSSSOD.DEF", SDLK_s);
buttons[1] = new AdventureMapButton("", "", 0 /*cb*/, 494, 117, "ZSSROE.DEF", SDLK_m);
buttons[2] = new AdventureMapButton("", "", 0 /*cb*/, 486, 241, "ZSSARM.DEF", SDLK_c);
buttons[3] = new AdventureMapButton("", "", 0 /*cb*/, 550, 358, "ZSSCUS.DEF", SDLK_t);
buttons[4] = new AdventureMapButton("", "", bind(&CMenuScreen::moveTo, this, CGP->scrs[newGame]), 582, 464, "ZSSEXIT.DEF", SDLK_ESCAPE);
(new CCampaignHandler())->getCampaignHeaders(); //just for testing
}
break;
}
for(int i = 0; i < ARRAY_COUNT(buttons); i++)
@ -1695,3 +1709,43 @@ void CTextInput::setText( const std::string &nText, bool callCb )
if(callCb)
cb(text);
}
bool mapSorter::operator()( const CMapHeader *a, const CMapHeader *b )
{
switch (sortBy)
{
case _format:
return (a->version<b->version);
break;
case _loscon:
return (a->lossCondition.typeOfLossCon<b->lossCondition.typeOfLossCon);
break;
case _playerAm:
int playerAmntB,humenPlayersB,playerAmntA,humenPlayersA;
playerAmntB=humenPlayersB=playerAmntA=humenPlayersA=0;
for (int i=0;i<8;i++)
{
if (a->players[i].canHumanPlay) {playerAmntA++;humenPlayersA++;}
else if (a->players[i].canComputerPlay) {playerAmntA++;}
if (b->players[i].canHumanPlay) {playerAmntB++;humenPlayersB++;}
else if (b->players[i].canComputerPlay) {playerAmntB++;}
}
if (playerAmntB!=playerAmntA)
return (playerAmntA<playerAmntB);
else
return (humenPlayersA<humenPlayersB);
break;
case _size:
return (a->width<b->width);
break;
case _viccon:
return (a->victoryCondition.condition < b->victoryCondition.condition);
break;
case _name:
return (a->name<b->name);
break;
default:
return (a->name<b->name);
break;
}
}

View File

@ -4,9 +4,6 @@
#include <set>
#include <SDL.h>
#include "../StartInfo.h"
#include "CMessage.h"
#include "../lib/map.h"
#include <cstdlib>
#include "GUIBase.h"
#include "FunctionList.h"
@ -21,11 +18,22 @@
*/
struct CMusicHandler;
class CMapInfo;
class CMapHeader;
enum EState { //where are we?
mainMenu, newGame, loadGame, ScenarioList, saveGame, scenarioInfo
mainMenu, newGame, loadGame, campaignMain, ScenarioList, saveGame, scenarioInfo
};
enum ESortBy{_playerAm, _size, _format, _name, _viccon, _loscon};
class mapSorter
{
public:
ESortBy sortBy;
bool operator()(const CMapHeader *a, const CMapHeader *b);;
mapSorter(ESortBy es):sortBy(es){};
};
class CTextInput : public CIntObject
{
@ -216,7 +224,7 @@ class CGPreGame : public CIntObject, public IUpdateable
{
public:
SDL_Surface *mainbg;
CMenuScreen *scrs[3];
CMenuScreen *scrs[4];
SDL_Surface *nHero, *rHero, *nTown, *rTown; // none/random hero/town imgs
CDefHandler *bonuses;

View File

@ -30,7 +30,7 @@ class CGHeroInstance;
class CGCreature;
class CQuest;
class CGTownInstance;
enum ESortBy{_playerAm, _size, _format, _name, _viccon, _loscon};
enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF,
EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF, ARTIFACT_DEF, WITCHHUT_DEF, SCHOLAR_DEF, PLAYERONLY_DEF,
SHRINE_DEF, SPELLSCROLL_DEF, PANDORA_DEF, GRAIL_DEF, CREGEN_DEF, CREGEN2_DEF, CREGEN3_DEF,
@ -260,52 +260,6 @@ public:
void countPlayers();
};
class DLL_EXPORT mapSorter
{
public:
ESortBy sortBy;
bool operator()(const CMapHeader *a, const CMapHeader *b)
{
switch (sortBy)
{
case _format:
return (a->version<b->version);
break;
case _loscon:
return (a->lossCondition.typeOfLossCon<b->lossCondition.typeOfLossCon);
break;
case _playerAm:
int playerAmntB,humenPlayersB,playerAmntA,humenPlayersA;
playerAmntB=humenPlayersB=playerAmntA=humenPlayersA=0;
for (int i=0;i<8;i++)
{
if (a->players[i].canHumanPlay) {playerAmntA++;humenPlayersA++;}
else if (a->players[i].canComputerPlay) {playerAmntA++;}
if (b->players[i].canHumanPlay) {playerAmntB++;humenPlayersB++;}
else if (b->players[i].canComputerPlay) {playerAmntB++;}
}
if (playerAmntB!=playerAmntA)
return (playerAmntA<playerAmntB);
else
return (humenPlayersA<humenPlayersB);
break;
case _size:
return (a->width<b->width);
break;
case _viccon:
return (a->victoryCondition.condition < b->victoryCondition.condition);
break;
case _name:
return (a->name<b->name);
break;
default:
return (a->name<b->name);
break;
}
};
mapSorter(ESortBy es):sortBy(es){};
};
struct DLL_EXPORT Mapa : public CMapHeader
{
ui32 checksum;