52 lines
1.3 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "talk.h"
void _vnConversationTalkStart(queue_t *queue,queueaction_t *action,uint8_t i) {
vnconversationitemdata_t *data;
data = (vnconversationitemdata_t *)action->data;
printf("Speaking ");
printf(data->text);
printf("\n");
vnTextBoxSetText(&data->conversation->textbox, data->text);
if(data->character != NULL) {
data->character->talking = true;
}
}
void _vnConversationTalkUpdate(queue_t *queue,queueaction_t *action,uint8_t i) {
vnconversationitemdata_t *data;
data = (vnconversationitemdata_t *)action->data;
if(data->conversation->textbox.state & VN_TEXTBOX_STATE_CLOSED) {
printf("Spoke\n");
if(data->character != NULL) data->character->talking = false;
queueNext(queue);
}
}
queueaction_t * vnConversationTalk(
vnconversation_t *conversation,
char *text,
vncharacter_t *character
) {
queueaction_t *action;
vnconversationitemdata_t *data;
action = vnConversationAdd(conversation);
action->onStart = &_vnConversationTalkStart;
action->onUpdate = &_vnConversationTalkUpdate;
data = (vnconversationitemdata_t *)action->data;
data->text = text;
data->character = character;
return action;
}