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

From Spesoft/GameEx Wiki
Jump to navigation Jump to search
 
(10 intermediate revisions by the same user not shown)
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 />
<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 />
<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">Game_Info</span> <span class="plugin_return_text_noline">= DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(Game_Info)), Game_Info)</span><br />
<span class="plugin_header_mini">C#:</span> <span class="plugin_return_text">Game_Info</span> <span class="plugin_return_text">Info</span> <span class="plugin_return_text_noline">= (Game_Info)Marshal.PtrToStructure(InfoPtr, typeof(Game_Info));</span>
<br />


== <span style="color:darkblue;">Code Examples</span> ==
== <span class="plugin_headline_text">Returns</span> ==
 
This function returns a <span class="plugin_return_text">string</span> value.
=== <span style="color:#003300;">VB.NET</span> ===
<br />
==== Structure ====
=== <span class="plugin_text_fx">Return Values</span> ===
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:dashed;">
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">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> ===
==== <span class="plugin_header_mini">Game Info Structure</span> ====
<pre class="code_es_vb">
<StructLayout(LayoutKind.Sequential)> _
<StructLayout(LayoutKind.Sequential)> _
Public Structure Game_Info
Public Structure Game_Info
     Public EmulatorNumber As Integer
     Public EmulatorNumber As Integer
     Public EmulatorName As String       'No value is passed during this event
     Public EmulatorName As String
     Public GameName As String           'No value is passed during this event
     Public GameName As String
     Public ROMPath As String           'No value is passed during this event
     Public ROMPath As String
     Public ROMName As String           'No value is passed during this event
     Public ROMName As String
     Public GameData As Database         'No value is passed during this event
     Public GameData As Database
     Public MameInfo As Mame_Info       'No value is passed during this event
     Public MameInfo As Mame_Info
     Public RomFilter As String         'No value is passed during this event
     Public RomFilter As String
     Public SnapPath As String           'No value is passed during this event
     Public SnapPath As String
     Public VideoPath As String         'No value is passed during this event
     Public VideoPath As String
     Public TitlePath As String         'No value is passed during this event
     Public TitlePath As String
     Public CmdLine As String
     Public CmdLine As String
End Structure</pre>
End Structure</pre>
==== Function ====
==== <span class="plugin_header_mini">Mame Info Structure</span> ====
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:solid;">
<pre class="code_es_vb">
<StructLayout(LayoutKind.Sequential)> _
Public Structure Mame_Info
    Public Players As String
    Public Control As String
    Public CloneOf As String
    Public Orientation As String
    Public VideoWidth As Integer
    Public VideoHeight As Integer
    Public Cocktail As Boolean
End Structure</pre>
==== <span class="plugin_header_mini">Database Structure</span> ====
<pre class="code_es_vb">
<StructLayout(LayoutKind.Sequential)> _
Public Structure Database
    Public Category As String
    Public Year As String
    Public Developer As String
    Public Publisher As String
    Public Description As String
    Public SystemBiography As String
End Structure</pre>
=== <span class="plugin_text_fx">C#</span> ===
==== <span class="plugin_header_mini">Game Info Structure</span> ====
<pre class="code_es_cs">
[ StructLayout( LayoutKind.Sequential )]
public struct Game_Info
{
    public int EmulatorNumber;
    public string EmulatorName;
    public string GameName;
    public string ROMPath;
    public string ROMName;
    public Database GameData;
    public Mame_Info MameInfo;
    public string ROMFilter;
    public string SnapPath;
    public string VideoPath;
    public string TitlePath;
    public string CMDLine;
};</pre>
==== <span class="plugin_header_mini">Mame Info Structure</span> ====
<pre class="code_es_cs">
[ StructLayout( LayoutKind.Sequential )]
public struct Mame_Info
{
    public string Players;
    public string Control;
    public string CloneOf;
    public string Orientation;
    public int VideoWidth;
    public int VideoHeight;
    public bool Cocktail;
};</pre>
==== <span class="plugin_header_mini">Database Structure</span> ====
<pre class="code_es_cs">
[ StructLayout( LayoutKind.Sequential )]
public struct Database
{
    public string Category;
    public string Year;
    public string Developer;
    public string Publisher;
    public string Description;
    public string SystemBiography;
};</pre>
== <span class="plugin_headline_text">Code Examples</span> ==
=== <span class="plugin_text_fx">VB.NET</span> ===
<pre class="code_vb">
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)
    'Access the Game_Info Structure:
     Dim CmdLine As String = Info.CmdLine
     Dim CmdLine As String = Info.CmdLine
    'Access the Mame_Info Structure:
    Dim CloneOf As String = Info.MameInfo.CloneOf
    'Access the Database Structure:
    Dim Dev As String = Info.GameData.Developer
       'Run some code here!
       'Run some code here!
     Return CmdLine
     Return CmdLine
