1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-31 06:32:39 +00:00
OpenMW/apps/openmw/mwgui/inventorywindow.hpp

146 lines
3.5 KiB
C++
Raw Normal View History

2012-04-21 10:51:01 +02:00
#ifndef MGUI_Inventory_H
#define MGUI_Inventory_H
2013-07-31 21:40:29 +02:00
#include "mode.hpp"
2022-09-22 21:26:05 +03:00
#include "windowpinnablebase.hpp"
2012-05-12 22:44:12 +02:00
#include "../mwrender/characterpreview.hpp"
2022-09-22 21:26:05 +03:00
#include "../mwworld/ptr.hpp"
2015-01-10 02:50:43 +01:00
namespace osg
2015-05-20 02:18:20 +02:00
{
class Group;
2015-05-20 02:18:20 +02:00
}
namespace Resource
{
class ResourceSystem;
}
2012-04-21 10:51:01 +02:00
namespace MWGui
{
2015-01-10 02:50:43 +01:00
namespace Widgets
{
class MWDynamicStat;
}
2013-05-11 18:38:27 +02:00
class ItemView;
class SortFilterItemModel;
class TradeItemModel;
class DragAndDrop;
class ItemModel;
class InventoryWindow : public WindowPinnableBase
2012-04-21 10:51:01 +02:00
{
2022-09-22 21:26:05 +03:00
public:
InventoryWindow(DragAndDrop* dragAndDrop, osg::Group* parent, Resource::ResourceSystem* resourceSystem);
void onOpen() override;
2022-09-22 21:26:05 +03:00
/// start trading, disables item drag&drop
void setTrading(bool trading);
2022-09-22 21:26:05 +03:00
void onFrame(float dt) override;
2022-09-22 21:26:05 +03:00
void pickUpObject(MWWorld::Ptr object);
2012-05-15 22:45:46 +02:00
2022-09-22 21:26:05 +03:00
MWWorld::Ptr getAvatarSelectedItem(int x, int y);
2022-09-22 21:26:05 +03:00
void rebuildAvatar();
2022-09-22 21:26:05 +03:00
SortFilterItemModel* getSortFilterModel();
TradeItemModel* getTradeModel();
ItemModel* getModel();
2022-09-22 21:26:05 +03:00
void updateItemView();
2013-05-11 18:38:27 +02:00
2022-09-22 21:26:05 +03:00
void updatePlayer();
2013-05-11 18:38:27 +02:00
2022-09-22 21:26:05 +03:00
void clear() override;
2013-05-15 17:54:18 +02:00
2022-09-22 21:26:05 +03:00
void useItem(const MWWorld::Ptr& ptr, bool force = false);
2022-09-22 21:26:05 +03:00
void setGuiMode(GuiMode mode);
2022-09-22 21:26:05 +03:00
/// Cycle to previous/next weapon
void cycle(bool next);
2013-07-31 21:40:29 +02:00
2023-07-09 08:42:09 +02:00
std::string_view getWindowIdForLua() const override { return "Inventory"; }
2022-09-22 21:26:05 +03:00
protected:
void onTitleDoubleClicked() override;
2022-09-22 21:26:05 +03:00
private:
DragAndDrop* mDragAndDrop;
2022-09-22 21:26:05 +03:00
int mSelectedItem;
2023-09-12 03:03:59 +08:00
std::optional<int> mEquippedStackableCount;
2013-05-11 18:38:27 +02:00
2022-09-22 21:26:05 +03:00
MWWorld::Ptr mPtr;
2013-05-11 18:38:27 +02:00
2022-09-22 21:26:05 +03:00
MWGui::ItemView* mItemView;
SortFilterItemModel* mSortModel;
TradeItemModel* mTradeModel;
2013-05-11 18:38:27 +02:00
2022-09-22 21:26:05 +03:00
MyGUI::Widget* mAvatar;
MyGUI::ImageBox* mAvatarImage;
MyGUI::TextBox* mArmorRating;
Widgets::MWDynamicStat* mEncumbranceBar;
2022-09-22 21:26:05 +03:00
MyGUI::Widget* mLeftPane;
MyGUI::Widget* mRightPane;
2012-05-12 21:28:04 +02:00
2022-09-22 21:26:05 +03:00
MyGUI::Button* mFilterAll;
MyGUI::Button* mFilterWeapon;
MyGUI::Button* mFilterApparel;
MyGUI::Button* mFilterMagic;
MyGUI::Button* mFilterMisc;
2022-09-22 21:26:05 +03:00
MyGUI::EditBox* mFilterEdit;
2012-05-12 21:28:04 +02:00
2022-09-22 21:26:05 +03:00
GuiMode mGuiMode;
2013-07-31 21:40:29 +02:00
2022-09-22 21:26:05 +03:00
int mLastXSize;
int mLastYSize;
2012-09-14 14:34:18 +02:00
2022-09-22 21:26:05 +03:00
std::unique_ptr<MyGUI::ITexture> mPreviewTexture;
std::unique_ptr<MWRender::InventoryPreview> mPreview;
2012-09-14 14:34:18 +02:00
2022-09-22 21:26:05 +03:00
bool mTrading;
float mUpdateTimer;
2022-09-22 21:26:05 +03:00
void toggleMaximized();
2022-09-22 21:26:05 +03:00
void onItemSelected(int index);
void onItemSelectedFromSourceModel(int index);
2013-05-11 18:38:27 +02:00
2022-09-22 21:26:05 +03:00
void onBackgroundSelected();
2013-05-11 18:38:27 +02:00
2022-09-22 21:26:05 +03:00
void sellItem(MyGUI::Widget* sender, int count);
void dragItem(MyGUI::Widget* sender, int count);
2013-05-11 18:38:27 +02:00
2022-09-22 21:26:05 +03:00
void onWindowResize(MyGUI::Window* _sender);
void onFilterChanged(MyGUI::Widget* _sender);
void onNameFilterChanged(MyGUI::EditBox* _sender);
void onAvatarClicked(MyGUI::Widget* _sender);
void onPinToggled() override;
2022-09-22 21:26:05 +03:00
void updateEncumbranceBar();
void notifyContentChanged();
void dirtyPreview();
void updatePreviewSize();
void updateArmorRating();
2013-12-03 18:42:35 +01:00
2022-09-22 21:26:05 +03:00
MyGUI::IntSize getPreviewViewportSize() const;
osg::Vec2f mapPreviewWindowToViewport(int x, int y) const;
2022-09-22 21:26:05 +03:00
void adjustPanes();
2022-09-22 21:26:05 +03:00
/// Unequips count items from mSelectedItem, if it is equipped, and then updates mSelectedItem in case the items
/// were re-stacked
void ensureSelectedItemUnequipped(int count);
2012-04-21 10:51:01 +02:00
};
}
2012-04-21 10:51:01 +02:00
#endif // Inventory_H