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

* Removed trailing newline from settings.txt (caused warning)

* Sprite/Bitmap handlers moved to VCMI_Lib
* Moved volume sliders 1px down for better look
This commit is contained in:
Michał W. Urbańczyk 2009-05-09 16:18:27 +00:00
parent ae2909667d
commit 90fd75e66c
14 changed files with 36 additions and 32 deletions

View File

@ -59,8 +59,8 @@ public:
CSemiLodHandler * sspriteh;
CDefObjInfoHandler * dobjinfo;
CTownHandler * townh;
CLodHandler * spriteh;
CLodHandler * bitmaph;
//CLodHandler * spriteh;
//CLodHandler * bitmaph;
CGeneralTextHandler * generaltexth;
CConsoleHandler * consoleh;
CCursorHandler * curh;

View File

@ -127,12 +127,7 @@ int main(int argc, char** argv)
tlog0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
tlog0<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
CDefHandler::Spriteh = cgi->spriteh = new CLodHandler();
cgi->spriteh->init("Data" PATHSEPARATOR "H3sprite.lod","Sprites");
BitmapHandler::bitmaph = cgi->bitmaph = new CLodHandler;
cgi->bitmaph->init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
tlog0<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
initDLL(cgi->bitmaph,::console,logfile);
initDLL(::console,logfile);
CGI->setFromLib();
cgi->audioh->initCreaturesSounds(CGI->creh->creatures);
tlog0<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;

View File

@ -4454,7 +4454,7 @@ CSystemOptionsWindow::CSystemOptionsWindow(const SDL_Rect &pos, CPlayerInterface
musicVolume = new CHighlightableButtonsGroup(0, true);
for(int i=0; i<10; ++i)
{
musicVolume->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[326+i].first),CGI->generaltexth->zelp[326+i].second, "syslb.def", 188 + 19*i, 415, i*11);
musicVolume->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[326+i].first),CGI->generaltexth->zelp[326+i].second, "syslb.def", 188 + 19*i, 416, i*11);
}
musicVolume->select(CGI->audioh->getMusicVolume(), 1);
musicVolume->onChange = boost::bind(&CAudioHandler::setMusicVolume, CGI->audioh, _1);
@ -4462,7 +4462,7 @@ CSystemOptionsWindow::CSystemOptionsWindow(const SDL_Rect &pos, CPlayerInterface
effectsVolume = new CHighlightableButtonsGroup(0, true);
for(int i=0; i<10; ++i)
{
effectsVolume->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[336+i].first),CGI->generaltexth->zelp[336+i].second, "syslb.def", 188 + 19*i, 481, i*11);
effectsVolume->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[336+i].first),CGI->generaltexth->zelp[336+i].second, "syslb.def", 188 + 19*i, 482, i*11);
}
effectsVolume->select(CGI->audioh->getSoundVolume(), 1);
effectsVolume->onChange = boost::bind(&CAudioHandler::setSoundVolume, CGI->audioh, _1);

View File

@ -46,10 +46,10 @@ template <typename T> inline void setData(T * data, boost::function<T()> func)
#define GET_DEF(DESTINATION, DEF_NAME) \
(GET_DATA \
(CDefHandler*,DESTINATION,\
boost::function<CDefHandler*()>(boost::bind(CDefHandler::giveDef,DEF_NAME,(CLodHandler*)NULL))))
boost::function<CDefHandler*()>(boost::bind(CDefHandler::giveDef,DEF_NAME))))
#define GET_DEF_ESS(DESTINATION, DEF_NAME) \
(GET_DATA \
(CDefEssential*,DESTINATION,\
boost::function<CDefEssential*()>(boost::bind(CDefHandler::giveDefEss,DEF_NAME,(CLodHandler*)NULL))))
boost::function<CDefEssential*()>(boost::bind(CDefHandler::giveDefEss,DEF_NAME))))
#endif // __CTHREADHELPER_H__

View File

@ -19,7 +19,9 @@
boost::mutex bitmap_handler_mx;
int readNormalNr (int pos, int bytCon, unsigned char * str);
CLodHandler * BitmapHandler::bitmaph = NULL;
extern DLL_EXPORT CLodHandler *bitmaph;
void BMPHeader::print(std::ostream & out)
{
CDefHandler::print(out,fullSize,4);

View File

@ -47,7 +47,6 @@ public:
};
namespace BitmapHandler
{
extern CLodHandler *bitmaph;
SDL_Surface * loadBitmap(std::string fname, bool setKey=false);
};

View File

