void DialogueSupervisor::Draw() { if (_current_dialogue == NULL) { IF_PRINT_WARNING(MAP_DEBUG) << "attempted to draw dialogue window when no dialogue was active" << endl; return; } // TODO: Check if speaker ID is 0 and if so, call Draw function with NULL arguments MapSprite* speaker = reinterpret_cast<MapSprite*>(MapMode::CurrentInstance()->GetObjectSupervisor()->GetObject(_current_dialogue->GetCurrentSpeaker())); _dialogue_window.Draw(&speaker->GetName(), speaker->GetFacePortrait()); } // void DialogueSupervisor::Draw()
void DialogueSupervisor::_BeginLine() { // Starts possible events at new line. MapMode *map_mode = MapMode::CurrentInstance(); std::string line_event = _current_dialogue->GetLineBeginEvent(_line_counter); if(!line_event.empty() && !map_mode->GetEventSupervisor()->IsEventActive(line_event)) { map_mode->GetEventSupervisor()->StartEvent(line_event); } // The current speaker id uint32 speaker_id = _current_dialogue->GetLineSpeaker(_line_counter); // Starts possible emote first. std::string emote_event = _current_dialogue->GetLineEmote(_line_counter); if(!emote_event.empty() && !_emote_triggered) { MapSprite* sprite = (speaker_id > 0) ? dynamic_cast<MapSprite *>(map_mode->GetObjectSupervisor()->GetObject(speaker_id)) : NULL; if(sprite) { sprite->Emote(emote_event, (vt_map::private_map::ANIM_DIRECTIONS)sprite->GetCurrentAnimationDirection()); _state = DIALOGUE_STATE_EMOTE; _emote_triggered = true; return; } } _emote_triggered = true; _state = DIALOGUE_STATE_LINE; _current_options = dynamic_cast<MapDialogueOptions *>(_current_dialogue->GetLineOptions(_line_counter)); // Initialize the line timer if(_current_dialogue->GetLineDisplayTime(_line_counter) >= 0) { _line_timer.Initialize(_current_dialogue->GetLineDisplayTime(_line_counter)); _line_timer.Run(); } // If the line has no timer specified, set the line time to zero and put the timer in the finished state else { _line_timer.Initialize(0); _line_timer.Finish(); } // Setup the text and graphics for the dialogue window _dialogue_window.Clear(); _dialogue_window.GetDisplayTextBox().SetDisplayText(_current_dialogue->GetLineText(_line_counter)); MapObject *object = speaker_id > 0 ? map_mode->GetObjectSupervisor()->GetObject(speaker_id) : NULL; if(object && object->GetType() != SPRITE_TYPE) { IF_PRINT_WARNING(MAP_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID() << " referenced a map object which was not a sprite with id: " << speaker_id << std::endl; return; } if(!object) { // Clear the speaker name and potential portrait. _dialogue_window.GetNameText().Clear(); _dialogue_window.SetPortraitImage(NULL); } else { MapSprite *speaker = dynamic_cast<MapSprite *>(object); _dialogue_window.GetNameText().SetText(speaker->GetName()); _dialogue_window.SetPortraitImage(speaker->GetFacePortrait()); } if(_current_options) { for(uint32 i = 0; i < _current_options->GetNumberOptions(); ++i) _dialogue_window.GetDisplayOptionBox().AddOption(_current_options->GetOptionText(i)); _dialogue_window.GetDisplayOptionBox().SetSelection(0); _state = DIALOGUE_STATE_OPTION; } }