Skip to content

Commit

Permalink
Add relativeExtractionPath for files and fileOverrides and update max…
Browse files Browse the repository at this point in the history
… JSON version
  • Loading branch information
drojf committed Jan 6, 2021
1 parent c386828 commit b5af0a2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
6 changes: 5 additions & 1 deletion JSONValidator/Sources/JSONValidator/JSONValidator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public struct FileDefinition: Codable {
public var url: String?
/// The priority of this file. Higher priority files are installed later so they will overwrite lower priority files
public var priority: Int
/// A path relative to the *top-level game directory* (should contain HigurashiEp##_data for a higurashi game's data folder)
public var relativeExtractionPath: String?
}

public struct FileOverrideDefinition: Codable {
Expand Down Expand Up @@ -92,6 +94,8 @@ public struct FileOverrideDefinition: Codable {
/// it's relative to the install directory
/// - If null, no files are checked
public var targetChecksums: [[String]]?
/// A path relative to the *top-level game directory* (should contain HigurashiEp##_data for a higurashi game's data folder)
public var relativeExtractionPath: String?
}

public enum OS: String, Codable, CaseIterable {
Expand Down Expand Up @@ -131,7 +135,7 @@ public struct ModOptionFileDefinition: Codable {
/// The url for the mod option
public var url: String
/// A path relative to the *top-level game directory* (should contain HigurashiEp##_data for a higurashi game's data folder)
public var relativeExtractionPath: String
public var relativeExtractionPath: String?
/// The priority of this file (same system as above priorities)
public var priority: Int
}
8 changes: 6 additions & 2 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Globals:
GITHUB_MASTER_BASE_URL = "https://raw.githubusercontent.com/07th-mod/python-patcher/master/"
# The installer info version this installer is compatibile with
# Increment it when you make breaking changes to the json files
JSON_VERSION = 10
JSON_VERSION = 11

# Define constants used throughout the script. Use function calls to enforce variables as const
IS_WINDOWS = platform.system() == "Windows"
Expand Down Expand Up @@ -878,7 +878,11 @@ def buildDownloadAndExtractionList(self):
if not self.suppressDownloadStatus:
commandLineParser.printSeventhModStatusUpdate(1, "Querying URLs to be Downloaded")
for i, file in enumerate(self.modFileList):
self.addItemManually(file.url, self.defaultExtractionDir)
extractionDir = self.defaultExtractionDir
if file.relativeExtractionPath is not None:
extractionDir = os.path.join(self.defaultExtractionDir, file.relativeExtractionPath)

self.addItemManually(file.url, extractionDir)

self.downloadAndExtractionListsBuilt = True

Expand Down
22 changes: 14 additions & 8 deletions installConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def buildFileListSorted(self, datadir="", verbosePrinting=True):

# for all other overrides, overwrite the value in the filesDict with a new ModFile
currentModFile = filesDict[fileOverride.name]
filesDict[fileOverride.name] = ModFile(currentModFile.name, fileOverride.url, currentModFile.priority, id=fileOverride.id)
filesDict[fileOverride.name] = ModFile(currentModFile.name, fileOverride.url, currentModFile.priority, id=fileOverride.id, relativeExtractionPath=fileOverride.relativeExtractionPath)

# Look for override-required files that weren't overridden
for key, value in filesDict.items():
Expand All @@ -130,8 +130,8 @@ def buildFileListSorted(self, datadir="", verbosePrinting=True):

class ModFile:
modFileCounter = 0
def __init__(self, name, url, priority, id=None):
# type: (str, Optional[str], int, str) -> None
def __init__(self, name, url, priority, id=None, relativeExtractionPath=None):
# type: (str, Optional[str], int, str, Optional[str]) -> None
self.name = name
self.url = url

Expand All @@ -142,15 +142,18 @@ def __init__(self, name, url, priority, id=None):
# Therefore, the 'later extracted' files are higher priority, that is archives with priority 3 will overwrite priority 0,1,2 archives
self.priority = priority #consider renaming this "extractionOrder"?

# A path relative to the *top-level game directory* (should contain HigurashiEp##_data for a higurashi game's data folder)
self.relativeExtractionPath = relativeExtractionPath # type: str

# This variable is used to provide ordering which roughly matches the ordering in the JSON file
# to ensure files are downloaded and extracted in a deterministic manner
self.nativeOrder = ModFile.modFileCounter
ModFile.modFileCounter += 1


class ModFileOverride:
def __init__(self, name, id, os, steam, unity, url, targetChecksums):
# type: (str, str, List[str], Optional[bool], Optional[str], str, List[Tuple[str, str]]) -> None
def __init__(self, name, id, os, steam, unity, url, targetChecksums, relativeExtractionPath=None):
# type: (str, str, List[str], Optional[bool], Optional[str], str, List[Tuple[str, str]], Optional[str]) -> None
self.name = name # type: str
self.id = id
"""A unique identifier among all files and modfiles for this submod. Set manually as 'movie-unix' for example"""
Expand All @@ -164,7 +167,9 @@ def __init__(self, name, id, os, steam, unity, url, targetChecksums):
"""This field can be None for no checksum checking.
This field consists of a list of tuples. Each tuple is a pair of (PATH, CHECKSUM).
If a file exists at PATH and matches CHECKSUM then this override will be accepted"""

self.relativeExtractionPath = relativeExtractionPath # type: str
"""A path relative to the *top-level game directory*
(should contain HigurashiEp##_data for a higurashi game's data folder)"""

class ModOption:
def __init__(self, name, description, group, type, isRadio, data, isGlobal=False, value=False):
Expand Down Expand Up @@ -262,7 +267,7 @@ def __init__(self, mod, subMod):

self.files = [] # type: List[ModFile]
for subModFile in subMod['files']:
self.files.append(ModFile(name=subModFile['name'], url = subModFile.get('url'), priority=subModFile['priority']))
self.files.append(ModFile(name=subModFile['name'], url = subModFile.get('url'), priority=subModFile['priority'], relativeExtractionPath=subModFile.get('relativeExtractionPath')))

self.fileOverrides = [] # type: List[ModFileOverride]
for subModFileOverride in subMod['fileOverrides']:
Expand All @@ -273,7 +278,8 @@ def __init__(self, mod, subMod):
unity=subModFileOverride.get('unity'),
url=subModFileOverride['url'],
id=subModFileOverride['id'],
targetChecksums=subModFileOverride.get('targetChecksums')
targetChecksums=subModFileOverride.get('targetChecksums'),
relativeExtractionPath=subModFileOverride.get('relativeExtractionPath')
))

# If no mod options are specified in the JSON, the 'self.modOptions' field defaults to the empty list ([])
Expand Down

0 comments on commit b5af0a2

Please sign in to comment.