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

From Spesoft/GameEx Wiki
Jump to navigation Jump to search
(Created page with "This function is called when a game is added to or removed from the user's favorites list.<br /><br /> <div class="note_block_red"><b>PLEASE NOTE:</b> ''As of Version 1.41, th...")
 
 
(One intermediate revision by the same user not shown)
Line 130: Line 130:
<pre class="code_vb">
<pre class="code_vb">
Public Function Event_Favourites(ByVal Type As Integer, ByVal InfoPtr As IntPtr) As Boolean
Public Function Event_Favourites(ByVal Type As Integer, ByVal InfoPtr As IntPtr) As Boolean
    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
     Select Case Type
     Select Case Type
         Case Favourites_Type.Add
         Case Favourites_Type.Add
Line 138: Line 146:
     Return True
     Return True
End Function</pre>
End Function</pre>
=== <span class="plugin_text_fx">C#</span> ===
=== <span class="plugin_text_fx">C#</span> ===
<pre class="code_cs">
<pre class="code_cs">
public bool Event_Favourites(Favourites_Type Type, Game_Info Info)
public bool Event_Favourites(Favourites_Type Type, Game_Info Info)
{
{
    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;
     switch(Type)
     switch(Type)
     {
     {

Latest revision as of 22:45, 30 April 2014

This function is called when a game is added to or removed from the user's favorites list.

PLEASE NOTE: As of Version 1.41, this feature is listed in the internal plugin documentation as "Not Yet Implemented".


Parameters

Type [Integer]: An integer specifying the Favorites type.
InfoPtr [IntPtr]: A sequential array of game data.

Parameter Values

The Type integer can be converted to Favorites_Type via the supplied enumeration.
The InfoPtr IntPtr should be pushed to the GameExInfo structure using a 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 process the favorites event.
Return false and GameEx will not process the favorites event.

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

Enumerations

The structures below outline the the data type converted in the PlugIn.dll file.

VB.NET

Public Enum Favourites_Type
     Add = 0
     Remove = 1
End Enum

C#

public enum Favourites_Type : uint
{
     Add = 0,
     Remove = 1
}

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 Event_Favourites(ByVal Type As Integer, ByVal InfoPtr As IntPtr) As Boolean
     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

     Select Case Type
        Case Favourites_Type.Add
           Exit Select
        Case Favourites_Type.Remove
           Exit Select
        End Select
     Return True
End Function

C#

public bool Event_Favourites(Favourites_Type Type, Game_Info Info)
{
     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;

     switch(Type)
     {
        case Favourites_Type.Add:
           break;
	case Favourites_Type.Remove:
	   break;
     }
     return true;
}