Merge remote-tracking branch 'upstream/master' into first-run-tutorial

This commit is contained in:
Lukas Brübach 2026-10-11 15:14:26 +02:00
commit f5826d9d6f
1395 changed files with 67177 additions and 10446 deletions

View file

@ -1,7 +1,47 @@
#include "interface_settings.h"
#include "libcockatrice/settings/settings_manager.h"
#include "libcockatrice/utility/card_ref.h"
#include "libcockatrice/utility/playmat_params.h"
#include <QChar>
#include <QDir>
#include <QFileInfo>
#include <QList>
#include <QVariant>
#include <QtGlobal>
class QObject;
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)
@ -10,7 +50,7 @@ InterfaceSettings::InterfaceSettings(const QString &settingPath, QObject *parent
bool InterfaceSettings::getUseTearOffMenus() const
{
return getValue("useTearOffMenus", QString(), QString(), true).toBool();
return getValue("useTearOffMenus", QString(), QString(), false).toBool();
}
int InterfaceSettings::getCardViewInitialRowsMax() const
@ -123,6 +163,11 @@ qreal InterfaceSettings::getFastForwardSpeed() const
return getValue("fastForwardSpeed", "replay", QString(), 10).toReal();
}
bool InterfaceSettings::getSkipEmptySections() const
{
return getValue("skipEmptySections", "replay", QString(), false).toBool();
}
bool InterfaceSettings::getLeftJustified() const
{
return getValue("leftJustified", QString(), QString(), false).toBool();
@ -171,6 +216,51 @@ bool InterfaceSettings::getTutorialCompleted() const
return getValue("tutorialCompleted", QString(), QString(), false).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();
}
bool InterfaceSettings::getBattlefieldFlashEnabled() const
{
return getValue("battlefieldFlashEnabled", QString(), QString(), true).toBool();
}
QStringList InterfaceSettings::getUserListExpandedSections() const
{
return getValue("userListExpandedSections", QString(), QString(), QStringList({"buddy", "online", "ignore"}))
.toStringList();
}
void InterfaceSettings::setUseTearOffMenus(bool _useTearOffMenus)
{
setValue(_useTearOffMenus, "useTearOffMenus");
@ -295,6 +385,11 @@ void InterfaceSettings::setFastForwardSpeed(qreal _value)
setValue(_value, "fastForwardSpeed", "replay");
}
void InterfaceSettings::setSkipEmptySections(bool _value)
{
setValue(_value, "skipEmptySections", "replay");
}
void InterfaceSettings::setLeftJustified(bool _leftJustified)
{
setValue(_leftJustified, "leftJustified");
@ -337,3 +432,60 @@ void InterfaceSettings::setTutorialCompleted(bool value)
{
setValue(value, "tutorialCompleted");
}
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");
emit lifeCounterAnimationsEnabledChanged(_lifeCounterAnimationsEnabled);
}
void InterfaceSettings::setBattlefieldFlashEnabled(bool _battlefieldFlashEnabled)
{
setValue(_battlefieldFlashEnabled, "battlefieldFlashEnabled");
emit battlefieldFlashEnabledChanged(_battlefieldFlashEnabled);
}
void InterfaceSettings::setUserListExpandedSections(const QStringList &sections)
{
setValue(sections, "userListExpandedSections");
}