Add a coffee break
Every so often a mug appears at the cat's nose, it sits down, dips its head in and takes a few slow sips while steam rises. M01, optional stop. The mug lives in its own click-through window like the chip, or inside the overlay on Wayland. It goes away as soon as the cat is petted, dragged, sent to sleep or moves on to something else, so no mug is ever left standing. Also renames OverlayWindow's mode flag, which shadowed QWindow::active. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f1df75a1d
commit
403ac30b3a
14 files changed
+283
-18
No files matched your search
@@ -95,6 +95,7 @@ void CatController::setPaused(bool paused)
|
||||
m_moodTimer.stop();
|
||||
m_chipTimer.stop();
|
||||
endChase();
|
||||
endCoffee();
|
||||
setMood(Mood::Sleeping);
|
||||
} else {
|
||||
pickNextMood();
|
||||
@@ -112,6 +113,7 @@ void CatController::setDragging(bool dragging)
|
||||
return;
|
||||
if (dragging) {
|
||||
m_moodTimer.stop();
|
||||
endCoffee();
|
||||
setMood(Mood::Alert);
|
||||
} else if (!m_paused) {
|
||||
holdMood(Mood::Sitting, 1500);
|
||||
@@ -132,6 +134,7 @@ void CatController::pet()
|
||||
return;
|
||||
m_settings->incrementPetCount();
|
||||
endChase();
|
||||
endCoffee();
|
||||
holdMood(Mood::Loving, 1800);
|
||||
}
|
||||
|
||||
@@ -140,7 +143,13 @@ void CatController::doTrick(Mood mood)
|
||||
if (m_paused)
|
||||
return;
|
||||
m_frozen = false;
|
||||
if (mood == Mood::Drinking) {
|
||||
coffeeBreak();
|
||||
return;
|
||||
}
|
||||
endChase();
|
||||
if (mood != Mood::Drinking)
|
||||
endCoffee();
|
||||
holdMood(mood, mood == Mood::Sleeping ? 15000 : 3500);
|
||||
}
|
||||
|
||||
@@ -155,6 +164,10 @@ void CatController::tossChip()
|
||||
{
|
||||
if (m_paused || m_frozen || m_chipVisible)
|
||||
return;
|
||||
if (m_cupVisible) { // finish the coffee first
|
||||
scheduleChip();
|
||||
return;
|
||||
}
|
||||
if (!m_settings->chipsEnabled()) {
|
||||
scheduleChip();
|
||||
return;
|
||||
@@ -173,6 +186,40 @@ void CatController::tossChip()
|
||||
setMood(Mood::Chasing);
|
||||
}
|
||||
|
||||
// A mug appears at the cat's nose, it sits down and takes its time.
|
||||
void CatController::coffeeBreak()
|
||||
{
|
||||
if (m_paused || m_frozen)
|
||||
return;
|
||||
|
||||
endChase();
|
||||
const qreal reach = m_catWidth * 1.08; // just past the whiskers
|
||||
const qreal edge = m_catWidth * 0.5;
|
||||
|
||||
// Put the mug on the side the cat faces, unless that runs off the screen.
|
||||
qreal wanted = m_facingRight ? m_x + reach : m_x + m_catWidth - reach;
|
||||
if (wanted < edge || wanted > m_stageWidth - edge) {
|
||||
setFacingRight(!m_facingRight);
|
||||
wanted = m_facingRight ? m_x + reach : m_x + m_catWidth - reach;
|
||||
}
|
||||
m_cupX = qBound(edge, wanted, m_stageWidth - edge);
|
||||
emit cupXChanged();
|
||||
|
||||
if (!m_cupVisible) {
|
||||
m_cupVisible = true;
|
||||
emit cupVisibleChanged();
|
||||
}
|
||||
holdMood(Mood::Drinking, QRandomGenerator::global()->bounded(7000, 12000));
|
||||
}
|
||||
|
||||
void CatController::endCoffee()
|
||||
{
|
||||
if (!m_cupVisible)
|
||||
return;
|
||||
m_cupVisible = false;
|
||||
emit cupVisibleChanged();
|
||||
}
|
||||
|
||||
void CatController::batChip()
|
||||
{
|
||||
auto *rng = QRandomGenerator::global();
|
||||
@@ -306,9 +353,15 @@ void CatController::pickNextMood()
|
||||
return;
|
||||
}
|
||||
|
||||
endCoffee();
|
||||
|
||||
auto *rng = QRandomGenerator::global();
|
||||
const int roll = rng->bounded(100);
|
||||
|
||||
if (roll < 8 && m_settings->coffeeEnabled()) {
|
||||
coffeeBreak();
|
||||
return;
|
||||
}
|
||||
if (roll < 45) {
|
||||
if (rng->bounded(100) < 20)
|
||||
setFacingRight(!m_facingRight);
|
||||
|
||||
Reference in new issue
Block a user