Setting up your development environment
Visual Studio Project creation
Build types
Make sure you have installed "Desktop Development with C++" as UWP DLL Projects will not work for Sonic Adventure 2 mods.
- Open Visual Studio (in the case of this guide, it will use 2022 Community edition)
- Create a new project -> C++ -> Dynamic Link Library (DLL)
- Name your project a suitable name, and place it somewhere easy to locate. You will need to go to the folder to grab your DLL file once you've built it to create the mod.
Adding the dependencies:
Go into your Sonic Adventure 2 folder, and find the "programming" directory. Copy all of the files into your Visual Studio Project folder into your Visual Studio project directory. Note that your files will be read in the same directory as the Microsoft Visual Studio Solution file.
For advanced users, the most up-to-date dependencies can be found in Tools inside the "SA2Modloader includes" github page.
Clone or download ModelInfo.h
and ModelInfo.cpp
from LibModUtils.
To download the file in Github, click on each file you want, and click the download button on the right hand side of the header of the code preview.
Place these two files into your Visual Studio Project folder, where the other dependencies have been placed.
You will need to change the first include in ModelInfo.cpp
in order to fix a problem -- change #include "stdafx.h"
to #include "pch.h"
.
If you don't replace the include, this error will occur!
Afterwards, Add the files into your project by right clicking "Header Files" in your project explorer and going to Add -> Existing Item... to add ModelInfo.h
and ModelInfo.cpp
Copying the boilerplate code:
Add a new source file and call it main.cpp
Copy the Chao World Extended API Code Template and paste it into the fresh main.cpp
file that you've added to the Visual Studio project.
Getting the Chao World Extended API:
Get the CWE API from here! Download the cwe_api.h
file and place it where you've placed all your includes.