-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM1OrientationSettings.cpp
42 lines (40 loc) · 1.62 KB
/
M1OrientationSettings.cpp
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
#include <JuceHeader.h>
#include "M1OrientationSettings.h"
bool M1OrientationManagerOSCSettings::initFromSettings(std::string jsonSettingsFilePath) {
juce::File settingsFile = juce::File(jsonSettingsFilePath);
if (!settingsFile.exists()) {
// Hiding UI error by default
// TODO: handle this more elegantly
// juce::AlertWindow::showMessageBoxAsync(
// juce::AlertWindow::NoIcon,
// "Warning",
// "Mach1: settings.json file doesn't exist in Mach1's Application Support directory, please reinstall the Spatial System",
// "",
// nullptr,
// juce::ModalCallbackFunction::create(([&](int result) {
// //juce::JUCEApplicationBase::quit();
// }))
// );
return false;
}
else {
// Found the settings.json
juce::var mainVar = juce::JSON::parse(juce::File(jsonSettingsFilePath));
int serverPort = mainVar["serverPort"];
int helperPort = mainVar["helperPort"];
if (!init(serverPort, helperPort)) {
juce::AlertWindow::showMessageBoxAsync(
juce::AlertWindow::WarningIcon,
"Warning",
"Mach1: Conflict is happening and you need to choose a new port by changing settings.json in Mach1's Application Support directory",
"",
nullptr,
juce::ModalCallbackFunction::create(([&](int result) {
//juce::JUCEApplicationBase::quit();
}))
);
return false;
}
}
return true;
}