aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_fomod_plus/installer/ui/ScaleLabel.cpp
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-14 02:45:12 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-14 02:45:25 -0600
commit817e8f5cd26739c69d930d21cd9dc4c0b6e4984e (patch)
tree52aed11d6751bb7d20b06acf197d56fac113203d /libs/installer_fomod_plus/installer/ui/ScaleLabel.cpp
parent51a9f8f197727f00896e5de44569b098923527dd (diff)
Add FUSE external mapping support, BG3/Oblivion Remastered fixes, fomod-plus and NaK integration
FUSE VFS now deploys non-data-dir mod mappings (Paks, OBSE, UE4SS, etc.) via real symlinks and injects file-level data-dir mappings (plugins.txt, loadorder.txt) into the VFS tree. Fixes game launches for Oblivion Remastered (Root Builder path resolution, script extender support) and BG3 (Wine prefix documents directory, file mapper symlinks on Linux). Vendors mo2-fomod-plus plugin and NaK crate for FOMOD installer and game finder/runtime support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/installer_fomod_plus/installer/ui/ScaleLabel.cpp')
-rw-r--r--libs/installer_fomod_plus/installer/ui/ScaleLabel.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/libs/installer_fomod_plus/installer/ui/ScaleLabel.cpp b/libs/installer_fomod_plus/installer/ui/ScaleLabel.cpp
new file mode 100644
index 0000000..3a33640
--- /dev/null
+++ b/libs/installer_fomod_plus/installer/ui/ScaleLabel.cpp
@@ -0,0 +1,120 @@
+#include "ScaleLabel.h"
+#include <QResizeEvent>
+#include <iostream>
+
+// Taken from https://github.com/ModOrganizer2/modorganizer-installer_fomod/blob/master/src/scalelabel.h
+static bool isResourceMovie(const QString& path)
+{
+ const auto formats = QMovie::supportedFormats();
+ return std::ranges::any_of(formats, [&path](const QByteArray& format) {
+ return path.endsWith("." + QString::fromUtf8(format));
+ });
+}
+
+void ScaleLabel::setScalableResource(const QString& path)
+{
+ if (const auto m = movie()) {
+ setMovie(nullptr);
+ delete m;
+ mOriginalMovieSize = QSize();
+ }
+ if (!pixmap().isNull()) {
+ setPixmap(QPixmap());
+ mUnscaledImage = QImage();
+ }
+
+ if (path.isEmpty()) {
+ return;
+ }
+
+ if (isResourceMovie(path)) {
+ setScalableMovie(path);
+ } else {
+ setScalableImage(path);
+ }
+}
+
+void ScaleLabel::setStatic(const bool isStatic)
+{
+ misStatic = isStatic;
+
+ if (const auto m = movie()) {
+ if (isStatic) {
+ m->stop();
+ } else {
+ m->start();
+ }
+ }
+}
+
+void ScaleLabel::setScalableMovie(const QString& path)
+{
+ const auto m = new QMovie(path);
+ if (!m->isValid()) {
+ qWarning(">%s< is an invalid movie. Reason: %s", qUtf8Printable(path),
+ m->lastErrorString().toStdString().c_str());
+ delete m;
+ return;
+ }
+
+ m->setParent(this);
+ setMovie(m);
+ m->start();
+ m->stop();
+ mOriginalMovieSize = m->currentImage().size();
+
+ m->setScaledSize(mOriginalMovieSize.scaled(size(), Qt::KeepAspectRatio));
+ if (!misStatic) {
+ m->start();
+ }
+ mHasResource = true;
+}
+
+void ScaleLabel::setScalableImage(const QString& path)
+{
+ if (const QImage image(path); image.isNull()) {
+ qWarning(">%s< is a null image", qUtf8Printable(path));
+ } else {
+ mUnscaledImage = image;
+ setPixmap(QPixmap::fromImage(image).scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ mHasResource = true;
+ }
+}
+
+void ScaleLabel::resizeEvent(QResizeEvent* event)
+{
+ if (const auto m = movie()) {
+ m->stop();
+ m->setScaledSize(mOriginalMovieSize.scaled(event->size(), Qt::KeepAspectRatio));
+ m->start();
+
+ // We can't just skip the start() above since that is what triggers the label to
+ // resize the movie The only way to resize the movie but keep it paused is to start
+ // and then re-stop it
+ if (misStatic) {
+ m->stop();
+ }
+ }
+ if (const auto p = pixmap(); !p.isNull()) {
+ setPixmap(
+ QPixmap::fromImage(mUnscaledImage).scaled(event->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ }
+}
+
+void ScaleLabel::showEvent(QShowEvent* event)
+{
+ QLabel::showEvent(event);
+
+ if (const auto m = movie()) {
+ m->stop();
+ m->setScaledSize(mOriginalMovieSize.scaled(size(), Qt::KeepAspectRatio));
+ m->start();
+
+ if (misStatic) {
+ m->stop();
+ }
+ }
+ if (const auto p = pixmap(); !p.isNull()) {
+ setPixmap(QPixmap::fromImage(mUnscaledImage).scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ }
+} \ No newline at end of file