[Game] Playmats (#7101)

* [Game] Playmats

Took 19 seconds

Took 1 minute

* [Playmats] Add fixed override and configurable fallbacks to settings.

Took 29 minutes

Took 43 seconds

* Add main to test.

Took 1 minute

Took 29 seconds

* Move settings to own group

Took 11 minutes

* Some attempts to refresh macOS compositor

Took 2 minutes

* Try something else

Took 17 minutes

* Don't manipulate live list

Took 11 minutes

* Change things about resolution, address comments.

Took 45 minutes

Took 12 minutes

* Comments.

Took 14 minutes

Took 8 seconds

* Re-order settings menu location

Took 2 minutes

* Rename PlaymatResolution to Info and add enums

Took 8 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-08-21 10:40:49 +02:00 committed by GitHub
parent 74a454552a
commit 9eafd90a91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 1931 additions and 28 deletions

View file

@ -1,5 +1,35 @@
#include "interface_settings.h"
namespace
{
const QChar PLAYMAT_FIELD_SEP = QChar(0x1F); ///< Separator between PlaymatInfo fields.
QString encodePlaymatInfo(const PlaymatInfo &res)
{
return res.card.name + PLAYMAT_FIELD_SEP + res.card.providerId + PLAYMAT_FIELD_SEP +
QString::number(res.params.marginPctL, 'f', 4) + PLAYMAT_FIELD_SEP +
QString::number(res.params.marginPctR, 'f', 4) + PLAYMAT_FIELD_SEP +
QString::number(res.params.verticalOffset, 'f', 4) + PLAYMAT_FIELD_SEP +
QString::number(res.params.zoom, 'f', 4);
}
PlaymatInfo decodePlaymatInfo(const QString &encoded)
{
const QStringList fields = encoded.split(PLAYMAT_FIELD_SEP);
if (fields.size() != 6) {
return {};
}
PlaymatInfo res;
res.card.name = fields.at(0);
res.card.providerId = fields.at(1);
res.params.marginPctL = fields.at(2).toDouble();
res.params.marginPctR = fields.at(3).toDouble();
res.params.verticalOffset = fields.at(4).toDouble();
res.params.zoom = fields.at(5).toDouble();
return res;
}
} // namespace
InterfaceSettings::InterfaceSettings(const QString &settingPath, QObject *parent)
: SettingsManager(settingPath + "interface.ini", "interface", QString(), parent)
{
@ -160,6 +190,35 @@ bool InterfaceSettings::getShowGameSelectorFilterToolbar() const
return getValue("showGameSelectorFilterToolbar", QString(), QString(), true).toBool();
}
int InterfaceSettings::getPlaymatVisibility() const
{
return qBound(0, getValue("playmatvisibility", QString(), QString(), 2).toInt(), 2);
}
QList<PlaymatInfo> InterfaceSettings::getPlaymatFallbackList() const
{
const QStringList entries = getValue("playmatFallbackList", QString(), QString(), QStringList()).toStringList();
QList<PlaymatInfo> result;
result.reserve(entries.size());
for (const QString &entry : entries) {
const PlaymatInfo res = decodePlaymatInfo(entry);
if (!res.card.isEmpty()) {
result.append(res);
}
}
return result;
}
int InterfaceSettings::getPlaymatMode() const
{
return qBound(0, getValue("playmatMode", QString(), QString(), 1).toInt(), 2);
}
int InterfaceSettings::getPlaymatFallbackBehavior() const
{
return qBound(0, getValue("playmatFallbackBehavior", QString(), QString(), 0).toInt(), 2);
}
bool InterfaceSettings::getLifeCounterAnimationsEnabled() const
{
return getValue("lifeCounterAnimationsEnabled", QString(), QString(), true).toBool();
@ -343,6 +402,46 @@ void InterfaceSettings::setShowGameSelectorFilterToolbar(bool _showGameSelectorF
emit showGameSelectorFilterToolbarChanged(_showGameSelectorFilterToolbar);
}
void InterfaceSettings::setPlaymatVisibility(int _visibility)
{
if (getPlaymatVisibility() == _visibility) {
return;
}
setValue(_visibility, "playmatvisibility");
emit playmatVisibilityChanged(_visibility);
}
void InterfaceSettings::setPlaymatFallbackList(const QList<PlaymatInfo> &_fallbackList)
{
QStringList entries;
entries.reserve(_fallbackList.size());
for (const PlaymatInfo &res : _fallbackList) {
entries.append(encodePlaymatInfo(res));
}
setValue(entries, "playmatFallbackList");
emit playmatSettingsChanged();
}
void InterfaceSettings::setPlaymatMode(int _mode)
{
const int mode = qBound(0, _mode, 2);
if (getPlaymatMode() == mode) {
return;
}
setValue(mode, "playmatMode");
emit playmatSettingsChanged();
}
void InterfaceSettings::setPlaymatFallbackBehavior(int _behavior)
{
const int behavior = qBound(0, _behavior, 2);
if (getPlaymatFallbackBehavior() == behavior) {
return;
}
setValue(behavior, "playmatFallbackBehavior");
emit playmatSettingsChanged();
}
void InterfaceSettings::setLifeCounterAnimationsEnabled(bool _lifeCounterAnimationsEnabled)
{
setValue(_lifeCounterAnimationsEnabled, "lifeCounterAnimationsEnabled");

View file

@ -42,6 +42,10 @@ public:
[[nodiscard]] bool getShowStatusBar() const override;
[[nodiscard]] bool getShowShortcuts() const override;
[[nodiscard]] bool getShowGameSelectorFilterToolbar() const override;
[[nodiscard]] int getPlaymatVisibility() const override;
[[nodiscard]] QList<PlaymatInfo> getPlaymatFallbackList() const override;
[[nodiscard]] int getPlaymatMode() const override;
[[nodiscard]] int getPlaymatFallbackBehavior() const override;
[[nodiscard]] bool getLifeCounterAnimationsEnabled() const override;
[[nodiscard]] bool getBattlefieldFlashEnabled() const override;
[[nodiscard]] QStringList getUserListExpandedSections() const override;
@ -77,6 +81,10 @@ public:
void setShowStatusBar(bool _showStatusBar);
void setShowShortcuts(bool _showShortcuts);
void setShowGameSelectorFilterToolbar(bool _showGameSelectorFilterToolbar);
void setPlaymatVisibility(int _visibility);
void setPlaymatFallbackList(const QList<PlaymatInfo> &_fallbackList);
void setPlaymatMode(int _mode);
void setPlaymatFallbackBehavior(int _behavior);
void setLifeCounterAnimationsEnabled(bool _lifeCounterAnimationsEnabled);
void setBattlefieldFlashEnabled(bool _battlefieldFlashEnabled);
void setUserListExpandedSections(const QStringList &sections);
@ -91,6 +99,8 @@ signals:
void tallyTypeChanged(int type);
void showStatusBarChanged(bool state);
void showGameSelectorFilterToolbarChanged(bool state);
void playmatVisibilityChanged(int visibility);
void playmatSettingsChanged();
void lifeCounterAnimationsEnabledChanged(bool state);
void battlefieldFlashEnabledChanged(bool state);