mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
- LodHandler now will ignore file extensions.
Special case: MSK\MSG files (they have same names as def) can be accessed as file#msk or file#msg - some fixes
This commit is contained in:
@@ -157,7 +157,10 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
|
|||||||
}
|
}
|
||||||
unsigned char * pcx;
|
unsigned char * pcx;
|
||||||
std::transform(fname.begin(),fname.end(),fname.begin(),toupper);
|
std::transform(fname.begin(),fname.end(),fname.begin(),toupper);
|
||||||
fname.replace(fname.find_last_of('.'), fname.find_last_of('.')+4, ".PCX");
|
int dotPos = fname.find_last_of('.');
|
||||||
|
if ( dotPos != -1 )
|
||||||
|
fname.erase(dotPos);
|
||||||
|
|
||||||
Entry *e = bitmaph->entries.znajdz(fname);
|
Entry *e = bitmaph->entries.znajdz(fname);
|
||||||
if(!e)
|
if(!e)
|
||||||
{
|
{
|
||||||
|
@@ -149,11 +149,10 @@ public:
|
|||||||
void recreateBuildings();
|
void recreateBuildings();
|
||||||
void recreateIcons();
|
void recreateIcons();
|
||||||
};
|
};
|
||||||
class CHallInterface : public IShowActivable
|
class CHallInterface : public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMinorResDataBar * resdatabar;
|
CMinorResDataBar * resdatabar;
|
||||||
SDL_Rect pos;
|
|
||||||
|
|
||||||
class CBuildingBox : public CIntObject
|
class CBuildingBox : public CIntObject
|
||||||
{
|
{
|
||||||
|
@@ -61,7 +61,7 @@ CHeroSwitcher::CHeroSwitcher()
|
|||||||
CHeroWindow::CHeroWindow(int playerColor):
|
CHeroWindow::CHeroWindow(int playerColor):
|
||||||
player(playerColor)
|
player(playerColor)
|
||||||
{
|
{
|
||||||
background = BitmapHandler::loadBitmap("HEROSCR4.bmp");
|
background = BitmapHandler::loadBitmap("HeroScr4");
|
||||||
graphics->blueToPlayersAdv(background, playerColor);
|
graphics->blueToPlayersAdv(background, playerColor);
|
||||||
pos.x = screen->w/2 - background->w/2 - 65;
|
pos.x = screen->w/2 - background->w/2 - 65;
|
||||||
pos.y = screen->h/2 - background->h/2 - 8;
|
pos.y = screen->h/2 - background->h/2 - 8;
|
||||||
|
@@ -1443,9 +1443,9 @@ void CTownList::select(int which)
|
|||||||
if (which>=LOCPLINT->towns.size())
|
if (which>=LOCPLINT->towns.size())
|
||||||
return;
|
return;
|
||||||
selected = which;
|
selected = which;
|
||||||
|
fixPos();
|
||||||
if(!fun.empty())
|
if(!fun.empty())
|
||||||
fun();
|
fun();
|
||||||
fixPos();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTownList::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
void CTownList::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||||
|
@@ -5,6 +5,6 @@ TBINBACK.bmp TPMAGEIN.bmp HALLINFR.DEF
|
|||||||
TBNCBACK.bmp TPMAGENC.bmp HALLNECR.DEF
|
TBNCBACK.bmp TPMAGENC.bmp HALLNECR.DEF
|
||||||
TBDNBACK.bmp TPMAGEDN.bmp HALLDUNG.DEF
|
TBDNBACK.bmp TPMAGEDN.bmp HALLDUNG.DEF
|
||||||
TBSTBACK.bmp TPMAGEST.bmp HALLSTRN.DEF
|
TBSTBACK.bmp TPMAGEST.bmp HALLSTRN.DEF
|
||||||
TPMAGEFR.bmp TBFRBACK.bmp HALLFORT.DEF
|
TBFRBACK.bmp TPMAGEFR.bmp HALLFORT.DEF
|
||||||
TBELBACK.bmp TPMAGEEL.bmp HALLELEM.DEF
|
TBELBACK.bmp TPMAGEEL.bmp HALLELEM.DEF
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ CGDefInfo::CGDefInfo()
|
|||||||
void CGDefInfo::fetchInfoFromMSK()
|
void CGDefInfo::fetchInfoFromMSK()
|
||||||
{
|
{
|
||||||
std::string nameCopy = name;
|
std::string nameCopy = name;
|
||||||
std::string msk = spriteh->getTextFile(nameCopy.replace( nameCopy.size()-4, 4, ".MSK" ));
|
std::string msk = spriteh->getTextFile(nameCopy.replace( nameCopy.size()-4, 4, "#MSK" ));
|
||||||
|
|
||||||
width = msk[0];
|
width = msk[0];
|
||||||
height = msk[1];
|
height = msk[1];
|
||||||
|
@@ -63,6 +63,10 @@ std::string readString(const unsigned char * bufor, int &i)
|
|||||||
unsigned char * CLodHandler::giveFile(std::string defName, int * length)
|
unsigned char * CLodHandler::giveFile(std::string defName, int * length)
|
||||||
{
|
{
|
||||||
std::transform(defName.begin(), defName.end(), defName.begin(), (int(*)(int))toupper);
|
std::transform(defName.begin(), defName.end(), defName.begin(), (int(*)(int))toupper);
|
||||||
|
int dotPos = defName.find_last_of('.');
|
||||||
|
if ( dotPos != -1 )
|
||||||
|
defName.erase(dotPos);
|
||||||
|
|
||||||
Entry * ourEntry = entries.znajdz(Entry(defName));
|
Entry * ourEntry = entries.znajdz(Entry(defName));
|
||||||
if(!ourEntry) //nothing's been found
|
if(!ourEntry) //nothing's been found
|
||||||
{
|
{
|
||||||
@@ -224,9 +228,17 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
|
|||||||
Entry entry;
|
Entry entry;
|
||||||
|
|
||||||
entry.nameStr = lodEntries[i].filename;
|
entry.nameStr = lodEntries[i].filename;
|
||||||
|
//format string: upper-case, remove extension
|
||||||
std::transform(entry.nameStr.begin(), entry.nameStr.end(),
|
std::transform(entry.nameStr.begin(), entry.nameStr.end(),
|
||||||
entry.nameStr.begin(), toupper);
|
entry.nameStr.begin(), toupper);
|
||||||
|
|
||||||
|
int dotPos = entry.nameStr.find_last_of('.');
|
||||||
|
std::string ext = entry.nameStr.substr(dotPos);
|
||||||
|
if (ext == ".MSK" || ext == ".MSG")
|
||||||
|
entry.nameStr[dotPos] = '#';//this files have same name as def - rename to defName#msk
|
||||||
|
else
|
||||||
|
entry.nameStr.erase(dotPos);//filename.ext becomes filename
|
||||||
|
|
||||||
entry.offset= SDL_SwapLE32(lodEntries[i].offset);
|
entry.offset= SDL_SwapLE32(lodEntries[i].offset);
|
||||||
entry.realSize = SDL_SwapLE32(lodEntries[i].uncompressedSize);
|
entry.realSize = SDL_SwapLE32(lodEntries[i].uncompressedSize);
|
||||||
entry.size = SDL_SwapLE32(lodEntries[i].size);
|
entry.size = SDL_SwapLE32(lodEntries[i].size);
|
||||||
@@ -246,7 +258,11 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
|
|||||||
std::string name = dir->path().leaf();
|
std::string name = dir->path().leaf();
|
||||||
std::string realname = name;
|
std::string realname = name;
|
||||||
std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper);
|
std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper);
|
||||||
boost::algorithm::replace_all(name,".BMP",".PCX");
|
|
||||||
|
int dotPos = name.find_last_of('.');
|
||||||
|
if ( dotPos != -1 )//extension found
|
||||||
|
name.erase(dotPos);
|
||||||
|
|
||||||
Entry * e = entries.znajdz(name);
|
Entry * e = entries.znajdz(name);
|
||||||
if(e) //file present in .lod - overwrite its entry
|
if(e) //file present in .lod - overwrite its entry
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user