Difference between revisions of "PlugIn Development:GameEx Event CommandLine Function"

From Spesoft/GameEx Wiki
Jump to navigation Jump to search
Line 1: Line 1:
This function is called when GameEx populates the command line for the chosen game.<br />Using this function call, you can return an altered command line for GameEx to run instead of the user configured one.<br />You can return <span style="color:red;">'''String.Empty'''</span> or <span style="color:red;">'''Info.CmdLine'''</span> and GameEx will not make any changes to the user's command line.<br />It should also be noted that the only info pushed down to this event is the command line since PlugIn Version 1.41. For the additional info exposed in the structure, you will need to push a DirectCast during the GameRun or the GameSelect event.
This function is called when GameEx populates the command line for the chosen game.<br />
<div class="note_block_red"><b>PLEASE NOTE:</b> ''The only info pushed down to this event is the command line since PlugIn Version 1.41. For the additional info exposed in the structure, you will need to push a <span class="plugin_return_text">DirectCast</span> during the GameRun or the GameSelect event.''</div>
<br />
== <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">GameInfo 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 />
VB.NET: <span class="plugin_return_text">Dim Info As Game_Info = CType(Marshal.PtrToStructure(InfoPtr, GetType(Game_Info)), Game_Info)</span><br />
C#: <span class="plugin_return_text">Game_Info Info = (Game_Info)Marshal.PtrToStructure(InfoPtr, typeof(Game_Info));</span>
<br />
== <span class="plugin_headline_text">Returns</span> ==
This function returns a <span class="plugin_return_text">string</span> value.
<br />
=== <span class="plugin_text_fx">Return Values</span> ===
Return your modified <span class="plugin_return_text">CmdLine string</span> and GameEx will use the new command line when it runs the game.<br />
Alternatively, you can return <span class="plugin_return_text">Nothing</span> and GameEx will process the currently configured command line.
<br />
== <span class="plugin_headline_text">Code Examples</span> ==


== <span style="color:darkblue;">Code Examples</span> ==
=== <span class="plugin_text_fx">VB.NET</span> ===
 
=== <span style="color:#003300;">VB.NET</span> ===
----
==== <span style="color:purple;">Structure</span> ====
==== <span style="color:purple;">Structure</span> ====
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:dashed;">
<pre class="code_block_struc">
<StructLayout(LayoutKind.Sequential)> _
<StructLayout(LayoutKind.Sequential)> _
Public Structure Game_Info
Public Structure Game_Info
Line 23: Line 38:
End Structure</pre>
End Structure</pre>
==== <span style="color:purple;">Function</span> ====
==== <span style="color:purple;">Function</span> ====
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:solid;">
<pre class="code_block_func">
Public Function Event_CommandLine(ByVal InfoPtr As IntPtr) As String
Public Function Event_CommandLine(ByVal InfoPtr As IntPtr) As String
     Dim Info As Game_Info = CType(Marshal.PtrToStructure(InfoPtr, GetType(Game_Info)), Game_Info)
     Dim Info As Game_Info = CType(Marshal.PtrToStructure(InfoPtr, GetType(Game_Info)), Game_Info)
Line 31: Line 46:
End Function</pre>
End Function</pre>


=== <span style="color:#003300;">C#</span> ===
=== <span class="plugin_text_fx">C#</span> ===
----
----
==== <span style="color:purple;">Structure</span> ====
==== <span style="color:purple;">Structure</span> ====
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:dashed;">
<pre class="code_block_struc">
[ StructLayout( LayoutKind.Sequential )]
[ StructLayout( LayoutKind.Sequential )]
public struct Game_Info
public struct Game_Info
Line 52: Line 67:
};</pre>
};</pre>
==== <span style="color:purple;">Function</span> ====
==== <span style="color:purple;">Function</span> ====
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:solid;">
<pre class="code_block_func">
public string Event_CommandLine(IntPtr InfoPtr)
public string Event_CommandLine(IntPtr InfoPtr)
{
{

Revision as of 01:41, 28 April 2014

This function is called when GameEx populates the command line for the chosen game.

PLEASE NOTE: The only info pushed down to this event is the command line since PlugIn Version 1.41. For the additional info exposed in the structure, you will need to push a DirectCast during the GameRun or the GameSelect event.


Parameters

InfoPtr [IntPtr]: An array of game data, which should be pushed to the GameInfo 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 Game_Info = CType(Marshal.PtrToStructure(InfoPtr, GetType(Game_Info)), Game_Info)
C#: Game_Info Info = (Game_Info)Marshal.PtrToStructure(InfoPtr, typeof(Game_Info));

Returns

This function returns a string value.

Return Values

Return your modified CmdLine string and GameEx will use the new command line when it runs the game.
Alternatively, you can return Nothing and GameEx will process the currently configured command line.

Code Examples

VB.NET

Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure Game_Info
     Public EmulatorNumber As Integer
     Public EmulatorName As String       'No value is passed during this event
     Public GameName As String           'No value is passed during this event
     Public ROMPath As String            'No value is passed during this event
     Public ROMName As String            'No value is passed during this event
     Public GameData As Database         'No value is passed during this event
     Public MameInfo As Mame_Info        'No value is passed during this event
     Public RomFilter As String          'No value is passed during this event
     Public SnapPath As String           'No value is passed during this event
     Public VideoPath As String          'No value is passed during this event
     Public TitlePath As String          'No value is passed during this event
     Public CmdLine As String
End Structure

Function

Public Function Event_CommandLine(ByVal InfoPtr As IntPtr) As String
     Dim Info As Game_Info = CType(Marshal.PtrToStructure(InfoPtr, GetType(Game_Info)), Game_Info)
     Dim CmdLine As String = Info.CmdLine
       'Run some code here!
     Return CmdLine
End Function

C#


Structure

[ StructLayout( LayoutKind.Sequential )]
public struct Game_Info
{
     public int EmulatorNumber; 
     public string EmulatorName;     //No value is passed during this event
     public string GameName;         //No value is passed during this event
     public string ROMPath;          //No value is passed during this event
     public string ROMName;          //No value is passed during this event
     public Database GameData;       //No value is passed during this event
     public Mame_Info MameInfo;      //No value is passed during this event
     public string ROMFilter;        //No value is passed during this event
     public string SnapPath;         //No value is passed during this event
     public string VideoPath;        //No value is passed during this event
     public string TitlePath;        //No value is passed during this event
     public string CMDLine;
};

Function

public string Event_CommandLine(IntPtr InfoPtr)
{
     Game_Info Info = (Game_Info)Marshal.PtrToStructure(InfoPtr, typeof(Game_Info));
     string CmdLine = Info.CMDLine;
       //Run some code here!
     return CmdLine;
}