mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merge pull request #3991 from Laserlicht/preselect_last_save_while_loading
[1.5.2] preselect last save in loading screen
This commit is contained in:
commit
9ed749e104
@ -677,6 +677,9 @@ void SelectionTab::selectFileName(std::string fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filter(-1);
|
||||||
|
selectAbs(-1);
|
||||||
|
|
||||||
for(int i = (int)curItems.size() - 1; i >= 0; i--)
|
for(int i = (int)curItems.size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if(curItems[i]->fileURI == fname)
|
if(curItems[i]->fileURI == fname)
|
||||||
@ -687,13 +690,23 @@ void SelectionTab::selectFileName(std::string fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filter(-1);
|
|
||||||
selectAbs(-1);
|
|
||||||
|
|
||||||
if(tabType == ESelectionScreen::saveGame && inputName->getText().empty())
|
if(tabType == ESelectionScreen::saveGame && inputName->getText().empty())
|
||||||
inputName->setText("NEWGAME");
|
inputName->setText("NEWGAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectionTab::selectNewestFile()
|
||||||
|
{
|
||||||
|
time_t newestTime = 0;
|
||||||
|
std::string newestFile = "";
|
||||||
|
for(int i = (int)allItems.size() - 1; i >= 0; i--)
|
||||||
|
if(allItems[i]->lastWrite > newestTime)
|
||||||
|
{
|
||||||
|
newestTime = allItems[i]->lastWrite;
|
||||||
|
newestFile = allItems[i]->fileURI;
|
||||||
|
}
|
||||||
|
selectFileName(newestFile);
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<ElementInfo> SelectionTab::getSelectedMapInfo() const
|
std::shared_ptr<ElementInfo> SelectionTab::getSelectedMapInfo() const
|
||||||
{
|
{
|
||||||
return curItems.empty() || curItems[selectionPos]->isFolder ? nullptr : curItems[selectionPos];
|
return curItems.empty() || curItems[selectionPos]->isFolder ? nullptr : curItems[selectionPos];
|
||||||
@ -733,6 +746,8 @@ void SelectionTab::restoreLastSelection()
|
|||||||
selectFileName(settings["general"]["lastCampaign"].String());
|
selectFileName(settings["general"]["lastCampaign"].String());
|
||||||
break;
|
break;
|
||||||
case ESelectionScreen::loadGame:
|
case ESelectionScreen::loadGame:
|
||||||
|
selectNewestFile();
|
||||||
|
break;
|
||||||
case ESelectionScreen::saveGame:
|
case ESelectionScreen::saveGame:
|
||||||
selectFileName(settings["general"]["lastSave"].String());
|
selectFileName(settings["general"]["lastSave"].String());
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ public:
|
|||||||
int getLine() const;
|
int getLine() const;
|
||||||
int getLine(const Point & position) const;
|
int getLine(const Point & position) const;
|
||||||
void selectFileName(std::string fname);
|
void selectFileName(std::string fname);
|
||||||
|
void selectNewestFile();
|
||||||
std::shared_ptr<ElementInfo> getSelectedMapInfo() const;
|
std::shared_ptr<ElementInfo> getSelectedMapInfo() const;
|
||||||
void rememberCurrentSelection();
|
void rememberCurrentSelection();
|
||||||
void restoreLastSelection();
|
void restoreLastSelection();
|
||||||
|
Loading…
Reference in New Issue
Block a user