1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-28 15:38:30 +02:00

De-duplicate Level Complete sequence textboxes

Every Level Complete sequence is the same copy-pasted thing, but with
minor changes. To make my work easier, I'm de-duplicating them so I have
less text boxes to change later, and less grind to grind.
This commit is contained in:
Misa 2021-03-19 19:37:54 -07:00 committed by Ethan Lee
parent b7ca408076
commit 5de884f584
2 changed files with 106 additions and 369 deletions

View File

@ -634,6 +634,86 @@ void Game::savecustomlevelstats(void)
} }
} }
void Game::levelcomplete_textbox(void)
{
if (graphics.flipmode)
{
graphics.createtextbox("", -1, 180, 165, 165, 255);
}
else
{
graphics.createtextbox("", -1, 12, 165, 165, 255);
}
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxcenterx();
}
void Game::crewmate_textbox(const int r, const int g, const int b)
{
if (graphics.flipmode)
{
graphics.createtextbox("", -1, 104, r, g, b);
}
else
{
graphics.createtextbox("", -1, 64 + 8 + 16, r, g, b);
}
graphics.addline(" You have rescued ");
graphics.addline(" a crew member! ");
graphics.addline("");
graphics.textboxcenterx();
}
void Game::remaining_textbox(void)
{
const int remaining = 6 - crewrescued();
const char* string;
char buffer[161]; /* 4 bytes per 40 chars (whole screen) plus 1 for null terminator */
if (remaining == 1)
{
string = " One remains ";
}
else if (remaining > 0)
{
SDL_snprintf(
buffer,
sizeof(buffer),
" %s remain ",
help.number(remaining).c_str()
);
string = buffer;
}
else
{
string = " All Crew Members Rescued! ";
}
if (graphics.flipmode)
{
graphics.createtextbox(string, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(string, -1, 128 + 16, 174, 174, 174);
}
graphics.textboxcenterx();
}
void Game::actionprompt_textbox(void)
{
if (graphics.flipmode)
{
graphics.createtextbox(" Press ACTION to continue ", -1, 20, 164, 164, 255);
}
else
{
graphics.createtextbox(" Press ACTION to continue ", -1, 196, 164, 164, 255);
}
graphics.textboxcenterx();
}
void Game::updatestate(void) void Game::updatestate(void)
{ {
statedelay--; statedelay--;
@ -2180,93 +2260,25 @@ void Game::updatestate(void)
state++; state++;
statedelay = 75; statedelay = 75;
if (graphics.flipmode) levelcomplete_textbox();
{
graphics.createtextbox("", -1, 180, 165, 165, 255);
}
else
{
graphics.createtextbox("", -1, 12, 165, 165, 255);
}
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3007: case 3007:
state++; state++;
statedelay = 45; statedelay = 45;
if (graphics.flipmode) crewmate_textbox(175, 174, 174);
{
graphics.createtextbox("", -1, 104, 175,174,174);
}
else
{
graphics.createtextbox("", -1, 64+8+16, 175,174,174);
}
graphics.addline(" You have rescued ");
graphics.addline(" a crew member! ");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3008: case 3008:
{
state++; state++;
statedelay = 45; statedelay = 45;
int temp = 6 - crewrescued(); remaining_textbox();
if (temp == 1)
{
std::string tempstring = " One remains ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else if (temp > 0)
{
std::string tempstring = " " + help.number(temp) + " remain ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else
{
if (graphics.flipmode)
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 128+16, 174, 174, 174);
}
}
graphics.textboxcenterx();
break; break;
}
case 3009: case 3009:
state++; state++;
statedelay = 0; statedelay = 0;
if (graphics.flipmode) actionprompt_textbox();
{
graphics.createtextbox(" Press ACTION to continue ", -1, 20, 164, 164, 255);
}
else
{
graphics.createtextbox(" Press ACTION to continue ", -1, 196, 164, 164, 255);
}
graphics.textboxcenterx();
break; break;
case 3010: case 3010:
if (jumppressed) if (jumppressed)
@ -2290,93 +2302,25 @@ void Game::updatestate(void)
statedelay = 75; statedelay = 75;
if (graphics.flipmode) levelcomplete_textbox();
{
graphics.createtextbox("", -1, 180, 165, 165, 255);
}
else
{
graphics.createtextbox("", -1, 12, 165, 165, 255);
}
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3021: case 3021:
state++; state++;
statedelay = 45; statedelay = 45;
if (graphics.flipmode) crewmate_textbox(174, 175, 174);
{
graphics.createtextbox("", -1, 104, 174,175,174);
}
else
{
graphics.createtextbox("", -1, 64+8+16, 174,175,174);
}
graphics.addline(" You have rescued ");
graphics.addline(" a crew member! ");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3022: case 3022:
{
state++; state++;
statedelay = 45; statedelay = 45;
int temp = 6 - crewrescued(); remaining_textbox();
if (temp == 1)
{
std::string tempstring = " One remains ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else if (temp > 0)
{
std::string tempstring = " " + help.number(temp) + " remain ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else
{
if (graphics.flipmode)
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 128+16, 174, 174, 174);
}
}
graphics.textboxcenterx();
break; break;
}
case 3023: case 3023:
state++; state++;
statedelay = 0; statedelay = 0;
if (graphics.flipmode) actionprompt_textbox();
{
graphics.createtextbox(" Press ACTION to continue ", -1, 20, 164, 164, 255);
}
else
{
graphics.createtextbox(" Press ACTION to continue ", -1, 196, 164, 164, 255);
}
graphics.textboxcenterx();
break; break;
case 3024: case 3024:
if (jumppressed) if (jumppressed)
@ -2399,93 +2343,25 @@ void Game::updatestate(void)
state++; state++;
statedelay = 75; statedelay = 75;
if (graphics.flipmode) levelcomplete_textbox();
{
graphics.createtextbox("", -1, 180, 165, 165, 255);
}
else
{
graphics.createtextbox("", -1, 12, 165, 165, 255);
}
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3041: case 3041:
state++; state++;
statedelay = 45; statedelay = 45;
if (graphics.flipmode) crewmate_textbox(174, 174, 175);
{
graphics.createtextbox("", -1, 104, 174,174,175);
}
else
{
graphics.createtextbox("", -1, 64+8+16, 174,174,175);
}
graphics.addline(" You have rescued ");
graphics.addline(" a crew member! ");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3042: case 3042:
{
state++; state++;
statedelay = 45; statedelay = 45;
int temp = 6 - crewrescued(); remaining_textbox();
if (temp == 1)
{
std::string tempstring = " One remains ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else if (temp > 0)
{
std::string tempstring = " " + help.number(temp) + " remain ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else
{
if (graphics.flipmode)
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 128+16, 174, 174, 174);
}
}
graphics.textboxcenterx();
break; break;
}
case 3043: case 3043:
state++; state++;
statedelay = 0; statedelay = 0;
if (graphics.flipmode) actionprompt_textbox();
{
graphics.createtextbox(" Press ACTION to continue ", -1, 20, 164, 164, 255);
}
else
{
graphics.createtextbox(" Press ACTION to continue ", -1, 196, 164, 164, 255);
}
graphics.textboxcenterx();
break; break;
case 3044: case 3044:
if (jumppressed) if (jumppressed)
@ -2509,93 +2385,25 @@ void Game::updatestate(void)
statedelay = 75; statedelay = 75;
if (graphics.flipmode) levelcomplete_textbox();
{
graphics.createtextbox("", -1, 180, 165, 165, 255);
}
else
{
graphics.createtextbox("", -1, 12, 165, 165, 255);
}
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3051: case 3051:
state++; state++;
statedelay = 45; statedelay = 45;
if (graphics.flipmode) crewmate_textbox(175, 175, 174);
{
graphics.createtextbox("", -1, 104, 175,175,174);
}
else
{
graphics.createtextbox("", -1, 64+8+16, 175,175,174);
}
graphics.addline(" You have rescued ");
graphics.addline(" a crew member! ");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3052: case 3052:
{
state++; state++;
statedelay = 45; statedelay = 45;
int temp = 6 - crewrescued(); remaining_textbox();
if (temp == 1)
{
std::string tempstring = " One remains ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else if (temp > 0)
{
std::string tempstring = " " + help.number(temp) + " remain ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else
{
if (graphics.flipmode)
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 128+16, 174, 174, 174);
}
}
graphics.textboxcenterx();
break; break;
}
case 3053: case 3053:
state++; state++;
statedelay = 0; statedelay = 0;
if (graphics.flipmode) actionprompt_textbox();
{
graphics.createtextbox(" Press ACTION to continue ", -1, 20, 164, 164, 255);
}
else
{
graphics.createtextbox(" Press ACTION to continue ", -1, 196, 164, 164, 255);
}
graphics.textboxcenterx();
break; break;
case 3054: case 3054:
if (jumppressed) if (jumppressed)
@ -2643,93 +2451,25 @@ void Game::updatestate(void)
state++; state++;
statedelay = 75; statedelay = 75;
if (graphics.flipmode) levelcomplete_textbox();
{
graphics.createtextbox("", -1, 180, 165, 165, 255);
}
else
{
graphics.createtextbox("", -1, 12, 165, 165, 255);
}
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3061: case 3061:
state++; state++;
statedelay = 45; statedelay = 45;
if (graphics.flipmode) crewmate_textbox(175, 174, 175);
{
graphics.createtextbox("", -1, 104, 175,174,175);
}
else
{
graphics.createtextbox("", -1, 64+8+16, 175,174,175);
}
graphics.addline(" You have rescued ");
graphics.addline(" a crew member! ");
graphics.addline("");
graphics.textboxcenterx();
break; break;
case 3062: case 3062:
{
state++; state++;
statedelay = 45; statedelay = 45;
int temp = 6 - crewrescued(); remaining_textbox();
if (temp == 1)
{
std::string tempstring = " One remains ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else if (temp > 0)
{
std::string tempstring = " " + help.number(temp) + " remain ";
if (graphics.flipmode)
{
graphics.createtextbox(tempstring, -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(tempstring, -1, 128+16, 174, 174, 174);
}
}
else
{
if (graphics.flipmode)
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 72, 174, 174, 174);
}
else
{
graphics.createtextbox(" All Crew Members Rescued! ", -1, 128+16, 174, 174, 174);
}
}
graphics.textboxcenterx();
break; break;
}
case 3063: case 3063:
state++; state++;
statedelay = 0; statedelay = 0;
if (graphics.flipmode) actionprompt_textbox();
{
graphics.createtextbox(" Press ACTION to continue ", -1, 20, 164, 164, 255);
}
else
{
graphics.createtextbox(" Press ACTION to continue ", -1, 196, 164, 164, 255);
}
graphics.textboxcenterx();
break; break;
case 3064: case 3064:
if (jumppressed) if (jumppressed)
@ -3018,15 +2758,7 @@ void Game::updatestate(void)
state++; state++;
statedelay = 0; statedelay = 0;
if (graphics.flipmode) actionprompt_textbox();
{
graphics.createtextbox(" Press ACTION to continue ", -1, 20, 164, 164, 255);
}
else
{
graphics.createtextbox(" Press ACTION to continue ", -1, 196, 164, 164, 255);
}
graphics.textboxcenterx();
break; break;
case 3509: case 3509:
if (jumppressed) if (jumppressed)

View File

@ -129,6 +129,11 @@ public:
void gethardestroom(void); void gethardestroom(void);
void levelcomplete_textbox(void);
void crewmate_textbox(const int r, const int g, const int b);
void remaining_textbox(void);
void actionprompt_textbox(void);
void updatestate(void); void updatestate(void);
void unlocknum(int t); void unlocknum(int t);