summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-24 14:26:15 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-24 14:28:39 +0300
commit1cd50987bce69ada9ccea8c822ccd0ffb34cedde (patch)
tree58858017e679e053905775ef5cad3a711851edea /src
parentb7bb27910303ef1538e2cbb4093e452c77567739 (diff)
downloadmv-1cd50987bce69ada9ccea8c822ccd0ffb34cedde.tar.gz
mv-1cd50987bce69ada9ccea8c822ccd0ffb34cedde.tar.bz2
mv-1cd50987bce69ada9ccea8c822ccd0ffb34cedde.tar.xz
mv-1cd50987bce69ada9ccea8c822ccd0ffb34cedde.zip
Add partial support for cart window.
Diffstat (limited to 'src')
-rw-r--r--src/actions/windows.cpp9
-rw-r--r--src/actions/windows.h1
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/game.cpp1
-rw-r--r--src/gui/windows/inventorywindow.cpp213
-rw-r--r--src/gui/windows/inventorywindow.h1
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h5
8 files changed, 153 insertions, 79 deletions
diff --git a/src/actions/windows.cpp b/src/actions/windows.cpp
index 1fe359402..9a7743590 100644
--- a/src/actions/windows.cpp
+++ b/src/actions/windows.cpp
@@ -275,6 +275,15 @@ impHandler0(bankWindowShow)
return true;
}
+impHandler0(cartWindowShow)
+{
+ if (!serverFeatures->haveCart())
+ return false;
+
+ showHideWindow(cartWindow);
+ return true;
+}
+
impHandler0(updaterWindowShow)
{
if (updaterWindow)
diff --git a/src/actions/windows.h b/src/actions/windows.h
index e418028ce..e3a4120cf 100644
--- a/src/actions/windows.h
+++ b/src/actions/windows.h
@@ -52,6 +52,7 @@ namespace Actions
decHandler(questsWindowShow);
decHandler(updaterWindowShow);
decHandler(bankWindowShow);
+ decHandler(cartWindowShow);
} // namespace Actions
#undef decHandler
diff --git a/src/defaults.cpp b/src/defaults.cpp
index b0349954c..5e0b2d031 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -361,6 +361,7 @@ DefaultsData* getConfigDefaults()
AddDEF("protectedItems", "");
AddDEF("inventorySortOrder", 0);
AddDEF("storageSortOrder", 0);
+ AddDEF("cartSortOrder", 0);
AddDEF("buySortOrder", 0);
AddDEF("showmotd", false);
AddDEF("playMapAnimations", true);
diff --git a/src/game.cpp b/src/game.cpp
index f17c4ae65..6d14184b8 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -319,6 +319,7 @@ static void destroyGuiWindows()
delete2(statusWindow)
delete2(miniStatusWindow)
delete2(inventoryWindow)
+ delete2(cartWindow)
delete2(shopWindow)
delete2(skillDialog)
delete2(minimap)
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index e0dd2e8f0..944c35f24 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -89,6 +89,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
mSplitButton(nullptr),
mOutfitButton(nullptr),
mShopButton(nullptr),
+ mCartButton(nullptr),
mEquipmentButton(nullptr),
mStoreButton(nullptr),
mRetrieveButton(nullptr),
@@ -117,7 +118,6 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
switch (inventory->getType())
{
case Inventory::INVENTORY:
- case Inventory::CART:
case Inventory::TRADE:
case Inventory::NPC:
default:
@@ -128,6 +128,10 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
mSortDropDown->setSelected(config.getIntValue(
"storageSortOrder"));
break;
+ case Inventory::CART:
+ mSortDropDown->setSelected(config.getIntValue(
+ "cartSortOrder"));
+ break;
};
}
else
@@ -170,78 +174,114 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
for (size_t f = 0; f < sz; f ++)
mFilter->addButton(tags[f], tags[f], false);
- if (isMainInventory())
+ switch (mInventory->getType())
{
- // TRANSLATORS: inventory button
- const std::string equip = _("Equip");
- // TRANSLATORS: inventory button
- const std::string use = _("Use");
- // TRANSLATORS: inventory button
- const std::string unequip = _("Unequip");
-
- std::string longestUseString = getFont()->getWidth(equip) >
- getFont()->getWidth(use) ? equip : use;
-
- if (getFont()->getWidth(longestUseString) <
- getFont()->getWidth(unequip))
+ case Inventory::INVENTORY:
{
- longestUseString = unequip;
- }
+ // TRANSLATORS: inventory button
+ const std::string equip = _("Equip");
+ // TRANSLATORS: inventory button
+ const std::string use = _("Use");
+ // TRANSLATORS: inventory button
+ const std::string unequip = _("Unequip");
- mUseButton = new Button(this, longestUseString, "use", this);
- // TRANSLATORS: inventory button
- mDropButton = new Button(this, _("Drop..."), "drop", this);
- // TRANSLATORS: inventory button
- mSplitButton = new Button(this, _("Split"), "split", this);
- // TRANSLATORS: inventory outfits button
- mOutfitButton = new Button(this, _("O"), "outfit", this);
- // TRANSLATORS: inventory shop button
- mShopButton = new Button(this, _("S"), "shop", this);
- // TRANSLATORS: inventory equipment button
- mEquipmentButton = new Button(this, _("E"), "equipment", this);
- mWeightBar = new ProgressBar(this, 0.0F, 100, 0, Theme::PROG_WEIGHT,
- "weightprogressbar.xml", "weightprogressbar_fill.xml");
- mWeightBar->setColor(getThemeColor(Theme::WEIGHT_BAR),
- getThemeColor(Theme::WEIGHT_BAR_OUTLINE));
-
- place(0, 0, mWeightBar, 4);
- mSlotsBarCell = &place(4, 0, mSlotsBar, 4);
- mSortDropDownCell = &place(8, 0, mSortDropDown, 3);
-
- mFilterCell = &place(0, 1, mFilter, 10).setPadding(3);
- mNameFilterCell = &place(8, 1, mNameFilter, 3);
-
- place(0, 2, invenScroll, 11).setPadding(3);
- place(0, 3, mUseButton);
- place(1, 3, mDropButton);
- place(8, 2, mSplitButton);
- ContainerPlacer placer = getPlacer(10, 3);
- placer(0, 0, mShopButton);
- placer(1, 0, mOutfitButton);
- placer(2, 0, mEquipmentButton);
+ std::string longestUseString = getFont()->getWidth(equip) >
+ getFont()->getWidth(use) ? equip : use;
- updateWeight();
- }
- else
- {
- // TRANSLATORS: storage button
- mStoreButton = new Button(this, _("Store"), "store", this);
- // TRANSLATORS: storage button
- mRetrieveButton = new Button(this, _("Retrieve"), "retrieve", this);
- // TRANSLATORS: storage button
- mInvCloseButton = new Button(this, _("Close"), "close", this);
+ if (getFont()->getWidth(longestUseString) <
+ getFont()->getWidth(unequip))
+ {
+ longestUseString = unequip;
+ }
+
+ mUseButton = new Button(this, longestUseString, "use", this);
+ // TRANSLATORS: inventory button
+ mDropButton = new Button(this, _("Drop..."), "drop", this);
+ // TRANSLATORS: inventory button
+ mSplitButton = new Button(this, _("Split"), "split", this);
+ // TRANSLATORS: inventory outfits button
+ mOutfitButton = new Button(this, _("O"), "outfit", this);
+ // TRANSLATORS: inventory cart button
+ mCartButton = new Button(this, _("C"), "cart", this);
+ // TRANSLATORS: inventory shop button
+ mShopButton = new Button(this, _("S"), "shop", this);
+ // TRANSLATORS: inventory equipment button
+ mEquipmentButton = new Button(this, _("E"), "equipment", this);
+ mWeightBar = new ProgressBar(this, 0.0F, 100, 0, Theme::PROG_WEIGHT,
+ "weightprogressbar.xml", "weightprogressbar_fill.xml");
+ mWeightBar->setColor(getThemeColor(Theme::WEIGHT_BAR),
+ getThemeColor(Theme::WEIGHT_BAR_OUTLINE));
+
+ place(0, 0, mWeightBar, 4);
+ mSlotsBarCell = &place(4, 0, mSlotsBar, 4);
+ mSortDropDownCell = &place(8, 0, mSortDropDown, 3);
+
+ mFilterCell = &place(0, 1, mFilter, 10).setPadding(3);
+ mNameFilterCell = &place(8, 1, mNameFilter, 3);
+
+ place(0, 2, invenScroll, 11).setPadding(3);
+ place(0, 3, mUseButton);
+ place(1, 3, mDropButton);
+ place(8, 2, mSplitButton);
+ ContainerPlacer placer = getPlacer(10, 3);
+ placer(0, 0, mShopButton);
+ placer(1, 0, mOutfitButton);
+ placer(2, 0, mCartButton);
+ placer(3, 0, mEquipmentButton);
+
+ updateWeight();
+ break;
+ }
- mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
- mSortDropDownCell = &place(6, 0, mSortDropDown, 1);
+ case Inventory::STORAGE:
+ {
+ // TRANSLATORS: storage button
+ mStoreButton = new Button(this, _("Store"), "store", this);
+ // TRANSLATORS: storage button
+ mRetrieveButton = new Button(this, _("Retrieve"), "retrieve", this);
+ // TRANSLATORS: storage button
+ mInvCloseButton = new Button(this, _("Close"), "close", this);
+
+ mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
+ mSortDropDownCell = &place(6, 0, mSortDropDown, 1);
+
+ mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
+ mNameFilterCell = &place(6, 1, mNameFilter, 1);
+
+ place(0, 2, invenScroll, 7, 4);
+ place(0, 6, mStoreButton);
+ place(1, 6, mRetrieveButton);
+ place(6, 6, mInvCloseButton);
+ break;
+ }
- mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
- mNameFilterCell = &place(6, 1, mNameFilter, 1);
+ case Inventory::CART:
+ {
+ // TRANSLATORS: storage button
+ mStoreButton = new Button(this, _("Store"), "store", this);
+ // TRANSLATORS: storage button
+ mRetrieveButton = new Button(this, _("Retrieve"), "retrieve", this);
+ // TRANSLATORS: storage button
+ mInvCloseButton = new Button(this, _("Close"), "close", this);
+
+ mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
+ mSortDropDownCell = &place(6, 0, mSortDropDown, 1);
+
+ mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
+ mNameFilterCell = &place(6, 1, mNameFilter, 1);
+
+ place(0, 2, invenScroll, 7, 4);
+ place(0, 6, mStoreButton);
+ place(1, 6, mRetrieveButton);
+ place(6, 6, mInvCloseButton);
+ break;
+ }
- place(0, 2, invenScroll, 7, 4);
- place(0, 6, mStoreButton);
- place(1, 6, mRetrieveButton);
- place(6, 6, mInvCloseButton);
- }
+ default:
+ case Inventory::TRADE:
+ case Inventory::NPC:
+ break;
+ };
Layout &layout = getLayout();
layout.setRowHeight(2, LayoutType::SET);
@@ -270,7 +310,7 @@ void InventoryWindow::postInit()
mItems->setSortType(mSortDropDown->getSelected());
widgetResized(Event(nullptr));
- if (!isMainInventory())
+ if (mInventory->getType() == Inventory::INVENTORY)
setVisible(true);
}
@@ -293,7 +333,6 @@ void InventoryWindow::storeSortOrder() const
switch (mInventory->getType())
{
case Inventory::INVENTORY:
- case Inventory::CART:
case Inventory::TRADE:
case Inventory::NPC:
default:
@@ -304,6 +343,10 @@ void InventoryWindow::storeSortOrder() const
config.setValue("storageSortOrder",
mSortDropDown->getSelected());
break;
+ case Inventory::CART:
+ config.setValue("cartSortOrder",
+ mSortDropDown->getSelected());
+ break;
};
}
}
@@ -323,6 +366,10 @@ void InventoryWindow::action(const ActionEvent &event)
{
inputManager.executeAction(InputAction::WINDOW_EQUIPMENT);
}
+ else if (eventId == "cart")
+ {
+ inputManager.executeAction(InputAction::WINDOW_CART);
+ }
else if (eventId == "close")
{
close();
@@ -662,18 +709,26 @@ void InventoryWindow::setSplitAllowed(const bool allowed)
void InventoryWindow::close()
{
- if (this == inventoryWindow)
- {
- setVisible(false);
- }
- else
+ switch (mInventory->getType())
{
- if (inventoryHandler)
- {
- inventoryHandler->closeStorage(Inventory::STORAGE);
- inventoryHandler->forgotStorage();
- }
- scheduleDelete();
+ case Inventory::INVENTORY:
+ case Inventory::CART:
+ setVisible(false);
+ break;
+
+ case Inventory::STORAGE:
+ if (inventoryHandler)
+ {
+ inventoryHandler->closeStorage(Inventory::STORAGE);
+ inventoryHandler->forgotStorage();
+ }
+ scheduleDelete();
+ break;
+
+ default:
+ case Inventory::TRADE:
+ case Inventory::NPC:
+ break;
}
}
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index aba6937a4..228f140bf 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -179,6 +179,7 @@ class InventoryWindow final : public Window,
Button *mSplitButton;
Button *mOutfitButton;
Button *mShopButton;
+ Button *mCartButton;
Button *mEquipmentButton;
Button *mStoreButton;
Button *mRetrieveButton;
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index 63f351706..9bc25f49d 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -535,6 +535,7 @@ namespace InputAction
CHAT_PARTY_TAB,
CHAT_GUILD_TAB,
DROP_CLEAR,
+ WINDOW_CART,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 23d4e6c06..013efa81f 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -3969,6 +3969,11 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputCondition::INGAME,
"cleardrops|cleardrop|cleardropwindow|dropclear|dropsclear",
false},
+ {"keyWindowCart",
+ defaultAction(&Actions::cartWindowShow),
+ InputCondition::SHORTCUT0,
+ "cart|opencart",
+ false},
};
#undef defaultAction