1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Work with full file paths instead of partial ones.

This commit is contained in:
Frank Zago 2009-10-10 01:42:33 +00:00
parent 1392df17dc
commit 668b203486
5 changed files with 11 additions and 19 deletions

View File

@ -428,7 +428,7 @@ void SelectionTab::getFiles(std::vector<FileInfo> &out, const std::string &dirna
{
out.resize(out.size()+1);
out.back().date = fs::last_write_time(file->path());
out.back().name = dirname+"/"+(file->path().leaf());
out.back().name = file->path().string();
}
}
@ -549,7 +549,7 @@ SelectionTab::SelectionTab(EState Type, const boost::function<void(CMapInfo *)>
switch(type)
{
case newGame:
selectFName(DATA_DIR "Maps/Arrogance.h3m");
selectFName(DATA_DIR "/Maps/Arrogance.h3m");
break;
case loadGame:
select(0);
@ -615,9 +615,6 @@ void SelectionTab::select( int position )
else if(position >= positions)
slider->moveTo(slider->value + position - positions + 1);
if(txt)
txt->setText(curItems[py]->filename.substr(6,curItems[py]->filename.size()-12));
onSelect(curItems[py]);
}
@ -708,17 +705,12 @@ void SelectionTab::printMaps(SDL_Surface *to)
}
blitAt(format->ourImages[temp].bitmap, POS(88, 117), to);
if (type == newGame)
{
if (!(curMap->name.length()))
if (type == newGame) {
if (!curMap->name.length())
curMap->name = "Unnamed";
CSDL_Ext::printAtMiddle(curMap->name, POS(213, 128), FONT_SMALL, nasz, to);
}
else
{
std::string &name = curMap->filename;
CSDL_Ext::printAtMiddle(name.substr(6,name.size()-12), POS(213, 128), FONT_SMALL, nasz, to);
}
} else
CSDL_Ext::printAtMiddle(fs::basename(curMap->filename), POS(213, 128), FONT_SMALL, nasz, to);
if (curMap->victoryCondition.condition == winStandard)
temp = 11;

View File

@ -60,7 +60,7 @@ public:
struct FileInfo
{
std::string name;
std::string name; // file name with full path and extension
std::time_t date;
};

View File

@ -541,7 +541,7 @@ void YourTurn::applyCl( CClient *cl )
void SaveGame::applyCl(CClient *cl)
{
CSaveFile save("Games/" + fname + ".vcgm1");
CSaveFile save(DATA_DIR "/Games/" + fname + ".vcgm1");
save << *cl;
}

View File

@ -204,7 +204,7 @@ void CConnection::setGS( CGameState *state )
}
CSaveFile::CSaveFile( const std::string &fname )
:sfile(new std::ofstream((USER_DIR "/" + fname).c_str(),std::ios::binary))
:sfile(new std::ofstream(fname.c_str(),std::ios::binary))
{
registerTypes(*this);
if(!(*sfile))

View File

@ -1848,14 +1848,14 @@ void CGameHandler::save( const std::string &fname )
{
tlog0 << "Serializing game info...\n";
CSaveFile save(std::string("Games/") + fname + ".vlgm1");
CSaveFile save(std::string(DATA_DIR "/Games/") + fname + ".vlgm1");
char hlp[8] = "VCMISVG";
save << hlp << static_cast<CMapHeader&>(*gs->map) << gs->scenarioOps->difficulty << *VLC << gs;
}
{
tlog0 << "Serializing server info...\n";
CSaveFile save(std::string("Games/") + fname + ".vsgm1");
CSaveFile save(std::string(DATA_DIR "/Games/") + fname + ".vsgm1");
save << *this;
}
tlog0 << "Game has been succesfully saved!\n";