Skip to content

Commit

Permalink
Cleanup ShowMessages command
Browse files Browse the repository at this point in the history
- Don't loop over choices or number input
- Increment index after choices and number input
(broken in earlier commit)
  • Loading branch information
mateofio committed Sep 3, 2019
1 parent fd271d9 commit eecb17b
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,37 +803,39 @@ bool Game_Interpreter::CommandShowMessage(RPG::EventCommand const& com) { // cod
Game_Message::texts.push_back(com.string);
line_count++;

for (; index + 1 < list.size(); index++) {
// If next event command is the following parts of the message
if (list[index+1].code == Cmd::ShowMessage_2) {
// Add second (another) line
line_count++;
Game_Message::texts.push_back(list[index+1].string);
} else {
// If next event command is show choices
if (list[index+1].code == Cmd::ShowChoice) {
std::vector<std::string> s_choices = GetChoices();
// If choices fit on screen
if (s_choices.size() <= (4 - line_count)) {
index++;
Game_Message::choice_start = line_count;
Game_Message::choice_cancel_type = list[index].parameters[0];
SetupChoices(s_choices, com.indent);
}
} else if (list[index+1].code == Cmd::InputNumber) {
// If next event command is input number
// If input number fits on screen
if (line_count < 4) {
index++;
Game_Message::num_input_start = line_count;
Game_Message::num_input_digits_max = list[index].parameters[0];
Game_Message::num_input_variable_id = list[index].parameters[1];
}
}
++index;

break;
// Check for continued lines via ShowMessage_2
while (index < list.size() && list[index].code == Cmd::ShowMessage_2) {
// Add second (another) line
line_count++;
Game_Message::texts.push_back(list[index].string);
++index;
}

// Handle Choices or number
if (index < list.size()) {
// If next event command is show choices
if (list[index].code == Cmd::ShowChoice) {
std::vector<std::string> s_choices = GetChoices();
// If choices fit on screen
if (s_choices.size() <= (4 - line_count)) {
Game_Message::choice_start = line_count;
Game_Message::choice_cancel_type = list[index].parameters[0];
SetupChoices(s_choices, com.indent);
++index;
}
} else if (list[index].code == Cmd::InputNumber) {
// If next event command is input number
// If input number fits on screen
if (line_count < 4) {
Game_Message::num_input_start = line_count;
Game_Message::num_input_digits_max = list[index].parameters[0];
Game_Message::num_input_variable_id = list[index].parameters[1];
++index;
}
}
} // End for
}

return true;
}
Expand Down

0 comments on commit eecb17b

Please sign in to comment.