From df116042d05f9ac6a01d8d162e22e4fb68f4bb0a Mon Sep 17 00:00:00 2001 From: David Date: Wed, 26 Nov 2014 14:05:49 -0500 Subject: [PATCH] Changes from dev: Added MGEF.SpellEffectFlag Unknown_X as in tesEdit. Changed SpellEffectFlags to match the TES5Edit ones Changed byte[] unkown to int counterEffectCount, since that was missing Changed SNDD.Sound to a public class Sound, to be able to get and set Sounds and other useful methods Added missing Language values Czech, Polish, Japanese Removed need for a - before the Language name when passed as an argument Fix for parsing keywordset with incorrect KSIZ; fixed SubFormArray.isValid() MajorRecord.getRecordHistory() Added MajorRecord.getModImportedFrom() Fixed ScriptPackage.getScript() for non-existent scripts --- src/skyproc/KeywordSet.java | 10 +- src/skyproc/MGEF.java | 1268 ++++++++++++++++++------------- src/skyproc/MajorRecord.java | 27 + src/skyproc/SPGlobal.java | 507 ++++++------ src/skyproc/ScriptPackage.java | 3 +- src/skyproc/SubFormArray.java | 10 +- src/skyproc/gui/SUMGUI.java | 6 +- src/skyproc/gui/SUMprogram.java | 6 +- 8 files changed, 1046 insertions(+), 791 deletions(-) diff --git a/src/skyproc/KeywordSet.java b/src/skyproc/KeywordSet.java index 7abbdb6..5d923c3 100644 --- a/src/skyproc/KeywordSet.java +++ b/src/skyproc/KeywordSet.java @@ -34,8 +34,7 @@ SubRecord getNew(String type) { @Override boolean isValid() { - return counter.isValid() - && keywords.isValid(); + return keywords.isValid(); } @Override @@ -52,6 +51,7 @@ int getContentLength(ModExporter out) { @Override void export(ModExporter out) throws IOException { if (isValid()) { + counter.setData(keywords.size(), 4); counter.export(out); keywords.export(out); } @@ -62,7 +62,7 @@ void parseData(LImport in, Mod srcMod) throws BadRecord, DataFormatException, Ba switch (getNextType(in)) { case "KSIZ": counter.parseData(in, srcMod); - keywords = new SubFormArray("KWDA", counter.toInt()); +// keywords = new SubFormArray("KWDA", counter.toInt()); break; case "KWDA": keywords.parseData(in, srcMod); @@ -92,7 +92,7 @@ public ArrayList getKeywordRefs() { public void addKeywordRef(FormID keywordRef) { if (!keywords.contains(keywordRef)) { keywords.add(keywordRef); - counter.modValue(1); + //counter.modValue(1); } } @@ -103,7 +103,7 @@ public void addKeywordRef(FormID keywordRef) { */ public void removeKeywordRef(FormID keywordRef) { if (keywords.remove(keywordRef)) { - counter.modValue(-1); + //counter.modValue(-1); } } diff --git a/src/skyproc/MGEF.java b/src/skyproc/MGEF.java index c46ddf0..1513bde 100644 --- a/src/skyproc/MGEF.java +++ b/src/skyproc/MGEF.java @@ -4,18 +4,18 @@ */ package skyproc; -import skyproc.genenums.SoundVolume; -import skyproc.genenums.DeliveryType; -import skyproc.genenums.CastType; -import skyproc.genenums.ActorValue; import java.io.IOException; import java.util.ArrayList; import java.util.zip.DataFormatException; -import lev.LImport; -import lev.LOutFile; + import lev.LFlags; +import lev.LImport; import skyproc.exceptions.BadParameter; import skyproc.exceptions.BadRecord; +import skyproc.genenums.ActorValue; +import skyproc.genenums.CastType; +import skyproc.genenums.DeliveryType; +import skyproc.genenums.SoundVolume; /** * A Magic Effect record @@ -27,313 +27,446 @@ public class MGEF extends MajorRecordDescription { // Static prototypes and definitions static final SubPrototype MGEFproto = new SubPrototype(MajorRecordDescription.descProto) { - @Override - protected void addRecords() { - add(new ScriptPackage()); - reposition("FULL"); - add(new SubForm("MDOB")); - add(new KeywordSet()); - add(new DATA()); - add(new SNDD()); - SubStringPointer dnam = new SubStringPointer("DNAM", SubStringPointer.Files.STRINGS); - dnam.forceExport = true; - add(dnam); - forceExport("DNAM"); - remove("DESC"); - add(new SubForm("ESCE")); - add(new SubList<>(new Condition())); - add(new SubData("OBND")); - } + @Override + protected void addRecords() { + add(new ScriptPackage()); + reposition("FULL"); + add(new SubForm("MDOB")); + add(new KeywordSet()); + add(new DATA()); + add(new SNDD()); + SubStringPointer dnam = new SubStringPointer("DNAM", SubStringPointer.Files.STRINGS); + dnam.forceExport = true; + add(dnam); + forceExport("DNAM"); + remove("DESC"); + add(new SubForm("ESCE")); + add(new SubList<>(new Condition())); + add(new SubData("OBND")); + } }; static class DATA extends SubRecord { - LFlags flags = new LFlags(4); - float baseCost = 0; - FormID relatedID = new FormID(); - ActorValue skillType = ActorValue.NONE; - ActorValue resistanceAV = ActorValue.NONE; - byte[] unknown = {0x00, 0x00, 0x00, (byte) 0x80}; - FormID lightID = new FormID(); - float taperWeight = 0; - FormID hitShader = new FormID(); - FormID enchantShader = new FormID(); - int skillLevel = 0; - int area = 0; - float castingTime = 0; - float taperCurve = 0; - float taperDuration = 0; - float secondAVWeight = 0; - int effectType = 0; - ActorValue primaryAV = ActorValue.Health; - FormID projectileID = new FormID(); - FormID explosionID = new FormID(); - CastType castType = CastType.ConstantEffect; - DeliveryType deliveryType = DeliveryType.Self; - ActorValue secondAV = ActorValue.NONE; - FormID castingArt = new FormID(); - FormID hitEffectArt = new FormID(); - FormID impactData = new FormID(); - float skillUsageMult = 0; - FormID dualCastID = new FormID(); - float dualCastScale = 1; - FormID enchantArtID = new FormID(); - int nullData = 0; - int nullData2 = 0; - FormID equipAbility = new FormID(); - FormID imageSpaceModID = new FormID(); - FormID perkID = new FormID(); - SoundVolume vol = SoundVolume.Normal; - float scriptAIDataScore = 0; - float scriptAIDataDelayTime = 0; - - DATA() { - super(); - } - - @Override - void export(ModExporter out) throws IOException { - super.export(out); - out.write(flags.export(), 4); - out.write(baseCost); - relatedID.export(out); + LFlags flags = new LFlags(4); + float baseCost = 0; + FormID relatedID = new FormID(); + ActorValue skillType = ActorValue.NONE; + ActorValue resistanceAV = ActorValue.NONE; + //byte[] unknown = {0x00, 0x00, 0x00, (byte) 0x80}; + int counterEffectCount = 0; + FormID lightID = new FormID(); + float taperWeight = 0; + FormID hitShader = new FormID(); + FormID enchantShader = new FormID(); + int skillLevel = 0; + int area = 0; + float castingTime = 0; + float taperCurve = 0; + float taperDuration = 0; + float secondAVWeight = 0; + int effectType = 0; + ActorValue primaryAV = ActorValue.Health; + FormID projectileID = new FormID(); + FormID explosionID = new FormID(); + CastType castType = CastType.ConstantEffect; + DeliveryType deliveryType = DeliveryType.Self; + ActorValue secondAV = ActorValue.NONE; + FormID castingArt = new FormID(); + FormID hitEffectArt = new FormID(); + FormID impactData = new FormID(); + float skillUsageMult = 0; + FormID dualCastID = new FormID(); + float dualCastScale = 1; + FormID enchantArtID = new FormID(); + int nullData = 0; + int nullData2 = 0; + FormID equipAbility = new FormID(); + FormID imageSpaceModID = new FormID(); + FormID perkID = new FormID(); + SoundVolume vol = SoundVolume.Normal; + float scriptAIDataScore = 0; + float scriptAIDataDelayTime = 0; + + DATA() { + super(); + } + + @Override + void export(ModExporter out) throws IOException { + super.export(out); + out.write(flags.export(), 4); + out.write(baseCost); + relatedID.export(out); // if (skillType == ActorValue.NONE){ // out.write(-1); // 4 bytes on disk // } else { - out.write(ActorValue.value(skillType)); + out.write(ActorValue.value(skillType)); // } // if (resistanceAV == ActorValue.NONE){ // out.write(-1); // 4 bytes on disk // } else { - out.write(ActorValue.value(resistanceAV)); + out.write(ActorValue.value(resistanceAV)); // } - out.write(unknown, 4); - lightID.export(out); - out.write(taperWeight); - hitShader.export(out); - enchantShader.export(out); - out.write(skillLevel); - out.write(area); - out.write(castingTime); - out.write(taperCurve); - out.write(taperDuration); - out.write(secondAVWeight); - out.write(effectType); + out.write(counterEffectCount);//unknown, 4); + lightID.export(out); + out.write(taperWeight); + hitShader.export(out); + enchantShader.export(out); + out.write(skillLevel); + out.write(area); + out.write(castingTime); + out.write(taperCurve); + out.write(taperDuration); + out.write(secondAVWeight); + out.write(effectType); // if (primaryAV == ActorValue.NONE){ // out.write(-1); // 4 bytes on disk // } else { - out.write(ActorValue.value(primaryAV)); + out.write(ActorValue.value(primaryAV)); // } - projectileID.export(out); - explosionID.export(out); - out.write(castType.ordinal()); - out.write(deliveryType.ordinal()); + projectileID.export(out); + explosionID.export(out); + out.write(castType.ordinal()); + out.write(deliveryType.ordinal()); // if (secondAV == ActorValue.NONE){ // out.write(-1); // 4 bytes on disk // } else { - out.write(ActorValue.value(secondAV)); + out.write(ActorValue.value(secondAV)); // } - castingArt.export(out); - hitEffectArt.export(out); - impactData.export(out); - out.write(skillUsageMult); - dualCastID.export(out); - out.write(dualCastScale); - enchantArtID.export(out); - out.write(nullData, 4); - out.write(nullData2, 4); - equipAbility.export(out); - imageSpaceModID.export(out); - perkID.export(out); - out.write(vol.ordinal()); - out.write(scriptAIDataScore); - out.write(scriptAIDataDelayTime); - } - - @Override - void parseData(LImport in, Mod srcMod) throws BadRecord, DataFormatException, BadParameter { - super.parseData(in, srcMod); - flags.set(in.extract(4)); - baseCost = in.extractFloat(); - relatedID.parseData(in, srcMod); - skillType = ActorValue.value(in.extractInt(4)); - resistanceAV = ActorValue.value(in.extractInt(4)); - unknown = in.extract(4); - lightID.parseData(in, srcMod); - taperWeight = in.extractFloat(); - hitShader.parseData(in, srcMod); - enchantShader.parseData(in, srcMod); - skillLevel = in.extractInt(4); - area = in.extractInt(4); - castingTime = in.extractFloat(); - taperCurve = in.extractFloat(); - taperDuration = in.extractFloat(); - secondAVWeight = in.extractFloat(); - effectType = in.extractInt(4); - primaryAV = ActorValue.value(in.extractInt(4)); - projectileID.parseData(in, srcMod); - explosionID.parseData(in, srcMod); - castType = CastType.values()[in.extractInt(4)]; - deliveryType = DeliveryType.values()[in.extractInt(4)]; - secondAV = ActorValue.value(in.extractInt(4)); - castingArt.parseData(in, srcMod); - hitEffectArt.parseData(in, srcMod); - impactData.parseData(in, srcMod); - skillUsageMult = in.extractFloat(); - dualCastID.parseData(in, srcMod); - dualCastScale = in.extractFloat(); - enchantArtID.parseData(in, srcMod); - nullData = in.extractInt(4); - nullData2 = in.extractInt(4); - equipAbility.parseData(in, srcMod); - imageSpaceModID.parseData(in, srcMod); - perkID.parseData(in, srcMod); - vol = SoundVolume.values()[in.extractInt(4)]; - scriptAIDataScore = in.extractFloat(); - scriptAIDataDelayTime = in.extractFloat(); - if (SPGlobal.logMods){ - logMod(srcMod, "", "DATA:"); - logMod(srcMod, "", " Flags: " + flags); - logMod(srcMod, "", " Base Cost: " + baseCost); - logMod(srcMod, "", " Related ID: " + relatedID); - logMod(srcMod, "", " skillType: " + skillType); - logMod(srcMod, "", " resistanceAV: " + resistanceAV); - logMod(srcMod, "", " Light: " + lightID); - logMod(srcMod, "", " Taper Weight: " + taperWeight); - logMod(srcMod, "", " Hit Shader: " + hitShader); - logMod(srcMod, "", " Enchant Shader: " + enchantShader); - logMod(srcMod, "", " Skill Level: " + skillLevel); - logMod(srcMod, "", " Area: " + area); - logMod(srcMod, "", " Casting Time: " + castingTime); - logMod(srcMod, "", " Taper Curve: " + taperCurve); - logMod(srcMod, "", " Taper Duration: " + taperDuration); - logMod(srcMod, "", " second AV weight: " + secondAVWeight); - logMod(srcMod, "", " Effect Type: " + effectType); - logMod(srcMod, "", " Primary AV: " + primaryAV); - logMod(srcMod, "", " Projectile : " + projectileID); - logMod(srcMod, "", " Explosion: " + explosionID); - logMod(srcMod, "", " Cast Type: " + castType); - logMod(srcMod, "", " Delivery Type: " + deliveryType); - logMod(srcMod, "", " Second AV: " + secondAV); - logMod(srcMod, "", " Casting Art: " + castingArt); - logMod(srcMod, "", " Hit Effect Art: " + hitEffectArt); - logMod(srcMod, "", " Impact Data: " + impactData); - logMod(srcMod, "", " Skill Usage Mult: " + skillUsageMult); - logMod(srcMod, "", " Dual Cast ID: " + dualCastID); - logMod(srcMod, "", " Dual Cast Scale: " + dualCastScale); - logMod(srcMod, "", " Enchant Art: " + enchantArtID); - logMod(srcMod, "", " Equip Ability: " + equipAbility); - logMod(srcMod, "", " Image Space Mod ID: " + imageSpaceModID); - logMod(srcMod, "", " Perk: " + perkID); - logMod(srcMod, "", " Volume: " + vol); - logMod(srcMod, "", " Script AI Data Score: " + scriptAIDataScore); - logMod(srcMod, "", " Script AI Data Delay Time: " + scriptAIDataDelayTime); - } - } - - @Override - SubRecord getNew(String type) { - return new DATA(); - } - - @Override - boolean isValid() { - return true; - } - - @Override - int getContentLength(ModExporter out) { - return 152; - } - - @Override - ArrayList allFormIDs() { - ArrayList out = new ArrayList<>(14); - out.add(relatedID); - out.add(lightID); - out.add(hitShader); - out.add(enchantShader); - out.add(projectileID); - out.add(explosionID); - out.add(castingArt); - out.add(hitEffectArt); - out.add(impactData); - out.add(dualCastID); - out.add(enchantArtID); - out.add(equipAbility); - out.add(imageSpaceModID); - out.add(perkID); - return out; - } - - @Override - ArrayList getTypes() { - return Record.getTypeList("DATA"); - } + castingArt.export(out); + hitEffectArt.export(out); + impactData.export(out); + out.write(skillUsageMult); + dualCastID.export(out); + out.write(dualCastScale); + enchantArtID.export(out); + out.write(nullData, 4); + out.write(nullData2, 4); + equipAbility.export(out); + imageSpaceModID.export(out); + perkID.export(out); + out.write(vol.ordinal()); + out.write(scriptAIDataScore); + out.write(scriptAIDataDelayTime); + } + + @Override + void parseData(LImport in, Mod srcMod) throws BadRecord, DataFormatException, BadParameter { + super.parseData(in, srcMod); + flags.set(in.extract(4)); + baseCost = in.extractFloat(); + relatedID.parseData(in, srcMod); + skillType = ActorValue.value(in.extractInt(4)); + resistanceAV = ActorValue.value(in.extractInt(4)); + counterEffectCount = in.extractInt(4);//unknown = in.extract(4); + lightID.parseData(in, srcMod); + taperWeight = in.extractFloat(); + hitShader.parseData(in, srcMod); + enchantShader.parseData(in, srcMod); + skillLevel = in.extractInt(4); + area = in.extractInt(4); + castingTime = in.extractFloat(); + taperCurve = in.extractFloat(); + taperDuration = in.extractFloat(); + secondAVWeight = in.extractFloat(); + effectType = in.extractInt(4); + primaryAV = ActorValue.value(in.extractInt(4)); + projectileID.parseData(in, srcMod); + explosionID.parseData(in, srcMod); + castType = CastType.values()[in.extractInt(4)]; + deliveryType = DeliveryType.values()[in.extractInt(4)]; + secondAV = ActorValue.value(in.extractInt(4)); + castingArt.parseData(in, srcMod); + hitEffectArt.parseData(in, srcMod); + impactData.parseData(in, srcMod); + skillUsageMult = in.extractFloat(); + dualCastID.parseData(in, srcMod); + dualCastScale = in.extractFloat(); + enchantArtID.parseData(in, srcMod); + nullData = in.extractInt(4); + nullData2 = in.extractInt(4); + equipAbility.parseData(in, srcMod); + imageSpaceModID.parseData(in, srcMod); + perkID.parseData(in, srcMod); + vol = SoundVolume.values()[in.extractInt(4)]; + scriptAIDataScore = in.extractFloat(); + scriptAIDataDelayTime = in.extractFloat(); + if (SPGlobal.logMods) { + logMod(srcMod, "", "DATA:"); + logMod(srcMod, "", " Flags: " + flags); + logMod(srcMod, "", " Base Cost: " + baseCost); + logMod(srcMod, "", " Related ID: " + relatedID); + logMod(srcMod, "", " skillType: " + skillType); + logMod(srcMod, "", " resistanceAV: " + resistanceAV); + logMod(srcMod, "", " Light: " + lightID); + logMod(srcMod, "", " Taper Weight: " + taperWeight); + logMod(srcMod, "", " Hit Shader: " + hitShader); + logMod(srcMod, "", " Enchant Shader: " + enchantShader); + logMod(srcMod, "", " Skill Level: " + skillLevel); + logMod(srcMod, "", " Area: " + area); + logMod(srcMod, "", " Casting Time: " + castingTime); + logMod(srcMod, "", " Taper Curve: " + taperCurve); + logMod(srcMod, "", " Taper Duration: " + taperDuration); + logMod(srcMod, "", " second AV weight: " + secondAVWeight); + logMod(srcMod, "", " Effect Type: " + effectType); + logMod(srcMod, "", " Primary AV: " + primaryAV); + logMod(srcMod, "", " Projectile : " + projectileID); + logMod(srcMod, "", " Explosion: " + explosionID); + logMod(srcMod, "", " Cast Type: " + castType); + logMod(srcMod, "", " Delivery Type: " + deliveryType); + logMod(srcMod, "", " Second AV: " + secondAV); + logMod(srcMod, "", " Casting Art: " + castingArt); + logMod(srcMod, "", " Hit Effect Art: " + hitEffectArt); + logMod(srcMod, "", " Impact Data: " + impactData); + logMod(srcMod, "", " Skill Usage Mult: " + skillUsageMult); + logMod(srcMod, "", " Dual Cast ID: " + dualCastID); + logMod(srcMod, "", " Dual Cast Scale: " + dualCastScale); + logMod(srcMod, "", " Enchant Art: " + enchantArtID); + logMod(srcMod, "", " Equip Ability: " + equipAbility); + logMod(srcMod, "", " Image Space Mod ID: " + imageSpaceModID); + logMod(srcMod, "", " Perk: " + perkID); + logMod(srcMod, "", " Volume: " + vol); + logMod(srcMod, "", " Script AI Data Score: " + scriptAIDataScore); + logMod(srcMod, "", " Script AI Data Delay Time: " + scriptAIDataDelayTime); + } + } + + @Override + SubRecord getNew(String type) { + return new DATA(); + } + + @Override + boolean isValid() { + return true; + } + + @Override + int getContentLength(ModExporter out) { + return 152; + } + + @Override + ArrayList allFormIDs() { + ArrayList out = new ArrayList<>(14); + out.add(relatedID); + out.add(lightID); + out.add(hitShader); + out.add(enchantShader); + out.add(projectileID); + out.add(explosionID); + out.add(castingArt); + out.add(hitEffectArt); + out.add(impactData); + out.add(dualCastID); + out.add(enchantArtID); + out.add(equipAbility); + out.add(imageSpaceModID); + out.add(perkID); + return out; + } + + @Override + ArrayList getTypes() { + return Record.getTypeList("DATA"); + } } static class SNDD extends SubRecord { - ArrayList sounds = new ArrayList<>(); - - SNDD() { - super(); - } - - @Override - void export(ModExporter out) throws IOException { - super.export(out); - for (SNDD.Sound s : sounds) { - out.write(s.sound.ordinal()); - s.soundID.export(out); - } - } - - @Override - void parseData(LImport in, Mod srcMod) throws BadRecord, DataFormatException, BadParameter { - super.parseData(in, srcMod); - while (!in.isDone()) { - SNDD.Sound sound = new SNDD.Sound(); - sound.sound = SoundData.values()[in.extractInt(4)]; - sound.soundID.parseData(in, srcMod); - sounds.add(sound); - } - } - - @Override - SubRecord getNew(String type) { - return new SNDD(); - } - - @Override - boolean isValid() { - return !sounds.isEmpty(); - } - - @Override - int getContentLength(ModExporter out) { - return 8 * sounds.size(); - } - - @Override - ArrayList allFormIDs() { - ArrayList out = new ArrayList<>(); - for (SNDD.Sound s : sounds) { - out.add(s.soundID); - } - return out; - } - - @Override - ArrayList getTypes() { - return Record.getTypeList("SNDD"); - } - - class Sound { - - SoundData sound; - FormID soundID = new FormID(); - } + ArrayList sounds = new ArrayList<>(); + + SNDD() { + super(); + } + + @Override + void export(ModExporter out) throws IOException { + super.export(out); + for (Sound s : sounds) { + out.write(s.sound.ordinal()); + s.soundID.export(out); + } + } + + @Override + void parseData(LImport in, Mod srcMod) throws BadRecord, DataFormatException, BadParameter { + super.parseData(in, srcMod); + while (!in.isDone()) { + Sound sound = new Sound(); + sound.sound = SoundData.values()[in.extractInt(4)]; + sound.soundID.parseData(in, srcMod); + sounds.add(sound); + } + } + + @Override + SubRecord getNew(String type) { + return new SNDD(); + } + + @Override + boolean isValid() { + return !sounds.isEmpty(); + } + + @Override + int getContentLength(ModExporter out) { + return 8 * sounds.size(); + } + + @Override + ArrayList allFormIDs() { + ArrayList out = new ArrayList<>(); + for (Sound s : sounds) { + out.add(s.soundID); + } + return out; + } + + @Override + ArrayList getTypes() { + return Record.getTypeList("SNDD"); + } + + } + + public static class Sound { + + SoundData sound; + FormID soundID = new FormID(); + + private Sound() { + } + + /** + * + * @param sound + * @param soundID + */ + public Sound(SoundData sound, FormID soundID) { + this.sound = sound; + this.soundID = soundID; + } + + /** + * + * @return + */ + public SoundData getSoundData() { + return sound; + } + + /** + * + * @param sound + */ + public void setSoundData(SoundData sound) { + this.sound = sound; + } + + /** + * + * @return + */ + public FormID getSoundID() { + return soundID; + } + + /** + * + * @param soundID + */ + public void setSoundID(FormID soundID) { + this.soundID = soundID; + } + + /** + * + * @return + */ + @Override + public String toString() { + return "Sound [sound=" + sound + ", soundID=" + soundID + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((sound == null) ? 0 : sound.hashCode()); + result = prime * result + + ((soundID == null) ? 0 : soundID.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Sound other = (Sound) obj; + if (sound != other.sound) { + return false; + } + if (soundID == null) { + if (other.soundID != null) { + return false; + } + } else if (!soundID.equals(other.soundID)) { + return false; + } + return true; + } + + } + + /** + * + * @return + */ + SNDD getSNDD() { + return (SNDD) subRecords.get("SNDD"); + } + + /** + * + * @return Returns the actual ArrayList, not a copy. + */ + public ArrayList getSounds() { + return getSNDD().sounds; + } + + /** + * Replaces all previous sounds + * + * @param sounds + */ + public void setSounds(ArrayList sounds) { + getSNDD().sounds = sounds; + } + + /** + * + * @param sound + */ + public void addSound(Sound sound) { + getSNDD().sounds.add(sound); + } + + /** + * + * @param sound + */ + public void removeSound(Sound sound) { + getSNDD().sounds.remove(sound); } // Enums @@ -342,83 +475,140 @@ class Sound { */ public enum SpellEffectFlag { - /** - * - */ - Hostile(0), - /** - * - */ - Recover(1), - /** - * - */ - Detrimental(2), - /** - * - */ - SnapToNavmesh(3), - /** - * - */ - NoHitEvent(4), - /** - * - */ - DispellEffects(8), - /** - * - */ - NoDuration(9), - /** - * - */ - NoMagnitude(10), - /** - * - */ - NoArea(11), - /** - * - */ - FXPersist(12), - /** - * - */ - NoRecast(13), - /** - * - */ - GoryVisual(14), - /** - * - */ - HideInUI(15), - /** - * - */ - PowerAffectsMagnitude(21), - /** - * - */ - PowerAffectsDuration(22), - /** - * - */ - Painless(26), - /** - * - */ - NoHitEffect(27), - /** - * - */ - NoDeathDispel(28); - int value; - - SpellEffectFlag(int value) { - this.value = value; - } + /** + * + */ + Hostile(0), + /** + * + */ + Recover(1), + /** + * + */ + Detrimental(2), + /** + * + */ + SnapToNavmesh(3), + /** + * + */ + NoHitEvent(4), + /** + * + */ + Unknown_6(5), + /** + * + */ + Unknown_7(6), + /** + * + */ + Unknown_8(7), + /** + * + */ + DispellEffects(8), + /** + * + */ + NoDuration(9), + /** + * + */ + NoMagnitude(10), + /** + * + */ + NoArea(11), + /** + * + */ + FXPersist(12), + /** + * + */ + Unknown_14(13), + /** + * + */ + GoryVisual(14), + /** + * + */ + HideInUI(15), + /** + * + */ + Unknown_17(16), + /** + * + */ + NoRecast(17), + /** + * + */ + Unknown_19(18), + /** + * + */ + Unknown_20(19), + /** + * + */ + Unknown_21(20), + /** + * + */ + PowerAffectsMagnitude(21), + /** + * + */ + PowerAffectsDuration(22), + /** + * + */ + Unknown_24(23), + /** + * + */ + Unknown_25(24), + /** + * + */ + Unknown_26(25), + /** + * + */ + Painless(26), + /** + * + */ + NoHitEffect(27), + /** + * + */ + NoDeathDispel(28), + /* + * + */ + Unknown_30(29), + /** + * + */ + Unknown_31(30), + /** + * + */ + Unknown_32(31); + + int value; + + SpellEffectFlag(int value) { + this.value = value; + } } /** @@ -426,30 +616,30 @@ public enum SpellEffectFlag { */ public enum SoundData { - /** - * - */ - SheathDraw, - /** - * - */ - Charge, - /** - * - */ - Ready, - /** - * - */ - Release, - /** - * - */ - ConcentrationCastLoop, - /** - * - */ - OnHit + /** + * + */ + SheathDraw, + /** + * + */ + Charge, + /** + * + */ + Ready, + /** + * + */ + Release, + /** + * + */ + ConcentrationCastLoop, + /** + * + */ + OnHit } // Common Functions @@ -459,24 +649,24 @@ public enum SoundData { * @param name */ public MGEF(String edid, String name) { - this(); - originateFromPatch(edid); - this.setName(name); + this(); + originateFromPatch(edid); + this.setName(name); } MGEF() { - super(); - subRecords.setPrototype(MGEFproto); + super(); + subRecords.setPrototype(MGEFproto); } @Override ArrayList getTypes() { - return Record.getTypeList("MGEF"); + return Record.getTypeList("MGEF"); } @Override Record getNew() { - return new MGEF(); + return new MGEF(); } // Get/Set @@ -486,12 +676,12 @@ Record getNew() { * empty. */ public KeywordSet getKeywordSet() { - return subRecords.getKeywords(); + return subRecords.getKeywords(); } @Override public String getDescription() { - return subRecords.getSubStringPointer("DNAM").print(); + return subRecords.getSubStringPointer("DNAM").print(); } /** @@ -500,11 +690,11 @@ public String getDescription() { */ @Override public void setDescription(String description) { - subRecords.setSubStringPointer("DNAM", description); + subRecords.setSubStringPointer("DNAM", description); } DATA getDATA() { - return (DATA) subRecords.get("DATA"); + return (DATA) subRecords.get("DATA"); } /** @@ -513,7 +703,7 @@ DATA getDATA() { * @param on */ public void set(SpellEffectFlag flag, boolean on) { - getDATA().flags.set(flag.value, on); + getDATA().flags.set(flag.value, on); } /** @@ -522,7 +712,7 @@ public void set(SpellEffectFlag flag, boolean on) { * @return */ public boolean get(SpellEffectFlag flag) { - return getDATA().flags.get(flag.value); + return getDATA().flags.get(flag.value); } /** @@ -530,135 +720,151 @@ public boolean get(SpellEffectFlag flag) { * @return */ public ScriptPackage getScriptPackage() { - return subRecords.getScripts(); + return subRecords.getScripts(); } /** * * @param value */ - public void setBaseCost (float value) { - getDATA().baseCost = value; + public void setBaseCost(float value) { + getDATA().baseCost = value; } /** * * @return */ - public float getBaseCost () { - return getDATA().baseCost; + public float getBaseCost() { + return getDATA().baseCost; } /** * * @param id */ - public void setRelatedID (FormID id) { - getDATA().relatedID = id; + public void setRelatedID(FormID id) { + getDATA().relatedID = id; } /** * * @return */ - public FormID getRelatedID () { - return getDATA().relatedID; + public FormID getRelatedID() { + return getDATA().relatedID; } /** * * @param val */ - public void setSkillType (ActorValue val) { - getDATA().skillType = val; + public void setSkillType(ActorValue val) { + getDATA().skillType = val; } /** * * @return */ - public ActorValue getSkillType () { - return getDATA().skillType; + public ActorValue getSkillType() { + return getDATA().skillType; } /** * * @param val */ - public void setResistanceAV (ActorValue val) { - getDATA().resistanceAV = val; + public void setResistanceAV(ActorValue val) { + getDATA().resistanceAV = val; } /** * * @return */ - public ActorValue getResistanceAV () { - return getDATA().resistanceAV; + public ActorValue getResistanceAV() { + return getDATA().resistanceAV; + } + + /** + * + * @param counterEffectCount + */ + public void setCounterEffectCount(int counterEffectCount) { + getDATA().counterEffectCount = counterEffectCount; + } + + /** + * + * @return + */ + public int getCounterEffectCount() { + return getDATA().counterEffectCount; } /** * * @param light */ - public void setLight (FormID light) { - getDATA().lightID = light; + public void setLight(FormID light) { + getDATA().lightID = light; } /** * * @return */ - public FormID getLight () { - return getDATA().lightID; + public FormID getLight() { + return getDATA().lightID; } /** * * @param value */ - public void setTaperWeight (float value) { - getDATA().taperWeight = value; + public void setTaperWeight(float value) { + getDATA().taperWeight = value; } /** * * @return */ - public float getTaperWeight () { - return getDATA().taperWeight; + public float getTaperWeight() { + return getDATA().taperWeight; } /** * * @param hitShader */ - public void setHitShader (FormID hitShader) { - getDATA().hitShader = hitShader; + public void setHitShader(FormID hitShader) { + getDATA().hitShader = hitShader; } /** * * @return */ - public FormID getHitShader () { - return getDATA().hitShader; + public FormID getHitShader() { + return getDATA().hitShader; } /** * * @param enchantShader */ - public void setEnchantShader (FormID enchantShader) { - getDATA().enchantShader = enchantShader; + public void setEnchantShader(FormID enchantShader) { + getDATA().enchantShader = enchantShader; } /** * * @return */ - public FormID getEnchantShader () { - return getDATA().enchantShader; + public FormID getEnchantShader() { + return getDATA().enchantShader; } /** @@ -666,7 +872,7 @@ public FormID getEnchantShader () { * @param level */ public void setSkillLevel(int level) { - getDATA().skillLevel = level; + getDATA().skillLevel = level; } /** @@ -674,7 +880,7 @@ public void setSkillLevel(int level) { * @return */ public int getSkillLevel() { - return getDATA().skillLevel; + return getDATA().skillLevel; } /** @@ -682,7 +888,7 @@ public int getSkillLevel() { * @param area */ public void setArea(int area) { - getDATA().area = area; + getDATA().area = area; } /** @@ -690,103 +896,103 @@ public void setArea(int area) { * @return */ public int getArea() { - return getDATA().area; + return getDATA().area; } /** * * @param value */ - public void setCastingTime (float value) { - getDATA().castingTime = value; + public void setCastingTime(float value) { + getDATA().castingTime = value; } /** * * @return */ - public float getCastingTime () { - return getDATA().castingTime; + public float getCastingTime() { + return getDATA().castingTime; } /** * * @param value */ - public void setTaperCurve (float value) { - getDATA().taperCurve = value; + public void setTaperCurve(float value) { + getDATA().taperCurve = value; } /** * * @return */ - public float getTaperCurve () { - return getDATA().taperCurve; + public float getTaperCurve() { + return getDATA().taperCurve; } /** * * @param value */ - public void setTaperDuration (float value) { - getDATA().taperDuration = value; + public void setTaperDuration(float value) { + getDATA().taperDuration = value; } /** * * @return */ - public float getTaperDuration () { - return getDATA().taperDuration; + public float getTaperDuration() { + return getDATA().taperDuration; } /** * * @param value */ - public void setSecondAVWeight (float value) { - getDATA().secondAVWeight = value; + public void setSecondAVWeight(float value) { + getDATA().secondAVWeight = value; } /** * * @return */ - public float getSecondAVWeight () { - return getDATA().secondAVWeight; + public float getSecondAVWeight() { + return getDATA().secondAVWeight; } /** * * @param value */ - public void setEffectType (int value) { - getDATA().effectType = value; + public void setEffectType(int value) { + getDATA().effectType = value; } /** * * @return */ - public float getEffectType () { - return getDATA().effectType; + public float getEffectType() { + return getDATA().effectType; } /** * * @param val */ - public void setPrimaryAV (ActorValue val) { - getDATA().primaryAV = val; + public void setPrimaryAV(ActorValue val) { + getDATA().primaryAV = val; } /** * * @return */ - public ActorValue getPrimaryAV () { - return getDATA().primaryAV; + public ActorValue getPrimaryAV() { + return getDATA().primaryAV; } /** @@ -794,7 +1000,7 @@ public ActorValue getPrimaryAV () { * @param id */ public void setProjectile(FormID id) { - getDATA().projectileID = id; + getDATA().projectileID = id; } /** @@ -802,7 +1008,7 @@ public void setProjectile(FormID id) { * @return */ public FormID getProjectile() { - return getDATA().projectileID; + return getDATA().projectileID; } /** @@ -810,7 +1016,7 @@ public FormID getProjectile() { * @param id */ public void setExplosion(FormID id) { - getDATA().explosionID = id; + getDATA().explosionID = id; } /** @@ -818,215 +1024,215 @@ public void setExplosion(FormID id) { * @return */ public FormID getExplosion() { - return getDATA().explosionID; + return getDATA().explosionID; } /** * * @param cast */ - public void setCastType (CastType cast) { - getDATA().castType = cast; + public void setCastType(CastType cast) { + getDATA().castType = cast; } /** * * @return */ - public CastType getCastType () { - return getDATA().castType; + public CastType getCastType() { + return getDATA().castType; } /** * * @param del */ - public void setDeliveryType (DeliveryType del) { - getDATA().deliveryType = del; + public void setDeliveryType(DeliveryType del) { + getDATA().deliveryType = del; } /** * * @return */ - public DeliveryType getDeliveryType () { - return getDATA().deliveryType; + public DeliveryType getDeliveryType() { + return getDATA().deliveryType; } /** * * @param val */ - public void setSecondAV (ActorValue val) { - getDATA().secondAV = val; + public void setSecondAV(ActorValue val) { + getDATA().secondAV = val; } /** * * @return */ - public ActorValue getSecondAV () { - return getDATA().secondAV; + public ActorValue getSecondAV() { + return getDATA().secondAV; } /** * * @param art */ - public void setCastingArt (FormID art) { - getDATA().castingArt = art; + public void setCastingArt(FormID art) { + getDATA().castingArt = art; } /** * * @return */ - public FormID getCastingArt () { - return getDATA().castingArt; + public FormID getCastingArt() { + return getDATA().castingArt; } /** * * @param art */ - public void setHitEffectArt (FormID art) { - getDATA().hitEffectArt = art; + public void setHitEffectArt(FormID art) { + getDATA().hitEffectArt = art; } /** * * @return */ - public FormID getHitEffectArt () { - return getDATA().hitEffectArt; + public FormID getHitEffectArt() { + return getDATA().hitEffectArt; } /** * * @param data */ - public void setImpactData (FormID data) { - getDATA().impactData = data; + public void setImpactData(FormID data) { + getDATA().impactData = data; } /** * * @return */ - public FormID getImpactData () { - return getDATA().impactData; + public FormID getImpactData() { + return getDATA().impactData; } /** * * @param mult */ - public void setSkillUsageMult (float mult) { - getDATA().skillUsageMult = mult; + public void setSkillUsageMult(float mult) { + getDATA().skillUsageMult = mult; } /** * * @return */ - public float getSkillUsageMult () { - return getDATA().skillUsageMult; + public float getSkillUsageMult() { + return getDATA().skillUsageMult; } /** * * @param id */ - public void setDualCast (FormID id) { - getDATA().dualCastID = id; + public void setDualCast(FormID id) { + getDATA().dualCastID = id; } /** * * @return */ - public FormID getDualCast () { - return getDATA().dualCastID; + public FormID getDualCast() { + return getDATA().dualCastID; } /** * * @param scale */ - public void setDualCastScale (float scale) { - getDATA().dualCastScale = scale; + public void setDualCastScale(float scale) { + getDATA().dualCastScale = scale; } /** * * @return */ - public float getDualCastScale () { - return getDATA().dualCastScale; + public float getDualCastScale() { + return getDATA().dualCastScale; } /** * * @param art */ - public void setEnchantArt (FormID art) { - getDATA().enchantArtID = art; + public void setEnchantArt(FormID art) { + getDATA().enchantArtID = art; } /** * * @return */ - public FormID getEnchantArt () { - return getDATA().enchantArtID; + public FormID getEnchantArt() { + return getDATA().enchantArtID; } /** * * @param id */ - public void setEquipAbility (FormID id) { - getDATA().equipAbility = id; + public void setEquipAbility(FormID id) { + getDATA().equipAbility = id; } /** * * @return */ - public FormID getEquipAbility () { - return getDATA().equipAbility; + public FormID getEquipAbility() { + return getDATA().equipAbility; } /** * * @param id */ - public void setImageSpaceMod (FormID id) { - getDATA().imageSpaceModID = id; + public void setImageSpaceMod(FormID id) { + getDATA().imageSpaceModID = id; } /** * * @return */ - public FormID getImageSpaceMod () { - return getDATA().imageSpaceModID; + public FormID getImageSpaceMod() { + return getDATA().imageSpaceModID; } /** * * @param id */ - public void setPerk (FormID id) { - getDATA().perkID = id; + public void setPerk(FormID id) { + getDATA().perkID = id; } /** * * @return */ - public FormID getPerk () { - return getDATA().perkID; + public FormID getPerk() { + return getDATA().perkID; } /** @@ -1034,7 +1240,7 @@ public FormID getPerk () { * @param vol */ public void setSoundVolume(SoundVolume vol) { - getDATA().vol = vol; + getDATA().vol = vol; } /** @@ -1042,7 +1248,7 @@ public void setSoundVolume(SoundVolume vol) { * @return */ public SoundVolume getSoundVolume() { - return getDATA().vol; + return getDATA().vol; } /** @@ -1050,7 +1256,7 @@ public SoundVolume getSoundVolume() { * @param score */ public void setScriptAIDataScore(float score) { - getDATA().scriptAIDataScore = score; + getDATA().scriptAIDataScore = score; } /** @@ -1058,7 +1264,7 @@ public void setScriptAIDataScore(float score) { * @return */ public float getScriptAIDataScore() { - return getDATA().scriptAIDataScore; + return getDATA().scriptAIDataScore; } /** @@ -1066,7 +1272,7 @@ public float getScriptAIDataScore() { * @param score */ public void setScriptAIDataTime(float score) { - getDATA().scriptAIDataDelayTime = score; + getDATA().scriptAIDataDelayTime = score; } /** @@ -1074,7 +1280,7 @@ public void setScriptAIDataTime(float score) { * @return */ public float getScriptAIDataTime() { - return getDATA().scriptAIDataDelayTime; + return getDATA().scriptAIDataDelayTime; } /** @@ -1082,23 +1288,23 @@ public float getScriptAIDataTime() { * @return */ public ArrayList getConditions() { - return subRecords.getSubList("CTDA").toPublic(); + return subRecords.getSubList("CTDA").toPublic(); } /** - * + * * @param c */ public void addCondition(Condition c) { - subRecords.getSubList("CTDA").add(c); + subRecords.getSubList("CTDA").add(c); } /** - * + * * @param c */ public void removeCondition(Condition c) { - subRecords.getSubList("CTDA").remove(c); + subRecords.getSubList("CTDA").remove(c); } } diff --git a/src/skyproc/MajorRecord.java b/src/skyproc/MajorRecord.java index 4d3eb5b..5349bad 100644 --- a/src/skyproc/MajorRecord.java +++ b/src/skyproc/MajorRecord.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.Objects; import java.util.zip.DataFormatException; import lev.LFlags; @@ -19,6 +20,8 @@ */ public abstract class MajorRecord extends Record implements Serializable { + static final HashMap> recordHistory = new HashMap<>(); + static final SubPrototype majorProto = new SubPrototype() { @Override @@ -176,6 +179,13 @@ void parseData(LImport in, Mod srcMod) throws BadRecord, DataFormatException, Ba } importSubRecords(in); + + ArrayList versions = recordHistory.get(ID); + if(versions == null){ + versions = new ArrayList<>(); + recordHistory.put(ID, versions); + } + versions.add(this); } void importSubRecords(LImport in) throws BadRecord, DataFormatException, BadParameter { @@ -321,6 +331,15 @@ String getFormArrayStr(Boolean master) { public ModListing getFormMaster() { return ID.getMaster(); } + + /** + * + * @return The mod (file) this Major Record was imported from. Does not need + * to be the same mod that this Major Record originates from. + */ + public ModListing getModImportedFrom(){ + return srcMod.getInfo(); + } /** * @@ -503,4 +522,12 @@ GRUP getGRUPAppend() { boolean shouldExportGRUP() { return false; } + + /** + * + * @return A copy of a list of this Major Record as it appears in all imported plugins. + */ + public ArrayList getRecordHistory(){ + return new ArrayList<>(recordHistory.get(ID)); + } } diff --git a/src/skyproc/SPGlobal.java b/src/skyproc/SPGlobal.java index 61f6dfc..ff5880f 100644 --- a/src/skyproc/SPGlobal.java +++ b/src/skyproc/SPGlobal.java @@ -27,7 +27,7 @@ public class SPGlobal { static boolean noModsAfter = true; static boolean checkMissingMasters = true; static MajorRecord lastStreamed; - + /* * Customizable Strings */ @@ -61,30 +61,42 @@ public class SPGlobal { */ public static enum Language { - /** - * - */ - English, - /** - * - */ - Spanish, - /** - * - */ - Italian, - /** - * - */ - French, - /** - * - */ - German, - /** - * - */ - Russian; + /** + * + */ + English, + /** + * + */ + Spanish, + /** + * + */ + Italian, + /** + * + */ + French, + /** + * + */ + German, + /** + * + */ + Russian, + /** + * + */ + Czech, + /** + * + */ + Polish, + /** + * + */ + Japanes; } /** * The path from the .jar location to create/look for the file used to @@ -102,12 +114,12 @@ public static enum Language { * @throws IOException */ public static File getSkyProcDocuments() throws FileNotFoundException, IOException { - if (skyProcDocuments == null) { - File myDocs = SPGlobal.getMyDocumentsSkyrimFolder(); - skyProcDocuments = new File(myDocs.getPath() + "\\SkyProc\\"); - skyProcDocuments.mkdirs(); - } - return skyProcDocuments; + if (skyProcDocuments == null) { + File myDocs = SPGlobal.getMyDocumentsSkyrimFolder(); + skyProcDocuments = new File(myDocs.getPath() + "\\SkyProc\\"); + skyProcDocuments.mkdirs(); + } + return skyProcDocuments; } /** @@ -115,7 +127,7 @@ public static File getSkyProcDocuments() throws FileNotFoundException, IOExcepti * @return The database defined as the Global Database */ public static SPDatabase getDB() { - return globalDatabase; + return globalDatabase; } /** @@ -125,11 +137,11 @@ public static SPDatabase getDB() { * @param patch Mod to set as the global patch. */ public static void setGlobalPatch(Mod patch) { - if (globalPatchOut != null) { - modsToSkip.remove(globalPatchOut.getInfo()); - } - globalPatchOut = patch; - modsToSkip.add(globalPatchOut.getInfo()); + if (globalPatchOut != null) { + modsToSkip.remove(globalPatchOut.getInfo()); + } + globalPatchOut = patch; + modsToSkip.add(globalPatchOut.getInfo()); } /** @@ -137,7 +149,7 @@ public static void setGlobalPatch(Mod patch) { * @return the set Global Patch, or null if one hasn' been set. */ public static Mod getGlobalPatch() { - return globalPatchOut; + return globalPatchOut; } static ArrayList modsToSkip = new ArrayList<>(); static ArrayList modsToSkipStr = new ArrayList<>(); @@ -149,7 +161,7 @@ public static Mod getGlobalPatch() { * @param m Mod to skip when importing. */ public static void addModToSkip(ModListing m) { - modsToSkip.add(m); + modsToSkip.add(m); } /** @@ -157,12 +169,12 @@ public static void addModToSkip(ModListing m) { * @param s */ public static void addModToSkip(String s) { - s = s.toUpperCase(); - if (s.contains(".ESP") || s.contains(".ESM")) { - addModToSkip(new ModListing(s)); - } else { - modsToSkipStr.add(s); - } + s = s.toUpperCase(); + if (s.contains(".ESP") || s.contains(".ESM")) { + addModToSkip(new ModListing(s)); + } else { + modsToSkipStr.add(s); + } } /** @@ -171,7 +183,7 @@ public static void addModToSkip(String s) { * @return */ public static boolean isModToSkip(ModListing m) { - return modsToSkip.contains(m) || isModToSkip(m.print()); + return modsToSkip.contains(m) || isModToSkip(m.print()); } /** @@ -180,7 +192,7 @@ public static boolean isModToSkip(ModListing m) { * @return */ public static boolean isModToSkip(String name) { - return Ln.hasAnyKeywords(name, modsToSkipStr); + return Ln.hasAnyKeywords(name, modsToSkipStr); } /** @@ -189,8 +201,8 @@ public static boolean isModToSkip(String name) { * @return */ public static boolean isWhiteListed(ModListing m) { - return (modsWhiteList.isEmpty() && modsWhiteListStr.isEmpty()) - || modsWhiteList.contains(m) || isWhiteListed(m.print()); + return (modsWhiteList.isEmpty() && modsWhiteListStr.isEmpty()) + || modsWhiteList.contains(m) || isWhiteListed(m.print()); } /** @@ -199,26 +211,30 @@ public static boolean isWhiteListed(ModListing m) { * @return */ public static boolean isWhiteListed(String name) { - return (modsWhiteList.isEmpty() && modsWhiteListStr.isEmpty()) - || Ln.hasAnyKeywords(name, modsWhiteListStr); + return (modsWhiteList.isEmpty() && modsWhiteListStr.isEmpty()) + || Ln.hasAnyKeywords(name, modsWhiteListStr); } /** - * True if not blacklisted and if white listed (if there are any white listings) + * True if not blacklisted and if white listed (if there are any white + * listings) + * * @param m * @return */ public static boolean shouldImport(ModListing m) { - return !SPGlobal.isModToSkip(m) && SPGlobal.isWhiteListed(m); + return !SPGlobal.isModToSkip(m) && SPGlobal.isWhiteListed(m); } /** - * True if not blacklisted and if white listed (if there are any white listings) + * True if not blacklisted and if white listed (if there are any white + * listings) + * * @param name * @return */ public static boolean shouldImport(String name) { - return !SPGlobal.isModToSkip(name) && SPGlobal.isWhiteListed(name); + return !SPGlobal.isModToSkip(name) && SPGlobal.isWhiteListed(name); } /** @@ -228,7 +244,7 @@ public static boolean shouldImport(String name) { * @param m */ public static void addModToWhiteList(ModListing m) { - modsWhiteList.add(m); + modsWhiteList.add(m); } /** @@ -238,11 +254,11 @@ public static void addModToWhiteList(ModListing m) { * @param s */ public static void addModToWhiteList(String s) { - if (s.contains(".ESP") || s.contains(".ESM")) { - addModToWhiteList(new ModListing(s)); - } else { - modsWhiteListStr.add(s); - } + if (s.contains(".ESP") || s.contains(".ESM")) { + addModToWhiteList(new ModListing(s)); + } else { + modsWhiteListStr.add(s); + } } /** @@ -254,7 +270,7 @@ public static void addModToWhiteList(String s) { * @return True if FormID exists in the database. */ static public boolean queryMajor(FormID query) { - return SPDatabase.queryMajor(query, SPGlobal.getDB()); + return SPDatabase.queryMajor(query, SPGlobal.getDB()); } /** @@ -266,7 +282,7 @@ static public boolean queryMajor(FormID query) { * @return True if FormID exists in the database. */ static public boolean queryMajor(FormID query, GRUP_TYPE... grup_types) { - return SPDatabase.queryMajor(query, SPGlobal.getDB(), grup_types); + return SPDatabase.queryMajor(query, SPGlobal.getDB(), grup_types); } /** @@ -277,7 +293,7 @@ static public boolean queryMajor(FormID query, GRUP_TYPE... grup_types) { * @throws IOException */ static public File getMyDocumentsSkyrimFolder() throws FileNotFoundException, IOException { - return getSkyrimINI().getParentFile(); + return getSkyrimINI().getParentFile(); } /** @@ -288,30 +304,30 @@ static public File getMyDocumentsSkyrimFolder() throws FileNotFoundException, IO * @throws IOException */ static public File getSkyrimINI() throws FileNotFoundException, IOException { - File myDocuments = Ln.getMyDocuments(); - File ini = new File(myDocuments.getPath() + "//My Games//Skyrim//Skyrim.ini"); - - // See if there's a manual override - File override = new File(SPGlobal.pathToInternalFiles + "Skyrim-INI-Location.txt"); - if (override.exists()) { - SPGlobal.log(header, "Skyrim.ini override file exists: " + override); - BufferedReader in = new BufferedReader(new FileReader(override)); - File iniTmp = new File(in.readLine()); - if (iniTmp.exists()) { - SPGlobal.log(header, "Skyrim.ini location override: " + iniTmp); - ini = iniTmp; - } else { - SPGlobal.log(header, "Skyrim.ini location override thought to be in: " + iniTmp + ", but it did not exist."); - } - } - - if (!ini.exists()) { - SPGlobal.logMain(header, "Skyrim.ini believed to be in: " + ini + ". But it does not exist. Locating manually."); - ini = Ln.manualFindFile("your Skyrim.ini file.", new File(SPGlobal.pathToInternalFiles + "SkyrimINIlocation.txt")); - } else if (SPGlobal.logging()) { - SPGlobal.logMain(header, "Skyrim.ini believed to be in: " + ini + ". File exists."); - } - return ini; + File myDocuments = Ln.getMyDocuments(); + File ini = new File(myDocuments.getPath() + "//My Games//Skyrim//Skyrim.ini"); + + // See if there's a manual override + File override = new File(SPGlobal.pathToInternalFiles + "Skyrim-INI-Location.txt"); + if (override.exists()) { + SPGlobal.log(header, "Skyrim.ini override file exists: " + override); + BufferedReader in = new BufferedReader(new FileReader(override)); + File iniTmp = new File(in.readLine()); + if (iniTmp.exists()) { + SPGlobal.log(header, "Skyrim.ini location override: " + iniTmp); + ini = iniTmp; + } else { + SPGlobal.log(header, "Skyrim.ini location override thought to be in: " + iniTmp + ", but it did not exist."); + } + } + + if (!ini.exists()) { + SPGlobal.logMain(header, "Skyrim.ini believed to be in: " + ini + ". But it does not exist. Locating manually."); + ini = Ln.manualFindFile("your Skyrim.ini file.", new File(SPGlobal.pathToInternalFiles + "SkyrimINIlocation.txt")); + } else if (SPGlobal.logging()) { + SPGlobal.logMain(header, "Skyrim.ini believed to be in: " + ini + ". File exists."); + } + return ini; } static String appDataFolder; @@ -321,35 +337,35 @@ static public File getSkyrimINI() throws FileNotFoundException, IOException { * @throws IOException */ static public String getSkyrimAppData() throws IOException { - if (appDataFolder == null) { - appDataFolder = System.getenv("LOCALAPPDATA"); - - // If XP - if (appDataFolder == null) { - SPGlobal.logError(header, "Can't locate local app data folder directly, probably running XP."); - appDataFolder = System.getenv("APPDATA"); - - // If Messed Up - if (appDataFolder == null) { - SPGlobal.logError(header, "Can't locate local app data folder."); - appDataFolder = Ln.manualFindFile("your Plugins.txt file.\nThis is usually found in your Local Application Data folder.\n" - + "You may need to turn on hidden folders to see it.", new File(SPGlobal.pathToInternalFiles + "PluginsListLocation.txt")).getPath(); + if (appDataFolder == null) { + appDataFolder = System.getenv("LOCALAPPDATA"); + + // If XP + if (appDataFolder == null) { + SPGlobal.logError(header, "Can't locate local app data folder directly, probably running XP."); + appDataFolder = System.getenv("APPDATA"); + + // If Messed Up + if (appDataFolder == null) { + SPGlobal.logError(header, "Can't locate local app data folder."); + appDataFolder = Ln.manualFindFile("your Plugins.txt file.\nThis is usually found in your Local Application Data folder.\n" + + "You may need to turn on hidden folders to see it.", new File(SPGlobal.pathToInternalFiles + "PluginsListLocation.txt")).getPath(); SPGlobal.logMain(header, "Plugin.txt returned: ", appDataFolder, " Shaving off the \\Plugins.txt."); - appDataFolder = appDataFolder.substring(0, appDataFolder.lastIndexOf("\\")); + appDataFolder = appDataFolder.substring(0, appDataFolder.lastIndexOf("\\")); // remove \\Skyrim so it can be added again below. Yep appDataFolder = appDataFolder.substring(0, appDataFolder.lastIndexOf("\\")); - } else { - SPGlobal.logMain(header, "APPDATA returned: ", appDataFolder, " Shaving off the \\Application Data."); - appDataFolder = appDataFolder.substring(0, appDataFolder.lastIndexOf("\\")); - SPGlobal.logMain(header, "path now reads: ", appDataFolder, " appending \\Local Settings\\Application Data"); - appDataFolder = appDataFolder + "\\Local Settings\\Application Data"; - SPGlobal.logMain(header, "path now reads: ", appDataFolder); - } - } - appDataFolder += "\\Skyrim"; - SPGlobal.logMain(header, SPGlobal.gameName + " App data thought to be found at: ", appDataFolder); - } - return appDataFolder; + } else { + SPGlobal.logMain(header, "APPDATA returned: ", appDataFolder, " Shaving off the \\Application Data."); + appDataFolder = appDataFolder.substring(0, appDataFolder.lastIndexOf("\\")); + SPGlobal.logMain(header, "path now reads: ", appDataFolder, " appending \\Local Settings\\Application Data"); + appDataFolder = appDataFolder + "\\Local Settings\\Application Data"; + SPGlobal.logMain(header, "path now reads: ", appDataFolder); + } + } + appDataFolder += "\\Skyrim"; + SPGlobal.logMain(header, SPGlobal.gameName + " App data thought to be found at: ", appDataFolder); + } + return appDataFolder; } /** @@ -360,14 +376,14 @@ static public String getSkyrimAppData() throws IOException { * @throws IOException */ static public String getPluginsTxt() throws FileNotFoundException, IOException { - String pluginsFile = getSkyrimAppData() + "\\plugins.txt"; - File pluginListPath = new File(pluginsFile); - if (!pluginListPath.exists()) { - SPGlobal.logMain(header, SPGlobal.gameName + " Plugin file location wrong. Locating manually."); - pluginsFile = Ln.manualFindFile("your Plugins.txt file.\nThis is usually found in your Local Application Data folder.\n" - + "You may need to turn on hidden folders to see it.", new File(SPGlobal.pathToInternalFiles + "PluginsListLocation.txt")).getPath(); - } - return pluginsFile; + String pluginsFile = getSkyrimAppData() + "\\plugins.txt"; + File pluginListPath = new File(pluginsFile); + if (!pluginListPath.exists()) { + SPGlobal.logMain(header, SPGlobal.gameName + " Plugin file location wrong. Locating manually."); + pluginsFile = Ln.manualFindFile("your Plugins.txt file.\nThis is usually found in your Local Application Data folder.\n" + + "You may need to turn on hidden folders to see it.", new File(SPGlobal.pathToInternalFiles + "PluginsListLocation.txt")).getPath(); + } + return pluginsFile; } /** @@ -376,12 +392,12 @@ static public String getPluginsTxt() throws FileNotFoundException, IOException { * @throws IOException */ static public String getLoadOrderTxt() throws IOException { - String loadorderFile = getSkyrimAppData() + "\\loadorder.txt"; - File loadorderPath = new File(loadorderFile); - if (!loadorderPath.exists()) { - throw new FileNotFoundException("Load Order Text file does not exist at: " + loadorderFile); - } - return loadorderFile; + String loadorderFile = getSkyrimAppData() + "\\loadorder.txt"; + File loadorderPath = new File(loadorderFile); + if (!loadorderPath.exists()) { + throw new FileNotFoundException("Load Order Text file does not exist at: " + loadorderFile); + } + return loadorderFile; } /** @@ -390,7 +406,7 @@ static public String getLoadOrderTxt() throws IOException { * want it to all be imported at once. */ static public void setStreamMode(boolean on) { - streamMode = on; + streamMode = on; } /** @@ -399,7 +415,7 @@ static public void setStreamMode(boolean on) { * in the load order. */ static public void setNoModsAfter(boolean on) { - noModsAfter = on; + noModsAfter = on; } /** @@ -409,7 +425,7 @@ static public void setNoModsAfter(boolean on) { * @param message */ static public void setSUMerrorMessage(String message) { - SUMGUI.setErrorMessage(message); + SUMGUI.setErrorMessage(message); } /* @@ -420,7 +436,7 @@ static public void setSUMerrorMessage(String message) { * print messages to them.
Do this step early in your program. */ public static void createGlobalLog() { - createGlobalLog("SkyProcDebug/"); + createGlobalLog("SkyProcDebug/"); } /** @@ -430,14 +446,14 @@ public static void createGlobalLog() { * @param path The path to create the "SkyProcDebug/" folder. */ public static void createGlobalLog(String path) { - pathToDebug = path; - log = new SPLogger(path); + pathToDebug = path; + log = new SPLogger(path); } static void logSync(String header, String... print) { - if (log != null) { - log.logSync(header, print); - } + if (log != null) { + log.logSync(header, print); + } } /** @@ -448,9 +464,9 @@ static void logSync(String header, String... print) { * @param print */ public static void logMain(String header, String... print) { - if (log != null) { - SPGlobal.log.logMain(header, print); - } + if (log != null) { + SPGlobal.log.logMain(header, print); + } } /** @@ -461,7 +477,7 @@ public static void logMain(String header, String... print) { * @param m Record that was blocked. */ public static void logBlocked(String header, String reason, MajorRecord m) { - log.logSpecial(SPLogger.SpecialTypes.BLOCKED, header, "Blocked " + m + " for reason: " + reason); + log.logSpecial(SPLogger.SpecialTypes.BLOCKED, header, "Blocked " + m + " for reason: " + reason); } /** @@ -469,11 +485,11 @@ public static void logBlocked(String header, String reason, MajorRecord m) { * @return True if the logger is currently on. */ public static boolean logging() { - if (log != null) { - return SPGlobal.log.logging(); - } else { - return false; - } + if (log != null) { + return SPGlobal.log.logging(); + } else { + return false; + } } /** @@ -481,9 +497,9 @@ public static boolean logging() { * @param on Turns the logger on/off. */ public static void logging(Boolean on) { - if (log != null) { - SPGlobal.log.logging(on); - } + if (log != null) { + SPGlobal.log.logging(on); + } } /** @@ -491,11 +507,11 @@ public static void logging(Boolean on) { * @return True if the logger is currently on. */ public static boolean loggingSync() { - if (log != null) { - return SPGlobal.log.loggingSync(); - } else { - return false; - } + if (log != null) { + return SPGlobal.log.loggingSync(); + } else { + return false; + } } /** @@ -503,9 +519,9 @@ public static boolean loggingSync() { * @param on Turns the logger on/off. */ public static void loggingSync(Boolean on) { - if (log != null) { - SPGlobal.log.loggingSync(on); - } + if (log != null) { + SPGlobal.log.loggingSync(on); + } } /** @@ -514,9 +530,9 @@ public static void loggingSync(Boolean on) { * @param on */ public static void loggingAsync(Boolean on) { - if (log != null) { - SPGlobal.log.loggingAsync(on); - } + if (log != null) { + SPGlobal.log.loggingAsync(on); + } } /** @@ -524,20 +540,20 @@ public static void loggingAsync(Boolean on) { * @return Whether the LLogger's async log is on/off. */ public static boolean loggingAsync() { - if (log != null) { - return SPGlobal.log.loggingAsync(); - } else { - return false; - } + if (log != null) { + return SPGlobal.log.loggingAsync(); + } else { + return false; + } } /** * Flushes the Debug buffers to the files. */ public static void flush() { - if (log != null) { - SPGlobal.log.flush(); - } + if (log != null) { + SPGlobal.log.flush(); + } } /** @@ -548,9 +564,9 @@ public static void flush() { * @param print */ public static void logError(String header, String... print) { - if (log != null) { - SPGlobal.log.logError(header, print); - } + if (log != null) { + SPGlobal.log.logError(header, print); + } } /** @@ -559,9 +575,9 @@ public static void logError(String header, String... print) { * @param e Exception to print. */ public static void logException(Throwable e) { - if (log != null) { - SPGlobal.log.logException(e); - } + if (log != null) { + SPGlobal.log.logException(e); + } } /** @@ -573,9 +589,9 @@ public static void logException(Throwable e) { * @param print */ public static void logSpecial(Enum e, String header, String... print) { - if (log != null) { - SPGlobal.log.logSpecial(e, header, print); - } + if (log != null) { + SPGlobal.log.logSpecial(e, header, print); + } } /** @@ -585,39 +601,40 @@ public static void logSpecial(Enum e, String header, String... print) { * @param logName */ public static void newSpecialLog(Enum e, String logName) { - if (log != null) { - SPGlobal.log.addSpecial(e, logName); - } + if (log != null) { + SPGlobal.log.addSpecial(e, logName); + } } + /** - * + * * @return if mod specific log files will be written */ - public static boolean logMods(){ + public static boolean logMods() { return logMods; } - + /** - * + * * @param on set mod specific logging */ - public static void logMods(boolean on){ + public static void logMods(boolean on) { logMods = on; - if(on){ + if (on) { logging(true); } } - static void logMod(Mod m, String h, String ... data) { - if (logMods && log != null){ + static void logMod(Mod m, String h, String... data) { + if (logMods && log != null) { log.logMod(m, h, data); } } static void newSyncLog(String fileName) { - if (log != null) { - SPGlobal.log.newSyncLog(fileName); - } + if (log != null) { + SPGlobal.log.newSyncLog(fileName); + } } /** @@ -627,9 +644,9 @@ static void newSyncLog(String fileName) { * @param print */ public static void log(String header, String... print) { - if (log != null) { - SPGlobal.log.log(header, print); - } + if (log != null) { + SPGlobal.log.log(header, print); + } } /** @@ -638,23 +655,23 @@ public static void log(String header, String... print) { * @param fileName Name of the log. */ public static void newLog(String fileName) { - if (log != null) { - SPGlobal.log.newLog(fileName); - } + if (log != null) { + SPGlobal.log.newLog(fileName); + } } static void sync(boolean flag) { - if (log != null) { - log.sync(flag); - } + if (log != null) { + log.sync(flag); + } } static boolean sync() { - if (log != null) { - return log.sync(); - } else { - return false; - } + if (log != null) { + return log.sync(); + } else { + return false; + } } /** @@ -664,47 +681,47 @@ static boolean sync() { * @throws IOException */ public static void redirectSystemOutStream() throws FileNotFoundException, IOException { - if (log == null) { - createGlobalLog(); - } - OutputStream outToDebug = new OutputStream() { - @Override - public void write(final int b) throws IOException { - if (b != 116) { - log("", String.valueOf((char) b)); - } - } - - @Override - public void write(byte[] b, int off, int len) throws IOException { - String output = new String(b, off, len); - if (output.length() > 2) { - log("", output); - } - } - - @Override - public void write(byte[] b) throws IOException { - write(b, 0, b.length); - } - }; - - System.setOut(new PrintStream(outToDebug, true)); + if (log == null) { + createGlobalLog(); + } + OutputStream outToDebug = new OutputStream() { + @Override + public void write(final int b) throws IOException { + if (b != 116) { + log("", String.valueOf((char) b)); + } + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + String output = new String(b, off, len); + if (output.length() > 2) { + log("", output); + } + } + + @Override + public void write(byte[] b) throws IOException { + write(b, 0, b.length); + } + }; + + System.setOut(new PrintStream(outToDebug, true)); } static void reset() { - SPDatabase.activePlugins.clear(); - SPDatabase.addedPlugins.clear(); - SPDatabase.modLookup.clear(); - FormID.allIDs.clear(); - Consistency.clear(); + SPDatabase.activePlugins.clear(); + SPDatabase.addedPlugins.clear(); + SPDatabase.modLookup.clear(); + FormID.allIDs.clear(); + Consistency.clear(); } /** * Closes all logs. */ public static void closeDebug() { - LDebug.wrapUp(); + LDebug.wrapUp(); } /** @@ -713,7 +730,7 @@ public static void closeDebug() { * @return */ public static String pathToDebug() { - return pathToDebug; + return pathToDebug; } // Debug Globals /** @@ -738,22 +755,22 @@ public static String pathToDebug() { * sync log
*/ public static boolean debugModMerge = false; - + /* * Toggle to force to processing exactly like vanilla files for validation. * Switches MajorRecord with flag DELETED to print full contents. * Needed because TesVEdit now removes all subrecords of DELETED majorRecords. */ public static boolean forceValidateMode = false; - + private static boolean allModsAsMasters = false; - - public static boolean getAllModsAsMasters(){ + + public static boolean getAllModsAsMasters() { return allModsAsMasters; } - - public static void setAllModsAsMasters(boolean b){ + + public static void setAllModsAsMasters(boolean b) { allModsAsMasters = b; } - + } diff --git a/src/skyproc/ScriptPackage.java b/src/skyproc/ScriptPackage.java index b5f91d5..94af7d8 100644 --- a/src/skyproc/ScriptPackage.java +++ b/src/skyproc/ScriptPackage.java @@ -144,7 +144,8 @@ public ScriptRef getScript(String scriptName) { * @return */ public ScriptRef getScript(ScriptRef script) { - return scripts.get(scripts.indexOf(script)); + int index = scripts.indexOf(script); + return (index != -1) ? scripts.get(index) : null; } /** diff --git a/src/skyproc/SubFormArray.java b/src/skyproc/SubFormArray.java index 93b8a0a..01e9bb4 100644 --- a/src/skyproc/SubFormArray.java +++ b/src/skyproc/SubFormArray.java @@ -58,6 +58,10 @@ void parseData(LImport in, Mod srcMod) throws BadRecord, DataFormatException, Ba FormID id = new FormID(); id.parseData(in, srcMod); add(id); + size++; + if (SPGlobal.logMods){ + logMod(srcMod, toString(), "Setting " + toString() + " FormID[" + size + "]: " + id); + } } } } @@ -77,11 +81,11 @@ ArrayList allFormIDs() { @Override boolean isValid() { for (FormID ID : IDs) { - if (ID.isValid()) { - return true; + if (!ID.isValid()) { + return false; } } - return false; + return true; } @Override diff --git a/src/skyproc/gui/SUMGUI.java b/src/skyproc/gui/SUMGUI.java index b9d4597..ac7d700 100644 --- a/src/skyproc/gui/SUMGUI.java +++ b/src/skyproc/gui/SUMGUI.java @@ -501,8 +501,8 @@ static void handleArgs(String[] args) { // Progress Bar Location int index = arguments.indexOf("-PROGRESSLOCATION"); if (index != -1) { - Dimension progressLoc = new Dimension(Integer.valueOf(arguments.get(index + 1).substring(1)), - Integer.valueOf(arguments.get(index + 2).substring(1))); + Dimension progressLoc = new Dimension(Integer.valueOf(arguments.get(index + 1)), + Integer.valueOf(arguments.get(index + 2))); SUMGUI.progress.setCorrectLocation(progressLoc.width, progressLoc.height); } @@ -510,7 +510,7 @@ static void handleArgs(String[] args) { index = arguments.indexOf("-LANGUAGE"); if (index != -1) { - String lang = arguments.get(index + 1).substring(1); + String lang = arguments.get(index + 1); for (Language l : Language.values()) { if (lang.equalsIgnoreCase(l.toString())) { SPGlobal.language = l; diff --git a/src/skyproc/gui/SUMprogram.java b/src/skyproc/gui/SUMprogram.java index a329440..45780b0 100644 --- a/src/skyproc/gui/SUMprogram.java +++ b/src/skyproc/gui/SUMprogram.java @@ -1037,13 +1037,13 @@ boolean runJarPatcher(PatcherLink link) { args.add("-NONEW"); args.add("-NOMODSAFTER"); args.add("-LANGUAGE"); - args.add("-" + Language.values()[SUMsave.getInt(SUMSettings.LANGUAGE)]); + args.add("" + Language.values()[SUMsave.getInt(SUMSettings.LANGUAGE)]); if (forceAllPatches.isSelected() || SUMsave.getBool(SUMSettings.MERGE_PATCH)) { args.add("-FORCE"); } args.add("-PROGRESSLOCATION"); - args.add("-" + (SUMGUI.progress.getX() + SUMGUI.progress.getWidth() + 10)); - args.add("-" + SUMGUI.progress.getY()); + args.add("" + (SUMGUI.progress.getX() + SUMGUI.progress.getWidth() + 10)); + args.add("" + SUMGUI.progress.getY()); args.add("-SUMBLOCK"); args.add("-NOBOSS"); if (SUMsave.getBool(SUMSettings.ALL_AS_MASTERS)){