void DialogueSupervisor::_EndLine() { // Execute any scripted events that should occur after this line of dialogue has finished std::string line_event = _current_dialogue->GetLineEndEvent(_line_counter); if(!line_event.empty()) { MapMode::CurrentInstance()->GetEventSupervisor()->StartEvent(line_event); } if(_current_options != NULL) { uint32 selected_option = _dialogue_window.GetDisplayOptionBox().GetSelection(); std::string selected_event = _current_options->GetOptionEvent(selected_option); if(!selected_event.empty()) { MapMode::CurrentInstance()->GetEventSupervisor()->StartEvent(selected_event); } } // Determine the next line to read int32 next_line = _current_dialogue->GetLineNextLine(_line_counter); // If this line had options, the selected option next line overrides the line's next line that we set above if(_current_options != NULL) { uint32 selected_option = _dialogue_window.GetDisplayOptionBox().GetSelection(); next_line = _current_options->GetOptionNextLine(selected_option); } // --- Case 1: Explicitly setting the next line. Warn and end the dialogue if the line to move to is invalid if(next_line >= 0) { if(static_cast<uint32>(next_line) >= _current_dialogue->GetLineCount()) { IF_PRINT_WARNING(MAP_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID() << " tried to set dialogue to invalid line. Current/next line values: {" << _line_counter << ", " << next_line << "}" << std::endl; next_line = COMMON_DIALOGUE_END; } } // --- Case 2: Request to incrementing the current line. If we're incrementing past the last line, end the dialogue else if(next_line == COMMON_DIALOGUE_NEXT_LINE) { next_line = _line_counter + 1; if(static_cast<uint32>(next_line) >= _current_dialogue->GetLineCount()) next_line = COMMON_DIALOGUE_END; } // --- Case 3: Request to end the current dialogue else if(next_line == COMMON_DIALOGUE_END) { // Do nothing } // --- Case 4: Unknown negative value. Warn and end dialogue else { IF_PRINT_WARNING(MAP_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID() << " unknown next line control value: " << next_line << std::endl; next_line = COMMON_DIALOGUE_END; } // Now either end the dialogue or move on to the next line if(next_line == COMMON_DIALOGUE_END) { EndDialogue(); } else { _line_counter = next_line; // Reset the emote trigger flag for the next line. _emote_triggered = false; _BeginLine(); } }
void DialogueSupervisor::_UpdateEmote() { MapObject *object = MapMode::CurrentInstance()->GetObjectSupervisor()->GetObject(_current_dialogue->GetLineSpeaker(_line_counter)); if(!object || !object->HasEmote()) { _emote_triggered = true; _BeginLine(); } }
void DialogueSupervisor::_UpdateEmote() { uint32 speaker_id = _current_dialogue->GetLineSpeaker(_line_counter); MapObject *object = speaker_id > 0 ? MapMode::CurrentInstance()->GetObjectSupervisor()->GetObject(speaker_id) : NULL; if(!object || !object->HasEmote()) { _emote_triggered = true; _BeginLine(); } }
void DialogueSupervisor::BeginDialogue(uint32 dialogue_id) { BattleDialogue* dialogue = GetDialogue(dialogue_id); if (dialogue == NULL) { IF_PRINT_WARNING(BATTLE_DEBUG) << "could not begin dialogue because none existed for id# " << dialogue_id << std::endl; return; } if (_current_dialogue != NULL) { IF_PRINT_WARNING(BATTLE_DEBUG) << "beginning a new dialogue while another dialogue is still active" << std::endl; } _line_counter = 0; _current_dialogue = dialogue; _BeginLine(); }
void DialogueSupervisor::_EndLine() { // Determine the next line to read int32 next_line = _current_dialogue->GetLineNextLine(_line_counter); // If this line had options, the selected option next line overrides the line's next line that we set above if (_current_options != NULL) { uint32 selected_option = _dialogue_window.GetDisplayOptionBox().GetSelection(); next_line = _current_options->GetOptionNextLine(selected_option); } // --- Case 1: Explicitly setting the next line. Warn and end the dialogue if the line to move to is invalid if (next_line >= 0) { if (static_cast<uint32>(next_line) >= _current_dialogue->GetLineCount()) { IF_PRINT_WARNING(BATTLE_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID() << " tried to set dialogue to invalid line. Current/next line values: {" << _line_counter << ", " << next_line << "}" << std::endl; next_line = COMMON_DIALOGUE_END; } } // --- Case 2: Request to incrementing the current line. If we're incrementing past the last line, end the dialogue else if (next_line == COMMON_DIALOGUE_NEXT_LINE) { next_line = _line_counter + 1; if (static_cast<uint32>(next_line) >= _current_dialogue->GetLineCount()) next_line = COMMON_DIALOGUE_END; } // --- Case 3: Request to end the current dialogue else if (next_line == COMMON_DIALOGUE_END) { // Do nothing } // --- Case 4: Unknown negative value. Warn and end dialogue else { IF_PRINT_WARNING(BATTLE_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID() << " unknown next line control value: " << next_line << std::endl; next_line = COMMON_DIALOGUE_END; } // Now either end the dialogue or move on to the next line if (next_line == COMMON_DIALOGUE_END) { EndDialogue(); } else { _line_counter = next_line; _BeginLine(); } }
void DialogueSupervisor::BeginDialogue(uint32 dialogue_id) { SpriteDialogue *dialogue = GetDialogue(dialogue_id); if(dialogue == NULL) { IF_PRINT_WARNING(COMMON_DEBUG) << "could not begin dialogue because none existed for id# " << dialogue_id << std::endl; return; } if(_current_dialogue != NULL) { IF_PRINT_WARNING(COMMON_DEBUG) << "beginning a new dialogue while another dialogue is still active" << std::endl; } _line_counter = 0; _current_dialogue = dialogue; _emote_triggered = false; _BeginLine(); MapMode::CurrentInstance()->PushState(STATE_DIALOGUE); }
void DialogueSupervisor::StartDialogue(const std::string& dialogue_id) { Dialogue *dialogue = GetDialogue(dialogue_id); if(dialogue == nullptr) { PRINT_WARNING << "Could not begin dialogue because none existed for id: " << dialogue_id << std::endl; return; } if(_current_dialogue != nullptr) { PRINT_WARNING << "beginning a new dialogue while another dialogue is still active" << std::endl; } _line_counter = 0; _current_dialogue = dialogue; _current_options = _current_dialogue->GetLineOptions(_line_counter); _BeginLine(); }