So, having read the FAQ, you've decided to code an Add-in? Great, welcome aboard. Let's hope your journey goes smoothly! There's just one important thing to keep in mind while creating your add-in: do not merge your add-in source code with the PowerPatcher source code on this site.

Truly Getting Started

OK, let's get cooking! The first thing you need to do is to install a .NET 3.5 - capable IDE:

Operating System IDE's
Windows (7, Vista, XP, Server, ect)
Linux (Debian, Ubuntu, Fedora, Red Hat, ect)

For this guide, I will be using Visual Studio 2010 Express as my IDE and C# as my language. C# is the preferred development language because you can easily debug your source and watch as it interacts with PowerPatcher, however you can use any .NET-supported language.

Get the Newest Source

Before you begin developing your add-in, you need to have a "development PowerPatcher". Simply head over to the Source Code, choose the newest (stable) release, then click "download" on the right. Save this file somewhere you can find it. Once it finishes, unzip it. I recommend unzipping it to your documents folder. Don't place it in any Mabinogi Folder - You'll just get yourself confused.

Now, open the file "PowerPatcher.sln". If all goes well, the projects will load up into your IDE. If not.... you'll need to fix the issues before continuing.

Now you'll need to rebuild the solution. This is a fancy way of saying "tell your computer to recompile everything needed to make PowerPatcher". The process varies slightly by IDE, but in Visual Studio, right click "Solution 'PowerPatcher'" (On the right in the Solution Explorer) and choose Rebuild All.

Don't be surprised if it fails, giving errors about "Missing an Assembly Reference" or "Cannot copy files". Just keep rebuilding until it finishes with no errors. (Warnings are OK)

Creating your Add-In's Project

The next step is to create your add-in's project. A project contains all the code files, assembly information, and references needed to compile your add-in.  Simply right click "Solution 'PowerPatcher'", go to the Add menu, and select New Project. The Add New Project wizard should appear. On the left, browse to the language that you'll be using to create your add-in. In the middle, select the Class Library template (it produces a .dll). Enter a name for your add-in. Make it descriptive, and somehow related to what your add-in will do. In this tutorial, I'll be coding an example add-in. Therefore, I chose the name "SampleAddIn". When you're done, the wizard should look something like this, only with your Project Name and Path:

Press OK to create the project.

Some Initial Setup

Now that you've created your project, you need to tweak it a bit. The first thing to do is to change the target framework to 3.5. This varies by IDE. In Visual Studio, open the Project Properties window. On the Application tab, select .NET 3.5 under "Target Framework".

Next, we have to add a reference to PowerPatcherInterop.dll. From the "Project" menu, select Add Reference. On the browse tab, navigate to the folder that contains "PowerPatcher.sln". Move into the subfolder "PowerPatcherInterop/bin/Debug", and make sure the filter is set to show "All files". Select "PowerPatcherInterop.dll" and press OK. Now, in the Solution Explorer, expand your project's tree and then the References subtree. Select the PowerPatcherInterop reference. In the properties window, set Copy Local to false.

We need to modify some other references. Go back to the Add Reference window. This time, on the .NET (GAC in some IDEs) tab, select the "PresentationCore" entry and click "Ok". Add references to PresentationFramework, System. Drawing, and WindowsBase in the same way. Now, depending on your IDE, you may have a reference to "Microsoft.CSharp" in your reference tree. If so, right click it > Remove.

Now we need to modify the build order. In the solution explorer, right click "Solution 'PowerPatcher'" and then click "Project Dependancies". Select your Add-in from the dropdown menu and check the box next to "PowerPatcherInterop". Now, select PowerPatcher from the dropdown menu and check the box next to your add-in. Press OK.

Example of Project Dependencies


Lastly rebuild the project to ensure there are no errors. Then,, in the project three, expand PowerPatcher > Extensions. Right click Add-ins, and choose new folder. Name it the name of your add-in. Right click on that folder. Add > Existing... and browse to your add-in dll. Click the arrow by "add" and choose "Add as link". Click your newly-added dll. In properties, change build action to None and Copy To Output to Always.

Continue to the next section.

Last edited Apr 15, 2012 at 3:01 AM by Xcelled194, version 7


No comments yet.