This repository was archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfinityStudioApplication.h
More file actions
107 lines (84 loc) · 3.55 KB
/
InfinityStudioApplication.h
File metadata and controls
107 lines (84 loc) · 3.55 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once
#include <JuceHeader.h>
#include "dialogs/MainWindow.h"
#include "google/protobuf/api.pb.h"
#include "utils/Config.h"
#include "utils/Source.h"
#include "menus/utils/MenuManager.h"
#include "utils/Utils.h"
#include "utils/CallBackManager.h"
#include "Ilvm/ILVM.h"
#include "utils/Egg.h"
class InfinityStudioApplication final :
public juce::JUCEApplication
{
public:
InfinityStudioApplication() :JUCEApplication() {};
const juce::String getApplicationName() override { return ProjectInfo::projectName; };
const juce::String getApplicationVersion() override { return ProjectInfo::versionString; };
bool moreThanOneInstanceAllowed() override { return false; };
void initialise(const juce::String& commandLine) override
{
Egg::init();//初始化彩蛋
Utils::init();//初始化单例复用类
Config::init(
juce::String("D:/develop/Infinity/"),
juce::String("main"),
juce::String("org.infinitysvs.infinitystudio")
);
Config::refreshConfigs();
Config::refreshTranslates();//配置初始化
ILVM::init(
[](juce::StringRef str) {CallBackManager::call<void(juce::StringRef)>("lambda_ConsoleWidget_ErrorMessage_const_juce::String&", str); },
[](juce::StringRef str) {CallBackManager::call<void(juce::StringRef)>("lambda_ConsoleWidget_NormalMessage_const_juce::String&", str); },
[] {CallBackManager::call<void(void)>("lambda_ConsoleWidget_ClearMessage_void"); },
[] {CallBackManager::call<void(bool)>("lambda_StatusBar_VMStartStop_bool", true); },
[] {CallBackManager::call<void(bool)>("lambda_StatusBar_VMStartStop_bool", false); }
);//初始化Lua虚拟机
//-------------------------前后端分界-----------------------------//
this->loadFont(Config::tsFull("main", "font"));//载入字体
Source::init();//初始化静态资源管理器
MenuManager::init();//初始化弹出菜单
CallBackManager::init();//初始化回调管理器
MenuManager::connect("MM_Close_Editor", [this](bool) {this->systemRequestedQuit(); });//菜单退出编辑器
this->mainWindow = std::make_unique<MainWindow>(getApplicationName());
this->mainWindow->init();
this->mainWindow->setVisible(true);
};
void shutdown() override
{
ILVM::destory();//先停虚拟机
this->mainWindow = nullptr;//再销毁窗口
CallBackManager::destory();
google::protobuf::ShutdownProtobufLibrary();
MenuManager::destory();
Source::destory();
Config::destory();
Utils::destory();
Egg::destory();
};
void systemRequestedQuit() override
{
this->mainWindow->setVisible(false);
this->quit();
};
void anotherInstanceStarted(const juce::String& commandLine) override
{
};
private:
std::unique_ptr<MainWindow> mainWindow;
void loadFont(juce::String&& path)
{
juce::File file(path);
juce::FileInputStream stream(file);
if (stream.failedToOpen()) {
return;
}
size_t fileSize = stream.getTotalLength();
std::unique_ptr<char[]> fontData(new char[fileSize]);
stream.read(fontData.get(), fileSize);
Utils::setTypeFace(juce::Typeface::createSystemTypefaceFor(fontData.get(), fileSize));
juce::LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypeface(Utils::getTypeFace());
};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InfinityStudioApplication)
};