mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 21:16:30 +02:00
Correctly handle import/export of .disabled (optional disabled) mods
This commit is contained in:
parent
a553c3ce08
commit
b546141d34
@ -54,7 +54,11 @@ var exportCmd = &cobra.Command{
|
|||||||
// TODO: how to handle files with CF metadata, but with different download path?
|
// TODO: how to handle files with CF metadata, but with different download path?
|
||||||
if ok {
|
if ok {
|
||||||
p := projectRaw.(cfUpdateData)
|
p := projectRaw.(cfUpdateData)
|
||||||
cfFileRefs = append(cfFileRefs, packinterop.AddonFileReference{ProjectID: p.ProjectID, FileID: p.FileID})
|
cfFileRefs = append(cfFileRefs, packinterop.AddonFileReference{
|
||||||
|
ProjectID: p.ProjectID,
|
||||||
|
FileID: p.FileID,
|
||||||
|
OptionalDisabled: mod.Option != nil && mod.Option.Optional && !mod.Option.Default,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// If the mod doesn't have the metadata, save it into the zip
|
// If the mod doesn't have the metadata, save it into the zip
|
||||||
path, err := filepath.Rel(filepath.Dir(indexPath), mod.GetDestFilePath())
|
path, err := filepath.Rel(filepath.Dir(indexPath), mod.GetDestFilePath())
|
||||||
|
@ -52,8 +52,9 @@ func (c cursePackMeta) Mods() []AddonFileReference {
|
|||||||
list := make([]AddonFileReference, len(c.Files))
|
list := make([]AddonFileReference, len(c.Files))
|
||||||
for i, v := range c.Files {
|
for i, v := range c.Files {
|
||||||
list[i] = AddonFileReference{
|
list[i] = AddonFileReference{
|
||||||
ProjectID: v.ProjectID,
|
ProjectID: v.ProjectID,
|
||||||
FileID: v.FileID,
|
FileID: v.FileID,
|
||||||
|
OptionalDisabled: !v.Required,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
|
@ -21,6 +21,8 @@ type twitchInstalledPackMeta struct {
|
|||||||
File struct {
|
File struct {
|
||||||
// I've given up on using this cached data, just going to re-request it
|
// I've given up on using this cached data, just going to re-request it
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
|
// Used to determine if the mod is optional-disabled
|
||||||
|
FileNameOnDisk string
|
||||||
} `json:"installedFile"`
|
} `json:"installedFile"`
|
||||||
} `json:"installedAddons"`
|
} `json:"installedAddons"`
|
||||||
// Used to determine if modpackOverrides should be used or not
|
// Used to determine if modpackOverrides should be used or not
|
||||||
@ -51,8 +53,9 @@ func (m twitchInstalledPackMeta) Mods() []AddonFileReference {
|
|||||||
list := make([]AddonFileReference, len(m.ModsInternal))
|
list := make([]AddonFileReference, len(m.ModsInternal))
|
||||||
for i, v := range m.ModsInternal {
|
for i, v := range m.ModsInternal {
|
||||||
list[i] = AddonFileReference{
|
list[i] = AddonFileReference{
|
||||||
ProjectID: v.ID,
|
ProjectID: v.ID,
|
||||||
FileID: v.File.ID,
|
FileID: v.File.ID,
|
||||||
|
OptionalDisabled: strings.HasSuffix(v.File.FileNameOnDisk, ".disabled"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
|
@ -61,10 +61,12 @@ func ReadMetadata(s ImportPackSource) ImportPackMetadata {
|
|||||||
return packImport
|
return packImport
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddonFileReference is a pair of Project ID and File ID to reference a single file on CurseForge
|
// AddonFileReference is a struct to reference a single file on CurseForge
|
||||||
type AddonFileReference struct {
|
type AddonFileReference struct {
|
||||||
ProjectID int
|
ProjectID int
|
||||||
FileID int
|
FileID int
|
||||||
|
// OptionalDisabled is true if the file is optional and disabled (turned off in Twitch launcher)
|
||||||
|
OptionalDisabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteManifestFromPack(pack core.Pack, fileRefs []AddonFileReference, out io.Writer) error {
|
func WriteManifestFromPack(pack core.Pack, fileRefs []AddonFileReference, out io.Writer) error {
|
||||||
@ -79,7 +81,7 @@ func WriteManifestFromPack(pack core.Pack, fileRefs []AddonFileReference, out io
|
|||||||
ProjectID int `json:"projectID"`
|
ProjectID int `json:"projectID"`
|
||||||
FileID int `json:"fileID"`
|
FileID int `json:"fileID"`
|
||||||
Required bool `json:"required"`
|
Required bool `json:"required"`
|
||||||
}{ProjectID: fr.ProjectID, FileID: fr.FileID, Required: true}
|
}{ProjectID: fr.ProjectID, FileID: fr.FileID, Required: !fr.OptionalDisabled}
|
||||||
}
|
}
|
||||||
|
|
||||||
modLoaders := make([]modLoaderDef, 0, 1)
|
modLoaders := make([]modLoaderDef, 0, 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user