forgot to add new files

This commit is contained in:
Alister
2021-12-25 17:58:17 +00:00
parent 3a51283a70
commit c76b8c2463
2 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#ifndef NOGGIT_COMPONENT_CREATE_PROJECT_HPP
#define NOGGIT_COMPONENT_CREATE_PROJECT_HPP
#include <noggit/project/ApplicationProject.h>
#include <noggit/ui/windows/projectSelection/noggitredprojectpage.h>
namespace Noggit::Ui::Component
{
class CreateProjectComponent
{
friend Windows::noggitRedProjectPage;
public:
void CreateProject(Noggit::Ui::Windows::noggitRedProjectPage* parent, ProjectInformation& projectInformation)
{
auto applicationConfiguration = parent->_noggitApplication->GetConfiguration();
auto applicationProjectsFolderPath = std::filesystem::path(applicationConfiguration->ApplicationProjectPath);
auto applicationProjectService = Noggit::Project::ApplicationProject(applicationConfiguration);
auto projectPath = std::filesystem::path(applicationProjectsFolderPath / projectInformation.ProjectName);
if (!std::filesystem::exists(projectPath))
{
applicationProjectService.CreateProject(projectPath, projectInformation.GameClientPath, projectInformation.GameClientVersion, projectInformation.ProjectName);
}
}
};
}
#endif //NOGGIT_COMPONENT_CREATE_PROJECT_HPP

View File

@@ -0,0 +1,31 @@
#ifndef NOGGIT_COMPONENT_LOAD_PROJECT_HPP
#define NOGGIT_COMPONENT_LOAD_PROJECT_HPP
#include <noggit/project/ApplicationProject.h>
#include <noggit/ui/windows/projectSelection/noggitredprojectpage.h>
namespace Noggit::Ui::Component
{
class LoadProjectComponent
{
friend Windows::noggitRedProjectPage;
public:
std::shared_ptr<Project::NoggitProject> LoadProject(Noggit::Ui::Windows::noggitRedProjectPage* parent)
{
QModelIndex index = parent->ui->listView->currentIndex();
auto applicationConfiguration = parent->_noggitApplication->GetConfiguration();
auto applicationProjectsFolderPath = std::filesystem::path(applicationConfiguration->ApplicationProjectPath);
auto projectName = index.data(Qt::UserRole).toString().toStdString();
auto applicationProjectService = Noggit::Project::ApplicationProject(applicationConfiguration);
auto projectPath = std::filesystem::path(applicationProjectsFolderPath / projectName);
auto project = applicationProjectService.LoadProject(projectPath);
//This to not be static, but its hard to remove
Noggit::Application::NoggitApplication::instance()->clientData(project->ClientData);
return project;
}
};
}
#endif //NOGGIT_COMPONENT_LOAD_PROJECT_HPP