@@ -40,6 +40,8 @@ constexpr int menu_command_width = 88;
40
40
constexpr int gold_window_width = 88 ;
41
41
constexpr int gold_window_height = 32 ;
42
42
43
+ Scene_Menu::CommandOptionType Scene_Menu::force_cursor_index = Scene_Menu::CommandOption_None;
44
+
43
45
Scene_Menu::Scene_Menu (int menu_index) :
44
46
menu_index(menu_index) {
45
47
type = Scene::Menu;
@@ -78,28 +80,30 @@ void Scene_Menu::CreateCommandWindow() {
78
80
// Create Options Window
79
81
std::vector<std::string> options;
80
82
83
+ using Cmd = CommandOptionType;
84
+
81
85
if (Player::IsRPG2k ()) {
82
- command_options.push_back (Item);
83
- command_options.push_back (Skill);
84
- command_options.push_back (Equipment);
85
- command_options.push_back (Save);
86
+ command_options.push_back (Cmd:: Item);
87
+ command_options.push_back (Cmd:: Skill);
88
+ command_options.push_back (Cmd:: Equipment);
89
+ command_options.push_back (Cmd:: Save);
86
90
if (Player::player_config.settings_in_menu .Get ()) {
87
- command_options.push_back (Settings);
91
+ command_options.push_back (Cmd:: Settings);
88
92
}
89
93
if (Player::debug_flag) {
90
- command_options.push_back (Debug);
94
+ command_options.push_back (Cmd:: Debug);
91
95
}
92
- command_options.push_back (Quit);
96
+ command_options.push_back (Cmd:: Quit);
93
97
} else {
94
98
for (std::vector<int16_t >::iterator it = lcf::Data::system .menu_commands .begin ();
95
99
it != lcf::Data::system .menu_commands .end (); ++it) {
96
100
switch (*it) {
97
- case Row:
101
+ case static_cast < int >(Cmd:: Row) :
98
102
if (Feature::HasRow ()) {
99
103
command_options.push_back ((CommandOptionType)*it);
100
104
}
101
105
break ;
102
- case Wait:
106
+ case static_cast < int >(Cmd:: Wait) :
103
107
if (Feature::HasRpg2k3BattleSystem ()) {
104
108
command_options.push_back ((CommandOptionType)*it);
105
109
}
@@ -110,46 +114,46 @@ void Scene_Menu::CreateCommandWindow() {
110
114
}
111
115
}
112
116
if (Player::player_config.settings_in_menu .Get ()) {
113
- command_options.push_back (Settings);
117
+ command_options.push_back (Cmd:: Settings);
114
118
}
115
119
if (Player::debug_flag) {
116
- command_options.push_back (Debug);
120
+ command_options.push_back (Cmd:: Debug);
117
121
}
118
- command_options.push_back (Quit);
122
+ command_options.push_back (Cmd:: Quit);
119
123
}
120
124
121
125
// Add all menu items
122
126
std::vector<CommandOptionType>::iterator it;
123
127
for (it = command_options.begin (); it != command_options.end (); ++it) {
124
128
switch (*it) {
125
- case Item:
129
+ case Cmd:: Item:
126
130
options.push_back (ToString (lcf::Data::terms.command_item ));
127
131
break ;
128
- case Skill:
132
+ case Cmd:: Skill:
129
133
options.push_back (ToString (lcf::Data::terms.command_skill ));
130
134
break ;
131
- case Equipment:
135
+ case Cmd:: Equipment:
132
136
options.push_back (ToString (lcf::Data::terms.menu_equipment ));
133
137
break ;
134
- case Save:
138
+ case Cmd:: Save:
135
139
options.push_back (ToString (lcf::Data::terms.menu_save ));
136
140
break ;
137
- case Status:
141
+ case Cmd:: Status:
138
142
options.push_back (ToString (lcf::Data::terms.status ));
139
143
break ;
140
- case Row:
144
+ case Cmd:: Row:
141
145
options.push_back (ToString (lcf::Data::terms.row ));
142
146
break ;
143
- case Order:
147
+ case Cmd:: Order:
144
148
options.push_back (ToString (lcf::Data::terms.order ));
145
149
break ;
146
- case Wait:
150
+ case Cmd:: Wait:
147
151
options.push_back (ToString (Main_Data::game_system->GetAtbMode () == lcf::rpg::SaveSystem::AtbMode_atb_wait ? lcf::Data::terms.wait_on : lcf::Data::terms.wait_off ));
148
152
break ;
149
- case Settings:
153
+ case Cmd:: Settings:
150
154
options.push_back (" Settings" );
151
155
break ;
152
- case Debug:
156
+ case Cmd:: Debug:
153
157
options.push_back (" Debug" );
154
158
break ;
155
159
default :
@@ -161,22 +165,30 @@ void Scene_Menu::CreateCommandWindow() {
161
165
command_window.reset (new Window_Command (options, menu_command_width));
162
166
command_window->SetX (Player::menu_offset_x);
163
167
command_window->SetY (Player::menu_offset_y);
164
- command_window->SetIndex (menu_index);
168
+
169
+ if (force_cursor_index != CommandOption_None) {
170
+ if (auto idx = GetCommandIndex (force_cursor_index); idx != -1 ) {
171
+ command_window->SetIndex (idx);
172
+ }
173
+ force_cursor_index = CommandOption_None;
174
+ } else {
175
+ command_window->SetIndex (menu_index);
176
+ }
165
177
166
178
// Disable items
167
179
for (it = command_options.begin (); it != command_options.end (); ++it) {
168
180
switch (*it) {
169
- case Save:
181
+ case Cmd:: Save:
170
182
// If save is forbidden disable this item
171
183
if (!Main_Data::game_system->GetAllowSave ()) {
172
184
command_window->DisableItem (it - command_options.begin ());
173
185
}
174
- case Wait:
175
- case Quit:
176
- case Settings:
177
- case Debug:
186
+ case Cmd:: Wait:
187
+ case Cmd:: Quit:
188
+ case Cmd:: Settings:
189
+ case Cmd:: Debug:
178
190
break ;
179
- case Order:
191
+ case Cmd:: Order:
180
192
if (Main_Data::game_party->GetActors ().size () <= 1 ) {
181
193
command_window->DisableItem (it - command_options.begin ());
182
194
}
@@ -191,25 +203,26 @@ void Scene_Menu::CreateCommandWindow() {
191
203
}
192
204
193
205
void Scene_Menu::UpdateCommand () {
206
+ using Cmd = CommandOptionType;
194
207
if (Input::IsTriggered (Input::CANCEL)) {
195
208
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Cancel ));
196
209
Scene::Pop ();
197
210
} else if (Input::IsTriggered (Input::DECISION)) {
198
211
menu_index = command_window->GetIndex ();
199
212
200
213
switch (command_options[menu_index]) {
201
- case Item:
214
+ case Cmd:: Item:
202
215
if (Main_Data::game_party->GetActors ().empty ()) {
203
216
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Buzzer ));
204
217
} else {
205
218
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
206
219
Scene::Push (std::make_shared<Scene_Item>());
207
220
}
208
221
break ;
209
- case Skill:
210
- case Equipment:
211
- case Status:
212
- case Row:
222
+ case Cmd:: Skill:
223
+ case Cmd:: Equipment:
224
+ case Cmd:: Status:
225
+ case Cmd:: Row:
213
226
if (Main_Data::game_party->GetActors ().empty ()) {
214
227
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Buzzer ));
215
228
} else {
@@ -219,37 +232,37 @@ void Scene_Menu::UpdateCommand() {
219
232
menustatus_window->SetIndex (0 );
220
233
}
221
234
break ;
222
- case Save:
235
+ case Cmd:: Save:
223
236
if (!Main_Data::game_system->GetAllowSave ()) {
224
237
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Buzzer ));
225
238
} else {
226
239
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
227
240
Scene::Push (std::make_shared<Scene_Save>());
228
241
}
229
242
break ;
230
- case Order:
243
+ case Cmd:: Order:
231
244
if (Main_Data::game_party->GetActors ().size () <= 1 ) {
232
245
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Buzzer ));
233
246
} else {
234
247
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
235
248
Scene::Push (std::make_shared<Scene_Order>());
236
249
}
237
250
break ;
238
- case Wait:
251
+ case Cmd:: Wait:
239
252
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
240
253
Main_Data::game_system->ToggleAtbMode ();
241
254
command_window->SetItemText (menu_index,
242
255
Main_Data::game_system->GetAtbMode () == lcf::rpg::SaveSystem::AtbMode_atb_wait ? lcf::Data::terms.wait_on : lcf::Data::terms.wait_off );
243
256
break ;
244
- case Settings:
257
+ case Cmd:: Settings:
245
258
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Game_System::SFX_Decision));
246
259
Scene::Push (std::make_shared<Scene_Settings>());
247
260
break ;
248
- case Debug:
261
+ case Cmd:: Debug:
249
262
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
250
263
Scene::Push (std::make_shared<Scene_Debug>());
251
264
break ;
252
- case Quit:
265
+ case Cmd:: Quit:
253
266
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
254
267
Scene::Push (std::make_shared<Scene_End>());
255
268
break ;
@@ -258,30 +271,31 @@ void Scene_Menu::UpdateCommand() {
258
271
}
259
272
260
273
void Scene_Menu::UpdateActorSelection () {
274
+ using Cmd = CommandOptionType;
261
275
if (Input::IsTriggered (Input::CANCEL)) {
262
276
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Cancel ));
263
277
command_window->SetActive (true );
264
278
menustatus_window->SetActive (false );
265
279
menustatus_window->SetIndex (-1 );
266
280
} else if (Input::IsTriggered (Input::DECISION)) {
267
281
switch (command_options[command_window->GetIndex ()]) {
268
- case Skill:
282
+ case Cmd:: Skill:
269
283
if (!menustatus_window->GetActor ()->CanAct ()) {
270
284
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Buzzer ));
271
285
return ;
272
286
}
273
287
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
274
288
Scene::Push (std::make_shared<Scene_Skill>(Main_Data::game_party->GetActors (), menustatus_window->GetIndex ()));
275
289
break ;
276
- case Equipment:
290
+ case Cmd:: Equipment:
277
291
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
278
292
Scene::Push (std::make_shared<Scene_Equip>(Main_Data::game_party->GetActors (), menustatus_window->GetIndex ()));
279
293
break ;
280
- case Status:
294
+ case Cmd:: Status:
281
295
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
282
296
Scene::Push (std::make_shared<Scene_Status>(Main_Data::game_party->GetActors (), menustatus_window->GetIndex ()));
283
297
break ;
284
- case Row:
298
+ case Cmd:: Row:
285
299
{
286
300
Main_Data::game_system->SePlay (Main_Data::game_system->GetSystemSE (Main_Data::game_system->SFX_Decision ));
287
301
// Don't allow entire party in the back row.
@@ -313,3 +327,11 @@ void Scene_Menu::UpdateActorSelection() {
313
327
menustatus_window->SetIndex (-1 );
314
328
}
315
329
}
330
+
331
+ int Scene_Menu::GetCommandIndex (CommandOptionType cmd) const {
332
+ auto it = std::find (command_options.begin (), command_options.end (), cmd);
333
+ if (it != command_options.end ()) {
334
+ return (it - command_options.begin ());
335
+ }
336
+ return -1 ;
337
+ }
0 commit comments