diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-02-05 17:46:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-02-05 20:56:16 +0300 |
commit | 12273c046fff6b2f778ef4c3cc0d8014d86233e5 (patch) | |
tree | e4dd0ca3b42c31883709dfcf0e85823e1f22479e | |
parent | 8db56130426f2c61e10219eddb67ee86bea82961 (diff) | |
download | manaverse-12273c046fff6b2f778ef4c3cc0d8014d86233e5.tar.gz manaverse-12273c046fff6b2f778ef4c3cc0d8014d86233e5.tar.bz2 manaverse-12273c046fff6b2f778ef4c3cc0d8014d86233e5.tar.xz manaverse-12273c046fff6b2f778ef4c3cc0d8014d86233e5.zip |
Impliment packet SMSG_NPC_CUTIN. Add support for cutins.
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/enums/cutin.h | 39 | ||||
-rw-r--r-- | src/game.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/window.h | 2 | ||||
-rw-r--r-- | src/gui/windows/cutinwindow.cpp | 143 | ||||
-rw-r--r-- | src/gui/windows/cutinwindow.h | 59 | ||||
-rw-r--r-- | src/net/eathena/npcrecv.cpp | 9 |
10 files changed, 260 insertions, 6 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c11074d71..6a5902882 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -351,6 +351,8 @@ SET(SRCS gui/windows/confirmdialog.h gui/windows/connectiondialog.cpp gui/windows/connectiondialog.h + gui/windows/cutinwindow.cpp + gui/windows/cutinwindow.h gui/windows/debugwindow.cpp gui/windows/debugwindow.h gui/windows/didyouknowwindow.cpp @@ -946,6 +948,7 @@ SET(SRCS guild.cpp guild.h enums/commandtarget.h + enums/cutin.h enums/dragdropsource.h enums/equipslot.h enums/guildpositionflags.h diff --git a/src/Makefile.am b/src/Makefile.am index 9c988d971..b6bc50334 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -129,7 +129,6 @@ SRC += events/actionevent.h \ enums/events/keyeventtype.h \ listeners/keylistener.h \ gui/models/listmodel.h \ - gui/models/magicschoolmodel.h \ events/mouseevent.h \ enums/events/mousebutton.h \ enums/events/mouseeventtype.h \ @@ -1362,6 +1361,7 @@ if ENABLE_TMWA manaplus_CXXFLAGS += -DTMWA_SUPPORT manaplus_SOURCES += \ enums/magicschool.h \ + gui/models/magicschoolmodel.h \ gui/widgets/tabs/chat/emulateguildtab.cpp \ gui/widgets/tabs/chat/emulateguildtab.h \ gui/windows/shopselldialog.cpp \ @@ -1493,6 +1493,8 @@ manaplus_SOURCES += gui/windows/bankwindow.cpp \ gui/windows/bankwindow.h \ gui/windows/buyingstoreselldialog.cpp \ gui/windows/buyingstoreselldialog.h \ + gui/windows/cutinwindow.cpp \ + gui/windows/cutinwindow.h \ gui/windows/eggselectiondialog.cpp \ gui/windows/eggselectiondialog.h \ gui/windows/insertcarddialog.cpp \ @@ -1503,6 +1505,7 @@ manaplus_SOURCES += gui/windows/bankwindow.cpp \ gui/windows/mailviewwindow.h \ gui/windows/mailwindow.cpp \ gui/windows/mailwindow.h \ + enums/cutin.h \ listeners/banklistener.cpp \ listeners/banklistener.h \ listeners/buyingstoremodelistener.cpp \ diff --git a/src/defaults.cpp b/src/defaults.cpp index 9b0874c4d..f8bf51394 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -628,6 +628,7 @@ DefaultsData* getPathsDefaults() AddDEF("shopbadge", "shop.xml"); AddDEF("inactivebadge", "inactive.xml"); AddDEF("awaybadge", "away.xml"); + AddDEF("cutInsDir", "graphics/cutins"); AddDEF("palettesDir", ""); AddDEF("defaultPaletteFile", "palette.gpl"); diff --git a/src/enums/cutin.h b/src/enums/cutin.h new file mode 100644 index 000000000..095832fe9 --- /dev/null +++ b/src/enums/cutin.h @@ -0,0 +1,39 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2016 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 ENUMS_CUTIN_H +#define ENUMS_CUTIN_H + +#ifdef EATHENA_SUPPORT + +#include "enums/simpletypes/enumdefines.h" + +enumStart(CutIn) +{ + BottomLeft = 0, + BottomCenter = 1, + BottomRight = 2, + Movable = 3, + MovableClose = 4 +} +enumEnd(CutIn); + +#endif // EATHENA_SUPPORT +#endif // ENUMS_CUTIN_H diff --git a/src/game.cpp b/src/game.cpp index 1a4f5c7a8..ef60b67c9 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -66,6 +66,7 @@ #ifdef EATHENA_SUPPORT #include "gui/windows/bankwindow.h" +#include "gui/windows/cutinwindow.h" #include "gui/windows/mailwindow.h" #endif #include "gui/windows/chatwindow.h" @@ -212,6 +213,7 @@ static void createGuiWindows() CREATEWIDGETV(cartWindow, InventoryWindow, PlayerInfo::getCartInventory()); } + CREATEWIDGETV0(cutInWindow, CutInWindow); #endif CREATEWIDGETV0(shopWindow, ShopWindow); CREATEWIDGETV0(skillDialog, SkillDialog); @@ -353,6 +355,7 @@ static void destroyGuiWindows() delete2(spellShortcutWindow); #ifdef EATHENA_SUPPORT delete2(bankWindow); + delete2(cutInWindow); delete2(mailWindow); #endif delete2(questsWindow); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index b7a7227c8..e22ea3f60 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -123,6 +123,7 @@ Window::Window(const std::string &caption, mDefaultY(0), mDefaultWidth(0), mDefaultHeight(0), + mShowTitle(true), mLastRedraw(true), mGrip(nullptr), mParent(parent), @@ -149,7 +150,6 @@ Window::Window(const std::string &caption, mStickyPadding(0), mCaptionFont(getFont()), mModal(modal), - mShowTitle(true), mCloseWindowButton(false), mDefaultVisible(false), mSaveVisible(false), diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 7d809e7db..277e971bb 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -641,6 +641,7 @@ class Window notfinal : public BasicContainer2, int mDefaultY; /**< Default window Y position */ int mDefaultWidth; /**< Default window width */ int mDefaultHeight; /**< Default window height */ + bool mShowTitle; /**< Window has a title bar */ bool mLastRedraw; private: @@ -707,7 +708,6 @@ class Window notfinal : public BasicContainer2, int mStickyPadding; Font *mCaptionFont A_NONNULLPOINTER; Modal mModal; /**< Window is modal */ - bool mShowTitle; /**< Window has a title bar */ bool mCloseWindowButton; /**< Window has a close button */ bool mDefaultVisible; /**< Window's default visibility */ bool mSaveVisible; /**< Window will save visibility */ diff --git a/src/gui/windows/cutinwindow.cpp b/src/gui/windows/cutinwindow.cpp new file mode 100644 index 000000000..910c6d562 --- /dev/null +++ b/src/gui/windows/cutinwindow.cpp @@ -0,0 +1,143 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2016 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 "gui/windows/cutinwindow.h" + +#include "configuration.h" + +#include "resources/image.h" +#include "resources/resourcemanager.h" + +#include "debug.h" + +CutInWindow *cutInWindow = nullptr; + +CutInWindow::CutInWindow() : + Window("", Modal_false, nullptr, "cutin.xml"), + mImage(nullptr), + mOldTitleBarHeight(mTitleBarHeight) +{ + setWindowName("CutIn"); + + setShowTitle(false); + setResizable(false); + setDefaultVisible(false); + setSaveVisible(false); + setVisible(Visible_false); + enableVisibleSound(false); +} + +CutInWindow::~CutInWindow() +{ + deleteImage(); +} + +void CutInWindow::deleteImage() +{ + if (mImage) + { + mImage->decRef(); + mImage = nullptr; + } +} + +void CutInWindow::draw(Graphics *graphics) +{ + Window::draw(graphics); + draw2(graphics); +} + +void CutInWindow::safeDraw(Graphics *graphics) +{ + Window::safeDraw(graphics); + draw2(graphics); +} + +void CutInWindow::draw2(Graphics *const graphics) +{ + if (mImage) + graphics->drawImage(mImage, mPadding, mTitleBarHeight); +} + +void CutInWindow::show(const std::string &name, + const CutIn cutin) +{ + deleteImage(); + if (name.empty()) + { + setVisible(Visible_false); + } + else + { + mImage = resourceManager->getImage( + std::string(paths.getStringValue("cutInsDir")).append( + "/").append( + name).append( + ".png")); + if (mImage) + { + const bool showTitle = (cutin == CutIn::MovableClose); + if (showTitle) + mTitleBarHeight = mOldTitleBarHeight; + else + mTitleBarHeight = mPadding; + const int width = mImage->mBounds.w + 2 * mPadding; + const int height = mImage->mBounds.h + mTitleBarHeight + + mPadding; + + const int screenWidth = mainGraphics->mWidth; + const int screenHeight = mainGraphics->mHeight; + + if (width * 2 > screenWidth || + height * 2 > screenHeight) + { + return; + } + const int padding = 100; + int x = 0; + const int y = screenHeight - height - padding; + switch (cutin) + { + case CutIn::BottomRight: + x = screenWidth - width - padding; + break; + case CutIn::BottomCenter: + case CutIn::Movable: + case CutIn::MovableClose: + x = (screenWidth - width) / 2; + break; + case CutIn::BottomLeft: + default: + x = padding; + break; + } + setCloseButton(false); + setVisible(Visible_true); + setPosition(x, y); + setCloseButton(showTitle); + setShowTitle(showTitle); + setSize(width, height); + setVisible(Visible_true); + requestMoveToTop(); + } + } +} diff --git a/src/gui/windows/cutinwindow.h b/src/gui/windows/cutinwindow.h new file mode 100644 index 000000000..2892f8548 --- /dev/null +++ b/src/gui/windows/cutinwindow.h @@ -0,0 +1,59 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2016 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 GUI_WINDOWS_CUTINWINDOW_H +#define GUI_WINDOWS_CUTINWINDOW_H + +#include "gui/widgets/window.h" + +#include "enums/cutin.h" + +class Image; + +class CutInWindow final : public Window +{ + public: + CutInWindow(); + + A_DELETE_COPY(CutInWindow) + + ~CutInWindow(); + + void draw(Graphics *graphics) override final A_NONNULL(2); + + void safeDraw(Graphics *graphics) override final A_NONNULL(2); + + void draw2(Graphics *const graphics) A_NONNULL(2); + + void show(const std::string &name, + const CutIn cutin); + + private: + void deleteImage(); + + Image *mImage; + int mOldTitleBarHeight; +}; + +extern CutInWindow *cutInWindow; + +#endif // GUI_WINDOWS_CUTINWINDOW_H diff --git a/src/net/eathena/npcrecv.cpp b/src/net/eathena/npcrecv.cpp index 44b37cd50..617ceb9ba 100644 --- a/src/net/eathena/npcrecv.cpp +++ b/src/net/eathena/npcrecv.cpp @@ -24,6 +24,9 @@ #include "being/being.h" +#include "enums/cutin.h" + +#include "gui/windows/cutinwindow.h" #include "gui/windows/npcdialog.h" #include "net/messagein.h" @@ -39,10 +42,10 @@ namespace EAthena void NpcRecv::processNpcCutin(Net::MessageIn &msg) { - UNIMPLIMENTEDPACKET; Ea::NpcRecv::mRequestLang = false; - msg.readString(64, "image name"); - msg.readUInt8("type"); + const std::string image = msg.readString(64, "image name"); + const CutIn cutin = fromInt(msg.readUInt8("type"), CutIn); + cutInWindow->show(image, cutin); } void NpcRecv::processNpcViewPoint(Net::MessageIn &msg) |