2024-07-02 14:26:33 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <projects-common/Data.h>
|
|
|
|
|
|
2024-07-04 11:43:12 +02:00
|
|
|
#include <common/utils/resources.h>
|
|
|
|
|
#include "Generated Files/resource.h"
|
|
|
|
|
|
2024-07-02 14:26:33 +02:00
|
|
|
namespace ProjectNameUtils
|
|
|
|
|
{
|
|
|
|
|
inline std::wstring CreateProjectName(const std::vector<Project>& projects)
|
|
|
|
|
{
|
2024-07-04 11:43:12 +02:00
|
|
|
std::wstring defaultNamePrefix = GET_RESOURCE_STRING(IDS_DEFAULTPROJECTNAMEPREFIX);
|
2024-07-02 14:26:33 +02:00
|
|
|
int nextProjectIndex = 0;
|
|
|
|
|
for (const auto& proj : projects)
|
|
|
|
|
{
|
|
|
|
|
const std::wstring& name = proj.name;
|
|
|
|
|
if (name.starts_with(defaultNamePrefix))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int index = std::stoi(name.substr(defaultNamePrefix.length() + 1));
|
|
|
|
|
if (nextProjectIndex < index)
|
|
|
|
|
{
|
|
|
|
|
nextProjectIndex = index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return defaultNamePrefix + L" " + std::to_wstring(nextProjectIndex + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|