1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

AB campaign selection screen added

This commit is contained in:
beegee1
2011-03-19 14:27:51 +00:00
parent 95efcc7cb5
commit fb929fa9b0
8 changed files with 103 additions and 20 deletions

View File

@@ -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 "<<fname<<" was not found"<<std::endl;

View File

@@ -249,7 +249,7 @@ CMenuScreen::CMenuScreen( EState which )
{
buttons[0] = new AdventureMapButton("", "", bind(&CGPreGame::openCampaignScreen, CGP, CCampaignScreen::WOG), 535, 8, "ZSSSOD.DEF", SDLK_s); // WOG
buttons[1] = new AdventureMapButton("", "", bind(&CGPreGame::openCampaignScreen, CGP, CCampaignScreen::ROE) , 494, 117, "ZSSROE.DEF", SDLK_m); // ROE
buttons[2] = new AdventureMapButton("", "", 0, 486, 241, "ZSSARM.DEF", SDLK_c); // AB TODO
buttons[2] = new AdventureMapButton("", "", bind(&CGPreGame::openCampaignScreen, CGP, CCampaignScreen::AB), 486, 241, "ZSSARM.DEF", SDLK_c); // AB
buttons[3] = new AdventureMapButton("", "", bind(&CGPreGame::openSel, CGP, campaignList, SINGLE_PLAYER), 550, 358, "ZSSCUS.DEF", SDLK_t); // Custom
buttons[4] = new AdventureMapButton("", "", bind(&CMenuScreen::moveTo, this, CGP->scrs[newGame]), 582, 464, "ZSSEXIT.DEF", SDLK_ESCAPE); // Back
@@ -3342,7 +3342,7 @@ CCampaignScreen::CCampaignScreen(CampaignSet campaigns, std::map<std::string, Ca
{
OBJ_CONSTRUCTION; // sets this as parent
std::string bgImage;
if (campaigns == ROE)
if (campaigns == ROE || campaigns == AB)
bgImage = "CAMPBACK.BMP";
else if (campaigns == SOD)
bgImage = "CAMPBKX2.BMP";
@@ -3426,7 +3426,62 @@ CCampaignScreen::CCampaignScreen(CampaignSet campaigns, std::map<std::string, Ca
else
drawCampaignPlaceholder();
}
if (campaigns == AB)
{
// Armageddon's Blade
static const std::string ab0Camp = "AB";
CCampaignButton *ab0 = new CCampaignButton(bg, "CAMP1AB7.BMP", buttonCords[0][0], buttonCords[0][1], camps[ab0Camp] != 0 ? camps[ab0Camp] : CCampaignScreen::ENABLED);
ab0->hoverText = "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) );
}
}
}

View File

@@ -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<std::string, CampaignStatus>& camps);
~CCampaignScreen();

View File

@@ -5,6 +5,7 @@
#include <SDL.h>
#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;

View File

@@ -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

View File

@@ -60,7 +60,6 @@ std::vector<CCampaignHeader> 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);

View File

@@ -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: "<<pomtime.getDif()<<std::endl;
//init pointers to handlers

View File

@@ -56,7 +56,7 @@ public:
};
extern DLL_EXPORT LibClasses * VLC;
extern DLL_EXPORT CLodHandler * bitmaph, *spriteh;
extern DLL_EXPORT CLodHandler * bitmaph, *spriteh, *bitmaph_ab;
DLL_EXPORT void loadToIt(std::string &dest, const std::string &src, int &iter, int mode);
DLL_EXPORT void loadToIt(si32 &dest, const std::string &src, int &iter, int mode);