//Get a resource given an id // the id is coming from TILEART -> TEXTURES // or TERRAINDEF -> TEXTURES public static UOResource getResource(Tileart tileart) { UOResource resource = null; //WorldArt Texture if (tileart.textures[0].texturePresent == 1) { resource = getResource(tileart.textures[0].texturesArray[0], ShaderTypes.Sprite); } //LegacyTexture if (resource == null && tileart.textures[1].texturePresent == 1) { resource = getLegacyResource(tileart.textures[1].texturesArray[0]); } //EnhancedTexture //Is this really necessary? //Light Texture if (resource != null && tileart.textures[3].texturePresent == 1) { //TODO: light texture load } // if (resource == null) { UOConsole.Fatal("texture is not present {0}", tileart.id); tileart = UOResourceManager.getTileart(1); resource = getResource(tileart.textures[0].texturesArray[0], ShaderTypes.Sprite); } return(resource); }
public static UOResource getLegacyResource(TextureImageInfo tileartTextureInfo) { //FAST search if (legacyTextures.ContainsKey(tileartTextureInfo.textureIDX)) { //TODO: references++ return(legacyTextures[tileartTextureInfo.textureIDX]); } //Get the string from stringDictionary if (tileartTextureInfo.textureIDX >= stringDictionary.count) { UOConsole.Fatal("String {0} not found in dictionary.", tileartTextureInfo.textureIDX); return(null); } string tga = stringDictionary.values[tileartTextureInfo.textureIDX]; //Replace extension int start = (tga.LastIndexOf("\\") == -1) ? 0 : (tga.LastIndexOf("\\") + 1); int end = tga.IndexOf("_"); if (end == -1) { UOConsole.Fatal("no descr in: {0} .. trying with extension", tga); tga = tga.Replace(".tga", ""); end = tga.Length; } //UOConsole.Fatal("{0} {1} {2}", tga, start, end); string toHash = tga.Substring(start, end - start); while (toHash.Length < 8) //Filling the missing zeros { toHash = "0" + toHash; } toHash += ".dds"; toHash = toHash.ToLower(); toHash = "build/tileartlegacy/" + toHash; //Get the file from Texture.uop ulong tehHash = HashDictionary.HashFileName(toHash); if (!uopHashes.legacyTexturesHashes.ContainsKey(tehHash)) { UOConsole.Fatal("string {0} not found in legacyTextureHashes - tga: {1}", toHash, tga); return(null); } uopMapping_t map = uopHashes.legacyTexturesHashes[tehHash]; MythicPackage tex = new MythicPackage(fileDirectory + "LegacyTexture.uop"); byte[] raw = tex.Blocks[map.block].Files[map.file].Unpack(tex.FileInfo.FullName); UOResource res = new UOResource(raw, ShaderTypes.Sprite, true); legacyTextures.Add(tileartTextureInfo.textureIDX, res); return(res); }
public UOSprite(uint spriteID) { tileart = UOResourceManager.getTileart(spriteID); resource = UOResourceManager.getResource(tileart); if (resource.isLegacy) { _imageOffset = tileart.offset2D; } else _imageOffset = tileart.offsetEC; _drawOffsetX = tileart.offsetEC.offX / UOEC_SIZE; _drawOffsetY = tileart.offsetEC.offY / UOEC_SIZE; }
public UOSprite(uint spriteID) { tileart = UOResourceManager.getTileart(spriteID); resource = UOResourceManager.getResource(tileart); if (resource.isLegacy) { _imageOffset = tileart.offset2D; } else { _imageOffset = tileart.offsetEC; } _drawOffsetX = tileart.offsetEC.offX / UOEC_SIZE; _drawOffsetY = tileart.offsetEC.offY / UOEC_SIZE; }
public static UOResource getLegacyResource(TextureImageInfo tileartTextureInfo) { //FAST search if (legacyTextures.ContainsKey(tileartTextureInfo.textureIDX)) { //TODO: references++ return legacyTextures[tileartTextureInfo.textureIDX]; } //Get the string from stringDictionary if (tileartTextureInfo.textureIDX >= stringDictionary.count) { UOConsole.Fatal("String {0} not found in dictionary.", tileartTextureInfo.textureIDX); return null; } string tga = stringDictionary.values[tileartTextureInfo.textureIDX]; //Replace extension int start = (tga.LastIndexOf("\\") == -1) ? 0 : (tga.LastIndexOf("\\") + 1); int end = tga.IndexOf("_"); if (end == -1) { UOConsole.Fatal("no descr in: {0} .. trying with extension", tga); tga = tga.Replace(".tga", ""); end = tga.Length; } //UOConsole.Fatal("{0} {1} {2}", tga, start, end); string toHash = tga.Substring(start, end - start); while(toHash.Length < 8)//Filling the missing zeros toHash = "0" + toHash; toHash += ".dds"; toHash = toHash.ToLower(); toHash = "build/tileartlegacy/" + toHash; //Get the file from Texture.uop ulong tehHash = HashDictionary.HashFileName(toHash); if (!uopHashes.legacyTexturesHashes.ContainsKey(tehHash)) { UOConsole.Fatal("string {0} not found in legacyTextureHashes - tga: {1}", toHash, tga); return null; } uopMapping_t map = uopHashes.legacyTexturesHashes[tehHash]; MythicPackage tex = new MythicPackage(fileDirectory + "LegacyTexture.uop"); byte[] raw = tex.Blocks[map.block].Files[map.file].Unpack(tex.FileInfo.FullName); UOResource res = new UOResource(raw, ShaderTypes.Sprite, true); legacyTextures.Add(tileartTextureInfo.textureIDX, res); return res; }