2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
2019-12-09 15:06:51 -05:00
|
|
|
|
|
|
|
#include "guiButtonItemImage.h"
|
|
|
|
|
|
|
|
#include "client/client.h"
|
|
|
|
#include "client/hud.h" // drawItemStack
|
|
|
|
#include "guiItemImage.h"
|
|
|
|
#include "IGUIEnvironment.h"
|
|
|
|
#include "itemdef.h"
|
|
|
|
|
|
|
|
using namespace irr;
|
|
|
|
using namespace gui;
|
|
|
|
|
2020-04-11 16:39:30 -04:00
|
|
|
GUIButtonItemImage::GUIButtonItemImage(gui::IGUIEnvironment *environment,
|
|
|
|
gui::IGUIElement *parent, s32 id, core::rect<s32> rectangle,
|
2021-04-05 13:38:31 +02:00
|
|
|
ISimpleTextureSource *tsrc, const std::string &item, Client *client,
|
2020-04-11 16:39:30 -04:00
|
|
|
bool noclip)
|
|
|
|
: GUIButton (environment, parent, id, rectangle, tsrc, noclip)
|
2019-12-09 15:06:51 -05:00
|
|
|
{
|
|
|
|
m_image = new GUIItemImage(environment, this, id,
|
|
|
|
core::rect<s32>(0,0,rectangle.getWidth(),rectangle.getHeight()),
|
|
|
|
item, getActiveFont(), client);
|
|
|
|
sendToBack(m_image);
|
|
|
|
|
|
|
|
m_client = client;
|
|
|
|
}
|
|
|
|
|
|
|
|
GUIButtonItemImage *GUIButtonItemImage::addButton(IGUIEnvironment *environment,
|
2020-04-11 16:39:30 -04:00
|
|
|
const core::rect<s32> &rectangle, ISimpleTextureSource *tsrc,
|
2021-04-05 13:38:31 +02:00
|
|
|
IGUIElement *parent, s32 id, const wchar_t *text, const std::string &item,
|
2020-04-11 16:39:30 -04:00
|
|
|
Client *client)
|
2019-12-09 15:06:51 -05:00
|
|
|
{
|
|
|
|
GUIButtonItemImage *button = new GUIButtonItemImage(environment,
|
|
|
|
parent ? parent : environment->getRootGUIElement(),
|
2020-04-11 16:39:30 -04:00
|
|
|
id, rectangle, tsrc, item, client);
|
2019-12-09 15:06:51 -05:00
|
|
|
|
|
|
|
if (text)
|
|
|
|
button->setText(text);
|
|
|
|
|
|
|
|
button->drop();
|
|
|
|
return button;
|
|
|
|
}
|