private void Read() { ulong absoluteFirstOffset = AbsolutePokemonIndexOffset(ActorDataList.First()); // TODO: get rid of the ArmInstruction class and add encoding and decoding functions for // the instructions used here to CodeGenerationHelper instead. var firstOffsetInstruction = new ArmInstruction(BitConverter.ToUInt32(executable.Data, (int)absoluteFirstOffset)); if (!firstOffsetInstruction.IsSupported) { throw new InvalidOperationException("Cannot read Actor database - maybe an incompatible version was used?"); } foreach (var actorData in ActorDataList.Where(actorData => actorData.PokemonIndexEditable)) { var instruction = new ArmInstruction(BitConverter.ToUInt32(executable.Data, (int)AbsolutePokemonIndexOffset(actorData))); if (instruction.IsSupported) { // It doesn't matter if the instruction is unsupported here because we can rely // on the hardcoded values PegasusActDatabase.Data.cs and it will be readable after edits. actorData.PokemonIndex = (CreatureIndex)instruction.Value; } } }
public void Write() { // TODO: get rid of the ArmInstruction class and add encoding and decoding functions for // the instructions used here to CodeGenerationHelper instead. foreach (var actorData in ActorDataList.Where(actorData => actorData.PokemonIndexEditable)) { var instruction = new ArmInstruction(BitConverter.ToUInt32(executable.Data, (int)AbsolutePokemonIndexOffset(actorData))); if (instruction.IsSupported) { instruction.Value = (ushort)actorData.PokemonIndex; } else if (instruction.Code == ArmInstructionCode.MovBitmaskImmediateToWRegister) { // Replace the unsupported instruction with an equivalent one instruction = new ArmInstruction(ArmInstructionCode.MovImmediateToWRegister, instruction.Register, (ushort)actorData.PokemonIndex); } BitConverter.GetBytes(instruction.RawInstruction).CopyTo(executable.Data, (int)AbsolutePokemonIndexOffset(actorData)); } }
private void OnEnable() { _database = new RPGDatabaseManager(); _database.Load(); if (_database.TotalEntries == 0) { DatabaseFolderHandler.ValidateAllFolders(); DatabaseFactory.CreateDatabase(); _database.Load(); } _actorDataList = _database.FetchEntry <ActorDataList>(); _classDataList = _database.FetchEntry <ActorClassDataList>(); _skillDataList = _database.FetchEntry <SkillDataList>(); _itemDataList = _database.FetchEntry <ItemDataList>(); _weaponDataList = _database.FetchEntry <WeaponDataList>(); _weaponTypeDataList = _database.FetchEntry <WeaponTypeDataList>(); _attributeSpectDataList = _database.FetchEntry <AttributeSpecDataList>(); _actorListSection = new ListSection <ActorData>(_actorDataList, "Actors"); _classListSection = new ListSection <ActorClassData>(_classDataList, "Classes"); _skillListSection = new ListSection <SkillData>(_skillDataList, "Skills"); _itemListSection = new ListSection <ItemData>(_itemDataList, "Items"); _weaponListSection = new ListSection <WeaponData>(_weaponDataList, "Weapons"); _weaponTypeListSection = new ListSection <WeaponTypeData>(_weaponTypeDataList, "Weapon Types"); var flags = ReorderableListFlags.ShowIndices | ReorderableListFlags.HideAddButton | ReorderableListFlags.DisableReordering | ReorderableListFlags.HideRemoveButtons; _attributeSpecListSection = new ListSection <AttributeSpecData>(_attributeSpectDataList, "Attribute Specs", flags); _infoSection = new InfoSection(); _effectsSection = new EffectsSection(); _coreTabSelected = (CoreTabId)DatabaseEditorPrefs.CoreTab; _mainTabSelected = (MainTabId)DatabaseEditorPrefs.MainTab; _configTabSelected = (ConfigTabId)DatabaseEditorPrefs.ConfigTab; }