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

change autosave folder name; align autosave folder

This commit is contained in:
Laserlicht 2024-10-30 21:18:55 +01:00
parent 6dc6cc4cbf
commit a54f4e1bd1
3 changed files with 24 additions and 2 deletions

View File

@ -249,7 +249,7 @@ void CPlayerInterface::performAutosave()
};
std::replace_if(name.begin(), name.end(), isSymbolIllegal, '_' );
prefix = name + "_" + cb->getStartInfo()->startTimeIso8601 + "/";
prefix = cb->getStartInfo()->startTimeIso8601 + "_" + name + "/";
}
}

View File

@ -501,6 +501,7 @@ void SelectionTab::filter(int size, bool selectFirst)
auto folder = std::make_shared<ElementInfo>();
folder->isFolder = true;
folder->folderName = folderName;
folder->isAutoSaveFolder = boost::starts_with(baseFolder, "Autosave/") && folderName != "Autosave";
auto itemIt = boost::range::find_if(curItems, [folder](std::shared_ptr<ElementInfo> e) { return e->folderName == folder->folderName; });
if (itemIt == curItems.end() && folderName != "") {
curItems.push_back(folder);
@ -561,7 +562,11 @@ void SelectionTab::sort()
int firstMapIndex = boost::range::find_if(curItems, [](std::shared_ptr<ElementInfo> e) { return !e->isFolder; }) - curItems.begin();
if(!sortModeAscending)
{
if(firstMapIndex)
std::reverse(std::next(curItems.begin(), boost::starts_with(curItems[0]->folderName, "..") ? 1 : 0), std::next(curItems.begin(), firstMapIndex - 1));
std::reverse(std::next(curItems.begin(), firstMapIndex), curItems.end());
}
updateListItems();
redraw();
@ -903,7 +908,7 @@ SelectionTab::ListItem::ListItem(Point position)
{
OBJECT_CONSTRUCTION;
pictureEmptyLine = std::make_shared<CPicture>(ImagePath::builtin("camcust"), Rect(25, 121, 349, 26), -8, -14);
labelName = std::make_shared<CLabel>(184, 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, "", 185);
labelName = std::make_shared<CLabel>(LABEL_POS_X, 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, "", 185);
labelName->setAutoRedraw(false);
labelAmountOfPlayers = std::make_shared<CLabel>(8, 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
labelAmountOfPlayers->setAutoRedraw(false);
@ -947,6 +952,16 @@ void SelectionTab::ListItem::updateItem(std::shared_ptr<ElementInfo> info, bool
labelNumberOfCampaignMaps->disable();
labelName->enable();
labelName->setMaxWidth(316);
if(info->isAutoSaveFolder) // align autosave folder left (starting timestamps in list should be in one line)
{
labelName->alignment = ETextAlignment::CENTERLEFT;
labelName->moveTo(Point(pos.x + 95, labelName->pos.y));
}
else
{
labelName->alignment = ETextAlignment::CENTER;
labelName->moveTo(Point(pos.x + LABEL_POS_X, labelName->pos.y));
}
labelName->setText(info->folderName);
labelName->setColor(color);
return;
@ -968,6 +983,8 @@ void SelectionTab::ListItem::updateItem(std::shared_ptr<ElementInfo> info, bool
labelNumberOfCampaignMaps->setText(ostr.str());
labelNumberOfCampaignMaps->setColor(color);
labelName->setMaxWidth(316);
labelName->alignment = ETextAlignment::CENTER;
labelName->moveTo(Point(pos.x + LABEL_POS_X, labelName->pos.y));
}
else
{
@ -989,6 +1006,8 @@ void SelectionTab::ListItem::updateItem(std::shared_ptr<ElementInfo> info, bool
iconLossCondition->enable();
iconLossCondition->setFrame(info->mapHeader->defeatIconIndex, 0);
labelName->setMaxWidth(185);
labelName->alignment = ETextAlignment::CENTER;
labelName->moveTo(Point(pos.x + LABEL_POS_X, labelName->pos.y));
}
labelName->setText(info->name);
labelName->setColor(color);

View File

@ -35,6 +35,7 @@ public:
std::string folderName = "";
std::string name = "";
bool isFolder = false;
bool isAutoSaveFolder = false;
};
/// Class which handles map sorting by different criteria
@ -60,6 +61,8 @@ class SelectionTab : public CIntObject
std::shared_ptr<CPicture> pictureEmptyLine;
std::shared_ptr<CLabel> labelName;
const int LABEL_POS_X = 184;
ListItem(Point position);
void updateItem(std::shared_ptr<ElementInfo> info = {}, bool selected = false);
};