45
45
#include " baseui.h"
46
46
#include < lcf/reader_util.h>
47
47
48
+ Scene_Title::CommandOptionType Scene_Title::force_cursor_index = Scene_Title::CommandOption_None;
49
+
48
50
Scene_Title::Scene_Title () {
49
51
type = Scene::Title;
50
52
}
@@ -108,7 +110,7 @@ void Scene_Title::Continue(SceneType prev_scene) {
108
110
}
109
111
110
112
void Scene_Title::TransitionIn (SceneType prev_scene) {
111
- if (Game_Battle::battle_test.enabled || ! Check2k3ShowTitle () || Player::game_config. new_game . Get ())
113
+ if (Game_Battle::battle_test.enabled || CheckStartNewGame ())
112
114
return ;
113
115
114
116
if (prev_scene == Scene::Load || Player::hide_title_flag) {
@@ -133,7 +135,7 @@ void Scene_Title::vUpdate() {
133
135
return ;
134
136
}
135
137
136
- if (! Check2k3ShowTitle () || Player::game_config. new_game . Get ()) {
138
+ if (CheckStartNewGame ()) {
137
139
Player::SetupNewGame ();
138
140
if (Player::debug_flag && Player::hide_title_flag) {
139
141
Scene::Push (std::make_shared<Scene_Load>());
@@ -170,12 +172,26 @@ void Scene_Title::vUpdate() {
170
172
void Scene_Title::Refresh () {
171
173
// Enable load game if available
172
174
continue_enabled = FileFinder::HasSavegame ();
173
- if (continue_enabled) {
175
+
176
+ if (force_cursor_index != CommandOption_None) {
177
+ if (auto idx = GetCommandIndex (force_cursor_index); idx != -1 ) {
178
+ command_window->SetIndex (idx);
179
+ }
180
+ force_cursor_index = CommandOption_None;
181
+ } else if (continue_enabled) {
174
182
command_window->SetIndex (1 );
175
183
}
176
184
command_window->SetItemEnabled (1 , continue_enabled);
177
185
}
178
186
187
+ int Scene_Title::GetCommandIndex (CommandOptionType cmd) const {
188
+ auto it = std::find (command_options.begin (), command_options.end (), cmd);
189
+ if (it != command_options.end ()) {
190
+ return (it - command_options.begin ());
191
+ }
192
+ return -1 ;
193
+ }
194
+
179
195
void Scene_Title::OnTranslationChanged () {
180
196
Start ();
181
197
@@ -211,35 +227,59 @@ void Scene_Title::RepositionWindow(Window_Command& window, bool center_vertical)
211
227
void Scene_Title::CreateCommandWindow () {
212
228
// Create Options Window
213
229
std::vector<std::string> options;
214
- options. push_back ( ToString (lcf::Data::terms. new_game ));
215
- options. push_back ( ToString (lcf::Data::terms. load_game )) ;
230
+
231
+ using Cmd = CommandOptionType ;
216
232
217
233
// Reset index to fix issues on reuse.
218
234
indices = CommandIndices ();
219
235
236
+ command_options.push_back (Cmd::NewGame);
237
+ command_options.push_back (Cmd::ContinueGame);
238
+
220
239
// Set "Import" based on metadata
221
240
if (Player::meta->IsImportEnabled ()) {
222
- options.push_back (Player::meta->GetExVocabImportSaveTitleText ());
223
- indices.import = indices.exit ;
224
- indices.exit ++;
241
+ command_options.push_back (Cmd::Import);
225
242
}
226
-
227
243
// Set "Settings" based on the configuration
228
244
if (Player::player_config.settings_in_title .Get ()) {
229
- // FIXME: Translation? Not shown by default though
230
- options.push_back (" Settings" );
231
- indices.settings = indices.exit ;
232
- indices.exit ++;
245
+ command_options.push_back (Cmd::Settings);
233
246
}
234
-
235
247
// Set "Translate" based on metadata
236
248
if (Player::translation.HasTranslations () && Player::player_config.lang_select_in_title .Get ()) {
237
- options.push_back (Player::meta->GetExVocabTranslateTitleText ());
238
- indices.translate = indices.exit ;
239
- indices.exit ++;
249
+ command_options.push_back (Cmd::Translate);
240
250
}
241
251
242
- options.push_back (ToString (lcf::Data::terms.exit_game ));
252
+ command_options.push_back (Cmd::Exit);
253
+
254
+ for (int i = 0 ; i < command_options.size (); ++i) {
255
+ switch (command_options[i]) {
256
+ case Cmd::NewGame:
257
+ indices.new_game = i;
258
+ options.push_back (ToString (lcf::Data::terms.new_game ));
259
+ break ;
260
+ case Cmd::ContinueGame:
261
+ indices.continue_game = i;
262
+ options.push_back (ToString (lcf::Data::terms.load_game ));
263
+ break ;
264
+ case Cmd::Import:
265
+ indices.import = i;
266
+ options.push_back (Player::meta->GetExVocabImportSaveTitleText ());
267
+ break ;
268
+ case Cmd::Settings:
269
+ indices.settings = i;
270
+ // FIXME: Translation? Not shown by default though
271
+ options.push_back (" Settings" );
272
+ break ;
273
+ case Cmd::Translate:
274
+ indices.translate = i;
275
+ options.push_back (Player::meta->GetExVocabTranslateTitleText ());
276
+ break ;
277
+ case Cmd::Exit:
278
+ indices.exit = i;
279
+ options.push_back (ToString (lcf::Data::terms.exit_game ));
280
+ break ;
281
+ }
282
+ }
243
283
244
284
command_window.reset (new Window_Command (options));
245
285
RepositionWindow (*command_window, Player::hide_title_flag);
@@ -267,7 +307,7 @@ void Scene_Title::PlayTitleMusic() {
267
307
268
308
bool Scene_Title::CheckEnableTitleGraphicAndMusic () {
269
309
return Check2k3ShowTitle () &&
270
- !Player::game_config. new_game . Get () &&
310
+ !CheckStartNewGame () &&
271
311
!Game_Battle::battle_test.enabled &&
272
312
!Player::hide_title_flag;
273
313
}
@@ -280,6 +320,10 @@ bool Scene_Title::CheckValidPlayerLocation() {
280
320
return (lcf::Data::treemap.start .party_map_id > 0 );
281
321
}
282
322
323
+ bool Scene_Title::CheckStartNewGame () {
324
+ return !Check2k3ShowTitle () || Player::game_config.new_game .Get ();
325
+ }
326
+
283
327
void Scene_Title::CommandNewGame () {
284
328
if (!CheckValidPlayerLocation ()) {
285
329
Output::Warning (" The game has no start location set." );
0 commit comments