diff --git a/client/CBitmapHandler.cpp b/client/CBitmapHandler.cpp index b80aaee64..edd18931a 100644 --- a/client/CBitmapHandler.cpp +++ b/client/CBitmapHandler.cpp @@ -20,6 +20,7 @@ boost::mutex bitmap_handler_mx; extern DLL_EXPORT CLodHandler *bitmaph; +extern DLL_EXPORT CLodHandler *bitmaph_ab; void CPCXConv::openPCX(char * PCX, int len) { @@ -157,8 +158,12 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey) } SDL_Surface * ret=NULL; int size; - unsigned char * file = bitmaph->giveFile(fname, FILE_GRAPHICS, &size); - + unsigned char * file = 0; + if (bitmaph->haveFile(fname, FILE_GRAPHICS)) + file = bitmaph->giveFile(fname, FILE_GRAPHICS, &size); + else if (bitmaph_ab->haveFile(fname, FILE_GRAPHICS)) + file = bitmaph_ab->giveFile(fname, FILE_GRAPHICS, &size); + if (!file) { tlog2<<"Entry for file "<scrs[newGame]), 582, 464, "ZSSEXIT.DEF", SDLK_ESCAPE); // Back @@ -3342,7 +3342,7 @@ CCampaignScreen::CCampaignScreen(CampaignSet campaigns, std::maphoverText = "Armageddon's Blade"; + ab0->campFile = ab0Camp; + ab0->video = "C1ab7.BIK"; + campButtons.push_back(ab0); + // Dragon's Blood + static const std::string ab1Camp = "BLOOD"; + CCampaignButton *ab1 = new CCampaignButton(bg, "CAMP1DB2.BMP", buttonCords[1][0], buttonCords[1][1], camps[ab1Camp] != 0 ? camps[ab1Camp] : CCampaignScreen::ENABLED); + ab1->hoverText = "Dragon's Blood"; + ab1->campFile = ab1Camp; + ab1->video = "C1db2.BIK"; + campButtons.push_back(ab1); + + // Dragon Slayer + static const std::string ab2Camp = "SLAYER"; + CCampaignButton *ab2 = new CCampaignButton(bg, "CAMP1DS1.BMP", buttonCords[2][0], buttonCords[2][1], camps[ab2Camp] != 0 ? camps[ab2Camp] : CCampaignScreen::ENABLED); + ab2->hoverText = "Dragon Slayer"; + ab2->campFile = ab2Camp; + ab2->video = "C1ds1.BIK"; + campButtons.push_back(ab2); + + // Festival of Life + static const std::string ab3Camp = "FESTIVAL"; + CCampaignButton *ab3 = new CCampaignButton(bg, "CAMP1FL3.BMP", buttonCords[3][0], buttonCords[3][1], camps[ab3Camp] != 0 ? camps[ab3Camp] : CCampaignScreen::ENABLED); + ab3->hoverText = "Festival of Life"; + ab3->campFile = ab3Camp; + ab3->video = "C1fl3.BIK"; + campButtons.push_back(ab3); + + // Playing With Fire + static const std::string ab4Camp = "FIRE"; + CCampaignButton *ab4 = new CCampaignButton(bg, "CAMP1PF2.BMP", buttonCords[4][0], buttonCords[4][1], camps[ab4Camp] != 0 ? camps[ab4Camp] : CCampaignScreen::ENABLED); + ab4->hoverText = "Playing With Fire"; + ab4->campFile = ab4Camp; + ab4->video = "C1pf2.BIK"; + campButtons.push_back(ab4); + + // Foolhardy Waywardness + SDL_Surface *ab5Dis = BitmapHandler::loadBitmap("CAMP1FWX"); + Rect ab5DisRect(buttonCords[5][0] - 2, buttonCords[5][1] - 2, ab5Dis->w, ab5Dis->h); + blitAt(ab5Dis, ab5DisRect, bg); + + static const std::string ab5Camp = "FOOL"; + CCampaignButton *ab5 = new CCampaignButton(bg, "CAMP1FW1.BMP", buttonCords[5][0], buttonCords[5][1], camps[ab5Camp] != 0 ? camps[ab5Camp] : CCampaignScreen::DISABLED); + ab5->hoverText = "Foolhardy Waywardness"; + ab5->campFile = ab5Camp; + ab5->video = "C1fw1.BIK"; + campButtons.push_back(ab5); + + drawCampaignPlaceholder(); + } if (campaigns == WOG) { // In the Wake of Gods @@ -3495,29 +3550,33 @@ CCampaignScreen::CCampaignButton::CCampaignButton(SDL_Surface *bg, const std::st this->image = image; this->status = status; - // Initialize base CIntObject members - if (status != CCampaignScreen::DISABLED) - used = LCLICK | HOVER; + // Initialize pos and size pos.x = x; pos.y = y; pos.w = 200; pos.h = 116; - // Creates the button image and the hover label + // Creates the button image button = BitmapHandler::loadBitmap(image); - if (status != CCampaignScreen::DISABLED) + if (status != CCampaignScreen::DISABLED && button != 0) + { blitAt(button, pos, bg); + used = LCLICK | HOVER; // set these flags to activate left click and hover event functions + } + // Create the checked image if (status == CCampaignScreen::COMPLETED) checked = BitmapHandler::loadBitmap("CAMPCHK.BMP"); + // Create the button hover effect hoverLabel = new CLabel(pos.w / 2., pos.h + 20, FONT_MEDIUM, CENTER, tytulowy, ""); hoverLabel->ignoreLeadingWhitespace = false; } CCampaignScreen::CCampaignButton::~CCampaignButton() { - SDL_FreeSurface(button); + if (button != 0) + SDL_FreeSurface(button); if (status == CCampaignScreen::COMPLETED) SDL_FreeSurface(checked); @@ -3541,7 +3600,7 @@ void CCampaignScreen::CCampaignButton::show(SDL_Surface *to) { CIntObject::show(to); - if (status == CCampaignScreen::DISABLED || video == "") + if (status == CCampaignScreen::DISABLED || video == "" || button == 0) return; #ifdef _WIN32 @@ -3582,4 +3641,4 @@ void CCampaignScreen::CCampaignButton::clickLeft(tribool down, bool previousStat campState->camp = ourCampaign; GH.pushInt( new CBonusSelection(campState) ); } -} +} \ No newline at end of file diff --git a/client/CPreGame.h b/client/CPreGame.h index c56d229db..831324737 100644 --- a/client/CPreGame.h +++ b/client/CPreGame.h @@ -456,7 +456,7 @@ class CCampaignScreen : public CIntObject void drawCampaignPlaceholder(); // draws the no campaign placeholder at the lower right position public: - enum CampaignSet {ROE, SOD, WOG}; + enum CampaignSet {ROE, AB, SOD, WOG}; CCampaignScreen(CampaignSet campaigns, std::map& camps); ~CCampaignScreen(); diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp index 304998841..5e6893fd3 100644 --- a/client/CVideoHandler.cpp +++ b/client/CVideoHandler.cpp @@ -5,6 +5,7 @@ #include #include "../client/SDL_Extensions.h" #include "../client/CPlayerInterface.h" +#include "boost\filesystem.hpp" extern SystemOptions GDefaultOptions; //reads events and returns true on key down @@ -401,12 +402,14 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update ) CVideoPlayer::CVideoPlayer() { vidh = new CVidHandler(std::string(DATA_DIR "/Data/VIDEO.VID")); + vidh_ab = new CVidHandler(std::string(DATA_DIR "/Data/H3ab_ahd.vid")); current = NULL; } CVideoPlayer::~CVideoPlayer() { delete vidh; + delete vidh_ab; } bool CVideoPlayer::open(std::string name) @@ -420,9 +423,17 @@ bool CVideoPlayer::open(std::string name) first = true; //extract video from video.vid so we can play it + bool opened = false; vidh->extract(name, name); - bool opened = current->open(name); - if(!opened) + if (boost::filesystem::exists(name)) + opened = current->open(name); + else // couldn't load video then load from ab resource file + { + vidh_ab->extract(name, name); + if (boost::filesystem::exists(name)) + opened = current->open(name); + } + if(!opened) // check if video could be loaded { current = NULL; tlog3 << "Failed to open video file " << name << std::endl; diff --git a/client/CVideoHandler.h b/client/CVideoHandler.h index d8a2692eb..5aa5f568f 100644 --- a/client/CVideoHandler.h +++ b/client/CVideoHandler.h @@ -162,6 +162,7 @@ class CVideoPlayer : public IVideoPlayer { private: CVidHandler * vidh; //.vid file handling + CVidHandler *vidh_ab; // armageddon's blade video file handling CSmackPlayer smkPlayer; //for .SMK CBIKHandler bikPlayer; //for .BIK diff --git a/lib/CCampaignHandler.cpp b/lib/CCampaignHandler.cpp index a5c56f678..7a430a54b 100644 --- a/lib/CCampaignHandler.cpp +++ b/lib/CCampaignHandler.cpp @@ -60,7 +60,6 @@ std::vector CCampaignHandler::getCampaignHeaders(GetMode mode) ret.push_back( getHeader(e.name, true) ); } } - } @@ -417,10 +416,15 @@ bool CCampaignHandler::startsAt( const unsigned char * buffer, int size, int pos unsigned char * CCampaignHandler::getFile( const std::string & name, bool fromLod, int & outSize ) { - unsigned char * cmpgn; + unsigned char * cmpgn = 0; if(fromLod) { - cmpgn = bitmaph->giveFile(name, FILE_CAMPAIGN, &outSize); + if (bitmaph->haveFile(name, FILE_CAMPAIGN)) + cmpgn = bitmaph->giveFile(name, FILE_CAMPAIGN, &outSize); + else if (bitmaph_ab->haveFile(name, FILE_CAMPAIGN)) + cmpgn = bitmaph_ab->giveFile(name, FILE_CAMPAIGN, &outSize); + else + tlog1 << "Cannot find file: " << name << std::endl; FILE * tmp = fopen("tmp_cmpgn", "wb"); fwrite(cmpgn, 1, outSize, tmp); fclose(tmp); diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index 999592b42..28291bc9c 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -25,7 +25,8 @@ class CLodHandler; LibClasses * VLC = NULL; DLL_EXPORT CLodHandler *bitmaph = NULL, - *spriteh = NULL; + *spriteh = NULL, + *bitmaph_ab = NULL; DLL_EXPORT CLogger tlog0(0); @@ -245,6 +246,8 @@ LibClasses::LibClasses() spriteh->init(DATA_DIR "/Data/H3sprite.lod", DATA_DIR "/Sprites"); bitmaph = new CLodHandler; bitmaph->init(DATA_DIR "/Data/H3bitmap.lod", DATA_DIR "/Data"); + bitmaph_ab = new CLodHandler(); + bitmaph_ab->init(DATA_DIR "/Data/H3ab_bmp.lod", DATA_DIR "/Data"); tlog0<<"Loading .lod files: "<