2021-02-13 21:22:48 +11:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Nick Vella <nick@nxk.io>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-13 21:22:48 +11:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/ByteBuffer.h>
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2021-02-13 21:22:48 +11:00
|
|
|
#include <AK/LexicalPath.h>
|
|
|
|
#include <AK/RefCounted.h>
|
|
|
|
#include <AK/Result.h>
|
|
|
|
#include <AK/Weakable.h>
|
|
|
|
#include <LibGUI/Icon.h>
|
|
|
|
|
|
|
|
namespace HackStudio {
|
|
|
|
|
|
|
|
class ProjectTemplate : public RefCounted<ProjectTemplate> {
|
|
|
|
public:
|
2022-12-04 18:02:33 +00:00
|
|
|
static DeprecatedString templates_path() { return "/res/devel/templates"; }
|
2021-02-13 21:22:48 +11:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
static RefPtr<ProjectTemplate> load_from_manifest(DeprecatedString const& manifest_path);
|
2021-02-13 21:22:48 +11:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
explicit ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority);
|
2021-02-13 21:22:48 +11:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
Result<void, DeprecatedString> create_project(DeprecatedString const& name, DeprecatedString const& path);
|
2021-02-13 21:22:48 +11:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString const& id() const { return m_id; }
|
|
|
|
DeprecatedString const& name() const { return m_name; }
|
|
|
|
DeprecatedString const& description() const { return m_description; }
|
2021-02-13 21:22:48 +11:00
|
|
|
const GUI::Icon& icon() const { return m_icon; }
|
2022-12-04 18:02:33 +00:00
|
|
|
const DeprecatedString content_path() const
|
2021-02-13 21:22:48 +11:00
|
|
|
{
|
2022-12-04 18:02:33 +00:00
|
|
|
return LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", templates_path(), m_id));
|
2021-02-13 21:22:48 +11:00
|
|
|
}
|
|
|
|
int priority() const { return m_priority; }
|
|
|
|
|
|
|
|
private:
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString m_id;
|
|
|
|
DeprecatedString m_name;
|
|
|
|
DeprecatedString m_description;
|
2021-02-13 21:22:48 +11:00
|
|
|
GUI::Icon m_icon;
|
|
|
|
int m_priority { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|