public static void OpenRoom(string File) { Room = new RooFile(File); Room.ResolveResources(ResourceManager); MainForm.Room = Room; }
private void btnGO_Click(object sender, EventArgs e) { // check if (!File.Exists(txtRoomFile.Text) || !Directory.Exists(txtBGFFolder.Text) || !Directory.Exists(txtOutputFolder.Text)) return; // init a resourcemanager with room bgfs only ResourceManager resMan = new ResourceManager(); resMan.InitConfig(new ResourceManagerConfig( 0, false, false, false, false, null, null, null, txtBGFFolder.Text, null, null)); // load room and resolve resources RooFile rooFile = new RooFile(txtRoomFile.Text); rooFile.ResolveResources(resMan); // make output subfolder string subfolder = Path.Combine(txtOutputFolder.Text, rooFile.Filename); if (!Directory.Exists(subfolder)) Directory.CreateDirectory(subfolder); // extract textures Bitmap bmp; string filename; foreach (RooFile.TextureInfo texInfo in rooFile.Textures) { filename = Path.Combine( subfolder, texInfo.Container.Filename + "-" + texInfo.Container.Frames.IndexOf(texInfo.Texture) + ".png"); bmp = texInfo.Texture.GetBitmap(); bmp.MakeTransparent(System.Drawing.Color.Cyan); bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png); bmp.Dispose(); bmp = null; } }
/// <summary> /// Tries to retrieve a ROO file from the Rooms dictionary. /// Will load the file from disk, if not yet loaded. /// </summary> /// <param name="File"></param> /// <returns></returns> public RooFile GetRoom(string File) { RooFile rooFile = null; // if the file is known if (Rooms.TryGetValue(File, out rooFile)) { // haven't loaded it yet? if (rooFile == null) { // load it rooFile = new RooFile(RoomsFolder + "/" + File); // resolve resource references (may load texture bgfs) rooFile.ResolveResources(this); // update the registry Rooms.TryUpdate(File, rooFile, null); } } return rooFile; }