Skip to content

Commit

Permalink
Adds support for loading screens for more than 2 sides.
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper committed Dec 5, 2022
1 parent c11b554 commit c0edcfb
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions src/extensions/scenario/scenarioext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,21 @@ static void Init_Loading_Screen(const char *filename)
if (side == SIDE_GDI) {
prefix = Percent_Chance(50) ? 'C' : 'D';

} else if (side == SIDE_NOD) {
prefix = Percent_Chance(50) ? 'A' : 'B';

/**
* #issue-665
*
* The remaining characters can be used in standard order for new sides.
* This gives us support for 11 new sides before this system breaks.
*/
} else {
prefix = Percent_Chance(50) ? 'A' : 'B';
prefix += char(2*side); // Offset the character based on the side index.
if (prefix > 'Z') {
prefix = 'Z';
}
}

Point2D textpos(0,0);
Expand Down Expand Up @@ -147,9 +160,16 @@ static void Init_Loading_Screen(const char *filename)
textpos.X = solo ? 435 : 435;
textpos.Y = solo ? 157 : 157;

} else {
} else if (side == SIDE_NOD) {
textpos.X = solo ? 436 : 436;
textpos.Y = solo ? 161 : 161;

/**
* All other sides (uses the GDI offsets).
*/
} else {
textpos.X = solo ? 435 : 435;
textpos.Y = solo ? 157 : 157;
}

image_width = 640;
Expand Down Expand Up @@ -183,9 +203,16 @@ static void Init_Loading_Screen(const char *filename)
textpos.X = solo ? 435 : 435;
textpos.Y = solo ? 195 : 195;

} else {
} else if (side == SIDE_NOD) {
textpos.X = solo ? 436 : 436;
textpos.Y = solo ? 200 : 200;

/**
* All other sides (uses the GDI offsets).
*/
} else {
textpos.X = solo ? 435 : 435;
textpos.Y = solo ? 195 : 195;
}

image_width = 640;
Expand Down Expand Up @@ -219,9 +246,16 @@ static void Init_Loading_Screen(const char *filename)
textpos.X = solo ? 563 : 563;
textpos.Y = solo ? 252 : 252;

} else {
} else if (side == SIDE_NOD) {
textpos.X = solo ? 565 : 565;
textpos.Y = solo ? 258 : 258;

/**
* All other sides (uses the GDI offsets).
*/
} else {
textpos.X = solo ? 563 : 563;
textpos.Y = solo ? 252 : 252;
}

image_width = 800;
Expand Down Expand Up @@ -252,6 +286,14 @@ static void Init_Loading_Screen(const char *filename)
char loadname[16];
std::snprintf(loadname, sizeof(loadname), "LOAD%d%c.PCX", load_filename_height, prefix);

/**
* Check to make sure the loading screen file can be found, if not, then
* default to the GDI loading screen image set.
*/
if (!CCFileClass(loadname).Is_Available()) {
std::snprintf(loadname, sizeof(loadname), "LOAD%d%c.PCX", load_filename_height, Sim_Percent_Chance(50) ? 'C' : 'D');
}

DEV_DEBUG_INFO("Loading Screen: \"%s\"\n", loadname);

/**
Expand Down

0 comments on commit c0edcfb

Please sign in to comment.