Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
824 additions
and 454 deletions.
- +3 −0 build/android/jni/Android.mk
- +7 −0 doc/lua_api.txt
- +3 −4 src/client/guiscalingfilter.cpp
- +2 −1 src/client/guiscalingfilter.h
- +3 −0 src/gui/CMakeLists.txt
- +69 −0 src/gui/guiBackgroundImage.cpp
- +38 −0 src/gui/guiBackgroundImage.h
- +38 −0 src/gui/guiBox.cpp
- +34 −0 src/gui/guiBox.h
- +490 −339 src/gui/guiFormSpecMenu.cpp
- +23 −108 src/gui/guiFormSpecMenu.h
- +64 −0 src/gui/guiItemImage.cpp
- +46 −0 src/gui/guiItemImage.h
- +4 −2 src/network/networkprotocol.h
@@ -0,0 +1,69 @@ | ||
/* | ||
Part of Minetest | ||
Copyright (C) 2013 RealBadAngel, Maciej Kasatkin <mk@realbadangel.pl> | ||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include "guiBackgroundImage.h" | ||
#include "client/guiscalingfilter.h" | ||
#include "log.h" | ||
|
||
GUIBackgroundImage::GUIBackgroundImage(gui::IGUIEnvironment *env, | ||
gui::IGUIElement *parent, s32 id, const core::rect<s32> &rectangle, | ||
const std::string &name, const core::rect<s32> &middle, | ||
ISimpleTextureSource *tsrc, bool autoclip) : | ||
gui::IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, rectangle), | ||
m_name(name), m_middle(middle), m_tsrc(tsrc), m_autoclip(autoclip) | ||
{ | ||
} | ||
|
||
void GUIBackgroundImage::draw() | ||
{ | ||
if (!IsVisible) | ||
return; | ||
|
||
video::ITexture *texture = m_tsrc->getTexture(m_name); | ||
|
||
if (!texture) { | ||
errorstream << "GUIBackgroundImage::draw() Unable to load texture:" | ||
<< std::endl; | ||
errorstream << "\t" << m_name << std::endl; | ||
return; | ||
} | ||
|
||
core::rect<s32> rect = AbsoluteRect; | ||
if (m_autoclip) | ||
rect.LowerRightCorner += Parent->getAbsolutePosition().getSize(); | ||
|
||
video::IVideoDriver *driver = Environment->getVideoDriver(); | ||
|
||
if (m_middle.getArea() == 0) { | ||
const video::SColor color(255, 255, 255, 255); | ||
const video::SColor colors[] = {color, color, color, color}; | ||
draw2DImageFilterScaled(driver, texture, rect, | ||
core::rect<s32>(core::position2d<s32>(0, 0), | ||
core::dimension2di(texture->getOriginalSize())), | ||
nullptr, colors, true); | ||
} else { | ||
core::rect<s32> middle = m_middle; | ||
// `-x` is interpreted as `w - x` | ||
if (middle.LowerRightCorner.X < 0) | ||
middle.LowerRightCorner.X += texture->getOriginalSize().Width; | ||
if (middle.LowerRightCorner.Y < 0) | ||
middle.LowerRightCorner.Y += texture->getOriginalSize().Height; | ||
draw2DImage9Slice(driver, texture, rect, middle); | ||
} | ||
|
||
IGUIElement::draw(); | ||
} |
@@ -0,0 +1,38 @@ | ||
/* | ||
Part of Minetest | ||
Copyright (C) 2013 RealBadAngel, Maciej Kasatkin <mk@realbadangel.pl> | ||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "irrlichttypes_extrabloated.h" | ||
#include "util/string.h" | ||
#include "client/tile.h" // ITextureSource | ||
|
||
class GUIBackgroundImage : public gui::IGUIElement | ||
{ | ||
public: | ||
GUIBackgroundImage(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id, | ||
const core::rect<s32> &rectangle, const std::string &name, | ||
const core::rect<s32> &middle, ISimpleTextureSource *tsrc, bool autoclip); | ||
|
||
virtual void draw() override; | ||
|
||
private: | ||
std::string m_name; | ||
core::rect<s32> m_middle; | ||
ISimpleTextureSource *m_tsrc; | ||
bool m_autoclip; | ||
}; |
@@ -0,0 +1,38 @@ | ||
/* | ||
Minetest | ||
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com> | ||
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. | ||
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. | ||
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. | ||
*/ | ||
|
||
#include "guiBox.h" | ||
|
||
GUIBox::GUIBox(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id, | ||
const core::rect<s32> &rectangle, const video::SColor &color) : | ||
gui::IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, rectangle), | ||
m_color(color) | ||
{ | ||
} | ||
|
||
void GUIBox::draw() | ||
{ | ||
if (!IsVisible) | ||
return; | ||
|
||
Environment->getVideoDriver()->draw2DRectangle(m_color, AbsoluteRect, | ||
&AbsoluteClippingRect); | ||
|
||
IGUIElement::draw(); | ||
} |
@@ -0,0 +1,34 @@ | ||
/* | ||
Minetest | ||
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com> | ||
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. | ||
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. | ||
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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "irrlichttypes_extrabloated.h" | ||
|
||
class GUIBox : public gui::IGUIElement | ||
{ | ||
public: | ||
GUIBox(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id, | ||
const core::rect<s32> &rectangle, const video::SColor &color); | ||
|
||
virtual void draw() override; | ||
|
||
private: | ||
video::SColor m_color; | ||
}; |
Oops, something went wrong.