kopia lustrzana https://github.com/jameshball/osci-render
Make timeline and new text rendering appear on premium only and remove license registration
rodzic
ab2fcc287f
commit
db8206200b
|
@ -35,7 +35,7 @@ CommonPluginEditor::CommonPluginEditor(CommonAudioProcessor& p, juce::String app
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addChildComponent(visualiser);
|
addAndMakeVisible(visualiser);
|
||||||
|
|
||||||
int width = std::any_cast<int>(audioProcessor.getProperty("appWidth", defaultWidth));
|
int width = std::any_cast<int>(audioProcessor.getProperty("appWidth", defaultWidth));
|
||||||
int height = std::any_cast<int>(audioProcessor.getProperty("appHeight", defaultHeight));
|
int height = std::any_cast<int>(audioProcessor.getProperty("appHeight", defaultHeight));
|
||||||
|
@ -66,8 +66,6 @@ CommonPluginEditor::CommonPluginEditor(CommonAudioProcessor& p, juce::String app
|
||||||
|
|
||||||
#if OSCI_PREMIUM
|
#if OSCI_PREMIUM
|
||||||
sharedTextureManager.initGL();
|
sharedTextureManager.initGL();
|
||||||
#else
|
|
||||||
visualiser.setVisible(true);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,6 @@
|
||||||
#include "components/VolumeComponent.h"
|
#include "components/VolumeComponent.h"
|
||||||
#include "components/DownloaderComponent.h"
|
#include "components/DownloaderComponent.h"
|
||||||
|
|
||||||
#if OSCI_PREMIUM
|
|
||||||
#include "components/LicenseRegistrationComponent.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class CommonPluginEditor : public juce::AudioProcessorEditor {
|
class CommonPluginEditor : public juce::AudioProcessorEditor {
|
||||||
public:
|
public:
|
||||||
CommonPluginEditor(CommonAudioProcessor&, juce::String appName, juce::String projectFileType, int width, int height);
|
CommonPluginEditor(CommonAudioProcessor&, juce::String appName, juce::String projectFileType, int width, int height);
|
||||||
|
@ -76,11 +72,6 @@ public:
|
||||||
juce::SharedResourcePointer<juce::TooltipWindow> tooltipWindow;
|
juce::SharedResourcePointer<juce::TooltipWindow> tooltipWindow;
|
||||||
juce::DropShadower tooltipDropShadow{juce::DropShadow(juce::Colours::black.withAlpha(0.5f), 6, {0,0})};
|
juce::DropShadower tooltipDropShadow{juce::DropShadow(juce::Colours::black.withAlpha(0.5f), 6, {0,0})};
|
||||||
|
|
||||||
#if OSCI_PREMIUM
|
|
||||||
LicenseRegistrationComponent licenseRegistration {audioProcessor, [this](bool success) {
|
|
||||||
visualiser.setVisible(success);
|
|
||||||
}};
|
|
||||||
#endif
|
|
||||||
bool usingNativeMenuBar = false;
|
bool usingNativeMenuBar = false;
|
||||||
|
|
||||||
#if JUCE_LINUX
|
#if JUCE_LINUX
|
||||||
|
|
|
@ -89,8 +89,6 @@ public:
|
||||||
bool hasSetSessionStartTime = false;
|
bool hasSetSessionStartTime = false;
|
||||||
bool programCrashedAndUserWantsToReset();
|
bool programCrashedAndUserWantsToReset();
|
||||||
|
|
||||||
std::atomic<bool> licenseVerified = true;
|
|
||||||
|
|
||||||
juce::SpinLock audioPlayerListenersLock;
|
juce::SpinLock audioPlayerListenersLock;
|
||||||
std::vector<AudioPlayerListener*> audioPlayerListeners;
|
std::vector<AudioPlayerListener*> audioPlayerListeners;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,9 @@ FrameSettingsComponent::FrameSettingsComponent(OscirenderAudioProcessor& p, Osci
|
||||||
offsetLabel.setTooltip("Offsets the animation's start point by a specified number of frames.");
|
offsetLabel.setTooltip("Offsets the animation's start point by a specified number of frames.");
|
||||||
} else {
|
} else {
|
||||||
audioProcessor.animationSyncBPM->setValueNotifyingHost(false);
|
audioProcessor.animationSyncBPM->setValueNotifyingHost(false);
|
||||||
|
#if OSCI_PREMIUM
|
||||||
addAndMakeVisible(timeline);
|
addAndMakeVisible(timeline);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
addAndMakeVisible(rateLabel);
|
addAndMakeVisible(rateLabel);
|
||||||
addAndMakeVisible(rateBox);
|
addAndMakeVisible(rateBox);
|
||||||
|
@ -60,20 +62,26 @@ void FrameSettingsComponent::resized() {
|
||||||
auto area = getLocalBounds().withTrimmedTop(20).reduced(20);
|
auto area = getLocalBounds().withTrimmedTop(20).reduced(20);
|
||||||
double rowHeight = 20;
|
double rowHeight = 20;
|
||||||
|
|
||||||
|
#if OSCI_PREMIUM
|
||||||
auto timelineArea = juce::JUCEApplicationBase::isStandaloneApp() ? area.removeFromBottom(30) : juce::Rectangle<int>();
|
auto timelineArea = juce::JUCEApplicationBase::isStandaloneApp() ? area.removeFromBottom(30) : juce::Rectangle<int>();
|
||||||
|
#endif
|
||||||
|
|
||||||
auto toggleBounds = juce::JUCEApplicationBase::isStandaloneApp() ? juce::Rectangle<int>() : area.removeFromTop(rowHeight);
|
auto toggleBounds = juce::JUCEApplicationBase::isStandaloneApp() ? juce::Rectangle<int>() : area.removeFromTop(rowHeight);
|
||||||
auto toggleWidth = juce::jmin(area.getWidth() / 3, 150);
|
auto toggleWidth = juce::jmin(area.getWidth() / 3, 150);
|
||||||
|
|
||||||
auto firstColumn = area.removeFromLeft(220);
|
auto firstColumn = area.removeFromLeft(220);
|
||||||
|
|
||||||
|
#if OSCI_PREMIUM
|
||||||
if (juce::JUCEApplicationBase::isStandaloneApp()) {
|
if (juce::JUCEApplicationBase::isStandaloneApp()) {
|
||||||
timeline.setVisible(animated);
|
timeline.setVisible(animated);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (animated) {
|
if (animated) {
|
||||||
if (juce::JUCEApplicationBase::isStandaloneApp()) {
|
if (juce::JUCEApplicationBase::isStandaloneApp()) {
|
||||||
|
#if OSCI_PREMIUM
|
||||||
timeline.setBounds(timelineArea);
|
timeline.setBounds(timelineArea);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
animate.setBounds(toggleBounds.removeFromLeft(toggleWidth));
|
animate.setBounds(toggleBounds.removeFromLeft(toggleWidth));
|
||||||
sync.setBounds(toggleBounds.removeFromLeft(toggleWidth));
|
sync.setBounds(toggleBounds.removeFromLeft(toggleWidth));
|
||||||
|
|
|
@ -33,7 +33,9 @@ private:
|
||||||
juce::Label offsetLabel{ "Offset","Offset" };
|
juce::Label offsetLabel{ "Offset","Offset" };
|
||||||
DoubleTextBox rateBox{ audioProcessor.animationRate->min, audioProcessor.animationRate->max };
|
DoubleTextBox rateBox{ audioProcessor.animationRate->min, audioProcessor.animationRate->max };
|
||||||
DoubleTextBox offsetBox{ audioProcessor.animationOffset->min, audioProcessor.animationRate->max };
|
DoubleTextBox offsetBox{ audioProcessor.animationOffset->min, audioProcessor.animationRate->max };
|
||||||
|
#if OSCI_PREMIUM
|
||||||
AnimationTimelineComponent timeline{audioProcessor};
|
AnimationTimelineComponent timeline{audioProcessor};
|
||||||
|
#endif
|
||||||
|
|
||||||
jux::SwitchButton invertImage{audioProcessor.invertImage};
|
jux::SwitchButton invertImage{audioProcessor.invertImage};
|
||||||
EffectComponent threshold{*audioProcessor.imageThreshold};
|
EffectComponent threshold{*audioProcessor.imageThreshold};
|
||||||
|
|
|
@ -128,7 +128,7 @@ MainComponent::MainComponent(OscirenderAudioProcessor& p, OscirenderAudioProcess
|
||||||
osci::BooleanParameter* visualiserFullScreen = audioProcessor.visualiserParameters.visualiserFullScreen;
|
osci::BooleanParameter* visualiserFullScreen = audioProcessor.visualiserParameters.visualiserFullScreen;
|
||||||
pluginEditor.visualiser.setFullScreen(visualiserFullScreen->getBoolValue());
|
pluginEditor.visualiser.setFullScreen(visualiserFullScreen->getBoolValue());
|
||||||
|
|
||||||
addChildComponent(pluginEditor.visualiser);
|
addAndMakeVisible(pluginEditor.visualiser);
|
||||||
pluginEditor.visualiser.setFullScreenCallback([this, visualiserFullScreen](FullScreenMode mode) {
|
pluginEditor.visualiser.setFullScreenCallback([this, visualiserFullScreen](FullScreenMode mode) {
|
||||||
if (mode == FullScreenMode::TOGGLE) {
|
if (mode == FullScreenMode::TOGGLE) {
|
||||||
visualiserFullScreen->setBoolValueNotifyingHost(!visualiserFullScreen->getBoolValue());
|
visualiserFullScreen->setBoolValueNotifyingHost(!visualiserFullScreen->getBoolValue());
|
||||||
|
|
|
@ -77,7 +77,7 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
|
||||||
|
|
||||||
addAndMakeVisible(lua);
|
addAndMakeVisible(lua);
|
||||||
addAndMakeVisible(luaResizerBar);
|
addAndMakeVisible(luaResizerBar);
|
||||||
addChildComponent(visualiser);
|
addAndMakeVisible(visualiser);
|
||||||
|
|
||||||
visualiser.openSettings = [this] {
|
visualiser.openSettings = [this] {
|
||||||
openVisualiserSettings();
|
openVisualiserSettings();
|
||||||
|
@ -95,11 +95,6 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
initialiseMenuBar(model);
|
initialiseMenuBar(model);
|
||||||
|
|
||||||
#if OSCI_PREMIUM
|
|
||||||
addChildComponent(licenseRegistration);
|
|
||||||
licenseRegistration.toFront(true);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OscirenderAudioProcessorEditor::~OscirenderAudioProcessorEditor() {
|
OscirenderAudioProcessorEditor::~OscirenderAudioProcessorEditor() {
|
||||||
|
@ -189,10 +184,6 @@ void OscirenderAudioProcessorEditor::resized() {
|
||||||
|
|
||||||
auto area = getLocalBounds();
|
auto area = getLocalBounds();
|
||||||
|
|
||||||
#if OSCI_PREMIUM
|
|
||||||
licenseRegistration.setBounds(area);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (audioProcessor.visualiserParameters.visualiserFullScreen->getBoolValue()) {
|
if (audioProcessor.visualiserParameters.visualiserFullScreen->getBoolValue()) {
|
||||||
visualiser.setBounds(area);
|
visualiser.setBounds(area);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -620,7 +620,7 @@ void OscirenderAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, ju
|
||||||
threadManager.write(osci::Point(x, y, 1));
|
threadManager.write(osci::Point(x, y, 1));
|
||||||
|
|
||||||
// Apply mute if active
|
// Apply mute if active
|
||||||
if (muteParameter->getBoolValue() || !licenseVerified) {
|
if (muteParameter->getBoolValue()) {
|
||||||
x = 0.0;
|
x = 0.0;
|
||||||
y = 0.0;
|
y = 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,6 @@ SosciPluginEditor::SosciPluginEditor(SosciAudioProcessor& p) : CommonPluginEdito
|
||||||
manager.addChangeListener(this);
|
manager.addChangeListener(this);
|
||||||
currentInputDevice = getInputDeviceName();
|
currentInputDevice = getInputDeviceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OSCI_PREMIUM
|
|
||||||
addChildComponent(licenseRegistration);
|
|
||||||
licenseRegistration.toFront(true);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SosciPluginEditor::~SosciPluginEditor() {
|
SosciPluginEditor::~SosciPluginEditor() {
|
||||||
|
@ -58,10 +53,6 @@ void SosciPluginEditor::resized() {
|
||||||
CommonPluginEditor::resized();
|
CommonPluginEditor::resized();
|
||||||
auto area = getLocalBounds();
|
auto area = getLocalBounds();
|
||||||
|
|
||||||
#if OSCI_PREMIUM
|
|
||||||
licenseRegistration.setBounds(area);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (audioProcessor.visualiserParameters.visualiserFullScreen->getBoolValue()) {
|
if (audioProcessor.visualiserParameters.visualiserFullScreen->getBoolValue()) {
|
||||||
visualiser.setBounds(area);
|
visualiser.setBounds(area);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,246 +0,0 @@
|
||||||
#include "LicenseRegistrationComponent.h"
|
|
||||||
|
|
||||||
LicenseRegistrationComponent::LicenseRegistrationComponent(CommonAudioProcessor& processor, std::function<void(bool)> onLicenseVerified)
|
|
||||||
: audioProcessor(processor), onLicenseVerified(onLicenseVerified)
|
|
||||||
{
|
|
||||||
setupComponents();
|
|
||||||
|
|
||||||
auto showComponent = [this] {
|
|
||||||
// If validated within the last week, show immediately
|
|
||||||
juce::WeakReference<LicenseRegistrationComponent> weakThis(this);
|
|
||||||
juce::MessageManager::callAsync([weakThis]() {
|
|
||||||
if (auto* strongThis = weakThis.get()) {
|
|
||||||
strongThis->setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
audioProcessor.licenseVerified = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
audioProcessor.reloadGlobalSettings();
|
|
||||||
auto savedKey = audioProcessor.getGlobalStringValue("license_key");
|
|
||||||
if (savedKey.isNotEmpty())
|
|
||||||
{
|
|
||||||
// Pre-populate the license key field
|
|
||||||
licenseKeyEditor.setText(savedKey, false);
|
|
||||||
|
|
||||||
auto lastValidated = audioProcessor.getGlobalStringValue("license_last_validated");
|
|
||||||
if (lastValidated.isNotEmpty())
|
|
||||||
{
|
|
||||||
auto lastValidationTime = juce::Time::fromISO8601(lastValidated);
|
|
||||||
auto weekAgo = juce::Time::getCurrentTime() - juce::RelativeTime::weeks(1);
|
|
||||||
auto hourAgo = juce::Time::getCurrentTime() - juce::RelativeTime::hours(1);
|
|
||||||
|
|
||||||
if (lastValidationTime > weekAgo)
|
|
||||||
{
|
|
||||||
if (onLicenseVerified != nullptr) {
|
|
||||||
onLicenseVerified(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
audioProcessor.licenseVerified = true;
|
|
||||||
} else {
|
|
||||||
showComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastValidationTime < hourAgo) {
|
|
||||||
// Validate the license key in the background
|
|
||||||
validateSavedLicense();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start periodic checks every hour
|
|
||||||
startTimer(1000 * 60 * 60);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
showComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LicenseRegistrationComponent::~LicenseRegistrationComponent()
|
|
||||||
{
|
|
||||||
stopTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LicenseRegistrationComponent::setupComponents()
|
|
||||||
{
|
|
||||||
titleLabel.setText("License Registration Required", juce::dontSendNotification);
|
|
||||||
titleLabel.setFont(juce::Font(24.0f, juce::Font::bold));
|
|
||||||
titleLabel.setJustificationType(juce::Justification::centred);
|
|
||||||
addAndMakeVisible(titleLabel);
|
|
||||||
|
|
||||||
instructionsLabel.setText("Please enter your license key to continue", juce::dontSendNotification);
|
|
||||||
instructionsLabel.setJustificationType(juce::Justification::centred);
|
|
||||||
instructionsLabel.setFont(juce::Font(18.0f));
|
|
||||||
addAndMakeVisible(instructionsLabel);
|
|
||||||
|
|
||||||
licenseKeyEditor.setTextToShowWhenEmpty("XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX", juce::Colours::grey);
|
|
||||||
licenseKeyEditor.setInputRestrictions(35, "0123456789ABCDEFabcdef-"); // Allow both upper and lowercase hex digits and hyphens
|
|
||||||
licenseKeyEditor.onReturnKey = [this] { verifyButton.triggerClick(); };
|
|
||||||
licenseKeyEditor.setFont(juce::Font(24.0f));
|
|
||||||
licenseKeyEditor.onTextChange = [this] {
|
|
||||||
auto currentText = licenseKeyEditor.getText();
|
|
||||||
auto upperText = currentText.toUpperCase();
|
|
||||||
if (currentText != upperText)
|
|
||||||
{
|
|
||||||
auto cursorPos = licenseKeyEditor.getCaretPosition();
|
|
||||||
licenseKeyEditor.setText(upperText, false);
|
|
||||||
licenseKeyEditor.setCaretPosition(cursorPos);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
addAndMakeVisible(licenseKeyEditor);
|
|
||||||
|
|
||||||
verifyButton.setButtonText("Verify License");
|
|
||||||
verifyButton.onClick = [this] {
|
|
||||||
if (!isVerifying)
|
|
||||||
{
|
|
||||||
verifyLicense(licenseKeyEditor.getText());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
addAndMakeVisible(verifyButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LicenseRegistrationComponent::paint(juce::Graphics& g)
|
|
||||||
{
|
|
||||||
g.fillAll(juce::Colours::black.withAlpha(0.9f));
|
|
||||||
|
|
||||||
auto bounds = getLocalBounds().toFloat();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LicenseRegistrationComponent::resized()
|
|
||||||
{
|
|
||||||
auto bounds = getLocalBounds().reduced(20);
|
|
||||||
|
|
||||||
titleLabel.setBounds(bounds.removeFromTop(40));
|
|
||||||
bounds.removeFromTop(20);
|
|
||||||
|
|
||||||
instructionsLabel.setBounds(bounds.removeFromTop(30));
|
|
||||||
bounds.removeFromTop(20);
|
|
||||||
|
|
||||||
auto row = bounds.removeFromTop(35);
|
|
||||||
licenseKeyEditor.setBounds(row.reduced(50, 0));
|
|
||||||
bounds.removeFromTop(20);
|
|
||||||
|
|
||||||
auto buttonBounds = bounds.removeFromTop(40);
|
|
||||||
verifyButton.setBounds(buttonBounds.withSizeKeepingCentre(120, 40));
|
|
||||||
}
|
|
||||||
|
|
||||||
void LicenseRegistrationComponent::verifyLicense(const juce::String& licenseKey, bool showErrorDialog)
|
|
||||||
{
|
|
||||||
if (licenseKey.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
isVerifying = true;
|
|
||||||
verifyButton.setEnabled(false);
|
|
||||||
verifyButton.setVisible(false);
|
|
||||||
|
|
||||||
juce::URL url("https://api.osci-render.com/api/verify-license");
|
|
||||||
|
|
||||||
auto jsonObj = std::make_unique<juce::DynamicObject>();
|
|
||||||
jsonObj->setProperty("license_key", licenseKey);
|
|
||||||
juce::var jsonData(jsonObj.release());
|
|
||||||
|
|
||||||
url = url.withPOSTData(juce::JSON::toString(jsonData));
|
|
||||||
|
|
||||||
auto webStream = url.createInputStream(false, nullptr, nullptr,
|
|
||||||
"Content-Type: application/json",
|
|
||||||
10000);
|
|
||||||
|
|
||||||
bool successfullyVerified = false;
|
|
||||||
|
|
||||||
if (webStream != nullptr)
|
|
||||||
{
|
|
||||||
auto response = webStream->readEntireStreamAsString();
|
|
||||||
DBG(response);
|
|
||||||
auto json = juce::JSON::parse(response);
|
|
||||||
|
|
||||||
if (json.hasProperty("success")) {
|
|
||||||
bool success = json["success"];
|
|
||||||
|
|
||||||
if (success && json.hasProperty("valid") && json.hasProperty("purchase")) {
|
|
||||||
bool valid = json["valid"];
|
|
||||||
|
|
||||||
auto purchase = json["purchase"].getDynamicObject();
|
|
||||||
auto productId = purchase->getProperty("product_id").toString();
|
|
||||||
|
|
||||||
if (success && valid && productId == SOSCI_PRODUCT_ID)
|
|
||||||
{
|
|
||||||
// Save the license key and validation timestamp
|
|
||||||
audioProcessor.setGlobalValue("license_key", licenseKey);
|
|
||||||
audioProcessor.setGlobalValue("license_last_validated", juce::Time::getCurrentTime().toISO8601(true));
|
|
||||||
audioProcessor.saveGlobalSettings();
|
|
||||||
|
|
||||||
audioProcessor.licenseVerified = true;
|
|
||||||
|
|
||||||
successfullyVerified = true;
|
|
||||||
|
|
||||||
juce::WeakReference<LicenseRegistrationComponent> weakThis(this);
|
|
||||||
juce::MessageManager::callAsync([weakThis]() {
|
|
||||||
if (auto* strongThis = weakThis.get()) {
|
|
||||||
strongThis->setVisible(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
startTimer(1000 * 60 * 60); // Check every hour
|
|
||||||
}
|
|
||||||
else if (showErrorDialog)
|
|
||||||
{
|
|
||||||
juce::AlertWindow::showMessageBoxAsync(juce::AlertWindow::WarningIcon,
|
|
||||||
"Invalid License",
|
|
||||||
"The license key you entered is not valid. Please check and try again.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Background check failed, clear the license
|
|
||||||
clearLicense();
|
|
||||||
}
|
|
||||||
} else if (showErrorDialog && json.hasProperty("message")) {
|
|
||||||
auto message = json["message"].toString();
|
|
||||||
juce::AlertWindow::showMessageBoxAsync(juce::AlertWindow::WarningIcon, "Error", message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (showErrorDialog)
|
|
||||||
{
|
|
||||||
juce::AlertWindow::showMessageBoxAsync(juce::AlertWindow::WarningIcon,
|
|
||||||
"Connection Error",
|
|
||||||
"Could not connect to the license server. Please check your internet connection and try again.");
|
|
||||||
}
|
|
||||||
|
|
||||||
isVerifying = false;
|
|
||||||
verifyButton.setEnabled(true);
|
|
||||||
verifyButton.setVisible(true);
|
|
||||||
|
|
||||||
if (onLicenseVerified != nullptr) {
|
|
||||||
onLicenseVerified(successfullyVerified);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LicenseRegistrationComponent::validateSavedLicense()
|
|
||||||
{
|
|
||||||
auto savedKey = audioProcessor.getGlobalStringValue("license_key");
|
|
||||||
if (savedKey.isNotEmpty())
|
|
||||||
{
|
|
||||||
auto lastValidated = audioProcessor.getGlobalStringValue("license_last_validated");
|
|
||||||
if (lastValidated.isNotEmpty())
|
|
||||||
{
|
|
||||||
// Verify in the background without showing error dialogs
|
|
||||||
verifyLicense(savedKey, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LicenseRegistrationComponent::clearLicense()
|
|
||||||
{
|
|
||||||
audioProcessor.removeGlobalValue("license_key");
|
|
||||||
audioProcessor.removeGlobalValue("license_last_validated");
|
|
||||||
audioProcessor.saveGlobalSettings();
|
|
||||||
setVisible(true);
|
|
||||||
audioProcessor.licenseVerified = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LicenseRegistrationComponent::timerCallback()
|
|
||||||
{
|
|
||||||
auto savedKey = audioProcessor.getGlobalStringValue("license_key");
|
|
||||||
if (savedKey.isNotEmpty()) {
|
|
||||||
verifyLicense(savedKey, false);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <JuceHeader.h>
|
|
||||||
#include "../CommonPluginProcessor.h"
|
|
||||||
|
|
||||||
class LicenseRegistrationComponent : public juce::Component,
|
|
||||||
public juce::Timer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LicenseRegistrationComponent(CommonAudioProcessor& processor, std::function<void(bool)> onLicenseVerified);
|
|
||||||
~LicenseRegistrationComponent() override;
|
|
||||||
|
|
||||||
void paint(juce::Graphics& g) override;
|
|
||||||
void resized() override;
|
|
||||||
|
|
||||||
// Timer callback for background license verification
|
|
||||||
void timerCallback() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void verifyLicense(const juce::String& licenseKey, bool showErrorDialog = true);
|
|
||||||
bool validateSavedLicense();
|
|
||||||
void clearLicense();
|
|
||||||
void setupComponents();
|
|
||||||
|
|
||||||
CommonAudioProcessor& audioProcessor;
|
|
||||||
juce::Label titleLabel;
|
|
||||||
juce::Label instructionsLabel;
|
|
||||||
juce::TextEditor licenseKeyEditor;
|
|
||||||
juce::TextButton verifyButton;
|
|
||||||
bool isVerifying = false;
|
|
||||||
|
|
||||||
const juce::String SOSCI_PRODUCT_ID = "Hsr9C58_YhTxYP0MNvsIow==";
|
|
||||||
|
|
||||||
std::function<void(bool)> onLicenseVerified;
|
|
||||||
|
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LicenseRegistrationComponent)
|
|
||||||
JUCE_DECLARE_WEAK_REFERENCEABLE(LicenseRegistrationComponent)
|
|
||||||
};
|
|
|
@ -13,6 +13,9 @@ TextParser::~TextParser() {
|
||||||
void TextParser::parse(juce::String text, juce::Font font) {
|
void TextParser::parse(juce::String text, juce::Font font) {
|
||||||
lastFont = font;
|
lastFont = font;
|
||||||
|
|
||||||
|
juce::Path textPath;
|
||||||
|
|
||||||
|
#if OSCI_PREMIUM
|
||||||
// Apply formatting markers if the font is bold or italic
|
// Apply formatting markers if the font is bold or italic
|
||||||
juce::String formattedText = text;
|
juce::String formattedText = text;
|
||||||
|
|
||||||
|
@ -31,9 +34,6 @@ void TextParser::parse(juce::String text, juce::Font font) {
|
||||||
juce::TextLayout layout;
|
juce::TextLayout layout;
|
||||||
layout.createLayout(attributedString, 64.0f);
|
layout.createLayout(attributedString, 64.0f);
|
||||||
|
|
||||||
// Create a path from the TextLayout
|
|
||||||
juce::Path textPath;
|
|
||||||
|
|
||||||
juce::String displayText = attributedString.getText();
|
juce::String displayText = attributedString.getText();
|
||||||
// remove all whitespace
|
// remove all whitespace
|
||||||
displayText = displayText.removeCharacters(" \t\n\r");
|
displayText = displayText.removeCharacters(" \t\n\r");
|
||||||
|
@ -75,10 +75,13 @@ void TextParser::parse(juce::String text, juce::Font font) {
|
||||||
|
|
||||||
// If the layout has no text, fallback to original method
|
// If the layout has no text, fallback to original method
|
||||||
if (textPath.isEmpty()) {
|
if (textPath.isEmpty()) {
|
||||||
|
#endif
|
||||||
juce::GlyphArrangement glyphs;
|
juce::GlyphArrangement glyphs;
|
||||||
glyphs.addFittedText(font, text, -2, -2, 4, 4, juce::Justification::centred, 2);
|
glyphs.addFittedText(font, text, -2, -2, 4, 4, juce::Justification::centred, 2);
|
||||||
glyphs.createPath(textPath);
|
glyphs.createPath(textPath);
|
||||||
|
#if OSCI_PREMIUM
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Convert path to shapes
|
// Convert path to shapes
|
||||||
shapes = std::vector<std::unique_ptr<osci::Shape>>();
|
shapes = std::vector<std::unique_ptr<osci::Shape>>();
|
||||||
|
|
|
@ -162,10 +162,6 @@
|
||||||
file="Source/components/ErrorCodeEditorComponent.h"/>
|
file="Source/components/ErrorCodeEditorComponent.h"/>
|
||||||
<FILE id="L9DIT2" name="LabelledTextBox.h" compile="0" resource="0"
|
<FILE id="L9DIT2" name="LabelledTextBox.h" compile="0" resource="0"
|
||||||
file="Source/components/LabelledTextBox.h"/>
|
file="Source/components/LabelledTextBox.h"/>
|
||||||
<FILE id="mp7cFK" name="LicenseRegistrationComponent.cpp" compile="1"
|
|
||||||
resource="0" file="Source/components/LicenseRegistrationComponent.cpp"/>
|
|
||||||
<FILE id="eW7t3h" name="LicenseRegistrationComponent.h" compile="0"
|
|
||||||
resource="0" file="Source/components/LicenseRegistrationComponent.h"/>
|
|
||||||
<FILE id="tpNWJ3" name="LuaConsole.cpp" compile="1" resource="0" file="Source/components/LuaConsole.cpp"/>
|
<FILE id="tpNWJ3" name="LuaConsole.cpp" compile="1" resource="0" file="Source/components/LuaConsole.cpp"/>
|
||||||
<FILE id="e3ZteP" name="LuaConsole.h" compile="0" resource="0" file="Source/components/LuaConsole.h"/>
|
<FILE id="e3ZteP" name="LuaConsole.h" compile="0" resource="0" file="Source/components/LuaConsole.h"/>
|
||||||
<FILE id="qIxm1z" name="LuaListComponent.cpp" compile="1" resource="0"
|
<FILE id="qIxm1z" name="LuaListComponent.cpp" compile="1" resource="0"
|
||||||
|
|
|
@ -120,10 +120,6 @@
|
||||||
file="Source/components/EffectComponent.cpp"/>
|
file="Source/components/EffectComponent.cpp"/>
|
||||||
<FILE id="u4UCwb" name="EffectComponent.h" compile="0" resource="0"
|
<FILE id="u4UCwb" name="EffectComponent.h" compile="0" resource="0"
|
||||||
file="Source/components/EffectComponent.h"/>
|
file="Source/components/EffectComponent.h"/>
|
||||||
<FILE id="GPZ9q4" name="LicenseRegistrationComponent.cpp" compile="1"
|
|
||||||
resource="0" file="Source/components/LicenseRegistrationComponent.cpp"/>
|
|
||||||
<FILE id="JcXyLX" name="LicenseRegistrationComponent.h" compile="0"
|
|
||||||
resource="0" file="Source/components/LicenseRegistrationComponent.h"/>
|
|
||||||
<FILE id="ka6rAh" name="MainMenuBarModel.cpp" compile="1" resource="0"
|
<FILE id="ka6rAh" name="MainMenuBarModel.cpp" compile="1" resource="0"
|
||||||
file="Source/components/MainMenuBarModel.cpp"/>
|
file="Source/components/MainMenuBarModel.cpp"/>
|
||||||
<FILE id="t6oUhv" name="MainMenuBarModel.h" compile="0" resource="0"
|
<FILE id="t6oUhv" name="MainMenuBarModel.h" compile="0" resource="0"
|
||||||
|
|
Ładowanie…
Reference in New Issue