Skip to content

Commit

Permalink
Add a welcome/warnign screen (#1077)
Browse files Browse the repository at this point in the history
Welcome screen
has a version
If you've seen that version once won't show again
If we bump the version you'll see it

CLoses #1075
  • Loading branch information
baconpaul authored Aug 6, 2024
1 parent 68c846c commit 6545914
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 8 deletions.
1 change: 1 addition & 0 deletions src-ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ add_library(${PROJECT_NAME} STATIC
components/SendFXScreen.cpp
components/AboutScreen.cpp
components/LogScreen.cpp
components/WelcomeScreen.cpp

components/browser/BrowserPane.cpp

Expand Down
31 changes: 31 additions & 0 deletions src-ui/components/SCXTEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "MixerScreen.h"
#include "AboutScreen.h"
#include "LogScreen.h"
#include "WelcomeScreen.h"
#include "SCXTJuceLookAndFeel.h"
#include "sst/jucegui/components/ToolTip.h"
#include <sst/jucegui/components/DiscreteParamMenuBuilder.h>
Expand Down Expand Up @@ -107,6 +108,9 @@ SCXTEditor::SCXTEditor(messaging::MessageController &e, infrastructure::Defaults
aboutScreen = std::make_unique<AboutScreen>(this);
addChildComponent(*aboutScreen);

welcomeScreen = std::make_unique<WelcomeScreen>(this);
addChildComponent(*welcomeScreen);

logScreen = std::make_unique<LogScreen>(this);
addChildComponent(*logScreen);

Expand Down Expand Up @@ -164,6 +168,7 @@ void SCXTEditor::showAboutOverlay()
aboutScreen->toFront(true);
aboutScreen->setVisible(true);
logScreen->setVisible(false);
welcomeScreen->setVisible(false);
resized();
}

Expand All @@ -172,6 +177,16 @@ void SCXTEditor::showLogOverlay()
logScreen->toFront(true);
logScreen->setVisible(true);
aboutScreen->setVisible(false);
welcomeScreen->setVisible(false);
resized();
}

void SCXTEditor::showWelcomeOverlay()
{
welcomeScreen->toFront(true);
welcomeScreen->setVisible(true);
aboutScreen->setVisible(false);
logScreen->setVisible(false);
resized();
}

Expand All @@ -190,6 +205,8 @@ void SCXTEditor::resized()
aboutScreen->setBounds(0, headerHeight, getWidth(), getHeight() - headerHeight);
if (logScreen->isVisible())
logScreen->setBounds(0, headerHeight, getWidth(), getHeight() - headerHeight);
if (welcomeScreen->isVisible())
welcomeScreen->setBounds(0, 0, getWidth(), getHeight());
}

void SCXTEditor::idle()
Expand Down Expand Up @@ -240,6 +257,20 @@ void SCXTEditor::idle()
}

headerRegion->setMemUsage((float)std::round(sampleManager.sampleMemoryInBytes / 1024 / 1024));

if (checkWelcomeCountdown == 0)
{
auto sc = defaultsProvider.getUserDefaultValue(scxt::infrastructure::welcomeScreenSeen, -1);
if (sc != WelcomeScreen::welcomeVersion)
{
showWelcomeOverlay();
}
checkWelcomeCountdown = -1;
}
else if (checkWelcomeCountdown > 0)
{
checkWelcomeCountdown--;
}
}

void SCXTEditor::drainCallbackQueue()
Expand Down
4 changes: 4 additions & 0 deletions src-ui/components/SCXTEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct HeaderRegion;
struct MultiScreen;
struct MixerScreen;
struct AboutScreen;
struct WelcomeScreen;
struct PlayScreen;
struct LogScreen;
struct SCXTJuceLookAndFeel;
Expand Down Expand Up @@ -124,6 +125,7 @@ struct SCXTEditor : sst::jucegui::components::WindowPanel, juce::DragAndDropCont
std::unique_ptr<MixerScreen> mixerScreen;
std::unique_ptr<PlayScreen> playScreen;
std::unique_ptr<AboutScreen> aboutScreen;
std::unique_ptr<WelcomeScreen> welcomeScreen;
std::unique_ptr<LogScreen> logScreen;

std::unique_ptr<sst::jucegui::components::ToolTip> toolTip;
Expand All @@ -144,6 +146,8 @@ struct SCXTEditor : sst::jucegui::components::WindowPanel, juce::DragAndDropCont
void setActiveScreen(ActiveScreen s);
void showAboutOverlay();
void showLogOverlay();
void showWelcomeOverlay();
int32_t checkWelcomeCountdown{20};

