// reset the display void ClockMaster::resetDisplayTime(DateTime newTime, int currentXPos){ clearTextLine(secondXPos, secondYPos, secondSize, secondLength); writeSecond(newTime); clearTextLine(minuteXPos, minuteYPos, minuteSize, minuteLength); writeMinute(newTime); clearTextLine(hourXPos, hourYPos, hourSize, hourLength); writeHour(newTime); clearTextLine(dayXPos, dayYPos, daySize, dayLength); clearTextLine(weekdayXPos, weekdayYPos, weekdaySize, weekdayLength); writeDay(newTime); writeWeekDay(newTime); clearTextLine(monthXPos, monthYPos, monthSize, monthLength); writeMonth(newTime); clearTextLine(yearXPos, yearYPos, yearSize, yearLength); writeYear(newTime); clearTextLine(tempXPos, tempYPos, tempSize, tempLength); writeTemp(); // draw current x-position-indicator if(lastAlarmXPos != currentXPos){ // Center x-position-indicator under current number being changed clearTextLine(0, 85, 2, 160); if(currentXPos != -1){ int calculatedXPos = 45 * currentXPos + 30; tft.setCursor(calculatedXPos, 85); tft.print("-"); } } lastAlarmXPos = currentXPos; }
// Update the display void ClockMaster::updateDisplayTime(DateTime time_now){ clearTextLine(secondXPos, secondYPos, secondSize, secondLength); writeSecond(time_now); clearTextLine(tempXPos, tempYPos, tempSize, tempLength); writeTemp(); // If second is 0, change the minute aswell if (time_now.second() == 0) { clearTextLine(minuteXPos, minuteYPos, minuteSize, minuteLength); writeMinute(time_now); // If the second is 0 AND minute is 0, bump the hour up if (time_now.minute() == 0) { clearTextLine(hourXPos, hourYPos, hourSize, hourLength); writeHour(time_now); // If the second is 0 AND the minute is 0 AND the hour is 0, skip to next day if (time_now.hour() == 0) { clearTextLine(dayXPos, dayYPos, daySize, dayLength); clearTextLine(weekdayXPos, weekdayYPos, weekdaySize, weekdayLength); writeDay(time_now); writeWeekDay(time_now); // If the second is 0 AND the minute is 0 AND the hour is 0 AND the day is 1, skip to next day (preferebly friday at 6pm) if (time_now.day() == 1) { clearTextLine(monthXPos, monthYPos, monthSize, monthLength); writeMonth(time_now); // If the second is 0 AND the minute is 0 AND the hour is 0 AND the day is 1 AND the month is 1, skip to next year and RIDE YOUR HOVERBOARDS if (time_now.month() == 1) { clearTextLine(yearXPos, yearYPos, yearSize, yearLength); writeYear(time_now); } } } } } }
void CSTimeInterface::stopDragging() { CSTimeScene *scene = _vm->getCase()->getCurrScene(); CSTimeInventoryObject *invObj = _vm->getCase()->_inventoryObjs[_draggedItem]; Common::Point mousePos = _vm->_system->getEventManager()->getMousePos(); _state = kCSTimeInterfaceStateNormal; if (_sceneRect.contains(mousePos)) scene->setCursorForCurrentPoint(); else setCursorForCurrentPoint(); // Find the inventory object hotspot which is topmost for this drop, if any. uint16 foundInvObjHotspot = 0xffff; const Common::Array<CSTimeHotspot> &hotspots = scene->getHotspots(); for (uint i = 0; i < hotspots.size(); i++) { if (hotspots[i].state != 1) continue; if (!hotspots[i].region.containsPoint(mousePos)) continue; for (uint j = 0; j < invObj->hotspots.size(); j++) { if (invObj->hotspots[j].sceneId != scene->getId()) continue; if (invObj->hotspots[j].hotspotId != i) continue; if (foundInvObjHotspot != 0xffff && invObj->hotspots[foundInvObjHotspot].hotspotId < invObj->hotspots[j].hotspotId) continue; foundInvObjHotspot = j; } } // Work out if we're going to consume (nom-nom) the object after the drop. bool consumeObj = false; bool runConsumeEvents = false; if (foundInvObjHotspot != 0xffff) { CSTimeInventoryHotspot &hotspot = invObj->hotspots[foundInvObjHotspot]; clearTextLine(); for (uint i = 0; i < invObj->locations.size(); i++) { if (invObj->locations[i].sceneId != hotspot.sceneId) continue; if (invObj->locations[i].hotspotId != hotspot.hotspotId) continue; consumeObj = true; break; } if (_draggedItem == TIME_CUFFS_ID && !_inventoryDisplay->getCuffsState()) { consumeObj = false; // Nuh-uh, they're not activated yet. _vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, _vm->getCase()->getCurrScene()->getHelperId(), 9902)); } else { // FIXME: ding(); runConsumeEvents = true; } } // Deal with the actual drop. if (grabbedFromInventory()) { if (!consumeObj) { _vm->getView()->dragFeature((NewFeature *)invObj->feature, mousePos, 2, 0x800, NULL); // TODO: playSound(151); } else if (_draggedItem != TIME_CUFFS_ID) { _vm->getView()->dragFeature((NewFeature *)invObj->feature, mousePos, 2, 0x600, NULL); _vm->_haveInvItem[_draggedItem] = 0; invObj->feature = NULL; invObj->featureDisabled = true; _inventoryDisplay->removeItem(_draggedItem); } else if (!_inventoryDisplay->getCuffsState()) { // Inactive cuffs. // TODO: We never actually get here? Which would explain why it makes no sense. _vm->getView()->dragFeature((NewFeature *)invObj->feature, mousePos, 2, 0x800, NULL); invObj->feature = NULL; } else { // Active cuffs. _vm->getView()->dragFeature((NewFeature *)invObj->feature, mousePos, 2, 0x600, NULL); _vm->_haveInvItem[_draggedItem] = 0; invObj->feature = NULL; invObj->featureDisabled = true; } if (runConsumeEvents) { _vm->addEventList(invObj->hotspots[foundInvObjHotspot].events); } _inventoryDisplay->draw(); } else { uint32 dragFlags = 0x600; _vm->getView()->dragFeature((NewFeature *)invObj->feature, mousePos, 2, dragFlags, NULL); if (_inventoryDisplay->_invRect.contains(mousePos)) { // Dropped into the inventory. invObj->feature = NULL; if (invObj->canTake) { dropItemInInventory(_draggedItem); if (invObj->hotspotId) _vm->addEvent(CSTimeEvent(kCSTimeEventDisableHotspot, 0xffff, invObj->hotspotId)); } else { if (invObj->featureId) _vm->addEvent(CSTimeEvent(kCSTimeEventAddFeature, 0xffff, invObj->featureId)); } for (uint i = 0; i < invObj->hotspots.size(); i++) { if (invObj->hotspots[i].sceneId != scene->getId()) continue; if (invObj->hotspots[i].hotspotId != 0xffff) continue; _vm->addEventList(invObj->hotspots[i].events); } } else { // Dropped into the scene. CSTimeEvent event; event.param1 = 0xffff; if (consumeObj) { invObj->feature = NULL; invObj->featureDisabled = true; event.type = kCSTimeEventDisableHotspot; event.param2 = invObj->hotspotId; } else { invObj->feature = NULL; event.type = kCSTimeEventAddFeature; event.param2 = invObj->featureId; } _vm->addEvent(event); if (runConsumeEvents) { _vm->addEventList(invObj->hotspots[foundInvObjHotspot].events); } else { for (uint i = 0; i < invObj->hotspots.size(); i++) { if (invObj->hotspots[i].sceneId != scene->getId()) continue; if (invObj->hotspots[i].hotspotId != 0xfffe) continue; _vm->addEventList(invObj->hotspots[i].events); } } } } if (_vm->getCase()->getId() == 1 && _vm->getCase()->getCurrScene()->getId() == 4) { // Hardcoded behaviour for torches in the dark tomb, in the first case. if (_draggedItem == 1 && foundInvObjHotspot == 0xffff) { // Trying to drag an unlit torch around? _vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, 0, 16352)); } else if (_draggedItem == 2 && _vm->_caseVariable[2] == 1) { // This the first time we tried dragging the lit torch around. _vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, 0, 16354)); } } // TODO: Is this necessary? _draggedItem = 0xffff; }
void CSTimeInterface::mouseMove(Common::Point pos) { if (_options->getState()) { // TODO: _options->mouseMove(pos); return; } if (!cursorGetState()) return; if (_mouseWasInScene && _uiRect.contains(pos)) { clearTextLine(); _mouseWasInScene = false; } if (_book->getState() == 2) { // TODO: _book->mouseMove(pos); return; } if (_note->getState() == 2) return; // TODO: case 20 ui craziness is handled seperately.. if (_sceneRect.contains(pos) && !_vm->getCase()->getCurrScene()->eventIsActive()) { _vm->getCase()->getCurrScene()->mouseMove(pos); _mouseWasInScene = true; return; } if (cursorGetShape() == 13) { cursorSetShape(1); return; } else if (cursorGetShape() == 14) { cursorSetShape(4); return; } bool mouseIsDown = _vm->getEventManager()->getButtonState() & 1; if (_book->getState() == 1 && !_bookRect.contains(pos)) { if (_state != kCSTimeInterfaceStateDragging) { clearTextLine(); cursorSetShape(mouseIsDown ? 4 : 1); _book->setState(0); } return; } // TODO: case 20 ui craziness again if (_note->getState() == 1 && !_noteRect.contains(pos)) { if (_state != kCSTimeInterfaceStateDragging) { clearTextLine(); cursorSetShape(mouseIsDown ? 4 : 1); _note->setState(0); } return; } // TODO: handle symbols if (_bookRect.contains(pos)) { if (_state != kCSTimeInterfaceStateDragging) { displayTextLine("Open Chronopedia"); cursorSetShape(mouseIsDown ? 5 : 2); _book->setState(1); } return; } if (_noteRect.contains(pos)) { if (_state != kCSTimeInterfaceStateDragging && _note->havePiece(0xffff) && !_note->getState()) { displayTextLine("Look at Note"); cursorSetShape(mouseIsDown ? 5 : 2); _note->setState(1); } return; } if (_vm->getCase()->getCurrConversation()->getState() != (uint)~0) { _vm->getCase()->getCurrConversation()->mouseMove(pos); return; } if (_help->getState() != (uint)~0) { _help->mouseMove(pos); return; } if (_state == kCSTimeInterfaceStateDragging) { // FIXME: dragging return; } // FIXME: if case is 20, we're done, return if (_inventoryDisplay->_invRect.contains(pos)) { _inventoryDisplay->mouseMove(pos); } }