Skip to content

Commit

Permalink
Adds support for custom loading screens per scenario.
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper committed Mar 17, 2023
1 parent 1fb45af commit 0bcb341
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 123 deletions.
48 changes: 47 additions & 1 deletion src/extensions/scenario/scenarioext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,20 @@
*/
ScenarioClassExtension::ScenarioClassExtension(const ScenarioClass *this_ptr) :
GlobalExtensionClass(this_ptr),
SidebarSide(SIDE_NONE)
SidebarSide(SIDE_NONE),
LoadingScreen400BackgroundName(),
LoadingScreen480BackgroundName(),
LoadingScreen600BackgroundName(),
LoadingScreen400Loc(0,0),
LoadingScreen480Loc(0,0),
LoadingScreen600Loc(0,0)
{
//if (this_ptr) EXT_DEBUG_TRACE("ScenarioClassExtension::ScenarioClassExtension - 0x%08X\n", (uintptr_t)(ThisPtr));

LoadingScreen400BackgroundName[0] = '\0';
LoadingScreen480BackgroundName[0] = '\0';
LoadingScreen600BackgroundName[0] = '\0';

/**
* This copies the behavior of the games ScenarioClass.
*/
Expand Down Expand Up @@ -171,6 +181,13 @@ void ScenarioClassExtension::Init_Clear()
{
//EXT_DEBUG_TRACE("ScenarioClassExtension::Init_Clear - 0x%08X\n", (uintptr_t)(This()));

LoadingScreen400BackgroundName[0] = '\0';
LoadingScreen480BackgroundName[0] = '\0';
LoadingScreen600BackgroundName[0] = '\0';
LoadingScreen400Loc = TPoint2D<int>(0,0);
LoadingScreen480Loc = TPoint2D<int>(0,0);
LoadingScreen600Loc = TPoint2D<int>(0,0);

{
/**
* Clear the any previously loaded tutorial messages in preperation for
Expand All @@ -197,6 +214,35 @@ bool ScenarioClassExtension::Read_INI(CCINIClass &ini)
{
//EXT_DEBUG_TRACE("ScenarioClassExtension::Read_INI - 0x%08X\n", (uintptr_t)(This()));

static const char * const BASIC = "Basic";

LoadingScreen400BackgroundName[0] = '\0';
LoadingScreen480BackgroundName[0] = '\0';
LoadingScreen400BackgroundName[0] = '\0';
LoadingScreen400Loc = TPoint2D<int>(0,0);
LoadingScreen480Loc = TPoint2D<int>(0,0);
LoadingScreen600Loc = TPoint2D<int>(0,0);

if (ini.Is_Present(BASIC, "LS400BkgdName")) {
ini.Get_String(BASIC, "LS400BkgdName", LoadingScreen400BackgroundName, sizeof(LoadingScreen400BackgroundName));
}
if (ini.Is_Present(BASIC, "LS480BkgdName")) {
ini.Get_String(BASIC, "LS480BkgdName", LoadingScreen480BackgroundName, sizeof(LoadingScreen480BackgroundName));
}
if (ini.Is_Present(BASIC, "LS600BkgdName")) {
ini.Get_String(BASIC, "LS600BkgdName", LoadingScreen600BackgroundName, sizeof(LoadingScreen600BackgroundName));
}

if (ini.Is_Present(BASIC, "LS400TextLoc")) {
LoadingScreen400Loc = ini.Get_Point(BASIC, "LS400TextLoc", LoadingScreen400Loc);
}
if (ini.Is_Present(BASIC, "LS480TextLoc")) {
LoadingScreen480Loc = ini.Get_Point(BASIC, "LS480TextLoc", LoadingScreen480Loc);
}
if (ini.Is_Present(BASIC, "LS600TextLoc")) {
LoadingScreen600Loc = ini.Get_Point(BASIC, "LS600TextLoc", LoadingScreen600Loc);
}

/**
* #issue-123
*
Expand Down
16 changes: 16 additions & 0 deletions src/extensions/scenario/scenarioext.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,20 @@ class ScenarioClassExtension final : public GlobalExtensionClass<ScenarioClass>
* The side to use for the sidebar assets (singleplayer only).
*/
SideType SidebarSide;

/**
* Scenarios can override the loading screen with a custom variant, these
* define the filename to load.
*/
char LoadingScreen400BackgroundName[32];
char LoadingScreen480BackgroundName[32];
char LoadingScreen600BackgroundName[32];

/**
* These are the custom text positions for each of the loading screen
* overrides.
*/
TPoint2D<int> LoadingScreen400Loc;
TPoint2D<int> LoadingScreen480Loc;
TPoint2D<int> LoadingScreen600Loc;
};
Loading

0 comments on commit 0bcb341

Please sign in to comment.