float zoomFactor{1.f};
void setZoomFactor(float zoomFactor); // 1.0 == 100%
Expand Down
11 changes: 8 additions & 3 deletions src-ui/components/SCXTEditorMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,20 @@ void SCXTEditor::showMainMenu()
if (w)
w->aboutScreen->copyInfo();
});
m.addItem("About", [w = juce::Component::SafePointer(this)] {
m.addItem("Show About Screen", [w = juce::Component::SafePointer(this)] {
if (w)
w->showAboutOverlay();
});
m.addItem("Log", [w = juce::Component::SafePointer(this)] {
m.addItem("Show Log", [w = juce::Component::SafePointer(this)] {
if (w)
w->showLogOverlay();
});
m.addItem("Source", [] {

m.addItem("Show Welcome Screen", [w = juce::Component::SafePointer(this)] {
if (w)
w->showWelcomeOverlay();
});
m.addItem("Read Source", [] {
juce::URL("https://github.com/surge-synthesizer/shortcircuit-xt").launchInDefaultBrowser();
});

Expand Down
110 changes: 110 additions & 0 deletions src-ui/components/WelcomeScreen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Shortcircuit XT - a Surge Synth Team product
*
* A fully featured creative sampler, available as a standalone
* and plugin for multiple platforms.
*
* Copyright 2019 - 2024, Various authors, as described in the github
* transaction log.
*
* ShortcircuitXT is released under the Gnu General Public Licence
* V3 or later (GPL-3.0-or-later). The license is found in the file
* "LICENSE" in the root of this repository or at
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* Individual sections of code which comprises ShortcircuitXT in this
* repository may also be used under an MIT license. Please see the
* section "Licensing" in "README.md" for details.
*
* ShortcircuitXT is inspired by, and shares code with, the
* commercial product Shortcircuit 1 and 2, released by VemberTech
* in the mid 2000s. The code for Shortcircuit 2 was opensourced in
* 2020 at the outset of this project.
*
* All source for ShortcircuitXT is available at
* https://github.com/surge-synthesizer/shortcircuit-xt
*/

#include "WelcomeScreen.h"

#include "utils.h"
#include "sst/plugininfra/cpufeatures.h"
#include "SCXTEditor.h"
#include "connectors/SCXTResources.h"
#include "infrastructure/user_defaults.h"

namespace scxt::ui
{
WelcomeScreen::WelcomeScreen(SCXTEditor *e) : HasEditor(e)
{
setAccessible(true);
setTitle("Welcome to ShortCircuit XT Pre-Alpha. Please use care. Press escape to use sampler.");
setWantsKeyboardFocus(true);
}
void WelcomeScreen::visibilityChanged()
{
if (isVisible())
grabKeyboardFocus();
}
bool WelcomeScreen::keyPressed(const juce::KeyPress &key)
{
if (key.getKeyCode() == juce::KeyPress::escapeKey)
{
okGotItDontShowAgain();
return true;
}
return false;
}

void WelcomeScreen::okGotItDontShowAgain()
{
editor->defaultsProvider.updateUserDefaultValue(infrastructure::welcomeScreenSeen,
welcomeVersion);
setVisible(false);
}

auto txt =
"Shortcircuit XT is in a pre-alpha release. This version has incomplete and "
"missing features, may have crashing bugs, may generate improper sounds, and is not streaming "
"stable (so saved sessions may not work in the future).\n"
"\n"
"We welcome testers in this pre-alpha period but recommend a few precautions:\n\n"
"- Consider using limiter and don't use in-ear headphones when experimenting.\n"
"- The platform is not streaming stable; if you make music you like, bounce stems.\n"
"- There is no missing sample resolution; don't move underlying files.\n"

"\n"
"We love early testers, documenters, and designers on all our projects. The best way to "
"chat with the Surge Synth Team devs about ShortcircutiXT is to join the Surge Synth Team "
"discord and hop into the #using-shortcircuit or #sc-development channels.\n\n"
"Finally, we love developers too! If you want to join the team and help sling some code on the "
"project, please get in touch.\n\n"
"Press escape or click on this screen to dismiss. If you want to re-review this information, "
"choose 'Show Welcome Screen' from the menu in the upper right corner.";
;

void WelcomeScreen::paint(juce::Graphics &g)
{
auto r = getLocalBounds();

g.fillAll(editor->themeColor(theme::ColorMap::bg_1).withAlpha(0.6f));

auto bd = r.reduced(140, 130);

g.setColour(editor->themeColor(theme::ColorMap::bg_1));
g.fillRect(bd);
g.setColour(editor->themeColor(theme::ColorMap::generic_content_medium));
g.drawRect(bd);
g.setFont(editor->themeApplier.interBoldFor(40));
g.setColour(editor->themeColor(theme::ColorMap::generic_content_highest));
g.drawText("Welcome to ShortcircuitXT", bd.reduced(10), juce::Justification::centredTop);
g.setColour(editor->themeColor(theme::ColorMap::warning_1a));
g.drawText("Pre-Alpha Release", bd.reduced(10).translated(0, 50),
juce::Justification::centredTop);

g.setFont(editor->themeApplier.interLightFor(22));
g.setColour(editor->themeColor(theme::ColorMap::generic_content_high));
auto tb = bd.reduced(10, 120);
g.drawFittedText(txt, tb, juce::Justification::topLeft, 50);
}
} // namespace scxt::ui
57 changes: 57 additions & 0 deletions src-ui/components/WelcomeScreen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Shortcircuit XT - a Surge Synth Team product
*
* A fully featured creative sampler, available as a standalone
* and plugin for multiple platforms.
*
* Copyright 2019 - 2024, Various authors, as described in the github
* transaction log.
*
* ShortcircuitXT is released under the Gnu General Public Licence
* V3 or later (GPL-3.0-or-later). The license is found in the file
* "LICENSE" in the root of this repository or at
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* Individual sections of code which comprises ShortcircuitXT in this
* repository may also be used under an MIT license. Please see the
* section "Licensing" in "README.md" for details.
*
* ShortcircuitXT is inspired by, and shares code with, the
* commercial product Shortcircuit 1 and 2, released by VemberTech
* in the mid 2000s. The code for Shortcircuit 2 was opensourced in
* 2020 at the outset of this project.
*
* All source for ShortcircuitXT is available at
* https://github.com/surge-synthesizer/shortcircuit-xt
*/

#ifndef SCXT_SRC_UI_COMPONENTS_WELCOMESCREEN_H
#define SCXT_SRC_UI_COMPONENTS_WELCOMESCREEN_H

#include <juce_gui_basics/juce_gui_basics.h>
#include "sst/jucegui/components/TextPushButton.h"
#include "HasEditor.h"

namespace scxt::ui
{
struct WelcomeScreen : juce::Component, HasEditor
{
/*
* If you update this version the user will see the welcome screen
* on their next startup even if they dismissed a prior version
*/
static constexpr int welcomeVersion{1};
WelcomeScreen(SCXTEditor *e);

void visibilityChanged() override;
void mouseDown(const juce::MouseEvent &e) override { okGotItDontShowAgain(); }
void paint(juce::Graphics &g) override;

bool keyPressed(const juce::KeyPress &key) override;

void okGotItDontShowAgain();

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WelcomeScreen);
};
} // namespace scxt::ui
#endif // SHORTCIRCUITXT_WELCOMESCREEN_H
33 changes: 28 additions & 5 deletions src/infrastructure/md5support.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
//
// Created by Paul Walker on 8/5/24.
//
/*
* Shortcircuit XT - a Surge Synth Team product
*
* A fully featured creative sampler, available as a standalone
* and plugin for multiple platforms.
*
* Copyright 2019 - 2024, Various authors, as described in the github
* transaction log.
*
* ShortcircuitXT is released under the Gnu General Public Licence
* V3 or later (GPL-3.0-or-later). The license is found in the file
* "LICENSE" in the root of this repository or at
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* Individual sections of code which comprises ShortcircuitXT in this
* repository may also be used under an MIT license. Please see the
* section "Licensing" in "README.md" for details.
*
* ShortcircuitXT is inspired by, and shares code with, the
* commercial product Shortcircuit 1 and 2, released by VemberTech
* in the mid 2000s. The code for Shortcircuit 2 was opensourced in
* 2020 at the outset of this project.
*
* All source for ShortcircuitXT is available at
* https://github.com/surge-synthesizer/shortcircuit-xt
*/

#ifndef SHORTCIRCUITXT_MD5SUPPORT_H
#define SHORTCIRCUITXT_MD5SUPPORT_H
#ifndef SCXT_SRC_INFRASTRUCTURE_MD5SUPPORT_H
#define SCXT_SRC_INFRASTRUCTURE_MD5SUPPORT_H

#include <string>
#include "filesystem_import.h"
Expand Down
3 changes: 3 additions & 0 deletions src/infrastructure/user_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum DefaultKeys
invertScroll,
showKnobs,
colormapId,
welcomeScreenSeen,

nKeys // must be last K?
};
Expand All @@ -58,6 +59,8 @@ inline std::string defaultKeyToString(DefaultKeys k)
return "invertScroll";
case showKnobs:
return "showKnobs";
case welcomeScreenSeen:
return "welcomeScreenSeen";
default:
std::terminate(); // for now
}
Expand Down

0 comments on commit 6545914

Please sign in to comment.