Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new Skip File & Skip Directory in usvfs #2033

Merged
merged 9 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 154 additions & 84 deletions src/organizer_en.ts
Twinki14 marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/organizercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,14 @@ void OrganizerCore::updateVFSParams(log::Levels logLevel,
env::CoreDumpTypes coreDumpType,
const QString& crashDumpsPath,
std::chrono::seconds spawnDelay,
QString executableBlacklist)
QString executableBlacklist,
const QString& skipFileSuffixes,
Twinki14 marked this conversation as resolved.
Show resolved Hide resolved
const QString& skipDirectories)
{
setGlobalCoreDumpType(coreDumpType);

m_USVFS.updateParams(logLevel, coreDumpType, crashDumpsPath, spawnDelay,
executableBlacklist);
executableBlacklist, skipFileSuffixes, skipDirectories);
}

void OrganizerCore::setLogLevel(log::Levels level)
Expand All @@ -484,7 +486,7 @@ void OrganizerCore::setLogLevel(log::Levels level)
updateVFSParams(
m_Settings.diagnostics().logLevel(), m_Settings.diagnostics().coreDumpType(),
QString::fromStdWString(getGlobalCoreDumpPath()),
m_Settings.diagnostics().spawnDelay(), m_Settings.executablesBlacklist());
m_Settings.diagnostics().spawnDelay(), m_Settings.executablesBlacklist(), m_Settings.skipFileSuffixes(), m_Settings.skipDirectories());

log::getDefault().setLevel(m_Settings.diagnostics().logLevel());
}
Expand Down
3 changes: 2 additions & 1 deletion src/organizercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ class OrganizerCore : public QObject, public MOBase::IPluginDiagnose

void updateVFSParams(MOBase::log::Levels logLevel, env::CoreDumpTypes coreDumpType,
const QString& coreDumpsPath, std::chrono::seconds spawnDelay,
QString executableBlacklist);
QString executableBlacklist, const QString& skipFileSuffixes,
const QString& skipDirectories);

void setLogLevel(MOBase::log::Levels level);

Expand Down
24 changes: 24 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ void Settings::setExecutablesBlacklist(const QString& s)
set(m_Settings, "Settings", "executable_blacklist", s);
}

QString Settings::skipFileSuffixes() const
{
static const QString def = (QStringList() << ".mohidden").join(";");

return get<QString>(m_Settings, "Settings", "skip_file_suffixes", def);
}

void Settings::setSkipFileSuffixes(const QString& s)
{
set(m_Settings, "Settings", "skip_file_suffixes", s);
}

QString Settings::skipDirectories() const
{
static const QString def = (QStringList() << ".git").join(";");

return get<QString>(m_Settings, "Settings", "skip_directories", def);
}

void Settings::setSkipDirectories(const QString& s)
{
set(m_Settings, "Settings", "skip_directories", s);
}

