Difference between revisions of "PlugIn Development:GameEx Initialize Function"

From Spesoft/GameEx Wiki
Jump to navigation Jump to search
Line 6: Line 6:
Return <span class="plugin_return_text">true</span> and GameEx will initialize your plugin.<br />
Return <span class="plugin_return_text">true</span> and GameEx will initialize your plugin.<br />
Return <span class="plugin_return_text">false</span> and GameEx will not initialize your plugin.
Return <span class="plugin_return_text">false</span> and GameEx will not initialize your plugin.
 
== <span class="plugin_headline_text">Structures</span> ==
== <span class="plugin_headline_text">Code Examples</span> ==
==== <span class="plugin_text_fx">VB.NET</span> ====
The code samples below outline the syntax needed to process the call in the <span class="plugin_return_text">PlugIn.dll</span> file within the template.<br />
=== <span class="plugin_text_fx">VB.NET</span> ===
==== <span class="plugin_header_mini">Structure</span> ====
<pre class="code_es_vb">
<pre class="code_es_vb">
<StructLayout(LayoutKind.Sequential)> _
<StructLayout(LayoutKind.Sequential)> _
Line 16: Line 13:
     Public GameExVersion As String
     Public GameExVersion As String
End Structure</pre>
End Structure</pre>
==== <span class="plugin_header_mini">Function</span> ====
==== <span class="plugin_text_fx">C#</span> ====
<pre class="code_es_cs">
[ StructLayout( LayoutKind.Sequential )]
public struct GameExInfo
{
    public string GameExVersion;
}</pre>
== <span class="plugin_headline_text">Code Examples</span> ==
The code samples below outline the syntax needed to process the call in the <span class="plugin_return_text">PlugIn.dll</span> file within the template.<br />
=== <span class="plugin_text_fx">VB.NET</span> ===
<pre class="code_vb">
<pre class="code_vb">
Public Function Initialize(ByVal InfoPtr As IntPtr) As Boolean
Public Function Initialize(ByVal InfoPtr As IntPtr) As Boolean
Line 26: Line 32:


=== <span class="plugin_text_fx">C#</span> ===
=== <span class="plugin_text_fx">C#</span> ===
==== <span class="plugin_header_mini">Structure</span> ====
<pre class="code_es_cs">
[ StructLayout( LayoutKind.Sequential )]
public struct GameExInfo
{
    public string GameExVersion;
}</pre>
==== <span class="plugin_header_mini">Function</span> ====
<pre class="code_cs">
<pre class="code_cs">
public bool Initialize(IntPtr InfoPtr)
public bool Initialize(IntPtr InfoPtr)

Revision as of 06:50, 28 April 2014

This function is called when GameEx initializes.
Using this function call, you can run code to do various things, like set up your log files or load your settings.

Returns

This function returns a boolean value.

Return Values

Return true and GameEx will initialize your plugin.
Return false and GameEx will not initialize your plugin.

Structures

VB.NET

<StructLayout(LayoutKind.Sequential)> _
Public Structure GameExInfo
    Public GameExVersion As String
End Structure

C#

[ StructLayout( LayoutKind.Sequential )]
public struct GameExInfo
{
     public string GameExVersion;
}

Code Examples

The code samples below outline the syntax needed to process the call in the PlugIn.dll file within the template.

VB.NET

Public Function Initialize(ByVal InfoPtr As IntPtr) As Boolean
     Dim Info As GameExInfo = DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(GameExInfo)), GameExInfo))
     'This will output the current version of GameEx:
     Dim GameEx_Version As String = Info.GameExVersion
     Return True
End Function

C#

public bool Initialize(IntPtr InfoPtr)
{
     GameExInfo Info = (GameExInfo) Marshal.PtrToStructure(InfoPtr, typeof(GameExInfo));
     //This will output the current version of GameEx as a string:
     string GameEx_Version = Info.GameExVersion;
     return true;
}