summaryrefslogtreecommitdiff
path: root/src/profile.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-03-27 20:48:33 +0100
committerTannin <devnull@localhost>2013-03-27 20:48:33 +0100
commite0eb97922d5ef4a1448e76f13374ebfda7fda403 (patch)
tree00f32ad3f680e51a210bee8155624d71f608bb15 /src/profile.cpp
parent74c75e60d67b66a63225239c1f6b1403662857aa (diff)
- added hooks for getFileVersion* functions
- automatic donwload retry - support for storing multiple download urls - improved "query info" functionality - some cleanup to download manager code - external fomod installer dialog are now brought to front - added shell... functions to have windows handle problematic situations - added visual clue when filters are active - esps are now automatically activated when installing a mod - added option to never endorse a mod - added "previous" and "next" buttons to mod info dialog - improved the way messagedialog text is shortened - coloring in mod info dialog now visible in other color schemes - plugin list is now saved automatically - vanilla bsas are now enabled even if they are not listed in the ini file - bugfix: setting mod to maximum now doesn't try to place the mod below overwrite
Diffstat (limited to 'src/profile.cpp')
-rw-r--r--src/profile.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/profile.cpp b/src/profile.cpp
index 67fd1e13..d67c6b8f 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -38,12 +38,15 @@ using namespace MOBase;
using namespace MOShared;
Profile::Profile()
+ : m_SaveTimer(NULL)
{
initTimer();
}
Profile::Profile(const QString &name, bool useDefaultSettings)
+ : m_SaveTimer(NULL)
{
+ initTimer();
QString profilesDir = QDir::fromNativeSeparators(ToQString(GameInfo::instance().getProfilesDir()));
QDir profileBase(profilesDir);
@@ -63,17 +66,17 @@ Profile::Profile(const QString &name, bool useDefaultSettings)
GameInfo::instance().createProfile(ToWString(fullPath), useDefaultSettings);
} catch (...) {
// clean up in case of an error
- removeDir(profileBase.absoluteFilePath(name));
+ shellDelete(QStringList(profileBase.absoluteFilePath(name)), NULL);
throw;
}
- initTimer();
refreshModStatus();
}
Profile::Profile(const QDir& directory)
- : m_Directory(directory)
+ : m_Directory(directory), m_SaveTimer(NULL)
{
+ initTimer();
if (!QFile::exists(m_Directory.filePath("modlist.txt"))) {
throw std::runtime_error(QObject::tr("modlist.txt missing").toUtf8().constData());
}
@@ -83,13 +86,12 @@ Profile::Profile(const QDir& directory)
if (!QFile::exists(getIniFileName())) {
reportError(QObject::tr("\"%1\" is missing").arg(getIniFileName()));
}
- initTimer();
refreshModStatus();
}
Profile::Profile(const Profile& reference)
- : m_Directory(reference.m_Directory)
+ : m_Directory(reference.m_Directory), m_SaveTimer(NULL)
{
initTimer();
refreshModStatus();
@@ -173,17 +175,11 @@ void Profile::createTweakedIniFile()
QFileInfo iniInfo(getIniFileName());
QString tweakedIni = iniInfo.absolutePath() + "/initweaks.ini";
-// QFile iniFile(tweakedIni);
- // workaround: the fallout nv launcher seems to mark the file read-only. crazy...
-/* ::SetFileAttributesW(ToWString(tweakedIni).c_str(), FILE_ATTRIBUTE_NORMAL);
- QFile(tweakedIni).remove();
- if (!iniFile.copy(tweakedIni)) {
- reportError(tr("failed to apply ini tweaks").append(": ").append(iniFile.errorString()));
+ if (!shellDelete(QStringList(tweakedIni), NULL)) {
+ reportError(tr("failed to update tweaked ini file, wrong settings may be used: %1").arg(windowsErrorString(::GetLastError())));
return;
- }*/
-
- QFile::remove(tweakedIni); // remove the old ini tweaks
+ }
for (unsigned int i = 0; i < m_ModStatus.size(); ++i) {
if (m_ModStatus[i].m_Enabled) {
@@ -391,11 +387,18 @@ int Profile::getModPriority(unsigned int index) const
void Profile::setModPriority(unsigned int index, int &newPriority)
{
- int newPriorityTemp = (std::max)(0, (std::min<int>)(m_ModStatus.size() - 1, newPriority));
if (m_ModStatus[index].m_Overwrite) {
// can't change priority of the overwrite
return;
}
+
+ int newPriorityTemp = (std::max)(0, (std::min<int>)(m_ModStatus.size() - 1, newPriority));
+
+ // don't try to place below overwrite
+ while (m_ModStatus[m_ModIndexByPriority[newPriorityTemp]].m_Overwrite) {
+ --newPriorityTemp;
+ }
+
int oldPriority = m_ModStatus[index].m_Priority;
if (newPriorityTemp > oldPriority) {
// priority is higher than the old, so the gap we left is in lower priorities
@@ -641,7 +644,7 @@ bool Profile::enableLocalSaves(bool enable)
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
QMessageBox::Cancel);
if (res == QMessageBox::Yes) {
- removeDir(m_Directory.absoluteFilePath("_saves"));
+ shellDelete(QStringList(m_Directory.absoluteFilePath("_saves")), NULL);
} else if (res == QMessageBox::No) {
m_Directory.rename("saves", "_saves");
} else {