summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/startup.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-06-20 22:45:22 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-06-20 22:45:22 -0700
commit8b14d1760315c8ea3dcc64298c844b5afbb8f1eb (patch)
treec5c8ee3f28568476d13dc9ad67eea41f81795e41 /crawl-ref/source/startup.cc
parent2ba718fbf94cce3f7ccc471f313afb59dd4060a9 (diff)
downloadcrawl-ref-8b14d1760315c8ea3dcc64298c844b5afbb8f1eb.tar.gz
crawl-ref-8b14d1760315c8ea3dcc64298c844b5afbb8f1eb.zip
Add a "New Game" option to the bottom of the save list
To provide an alternate path for players who don't realize the way to have more than one character running at a time. (Offline.)
Diffstat (limited to 'crawl-ref/source/startup.cc')
-rw-r--r--crawl-ref/source/startup.cc48
1 files changed, 41 insertions, 7 deletions
diff --git a/crawl-ref/source/startup.cc b/crawl-ref/source/startup.cc
index c569043739..22609083fb 100644
--- a/crawl-ref/source/startup.cc
+++ b/crawl-ref/source/startup.cc
@@ -524,6 +524,24 @@ static void _construct_game_modes_menu(MenuScroller* menu)
tmp->set_visible(true);
}
+static void _add_newgame_button(MenuScroller* menu, int num_chars)
+{
+ // XXX: duplicates a lot of _construct_save_games_menu code. not ideal.
+#ifdef USE_TILE_LOCAL
+ SaveMenuItem* tmp = new SaveMenuItem();
+#else
+ TextItem* tmp = new TextItem();
+#endif
+ tmp->set_text("New Game");
+ tmp->set_bounds(coord_def(1, 1), coord_def(1, 2));
+ tmp->set_fg_colour(WHITE);
+ tmp->set_highlight_colour(WHITE);
+ // unique id
+ tmp->set_id(NUM_GAME_TYPE + num_chars);
+ menu->attach_item(tmp);
+ tmp->set_visible(true);
+}
+
static void _construct_save_games_menu(MenuScroller* menu,
const vector<player_save_info>& chars)
{
@@ -546,6 +564,9 @@ static void _construct_save_games_menu(MenuScroller* menu,
menu->attach_item(tmp);
tmp->set_visible(true);
}
+
+ if (!chars.empty())
+ _add_newgame_button(menu, chars.size());
}
// Should probably use some find invocation instead.
@@ -589,12 +610,13 @@ again:
const int max_col = get_number_of_cols();
#endif
const int max_line = get_number_of_lines();
- const int help_start = min(GAME_MODES_START_Y + num_to_lines(num_saves + num_modes) + 2,
+ int save_lines = num_saves + (num_saves ? 1 : 0); // add 1 for New Game
+ const int help_start = min(GAME_MODES_START_Y + num_to_lines(save_lines + num_modes) + 2,
max_line - NUM_MISC_LINES + 1);
const int help_end = help_start + NUM_HELP_LINES + 1;
const int game_mode_bottom = GAME_MODES_START_Y + num_to_lines(num_modes);
- const int game_save_top = help_start - 2 - num_to_lines(min(2, num_saves));
+ const int game_save_top = help_start - 2 - num_to_lines(min(2, save_lines));
const int save_games_start_y = min<int>(game_mode_bottom, game_save_top);
clrscr();
@@ -830,7 +852,10 @@ again:
default:
int save_number = type - NUM_GAME_TYPE;
- input_string = chars.at(save_number).name;
+ if (save_number < num_saves)
+ input_string = chars.at(save_number).name;
+ else // new game
+ input_string = "";
full_name = true;
break;
}
@@ -885,10 +910,19 @@ again:
default:
// It was a savegame instead
const int save_number = id - NUM_GAME_TYPE;
- // Save the savegame character name
- ng_choice->name = chars.at(save_number).name;
- ng_choice->type = chars.at(save_number).saved_game_type;
- ng_choice->filename = chars.at(save_number).filename;
+ if (save_number < num_saves) // actual save
+ {
+ // Save the savegame character name
+ ng_choice->name = chars.at(save_number).name;
+ ng_choice->type = chars.at(save_number).saved_game_type;
+ ng_choice->filename = chars.at(save_number).filename;
+ }
+ else // "new game"
+ {
+ ng_choice->name = "";
+ ng_choice->type = GAME_TYPE_NORMAL;
+ ng_choice->filename = ""; // ?
+ }
return;
}
}