@ -1,5 +1,6 @@
#include "CCreatureAnimation.h"
#include "../hch/CLodHandler.h"
#include "../lib/VCMI_Lib.h"
/*
* CCreatureAnimation.cpp, part of VCMI engine
@ -35,7 +36,7 @@ void CCreatureAnimation::setType(int type)
CCreatureAnimation::CCreatureAnimation(std::string name) : RLEntries(NULL), internalFrame(0), once(false)
{
FDef = CDefHandler::Spriteh->giveFile(name); //load main file
FDef = spriteh->giveFile(name); //load main file
//init anim data
int i,j, totalInBlock;

View File

@ -13,6 +13,7 @@
#include "../CThreadHelper.h"
#include "../CGameInfo.h"
#include "../hch/CLodHandler.h"
#include "../lib/VCMI_Lib.h"
using namespace boost::assign;
using namespace CSDL_Ext;
#ifdef min
@ -102,7 +103,7 @@ SDL_Surface * Graphics::drawTownInfoWin(const CGTownInstance * curh)
void Graphics::loadPaletteAndColors()
{
std::string pals = CGI->bitmaph->getTextFile("PLAYERS.PAL");
std::string pals = bitmaph->getTextFile("PLAYERS.PAL");
playerColorPalette = new SDL_Color[256];
neutralColor = new SDL_Color;
playerColors = new SDL_Color[PLAYER_LIMIT];

View File

@ -3,6 +3,7 @@
#include "CDefHandler.h"
#include <sstream>
#include "CLodHandler.h"
#include "../lib/VCMI_Lib.h"
/*
* CDefHandler.cpp, part of VCMI engine
@ -14,8 +15,6 @@
*
*/
CLodHandler* CDefHandler::Spriteh = NULL;
long long pow(long long a, int b)
{
if (!b) return 1;
@ -564,9 +563,8 @@ CDefEssential * CDefHandler::essentialize()
return ret;
}
CDefHandler * CDefHandler::giveDef(std::string defName, CLodHandler * spriteh)
CDefHandler * CDefHandler::giveDef(std::string defName)
{
if(!spriteh) spriteh=Spriteh;
unsigned char * data = spriteh->giveFile(defName);
if(!data)
throw "bad def name!";
@ -576,10 +574,10 @@ CDefHandler * CDefHandler::giveDef(std::string defName, CLodHandler * spriteh)
delete [] data;
return nh;
}
CDefEssential * CDefHandler::giveDefEss(std::string defName, CLodHandler * spriteh)
CDefEssential * CDefHandler::giveDefEss(std::string defName)
{
CDefEssential * ret;
CDefHandler * temp = giveDef(defName,spriteh);
CDefHandler * temp = giveDef(defName);
ret = temp->essentialize();
delete temp;
return ret;

View File

@ -39,7 +39,6 @@ private:
public:
int width, height; //width and height
static CLodHandler * Spriteh;
std::string defName, curDir;
std::vector<Cimage> ourImages;
bool alphaTransformed;
@ -56,8 +55,8 @@ public:
void openFromMemory(unsigned char * table, std::string name);
CDefEssential * essentialize();
static CDefHandler * giveDef(std::string defName, CLodHandler * spriteh=NULL);
static CDefEssential * giveDefEss(std::string defName, CLodHandler * spriteh=NULL);
static CDefHandler * giveDef(std::string defName);
static CDefEssential * giveDefEss(std::string defName);
};
class CDefEssential //DefHandler with images only

View File

@ -5,6 +5,7 @@
#include "../hch/CCreatureHandler.h"
#include "../hch/CDefObjInfoHandler.h"
#include "../hch/CHeroHandler.h"
#include "../hch/CLodHandler.h"
#include "../hch/CObjectHandler.h"
#include "../hch/CTownHandler.h"
#include "../hch/CBuildingHandler.h"
@ -23,21 +24,23 @@
class CLodHandler;
LibClasses * VLC = NULL;
CLodHandler * bitmaph=NULL;
DLL_EXPORT CLodHandler *bitmaph = NULL,
*spriteh = NULL;
DLL_EXPORT CLogger<0> tlog0;
DLL_EXPORT CLogger<1> tlog1;
DLL_EXPORT CLogger<2> tlog2;
DLL_EXPORT CLogger<3> tlog3;
DLL_EXPORT CLogger<4> tlog4;
DLL_EXPORT CLogger<5> tlog5;
DLL_EXPORT CConsoleHandler *console = NULL;
DLL_EXPORT std::ostream *logfile = NULL
;
DLL_EXPORT void initDLL(CLodHandler *b, CConsoleHandler *Console, std::ostream *Logfile)
DLL_EXPORT void initDLL(CConsoleHandler *Console, std::ostream *Logfile)
{
console = Console;
logfile = Logfile;
bitmaph=b;
VLC = new LibClasses;
VLC->init();
}
@ -160,6 +163,12 @@ DLL_EXPORT void loadToIt(si32 &dest, std::string &src, int &iter, int mode)
void LibClasses::init()
{
timeHandler pomtime;
spriteh = new CLodHandler();
spriteh->init("Data" PATHSEPARATOR "H3sprite.lod","Sprites");
bitmaph = new CLodHandler;
bitmaph->init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
tlog0<<"Loading .lod files: "<<pomtime.getDif()<<std::endl;
generaltexth = new CGeneralTextHandler;
generaltexth->load();
tlog0<<"\tGeneral text handler: "<<pomtime.getDif()<<std::endl;

View File

@ -63,11 +63,11 @@ public:
};
extern DLL_EXPORT LibClasses * VLC;
extern CLodHandler * bitmaph;
extern DLL_EXPORT CLodHandler * bitmaph, *spriteh;
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode);
DLL_EXPORT void loadToIt(si32 &dest, std::string &src, int &iter, int mode);
DLL_EXPORT void initDLL(CLodHandler *b, CConsoleHandler *Console, std::ostream *Logfile);
DLL_EXPORT void initDLL(CConsoleHandler *Console, std::ostream *Logfile);
#endif // __VCMI_LIB_H__

View File

@ -246,7 +246,7 @@ int main(int argc, char** argv)
tlog0 << "Port " << port << " will be used." << std::endl;
CLodHandler h3bmp;
h3bmp.init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
initDLL(&h3bmp,console,logfile);
initDLL(console,logfile);
srand ( (unsigned int)time(NULL) );
try
{