I am back guys. I have almost 3 more years of programming experience and now I actually know what I am doing (scary thought). I made this tutorial for anyone that wants to use the newest version of Microsoft Visual Studio to do OP2 stuff. Since VS2010, I have really liked VS, VS2012 is a really cool IDE for development.
N.B.: I am using Visual Studio 2012 Ultimate on a Windows 8 Pro 64-bit OS for my development, so I apologize if anything does not work or is not in the right place. If any of this is the case, just say so. (:
Getting VS 2012 ExpressVisual Studio 2012 Express for Desktop is free for anyone with a Windows computer. The system requirements are more on the new side. You have to have Windows 7 or newer with 1GB + of RAM and 5GB+ of harddrive space. If you have all of these, you can download and install it from
this link. Download the installer for this and then install it.
DirectoriesOnce you get VS2012 install, you can put everything where it goes. Lets go over the different directories I will refer to.
OP2Development Download the
OP2Development.zip file. In this ZIP, is a solution with everything you need to do development for OP2. Extract this files to anywhere you want. To make things easy, I am going to call the folder you put files in
OP2Development.
VS2012DirThis directory is the one that your VS2012 was installed to, on my machine it is "C:\Program Files (x86)\Microsoft Visual Studio 11.0". Yours should be somewhere similar.
VS2012TemplateDirThis directory is located in your user folder. It should be at "B:\Users\{USER}\Documents\Visual Studio 2012\Templates\ProjectTemplates", where [USER} is your username.
Putting things in the Right PlaceSDK Files (required)Copy the folders "Include" and "Lib" from
OP2Development\API\Outpost2DLL to
VS2012Dir\VC. Also copy the "Include" and "Lib" folders from
OP2Development\API\OP2Helper to
VS2012Dir\VC.
Project Templates (optional)This part is optional, but if you do it, it will add the three simple project templates to your list of templates. This will allow you to quickly and easily create new OP2 projects. In
OP2Development\Templates there are the three template projects. In each project, there is a ZIP folder with the template in it. So there is
OP2Development\Templates\Blank\OP2 Blank.zip,
OP2Development\Templates\Blank-WithComments\OP2 Blank-WithComments.zip, and
OP2Development\Templates\Hooville\OP2 Hooville.zip. To install each of these, copy this ZIP file to
VS2012TemplateDir. Once you do this, restart VS2012 (if it is running) and create a new project. This should be under Visual C++ at the very bottom.
Testing EverythingOnce you get VS2012 installed and all the SDK files copied to the right place, open
OP2Development\Outpost2.sln. VS2012 should open and in the Solution Explorer on the right, you will see three folders: "API", "Templates", and "Tutorials". Each of these folders have projects that are self-explanatory. I got all of these projects from the
GIT repo. If you see no errors in the Solution Explorer, click "BUILD -> Build Solution" or press F9. If everything went okay, you should see "Build succeeded" in the bottom left-hand corner. If this is not working, make sure you did everything right, if it is still not working, post below.
Customizing ProjectsIf you are using the templates I supplied, you can very easily change the output location and file name of the compiled DLL. This is useful if you want to compile the DLL and place it directly into your OP2 game directory to test it
To do this, create a project with one of the templates, then in the Solution Explorer, right-click on the project and goto Properties. Under "Configuration Properties -> General", there is two options you can change, "Output Directory" and "Target Name". Output Directory is the location that the DLL will compiled too and Target Name is what the DLL will be named, which by default is the project name. The Output Directory can be relative or absolute. If you are using relative, ".\" means current directory, and "..\" means previous directory. For example, if have the file structure like this
- Outpost2
- Dev
- API
- Templates
- Tutorials
- Some Project
- Game
The game files are located at "Outpost2\Game" and the project is at "Outpost2\Dev\Some Project". If you want the DLL to be directly compile as a tutorial mission named "tTest.dll", you would change Output Directory to "..\..\Game\" and Target Name would be "tTest".
Importing Visual C++ 6 Project (.dsp) to VS2012First, find the .dsp file. Rename it to whatever you want the project to be named (this allowes you to have mutliple OP2 projects in on Solution, not required). Then, either goto "FILE -> Open -> Project/Solution" or "FILE -> Add -> Existing Project..." and select the .dsp file, or just double-click the .dsp file. Follow the prompts to import the project. You should have a couple of minor errors for the solution import. You can ignore these. Once you import them, you need to modify them a bit to make them compile for the new version of VS. In the Solution Explorer, right-click the project name, goto Properties. In the Properties window, goto "Configuration Properties -> Linker -> Advanced". Look for the option "Image Has Safe Exception Handlers" and set it to "No (/SAFESEH:NO)".
Changes made to Outpost2DLL SDKThis is technical stuff that is boring and most people probably do not care about. These are the changes I had to made to the Outpost2DLL.h file to work with the new setup. In previous setups, it was assumed that the user manually included the .h and .lib files per project. I made everyone's life easier by adding these files to the include directories for VS itself, so there is no problem with trying to use the API functions. I also had to update the check for the CRT replacement. Anyways, I changed lines 4-10 in Outpost2DLL.h to
#pragma comment(lib, "../../Lib/Outpost2DLL")
// Use smaller runtime if MSVC 6.0 is being used
// Note: Later compilers have issues with this.
#if _MSC_VER >= 1200
// Replace the C-RunTime (CRT) with a customized smaller one
#pragma comment(lib, "../../Lib/LibCTiny")