summaryrefslogtreecommitdiff
path: root/src/modinfoforeign.cpp
blob: 6ac66c67461982ad11a8558e500982149ac89c4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "modinfoforeign.h"

#include "iplugingame.h"
#include "utility.h"

#include <QApplication>

using namespace MOBase;
using namespace MOShared;

QString ModInfoForeign::name() const
{
  return m_Name;
}

QDateTime ModInfoForeign::creationTime() const
{
  return m_CreationTime;
}

QString ModInfoForeign::absolutePath() const
{
  //I ought to store this, it's used elsewhere
  IPluginGame const *game = qApp->property("managed_game").value<IPluginGame *>();
  return game->dataDirectory().absolutePath();
}

std::vector<ModInfo::EFlag> ModInfoForeign::getFlags() const
{
  std::vector<ModInfo::EFlag> result = ModInfoWithConflictInfo::getFlags();
  result.push_back(FLAG_FOREIGN);

  if (m_PluginSelected) {
    result.push_back(ModInfo::FLAG_PLUGIN_SELECTED);
  }

  return result;
}

int ModInfoForeign::getHighlight() const
{
  return m_PluginSelected ? ModInfo::HIGHLIGHT_PLUGIN : ModInfo::HIGHLIGHT_NONE;
}

QString ModInfoForeign::getDescription() const
{
  return tr("This pseudo mod represents content managed outside MO. It isn't modified by MO.");
}

ModInfoForeign::ModInfoForeign(const QString &modName,
                               const QString &referenceFile,
                               const QStringList &archives,
                               ModInfo::EModType modType,
                               DirectoryEntry **directoryStructure)
    : ModInfoWithConflictInfo(directoryStructure),
      m_ReferenceFile(referenceFile), m_Archives(archives) {
  m_CreationTime = QFileInfo(referenceFile).created();
  switch (modType) {
  case ModInfo::EModType::MOD_DLC:
    m_Name = tr("DLC: ") + modName;
    break;
  case ModInfo::EModType::MOD_CC:
    m_Name = tr("Creation Club: ") + modName;
    break;
  default:
    m_Name = tr("Unmanaged: ") + modName;
  }
}