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

From Spesoft/GameEx Wiki
Jump to navigation Jump to search
(Created page with "==<span style="font-size:150%;">Initialize Plugin Function</span>== This function is called when GameEx initializes. Using this function call, you can run code to do various t...")
 
 
(41 intermediate revisions by the same user not shown)
Line 1: Line 1:
==<span style="font-size:150%;">Initialize Plugin Function</span>==
This function is called when GameEx initializes.<br />Using this function call, you can run code to do various things, like set up your log files or load your settings.<br />
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. I often use this function to run a thread when I need to download something on a thread (or check for updates) and I don't need to wait for it to finish prior to GameEx launching.
<br />
You can return <span style="color:red;">'''TRUE'''</span> to continue processing the event or return <span style="color:red;">'''FALSE'''</span> and GameEx will not initialize your plugin.
== <span class="plugin_headline_text">Parameters</span> ==
<span class="plugin_return_text">InfoPtr [IntPtr]</span>: An array of game data, which should be pushed to the <span class="plugin_return_text">GameExInfo structure</span> using a <span class="plugin_return_text">DirectCast</span>.
<br />
=== <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 />
<span class="plugin_header_mini">VB.NET:</span> <span class="plugin_return_text_noline">Dim</span> <span class="plugin_return_text">Info</span> <span class="plugin_return_text_noline">As</span> <span class="plugin_return_text">GameExInfo</span> <span class="plugin_return_text_noline">= DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(GameExInfo)), Game_Info)</span><br />
<span class="plugin_header_mini">C#:</span> <span class="plugin_return_text">GameExInfo</span> <span class="plugin_return_text">Info</span> <span class="plugin_return_text_noline">= (GameExInfo)Marshal.PtrToStructure(InfoPtr, typeof(GameExInfo));</span>
<br />


== <span class="plugin_headline_text">Returns</span> ==
This function returns a <span class="plugin_return_text">boolean</span> value.<br />
=== <span class="plugin_text_fx">Return Values</span> ===
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.
== <span class="plugin_headline_text">Structures</span> ==
The structures below outline the the data passed in the <span class="plugin_return_text">PlugIn.dll</span> file.<br />
==== <span class="plugin_text_fx">VB.NET</span> ====
<pre class="code_es_vb">
<StructLayout(LayoutKind.Sequential)> _
Public Structure GameExInfo
    Public GameExVersion As String
End Structure</pre>


<span style="font-size:125%; color:#003300;"><b>VB.NET syntax:</b></span>
==== <span class="plugin_text_fx">C#</span> ====
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:dashed;">
<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">
Public Function Initialize(ByVal InfoPtr As IntPtr) As Boolean
Public Function Initialize(ByVal InfoPtr As IntPtr) As Boolean
     Dim Info As GameExInfo = DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(GameExInfo)), GameExInfo))
     Dim Info As GameExInfo = DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(GameExInfo)), GameExInfo))
Line 13: Line 43:
End Function</pre>
End Function</pre>


<span style="font-size:125%; color:#003300;"><b>C# syntax:</b></span>
=== <span class="plugin_text_fx">C#</span> ===
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:dashed;">
<pre class="code_cs">
public bool Initialize(IntPtr InfoPtr)
public bool Initialize(IntPtr InfoPtr)
{
{
Line 22: Line 52:
     return true;
     return true;
}</pre>
}</pre>
 
<br />
[[Category:Plugin Development]]
[[Category:PlugIn Development]]

Latest revision as of 21:17, 30 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;
}