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

From Spesoft/GameEx Wiki
Jump to navigation Jump to search
Line 6: Line 6:
=== <span class="plugin_text_fx">Parameter Values</span> ===
=== <span class="plugin_text_fx">Parameter Values</span> ===
The <span class="plugin_return_text">InfoPtr</span> passed to this variable populates the <span class="plugin_return_text">GameInfo structure</span> when passed via <span class="plugin_return_text">DirectCast</span> like so:<br />
The <span class="plugin_return_text">InfoPtr</span> passed to this variable populates the <span class="plugin_return_text">GameInfo structure</span> when passed via <span class="plugin_return_text">DirectCast</span> like so:<br />
VB.NET: <span class="plugin_return_text">Dim Info As GameExInfo = DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(GameExInfo)), Game_Info)</span><br />
<span class="plugin_header_mini">VB.NET:</span> <span class="plugin_return_text">Dim Info As GameExInfo = DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(GameExInfo)), Game_Info)</span><br />
C#: <span class="plugin_return_text">GameExInfo Info = (GameExInfo)Marshal.PtrToStructure(InfoPtr, typeof(GameExInfo));</span>
<span class="plugin_header_mini">C#:</span> <span class="plugin_return_text">GameExInfo Info = (GameExInfo)Marshal.PtrToStructure(InfoPtr, typeof(GameExInfo));</span>
<br />
<br />



Revision as of 07:05, 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.

Parameters

InfoPtr [IntPtr]: An array of game data, which should be pushed to the GameExInfo structure using a DirectCast.

Parameter Values

The InfoPtr passed to this variable populates the GameInfo structure when passed via DirectCast like so:
VB.NET: Dim Info As GameExInfo = DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(GameExInfo)), Game_Info)
C#: GameExInfo Info = (GameExInfo)Marshal.PtrToStructure(InfoPtr, typeof(GameExInfo));

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

The structures below outline the the data passed in the PlugIn.dll file.

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;
}