8
internal static class Interfaces {
9
internal static IHost10 Host = null;
13
/// <summary>Exposes version 1.0 of the interface to be implemented by a plugin.</summary>
14
public class Plugin : IPlugin10 {
18
/// <summary>Is called when the plugin is loaded.</summary>
19
/// <param name="hosts">A list of versions of the host interface as used for callbacks.</param>
20
/// <returns>A boolean indicating whether the plugin was successfully loaded.</returns>
21
/// <remarks>A plugin should make use of the smallest version the host interface provides as possible. If the plugin expects a certain version that is not supplied by the host application, this operation should return as unsuccessful.</remarks>
22
public bool Load(IHost[] hosts) {
23
foreach (IHost host in hosts) {
24
if (host is IHost10) {
25
Interfaces.Host = (IHost10)host;
32
/// <summary>Is called when the plugin is unloaded.</summary>
33
public void Unload() { }
36
// --- textures (loading) ---
38
/// <summary>Returns whether the plugin is capable of loading textures.</summary>
39
/// <returns>A boolean indicating whether the plugin is capable of loading textures.</returns>
40
public bool CanLoadTextures() {
44
/// <summary>Returns whether the plugin is capable of loading the specified texture.</summary>
45
/// <param name="path">The file or folder where the texture is stored.</param>
46
/// <param name="encoding">The suggested encoding in case the texture format does not mandate a specific encoding.</param>
47
/// <param name="data">Optional data passed from another plugin. If you access this field, you must check the type before casting to that type.</param>
48
/// <returns>The priority at which the plugin supports loading the specified texture.</returns>
49
public General.Priority CanLoadTexture(Path.PathReference path, Encoding encoding, object data) {
50
if (path is Path.FileReference) {
51
string fileName = ((Path.FileReference)path).Path;
53
fileName.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase) ||
54
fileName.EndsWith(".gif", StringComparison.OrdinalIgnoreCase) ||
55
fileName.EndsWith(".exig", StringComparison.OrdinalIgnoreCase) ||
56
fileName.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
57
fileName.EndsWith(".jpeg", StringComparison.OrdinalIgnoreCase) ||
58
fileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase) ||
59
fileName.EndsWith(".tif", StringComparison.OrdinalIgnoreCase) ||
60
fileName.EndsWith(".tiff", StringComparison.OrdinalIgnoreCase)
62
return General.Priority.Normal;
64
return General.Priority.NotCapable;
67
return General.Priority.NotCapable;
71
/// <summary>Loads a texture into an output parameter and returns the success of the operation.</summary>
72
/// <param name="path">The file or folder where the texture is stored.</param>
73
/// <param name="encoding">The suggested encoding in case the texture format does not mandate a specific encoding.</param>
74
/// <param name="data">Optional data passed from another plugin. If you access this field, you must check the type before casting to that type.</param>
75
/// <param name="texture">Receives the texture.</param>
76
/// <returns>The success of the operation.</returns>
77
public General.Result LoadTexture(Path.PathReference path, Encoding encoding, object data, out Texture.TextureData texture) {
81
string fileName = ((Path.FileReference)path).Path;
82
if (System.IO.File.Exists(fileName)) {
83
return Loader.LoadTexture(fileName, out texture);
86
return OpenBveApi.General.Result.FileNotFound;
91
return OpenBveApi.General.Result.InternalError;
97
// --- objects (loading) ---
99
/// <summary>Returns whether the plugin is capable of loading objects.</summary>
100
/// <returns>A boolean indicating whether the plugin is capable of loading objects.</returns>
101
public bool CanLoadObjects() {
105
/// <summary>Returns whether the plugin is capable of loading the specified object.</summary>
106
/// <param name="path">The file or folder where the object is stored.</param>
107
/// <param name="encoding">The suggested encoding in case the object format does not mandate a specific encoding.</param>
108
/// <param name="data">Optional data passed from another plugin. If you access this field, you must check the type before casting to that type.</param>
109
/// <returns>The priority at which the plugin supports loading the specified object.</returns>
110
public General.Priority CanLoadObject(Path.PathReference path, Encoding encoding, object data) {
111
return General.Priority.NotCapable;
114
/// <summary>Loads an object into an output parameter and returns the success of the operation.</summary>
115
/// <param name="path">The file or folder where the object is stored.</param>
116
/// <param name="encoding">The suggested encoding in case the object format does not mandate a specific encoding.</param>
117
/// <param name="data">Optional data passed from another plugin. If you access this field, you must check the type before casting to that type.</param>
118
/// <param name="obj">Receives the object.</param>
119
/// <returns>The success of the operation.</returns>
120
public General.Result LoadObject(Path.PathReference path, Encoding encoding, object data, out Geometry.GenericObject obj) {
122
return General.Result.NotSupported;
126
// --- sounds (loading) ---
128
/// <summary>Returns whether the plugin is capable of loading sounds.</summary>
129
/// <returns>A boolean indicating whether the plugin is capable of loading sounds.</returns>
130
public bool CanLoadSounds() {
134
/// <summary>Returns whether the plugin is capable of loading the specified sound.</summary>
135
/// <param name="path">The file or folder where the sound is stored.</param>
136
/// <param name="encoding">The suggested encoding in case the sound format does not mandate a specific encoding.</param>
137
/// <param name="data">Optional data passed from another plugin. If you access this field, you must check the type before casting to that type.</param>
138
/// <returns>The priority at which the plugin supports loading the specified sound.</returns>
139
public General.Priority CanLoadSound(Path.PathReference path, Encoding encoding, object data) {
140
return General.Priority.NotCapable;
143
/// <summary>Loads a sound into an output parameter and returns the success of the operation.</summary>
144
/// <param name="path">The file or folder where the sound is stored.</param>
145
/// <param name="encoding">The suggested encoding in case the sound format does not mandate a specific encoding.</param>
146
/// <param name="data">Optional data passed from another plugin. If you access this field, you must check the type before casting to that type.</param>
147
/// <param name="sound">Receives the sound.</param>
148
/// <returns>The success of the operation.</returns>
149
public General.Result LoadSound(Path.PathReference path, Encoding encoding, object data, out Sound.SoundData sound) {
151
return General.Result.NotSupported;
155
// --- routes (loading) ---
157
/// <summary>Returns whether the plugin is capable of loading routes.</summary>
158
/// <returns>A boolean indicating whether the plugin is capable of loading routes.</returns>
159
public bool CanLoadRoutes() {
163
/// <summary>Returns whether the plugin is capable of loading the specified route.</summary>
164
/// <param name="path">The file or folder where the route is stored.</param>
165
/// <param name="encoding">The suggested encoding in case the route format does not mandate a specific encoding.</param>
166
/// <param name="data">Optional data passed from another plugin. If you access this field, you must check the type before casting to that type.</param>
167
/// <returns>The priority at which the plugin supports loading the specified route.</returns>
168
public General.Priority CanLoadRoute(Path.PathReference path, Encoding encoding, object data) {
169
return General.Priority.NotCapable;
172
/// <summary>Loads a route into an output parameter and returns the success of the operation.</summary>
173
/// <param name="path">The file or folder where the route is stored.</param>
174
/// <param name="encoding">The suggested encoding in case the route format does not mandate a specific encoding.</param>
175
/// <param name="data">Optional data passed from another plugin. If you access this field, you must check the type before casting to that type.</param>
176
/// <param name="route">Receives the route.</param>
177
/// <returns>The success of the operation.</returns>
178
public General.Result LoadRoute(Path.PathReference path, Encoding encoding, object data, out Route.RouteData route) {
180
return General.Result.NotSupported;
186
/// <summary>Queries data from this runtime plugin.</summary>
187
/// <param name="contentType">The type of content to query.</param>
188
/// <param name="contentData">Receives the queried content.</param>
189
/// <returns>The success of the operation.</returns>
190
public General.Result QueryPluginData(int contentType, out object contentData) {
192
return General.Result.NotSupported;
195
/// <summary>Submits data to this runtime plugin.</summary>
196
/// <param name="contentType">The type of content to submit.</param>
197
/// <param name="contentData">The data to submit.</param>
198
/// <returns>The success of the operation.</returns>
199
public General.Result SubmitPluginData(int contentType, object contentData) {
200
return General.Result.NotSupported;
b'\\ No newline at end of file'