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

From Spesoft/GameEx Wiki
Jump to navigation Jump to search
Line 4: Line 4:


=== <span style="color:#003300;">VB.NET</span> ===
=== <span style="color:#003300;">VB.NET</span> ===
==== Structure =====
==== Structure ====
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:dashed;">
<pre style="font-family:'Lucida Console', Monaco, monospace; border-color:#003300; background-color:#E0EEE0; border-style:dashed;">
<StructLayout(LayoutKind.Sequential)> _
<StructLayout(LayoutKind.Sequential)> _

Revision as of 06:28, 27 April 2014

This function is called when GameEx populates the command line for the chosen game.
Using this function call, you can return an altered command line for GameEx to run instead of the user configured one.
You can return String.Empty or Info.CmdLine and GameEx will not make any changes to the user's command line.
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.

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