// Copyright (c) 2022 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "VisualNovelTextboxEvent.hpp" using namespace Dawn; VisualNovelTextboxEvent::VisualNovelTextboxEvent( VisualNovelManager *manager, VisualNovelCharacter *character, struct VisualNovelCharacterEmotion emotion, std::string languageKey ) : IVisualNovelEvent(manager) { this->character = character; this->languageKey = languageKey; this->emotion = emotion; } VisualNovelTextboxEvent::VisualNovelTextboxEvent( VisualNovelManager *manager, std::string languageKey ) : IVisualNovelEvent(manager) { this->character = nullptr; this->languageKey = languageKey; } void VisualNovelTextboxEvent::onStart(IVisualNovelEvent *previous) { if(this->manager->textBox == nullptr) return; this->manager->textBox->setText(this->languageKey); this->manager->textBox->setCharacter(this->character); if(this->character != nullptr) { this->character->tiledSprite->setTile(this->emotion.tile); } if(this->emotion.emotionSound != nullptr) { if(this->manager->audioCharacter != nullptr) { this->manager->audioCharacter->stop(); this->manager->audioCharacter->loop = false; this->manager->audioCharacter->setAudioData(this->emotion.emotionSound); this->manager->audioCharacter->play(); } } else if(this->emotion.talkSound != nullptr) { this->manager->textBox->setTalkingSound(this->emotion.talkSound); } this->manager->textBox->show(); } bool_t VisualNovelTextboxEvent::onUpdate() { return this->manager->textBox->isVisible(); } void VisualNovelTextboxEvent::onEnd() { }