Jump to content

SA2B Mod Loader: Difference between revisions

From SA Docs
Writing SA2B Mod Loader page and documentation.
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:


== Struct ==
== Struct ==
Below is the initialized version of the HelperFunctions struct. For the definition of the struct, you can find that in [https://github.com/X-Hax/sa2-mod-loader/blob/master/SA2ModLoader/include/SA2ModInfo.h SA2ModInfo.h]  
Below is the initialized version of the HelperFunctions struct. For the definition of the struct, you can find that in [https://github.com/X-Hax/sa2-mod-loader/blob/master/SA2ModLoader/include/SA2ModInfo.h SA2ModInfo.h]
{{DocHeader|header=HelperFunctions|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
HelperFunctions helperFunctions =  
HelperFunctions helperFunctions =  
Line 38: Line 39:
};
};
</syntaxhighlight>
</syntaxhighlight>
}}


{{Note|text=Please be aware that all examples on this page will be using <code>helperFunctions</code> which is how the variable is sent to a mod.|type=info}}
== Properties ==
== Properties ==


Line 47: Line 50:


This returns the version of the mod loader. This can be used to check if the user has an old version of the mod loader that may not have functionality your mod requires.
This returns the version of the mod loader. This can be used to check if the user has an old version of the mod loader that may not have functionality your mod requires.
 
{{DocHeader|header=Example Usage|content=
==== Example ====
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
if (globalHelperFunctions.ModLoaderVer <= 10)
if (helperFunctions.ModLoaderVer <= 10)
     PrintDebug("This Mod Loader is way out of date.\n");
     PrintDebug("This Mod Loader is way out of date.\n");
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Mod Loader Settings ===
=== Mod Loader Settings ===
Line 61: Line 63:




==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Mod List ===
=== Mod List ===
Line 72: Line 74:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
 
}}


== Functions ==
== Functions ==
Line 86: Line 88:


Registers a Start Position for the specified character.
Registers a Start Position for the specified character.
 
