Example #1
0
 /// <summary>Loads a texture and returns the texture data.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="texture">Receives the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool LoadTexture(string path, OpenBveApi.Textures.TextureParameters parameters, out OpenBveApi.Textures.Texture texture)
 {
     if (System.IO.File.Exists(path) || System.IO.Directory.Exists(path)) {
         for (int i = 0; i < Plugins.LoadedPlugins.Length; i++) {
             if (Plugins.LoadedPlugins[i].Texture != null) {
                 try {
                     if (Plugins.LoadedPlugins[i].Texture.CanLoadTexture(path)) {
                         try {
                             if (!Plugins.LoadedPlugins[i].Texture.LoadTexture(path, out texture)) {
                                 texture = null;
                                 return false;
                             }
                             texture = texture.ApplyParameters(parameters);
                             return true;
                         } catch (Exception ex) {
                             Program.AppendToLogFile("Plugin " + Plugins.LoadedPlugins[i].Title + " raised the following exception at LoadTexture:" + ex.Message);
                         }
                     }
                 } catch (Exception ex) {
                     Program.AppendToLogFile("Plugin " + Plugins.LoadedPlugins[i].Title + " raised the following exception at CanLoadTexture:" + ex.Message);
                 }
             }
         }
         Program.AppendToLogFile("No plugin found that is capable of loading texture " + path.ToString());
     } else {
         ReportProblem(OpenBveApi.Hosts.ProblemType.PathNotFound, path.ToString());
     }
     texture = null;
     return false;
 }
Example #2
0
		/// <summary>Loads a texture and returns the texture data.</summary>
		/// <param name="path">The path to the file or folder that contains the texture.</param>
		/// <param name="parameters">The parameters that specify how to process the texture.</param>
		/// <param name="texture">Receives the texture.</param>
		/// <returns>Whether loading the texture was successful.</returns>
		public override bool LoadTexture(string path, OpenBveApi.Textures.TextureParameters parameters, out OpenBveApi.Textures.Texture texture) {
			if (System.IO.File.Exists(path) || System.IO.Directory.Exists(path)) {
				for (int i = 0; i < Plugins.LoadedPlugins.Length; i++) {
					if (Plugins.LoadedPlugins[i].TextureLoaders.Length > 0) {
						try {
							for(int l = 0; l < Plugins.LoadedPlugins[i].TextureLoaders.Length; l++){
								if (Plugins.LoadedPlugins[i].TextureLoaders[l].CanLoadTexture(path)) {
								try {
										if (Plugins.LoadedPlugins[i].TextureLoaders[l].LoadTexture(path, out texture)) {
										texture = texture.ApplyParameters(parameters);
										return true;
									}
									Debug.AddMessage(Debug.MessageType.Error, false,
									                     "Plugin " + Plugins.LoadedPlugins[i].Title + " returned unsuccessfully at LoadTexture"
									                    );
								} catch (Exception ex) {
									Debug.AddMessage(Debug.MessageType.Error, false,
									                     "Plugin " + Plugins.LoadedPlugins[i].Title + " raised the following exception at LoadTexture:" + ex.Message
									                    );
								}
								}
							}
						} catch (Exception ex) {
							Debug.AddMessage(Debug.MessageType.Error, false,
							                     "Plugin " + Plugins.LoadedPlugins[i].Title + " raised the following exception at CanLoadTexture:" + ex.Message
							                    );
						}
					}
				}
				Debug.AddMessage(Debug.MessageType.Error, false,
				                     "No plugin found that is capable of loading texture " + path);
			} else {
				ReportProblem(OpenBveApi.Hosts.ProblemType.PathNotFound, path);
			}
			texture = null;
			return false;
		}
Example #3
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="texture">The texture data.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool RegisterTexture(OpenBveApi.Textures.Texture texture, OpenBveApi.Textures.TextureParameters parameters, out OpenBveApi.Textures.TextureHandle handle)
 {
     texture = texture.ApplyParameters(parameters);
     handle = Textures.RegisterTexture(texture);
     return true;
 }