2018-06-25 02:39:23 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* OpenMiner
|
|
|
|
* Copyright (C) 2018-2020 Unarelith, Quentin Bazin <openminer@unarelith.net>
|
2018-06-25 02:39:23 +02:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2018-06-25 02:39:23 +02:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* 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
|
|
|
|
* Lesser General Public License for more details.
|
2018-06-25 02:39:23 +02:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2018-06-25 02:39:23 +02:00
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef CRAFTINGWIDGET_HPP_
|
|
|
|
#define CRAFTINGWIDGET_HPP_
|
|
|
|
|
|
|
|
#include "InventoryWidget.hpp"
|
|
|
|
|
2018-06-30 03:47:39 +02:00
|
|
|
class Recipe;
|
2018-06-25 03:00:49 +02:00
|
|
|
|
2018-06-25 02:39:23 +02:00
|
|
|
class CraftingWidget : public Widget {
|
|
|
|
public:
|
2019-04-08 12:59:02 +02:00
|
|
|
CraftingWidget(ClientCommandHandler &client, Inventory &craftingInventory, Widget *parent = nullptr);
|
2018-06-25 02:39:23 +02:00
|
|
|
|
2020-02-03 14:11:18 +09:00
|
|
|
void init(unsigned int offset = 0, unsigned int size = 3);
|
|
|
|
|
2018-12-28 06:19:40 +01:00
|
|
|
void onMouseEvent(const SDL_Event &event, MouseItemWidget &mouseItemWidget);
|
2018-06-25 02:39:23 +02:00
|
|
|
|
2018-06-27 05:39:56 +02:00
|
|
|
void update() override;
|
2018-06-25 03:49:53 +02:00
|
|
|
|
2018-06-25 22:30:38 +02:00
|
|
|
const ItemWidget *currentItemWidget() const { return m_craftingResultInventoryWidget.currentItemWidget() ? m_craftingResultInventoryWidget.currentItemWidget() : m_craftingInventoryWidget.currentItemWidget(); }
|
|
|
|
|
2018-06-29 07:38:57 +02:00
|
|
|
InventoryWidget &craftingInventoryWidget() { return m_craftingInventoryWidget; }
|
|
|
|
InventoryWidget &craftingResultInventoryWidget() { return m_craftingResultInventoryWidget; }
|
|
|
|
|
2018-06-27 09:07:57 +02:00
|
|
|
protected:
|
2019-04-08 12:59:02 +02:00
|
|
|
ClientCommandHandler &m_client;
|
2019-01-26 20:29:13 +01:00
|
|
|
|
2018-06-29 07:16:51 +02:00
|
|
|
Inventory &m_craftingInventory;
|
2019-01-26 20:29:13 +01:00
|
|
|
InventoryWidget m_craftingInventoryWidget{m_client, this};
|
2018-06-25 02:39:23 +02:00
|
|
|
|
|
|
|
Inventory m_craftingResultInventory{1, 1};
|
2019-01-26 20:29:13 +01:00
|
|
|
InventoryWidget m_craftingResultInventoryWidget{m_client, this};
|
2018-06-25 03:00:49 +02:00
|
|
|
|
2018-06-27 09:07:57 +02:00
|
|
|
private:
|
2018-12-29 02:23:23 +01:00
|
|
|
void draw(gk::RenderTarget &target, gk::RenderStates states) const override;
|
2018-06-27 09:07:57 +02:00
|
|
|
|
2018-06-30 03:47:39 +02:00
|
|
|
const Recipe *m_recipe = nullptr;
|
2018-06-25 02:39:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CRAFTINGWIDGET_HPP_
|