Ejemplo n.º 1
0
        /// <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
                    if (Rooms.TryUpdate(File, rooFile, null))
                    {
                        numLoadedRooms++;
                    }
                }
            }

            return(rooFile);
        }
Ejemplo n.º 2
0
        public static void OpenRoom(string File)
        {
            Room = new RooFile(File);
            Room.ResolveResources(ResourceManager);

            MainForm.Room = Room;
        }
Ejemplo n.º 3
0
        public void ResolveResources(ResourceManager M59ResourceManager, bool RaiseChangedEvent)
        {
            // try find the roofile instance
            RooFile rooFile = M59ResourceManager.GetRoom(roomFile);

            // if found resolve room resources and uncompress all
            if (rooFile != null && !rooFile.IsResourcesResolved)
            {
                rooFile.ResolveResources(M59ResourceManager);
                rooFile.UncompressAll();
            }

            // try find the wading sound file and load it
            string sound = M59ResourceManager.GetWavFile(wadingSoundFile);

            if (RaiseChangedEvent)
            {
                ResourceRoom        = rooFile;
                ResourceWadingSound = sound;
            }
            else
            {
                resourceRoom        = rooFile;
                resourceWadingSound = sound;
            }
        }
Ejemplo n.º 4
0
        protected virtual void HandlePlayerMessage(PlayerMessage Message)
        {
            double tick = GameTick.GetUpdatedTick();

            RoomInfo roomInfo = Message.RoomInfo;

            if (roomInfo.RoomFile != String.Empty)
            {
                // try find the roofile instance
                RooFile rooFile = resourceManager.GetRoom(roomInfo.RoomFile);
                roomInfo.ResourceRoom = rooFile;

                // found and never "loaded" before, resolve and uncompress
                // otherwise don't touch it in this thread
                if (rooFile != null && !rooFile.IsResourcesResolved)
                {
                    rooFile.ResolveResources(resourceManager);
                    rooFile.UncompressAll();
                }
            }

            double span = GameTick.GetUpdatedTick() - tick;

            Logger.Log(MODULENAME, LogType.Info, "Loaded BP_PLAYER: " + span.ToString() + " ms");
        }
Ejemplo n.º 5
0
        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)
                {
                    byte[] buffer;

                    // get file byte buffer
                    if (!fileBuffers.TryPop(out buffer))
                    {
                        buffer = new byte[FILEBUFFERSIZE];
                    }

                    string file = RoomsFolder + "/" + File;

                    // load to mem
                    if (Util.LoadFileToBuffer(file, buffer))
                    {
                        rooFile = new RooFile(file, buffer);

                        // resolve resource references (may load texture bgfs)
                        rooFile.ResolveResources(this);

                        // update the registry
                        if (Rooms.TryUpdate(File, rooFile, null))
                        {
                            numLoadedRooms++;
                        }
                    }
                    else
                    {
                        Logger.Log(MODULENAME, LogType.Error, "Failed to load file (possibly too big?): " + File);
                    }

                    fileBuffers.Push(buffer);
                }
            }

            return(rooFile);
        }
Ejemplo n.º 7
0
        public void ResolveResources(ResourceManager M59ResourceManager, bool RaiseChangedEvent)
        {
            if (RoomFile != String.Empty)
            {
                if (RaiseChangedEvent)
                {
                    ResourceRoom = M59ResourceManager.GetRoom(RoomFile);
                }
                else
                {
                    resourceRoom = M59ResourceManager.GetRoom(RoomFile);
                }

                if (resourceRoom != null)
                {
                    resourceRoom.ResolveResources(M59ResourceManager);
                }
            }
        }