summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorAl12rs <gabriel.cortesi@outlook.com>2018-03-12 19:53:43 +0100
committerAl12rs <gabriel.cortesi@outlook.com>2018-03-12 20:53:33 +0100
commit9f61ef5c9e6c8884a14b7d6f1507199f61a64377 (patch)
tree35e632d63a8fc7964f3431495fd1fb695f8458d3 /src/mainwindow.cpp
parent887d464f2c02d6f2f43e554fc35b1ae16c4bcf6e (diff)
Added a check to the preview function to handle tha case of the file beeing from the actual data folder instead of a mod.
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 83a12437..bdf79bd5 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3929,10 +3929,22 @@ void MainWindow::previewDataFile()
// what we have is an absolute path to the file in its actual location (for the primary origin)
// what we want is the path relative to the virtual data directory
- // crude: we search for the next slash after the base mod directory to skip everything up to the data-relative directory
- int offset = m_OrganizerCore.settings().getModDirectory().size() + 1;
- offset = fileName.indexOf("/", offset);
- fileName = fileName.mid(offset + 1);
+ // we need to look in the virtual directory for the file to make sure the info is up to date.
+
+ // check if the file comes from the actual data folder instead of a mod
+ QDir gameDirectory = m_OrganizerCore.managedGame()->dataDirectory().absolutePath();
+ QString relativePath = gameDirectory.relativeFilePath(fileName);
+ if (!relativePath.startsWith("..")) {
+ fileName = relativePath;
+ }
+ else {
+ // crude: we search for the next slash after the base mod directory to skip everything up to the data-relative directory
+ int offset = m_OrganizerCore.settings().getModDirectory().size() + 1;
+ offset = fileName.indexOf("/", offset);
+ fileName = fileName.mid(offset + 1);
+ }
+
+
const FileEntry::Ptr file = m_OrganizerCore.directoryStructure()->searchFile(ToWString(fileName), nullptr);