Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. Thank you for your support. Tom Speirs

Patreon

[PLUGIN DEVELOPMENT] Visual Basic 2010 Project Template


Adultery

Recommended Posts

Ouch. Was going great guns and getting excited about plugin development, until I hit the reality of debugging. :(

It looks like if your code in an event handler causes an error - this doesn't get caught via the JIT (?), rather it returns false or something to GameEx and gameex closes/disables the plugin? Looked in the GameEx log, and this is what I found:

14:53:41.6 27/10/2015: PlugIn: "Marquee Masher" caused an exception and is being disabled.
14:53:41.6 27/10/2015: Exception has been thrown by the target of an invocation.
14:53:41.6 27/10/2015: at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
14:53:41.6 27/10/2015: at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
14:53:41.6 27/10/2015: at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
14:53:41.6 27/10/2015: at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
14:53:41.6 27/10/2015: at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
14:53:41.6 27/10/2015: at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
14:53:41.6 27/10/2015: at GameEx.PlugIns.InvokeMethod(Object obj, String sProperty, String oValue)
14:53:41.6 27/10/2015: at GameEx.PlugIns.Event_EmulatorLoad(String EmuName)

Ouch. I have no idea how to apply this to the code area concerned - is there any way to get the MS error reporting back (is it the JIT debugger or something?)

Link to comment
Share on other sites

Your best bet here is to put all your code in a try/catch block and log the error. I can provide an example for you if you are already using a log file, or I can look at your code. Your choice. ;)

  • Like 1
Link to comment
Share on other sites

Assuming you've code initializes the logger class...

Try

yourcodehere(variable)

Catch ex As Exception

log.Log_Error(ex.Message)

log.Log_Data(ex.StackTrace)

End Try

  • Like 1
Link to comment
Share on other sites

Oh get in.... loving this plugin development thing now... just don't look under the hood... :)

So, in your tmeplate, Adultery, there's this stuff:

      Public Sub Dispose()            Dispose(True)            GC.SuppressFinalize(Me)        End Sub        ''' <summary>        ''' This event handles the disposal of unused variables.        ''' </summary>        Private Sub Dispose(ByVal disposing As Boolean)            If Not (Me.disposed) Then                If (disposing) Then                End If            End If            disposed = True        End Sub

Bit confused by this bit. Firstly - not very good with disposing stuff - what should I dispose of?

Secondly - where should i stick any code - after "If (disposing) Then"?

Thanks for getting me up and running with yet another great tinker-tastic feature of GameEx!

Link to comment
Share on other sites

You shouldn't need to do anything there unless you are adding your own handles, are reserving memory, holding files and blocking access to them, holding registry values, or unmanaged code or something. GameEx and/or Windows will automatically take care of your garbage collection when you exit the app.

Here's more on that: https://msdn.microsoft.com/en-us/library/fs2xkftw%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

  • Like 1
Link to comment
Share on other sites

That's good news!

Another couple of questions. With attract mode:

Is there any way to get what game and system are playing? The code is

Public Function Event_ScreenSaver(ByVal Type As Integer) As Boolean

There's no

Dim Info As Game_Info = DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(Game_Info)), Game_Info)
To get the game details?
Also - is there any way to start the attract mode manually from the GE UI? I'm sure I remember there was a launch screensaver option - but I can't find it for love nor money - i remember making a graphic for it, but now it no there :(
cheers
Link to comment
Share on other sites

For one: Yes. Get it from the game run event. That event only triggers when attract is actually started or exited, nothing more to see there. It still passes games through the same process of events > Game Run, Command Line, Game Exit. :)

For two: Yes. It's under more programs menu unless you have it disabled. :)

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Yes it does, you'll lose compatibility for users on other OS's. The reason it works for you is probably because you're on an OS with 3.5 or up.

But if yuh don't care about alienating XP users, go for it. :)

Link to comment
Share on other sites

  • 1 year later...

Adultery, 

Can I ask a real noob type question.  I have Visual Studio 17.0 and I have downloaded your plugin template.  When I open the template and try to run it, I get the following error:  Severity    Code    Description    Project    File    Line    Suppression State
Error    BC30113    '$safeprojectname$' is not a valid name and cannot be used as the root namespace name.    GameEx PluginTemplate1    C:\Users\Jim dePrado\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual Basic\vbc    1    Active

 

I would like to try and create a basic plugin, but I am having trouble getting started.  

Thanks and enjoy your weekend!

Jim

Link to comment
Share on other sites

When you say "Run" do you mean you're trying execute it in the VS IDE environment? I.e. you're pressing "Start" (the little green arrow at the top)? 

If so, this won't work. You cannot execute plugins directly. You have to Build them to the GameEx Plugins directory and execute them via GameEx. This also means that you cannot use the VS debugger or runtime environment. So you'll have to build your own logging/error catching system. 

If you're just starting out, I'd recommend trying to write a small stand-alone app first incorporating logging and monitoring tools (an equivalent to Console) and then moving onto writing your first plugin. 

Take it form someone who, until a couple of years ago, could only remember Commodore BASIC:

10 Print "Wham suck"
20 Goto 10

Thus, have been on those starting blocks!

Just for the record - the Plugin Template works fine, having used this to start all my plugins. 

  • Like 1
Link to comment
Share on other sites

Thanks!  Like I said, I am a complete amateur, especially compared to you guys.  

My initial thought is to create an app that creates custom lists for emulators.  Here is my thought process.

  1. Read existing emulators from gameex.ini
  2. Read games/roms from somewhere (I haven't figured this out yet)
  3. Allow users to create alternate lists by selecting games/roms
  4. Copy the selected emulator (and all of it's properties - including rom location).
    1. Maybe make the copied emulator at the bottom of the list (~250)
    2. Create a map file for the emulator for the selected games
  5. Edit custommenu.ini to include the new list

Does that seem reasonable?  There are a ton of things that I'm sure that I haven't thought about yet.  This may have been done in whole or part already.  It is just something that I thought of that would be easy for me to get started.

Are there any files out there that work with input and output of text files that I could look at to get some ideas?  

Thanks!

Jim

Link to comment
Share on other sites

 

 

 

 

The nice thing about the plugin system is that you can do pretty much anything. It's definitely reasonable, but that will be quite the undertaking!

 

 

The plugin template comes with ini parsing code I think. If not I got a class you can import.

 

 

There are people here who can help, so feel free to open a project thread. [emoji880]

 

Link to comment
Share on other sites

2 hours ago, jimdeprado said:

Thanks!  Like I said, I am a complete amateur, especially compared to you guys.  

He must be talking about you, A.....

@jimdeprado - Errrrrr, Custom Lists can do all that (I believe you've downloaded that?). But if you want to re-invent the wheel - tuck in! 

I would say though, as a complete amateur, aim smaller first. People will help out, but not to the level of helping a brick layer do brain surgery. Aim for technical drawing before architecture.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...