public void LoadTGV() { EdataManager manager = new EdataManager(@"C:\Users\mja\Documents\perso\mods\commoninterface.ppk"); manager.ParseEdataFile(); string filename = @"pc\texture\assets\2d\interface\common\unitsicons\us\stryker_icv_upgrade_1.tgv"; Bitmap bitmap = null; Assert.IsTrue(manager.TryToLoadTgv(filename, out bitmap)); Assert.IsNotNull(bitmap); bitmap.Save("Unit2.png"); }
public void LoadTGVFromZZ4() { string zz4 = @"C:\Users\mja\Documents\perso\mods\ZZ_4.dat"; EdataManager zz4File = new EdataManager(zz4); zz4File.ParseEdataFile(); string filename = @"pc\texture\assets\2d\interface\common\unitsicons\cs\m8_losat_upb.tgv"; string ICON_PACKAGE = @"pc\texture\pack\commoninterface.ppk"; EdataManager pack = zz4File.ReadPackage(ICON_PACKAGE); Bitmap bitmap = null; Assert.IsTrue(pack.TryToLoadTgv(filename, out bitmap)); Assert.IsNotNull(bitmap); bitmap.Save("UnitDXT1.png"); }
public bool LoadData(NdfObject dataobject, TradManager dictionary, TradManager dictionary2, EdataManager iconPackage) { InstanceIndex = dataobject.Id; NdfString debugstring; if (dataobject.TryGetValueFromQuery<NdfString>(DEBUG_NAME, out debugstring)) { DebugName = debugstring.ToString(); if (DEBUG_NAME_USELESS.Any(x => DebugName.Contains(x))) // verify if unit isn't a useless data return false; //Finish loading data NdfLocalisationHash localisation; string aString; //NAME if (!dataobject.TryGetValueFromQuery<NdfLocalisationHash>(UNIT_NAME_HASH, out localisation)) if (!dataobject.TryGetValueFromQuery<NdfLocalisationHash>(UNIT_NAME_HASH_ALT, out localisation)) return false; if (!dictionary.TryGetString(localisation.Value, out aString)) return false; Name = aString; //Description if (!dataobject.TryGetValueFromQuery<NdfLocalisationHash>(UNIT_DESCRIPTION_HASH, out localisation)) if (!dataobject.TryGetValueFromQuery<NdfLocalisationHash>(UNIT_DESCRIPTION_HASH_ALT, out localisation)) return false; if (!dictionary.TryGetString(localisation.Value, out aString)) return false; Description = aString; //Icon string iconPath; NdfString ndfstring = null; Bitmap bitmap; if (!dataobject.TryGetValueFromQuery<NdfString>(UNIT_ICON, out ndfstring)) dataobject.TryGetValueFromQuery<NdfString>(UNIT_ICON_ALT, out ndfstring); if (ndfstring != null) { string iconpath = ndfstring.ToString().Replace(@"/", @"\").Replace(@"GameData:\", @"pc\texture\").Replace("png", "tgv").ToLower(); if (iconPackage.TryToLoadTgv(iconpath, out bitmap)) // must modify icon path first Icon = new Bitmap(bitmap); } //Faction NdfString str; if (!dataobject.TryGetValueFromQuery<NdfString>(UNIT_FACTION, out str)) return false; if (str != null) { Faction = FromString2FactionEnum(str.ToString()); } else { Faction = FactionEnum.Other; } //Type NdfInt32 ndfint32; if (!dataobject.TryGetValueFromQuery<NdfInt32>(UNIT_TYPE, out ndfint32)) if (!dataobject.TryGetValueFromQuery<NdfInt32>(UNIT_TYPE_ALT, out ndfint32)) return false; Type = (ObjectType)ndfint32.Value; //COSTS NdfUInt32 ndfuint32; if (dataobject.TryGetValueFromQuery<NdfUInt32>(UNIT_CASH_COST, out ndfuint32)) CashCost = (int)ndfuint32.Value; if (dataobject.TryGetValueFromQuery<NdfUInt32>(UNIT_ALU_COST, out ndfuint32)) AluminiumCost = (int)ndfuint32.Value; if (dataobject.TryGetValueFromQuery<NdfUInt32>(UNIT_ELEC_COST, out ndfuint32)) ElectricityCost = (int)ndfuint32.Value; if (dataobject.TryGetValueFromQuery<NdfUInt32>(UNIT_REA_COST, out ndfuint32)) RareEarthCost = (int)ndfuint32.Value; return true; } else { return false; } }