void Settings::setMotdHash(uint hash)
{
set(m_Settings, "General", "motd_hash", hash);
Expand Down
6 changes: 6 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@ class Settings : public QObject
bool isExecutableBlacklisted(const QString& s) const;
void setExecutablesBlacklist(const QString& s);

QString skipFileSuffixes() const;
void setSkipFileSuffixes(const QString& s);

QString skipDirectories() const;
void setSkipDirectories(const QString& s);

// ? looks obsolete, only used by dead code
//
unsigned int motdHash() const;
Expand Down
85 changes: 76 additions & 9 deletions src/settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,60 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bsaDateBtn">
<property name="toolTip">
<string>
For Skyrim, this can be used instead of Archive Invalidation. It should make AI redundant for all Profiles.
For the other games this is not a sufficient replacement for AI!
</string>
</property>
<property name="whatsThis">
<string>
For Skyrim, this can be used instead of Archive Invalidation. It should make AI redundant for all Profiles.
Holt59 marked this conversation as resolved.
Show resolved Hide resolved
For the other games this is not a sufficient replacement for AI!
</string>
</property>
<property name="text">
<string>Back-date BSAs</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/MO/gui/resources/emblem-readonly.png</normaloff>:/MO/gui/resources/emblem-readonly.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_usvfs" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="execBlacklistBtn">
<property name="toolTip">
Expand All @@ -2037,21 +2091,34 @@ programs you are intentionally running.</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="bsaDateBtn">
<widget class="QPushButton" name="skipFileSuffixBtn">
<property name="toolTip">
<string>For Skyrim, this can be used instead of Archive Invalidation. It should make AI redundant for all Profiles.
For the other games this is not a sufficient replacement for AI!</string>
<string>Files to skip or ignore from the virtual file system.</string>
</property>
<property name="whatsThis">
<string>For Skyrim, this can be used instead of Archive Invalidation. It should make AI redundant for all Profiles.
For the other games this is not a sufficient replacement for AI!</string>
<string>Files to skip or ignore from the virtual file system.</string>
</property>
<property name="text">
<string>Back-date BSAs</string>
<string>Skip File Suffixes</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/MO/gui/resources/emblem-readonly.png</normaloff>:/MO/gui/resources/emblem-readonly.png</iconset>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="skipDirectoriesBtn">
<property name="toolTip">
<string>Directories to skip or ignore from the virtual file system.</string>
</property>
<property name="whatsThis">
<string>Directories to skip or ignore from the virtual file system.</string>
</property>
<property name="text">
<string>Skip Directories</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
Expand Down
80 changes: 80 additions & 0 deletions src/settingsdialogworkarounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ WorkaroundsSettingsTab::WorkaroundsSettingsTab(Settings& s, SettingsDialog& d)

// buttons
m_ExecutableBlacklist = settings().executablesBlacklist();
m_SkipFileSuffixes = settings().skipFileSuffixes();
m_SkipDirectories = settings().skipDirectories();

QObject::connect(ui->bsaDateBtn, &QPushButton::clicked, [&] {
on_bsaDateBtn_clicked();
});
QObject::connect(ui->execBlacklistBtn, &QPushButton::clicked, [&] {
on_execBlacklistBtn_clicked();
});
QObject::connect(ui->skipFileSuffixBtn, &QPushButton::clicked, [&] {
on_skipFileSuffixBtn_clicked();
});
QObject::connect(ui->skipDirectoriesBtn, &QPushButton::clicked, [&] {
on_skipDirectoriesBtn_clicked();
});
QObject::connect(ui->resetGeometryBtn, &QPushButton::clicked, [&] {
on_resetGeometryBtn_clicked();
});
Expand Down Expand Up @@ -69,6 +77,8 @@ void WorkaroundsSettingsTab::update()

// buttons
settings().setExecutablesBlacklist(m_ExecutableBlacklist);
settings().setSkipFileSuffixes(m_SkipFileSuffixes);
settings().setSkipDirectories(m_SkipDirectories);
}

bool WorkaroundsSettingsTab::changeBlacklistNow(QWidget* parent, Settings& settings)
Expand Down Expand Up @@ -114,13 +124,83 @@ WorkaroundsSettingsTab::changeBlacklistLater(QWidget* parent, const QString& cur
return blacklist.join(";");
}

std::optional<QString>
WorkaroundsSettingsTab::changeSkipFileSuffixes(QWidget* parent, const QString& current)
{
bool ok = false;

QString result = QInputDialog::getMultiLineText(
parent, QObject::tr("Skip File Suffixes"),
QObject::tr(
"Enter one file suffix per line to be skipped / ignored from the virtual "
"file system.\n"
"Not to be confused with file extensions, file suffixes are simply how the "
"filename ends.\n\n"
"Example:\n"
" .txt - Would skip all files that end with .txt, <any text>.txt\n"
" some_file.txt - Would skip all files that end with some_file.txt, <any text>some_file.txt"),
current.split(";").join("\n"), &ok);

if (!ok) {
return {};
}

QStringList fileSuffixes;
for (auto& suffix : result.split("\n")) {
fileSuffixes << suffix.trimmed();
}

return fileSuffixes.join(";");
}

std::optional<QString>
WorkaroundsSettingsTab::changeSkipDirectories(QWidget* parent, const QString& current)
{
bool ok = false;

QString result = QInputDialog::getMultiLineText(
parent, QObject::tr("Skip Directories"),
QObject::tr(
"Enter one directory per line to be skipped / ignored from the virtual "
"file system.\n\n"
"Example:\n"
" .git\n"
" instructions"),
current.split(";").join("\n"), &ok);

if (!ok) {
return {};
}

QStringList directories;
for (auto& dir : result.split("\n")) {
directories << dir.trimmed();
}

return directories.join(";");
}

