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;
|
||||
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);
|
||||
if(!e)
|
||||
{
|
||||
|
@@ -149,11 +149,10 @@ public:
|
||||
void recreateBuildings();
|
||||
void recreateIcons();
|
||||
};
|
||||
class CHallInterface : public IShowActivable
|
||||
class CHallInterface : public CIntObject
|
||||
{
|
||||
public:
|
||||
CMinorResDataBar * resdatabar;
|
||||
SDL_Rect pos;
|
||||
|
||||
class CBuildingBox : public CIntObject
|
||||
{
|
||||
|
@@ -61,7 +61,7 @@ CHeroSwitcher::CHeroSwitcher()
|
||||
CHeroWindow::CHeroWindow(int playerColor):
|
||||
player(playerColor)
|
||||
{
|
||||
background = BitmapHandler::loadBitmap("HEROSCR4.bmp");
|
||||
background = BitmapHandler::loadBitmap("HeroScr4");
|
||||
graphics->blueToPlayersAdv(background, playerColor);
|
||||
pos.x = screen->w/2 - background->w/2 - 65;
|
||||
pos.y = screen->h/2 - background->h/2 - 8;
|
||||
|
@@ -1443,9 +1443,9 @@ void CTownList::select(int which)
|
||||
if (which>=LOCPLINT->towns.size())
|
||||
return;
|
||||
selected = which;
|
||||
fixPos();
|
||||
if(!fun.empty())
|
||||
fun();
|
||||
fixPos();
|
||||
}
|
||||
|
||||
void CTownList::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
|
@@ -5,6 +5,6 @@ TBINBACK.bmp TPMAGEIN.bmp HALLINFR.DEF
|
||||
TBNCBACK.bmp TPMAGENC.bmp HALLNECR.DEF
|
||||
TBDNBACK.bmp TPMAGEDN.bmp HALLDUNG.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
|
||||
|
||||
|
@@ -39,7 +39,7 @@ CGDefInfo::CGDefInfo()
|
||||
void CGDefInfo::fetchInfoFromMSK()
|
||||
{
|
||||
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];
|
||||
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)
|
||||
{
|
||||
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));
|
||||
if(!ourEntry) //nothing's been found
|
||||
{
|
||||
@@ -224,8 +228,16 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
|
||||
Entry entry;
|
||||
|
||||
entry.nameStr = lodEntries[i].filename;
|
||||
//format string: upper-case, remove extension
|
||||
std::transform(entry.nameStr.begin(), entry.nameStr.end(),
|
||||
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.realSize = SDL_SwapLE32(lodEntries[i].uncompressedSize);
|
||||
@@ -246,7 +258,11 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
|
||||
std::string name = dir->path().leaf();
|
||||
std::string realname = name;
|
||||
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);
|
||||
if(e) //file present in .lod - overwrite its entry
|
||||
{
|
||||
|
Reference in New Issue
Block a user