/// <summary> /// Tries to retrieve a BGF file from the RoomTextures dictionary. /// Will load the file from disk, if not yet loaded. /// </summary> /// <param name="File"></param> /// <returns></returns> public BgfFile GetRoomTexture(string File) { BgfFile bgfFile = null; // if the file is known if (RoomTextures.TryGetValue(File, out bgfFile)) { // haven't loaded it yet? if (bgfFile == null) { byte[] buffer; // get file byte buffer if (!fileBuffers.TryPop(out buffer)) { buffer = new byte[FILEBUFFERSIZE]; } string file = RoomTexturesFolder + "/" + File; // load to mem if (Util.LoadFileToBuffer(file, buffer)) { // load it bgfFile = new BgfFile(file, buffer); // update the registry if (RoomTextures.TryUpdate(File, bgfFile, null)) { numLoadedRoomTextures++; } } else { Logger.Log(MODULENAME, LogType.Error, "Failed to load file (possibly too big?): " + File); } fileBuffers.Push(buffer); } } return(bgfFile); }
/// <summary> /// Tries to retrieve a BGF file from the RoomTextures dictionary. /// Will load the file from disk, if not yet loaded. /// </summary> /// <param name="File"></param> /// <returns></returns> public BgfFile GetRoomTexture(string File) { BgfFile bgfFile = null; // if the file is known if (RoomTextures.TryGetValue(File, out bgfFile)) { // haven't loaded it yet? if (bgfFile == null) { // load it bgfFile = new BgfFile(RoomTexturesFolder + "/" + File); // update the registry RoomTextures.TryUpdate(File, bgfFile, null); } } return(bgfFile); }