void WorkaroundsSettingsTab::on_execBlacklistBtn_clicked()
{
if (auto s = changeBlacklistLater(parentWidget(), m_ExecutableBlacklist)) {
m_ExecutableBlacklist = *s;
}
}

void WorkaroundsSettingsTab::on_skipFileSuffixBtn_clicked()
{
if (auto s = changeSkipFileSuffixes(parentWidget(), m_SkipFileSuffixes)) {
m_SkipFileSuffixes = *s;
}
}

void WorkaroundsSettingsTab::on_skipDirectoriesBtn_clicked()
{
if (auto s = changeSkipDirectories(parentWidget(), m_SkipDirectories)) {
m_SkipDirectories = *s;
}
}

void WorkaroundsSettingsTab::on_bsaDateBtn_clicked()
{
const auto* game = qApp->property("managed_game").value<MOBase::IPluginGame*>();
Expand Down
16 changes: 16 additions & 0 deletions src/settingsdialogworkarounds.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,29 @@ class WorkaroundsSettingsTab : public SettingsTab
static std::optional<QString> changeBlacklistLater(QWidget* parent,
const QString& current);

// shows the blacklist dialog from the given string and returns the new
// blacklist if the user accepted it
//
static std::optional<QString> changeSkipFileSuffixes(QWidget* parent,
const QString& current);

// shows the blacklist dialog from the given string and returns the new
// blacklist if the user accepted it
//
static std::optional<QString> changeSkipDirectories(QWidget* parent,
const QString& current);

void update();

private:
QString m_ExecutableBlacklist;
QString m_SkipFileSuffixes;
QString m_SkipDirectories;

void on_bsaDateBtn_clicked();
void on_execBlacklistBtn_clicked();
void on_skipFileSuffixBtn_clicked();
void on_skipDirectoriesBtn_clicked();
void on_resetGeometryBtn_clicked();
};

Expand Down
34 changes: 33 additions & 1 deletion src/usvfsconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ UsvfsConnector::UsvfsConnector()
BlacklistExecutable(buf.data());
}

usvfsClearSkipFileSuffixes();
for (auto& suffix : s.skipFileSuffixes().split(";")) {
if (suffix.isEmpty()) {
continue;
}
std::wstring buf = suffix.toStdWString();
usvfsAddSkipFileSuffix(buf.data());
}

usvfsClearSkipDirectories();
for (auto& dir : s.skipDirectories().split(";")) {
std::wstring buf = dir.toStdWString();
usvfsAddSkipDirectory(buf.data());
}

ClearLibraryForceLoads();

m_LogWorker.moveToThread(&m_WorkerThread);
Expand Down Expand Up @@ -228,7 +243,9 @@ void UsvfsConnector::updateParams(MOBase::log::Levels logLevel,
env::CoreDumpTypes coreDumpType,
const QString& crashDumpsPath,
std::chrono::seconds spawnDelay,
QString executableBlacklist)
QString executableBlacklist,
const QString& skipFileSuffixes,
const QString& skipDirectories)
{
using namespace std::chrono;

Expand All @@ -248,6 +265,21 @@ void UsvfsConnector::updateParams(MOBase::log::Levels logLevel,
std::wstring buf = exec.toStdWString();
BlacklistExecutable(buf.data());
}

usvfsClearSkipFileSuffixes();
for (auto& suffix : skipFileSuffixes.split(";")) {
if (suffix.isEmpty()) {
continue;
}
std::wstring buf = suffix.toStdWString();
usvfsAddSkipFileSuffix(buf.data());
}

usvfsClearSkipDirectories();
for (auto& dir : skipDirectories.split(";")) {
std::wstring buf = dir.toStdWString();
usvfsAddSkipDirectory(buf.data());
}
}

void UsvfsConnector::updateForcedLibraries(
Expand Down
3 changes: 2 additions & 1 deletion src/usvfsconnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class UsvfsConnector : public QObject

void updateParams(MOBase::log::Levels logLevel, env::CoreDumpTypes coreDumpType,
const QString& crashDumpsPath, std::chrono::seconds spawnDelay,
QString executableBlacklist);
QString executableBlacklist, const QString& skipFileSuffixes,
const QString& skipDirectories);

void updateForcedLibraries(
const QList<MOBase::ExecutableForcedLoadSetting>& forcedLibraries);
Expand Down