Exemple #1
0
        /// <summary>
        /// Loads an asset that has been processed by the Content Pipeline.
        /// </summary>
        /// <typeparam name="T">The type of asset to load. Model, Effect, SpriteFont, Texture, Texture2D, and TextureCube are all supported by default by the standard Content Pipeline processor, but additional types may be loaded by extending the processor.</typeparam>
        /// <param name="assetName">Asset name, relative to the loader root directory, and not including the .xnb extension.</param>
        /// <returns>The loaded asset. Repeated calls to load the same asset will return the same object instance.</returns>
        public T Load <T>(string assetName)
        {
#if DEBUG
            if (!this.loaded.Contains(assetName))
            {
                // TODO: Reference to documentation url:
                Debug.WriteLine("WARNING: Asset '" + assetName + "' is not loaded in the current context!!!");
            }
#endif
            lock (PhantomGame.Game.GlobalRenderLock)
            {
#if DEBUG
                T asset = this.LoadAffixed <T>(assetName);
                if (asset is Texture2D)
                {
                    this.textureNames[asset as Texture2D] = assetName;
                    if (!debugData.ContainsKey(assetName))
                    {
                        debugData[assetName] = new SpriteDebugData(0);
                    }
                }
#endif

                return(this.LoadAffixed <T>(assetName));
            }
        }
Exemple #2
0
        public string ReportDebugData(Texture2D texture, float scale)
        {
            if (!textureNames.ContainsKey(texture))
            {
                return("");
            }
            string name = textureNames[texture];

            if (!debugData.ContainsKey(name))
            {
                debugData[name] = new SpriteDebugData(0);
            }
            debugData[name].Report(scale);
            return(name);
        }