forked from ProbablyManuel/requiem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ogerboss
committed
Jul 2, 2020
0 parents
commit d88a5bb
Showing
1,201 changed files
with
104,354 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
buildSrc/.gradle | ||
buildSrc/build | ||
distribution | ||
meta.ini | ||
Java/*/build | ||
Java/*/nbproject/private/ | ||
Java/*/dist/ | ||
Java/*/store | ||
.gradle | ||
.idea | ||
*iml | ||
*ipr | ||
*iws | ||
PapyrusLogs | ||
userSetup.gradle | ||
Scripts/*.pex | ||
distribution/* | ||
Java/Reqtificator/src/main/resources/version.properties | ||
documentation/**.aux | ||
documentation/**.log | ||
documentation/*/*.pdf | ||
documentation/*/*.png | ||
Interface/Translations/Requiem_CZECH.txt | ||
Interface/Translations/Requiem_ENGLISH.txt | ||
Interface/Translations/Requiem_FRENCH.txt | ||
Interface/Translations/Requiem_GERMAN.txt | ||
Interface/Translations/Requiem_ITALIAN.txt | ||
Interface/Translations/Requiem_JAPANESE.txt | ||
Interface/Translations/Requiem_POLISH.txt | ||
Interface/Translations/Requiem_RUSSIAN.txt | ||
Interface/Translations/Requiem_SPANISH.txt | ||
.kotlintest | ||
fomod/info.xml | ||
SkyProc Patchers/Requiem/app | ||
SkyProc Patchers/Requiem/legacy/Reqtificator.jar | ||
build/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import skyrim.requiem.build.VersionFileTask | ||
|
||
plugins { | ||
application | ||
java | ||
kotlin("jvm") | ||
id("org.jlleitschuh.gradle.ktlint") | ||
id("org.beryx.jlink") | ||
} | ||
|
||
val reqtificatorDir = objects.directoryProperty() | ||
reqtificatorDir.set(file("$rootDir/SkyProc Patchers/Requiem/app")) | ||
|
||
dependencies { | ||
implementation(kotlin("stdlib-jdk8")) | ||
implementation("com.typesafe:config:1.3.1") | ||
implementation("org.apache.logging.log4j:log4j-api:2.13.0") | ||
implementation("org.apache.logging.log4j:log4j-core:2.13.0") | ||
implementation(project(":Java:SkyProc")) | ||
testImplementation("io.kotlintest:kotlintest-runner-junit5:3.3.2") | ||
testImplementation("io.mockk:mockk:1.9.3") | ||
testImplementation("net.bytebuddy:byte-buddy:1.10.6") | ||
} | ||
|
||
val createVersionFile = tasks.register<VersionFileTask>("createVersionFile") { | ||
val mercurialRevision: String by rootProject.extra | ||
val mercurialBranch: String by rootProject.extra | ||
val mercurialBookmarks: String by rootProject.extra | ||
|
||
group = "build" | ||
description = "store Mercurial revision information in a properties file" | ||
|
||
revision = mercurialRevision | ||
branch = mercurialBranch | ||
tags = mercurialBookmarks | ||
versionFile = file("file:/$projectDir/src/main/resources/version.properties") | ||
} | ||
|
||
tasks.processResources { | ||
dependsOn(createVersionFile) | ||
} | ||
|
||
tasks.jar { | ||
manifest { | ||
attributes( | ||
mapOf( | ||
"Implementation-Title" to "Reqtificator - SkyProc Patcher for the Skyrim mod 'Requiem'", | ||
"Implementation-Version" to archiveVersion | ||
) | ||
) | ||
} | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
} | ||
|
||
val cleanReqtificator = tasks.register<Delete>("cleanReqtificator") { | ||
group = "build" | ||
description = "remove the deployed Reqtificator" | ||
|
||
delete(reqtificatorDir) | ||
delete(file("file:/$projectDir/src/main/resources/version.properties")) | ||
} | ||
|
||
tasks.clean { | ||
dependsOn(cleanReqtificator) | ||
} | ||
|
||
tasks.compileKotlin { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
destinationDir = tasks.compileJava.map { it.destinationDir }.get() | ||
} | ||
tasks.compileTestKotlin { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
val moduleName by project.extra("skyrim.requiem") | ||
|
||
tasks.compileJava { | ||
inputs.property("moduleName", moduleName) | ||
doFirst { | ||
options.compilerArgs = listOf("--module-path", classpath.asPath) | ||
classpath = files() | ||
} | ||
} | ||
|
||
jlink { | ||
setProperty("mainClass", "Reqtificator.Reqtificator") | ||
setProperty("options", listOf("--compress", "2", "--no-header-files", "--no-man-pages")) | ||
setProperty("imageDir", reqtificatorDir) | ||
forceMerge("log4j-api", "config") | ||
|
||
launcher { | ||
name = "launcher_template" | ||
} | ||
} |
243 changes: 243 additions & 0 deletions
243
Java/Reqtificator/src/main/java/Reqtificator/ConsistencyManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package Reqtificator; | ||
|
||
import Reqtificator.exceptions.SetupException; | ||
import Reqtificator.exceptions.SilentException; | ||
import Reqtificator.logging_and_gui.TextManager; | ||
import skyproc.ModListing; | ||
import skyproc.SPDatabase; | ||
import skyproc.SPGlobal; | ||
import skyrim.requiem.fptools.Option; | ||
import skyrim.requiem.gui.PopupTools; | ||
import skyrim.requiem.gui.PopupTools.Companion.PopupType; | ||
import skyrim.requiem.localization.Translatable; | ||
import skyrim.requiem.localization.TextReference; | ||
|
||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.StandardCopyOption; | ||
import java.text.MessageFormat; | ||
import java.util.Calendar; | ||
|
||
/** | ||
* A management class for assigning FormIDs in a consistent way. | ||
* This helper | ||
* class takes care of managing SkyProc's internal consistency files and tries | ||
* to prevent the user from accidentally deleting mandatory auxiliary files to | ||
* continue existing save games when updating Requiem. | ||
* | ||
* @author Ogerboss | ||
*/ | ||
public class ConsistencyManager { | ||
|
||
private TextManager texts; | ||
private final PopupTools popupManager; | ||
private final File backuppath; | ||
private final String consistencyFileName; | ||
private final String MetaFileName = "ConsistencyMetaData.txt"; | ||
|
||
private enum UserReaction implements Translatable { | ||
Cancel { | ||
@Override | ||
public TextReference getText() { | ||
return new TextReference("gui.consistency.cancel"); | ||
} | ||
}, | ||
FreshInstall { | ||
@Override | ||
public TextReference getText() { | ||
return new TextReference("gui.consistency.fresh"); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Create a new ConsistencyManager. | ||
* <p> | ||
* In addition to loading the required strings, this constructor will also | ||
* create the backup directory in My Documents/Skyrim if it doesn't exist | ||
* yet. | ||
* | ||
* @throws SetupException if the My Documents/Skyrim folder was not readable | ||
*/ | ||
public ConsistencyManager(TextManager texts, PopupTools popupManager, String consistencyFileName) | ||
throws SetupException { | ||
this.texts = texts; | ||
this.popupManager = popupManager; | ||
this.consistencyFileName = consistencyFileName; | ||
try { | ||
backuppath = new File(SPGlobal.getMyDocumentsSkyrimFolder(), | ||
"Requiem/"); | ||
if (!backuppath.exists()) { | ||
Files.createDirectory(backuppath.toPath()); | ||
} | ||
} catch (IOException e) { | ||
String message = texts.format( | ||
"patch.consistency.my_documents_not_found", | ||
"My Documents/Skyrim", e.toString()); | ||
throw new SetupException("My Documents not found", message, e); | ||
} | ||
} | ||
|
||
/** | ||
* Find the Consistency file to use and warn user if it is missing. | ||
* <p> | ||
* If the default location doesn't contain any usable consistency file, the | ||
* user is informed about the situation and whether a backup has been found. | ||
* The user can then either abort the process to recover the backup or start | ||
* from scratch to patch for a new game. | ||
* | ||
* @throws SilentException if default location provides no match and the | ||
* user decides to abort the patch generation | ||
*/ | ||
public void checkConsistencyFile() throws SilentException { | ||
File standard = new File(".", consistencyFileName); | ||
File backup = new File(backuppath, consistencyFileName); | ||
|
||
if (!standard.exists()) { | ||
TextReference message; | ||
UserReaction defaultChoice; | ||
if (backup.exists()) { | ||
message = new TextReference("patch.consistency.backup_found", standard.getAbsolutePath(), | ||
backup.getAbsolutePath()); | ||
defaultChoice = UserReaction.Cancel; | ||
} else { | ||
message = new TextReference("patch.consistency.no_backup", consistencyFileName); | ||
defaultChoice = UserReaction.FreshInstall; | ||
} | ||
Option<UserReaction> choice = popupManager.showPopupQuestion( | ||
new TextReference("patch.consistency.backup_title"), | ||
message, | ||
UserReaction.values(), | ||
defaultChoice, | ||
PopupType.Warning); | ||
if (choice.getOrElse(() -> UserReaction.Cancel).equals(UserReaction.Cancel)) { | ||
throw new SilentException("aborted to recover backup consistency file"); | ||
} | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Write consistency file meta data and update external backups. | ||
* | ||
* @throws SetupException if any file operation fails | ||
*/ | ||
public void backupConsistencyData() throws SetupException { | ||
File tempMeta = new File(MessageFormat.format("{0}_tmp", MetaFileName)); | ||
File fileMeta = new File(MetaFileName); | ||
|
||
writeTempMetaFile(tempMeta); | ||
try { | ||
Files.move(tempMeta.toPath(), fileMeta.toPath(), | ||
StandardCopyOption.REPLACE_EXISTING); | ||
} catch (IOException e) { | ||
String message = texts.format("patch.consistency.not_writable", | ||
texts.format("urls.security_settings", true), | ||
fileMeta.getAbsolutePath()); | ||
throw new SetupException("cannot write consistency file", message, | ||
e); | ||
} | ||
updateBackups(); | ||
} | ||
|
||
private void writeTempMetaFile(File temppath) | ||
throws SetupException { | ||
try (FileWriter fstream = new FileWriter(temppath); | ||
BufferedWriter writer = new BufferedWriter(fstream)) { | ||
String end = System.getProperty("line.separator"); | ||
writer.write("This file contains the meta data for the " + | ||
"consistency file used by the Reqtificator, " + | ||
"Requiem's SkyProc Patcher." + end); | ||
writer.write("It is intended to help you to recover the correct " + | ||
"backup file if you accidentally deleted the " + | ||
"original version." + end); | ||
writer.write(MessageFormat.format("Creation Date: " + | ||
"{0,date,full} {0,time,full}{1}", | ||
Calendar.getInstance().getTime(), end)); | ||
writer.write("Imported Load Order this Consistency File was " + | ||
"based on:" + end); | ||
for (ModListing mod : SPDatabase.getImportedModListings()) { | ||
writer.write(MessageFormat.format( | ||
"ModIndex: {0,number,###} - {1}{2}", | ||
SPDatabase.modIndex(mod), mod, end)); | ||
} | ||
} catch (IOException e) { | ||
String message = texts.format("patch.consistency.not_writable", | ||
texts.format("urls.security_settings", true), | ||
temppath.getAbsolutePath()); | ||
throw new SetupException("consistency metafile not writable", | ||
message, e); | ||
} | ||
} | ||
|
||
private void updateBackups() | ||
throws SetupException { | ||
File metaFile = new File(backuppath, MetaFileName + "_5"); | ||
File consistencyFile = new File(backuppath, consistencyFileName + "_5"); | ||
|
||
File copySource = new File("."); | ||
File copyTarget = new File("."); | ||
try { | ||
for (int i = 4; i >= 2; i--) { | ||
copyTarget = metaFile; | ||
copySource = new File(backuppath, | ||
MetaFileName + "_" + i); | ||
if (copySource.exists()) { | ||
Files.move(copySource.toPath(), copyTarget.toPath(), | ||
StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
metaFile = copySource; | ||
|
||
copyTarget = consistencyFile; | ||
copySource = new File(backuppath, | ||
consistencyFileName + "_" + i); | ||
if (copySource.exists()) { | ||
Files.move(copySource.toPath(), copyTarget.toPath(), | ||
StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
consistencyFile = copySource; | ||
} | ||
|
||
copyTarget = metaFile; | ||
copySource = new File(backuppath, MetaFileName); | ||
if (copySource.exists()) { | ||
Files.move(copySource.toPath(), copyTarget.toPath(), | ||
StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
metaFile = copySource; | ||
|
||
copyTarget = consistencyFile; | ||
copySource = new File(backuppath, consistencyFileName); | ||
if (copySource.exists()) { | ||
Files.move(copySource.toPath(), copyTarget.toPath(), | ||
StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
consistencyFile = copySource; | ||
|
||
copyTarget = consistencyFile; | ||
copySource = new File(consistencyFileName); | ||
Files.copy(copySource.toPath(), copyTarget.toPath(), | ||
StandardCopyOption.REPLACE_EXISTING); | ||
|
||
copyTarget = metaFile; | ||
copySource = new File(MetaFileName); | ||
Files.copy(copySource.toPath(), copyTarget.toPath(), | ||
StandardCopyOption.REPLACE_EXISTING); | ||
} catch (IOException e) { | ||
String message = texts.format("patch.consistency.copy_failure", | ||
texts.format("urls.security_settings", true), | ||
copySource.getAbsolutePath(), copyTarget.getAbsolutePath()); | ||
throw new SetupException("backup file rotation failed", message, e); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.