summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-15 00:14:39 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-15 00:14:39 +0300
commitc2f007b58743491dc9250f09137ad847043b840d (patch)
tree472ce728623054a7b58141c16118e53a2837759b
parentc7f54151ba693e7f57378b77cc567d5aa26cf4cf (diff)
downloadmanaplus-c2f007b58743491dc9250f09137ad847043b840d.tar.gz
manaplus-c2f007b58743491dc9250f09137ad847043b840d.tar.bz2
manaplus-c2f007b58743491dc9250f09137ad847043b840d.tar.xz
manaplus-c2f007b58743491dc9250f09137ad847043b840d.zip
eathena: impliment packet SMSG_BUYINGSTORE_OWN_ITEMS.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/windows/shopwindow.cpp11
-rw-r--r--src/gui/windows/shopwindow.h5
-rw-r--r--src/listeners/buyingstoremodelistener.cpp36
-rw-r--r--src/listeners/buyingstoremodelistener.h38
-rw-r--r--src/net/eathena/buyingstorehandler.cpp4
7 files changed, 98 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1820c1412..10384a26b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -822,6 +822,8 @@ SET(SRCS
listeners/banklistener.cpp
listeners/banklistener.h
listeners/baselistener.hpp
+ listeners/buyingstoremodelistener.cpp
+ listeners/buyingstoremodelistener.h
listeners/buyingstoreslotslistener.cpp
listeners/buyingstoreslotslistener.h
listeners/charrenamelistener.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 993ee575f..b14c4f99e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -951,6 +951,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
listeners/banklistener.cpp \
listeners/banklistener.h \
listeners/baselistener.hpp \
+ listeners/buyingstoremodelistener.cpp \
+ listeners/buyingstoremodelistener.h \
listeners/buyingstoreslotslistener.cpp \
listeners/buyingstoreslotslistener.h \
listeners/charrenamelistener.cpp \
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 6490ff746..bed828f0a 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -88,6 +88,7 @@ ShopWindow::ShopWindow() :
SelectionListener(),
VendingModeListener(),
VendingSlotsListener(),
+ BuyingStoreModeListener(),
BuyingStoreSlotsListener(),
// TRANSLATORS: shop window button
mCloseButton(new Button(this, _("Close"), "close", this)),
@@ -121,6 +122,7 @@ ShopWindow::ShopWindow() :
mBuyShopSize(0),
isBuySelected(true),
mHaveVending(serverFeatures->haveVending()),
+ mEnableBuyingStore(false),
mEnableVending(false)
{
mBuyShopItemList->postInit();
@@ -1063,3 +1065,12 @@ void ShopWindow::buyingStoreSlotsChanged(const int slots)
mBuyShopSize = slots;
updateButtonsAndLabels();
}
+
+void ShopWindow::buyingStoreEnabled(const bool b)
+{
+ mEnableBuyingStore = b;
+ localPlayer->enableShop(b);
+ if (!b)
+ mBuyShopSize = 0;
+ updateButtonsAndLabels();
+}
diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h
index e3398d093..313d3b4fb 100644
--- a/src/gui/windows/shopwindow.h
+++ b/src/gui/windows/shopwindow.h
@@ -26,6 +26,7 @@
#include "gui/widgets/window.h"
#include "listeners/actionlistener.h"
+#include "listeners/buyingstoremodelistener.h"
#include "listeners/buyingstoreslotslistener.h"
#include "listeners/selectionlistener.h"
#include "listeners/vendingmodelistener.h"
@@ -50,6 +51,7 @@ class ShopWindow final : public Window,
public SelectionListener,
public VendingModeListener,
public VendingSlotsListener,
+ public BuyingStoreModeListener,
public BuyingStoreSlotsListener
{
public:
@@ -149,6 +151,8 @@ class ShopWindow final : public Window,
void vendingEnabled(const bool b) override final;
+ void buyingStoreEnabled(const bool b) override final;
+
void setShopName(const std::string &name);
private:
@@ -191,6 +195,7 @@ class ShopWindow final : public Window,
int mBuyShopSize;
bool isBuySelected;
bool mHaveVending;
+ bool mEnableBuyingStore;
bool mEnableVending;
};
diff --git a/src/listeners/buyingstoremodelistener.cpp b/src/listeners/buyingstoremodelistener.cpp
new file mode 100644
index 000000000..217c19813
--- /dev/null
+++ b/src/listeners/buyingstoremodelistener.cpp
@@ -0,0 +1,36 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2014-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "listeners/buyingstoremodelistener.h"
+
+#include "debug.h"
+
+defineListener(BuyingStoreModeListener)
+
+void BuyingStoreModeListener::distributeEvent(const bool b)
+{
+ FOR_EACH (std::vector<BuyingStoreModeListener*>::iterator,
+ it, mListeners)
+ {
+ BuyingStoreModeListener *const listener = *it;
+ if (listener)
+ listener->buyingStoreEnabled(b);
+ }
+}
diff --git a/src/listeners/buyingstoremodelistener.h b/src/listeners/buyingstoremodelistener.h
new file mode 100644
index 000000000..36d402d59
--- /dev/null
+++ b/src/listeners/buyingstoremodelistener.h
@@ -0,0 +1,38 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2014-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LISTENERS_BUYINGSTOREMODELISTENER_H
+#define LISTENERS_BUYINGSTOREMODELISTENER_H
+
+#include "listeners/baselistener.hpp"
+
+#include "localconsts.h"
+
+class BuyingStoreModeListener notfinal
+{
+ public:
+ virtual void buyingStoreEnabled(const bool b) = 0;
+
+ static void distributeEvent(const bool b);
+
+ defineListenerHeader(BuyingStoreModeListener)
+};
+
+#endif // LISTENERS_BUYINGSTOREMODELISTENER_H
diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp
index 8781a13ee..e0cd402a7 100644
--- a/src/net/eathena/buyingstorehandler.cpp
+++ b/src/net/eathena/buyingstorehandler.cpp
@@ -24,7 +24,9 @@
#include "shopitem.h"
#include "being/being.h"
+#include "being/playerinfo.h"
+#include "listeners/buyingstoremodelistener.h"
#include "listeners/buyingstoreslotslistener.h"
#include "net/ea/eaprotocol.h"
@@ -149,6 +151,8 @@ void BuyingStoreHandler::processBuyingStoreOwnItems(Net::MessageIn &msg)
msg.readUInt8("item type");
msg.readInt16("item id");
}
+ PlayerInfo::enableVending(true);
+ BuyingStoreModeListener::distributeEvent(true);
}
void BuyingStoreHandler::processBuyingStoreShowBoard(Net::MessageIn &msg)