From: Daniel Karbach Date: Tue, 4 Dec 2012 21:44:35 +0000 (+0100) Subject: made third column hack of menus configurable X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=ec25171b0b27999eb126e2144dae1e35f271b945;p=l2e.git made third column hack of menus configurable --- diff --git a/src/graphics/Menu.cpp b/src/graphics/Menu.cpp index 6527e3e..1b81f85 100644 --- a/src/graphics/Menu.cpp +++ b/src/graphics/Menu.cpp @@ -32,6 +32,7 @@ void MenuProperties::CreateTypeDescription() { td.AddField("additionalTextGap", FieldDescription(((char *)&p.additionalTextGap) - ((char *)&p), Interpreter::NUMBER_ID).SetDescription("space between normal and additional text in pixels")); td.AddField("wrapX", FieldDescription(((char *)&p.wrapX) - ((char *)&p), Interpreter::BOOLEAN_ID).SetDescription("horizontally wrap cursor movement")); td.AddField("wrapY", FieldDescription(((char *)&p.wrapY) - ((char *)&p), Interpreter::BOOLEAN_ID).SetDescription("vertically wrap cursor movement")); + td.AddField("thirdColumnHack", FieldDescription(((char *)&p.thirdColumnHack) - ((char *)&p), Interpreter::NUMBER_ID).SetDescription("offset the third column by this many characters")); } void MenuProperties::Construct(void *data) { diff --git a/src/graphics/Menu.h b/src/graphics/Menu.h index 886e2fd..d83b2a5 100644 --- a/src/graphics/Menu.h +++ b/src/graphics/Menu.h @@ -28,6 +28,7 @@ struct MenuProperties { int charsPerNumber; int charsPerAdditionalText; int additionalTextGap; + int thirdColumnHack; char delimiter; bool wrapX; bool wrapY; @@ -37,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(); @@ -241,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) { @@ -273,10 +273,9 @@ void Menu::Draw(SDL_Surface *dest, const geometry::Vector &position) con geometry::Vector cursorOffset( (selected % cols) * (ColWidth() + colGap) - cursor->Width(), ((selected - start) / cols) * RowHeight()); - // Third column hack! - // This fixes the position of the "DROP" item in the inventory menu. - if (selected % cols == 2) { - cursorOffset += geometry::Vector(font->CharWidth(), 0); + // 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: diff --git a/test-data/test.l2s b/test-data/test.l2s index 98553df..0d76b42 100644 --- a/test-data/test.l2s +++ b/test-data/test.l2s @@ -769,7 +769,8 @@ export MenuResources menuResources { disabledFont: menuInactiveFont, iconSpace: 16, charsPerNumber: 2, - delimiter: ":" + delimiter: ":", + thirdColumnHack: 1 }, spellMenu: MenuProperties { cols: 2,