Chaos Project

Game Development => Sea of Code => Development Tools => Topic started by: ForeverZer0 on May 18, 2014, 10:17:54 pm

Title: [C#] Rpg.NET Export Tool
Post by: ForeverZer0 on May 18, 2014, 10:17:54 pm
Rpg.NET Export Tool
Authors: ForeverZer0
Version: 1.0
Type: .NET Post-Built Tool



Introduction

This application is designed to allow you to create Microsoft .NET assemblies that can interop with RGSS using Ruby's Win32API. Assemblies built that target the .NET Framework are managed code, and are unable to be invoked using Ruby. This application performs a post-build process on your existing .NET projects that allows them to be invoked with Win32API, just like that of an unmanaged C/C++ library. Since many on this forum are C# (and other .NET Framework languages) programmers, this should hopefully open up many new possibilities for us that have since moved on from RGSS due to it's simplicity, but still have an active interest in it.



Features





Download

.NET Framework v.4.0
Rpg.NET Export.zip (https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/Rpg.NET%20Export%204.0.zip) (116 KB)

Requires Microsoft .NET Framework 4.0 (http://www.microsoft.com/en-us/download/details.aspx?id=17851)

.NET Framework v.2.0
Rpg.NET Export.zip (https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/Rpg.NET%20Export%202.0.zip) (116 KB)

This version of the framework is already pre-installed on Windows XP SP3 and above.

Contains everything needed to built projects with exported functions.


Source Code
Source Forge (http://sourceforge.net/projects/rpgexport/)



Instructions

Step 1
Download the above file, and unzip to anywhere on your computer.

Step 2
Create a new project, targeting whichever framework you prefer. Remember that pretty much every Window's computer out there will have .NET Framework installed already on it, but higher versions such as 3.5 and 4.0 may not be, and could possibly require the end-user to install before your assembly will work on it.

After creating your project, make a reference to RpgExportAttribute.dll.

Spoiler: ShowHide
(https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/1.png)


Step 3
Now create your code as you please. The only important factor to implement is that the methods must be marked as "static", and they need decorated with the "RpgExport" attribute that is imported from the RpgExportAttribute.dll. The only required argument with the attribute is the name that it will be as exported as, which can be different than the actual method name. Following is a rather simple example:

Spoiler: ShowHide
(https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/2.png)


The name assigned within the "RpgExport" attribute is the name that will be invoked with Ruby's Win32API class.

Step 4
Now build your project, and open up the RpgExport.exe tool.
Either drag-drop the created assembly onto the form, type in the full path to the file, or use the dialog to set the assembly as the input assembly.

Spoiler: ShowHide
(https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/3.png)


Here is a quick explanation of the parameters that can be set in the application:


Step 5
After making any changes you need, click "Export" and the project will be rebuilt. Copy this output assembly to your RPG Maker project's game folder, and you are ready for a test.

Spoiler: ShowHide
(https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/4.png)


Step 6
Within RPG Maker, create the necessary Win32API object, and invoke your new method!

Spoiler: ShowHide
(https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/5.png)


Spoiler: ShowHide
(https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/6.png)




Tips and Tricks

I will add  more to this section later, and explain more on the few things that follow just to get you started.

Invoke Ruby Code From .NET Assembly

Include "System.Runtime.InteropServices" in a class, and use P/Invoke to exectute Ruby code. The only little hiccup I have run in to so far is that ensure any class that implements importing unmanaged DLLs is marked as "internal", and not the within a class you are exporting functions from. To see what I mean, look at the following two pictures.

Spoiler: ShowHide
(https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/7.png)


Spoiler: ShowHide
(https://dl.dropboxusercontent.com/u/20787370/RMXP/Rpg.NET%20Export/8.png)


Win32API.new('RpgNet.dll', 'SayHello', 'p', '').call('ForeverZer0')


Encrypting/Compressing Scripts

Yup, this is actually quite simple, a very good encryption, but does require the use of one other post-built tool. I will explain more tomorrow within the next day or so.



Notes

Feel free to report any bugs, issues, or comments, I will try to answer anything that I can.
Please give credit if using in your project!
Title: Re: [C#] Rpg.NET Export Tool
Post by: PhoenixFire on May 18, 2014, 11:36:09 pm
+1

very cool :)
Title: Re: [C#] Rpg.NET Export Tool
Post by: Blizzard on May 19, 2014, 01:55:43 am
Nice work, F0!
Title: Re: [C#] Rpg.NET Export Tool
Post by: G_G on May 19, 2014, 07:14:44 am
This is definitely cool. Can't wait to see some other stuff with this. :3
Title: Re: [C#] Rpg.NET Export Tool
Post by: ForeverZer0 on May 19, 2014, 07:56:09 am
Thank you all.
I added the download link for version that target Framework 2.0.
I wasn't thinking that when I created using 4.0, one could not make references to the DLL without also targetting 4.0.  Using 2.0 should allow you to use any version you like.
Title: Re: [C#] Rpg.NET Export Tool
Post by: Loveless on March 07, 2015, 10:05:47 pm
Sorry for the necro but I just wanted to say/ask a few things:
-This is beautiful. Much thanks.
-Is the source for this available anywhere? I assume the project itself is abandoned by now.
  -If yes, where and is there a list of bugs or something (maybe some features that were planned but never implemented) that I can use to continue development on my own.

After making use of this I've grown to love the idea too much to give up on it so if there's no source available anywhere I'll probably end up starting from scratch and working to implement the idea myself. At the very least I'd like to let my appreciation of this initiative be known.
   
Title: Re: [C#] Rpg.NET Export Tool
Post by: ForeverZer0 on March 09, 2015, 06:26:14 am
https://sourceforge.net/projects/rpgexport/
Title: Re: [C#] Rpg.NET Export Tool
Post by: Loveless on March 09, 2015, 06:10:11 pm
Quote from: ForeverZer0 on March 09, 2015, 06:26:14 am
https://sourceforge.net/projects/rpgexport/

Thanks for the response but this page gives a 403 error and says it's forbidden.
Title: Re: [C#] Rpg.NET Export Tool
Post by: ForeverZer0 on March 09, 2015, 06:39:39 pm
Oops, I might have it set to private, I will check it out when I get home later, or tomorrow.
Title: Re: [C#] Rpg.NET Export Tool
Post by: Loveless on March 09, 2015, 06:59:42 pm
No problem. I've got time and more than enough to work with at this point.
Title: Re: [C#] Rpg.NET Export Tool
Post by: PhoenixFire on March 09, 2015, 07:08:54 pm
I would be interested to see just what this can do.. C# does after all, have networking capabilities; it would be very cool to see someone take advantage of this possibility, and create an even better networking system for RM games. i guess my only thought on it though, is just feasible that would be..
Title: Re: [C#] Rpg.NET Export Tool
Post by: KK20 on March 09, 2015, 07:29:04 pm
If you wanted to expand upon the server, you'd have to know C# and compile it yourself.
Meanwhile, RMX-OS is Ruby (can you script in RPG Maker? Then you are good to go) and doesn't even need compiling. Extensions are easy because of that.

As for me, I'm just making my server in C/C++ as I really doubt anyone would need to modify the server code for AWE.
Title: Re: [C#] Rpg.NET Export Tool
Post by: Loveless on March 09, 2015, 08:18:26 pm
Quote from: KK20 on March 09, 2015, 07:29:04 pm
If you wanted to expand upon the server, you'd have to know C# and compile it yourself.
Meanwhile, RMX-OS is Ruby (can you script in RPG Maker? Then you are good to go) and doesn't even need compiling. Extensions are easy because of that.

As for me, I'm just making my server in C/C++ as I really doubt anyone would need to modify the server code for AWE.

I don't know much about servers in most regards but my plans would have, generally, been more for personal use. I realize the implications of this type of system but I can't think of a way to distribute it the way normal scripts are shared. Sure we could make a new and infinitely better server but what's the point if the people you made it for wouldn't even be able to use it. Not that it's really a problem seeing as I'm pretty sure this was only ever meant for the more experienced anyways.
Title: Re: [C#] Rpg.NET Export Tool
Post by: ForeverZer0 on March 10, 2015, 11:59:57 pm
Fixed the permission on the Source Forge page, and added the link to the main post.