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; CSemiLodHandler * sspriteh;
CDefObjInfoHandler * dobjinfo; CDefObjInfoHandler * dobjinfo;
CTownHandler * townh; CTownHandler * townh;
CLodHandler * spriteh; //CLodHandler * spriteh;
CLodHandler * bitmaph; //CLodHandler * bitmaph;
CGeneralTextHandler * generaltexth; CGeneralTextHandler * generaltexth;
CConsoleHandler * consoleh; CConsoleHandler * consoleh;
CCursorHandler * curh; CCursorHandler * curh;

View File

@ -127,12 +127,7 @@ int main(int argc, char** argv)
tlog0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl; tlog0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
tlog0<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl; tlog0<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
CDefHandler::Spriteh = cgi->spriteh = new CLodHandler(); initDLL(::console,logfile);
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);
CGI->setFromLib(); CGI->setFromLib();
cgi->audioh->initCreaturesSounds(CGI->creh->creatures); cgi->audioh->initCreaturesSounds(CGI->creh->creatures);
tlog0<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl; 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); musicVolume = new CHighlightableButtonsGroup(0, true);
for(int i=0; i<10; ++i) 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->select(CGI->audioh->getMusicVolume(), 1);
musicVolume->onChange = boost::bind(&CAudioHandler::setMusicVolume, CGI->audioh, _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); effectsVolume = new CHighlightableButtonsGroup(0, true);
for(int i=0; i<10; ++i) 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->select(CGI->audioh->getSoundVolume(), 1);
effectsVolume->onChange = boost::bind(&CAudioHandler::setSoundVolume, CGI->audioh, _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) \ #define GET_DEF(DESTINATION, DEF_NAME) \
(GET_DATA \ (GET_DATA \
(CDefHandler*,DESTINATION,\ (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) \ #define GET_DEF_ESS(DESTINATION, DEF_NAME) \
(GET_DATA \ (GET_DATA \
(CDefEssential*,DESTINATION,\ (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__ #endif // __CTHREADHELPER_H__

View File

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

View File

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

View File

@ -1,5 +1,6 @@
#include "CCreatureAnimation.h" #include "CCreatureAnimation.h"
#include "../hch/CLodHandler.h" #include "../hch/CLodHandler.h"
#include "../lib/VCMI_Lib.h"
/* /*
* CCreatureAnimation.cpp, part of VCMI engine * 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) 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 //init anim data
int i,j, totalInBlock; int i,j, totalInBlock;

View File

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

View File

@ -97,4 +97,4 @@ GUISettings
ButtonEndTurn: x=903 y=524 graphic=IAM001.DEF playerColoured=1; ButtonEndTurn: x=903 y=524 graphic=IAM001.DEF playerColoured=1;
}; };
} }
} }

View File

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

View File

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

View File

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

View File

@ -63,11 +63,11 @@ public:
}; };
extern DLL_EXPORT LibClasses * VLC; 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(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 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__ #endif // __VCMI_LIB_H__

View File

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