| 59 | } |
| 60 | |
| 61 | void EquipmentPaperDoll::update() |
| 62 | { |
| 63 | // Only draw highlight if one of the colours isn't 100% transparent |
| 64 | if (slotHighlightColours[0].a != 0 || slotHighlightColours[1].a != 0) |
| 65 | { |
| 66 | this->slotHighlightCounter += slotHighlightIncrement; |
| 67 | while (this->slotHighlightCounter > 2.0f * M_PI) |
| 68 | { |
| 69 | this->slotHighlightCounter -= 2.0f * M_PI; |
| 70 | } |
| 71 | // Scale the sin curve from (-1, 1) to (0, 1) |
| 72 | float glowFactor = (sin(this->slotHighlightCounter) + 1.0f) / 2.0f; |
| 73 | |
| 74 | this->highlightColour.r = |
| 75 | mix(slotHighlightColours[0].r, slotHighlightColours[1].r, glowFactor); |
| 76 | this->highlightColour.g = |
| 77 | mix(slotHighlightColours[0].g, slotHighlightColours[1].g, glowFactor); |
| 78 | this->highlightColour.b = |
| 79 | mix(slotHighlightColours[0].b, slotHighlightColours[1].b, glowFactor); |
| 80 | this->highlightColour.a = |
| 81 | mix(slotHighlightColours[0].a, slotHighlightColours[1].a, glowFactor); |
| 82 | |
| 83 | this->setDirty(); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | static const EquipmentLayoutSlot *getSlotAtPosition(Vec2<int> pos, |
| 88 | const std::list<EquipmentLayoutSlot> &slots) |