Improve: revise splitscreen tutorial (try 2) (#7341)

<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Show the splitscreen tutorial to only new Mudlet players (who have had
Mudlet installed for less than 6 months) and only the first 3 times
ever.
#### Motivation for adding to Mudlet
Showing it once per profile launch was a little too much.
#### Other info (issues closed, discussion etc)
I'm not sure if the first 3 times ever is enough, but let's judge and
see based on feedback in Discord.

Fixes https://github.com/Mudlet/Mudlet/issues/7336.
This commit is contained in:
Vadim Peretokin 2024-09-04 09:49:31 +02:00 committed by GitHub
parent 47ee7271ed
commit ae0564e6e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 3 deletions

View file

@ -683,7 +683,6 @@ public:
QMap<QString, QKeySequence*> profileShortcuts;
bool mTutorialForCompactLineAlreadyShown;
bool mTutorialForSplitscreenScrollbackAlreadyShown = false;
bool mAnnounceIncomingText = true;
bool mAdvertiseScreenReader = false;

View file

@ -1023,14 +1023,14 @@ void TConsole::scrollUp(int lines)
if (lowerAppears) {
QTimer::singleShot(0, this, [this]() { mUpperPane->scrollUp(mLowerPane->getRowCount()); });
if (!mpHost->mTutorialForSplitscreenScrollbackAlreadyShown) {
if (mudlet::self()->showSplitscreenTutorial()) {
#if defined(Q_OS_MACOS)
const QString infoMsg = tr("[ INFO ] - Split-screen scrollback activated. Press <⌘>+<ENTER> to cancel.");
#else
const QString infoMsg = tr("[ INFO ] - Split-screen scrollback activated. Press <CTRL>+<ENTER> to cancel.");
#endif
mpHost->postMessage(infoMsg);
mpHost->mTutorialForSplitscreenScrollbackAlreadyShown = true;
mudlet::self()->showedSplitscreenTutorial();
}
}
mUpperPane->scrollUp(lines);

View file

@ -1960,6 +1960,7 @@ void mudlet::readLateSettings(const QSettings& settings)
setToolBarIconSize(settings.value(qsl("mainiconsize")).toInt());
}
setEditorTreeWidgetIconSize(settings.value("tefoldericonsize", QVariant(3)).toInt());
mScrollbackTutorialsShown = settings.value("scrollbackTutorialsShown", QVariant(0)).toInt();
// We have abandoned previous "showMenuBar" / "showToolBar" booleans
// although we provide a backwards compatible value
// of: (bool) showXXXXBar = (XXXXBarVisibilty != visibleNever) for, until,
@ -2109,6 +2110,7 @@ void mudlet::writeSettings()
settings.setValue("size", size());
settings.setValue("mainiconsize", mToolbarIconSize);
settings.setValue("tefoldericonsize", mEditorTreeWidgetIconSize);
settings.setValue("scrollbackTutorialsShown", mScrollbackTutorialsShown);
// This pair are only for backwards compatibility and will be ignored for
// this and future Mudlet versions - suggest they get removed in Mudlet 4.x
settings.setValue("showMenuBar", mMenuBarVisibility != visibleNever);
@ -4981,6 +4983,40 @@ void mudlet::armForceClose()
});
}
bool mudlet::showSplitscreenTutorial()
{
return !experiencedMudletPlayer() && mScrollbackTutorialsShown < mScrollbackTutorialsMax;
}
void mudlet::showedSplitscreenTutorial()
{
mScrollbackTutorialsShown++;
}
// returns true if the Mudlet player is considered 'experienced' and doesn't need to be shown the basic
// tutorial tips, such as splitscreen cancel shortcut
bool mudlet::experiencedMudletPlayer()
{
static std::optional<bool> cachedResult;
if (cachedResult.has_value()) {
return cachedResult.value();
}
// crude metric to check if the player is experienced in Mudlet: see if any of the profiles is more than 6mo old
QDir profilesDir(mudlet::getMudletPath(mudlet::profilesPath));
QFileInfoList entries = profilesDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
QDateTime sixMonthsAgo = QDateTime::currentDateTime().addMonths(-6);
for (const QFileInfo &entry : entries) {
if (entry.lastModified() < sixMonthsAgo) {
cachedResult = true;
return true;
}
}
cachedResult = false;
return false;
}
dlgTriggerEditor* mudlet::createMudletEditor()
{
Host* pHost = getActiveHost();

View file

@ -418,6 +418,9 @@ public:
bool muteGame() const { return mMuteGame; }
bool mediaMuted() const { return mMuteAPI && mMuteGame; }
bool mediaUnmuted() const { return !mMuteAPI && !mMuteGame; }
auto showSplitscreenTutorial() -> bool;
auto showedSplitscreenTutorial() -> void;
auto experiencedMudletPlayer() -> bool;
Appearance mAppearance = Appearance::systemSetting;
// 1 (of 2) needed to work around a (Windows/MacOs specific QStyleFactory)
@ -426,6 +429,7 @@ public:
// approximate max duration that 'Copy as image' is allowed to take
// (seconds):
int mCopyAsImageTimeout = 3;
// A list of potential dictionary languages - probably will cover a much
// wider range of languages compared to the translations - and is intended
// for Dictionary identification - there is a request for users to submit
@ -738,6 +742,11 @@ private:
QMap<Host*, QToolBar*> mUserToolbarMap;
// The collection of words in what mpHunspell_sharedDictionary points to:
QSet<QString> mWordSet_shared;
// amount of times the shortcut to cancel split screen has been shown help educate new users
int mScrollbackTutorialsShown = 0;
// show the split screen tutorial maximum 3 times on a new Mudlet
static const int mScrollbackTutorialsMax = 3;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(mudlet::controlsVisibility)