Version revert logic improvements, colorful icons for mod lists and resource pack list.
Icons are from Oxygen.
This commit is contained in:
		| @@ -49,8 +49,8 @@ QList<BasePage *> LegacyInstance::getPages() | ||||
| 	QList<BasePage *> values; | ||||
| 	values.append(new LegacyUpgradePage(this)); | ||||
| 	values.append(new LegacyJarModPage(this)); | ||||
| 	values.append(new ModFolderPage(loaderModList(), "mods", "centralmods", tr("Loader Mods"))); | ||||
| 	values.append(new ModFolderPage(coreModList(), "coremods", "viewfolder", tr("Core Mods"))); | ||||
| 	values.append(new ModFolderPage(loaderModList(), "mods", "plugin-blue", tr("Loader Mods"))); | ||||
| 	values.append(new ModFolderPage(coreModList(), "coremods", "plugin-green", tr("Core Mods"))); | ||||
| 	values.append(new TexturePackPage(this)); | ||||
| 	return values; | ||||
| } | ||||
|   | ||||
| @@ -60,8 +60,8 @@ QList<BasePage *> OneSixInstance::getPages() | ||||
| { | ||||
| 	QList<BasePage *> values; | ||||
| 	values.append(new VersionPage(this)); | ||||
| 	values.append(new ModFolderPage(loaderModList(), "mods", "centralmods", tr("Loader Mods"))); | ||||
| 	values.append(new ModFolderPage(coreModList(), "coremods", "viewfolder", tr("Core Mods"))); | ||||
| 	values.append(new ModFolderPage(loaderModList(), "mods", "plugin-blue", tr("Loader Mods"))); | ||||
| 	values.append(new ModFolderPage(coreModList(), "coremods", "plugin-green", tr("Core Mods"))); | ||||
| 	values.append(new ResourcePackPage(this)); | ||||
| 	values.append(new TexturePackPage(this)); | ||||
| 	return values; | ||||
|   | ||||
| @@ -161,12 +161,35 @@ bool InstanceVersion::isVanilla() | ||||
| 		return false; | ||||
| 	if(QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json"))) | ||||
| 		return false; | ||||
| 	if(QFile::exists(PathCombine(m_instance->instanceRoot(), "version.json"))) | ||||
| 		return false; | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| bool InstanceVersion::revertToVanilla() | ||||
| { | ||||
| 	beginResetModel(); | ||||
| 	// remove custom.json, if present | ||||
| 	QString customPath = PathCombine(m_instance->instanceRoot(), "custom.json"); | ||||
| 	if(QFile::exists(customPath)) | ||||
| 	{ | ||||
| 		if(!QFile::remove(customPath)) | ||||
| 		{ | ||||
| 			endResetModel(); | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 	// remove version.json, if present | ||||
| 	QString versionPath = PathCombine(m_instance->instanceRoot(), "version.json"); | ||||
| 	if(QFile::exists(versionPath)) | ||||
| 	{ | ||||
| 		if(!QFile::remove(versionPath)) | ||||
| 		{ | ||||
| 			endResetModel(); | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 	// remove patches, if present | ||||
| 	auto it = VersionPatches.begin(); | ||||
| 	while (it != VersionPatches.end()) | ||||
| 	{ | ||||
| @@ -195,9 +218,40 @@ bool InstanceVersion::revertToVanilla() | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| bool InstanceVersion::usesLegacyCustomJson() | ||||
| bool InstanceVersion::hasDeprecatedVersionFiles() | ||||
| { | ||||
| 	return QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json")); | ||||
| 	if(QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json"))) | ||||
| 		return true; | ||||
| 	if(QFile::exists(PathCombine(m_instance->instanceRoot(), "version.json"))) | ||||
| 		return true; | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| bool InstanceVersion::removeDeprecatedVersionFiles() | ||||
| { | ||||
| 	beginResetModel(); | ||||
| 	// remove custom.json, if present | ||||
| 	QString customPath = PathCombine(m_instance->instanceRoot(), "custom.json"); | ||||
| 	if(QFile::exists(customPath)) | ||||
| 	{ | ||||
| 		if(!QFile::remove(customPath)) | ||||
| 		{ | ||||
| 			endResetModel(); | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 	// remove version.json, if present | ||||
| 	QString versionPath = PathCombine(m_instance->instanceRoot(), "version.json"); | ||||
| 	if(QFile::exists(versionPath)) | ||||
| 	{ | ||||
| 		if(!QFile::remove(versionPath)) | ||||
| 		{ | ||||
| 			endResetModel(); | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 	endResetModel(); | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| QList<std::shared_ptr<OneSixLibrary> > InstanceVersion::getActiveNormalLibs() | ||||
|   | ||||
| @@ -51,6 +51,11 @@ public: | ||||
| 	// remove any customizations on top of vanilla | ||||
| 	bool revertToVanilla(); | ||||
| 	 | ||||
| 	// does this version consist of obsolete files? | ||||
| 	bool hasDeprecatedVersionFiles(); | ||||
| 	// remove obsolete files | ||||
| 	bool removeDeprecatedVersionFiles(); | ||||
| 	 | ||||
| 	// does this version have an FTB pack patch file? | ||||
| 	bool hasFtbPack(); | ||||
| 	// remove FTB pack | ||||
| @@ -61,9 +66,6 @@ public: | ||||
| 	void installJarMods(QStringList selectedFiles); | ||||
| 	void installJarModByFilename(QString filepath); | ||||
|  | ||||
| 	// does this version still use a legacy custom.json file? | ||||
| 	bool usesLegacyCustomJson(); | ||||
|  | ||||
| 	enum MoveDirection { MoveUp, MoveDown }; | ||||
| 	void move(const int index, const MoveDirection direction); | ||||
| 	void resetOrder(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Petr Mrázek
					Petr Mrázek