Skip to content

Commit

Permalink
[TD] Implement Cancel button on difficulty select.
Browse files Browse the repository at this point in the history
  • Loading branch information
OmniBlade committed Jun 14, 2024
1 parent 6233416 commit 5ab492d
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 82 deletions.
173 changes: 93 additions & 80 deletions tiberiandawn/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ bool Init_Game(int, char*[])
sprintf(buffer, "Command & Conquer kann Ihren Maustreiber nicht finden..");
#else
#ifdef FRENCH
sprintf(buffer, "Command & Conquer ne peut pas d‚tecter votre gestionnaire de souris.");
sprintf(buffer, "Command & Conquer ne peut pas dtecter votre gestionnaire de souris.");
#else
sprintf(buffer, "Command & Conquer is unable to detect your mouse driver.");
#endif
Expand Down Expand Up @@ -877,37 +877,43 @@ bool Select_Game(bool fade)
case SEL_NEW_SCENARIO:
Scen.CarryOverMoney = 0;
if (Expansion_Dialog()) {
switch (Fetch_Difficulty()) {
case 0:
Scen.CDifficulty = DIFF_HARD;
Scen.Difficulty = DIFF_EASY;
break;

case 1:
Scen.CDifficulty = DIFF_HARD;
Scen.Difficulty = DIFF_NORMAL;
break;

case 2:
Scen.CDifficulty = DIFF_NORMAL;
Scen.Difficulty = DIFF_NORMAL;
break;

case 3:
Scen.CDifficulty = DIFF_EASY;
Scen.Difficulty = DIFF_NORMAL;
break;
int difficulty = Fetch_Difficulty();
if (difficulty != -1) {
switch (difficulty) {
case 0:
Scen.CDifficulty = DIFF_HARD;
Scen.Difficulty = DIFF_EASY;
break;

case 1:
Scen.CDifficulty = DIFF_HARD;
Scen.Difficulty = DIFF_NORMAL;
break;

case 2:
Scen.CDifficulty = DIFF_NORMAL;
Scen.Difficulty = DIFF_NORMAL;
break;

case 3:
Scen.CDifficulty = DIFF_EASY;
Scen.Difficulty = DIFF_NORMAL;
break;

case 4:
Scen.CDifficulty = DIFF_EASY;
Scen.Difficulty = DIFF_HARD;
break;
}

case 4:
Scen.CDifficulty = DIFF_EASY;
Scen.Difficulty = DIFF_HARD;
break;
Theme.Fade_Out();
// Theme.Queue_Song(THEME_AOI);
GameToPlay = GAME_NORMAL;
process = false;
} else {
display = true;
selection = SEL_NONE;
}

Theme.Fade_Out();
// Theme.Queue_Song(THEME_AOI);
GameToPlay = GAME_NORMAL;
process = false;
} else {
display = true;
selection = SEL_NONE;
Expand Down Expand Up @@ -955,12 +961,15 @@ bool Select_Game(bool fade)
/*
** SEL_START_NEW_GAME: Play the game
*/
case SEL_START_NEW_GAME:
if (Special.IsFromInstall) {
Scen.CDifficulty = DIFF_NORMAL;
Scen.Difficulty = DIFF_NORMAL;
} else {
switch (Fetch_Difficulty()) {
case SEL_START_NEW_GAME: {
int difficulty = 2;

if (!Special.IsFromInstall) {
difficulty = Fetch_Difficulty();
}

if (difficulty != -1) {
switch (difficulty) {
case 0:
Scen.CDifficulty = DIFF_HARD;
Scen.Difficulty = DIFF_EASY;
Expand All @@ -986,48 +995,52 @@ bool Select_Game(bool fade)
Scen.Difficulty = DIFF_HARD;
break;
}
}

Scen.CarryOverMoney = 0;
Scen.CarryOverMoney = 0;

if (Is_Demo()) {
Hide_Mouse();
Fade_Palette_To(BlackPalette, FADE_PALETTE_MEDIUM, Call_Back);
Load_Title_Screen("PREPICK.CPS", &HidPage, Palette);
Blit_Hid_Page_To_Seen_Buff();
Fade_Palette_To(Palette, FADE_PALETTE_MEDIUM, Call_Back);
Keyboard->Clear();
Keyboard->Get();
Fade_Palette_To(BlackPalette, FADE_PALETTE_MEDIUM, Call_Back);
Show_Mouse();
}
if (Is_Demo()) {
Hide_Mouse();
Fade_Palette_To(BlackPalette, FADE_PALETTE_MEDIUM, Call_Back);
Load_Title_Screen("PREPICK.CPS", &HidPage, Palette);
Blit_Hid_Page_To_Seen_Buff();
Fade_Palette_To(Palette, FADE_PALETTE_MEDIUM, Call_Back);
Keyboard->Clear();
Keyboard->Get();
Fade_Palette_To(BlackPalette, FADE_PALETTE_MEDIUM, Call_Back);
Show_Mouse();
}

Scen.Scenario = 1;
BuildLevel = 1;
Scen.Scenario = 1;
BuildLevel = 1;

ScenPlayer = SCEN_PLAYER_GDI;
ScenDir = SCEN_DIR_EAST;
Whom = HOUSE_GOOD;
ScenPlayer = SCEN_PLAYER_GDI;
ScenDir = SCEN_DIR_EAST;
Whom = HOUSE_GOOD;

if (!Is_Demo()) {
Theme.Fade_Out();
Choose_Side();
}
if (!Is_Demo()) {
Theme.Fade_Out();
Choose_Side();
}

/*
** If user is playing special mode, do NOT change Whom; leave it set to
** GDI or NOD. Ini.cpp will set the player's ActLike to mirror the
** Whom value.
*/
if (Special.IsJurassic && AreThingiesEnabled) {
ScenPlayer = SCEN_PLAYER_JP;
ScenDir = SCEN_DIR_EAST;
}
/*
** If user is playing special mode, do NOT change Whom; leave it set to
** GDI or NOD. Ini.cpp will set the player's ActLike to mirror the
** Whom value.
*/
if (Special.IsJurassic && AreThingiesEnabled) {
ScenPlayer = SCEN_PLAYER_JP;
ScenDir = SCEN_DIR_EAST;
}

GameToPlay = GAME_NORMAL;
process = false;
GameToPlay = GAME_NORMAL;
process = false;
} else {
display = true;
selection = SEL_NONE;
}
break;

}

/*
** Load a saved game.
*/
Expand Down Expand Up @@ -1652,20 +1665,20 @@ bool Parse_Command_Line(int argc, char* argv[])
" (Syntax: DESTNETxx.xx.xx.xx)\r\n"
" -SOCKET = Kennung des Netzwerk-Sockets (0 - 16383)\n"
" -STEALTH = Namen im Mehrspieler-Modus verstecken (\"Boss-Modus\")\r\n"
" -MESSAGES = Mitteilungen von auáerhalb des Spiels zulassen\r\n"
" -MESSAGES = Mitteilungen von au�erhalb des Spiels zulassen\r\n"
// " -ELITE = Fortgeschrittene KI und Gefechtstechniken.\r\n"
"\r\n");
#else
#ifdef FRENCH
puts("Command & Conquer (c) 1995, Westwood Studios\r\n"
"ParamŠtres:\r\n"
// " -CD<chemin d'accŠs> = Recherche des fichiers dans le\r\n"
// " r‚pertoire indiqu‚.\r\n"
" -DESTNET = Sp‚cifier le num‚ro de r‚seau du systŠme de destination\r\n"
"Paramtres:\r\n"
// " -CD<chemin d'accs> = Recherche des fichiers dans le\r\n"
// " rpertoire indiqu.\r\n"
" -DESTNET = Spcifier le numro de rseau du systme de destination\r\n"
" (Syntaxe: DESTNETxx.xx.xx.xx)\r\n"
" -SOCKET = ID poste r‚seau (0 … 16383)\r\n"
" -SOCKET = ID poste rseau (0 16383)\r\n"
" -STEALTH = Cacher les noms en mode multijoueurs (\"Mode Boss\")\r\n"
" -MESSAGES = Autorise les messages ext‚rieurs … ce jeu.\r\n"
" -MESSAGES = Autorise les messages extrieurs ce jeu.\r\n"
"\r\n");
#else
puts("Command & Conquer (c) 1995, 1996 Westwood Studios\r\n"
Expand Down Expand Up @@ -2062,9 +2075,9 @@ void Parse_INI_File(void)
/*
** These arrays store the coded version of the names Geologic, Period, & Jurassic.
** Decode them by subtracting 83. For you curious types, the names look like:
** š¸Â¿Âº¼¶
** £¸Å¼Â·
** ?ÈÅ´ÆƼ¶
** ��¿º��
** ��ż·
** ?�Ŵ�Ƽ�
** If these INI entries aren't found, the IsJurassic flag does nothing.
*/
static char coded_section[] = {154, 184, 194, 191, 194, 186, 188, 182, 0};
Expand Down
9 changes: 7 additions & 2 deletions tiberiandawn/special.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ int Fetch_Difficulty(void)

int factor = (SeenBuff.Get_Width() == 320) ? 1 : 2;
int const w = 250 * factor;
int const h = 80 * factor;
int const h = 70 * factor;
int const x = ((320 * factor) / 2) - w / 2;
int const y = ((200 * factor) / 2) - h / 2;
int const bwidth = 30 * factor;
Expand All @@ -304,12 +304,14 @@ int Fetch_Difficulty(void)
** Create the OK button.
*/
TextButtonClass okbutton(1, TXT_OK, TPF_BUTTON, (x + w) - (bwidth + 20 * factor), (y + h) - (18 * factor), bwidth);
TextButtonClass cancelbutton(3, TXT_CANCEL, TPF_BUTTON, x + (20 * factor), (y + h) - (18 * factor), bwidth);
GadgetClass* buttonlist = &okbutton;
cancelbutton.Add(*buttonlist);

/*
** Create the slider button.
*/
SliderClass slider(2, x + 20 * factor, y + h - 29 * factor, w - 40 * factor, 8 * factor, true);
SliderClass slider(2, x + 20 * factor, y + h - 38 * factor, w - 40 * factor, 8 * factor, true);
if (Rule.IsFineDifficulty) {
slider.Set_Maximum(5);
slider.Set_Value(2);
Expand Down Expand Up @@ -403,6 +405,9 @@ int Fetch_Difficulty(void)
process = false;
break;

case (3 | BUTTON_FLAG):
return -1;

default:
break;
}
Expand Down

0 comments on commit 5ab492d

Please sign in to comment.