blob: b7b4c9f89a6bf4a3075160b3370ca13182d55e75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include "States.hpp"
#include "Model/GlobalStates.hpp"
#include "Model/Project.hpp"
#include <memory>
#include <utility>
static std::unique_ptr<UIState> uiStateInstance;
void UIState::Init()
{
uiStateInstance = std::make_unique<UIState>();
}
void UIState::Shutdown()
{
if (uiStateInstance) {
uiStateInstance->CloseCurrentProject();
uiStateInstance = nullptr;
}
}
UIState& UIState::GetInstance()
{
return *uiStateInstance;
}
void UIState::SetCurrentProject(std::unique_ptr<Project> project)
{
CloseCurrentProject();
if (project) {
GlobalStates::GetInstance().MoveProjectToTop(*project);
}
CurrentProject = std::move(project);
}
void UIState::CloseCurrentProject()
{
if (CurrentProject) {
CurrentProject->WriteToDisk();
CurrentProject = nullptr;
}
}
|