Skip to content

Commit

Permalink
Added [UserString] attribute to all known strings in .dat files that …
Browse files Browse the repository at this point in the history
…the users sees (These need translation)

Renamed a few unknowns in dat parsers
Removed some of the weird reflection horrors in LibDat, added dat parser factory/lookup functionality to DatFactory.cs
Moved MakeCSV() logic to RecordContainer.cs
LibDat interface now takes any stream as a source instead of BinaryReader
  • Loading branch information
nooperation committed Feb 12, 2013
1 parent 8375127 commit 364545c
Show file tree
Hide file tree
Showing 53 changed files with 1,221 additions and 314 deletions.
5 changes: 5 additions & 0 deletions LibDat/BaseRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public class StringIndex : System.Attribute { }
/// </summary>
public class DataIndex : System.Attribute { }

public class UserStringIndex : StringIndex
{
}


public abstract class BaseDat
{
/// <summary>
Expand Down
298 changes: 298 additions & 0 deletions LibDat/DatFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using LibDat.Files;

namespace LibDat
{
static class DatFactory
{
public static Type GetType(string fileName)
{
switch (fileName)
{
case "ActiveSkills":
return typeof(ActiveSkills);
case "ArmourTypes":
return typeof(ArmourTypes);
case "BackendErrors":
return typeof(BackendErrors);
case "BaseItemTypes":
return typeof(BaseItemTypes);
case "BloodTypes":
return typeof(BloodTypes);
case "BuffDefinitions":
return typeof(BuffDefinitions);
case "CharacterAudioEvents":
return typeof(CharacterAudioEvents);
case "Characters":
return typeof(Characters);
case "ChestClusters":
return typeof(ChestClusters);
case "Chests":
return typeof(Chests);
case "ComponentArmour":
return typeof(ComponentArmour);
case "ComponentAttributeRequirements":
return typeof(ComponentAttributeRequirements);
case "ComponentCharges":
return typeof(ComponentCharges);
case "CurrencyItems":
return typeof(CurrencyItems);
case "Dances":
return typeof(Dances);
case "DefaultMonsterStats":
return typeof(DefaultMonsterStats);
case "Difficulties":
return typeof(Difficulties);
case "DropPool":
return typeof(DropPool);
case "Environments":
return typeof(Environments);
case "ExperienceLevels":
return typeof(ExperienceLevels);
case "Flasks":
return typeof(Flasks);
case "FlavourText":
return typeof(FlavourText);
case "GameConstants":
return typeof(GameConstants);
case "GemTags":
return typeof(GemTags);
case "GrantedEffects":
return typeof(GrantedEffects);
case "GrantedEffectsPerLevel":
return typeof(GrantedEffectsPerLevel);
case "ItemExperiencePerLevel":
return typeof(ItemExperiencePerLevel);
case "ItemisedVisualEffect":
return typeof(ItemisedVisualEffect);
case "ItemVisualEffect":
return typeof(ItemVisualEffect);
case "ItemVisualIdentity":
return typeof(ItemVisualIdentity);
case "MapConnections":
return typeof(MapConnections);
case "MapPins":
return typeof(MapPins);
case "Maps":
return typeof(Maps);
case "MiscAnimated":
return typeof(MiscAnimated);
case "MiscObjects":
return typeof(MiscObjects);
case "Mods":
return typeof(Mods);
case "ModSellPrices":
return typeof(ModSellPrices);
case "MonsterPackEntries":
return typeof(MonsterPackEntries);
case "MonsterPacks":
return typeof(MonsterPacks);
case "MonsterTypes":
return typeof(MonsterTypes);
case "MonsterVarieties":
return typeof(MonsterVarieties);
case "Music":
return typeof(Music);
case "NPCs":
return typeof(NPCs);
case "NPCTalk":
return typeof(NPCTalk);
case "NPCTextAudio":
return typeof(NPCTextAudio);
case "PassiveSkills":
return typeof(PassiveSkills);
case "Pet":
return typeof(Pet);
case "Projectiles":
return typeof(Projectiles);
case "Quest":
return typeof(Quest);
case "QuestRewards":
return typeof(QuestRewards);
case "QuestStates":
return typeof(QuestStates);
case "QuestStaticRewards":
return typeof(QuestStaticRewards);
case "Realms":
return typeof(Realms);
case "ShieldTypes":
return typeof(ShieldTypes);
case "ShopItem":
return typeof(ShopItem);
case "ShopPaymentPackage":
return typeof(ShopPaymentPackage);
case "Shrines":
return typeof(Shrines);
case "SkillGems":
return typeof(SkillGems);
case "SoundEffects":
return typeof(SoundEffects);
case "Stats":
return typeof(Stats);
case "Tags":
return typeof(Tags);
case "Topologies":
return typeof(Topologies);
case "VoteState":
return typeof(VoteState);
case "VoteType":
return typeof(VoteType);
case "WeaponTypes":
return typeof(WeaponTypes);
case "Words":
return typeof(Words);
case "WorldAreas":
return typeof(WorldAreas);
}

return null;
}

public static BaseDat Create(string fileName, BinaryReader inStream)
{
switch (fileName)
{
case "ActiveSkills":
return new ActiveSkills(inStream);
case "ArmourTypes":
return new ArmourTypes(inStream);
case "BackendErrors":
return new BackendErrors(inStream);
case "BaseItemTypes":
return new BaseItemTypes(inStream);
case "BloodTypes":
return new BloodTypes(inStream);
case "BuffDefinitions":
return new BuffDefinitions(inStream);
case "CharacterAudioEvents":
return new CharacterAudioEvents(inStream);
case "Characters":
return new Characters(inStream);
case "ChestClusters":
return new ChestClusters(inStream);
case "Chests":
return new Chests(inStream);
case "ComponentArmour":
return new ComponentArmour(inStream);
case "ComponentAttributeRequirements":
return new ComponentAttributeRequirements(inStream);
case "ComponentCharges":
return new ComponentCharges(inStream);
case "CurrencyItems":
return new CurrencyItems(inStream);
case "Dances":
return new Dances(inStream);
case "DefaultMonsterStats":
return new DefaultMonsterStats(inStream);
case "Difficulties":
return new Difficulties(inStream);
case "DropPool":
return new DropPool(inStream);
case "Environments":
return new Environments(inStream);
case "ExperienceLevels":
return new ExperienceLevels(inStream);
case "Flasks":
return new Flasks(inStream);
case "FlavourText":
return new FlavourText(inStream);
case "GameConstants":
return new GameConstants(inStream);
case "GemTags":
return new GemTags(inStream);
case "GrantedEffects":
return new GrantedEffects(inStream);
case "GrantedEffectsPerLevel":
return new GrantedEffectsPerLevel(inStream);
case "ItemExperiencePerLevel":
return new ItemExperiencePerLevel(inStream);
case "ItemisedVisualEffect":
return new ItemisedVisualEffect(inStream);
case "ItemVisualEffect":
return new ItemVisualEffect(inStream);
case "ItemVisualIdentity":
return new ItemVisualIdentity(inStream);
case "MapConnections":
return new MapConnections(inStream);
case "MapPins":
return new MapPins(inStream);
case "Maps":
return new Maps(inStream);
case "MiscAnimated":
return new MiscAnimated(inStream);
case "MiscObjects":
return new MiscObjects(inStream);
case "Mods":
return new Mods(inStream);
case "ModSellPrices":
return new ModSellPrices(inStream);
case "MonsterPackEntries":
return new MonsterPackEntries(inStream);
case "MonsterPacks":
return new MonsterPacks(inStream);
case "MonsterTypes":
return new MonsterTypes(inStream);
case "MonsterVarieties":
return new MonsterVarieties(inStream);
case "Music":
return new Music(inStream);
case "NPCs":
return new NPCs(inStream);
case "NPCTalk":
return new NPCTalk(inStream);
case "NPCTextAudio":
return new NPCTextAudio(inStream);
case "PassiveSkills":
return new PassiveSkills(inStream);
case "Pet":
return new Pet(inStream);
case "Projectiles":
return new Projectiles(inStream);
case "Quest":
return new Quest(inStream);
case "QuestRewards":
return new QuestRewards(inStream);
case "QuestStates":
return new QuestStates(inStream);
case "QuestStaticRewards":
return new QuestStaticRewards(inStream);
case "Realms":
return new Realms(inStream);
case "ShieldTypes":
return new ShieldTypes(inStream);
case "ShopItem":
return new ShopItem(inStream);
case "ShopPaymentPackage":
return new ShopPaymentPackage(inStream);
case "Shrines":
return new Shrines(inStream);
case "SkillGems":
return new SkillGems(inStream);
case "SoundEffects":
return new SoundEffects(inStream);
case "Stats":
return new Stats(inStream);
case "Tags":
return new Tags(inStream);
case "Topologies":
return new Topologies(inStream);
case "VoteState":
return new VoteState(inStream);
case "VoteType":
return new VoteType(inStream);
case "WeaponTypes":
return new WeaponTypes(inStream);
case "Words":
return new Words(inStream);
case "WorldAreas":
return new WorldAreas(inStream);
}

throw new Exception("Missing dat parser for type " + fileName);
}
}
}
16 changes: 8 additions & 8 deletions LibDat/Files/ActiveSkills.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public class ActiveSkills : BaseDat
{
[StringIndex]
public int NameIndex { get; set; }
[StringIndex]
[UserStringIndex]
public int DisplayedName { get; set; }
[StringIndex]
[UserStringIndex]
public int Description { get; set; }
[StringIndex]
public int Index3 { get; set; }
Expand All @@ -25,9 +25,9 @@ public class ActiveSkills : BaseDat
[DataIndex]
public int Data2 { get; set; }
[StringIndex]
public int ExtraDescription { get; set; }
public int WebsiteDescription { get; set; }
[StringIndex]
public int ExamplePath { get; set; }
public int WebsiteImage { get; set; }
public bool Flag0 { get; set; }
public int Unknown4 { get; set; }
public bool Flag1 { get; set; }
Expand All @@ -49,8 +49,8 @@ public ActiveSkills(BinaryReader inStream)
Data1 = inStream.ReadInt32();
Unknown3 = inStream.ReadInt32();
Data2 = inStream.ReadInt32();
ExtraDescription = inStream.ReadInt32();
ExamplePath = inStream.ReadInt32();
WebsiteDescription = inStream.ReadInt32();
WebsiteImage = inStream.ReadInt32();
Flag0 = inStream.ReadBoolean();
Unknown4 = inStream.ReadInt32();
Flag1 = inStream.ReadBoolean();
Expand All @@ -72,8 +72,8 @@ public override void Save(BinaryWriter outStream)
outStream.Write(Data1);
outStream.Write(Unknown3);
outStream.Write(Data2);
outStream.Write(ExtraDescription);
outStream.Write(ExamplePath);
outStream.Write(WebsiteDescription);
outStream.Write(WebsiteImage);
outStream.Write(Flag0);
outStream.Write(Unknown4);
outStream.Write(Flag1);
Expand Down
2 changes: 1 addition & 1 deletion LibDat/Files/BackendErrors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class BackendErrors : BaseDat
{
[StringIndex]
public int Id { get; set; }
[StringIndex]
[UserStringIndex]
public int Text { get; set; }

public BackendErrors()
Expand Down
2 changes: 1 addition & 1 deletion LibDat/Files/BaseItemTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class BaseItemTypes : BaseDat
public int Unknown0 { get; set; }
public int Unknown1 { get; set; }
public int Unknown2 { get; set; }
[StringIndex]
[UserStringIndex]
public int Name { get; set; }
[StringIndex]
public int InheritsFrom { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion LibDat/Files/BuffDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class BuffDefinitions : BaseDat
{
[StringIndex]
public int Id { get; set; }
[StringIndex]
[UserStringIndex]
public int Description { get; set; }
public bool Invisible { get; set; }
public bool Removable { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion LibDat/Files/Characters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Characters : BaseDat
public int Unknown10 { get; set; }
[DataIndex]
public int Data0 { get; set; }
[StringIndex]
[UserStringIndex]
public int Description { get; set; }
public int Unknown11 { get; set; }
public int Unknown12 { get; set; }
Expand Down
Loading

0 comments on commit 364545c

Please sign in to comment.