{{DocHeader|header=Example Usage|content=
==== Example ====
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
// This is a declaration of an SA2 StartPosition struct.
// This is a declaration of an SA2 StartPosition struct.
Line 103: Line 104:
// and we have specified Sonic, so the level for this ID would now use
// and we have specified Sonic, so the level for this ID would now use
// our StartPosition instead of the original.
// our StartPosition instead of the original.
globalHelperFunctions.RegisterStartPosition(Characters_Sonic, &myStageStartPos);
helperFunctions.RegisterStartPosition(Characters_Sonic, &myStageStartPos);
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Clear Start Position List ===
=== Clear Start Position List ===
Line 113: Line 114:


Clears the Start Positions for the specified character.  
Clears the Start Positions for the specified character.  
 
{{DocHeader|header=Example Usage|content=
==== Example ====
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Register 2P Intro Position ===
=== Register 2P Intro Position ===
Line 126: Line 126:


Registers a Multiplayer Intro Position for the specified character.  
Registers a Multiplayer Intro Position for the specified character.  
 
{{DocHeader|header=Example Usage|content=
==== Example ====
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Clear 2P Intro Position List ===
=== Clear 2P Intro Position List ===
Line 139: Line 138:


Clears all Multiplayer Intro Positions for the specified character.
Clears all Multiplayer Intro Positions for the specified character.
 
{{DocHeader|header=Example Usage|content=
==== Example ====
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Get Main Save Path ===
=== Get Main Save Path ===
Line 152: Line 150:


Returns the game's Main Save File's path.
Returns the game's Main Save File's path.
 
{{DocHeader|header=Example Usage|content=
==== Example ====
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Get Chao Save Path ===
=== Get Chao Save Path ===
Line 164: Line 161:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Register End Position ===
=== Register End Position ===
Line 175: Line 172:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Clear End Position List ===
=== Clear End Position List ===
Line 186: Line 183:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Register Mission 2/3 End Position ===
=== Register Mission 2/3 End Position ===
Line 197: Line 194:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Clear Mission 2/3 End Position List ===
=== Clear Mission 2/3 End Position List ===
Line 208: Line 205:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Hook Export ===
=== Hook Export ===
Line 219: Line 216:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Get Replaceable Path ===
=== Get Replaceable Path ===
Line 230: Line 227:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Replace File ===
=== Replace File ===
Line 241: Line 238:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Set Window Title ===
=== Set Window Title ===
Line 252: Line 249:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Debug Text : Set Font Size ===
=== Debug Text : Set Font Size ===
Line 263: Line 260:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Debug Text : Set Font Color ===
=== Debug Text : Set Font Color ===
Line 274: Line 271:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Debug Text : Display String ===
=== Debug Text : Display String ===
Line 285: Line 282:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Debug Text : Display String Formatted ===
=== Debug Text : Display String Formatted ===
Line 296: Line 293:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Debug Text : Display Number ===
=== Debug Text : Display Number ===
Line 307: Line 304:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Register Voice ===
=== Register Voice ===
Line 318: Line 315:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Replace Texture ===
=== Replace Texture ===
Line 329: Line 326:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Unreplace File ===
=== Unreplace File ===
Line 340: Line 337:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Push Interpolation Fix ===
=== Push Interpolation Fix ===
Line 351: Line 348:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Pop Interpolation Fix ===
=== Pop Interpolation Fix ===
Line 362: Line 359:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Get File Mod Index ===
=== Get File Mod Index ===
Line 373: Line 370:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}


=== Replace File At Index ===
=== Replace File At Index ===
Line 384: Line 381:
</syntaxhighlight>
</syntaxhighlight>


==== Example ====
{{DocHeader|header=Example Usage|content=
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
 
// TODO: Add proper example.
</syntaxhighlight>
</syntaxhighlight>
<hr>
}}

Latest revision as of 17:52, 8 October 2025

Source Code


HelperFunctions API

Struct

Below is the initialized version of the HelperFunctions struct. For the definition of the struct, you can find that in SA2ModInfo.h

HelperFunctions

HelperFunctions helperFunctions = 
{
    ModLoaderVer,
    RegisterStartPosition,
    ClearStartPositionList,
    Register2PIntroPosition,
    Clear2PIntroPositionList,
    GetMainSavePath,
    GetChaoSavePath,
    RegisterEndPosition,
    ClearEndPositionList,
    RegisterMission23EndPosition,
    ClearMission23EndPositionList,
    HookExport,
    GetReplaceablePath,
    _ReplaceFile,
    SetWindowTitle,
    debug_text::SetFontSize,
    debug_text::SetFontColor,
    debug_text::DisplayString,
    debug_text::DisplayStringFormatted,
    debug_text::DisplayNumber,
    &loaderSettings,
    &modList,
    &RegisterVoice,
    &ReplaceTexture,
    &UnreplaceFile,
    &PushInterpolationFix,
    &PopInterpolationFix,
};


  Please be aware that all examples on this page will be using helperFunctions which is how the variable is sent to a mod.

Properties

Mod Loader Version

int ModLoaderVer;

This returns the version of the mod loader. This can be used to check if the user has an old version of the mod loader that may not have functionality your mod requires.

Example Usage

if (helperFunctions.ModLoaderVer <= 10)
    PrintDebug("This Mod Loader is way out of date.\n");


Mod Loader Settings

LoaderSettings loaderSettings;


Example Usage

// TODO: Add proper example.


Mod List

std::vector<Mod> modlist;


Example Usage

// TODO: Add proper example.


Functions

Register Start Position

void RegisterStartPosition(unsigned char character, const StartPosition& position)

Registers a Start Position for the specified character.

Example Usage

// This is a declaration of an SA2 StartPosition struct.
StartPosition myStageStartPos = { 
    1,                          // Level ID
    0x4000,                     // Single Player Y Rotation 
    0x4000,                     // Multiplayer, Player 1 Y Rotation
    0x4000,                     // Multiplayer, Player 2 Y Rotation
    { 100.0f, 200.0f, 100.0f }, // Single Player Start Position
    { 90.0f, 200.0f, 100.0f },  // Multiplayer, Player 1 Start Position
    { 110.0f, 200.0f, 100.0f }  // Multiplayer, Player 2 Start Position
};

// We pass our StagePosition variable as a pointer to this function
// and we have specified Sonic, so the level for this ID would now use
// our StartPosition instead of the original.
helperFunctions.RegisterStartPosition(Characters_Sonic, &myStageStartPos);


Clear Start Position List

void ClearStartPositionList(unsigned char character)

Clears the Start Positions for the specified character.

Example Usage

// TODO: Add proper example.


Register 2P Intro Position

void Register2PIntroPosition(unsigned char character, const LevelEndPosition& position)

Registers a Multiplayer Intro Position for the specified character.

Example Usage

// TODO: Add proper example.


Clear 2P Intro Position List

void Clear2PIntroPositionList(unsigned char character)

Clears all Multiplayer Intro Positions for the specified character.

Example Usage

// TODO: Add proper example.


Get Main Save Path

const char* GetMainSavePath()

Returns the game's Main Save File's path.

Example Usage

// TODO: Add proper example.


Get Chao Save Path

const char* GetChaoSavePath()


Example Usage

// TODO: Add proper example.


Register End Position

void RegisterEndPosition(unsigned char character, const StartPosition& position)


Example Usage

// TODO: Add proper example.


Clear End Position List

void ClearEndPositionList(unsigned char character)


Example Usage

// TODO: Add proper example.


Register Mission 2/3 End Position

void RegisterMission23EndPosition(unsigned char character, const LevelEndPosition& position)


Example Usage

// TODO: Add proper example.


Clear Mission 2/3 End Position List

void ClearMission23EndPositionList(unsigned char character)


Example Usage

// TODO: Add proper example.


Hook Export

void HookExport(LPCSTR exportName, const void* newdata)


Example Usage

// TODO: Add proper example.


Get Replaceable Path

const char* __cdecl GetReplaceablePath(const char* path)


Example Usage

// TODO: Add proper example.


Replace File

void _ReplaceFile(const char* src, const char* dst)


Example Usage

// TODO: Add proper example.


Set Window Title

void SetWindowTitle(const wchar_t* title)


Example Usage

// TODO: Add proper example.


Debug Text : Set Font Size

void SetFontSize(float size)


Example Usage

// TODO: Add proper example.


Debug Text : Set Font Color

void SetFontColor(int color)


Example Usage

// TODO: Add proper example.


Debug Text : Display String

void DisplayString(int loc, const char* str)


Example Usage

// TODO: Add proper example.


Debug Text : Display String Formatted

void DisplayStringFormatted(int loc, const char* Format, ...)


Example Usage

// TODO: Add proper example.


Debug Text : Display Number

void DisplayNumber(int loc, int value, int numdigits)


Example Usage

// TODO: Add proper example.


Register Voice

uint16_t RegisterVoice(const char* fileJP, const char* fileEN)


Example Usage

// TODO: Add proper example.


Replace Texture

void ReplaceTexture(const char* pvm_name, const char* tex_name, const char* file_path, uint32_t gbix, uint32_t width, uint32_t height)


Example Usage

// TODO: Add proper example.


Unreplace File

void UnreplaceFile(const char* file)


Example Usage

// TODO: Add proper example.


Push Interpolation Fix

void PushInterpolationFix()


Example Usage

// TODO: Add proper example.


Pop Interpolation Fix

void PopInterpolationFix()


Example Usage

// TODO: Add proper example.


Get File Mod Index

int GetFileModIndex(const char* path)


Example Usage

// TODO: Add proper example.


Replace File At Index

void ReplaceFileAtIndex(const char* src, const char* dst, int modIndex)


Example Usage

// TODO: Add proper example.