Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
project.h
1#pragma once
2
3#include "sound_bakery/core/core_include.h"
4
5#include "yaml-cpp/yaml.h"
6
7namespace SB::Engine
8{
9 class SoundContainer;
10}
11
12namespace SB::Editor
13{
18 {
19 ProjectConfiguration() = default;
20
21 ProjectConfiguration(const std::filesystem::path& projectFile)
22 : m_projectFile(projectFile),
23 m_projectFolder(projectFile.parent_path()),
24 m_projectName(projectFile.filename().stem().string())
25 {
26 }
27
28 std::filesystem::path m_projectFile;
29
30 std::string m_projectName;
31 std::filesystem::path m_projectFolder;
32
33 std::filesystem::path sourceFolder() const { return m_projectFolder / "Source"; }
34 std::filesystem::path objectFolder() const { return m_projectFolder / "Objects"; }
35 std::filesystem::path buildFolder() const { return m_projectFolder / "Build"; }
36 std::filesystem::path savedFolder() const { return m_projectFolder / "Saved"; }
37
38 std::filesystem::path encodedFolder() const { return buildFolder() / "Encoded"; }
39 std::filesystem::path logFolder() const { return savedFolder() / "Logs"; }
40
44 std::filesystem::path typeFolder(const rttr::type& type) const;
45
46 std::string getIdFilename(SB::Core::DatabaseObject* databaseObject,
47 std::optional<std::string> extensionOverride = std::nullopt) const
48 {
49 return std::to_string(databaseObject->getDatabaseID()) +
50 (extensionOverride.has_value() ? extensionOverride.value() : ".yaml");
51 }
52
53 bool isValid() const { return std::filesystem::exists(m_projectFile); }
54 };
55
59 class SB_CLASS Project
60 {
61 public:
62 bool openProject(const std::filesystem::path& projectFile);
63 void createProject(const std::filesystem::path& projectFile) {}
64
65 void saveProject() const;
66
67 void encodeAllMedia() const;
68
69 const ProjectConfiguration& getConfig() const { return m_projectConfig; }
70
71 SB::Engine::SoundContainer* getPreviewContainer() const { return m_previewSoundContainer; }
72
73 private:
74 void loadSounds();
75 void loadSystem();
76 void loadObjects();
77
78 void createPreviewContainer();
79
80 void buildSoundbanks() const;
81
82 void saveSystem() const;
83 void saveObjects() const;
84 void saveYAML(const YAML::Emitter& emitter, const std::filesystem::path& filePath) const;
85
86 private:
87 ProjectConfiguration m_projectConfig;
88 SB::Engine::SoundContainer* m_previewSoundContainer;
89 };
90} // namespace SB::Editor
Base object type for any object that can exist in the editor/database. Holds an ID and name.
Definition database_object.h:22
Definition project.h:60
Definition sound_container.h:10
Handles file and folder paths for a project.
Definition project.h:18
std::filesystem::path typeFolder(const rttr::type &type) const
Converts an object type to a folder location.
Definition project.cpp:9