+ if (!entries[start + i].title) continue;
+ math::Vector<int> iconOffset(
+ (i % cols) * (ColWidth() + colGap),
+ (i / cols) * RowHeight());
+
+ // This fixes the position of the third column of the inventory and capsule menus.
+ if (thirdColumnHack && i % cols == 2) {
+ iconOffset += math::Vector<int>(font->CharWidth() * thirdColumnHack, 0);
+ }
+
+ if (entries[start + i].icon) {
+ entries[start + i].icon->Draw(dest, position + iconOffset);
+ }
+ math::Vector<int> textOffset(iconOffset.X() + iconSpace, iconOffset.Y());
+ const Font *usedFont(entries[start + i].enabled ? font : disabledFont);
+ usedFont->DrawString(entries[start + i].title, dest, position + textOffset, charsPerEntry);
+
+ textOffset += math::Vector<int>(charsPerEntry * usedFont->CharWidth(), 0);
+
+ if (charsPerAdditionalText) {
+ textOffset += math::Vector<int>(additionalTextGap, 0);
+ if (entries[start + i].additionalText) {
+ usedFont->DrawString(entries[start + i].additionalText, dest, position + textOffset, charsPerAdditionalText);
+ }
+ textOffset += math::Vector<int>(charsPerAdditionalText * usedFont->CharWidth(), 0);
+ }
+
+ if (charsPerNumber) {
+ usedFont->DrawChar(delimiter, dest, position + textOffset);
+ textOffset += math::Vector<int>(usedFont->CharWidth(), 0);
+ usedFont->DrawNumber(entries[start + i].number, dest, position + textOffset, charsPerNumber);
+ }
+ }
+ math::Vector<int> cursorOffset(
+ (selected % cols) * (ColWidth() + colGap) - cursor->Width(),
+ ((selected - start) / cols) * RowHeight());
+ // This fixes the position of the third column of the inventory and capsule menus.
+ if (thirdColumnHack && selected % cols == 2) {
+ cursorOffset += math::Vector<int>(font->CharWidth() * thirdColumnHack, 0);
+ }
+ switch (state) {
+ case STATE_INACTIVE:
+ break;
+ case STATE_ACTIVE:
+ DrawCursor(dest, position + cursorOffset);
+ break;
+ case STATE_SELECTED:
+ DrawSelectedCursor(dest, position + cursorOffset);
+ break;
+ case STATE_DUAL:
+ DrawCursor(dest, position + cursorOffset
+ - math::Vector<int>(selectedCursor->Width(), 0));
+ if (secondarySelection >= start && secondarySelection <= end) {
+ math::Vector<int> secondaryOffset(
+ (secondarySelection % cols) * (ColWidth() + colGap) - cursor->Width(),
+ ((secondarySelection - start) / cols) * RowHeight());
+ DrawSelectedCursor(dest, position + secondaryOffset);
+ }
+ break;
+ }
+}
+
+template<class T>
+void Menu<T>::DrawCursor(
+ SDL_Surface *dest,
+ const math::Vector<int> &position) const {
+ if (animation.Running()) {
+ animation.Draw(dest, position);
+ } else {
+ cursor->Draw(dest, position);
+ }
+}
+
+template<class T>
+void Menu<T>::DrawSelectedCursor(
+ SDL_Surface *dest,
+ const math::Vector<int> &position) const {
+ if (selectedAnimation.Running()) {
+ selectedAnimation.Draw(dest, position);
+ } else {
+ selectedCursor->Draw(dest, position);