public void UpdateView( AllPropositions props ) { ignoreChanges = true; allProps = props; propTypeBonuses = props.PropositionTypeBonuses; propTypeBonusesDefault = props.Default.PropositionTypeBonuses; bfnBonuses = props.BraveFaithBonuses; bfnBonusesDefault = props.Default.BraveFaithBonuses; UpdateRowHeaders( FFTPatch.Context ); foreach (PropositionClass clas in (PropositionClass[])Enum.GetValues( typeof( PropositionClass ) )) { foreach (PropositionType type in (PropositionType[])Enum.GetValues( typeof( PropositionType ) )) { if (propTypeBonuses.ContainsKey( Tuple.From( type, clas ) )) { dataGridView1[(int)type, (int)clas].Value = propTypeBonuses[type, clas]; } } foreach (BraveFaithNeutral bfn in (BraveFaithNeutral[])Enum.GetValues( typeof( BraveFaithNeutral ) )) { if (bfnBonuses.ContainsKey( Tuple.From( bfn, clas ) )) { dataGridView1[(int)bfn - 1 + braveColumn.Index, (int)clas].Value = bfnBonuses[bfn, clas]; } } } ignoreChanges = false; }
private static void LoadDataFromBytes( IList <byte> abilities, IList <byte> abilityEffects, IList <byte> itemAbilityEffects, IList <byte> reactionEffects, IList <byte> abilityAnimations, IList <byte> oldItems, IList <byte> oldItemAttributes, IList <byte> newItems, IList <byte> newItemAttributes, IList <byte> jobs, IList <byte> jobLevels, IList <byte> skillSets, IList <byte> monsterSkills, IList <byte> actionMenus, IList <byte> statusAttributes, IList <byte> inflictStatuses, IList <byte> poach, IList <byte> entd1, IList <byte> entd2, IList <byte> entd3, IList <byte> entd4, IList <byte> entd5, IList <byte> moveFind, IList <byte> inventories, IList <byte> propositions, bool brokenLevelBonuses) { try { bool psp = Context == Context.US_PSP; var Abilities = new AllAbilities(abilities, abilityEffects, itemAbilityEffects, reactionEffects); var AbilityAnimations = new AllAnimations(Context, abilityAnimations, psp ? PSPResources.Binaries.AbilityAnimations : PSXResources.Binaries.AbilityAnimations); var Items = new AllItems(oldItems, newItems != null ? newItems : null); var ItemAttributes = new AllItemAttributes(oldItemAttributes, newItemAttributes != null ? newItemAttributes : null); var Jobs = new AllJobs(Context, jobs); var JobLevels = new JobLevels(Context, jobLevels, new JobLevels(Context, Context == Context.US_PSP ? PSPResources.Binaries.JobLevels : PSXResources.Binaries.JobLevels)); var SkillSets = new AllSkillSets(Context, skillSets, Context == Context.US_PSP ? PSPResources.Binaries.SkillSets : PSXResources.Binaries.SkillSets); var MonsterSkills = new AllMonsterSkills(monsterSkills); var ActionMenus = new AllActionMenus(actionMenus, Context); var StatusAttributes = new AllStatusAttributes(statusAttributes); var InflictStatuses = new AllInflictStatuses(inflictStatuses); var PoachProbabilities = new AllPoachProbabilities(poach); var ENTDs = psp ? new AllENTDs(entd1, entd2, entd3, entd4, entd5) : new AllENTDs(entd1, entd2, entd3, entd4); var MoveFind = new AllMoveFindItems(Context, moveFind, new AllMoveFindItems(Context, psp ? PSPResources.Binaries.MoveFind : PSXResources.Binaries.MoveFind)); var StoreInventories = new AllStoreInventories(Context, inventories, psp ? PSPResources.Binaries.StoreInventories : PSXResources.Binaries.StoreInventories); var Propositions = new AllPropositions(propositions, psp ? PSPResources.Binaries.Propositions : PSXResources.Binaries.Propositions, brokenLevelBonuses); FFTPatch.Propositions = Propositions; FFTPatch.Abilities = Abilities; FFTPatch.AbilityAnimations = AbilityAnimations; FFTPatch.Items = Items; FFTPatch.ItemAttributes = ItemAttributes; FFTPatch.Jobs = Jobs; FFTPatch.JobLevels = JobLevels; FFTPatch.SkillSets = SkillSets; FFTPatch.MonsterSkills = MonsterSkills; FFTPatch.ActionMenus = ActionMenus; FFTPatch.StatusAttributes = StatusAttributes; FFTPatch.InflictStatuses = InflictStatuses; FFTPatch.PoachProbabilities = PoachProbabilities; FFTPatch.ENTDs = ENTDs; FFTPatch.MoveFind = MoveFind; FFTPatch.StoreInventories = StoreInventories; } catch (Exception) { throw new LoadPatchException(); } }
public void UpdateView( AllPropositions props ) { this.props = props; UpdateListBox(); listBox1.SelectedIndex = 0; propositionEditor1.BindTo( props.Propositions[0], props.Prices, props.SmallBonuses, props.LargeBonuses ); }
private static void BuildFromContext() { switch (Context) { case Context.US_PSP: Abilities = new AllAbilities(PSPResources.Binaries.Abilities, PSPResources.Binaries.AbilityEffects, PSPResources.Binaries.ItemAbilityEffects, PSPResources.Binaries.ReactionAbilityEffects); AbilityAnimations = new AllAnimations(Context, PSPResources.Binaries.AbilityAnimations, PSPResources.Binaries.AbilityAnimations); Items = new AllItems( PSPResources.Binaries.OldItems, PSPResources.Binaries.NewItems); ItemAttributes = new AllItemAttributes( PSPResources.Binaries.OldItemAttributes, PSPResources.Binaries.NewItemAttributes); Jobs = new AllJobs(Context, PSPResources.Binaries.Jobs); JobLevels = new JobLevels(Context, PSPResources.Binaries.JobLevels, new JobLevels(Context, PSPResources.Binaries.JobLevels)); SkillSets = new AllSkillSets(Context, PSPResources.Binaries.SkillSets, PSPResources.Binaries.SkillSets); MonsterSkills = new AllMonsterSkills(PSPResources.Binaries.MonsterSkills); ActionMenus = new AllActionMenus(PSPResources.Binaries.ActionEvents, Context); StatusAttributes = new AllStatusAttributes(PSPResources.Binaries.StatusAttributes); InflictStatuses = new AllInflictStatuses(PSPResources.Binaries.InflictStatuses); PoachProbabilities = new AllPoachProbabilities(PSPResources.Binaries.PoachProbabilities); ENTDs = new AllENTDs(PSPResources.Binaries.ENTD1, PSPResources.Binaries.ENTD2, PSPResources.Binaries.ENTD3, PSPResources.Binaries.ENTD4, PSPResources.Binaries.ENTD5); MoveFind = new AllMoveFindItems(Context, PSPResources.Binaries.MoveFind, new AllMoveFindItems(Context, PSPResources.Binaries.MoveFind)); StoreInventories = new AllStoreInventories(Context, PSPResources.Binaries.StoreInventories, PSPResources.Binaries.StoreInventories); Propositions = new AllPropositions(PSPResources.Binaries.Propositions, PSPResources.Binaries.Propositions, false); break; case Context.US_PSX: Abilities = new AllAbilities(PSXResources.Binaries.Abilities, PSXResources.Binaries.AbilityEffects, PSXResources.Binaries.ItemAbilityEffects, PSXResources.Binaries.ReactionAbilityEffects); AbilityAnimations = new AllAnimations(Context, PSXResources.Binaries.AbilityAnimations, PSXResources.Binaries.AbilityAnimations); Items = new AllItems(PSXResources.Binaries.OldItems, null); ItemAttributes = new AllItemAttributes(PSXResources.Binaries.OldItemAttributes, null); Jobs = new AllJobs(Context, PSXResources.Binaries.Jobs); JobLevels = new JobLevels(Context, PSXResources.Binaries.JobLevels, new JobLevels(Context, PSXResources.Binaries.JobLevels)); SkillSets = new AllSkillSets(Context, PSXResources.Binaries.SkillSets, PSXResources.Binaries.SkillSets); MonsterSkills = new AllMonsterSkills(PSXResources.Binaries.MonsterSkills); ActionMenus = new AllActionMenus(PSXResources.Binaries.ActionEvents, Context); StatusAttributes = new AllStatusAttributes(PSXResources.Binaries.StatusAttributes); InflictStatuses = new AllInflictStatuses(PSXResources.Binaries.InflictStatuses); PoachProbabilities = new AllPoachProbabilities(PSXResources.Binaries.PoachProbabilities); ENTDs = new AllENTDs(PSXResources.Binaries.ENTD1, PSXResources.Binaries.ENTD2, PSXResources.Binaries.ENTD3, PSXResources.Binaries.ENTD4); MoveFind = new AllMoveFindItems(Context, PSXResources.Binaries.MoveFind, new AllMoveFindItems(Context, PSXResources.Binaries.MoveFind)); StoreInventories = new AllStoreInventories(Context, PSXResources.Binaries.StoreInventories, PSXResources.Binaries.StoreInventories); Propositions = new AllPropositions(PSXResources.Binaries.Propositions, PSXResources.Binaries.Propositions, false); break; default: throw new ArgumentException(); } }
private static void SaveZippedPatch(string path, Context destinationContext) { using (ZipOutputStream stream = new ZipOutputStream(File.Open(path, FileMode.Create, FileAccess.ReadWrite))) { const string fileVersion = "1.0"; bool psp = destinationContext == Context.US_PSP; WriteFileToZip(stream, "version", Encoding.UTF8.GetBytes(fileVersion)); WriteFileToZip(stream, "type", Encoding.UTF8.GetBytes(destinationContext.ToString())); WriteFileToZip(stream, elementNames[ElementName.Abilities], Abilities.ToByteArray(destinationContext)); WriteFileToZip(stream, elementNames[ElementName.AbilityAnimations], AbilityAnimations.ToByteArray()); WriteFileToZip(stream, elementNames[ElementName.AbilityEffects], Abilities.ToEffectsByteArray()); WriteFileToZip(stream, elementNames[ElementName.ItemAbilityEffects], Abilities.ToItemEffectsByteArray()); WriteFileToZip(stream, elementNames[ElementName.ReactionAbilityEffects], Abilities.ToReactionEffectsByteArray()); WriteFileToZip(stream, elementNames[ElementName.Items], Items.ToFirstByteArray()); WriteFileToZip(stream, elementNames[ElementName.ItemAttributes], ItemAttributes.ToFirstByteArray()); if (psp && Context == Context.US_PSP) { WriteFileToZip(stream, elementNames[ElementName.PSPItems], Items.ToSecondByteArray()); WriteFileToZip(stream, elementNames[ElementName.PSPItemAttributes], ItemAttributes.ToSecondByteArray()); WriteFileToZip(stream, elementNames[ElementName.ENTD5], ENTDs.PSPEventsToByteArray()); } WriteFileToZip(stream, elementNames[ElementName.Jobs], Jobs.ToByteArray(destinationContext)); WriteFileToZip(stream, elementNames[ElementName.JobLevels], JobLevels.ToByteArray(destinationContext)); WriteFileToZip(stream, elementNames[ElementName.MonsterSkills], MonsterSkills.ToByteArray(destinationContext)); WriteFileToZip(stream, elementNames[ElementName.SkillSets], SkillSets.ToByteArray(destinationContext)); WriteFileToZip(stream, elementNames[ElementName.ActionMenus], ActionMenus.ToByteArray(destinationContext)); WriteFileToZip(stream, elementNames[ElementName.StatusAttributes], StatusAttributes.ToByteArray(destinationContext)); WriteFileToZip(stream, elementNames[ElementName.InflictStatuses], InflictStatuses.ToByteArray()); WriteFileToZip(stream, elementNames[ElementName.Poaching], PoachProbabilities.ToByteArray(destinationContext)); WriteFileToZip(stream, elementNames[ElementName.ENTD1], ENTDs.ENTDs[0].ToByteArray()); WriteFileToZip(stream, elementNames[ElementName.ENTD2], ENTDs.ENTDs[1].ToByteArray()); WriteFileToZip(stream, elementNames[ElementName.ENTD3], ENTDs.ENTDs[2].ToByteArray()); WriteFileToZip(stream, elementNames[ElementName.ENTD4], ENTDs.ENTDs[3].ToByteArray()); WriteFileToZip(stream, elementNames[ElementName.MoveFindItems], MoveFind.ToByteArray()); WriteFileToZip(stream, elementNames[ElementName.StoreInventories], StoreInventories.ToByteArray()); WriteFileToZip(stream, elementNames[ElementName.Propositions], Propositions.ToByteArray()); if (!AllPropositions.CanFixBuggyLevelBonuses(destinationContext)) { WriteFileToZip(stream, "BuggyPropositions", new byte[0]); } } }
public void UpdateView( AllPropositions allProps ) { ignoreChanges = true; props = allProps; for (int i = 0; i < 8; i++) { jpBonusSpinners[i].SetValueAndDefault( allProps.SmallBonuses[i], allProps.Default.SmallBonuses[i] ); gilBonusSpinners[i].SetValueAndDefault( allProps.LargeBonuses[i], allProps.Default.LargeBonuses[i] ); } for (int i = 0; i < 10; i++) { jpMultiplierSpinners[i].SetValueAndDefault( allProps.JPMultipliers[i], allProps.Default.JPMultipliers[i] ); gilMultiplierSpinners[i].SetValueAndDefault( allProps.GilMultipliers[i], allProps.Default.GilMultipliers[i] ); } classBonusesEditor1.UpdateView( allProps ); statLevelBonusesEditor1.UpdateView( allProps ); additionalRewardsEditor1.UpdateView( allProps ); allPropositionDetailsEditor1.UpdateView( allProps ); ignoreChanges = false; }
public static void OpenPatchedPspIso(string filename) { using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) { Context = Context.US_PSP; PatcherLib.Iso.PspIso.PspIsoInfo info = PatcherLib.Iso.PspIso.PspIsoInfo.GetPspIsoInfo(stream); LoadDataFromBytes( PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.Abilities[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.AbilityEffects[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.ItemAbilityEffects[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.ReactionAbilityEffects[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.AbilityAnimations[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.OldItems[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.OldItemAttributes[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.NewItems[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.NewItemAttributes[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.Jobs[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.JobLevels[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.SkillSets[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.MonsterSkills[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.ActionEvents[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.StatusAttributes[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.InflictStatuses[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.PoachProbabilities[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.ENTD1), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.ENTD2), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.ENTD3), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.ENTD4), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.ENTD5), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.MoveFindItems[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.StoreInventories[0]), PatcherLib.Iso.PspIso.GetBlock(stream, info, PatcherLib.Iso.PspIso.Propositions[0]), AllPropositions.IsoHasBuggyLevelBonuses(stream, Context.US_PSP)); FireDataChangedEvent(); } }
public AllPropositions( IList<byte> bytes, AllPropositions defaults, bool brokenLevelBonuses ) { Default = defaults; var names = FFTPatch.Context == Context.US_PSP ? PSPResources.Lists.Propositions : PSXResources.Lists.Propositions; List<Proposition> props = new List<Proposition>(); if (defaults != null) { for (int i = 0; i < NumPropositions; i++) { props.Add( new Proposition( names[i], bytes.Sub( i * propLength, (i + 1) * propLength - 1 ), defaults.Propositions[i] ) ); } } else { for (int i = 0; i < NumPropositions; i++) { props.Add( new Proposition( names[i], bytes.Sub( i * propLength, (i + 1) * propLength - 1 ) ) ); } } Prices = new UInt16[8]; for (int i = 0; i < 8; i++) { var b = bytes.Sub( propLength * NumPropositions + i * 2 + 2, propLength * NumPropositions + i * 2 + 2 + 1 ); Prices[i] = Utilities.BytesToUShort( b[0], b[1] ); } unknownBytes = bytes.Sub( 0x8b2, 0x8bf ).ToArray(); propTypeBonuses = new TupleDictionary<PropositionType, PropositionClass, byte>(); foreach (PropositionType type in (PropositionType[])Enum.GetValues( typeof( PropositionType ) )) { foreach (PropositionClass _class in (PropositionClass[])Enum.GetValues( typeof( PropositionClass ) )) { propTypeBonuses[type, _class] = bytes[0x8C0 + ((int)type - 1) * 22 + (int)_class]; } } propTypeBonuses = new TupleDictionary<PropositionType, PropositionClass, byte>( propTypeBonuses, false, true ); bfBonuses = new TupleDictionary<BraveFaithNeutral, PropositionClass, byte>(); foreach (BraveFaithNeutral bfn in (BraveFaithNeutral[])Enum.GetValues( typeof( BraveFaithNeutral ) )) { foreach (PropositionClass _class in (PropositionClass[])Enum.GetValues( typeof( PropositionClass ) )) { bfBonuses[bfn, _class] = bytes[0x970 + ((int)bfn - 1) * 22 + (int)_class]; } } bfBonuses = new TupleDictionary<BraveFaithNeutral, PropositionClass, byte>( bfBonuses, false, true ); braveBonuses = new TupleDictionary<BraveFaithNeutral, BraveFaithRange, byte>(); faithBonuses = new TupleDictionary<BraveFaithNeutral, BraveFaithRange, byte>(); levelBonuses = new TupleDictionary<BraveFaithNeutral, LevelRange, byte>(); int levelBonusesOffset = brokenLevelBonuses ? 0x9B4 : 0x9D4; //int levelBonusesOffset = 0x9D4; foreach (BraveFaithNeutral bfn in (BraveFaithNeutral[])Enum.GetValues( typeof( BraveFaithNeutral ) )) { foreach (BraveFaithRange range in (BraveFaithRange[])Enum.GetValues( typeof( BraveFaithRange ) )) { braveBonuses[bfn, range] = bytes[0x9B4 + ((int)bfn - 1) * 5 + (int)range]; faithBonuses[bfn, range] = bytes[0x9C4 + ((int)bfn - 1) * 5 + (int)range]; } foreach (LevelRange range in (LevelRange[])Enum.GetValues( typeof( LevelRange ) )) { levelBonuses[bfn, range] = bytes[levelBonusesOffset + ((int)bfn - 1) * 10 + (int)range]; } } braveBonuses = new TupleDictionary<BraveFaithNeutral, BraveFaithRange, byte>( braveBonuses, false, true ); faithBonuses = new TupleDictionary<BraveFaithNeutral, BraveFaithRange, byte>( faithBonuses, false, true ); levelBonuses = new TupleDictionary<BraveFaithNeutral, LevelRange, byte>( levelBonuses, false, true ); treasureLandJpBonuses = new Dictionary<PropositionType, BonusIndex>(); treasureLandGilBonuses = new Dictionary<PropositionType, BonusIndex>(); bonusCashGilBonuses = new TupleDictionary<PropositionType, BonusPercent, BonusIndex>(); bonusCashJpBonuses = new TupleDictionary<PropositionType, BonusPercent, BonusIndex>(); foreach (PropositionType type in (PropositionType[])Enum.GetValues( typeof( PropositionType ) )) { treasureLandGilBonuses[type] = (BonusIndex)bytes[0x9F4 + 2 * ((int)type - 1)]; treasureLandJpBonuses[type] = (BonusIndex)bytes[0x9F4 + 2 * ((int)type - 1) + 1]; bonusCashGilBonuses[type, BonusPercent._10Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 2]; bonusCashGilBonuses[type, BonusPercent._40Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 1]; bonusCashGilBonuses[type, BonusPercent._50Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 0]; bonusCashJpBonuses[type, BonusPercent._10Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 2 + 1]; bonusCashJpBonuses[type, BonusPercent._40Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 1 + 1]; bonusCashJpBonuses[type, BonusPercent._50Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 0 + 1]; } bonusCashGilBonuses = new TupleDictionary<PropositionType, BonusPercent, BonusIndex>( bonusCashGilBonuses, false, true ); bonusCashJpBonuses = new TupleDictionary<PropositionType, BonusPercent, BonusIndex>( bonusCashJpBonuses, false, true ); SmallBonuses = new UInt16[8]; LargeBonuses = new UInt16[8]; for (int i = 0; i < 8; i++) { SmallBonuses[i] = Utilities.BytesToUShort( bytes[0xA34 + i * 2], bytes[0xA34 + i * 2 + 1] ); LargeBonuses[i] = Utilities.BytesToUShort( bytes[0xA44 + i * 2], bytes[0xA44 + i * 2 + 1] ); } JPMultipliers = new UInt16[10]; GilMultipliers = new UInt16[10]; for (int i = 0; i < 10; i++) { JPMultipliers[i] = Utilities.BytesToUShort( bytes[0xA54 + i * 2], bytes[0xA54 + i * 2 + 1] ); GilMultipliers[i] = Utilities.BytesToUShort( bytes[0xA68 + i * 2], bytes[0xA68 + i * 2 + 1] ); } Propositions = props.AsReadOnly(); }
public AllPropositions(IList <byte> bytes, AllPropositions defaults, bool brokenLevelBonuses) { Default = defaults; var names = FFTPatch.Context == Context.US_PSP ? PSPResources.Lists.Propositions : PSXResources.Lists.Propositions; List <Proposition> props = new List <Proposition>(); if (defaults != null) { for (int i = 0; i < NumPropositions; i++) { props.Add(new Proposition(names[i], bytes.Sub(i * propLength, (i + 1) * propLength - 1), defaults.Propositions[i])); } } else { for (int i = 0; i < NumPropositions; i++) { props.Add(new Proposition(names[i], bytes.Sub(i * propLength, (i + 1) * propLength - 1))); } } Prices = new UInt16[8]; for (int i = 0; i < 8; i++) { var b = bytes.Sub(propLength * NumPropositions + i * 2 + 2, propLength * NumPropositions + i * 2 + 2 + 1); Prices[i] = Utilities.BytesToUShort(b[0], b[1]); } unknownBytes = bytes.Sub(0x8b2, 0x8bf).ToArray(); propTypeBonuses = new TupleDictionary <PropositionType, PropositionClass, byte>(); foreach (PropositionType type in (PropositionType[])Enum.GetValues(typeof(PropositionType))) { foreach (PropositionClass _class in (PropositionClass[])Enum.GetValues(typeof(PropositionClass))) { propTypeBonuses[type, _class] = bytes[0x8C0 + ((int)type - 1) * 22 + (int)_class]; } } propTypeBonuses = new TupleDictionary <PropositionType, PropositionClass, byte>(propTypeBonuses, false, true); bfBonuses = new TupleDictionary <BraveFaithNeutral, PropositionClass, byte>(); foreach (BraveFaithNeutral bfn in (BraveFaithNeutral[])Enum.GetValues(typeof(BraveFaithNeutral))) { foreach (PropositionClass _class in (PropositionClass[])Enum.GetValues(typeof(PropositionClass))) { bfBonuses[bfn, _class] = bytes[0x970 + ((int)bfn - 1) * 22 + (int)_class]; } } bfBonuses = new TupleDictionary <BraveFaithNeutral, PropositionClass, byte>(bfBonuses, false, true); braveBonuses = new TupleDictionary <BraveFaithNeutral, BraveFaithRange, byte>(); faithBonuses = new TupleDictionary <BraveFaithNeutral, BraveFaithRange, byte>(); levelBonuses = new TupleDictionary <BraveFaithNeutral, LevelRange, byte>(); int levelBonusesOffset = brokenLevelBonuses ? 0x9B4 : 0x9D4; //int levelBonusesOffset = 0x9D4; foreach (BraveFaithNeutral bfn in (BraveFaithNeutral[])Enum.GetValues(typeof(BraveFaithNeutral))) { foreach (BraveFaithRange range in (BraveFaithRange[])Enum.GetValues(typeof(BraveFaithRange))) { braveBonuses[bfn, range] = bytes[0x9B4 + ((int)bfn - 1) * 5 + (int)range]; faithBonuses[bfn, range] = bytes[0x9C4 + ((int)bfn - 1) * 5 + (int)range]; } foreach (LevelRange range in (LevelRange[])Enum.GetValues(typeof(LevelRange))) { levelBonuses[bfn, range] = bytes[levelBonusesOffset + ((int)bfn - 1) * 10 + (int)range]; } } braveBonuses = new TupleDictionary <BraveFaithNeutral, BraveFaithRange, byte>(braveBonuses, false, true); faithBonuses = new TupleDictionary <BraveFaithNeutral, BraveFaithRange, byte>(faithBonuses, false, true); levelBonuses = new TupleDictionary <BraveFaithNeutral, LevelRange, byte>(levelBonuses, false, true); treasureLandJpBonuses = new Dictionary <PropositionType, BonusIndex>(); treasureLandGilBonuses = new Dictionary <PropositionType, BonusIndex>(); bonusCashGilBonuses = new TupleDictionary <PropositionType, BonusPercent, BonusIndex>(); bonusCashJpBonuses = new TupleDictionary <PropositionType, BonusPercent, BonusIndex>(); foreach (PropositionType type in (PropositionType[])Enum.GetValues(typeof(PropositionType))) { treasureLandGilBonuses[type] = (BonusIndex)bytes[0x9F4 + 2 * ((int)type - 1)]; treasureLandJpBonuses[type] = (BonusIndex)bytes[0x9F4 + 2 * ((int)type - 1) + 1]; bonusCashGilBonuses[type, BonusPercent._10Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 2]; bonusCashGilBonuses[type, BonusPercent._40Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 1]; bonusCashGilBonuses[type, BonusPercent._50Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 0]; bonusCashJpBonuses[type, BonusPercent._10Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 2 + 1]; bonusCashJpBonuses[type, BonusPercent._40Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 1 + 1]; bonusCashJpBonuses[type, BonusPercent._50Percent] = (BonusIndex)bytes[0xA04 + ((int)type - 1) * 6 + 2 * 0 + 1]; } bonusCashGilBonuses = new TupleDictionary <PropositionType, BonusPercent, BonusIndex>(bonusCashGilBonuses, false, true); bonusCashJpBonuses = new TupleDictionary <PropositionType, BonusPercent, BonusIndex>(bonusCashJpBonuses, false, true); SmallBonuses = new UInt16[8]; LargeBonuses = new UInt16[8]; for (int i = 0; i < 8; i++) { SmallBonuses[i] = Utilities.BytesToUShort(bytes[0xA34 + i * 2], bytes[0xA34 + i * 2 + 1]); LargeBonuses[i] = Utilities.BytesToUShort(bytes[0xA44 + i * 2], bytes[0xA44 + i * 2 + 1]); } JPMultipliers = new UInt16[10]; GilMultipliers = new UInt16[10]; for (int i = 0; i < 10; i++) { JPMultipliers[i] = Utilities.BytesToUShort(bytes[0xA54 + i * 2], bytes[0xA54 + i * 2 + 1]); GilMultipliers[i] = Utilities.BytesToUShort(bytes[0xA68 + i * 2], bytes[0xA68 + i * 2 + 1]); } Propositions = props.AsReadOnly(); }
public static void ConvertPsxPatchToPsp(string filename) { Dictionary <string, byte[]> fileList = new Dictionary <string, byte[]>(); using (ZipFile zipFile = new ZipFile(filename)) { foreach (ZipEntry entry in zipFile) { byte[] bytes = new byte[entry.Size]; StreamUtils.ReadFully(zipFile.GetInputStream(entry), bytes); fileList[entry.Name] = bytes; } } File.Delete(filename); if (fileList["type"].ToUTF8String() == Context.US_PSX.ToString()) { List <byte> amBytes = new List <byte>(fileList["actionMenus"]); amBytes.AddRange(PSPResources.Binaries.ActionEvents.Sub(0xE0, 0xE2)); fileList["actionMenus"] = amBytes.ToArray(); AllJobs aj = new AllJobs(Context.US_PSX, fileList["jobs"]); List <Job> jobs = new List <Job>(aj.Jobs); AllJobs defaultPspJobs = new AllJobs(Context.US_PSP, PSPResources.Binaries.Jobs); for (int i = 0; i < jobs.Count; i++) { jobs[i].Equipment.Unknown1 = defaultPspJobs.Jobs[i].Equipment.Unknown1; jobs[i].Equipment.Unknown2 = defaultPspJobs.Jobs[i].Equipment.Unknown2; jobs[i].Equipment.Unknown3 = defaultPspJobs.Jobs[i].Equipment.Unknown3; jobs[i].Equipment.FellSword = defaultPspJobs.Jobs[i].Equipment.FellSword; jobs[i].Equipment.LipRouge = defaultPspJobs.Jobs[i].Equipment.LipRouge; jobs[i].Equipment.Unknown6 = defaultPspJobs.Jobs[i].Equipment.Unknown6; jobs[i].Equipment.Unknown7 = defaultPspJobs.Jobs[i].Equipment.Unknown7; jobs[i].Equipment.Unknown8 = defaultPspJobs.Jobs[i].Equipment.Unknown8; } for (int i = 160; i < 169; i++) { jobs.Add(defaultPspJobs.Jobs[i]); } ReflectionHelpers.SetFieldOrProperty(aj, "Jobs", jobs.ToArray()); fileList["jobs"] = aj.ToByteArray(Context.US_PSP); JobLevels jl = new JobLevels(Context.US_PSX, fileList["jobLevels"]); JobLevels pspJobLevels = new JobLevels(Context.US_PSP, PSPResources.Binaries.JobLevels); foreach (string jobName in new string[19] { "Archer", "Arithmetician", "Bard", "BlackMage", "Chemist", "Dancer", "Dragoon", "Geomancer", "Knight", "Mime", "Monk", "Mystic", "Ninja", "Orator", "Samurai", "Summoner", "Thief", "TimeMage", "WhiteMage" }) { Requirements psxR = ReflectionHelpers.GetFieldOrProperty <Requirements>(jl, jobName); Requirements pspR = ReflectionHelpers.GetFieldOrProperty <Requirements>(pspJobLevels, jobName); psxR.Unknown1 = pspR.Unknown1; psxR.Unknown2 = pspR.Unknown2; psxR.DarkKnight = pspR.DarkKnight; psxR.OnionKnight = pspR.OnionKnight; } ReflectionHelpers.SetFieldOrProperty(jl, "OnionKnight", pspJobLevels.OnionKnight); ReflectionHelpers.SetFieldOrProperty(jl, "DarkKnight", pspJobLevels.DarkKnight); ReflectionHelpers.SetFieldOrProperty(jl, "Unknown", pspJobLevels.Unknown); fileList["jobLevels"] = jl.ToByteArray(Context.US_PSP); List <byte> ssBytes = new List <byte>(fileList["skillSets"]); ssBytes.AddRange(PSPResources.Binaries.SkillSets.Sub(ssBytes.Count)); fileList["skillSets"] = ssBytes.ToArray(); fileList["entd5"] = PSPResources.Binaries.ENTD5.ToArray(); fileList["type"] = Encoding.UTF8.GetBytes(Context.US_PSP.ToString()); fileList["pspItemAttributes"] = PSPResources.Binaries.NewItemAttributes.ToArray(); fileList["pspItems"] = PSPResources.Binaries.NewItems.ToArray(); if (!AllPropositions.CanFixBuggyLevelBonuses(Context.US_PSP)) { fileList["BuggyPropositions"] = new byte[0]; } else if (fileList.ContainsKey("BuggyPropositions")) { fileList.Remove("BuggyPropositions"); } } using (FileStream outFile = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite)) using (ZipOutputStream output = new ZipOutputStream(outFile)) { foreach (KeyValuePair <string, byte[]> entry in fileList) { WriteFileToZip(output, entry.Key, entry.Value); } } }
private static void LoadDataFromBytes( IList<byte> abilities, IList<byte> abilityEffects, IList<byte> itemAbilityEffects, IList<byte> reactionEffects, IList<byte> abilityAnimations, IList<byte> oldItems, IList<byte> oldItemAttributes, IList<byte> newItems, IList<byte> newItemAttributes, IList<byte> jobs, IList<byte> jobLevels, IList<byte> skillSets, IList<byte> monsterSkills, IList<byte> actionMenus, IList<byte> statusAttributes, IList<byte> inflictStatuses, IList<byte> poach, IList<byte> entd1, IList<byte> entd2, IList<byte> entd3, IList<byte> entd4, IList<byte> entd5, IList<byte> moveFind, IList<byte> inventories, IList<byte> propositions, bool brokenLevelBonuses ) { try { bool psp = Context == Context.US_PSP; var Abilities = new AllAbilities( abilities, abilityEffects, itemAbilityEffects, reactionEffects ); var AbilityAnimations = new AllAnimations( Context, abilityAnimations, psp ? PSPResources.Binaries.AbilityAnimations : PSXResources.Binaries.AbilityAnimations ); var Items = new AllItems( oldItems, newItems != null ? newItems : null ); var ItemAttributes = new AllItemAttributes( oldItemAttributes, newItemAttributes != null ? newItemAttributes : null ); var Jobs = new AllJobs( Context, jobs ); var JobLevels = new JobLevels( Context, jobLevels, new JobLevels( Context, Context == Context.US_PSP ? PSPResources.Binaries.JobLevels : PSXResources.Binaries.JobLevels ) ); var SkillSets = new AllSkillSets( Context, skillSets, Context == Context.US_PSP ? PSPResources.Binaries.SkillSets : PSXResources.Binaries.SkillSets ); var MonsterSkills = new AllMonsterSkills( monsterSkills ); var ActionMenus = new AllActionMenus( actionMenus, Context ); var StatusAttributes = new AllStatusAttributes( statusAttributes ); var InflictStatuses = new AllInflictStatuses( inflictStatuses ); var PoachProbabilities = new AllPoachProbabilities( poach ); var ENTDs = psp ? new AllENTDs( entd1, entd2, entd3, entd4, entd5 ) : new AllENTDs( entd1, entd2, entd3, entd4 ); var MoveFind = new AllMoveFindItems( Context, moveFind, new AllMoveFindItems( Context, psp ? PSPResources.Binaries.MoveFind : PSXResources.Binaries.MoveFind ) ); var StoreInventories = new AllStoreInventories( Context, inventories, psp ? PSPResources.Binaries.StoreInventories : PSXResources.Binaries.StoreInventories ); var Propositions = new AllPropositions( propositions, psp ? PSPResources.Binaries.Propositions : PSXResources.Binaries.Propositions, brokenLevelBonuses ); FFTPatch.Propositions = Propositions; FFTPatch.Abilities = Abilities; FFTPatch.AbilityAnimations = AbilityAnimations; FFTPatch.Items = Items; FFTPatch.ItemAttributes = ItemAttributes; FFTPatch.Jobs = Jobs; FFTPatch.JobLevels = JobLevels; FFTPatch.SkillSets = SkillSets; FFTPatch.MonsterSkills = MonsterSkills; FFTPatch.ActionMenus = ActionMenus; FFTPatch.StatusAttributes = StatusAttributes; FFTPatch.InflictStatuses = InflictStatuses; FFTPatch.PoachProbabilities = PoachProbabilities; FFTPatch.ENTDs = ENTDs; FFTPatch.MoveFind = MoveFind; FFTPatch.StoreInventories = StoreInventories; } catch( Exception ) { throw new LoadPatchException(); } }
private static void BuildFromContext() { switch( Context ) { case Context.US_PSP: Abilities = new AllAbilities( PSPResources.Binaries.Abilities, PSPResources.Binaries.AbilityEffects, PSPResources.Binaries.ItemAbilityEffects, PSPResources.Binaries.ReactionAbilityEffects ); AbilityAnimations = new AllAnimations( Context, PSPResources.Binaries.AbilityAnimations, PSPResources.Binaries.AbilityAnimations ); Items = new AllItems( PSPResources.Binaries.OldItems, PSPResources.Binaries.NewItems ); ItemAttributes = new AllItemAttributes( PSPResources.Binaries.OldItemAttributes, PSPResources.Binaries.NewItemAttributes ); Jobs = new AllJobs( Context, PSPResources.Binaries.Jobs ); JobLevels = new JobLevels( Context, PSPResources.Binaries.JobLevels, new JobLevels( Context, PSPResources.Binaries.JobLevels ) ); SkillSets = new AllSkillSets( Context, PSPResources.Binaries.SkillSets, PSPResources.Binaries.SkillSets ); MonsterSkills = new AllMonsterSkills( PSPResources.Binaries.MonsterSkills ); ActionMenus = new AllActionMenus( PSPResources.Binaries.ActionEvents, Context ); StatusAttributes = new AllStatusAttributes( PSPResources.Binaries.StatusAttributes ); InflictStatuses = new AllInflictStatuses( PSPResources.Binaries.InflictStatuses ); PoachProbabilities = new AllPoachProbabilities( PSPResources.Binaries.PoachProbabilities ); ENTDs = new AllENTDs( PSPResources.Binaries.ENTD1, PSPResources.Binaries.ENTD2, PSPResources.Binaries.ENTD3, PSPResources.Binaries.ENTD4, PSPResources.Binaries.ENTD5 ); MoveFind = new AllMoveFindItems( Context, PSPResources.Binaries.MoveFind, new AllMoveFindItems( Context, PSPResources.Binaries.MoveFind ) ); StoreInventories = new AllStoreInventories( Context, PSPResources.Binaries.StoreInventories, PSPResources.Binaries.StoreInventories ); Propositions = new AllPropositions( PSPResources.Binaries.Propositions, PSPResources.Binaries.Propositions, false ); break; case Context.US_PSX: Abilities = new AllAbilities( PSXResources.Binaries.Abilities, PSXResources.Binaries.AbilityEffects, PSXResources.Binaries.ItemAbilityEffects, PSXResources.Binaries.ReactionAbilityEffects ); AbilityAnimations = new AllAnimations( Context, PSXResources.Binaries.AbilityAnimations, PSXResources.Binaries.AbilityAnimations ); Items = new AllItems( PSXResources.Binaries.OldItems, null ); ItemAttributes = new AllItemAttributes( PSXResources.Binaries.OldItemAttributes, null ); Jobs = new AllJobs( Context, PSXResources.Binaries.Jobs ); JobLevels = new JobLevels( Context, PSXResources.Binaries.JobLevels, new JobLevels( Context, PSXResources.Binaries.JobLevels ) ); SkillSets = new AllSkillSets( Context, PSXResources.Binaries.SkillSets, PSXResources.Binaries.SkillSets ); MonsterSkills = new AllMonsterSkills( PSXResources.Binaries.MonsterSkills ); ActionMenus = new AllActionMenus( PSXResources.Binaries.ActionEvents, Context ); StatusAttributes = new AllStatusAttributes( PSXResources.Binaries.StatusAttributes ); InflictStatuses = new AllInflictStatuses( PSXResources.Binaries.InflictStatuses ); PoachProbabilities = new AllPoachProbabilities( PSXResources.Binaries.PoachProbabilities ); ENTDs = new AllENTDs( PSXResources.Binaries.ENTD1, PSXResources.Binaries.ENTD2, PSXResources.Binaries.ENTD3, PSXResources.Binaries.ENTD4 ); MoveFind = new AllMoveFindItems( Context, PSXResources.Binaries.MoveFind, new AllMoveFindItems( Context, PSXResources.Binaries.MoveFind ) ); StoreInventories = new AllStoreInventories( Context, PSXResources.Binaries.StoreInventories, PSXResources.Binaries.StoreInventories ); Propositions = new AllPropositions( PSXResources.Binaries.Propositions, PSXResources.Binaries.Propositions, false ); break; default: throw new ArgumentException(); } }
public void UpdateView( AllPropositions props ) { this.props = props; RefreshDataSources(); UpdateAllComboBoxes(); }
public void UpdateView( AllPropositions props ) { ignoreChanges = true; this.props = props; levelBonuses = props.LevelBonuses; levelBonusesDefault = props.Default.LevelBonuses; braveBonuses = props.BraveStatBonuses; braveBonusesDefault = props.Default.BraveStatBonuses; faithBonuses = props.FaithStatBonuses; faithBonusesDefault = props.Default.FaithStatBonuses; UpdateRowHeaders( FFTPatch.Context ); foreach (BraveFaithNeutral bfn in (BraveFaithNeutral[])Enum.GetValues( typeof( BraveFaithNeutral ) )) { foreach (BraveFaithRange bfr in (BraveFaithRange[])Enum.GetValues( typeof( BraveFaithRange ) )) { var thisTuple = Tuple.From( bfn, bfr ); if (braveBonuses.ContainsKey( thisTuple )) { dataGridView1[(int)bfn, (int)bfr + braveBonusesFirstRow].Value = braveBonuses[bfn, bfr]; } if (faithBonuses.ContainsKey( thisTuple )) { dataGridView1[(int)bfn, (int)bfr + faithBonusesFirstRow].Value = faithBonuses[bfn, bfr]; } } foreach (LevelRange lr in (LevelRange[])Enum.GetValues( typeof( LevelRange ) )) { if (levelBonuses.ContainsKey( Tuple.From( bfn, lr ) )) { dataGridView1[(int)bfn, (int)lr + levelBonusesFirstRow].Value = levelBonuses[bfn, lr]; } } } ignoreChanges = false; }