From ebb73f6dd78ecd616cbb56cf426d43cfcb3e3dd2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Oct 2012 01:37:05 +0300 Subject: Add new parameters to equipment window tehming. New parameters: itemPadding - ofset in pixels from left top corner or item box boxSize - slot item box size (by default 36 px) --- data/graphics/gui/CMakeLists.txt | 1 + data/graphics/gui/Makefile.am | 1 + data/graphics/gui/equipment.xml | 25 +++++++++++++++++++++++++ data/themes/enchilado/CMakeLists.txt | 1 + data/themes/enchilado/Makefile.am | 1 + data/themes/pink/CMakeLists.txt | 1 + data/themes/pink/Makefile.am | 1 + data/themes/unity/CMakeLists.txt | 1 + data/themes/unity/Makefile.am | 1 + data/themes/wood/CMakeLists.txt | 1 + data/themes/wood/Makefile.am | 1 + src/gui/equipmentwindow.cpp | 26 +++++++++++++------------- src/gui/equipmentwindow.h | 2 ++ 13 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 data/graphics/gui/equipment.xml diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt index c19714e94..2d1566b1a 100644 --- a/data/graphics/gui/CMakeLists.txt +++ b/data/graphics/gui/CMakeLists.txt @@ -17,6 +17,7 @@ SET (FILES dropdown_background.xml dropdown_pressed.xml emote_selection.xml + equipment.xml equipment_background.xml equipment_playerbox.xml equipmentbox.png diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am index 221418c71..5da480034 100644 --- a/data/graphics/gui/Makefile.am +++ b/data/graphics/gui/Makefile.am @@ -20,6 +20,7 @@ gui_DATA = \ dropdown_background.xml \ dropdown_pressed.xml \ emote_selection.xml \ + equipment.xml \ equipment_background.xml \ equipment_playerbox.xml \ equipmentbox.png \ diff --git a/data/graphics/gui/equipment.xml b/data/graphics/gui/equipment.xml new file mode 100644 index 000000000..f353e5a1e --- /dev/null +++ b/data/graphics/gui/equipment.xml @@ -0,0 +1,25 @@ + + + + diff --git a/data/themes/enchilado/CMakeLists.txt b/data/themes/enchilado/CMakeLists.txt index a008e8f86..f853912d8 100644 --- a/data/themes/enchilado/CMakeLists.txt +++ b/data/themes/enchilado/CMakeLists.txt @@ -1,6 +1,7 @@ SET (FILES buy.xml colors.xml + equipment.xml inventory.xml popup.xml progressbar.xml diff --git a/data/themes/enchilado/Makefile.am b/data/themes/enchilado/Makefile.am index 041c1aaf8..d3b517c9e 100644 --- a/data/themes/enchilado/Makefile.am +++ b/data/themes/enchilado/Makefile.am @@ -4,6 +4,7 @@ guidir = $(pkgdatadir)/data/themes/enchilado gui_DATA = \ buy.xml \ colors.xml \ + equipment.xml \ inventory.xml \ popup.xml \ progressbar.xml \ diff --git a/data/themes/pink/CMakeLists.txt b/data/themes/pink/CMakeLists.txt index 04e036ffa..a6353dbc4 100644 --- a/data/themes/pink/CMakeLists.txt +++ b/data/themes/pink/CMakeLists.txt @@ -2,6 +2,7 @@ SET (FILES bubble.png buy.xml colors.xml + equipment.xml inventory.xml popup.xml progress-indicator.png diff --git a/data/themes/pink/Makefile.am b/data/themes/pink/Makefile.am index 025b043bd..43c5982d0 100644 --- a/data/themes/pink/Makefile.am +++ b/data/themes/pink/Makefile.am @@ -5,6 +5,7 @@ gui_DATA = \ bubble.png \ buy.xml \ colors.xml \ + equipment.xml \ inventory.xml \ popup.xml \ progress-indicator.png \ diff --git a/data/themes/unity/CMakeLists.txt b/data/themes/unity/CMakeLists.txt index c54c64723..20545812c 100644 --- a/data/themes/unity/CMakeLists.txt +++ b/data/themes/unity/CMakeLists.txt @@ -2,6 +2,7 @@ SET (FILES buy.xml char.xml colors.xml + equipment.xml inventory.xml npc.xml popup.xml diff --git a/data/themes/unity/Makefile.am b/data/themes/unity/Makefile.am index 735028301..bed2b3c15 100644 --- a/data/themes/unity/Makefile.am +++ b/data/themes/unity/Makefile.am @@ -5,6 +5,7 @@ gui_DATA = \ buy.xml \ char.xml \ colors.xml \ + equipment.xml \ inventory.xml \ npc.xml \ popup.xml \ diff --git a/data/themes/wood/CMakeLists.txt b/data/themes/wood/CMakeLists.txt index c62b25d47..622c4dcd9 100644 --- a/data/themes/wood/CMakeLists.txt +++ b/data/themes/wood/CMakeLists.txt @@ -1,6 +1,7 @@ SET (FILES buy.xml colors.xml + equipment.xml inventory.xml item_shortcut_bgr.png mouse.png diff --git a/data/themes/wood/Makefile.am b/data/themes/wood/Makefile.am index 11af7c229..fc9518b16 100644 --- a/data/themes/wood/Makefile.am +++ b/data/themes/wood/Makefile.am @@ -4,6 +4,7 @@ guidir = $(pkgdatadir)/data/themes/wood gui_DATA = \ buy.xml \ colors.xml \ + equipment.xml \ inventory.xml \ item_shortcut_bgr.png \ mouse.png \ diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index b40a73afd..5b5c8d1d1 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -47,10 +47,6 @@ #include "debug.h" -static const int BOX_WIDTH = 36; -static const int BOX_HEIGHT = 36; -static const int BOX_X_PAD = (BOX_WIDTH - 32) / 2; -static const int BOX_Y_PAD = (BOX_HEIGHT - 32) / 2; static const int BOX_COUNT = 13; EquipmentWindow::EquipmentWindow(Equipment *const equipment, @@ -68,11 +64,16 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, mBeing(being), mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), mBorderColor(Theme::getThemeColor(Theme::BORDER)), - mLabelsColor(Theme::getThemeColor(Theme::LABEL)) + mLabelsColor(Theme::getThemeColor(Theme::LABEL)), + mItemPadding(getOption("itemPadding")), + mBoxSize(getOption("boxSize")) { if (setupWindow) setupWindow->registerWindowForReset(this); + if (!mBoxSize) + mBoxSize = 36; + // Control that shows the Player mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168)); mPlayerBox->setPlayer(being); @@ -176,20 +177,21 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) { image->setAlpha(1.0f); // Ensure the image is drawn // with maximum opacity - g->drawImage(image, box->x + 2, box->y + 2); + g->drawImage(image, box->x + mItemPadding, + box->y + mItemPadding); if (i == EQUIP_PROJECTILE_SLOT) { g->setColor(mLabelsColor); graphics->drawText(toString(item->getQuantity()), - box->x + (BOX_WIDTH / 2), box->y - fontHeight, + box->x + (mBoxSize / 2), box->y - fontHeight, gcn::Graphics::CENTER); } } } else if (box->image) { - g->drawImage(box->image, box->x + BOX_X_PAD, - box->y + BOX_Y_PAD); + g->drawImage(box->image, box->x + mItemPadding, + box->y + mItemPadding); } } } @@ -220,8 +222,7 @@ Item *EquipmentWindow::getItem(const int x, const int y) const const EquipmentBox *const box = *it; if (!box) continue; - const gcn::Rectangle tRect(box->x, box->y, - BOX_WIDTH, BOX_HEIGHT); + const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); if (tRect.isPointInRect(x, y)) return mEquipment->getEquipment(i); @@ -253,8 +254,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) if (!box) continue; const Item *const item = mEquipment->getEquipment(i); - const gcn::Rectangle tRect(box->x, box->y, - BOX_WIDTH, BOX_HEIGHT); + const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); if (tRect.isPointInRect(x, y) && item) setSelected(i); diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index 6a7158922..4d20a8447 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -142,6 +142,8 @@ class EquipmentWindow final : public Window, public gcn::ActionListener gcn::Color mLabelsColor; Image *mSlotBackground; Image *mSlotHighlightedBackground; + int mItemPadding; + int mBoxSize; }; extern EquipmentWindow *equipmentWindow; -- cgit v1.2.3-70-g09d2