End Function</pre>
End Function</pre>


=== <span style="color:#003300;">C#</span> ===
=== <span class="plugin_text_fx">C#</span> ===
==== Structure ====
<pre class="code_cs">
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:dashed;">
[ 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;
};</pre>
==== Function ====
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:solid;">
public string Event_CommandLine(IntPtr InfoPtr)
public string Event_CommandLine(IntPtr InfoPtr)
{
{
     Game_Info Info = (Game_Info)Marshal.PtrToStructure(InfoPtr, typeof(Game_Info));
     Game_Info Info = (Game_Info)Marshal.PtrToStructure(InfoPtr, typeof(Game_Info));
    //Access the Game_Info Structure:
     string CmdLine = Info.CMDLine;
     string CmdLine = Info.CMDLine;
    //Access the Mame_Info Structure:
    string CloneOf = Info.MameInfo.CloneOf;
    //Access the Database Structure:
    string Dev = Info.GameData.Developer;
       //Run some code here!
       //Run some code here!
     return CmdLine;
     return CmdLine;

Latest revision as of 21:22, 30 April 2014

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

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 = DirectCast(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.

Structures

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

VB.NET

Game Info Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure Game_Info
     Public EmulatorNumber As Integer
     Public EmulatorName As String
     Public GameName As String
     Public ROMPath As String
     Public ROMName As String
     Public GameData As Database
     Public MameInfo As Mame_Info
     Public RomFilter As String
     Public SnapPath As String
     Public VideoPath As String
     Public TitlePath As String
     Public CmdLine As String
End Structure

Mame Info Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure Mame_Info
     Public Players As String
     Public Control As String
     Public CloneOf As String
     Public Orientation As String
     Public VideoWidth As Integer
     Public VideoHeight As Integer
     Public Cocktail As Boolean
End Structure

Database Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure Database
     Public Category As String
     Public Year As String
     Public Developer As String
     Public Publisher As String
     Public Description As String
     Public SystemBiography As String
End Structure

C#

Game Info Structure

[ StructLayout( LayoutKind.Sequential )]
public struct Game_Info
{
     public int EmulatorNumber; 
     public string EmulatorName;
     public string GameName;
     public string ROMPath;
     public string ROMName;
     public Database GameData;
     public Mame_Info MameInfo;
     public string ROMFilter;
     public string SnapPath;
     public string VideoPath;
     public string TitlePath;
     public string CMDLine;
};

Mame Info Structure

[ StructLayout( LayoutKind.Sequential )]
public struct Mame_Info
{
     public string Players;
     public string Control;
     public string CloneOf;
     public string Orientation;
     public int VideoWidth;
     public int VideoHeight;
     public bool Cocktail;
};

Database Structure

[ StructLayout( LayoutKind.Sequential )]
public struct Database
{
     public string Category;
     public string Year;
     public string Developer;
     public string Publisher;
     public string Description;
     public string SystemBiography;
};

Code Examples

VB.NET

Public Function Event_CommandLine(ByVal InfoPtr As IntPtr) As String
     Dim Info As Game_Info = CType(Marshal.PtrToStructure(InfoPtr, GetType(Game_Info)), Game_Info)
     'Access the Game_Info Structure:
     Dim CmdLine As String = Info.CmdLine
     'Access the Mame_Info Structure:
     Dim CloneOf As String = Info.MameInfo.CloneOf
     'Access the Database Structure:
     Dim Dev As String = Info.GameData.Developer
       'Run some code here!
     Return CmdLine
End Function

C#

public string Event_CommandLine(IntPtr InfoPtr)
{
     Game_Info Info = (Game_Info)Marshal.PtrToStructure(InfoPtr, typeof(Game_Info));
     //Access the Game_Info Structure:
     string CmdLine = Info.CMDLine;
     //Access the Mame_Info Structure:
     string CloneOf = Info.MameInfo.CloneOf;
     //Access the Database Structure:
     string Dev = Info.GameData.Developer;
       //Run some code here!
     return CmdLine;
}