CatDog: Enhance the speech bubble artificial intelligence

Enable cat dog to greet you, and help you with yak shave sessions.
This commit is contained in:
Brian Gianforcaro 2021-06-07 02:21:42 -07:00 committed by Andreas Kling
parent c3a60a5dcd
commit 06ea31d0d5
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00

View file

@ -5,9 +5,18 @@
*/
#include "SpeechBubble.h"
#include <AK/Array.h>
#include <AK/Random.h>
#include <AK/StringView.h>
#include <LibGUI/Painter.h>
#include <LibGfx/Palette.h>
static Array<StringView, 3> messages = {
"It looks like you're trying to debug\na program. Would you like some help?"sv,
"It looks like you're trying to shave\na yak. Would you like some help?"sv,
"Well Hello Friend!"sv,
};
void SpeechBubble::paint_event(GUI::PaintEvent&)
{
GUI::Painter painter(*this);
@ -28,7 +37,8 @@ void SpeechBubble::paint_event(GUI::PaintEvent&)
painter.draw_line(connector_top_left, Gfx::IntPoint { connector_bottom.x() - 1, connector_bottom.y() }, palette().active_window_border1());
painter.draw_line(connector_top_right, connector_bottom, palette().active_window_border1());
painter.draw_text(text_area, "It looks like you're trying to debug\na program. Would you like some help?", Gfx::TextAlignment::Center);
auto message = messages[get_random<u8>() % messages.size()];
painter.draw_text(text_area, message, Gfx::TextAlignment::Center);
}
void SpeechBubble::mousedown_event(GUI::MouseEvent& event)