X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FMenu.h;h=d83b2a5e9b540801b88128b77f4d41002bc36521;hb=ec25171b0b27999eb126e2144dae1e35f271b945;hp=b29e9687cc58bd7019bc9f879bea14c9e3b24340;hpb=ea2353f282a48a4474b32a1ab604eaf1aeff4e2b;p=l2e.git diff --git a/src/graphics/Menu.h b/src/graphics/Menu.h index b29e968..d83b2a5 100644 --- a/src/graphics/Menu.h +++ b/src/graphics/Menu.h @@ -1,10 +1,3 @@ -/* - * Menu.h - * - * Created on: Aug 8, 2012 - * Author: holy - */ - #ifndef GRAPHICS_MENU_H_ #define GRAPHICS_MENU_H_ @@ -35,6 +28,7 @@ struct MenuProperties { int charsPerNumber; int charsPerAdditionalText; int additionalTextGap; + int thirdColumnHack; char delimiter; bool wrapX; bool wrapY; @@ -44,7 +38,7 @@ struct MenuProperties { , charsPerEntry(0), rows(1), rowGap(0) , iconSpace(0), cols(1), colGap(0) , charsPerNumber(0), charsPerAdditionalText(0) - , additionalTextGap(0), delimiter(':') + , additionalTextGap(0), thirdColumnHack(0), delimiter(':') , wrapX(false), wrapY(false) { } static void CreateTypeDescription(); @@ -109,6 +103,7 @@ public: void Enable(int index) { entries[index].enabled = true; } void Reserve(int n) { entries.reserve(n); } void Clear() { entries.clear(); } + void ClearEntry(int at) { entries[at] = Entry(0, T(), false); } void Draw(SDL_Surface *dest, const geometry::Vector &position) const; @@ -247,10 +242,9 @@ void Menu::Draw(SDL_Surface *dest, const geometry::Vector &position) con (i % cols) * (ColWidth() + colGap), (i / cols) * RowHeight()); - // Third column hack! - // This fixes the position of the "DROP" item in the inventory menu. - if (i % cols == 2) { - iconOffset += geometry::Vector(font->CharWidth(), 0); + // This fixes the position of the third column of the inventory and capsule menus. + if (thirdColumnHack && i % cols == 2) { + iconOffset += geometry::Vector(font->CharWidth() * thirdColumnHack, 0); } if (entries[start + i].icon) { @@ -279,6 +273,10 @@ void Menu::Draw(SDL_Surface *dest, const geometry::Vector &position) con geometry::Vector 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 += geometry::Vector(font->CharWidth() * thirdColumnHack, 0); + } switch (state) { case STATE_INACTIVE: break;