mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
* a bit of custom campaign selection screen
This commit is contained in:
@@ -1813,7 +1813,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|||||||
return;
|
return;
|
||||||
case SDLK_s:
|
case SDLK_s:
|
||||||
if(isActive())
|
if(isActive())
|
||||||
GH.pushInt(new CSelectionScreen(saveGame));
|
GH.pushInt(new CSelectionScreen(CMenuScreen::saveGame));
|
||||||
return;
|
return;
|
||||||
case SDLK_SPACE: //space - try to revisit current object with selected hero
|
case SDLK_SPACE: //space - try to revisit current object with selected hero
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -18,11 +18,24 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct CMusicHandler;
|
struct CMusicHandler;
|
||||||
class CMapInfo;
|
|
||||||
class CMapHeader;
|
class CMapHeader;
|
||||||
|
class CCampaignHeader;
|
||||||
|
|
||||||
enum EState { //where are we?
|
class CMapInfo
|
||||||
mainMenu, newGame, loadGame, campaignMain, ScenarioList, saveGame, scenarioInfo
|
{
|
||||||
|
public:
|
||||||
|
CMapHeader * mapHeader; //may be NULL if campaign
|
||||||
|
CCampaignHeader * campaignHeader; //may be NULL if scenario
|
||||||
|
ui8 seldiff; //selected difficulty (only in saved games)
|
||||||
|
std::string filename;
|
||||||
|
std::string date;
|
||||||
|
int playerAmnt, humenPlayers;
|
||||||
|
CMapInfo(bool map = true);
|
||||||
|
~CMapInfo();
|
||||||
|
//CMapInfo(const std::string &fname, const unsigned char *map);
|
||||||
|
void mapInit(const std::string &fname, const unsigned char *map);
|
||||||
|
void campaignInit();
|
||||||
|
void countPlayers();
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ESortBy{_playerAm, _size, _format, _name, _viccon, _loscon};
|
enum ESortBy{_playerAm, _size, _format, _name, _viccon, _loscon};
|
||||||
@@ -31,7 +44,7 @@ class mapSorter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ESortBy sortBy;
|
ESortBy sortBy;
|
||||||
bool operator()(const CMapHeader *a, const CMapHeader *b);;
|
bool operator()(const CMapInfo *aaa, const CMapInfo *bbb);
|
||||||
mapSorter(ESortBy es):sortBy(es){};
|
mapSorter(ESortBy es):sortBy(es){};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -55,6 +68,10 @@ public:
|
|||||||
class CMenuScreen : public CIntObject
|
class CMenuScreen : public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum EState { //where are we?
|
||||||
|
mainMenu, newGame, loadGame, campaignMain, ScenarioList, saveGame, scenarioInfo, campaignList
|
||||||
|
};
|
||||||
|
|
||||||
CPicture *bgAd;
|
CPicture *bgAd;
|
||||||
AdventureMapButton *buttons[5];
|
AdventureMapButton *buttons[5];
|
||||||
|
|
||||||
@@ -76,7 +93,7 @@ class InfoCard : public CIntObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPicture *bg;
|
CPicture *bg;
|
||||||
EState type;
|
CMenuScreen::EState type;
|
||||||
|
|
||||||
CHighlightableButtonsGroup *difficulty;
|
CHighlightableButtonsGroup *difficulty;
|
||||||
CDefHandler *sizes, *sFlags;;
|
CDefHandler *sizes, *sFlags;;
|
||||||
@@ -85,12 +102,20 @@ public:
|
|||||||
void showAll(SDL_Surface * to);
|
void showAll(SDL_Surface * to);
|
||||||
void clickRight(tribool down, bool previousState);
|
void clickRight(tribool down, bool previousState);
|
||||||
void showTeamsPopup();
|
void showTeamsPopup();
|
||||||
InfoCard(EState Type);
|
InfoCard(CMenuScreen::EState Type);
|
||||||
~InfoCard();
|
~InfoCard();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SelectionTab : public CIntObject
|
class SelectionTab : public CIntObject
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
CDefHandler *format; //map size
|
||||||
|
|
||||||
|
void parseMaps(std::vector<FileInfo> &files, int start = 0, int threads = 1);
|
||||||
|
void parseGames(std::vector<FileInfo> &files);
|
||||||
|
void parseCampaigns( std::vector<FileInfo> & files );
|
||||||
|
void getFiles(std::vector<FileInfo> &out, const std::string &dirname, const std::string &ext);
|
||||||
|
CMenuScreen::EState tabType;
|
||||||
public:
|
public:
|
||||||
int positions; //how many entries (games/maps) can be shown
|
int positions; //how many entries (games/maps) can be shown
|
||||||
CPicture *bg; //general bg image
|
CPicture *bg; //general bg image
|
||||||
@@ -103,13 +128,9 @@ public:
|
|||||||
ESortBy sortingBy;
|
ESortBy sortingBy;
|
||||||
bool ascending;
|
bool ascending;
|
||||||
|
|
||||||
CDefHandler *format;
|
|
||||||
|
|
||||||
CTextInput *txt;
|
CTextInput *txt;
|
||||||
|
|
||||||
void getFiles(std::vector<FileInfo> &out, const std::string &dirname, const std::string &ext);
|
|
||||||
void parseMaps(std::vector<FileInfo> &files, int start = 0, int threads = 1);
|
|
||||||
void parseGames(std::vector<FileInfo> &files);
|
|
||||||
void filter(int size, bool selectFirst = false); //0 - all
|
void filter(int size, bool selectFirst = false); //0 - all
|
||||||
void select(int position); //position: <0 - positions> position on the screen
|
void select(int position); //position: <0 - positions> position on the screen
|
||||||
void selectAbs(int position); //position: absolute position in curItems vector
|
void selectAbs(int position); //position: absolute position in curItems vector
|
||||||
@@ -126,7 +147,7 @@ public:
|
|||||||
void wheelScrolled(bool down, bool in);
|
void wheelScrolled(bool down, bool in);
|
||||||
void keyPressed(const SDL_KeyboardEvent & key);
|
void keyPressed(const SDL_KeyboardEvent & key);
|
||||||
void onDoubleClick();
|
void onDoubleClick();
|
||||||
SelectionTab(EState Type, const boost::function<void(CMapInfo *)> &OnSelect);
|
SelectionTab(CMenuScreen::EState Type, const boost::function<void(CMapInfo *)> &OnSelect);
|
||||||
~SelectionTab();
|
~SelectionTab();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -162,7 +183,7 @@ public:
|
|||||||
void selectButtons(bool onlyHero = true); //hides unavailable buttons
|
void selectButtons(bool onlyHero = true); //hides unavailable buttons
|
||||||
void showAll(SDL_Surface * to);
|
void showAll(SDL_Surface * to);
|
||||||
};
|
};
|
||||||
EState type;
|
CMenuScreen::EState type;
|
||||||
CPicture *bg;
|
CPicture *bg;
|
||||||
CSlider *turnDuration;
|
CSlider *turnDuration;
|
||||||
|
|
||||||
@@ -177,7 +198,7 @@ public:
|
|||||||
void flagPressed(int player);
|
void flagPressed(int player);
|
||||||
|
|
||||||
void changeSelection(const CMapHeader *to);
|
void changeSelection(const CMapHeader *to);
|
||||||
OptionsTab(EState Type/*, StartInfo &Opts*/);
|
OptionsTab(CMenuScreen::EState Type/*, StartInfo &Opts*/);
|
||||||
~OptionsTab();
|
~OptionsTab();
|
||||||
void showAll(SDL_Surface * to);
|
void showAll(SDL_Surface * to);
|
||||||
|
|
||||||
@@ -195,12 +216,12 @@ public:
|
|||||||
SelectionTab *sel;
|
SelectionTab *sel;
|
||||||
OptionsTab *opt;
|
OptionsTab *opt;
|
||||||
|
|
||||||
EState type; //new/save/load#Game
|
CMenuScreen::EState type; //new/save/load#Game
|
||||||
const CMapInfo *current;
|
const CMapInfo *current;
|
||||||
StartInfo sInfo;
|
StartInfo sInfo;
|
||||||
CIntObject *curTab;
|
CIntObject *curTab;
|
||||||
|
|
||||||
CSelectionScreen(EState Type);
|
CSelectionScreen(CMenuScreen::EState Type);
|
||||||
~CSelectionScreen();
|
~CSelectionScreen();
|
||||||
void toggleTab(CIntObject *tab);
|
void toggleTab(CIntObject *tab);
|
||||||
void changeSelection(const CMapInfo *to);
|
void changeSelection(const CMapInfo *to);
|
||||||
@@ -216,7 +237,7 @@ public:
|
|||||||
InfoCard *card;
|
InfoCard *card;
|
||||||
OptionsTab *opt;
|
OptionsTab *opt;
|
||||||
|
|
||||||
CScenarioInfo(const CMapHeader *mapInfo, const StartInfo *startInfo);
|
CScenarioInfo(const CMapHeader *mapHeader, const StartInfo *startInfo, const CMapInfo * makeItCurrent=NULL);
|
||||||
~CScenarioInfo();
|
~CScenarioInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,7 +255,7 @@ public:
|
|||||||
~CGPreGame();
|
~CGPreGame();
|
||||||
void update();
|
void update();
|
||||||
void run();
|
void run();
|
||||||
void openSel(EState type);
|
void openSel(CMenuScreen::EState type);
|
||||||
void loadGraphics();
|
void loadGraphics();
|
||||||
void disposeGraphics();
|
void disposeGraphics();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2999,7 +2999,7 @@ void CSystemOptionsWindow::bmainmenuf()
|
|||||||
void CSystemOptionsWindow::bsavef()
|
void CSystemOptionsWindow::bsavef()
|
||||||
{
|
{
|
||||||
GH.popIntTotally(this);
|
GH.popIntTotally(this);
|
||||||
GH.pushInt(new CSelectionScreen(saveGame));
|
GH.pushInt(new CSelectionScreen(CMenuScreen::saveGame));
|
||||||
/*using namespace boost::posix_time;
|
/*using namespace boost::posix_time;
|
||||||
std::ostringstream fnameStream;
|
std::ostringstream fnameStream;
|
||||||
fnameStream << second_clock::local_time();
|
fnameStream << second_clock::local_time();
|
||||||
|
|||||||
@@ -40,14 +40,14 @@ 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(), fs::file_size( file->path() ) ) );
|
ret.push_back( getHeader( file->path().string() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCampaignHeader CCampaignHandler::getHeader( const std::string & name, int size )
|
CCampaignHeader CCampaignHandler::getHeader( const std::string & name )
|
||||||
{
|
{
|
||||||
int realSize;
|
int realSize;
|
||||||
unsigned char * cmpgn = CLodHandler::getUnpackedFile(name, &realSize);
|
unsigned char * cmpgn = CLodHandler::getUnpackedFile(name, &realSize);
|
||||||
|
|||||||
@@ -111,16 +111,16 @@ public:
|
|||||||
|
|
||||||
class DLL_EXPORT CCampaignHandler
|
class DLL_EXPORT CCampaignHandler
|
||||||
{
|
{
|
||||||
CCampaignHeader readHeaderFromMemory( const unsigned char *buffer, int & outIt );
|
static CCampaignHeader readHeaderFromMemory( const unsigned char *buffer, int & outIt );
|
||||||
CCampaignScenario readScenarioFromMemory( const unsigned char *buffer, int & outIt );
|
static CCampaignScenario readScenarioFromMemory( const unsigned char *buffer, int & outIt );
|
||||||
CScenarioTravel readScenarioTravelFromMemory( const unsigned char * buffer, int & outIt );
|
static CScenarioTravel readScenarioTravelFromMemory( const unsigned char * buffer, int & outIt );
|
||||||
CCampaignHeader getHeader( const std::string & name, int size );
|
static std::vector<ui32> locateH3mStarts(const unsigned char * buffer, int start, int size);
|
||||||
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:
|
||||||
std::vector<CCampaignHeader> getCampaignHeaders();
|
static std::vector<CCampaignHeader> getCampaignHeaders();
|
||||||
|
static CCampaignHeader getHeader( const std::string & name );
|
||||||
|
|
||||||
CCampaign * getCampaign(const std::string & name);
|
static CCampaign * getCampaign(const std::string & name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
35
lib/map.cpp
35
lib/map.cpp
@@ -2106,41 +2106,6 @@ void Mapa::checkForObjectives()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapInfo::countPlayers()
|
|
||||||
{
|
|
||||||
playerAmnt = humenPlayers = 0;
|
|
||||||
for(int i=0;i<PLAYER_LIMIT;i++)
|
|
||||||
{
|
|
||||||
if(players[i].canHumanPlay)
|
|
||||||
{
|
|
||||||
playerAmnt++;
|
|
||||||
humenPlayers++;
|
|
||||||
}
|
|
||||||
else if(players[i].canComputerPlay)
|
|
||||||
{
|
|
||||||
playerAmnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CMapInfo::CMapInfo(const std::string &fname, const unsigned char *map )
|
|
||||||
{
|
|
||||||
init(fname, map);
|
|
||||||
}
|
|
||||||
|
|
||||||
CMapInfo::CMapInfo()
|
|
||||||
{
|
|
||||||
version = invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMapInfo::init(const std::string &fname, const unsigned char *map )
|
|
||||||
{
|
|
||||||
filename = fname;
|
|
||||||
int i = 0;
|
|
||||||
initFromMemory(map, i);
|
|
||||||
countPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
LossCondition::LossCondition()
|
LossCondition::LossCondition()
|
||||||
{
|
{
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
|
|||||||
13
lib/map.h
13
lib/map.h
@@ -247,19 +247,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_EXPORT CMapInfo : public CMapHeader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ui8 seldiff; //selected difficulty (only in saved games)
|
|
||||||
std::string filename;
|
|
||||||
std::string date;
|
|
||||||
int playerAmnt, humenPlayers;
|
|
||||||
CMapInfo();
|
|
||||||
CMapInfo(const std::string &fname, const unsigned char *map);
|
|
||||||
void init(const std::string &fname, const unsigned char *map);
|
|
||||||
void countPlayers();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DLL_EXPORT Mapa : public CMapHeader
|
struct DLL_EXPORT Mapa : public CMapHeader
|
||||||
{
|
{
|
||||||
ui32 checksum;
|
ui32 checksum;
|
||||||
|
|||||||
Reference in New Issue
Block a user