Skip to content

Commit a59f85c

Browse files
BlockMenRealBadAngel
authored andcommittedJul 23, 2013
Add support of pressed_texture of image_button
Fix params number Add pressed texture name Fix string def Fix syntax error
1 parent 8e2467c commit a59f85c

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed
 

‎doc/lua_api.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -933,16 +933,24 @@ button[<X>,<Y>;<W>,<H>;<name>;<label>]
933933

934934
image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
935935
^ x, y, w, h, and name work as per button
936-
^ image is the filename of an image
936+
^ texture name is the filename of an image
937937
^ Position and size units are inventory slots
938938

939939
image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>]
940940
^ x, y, w, h, and name work as per button
941-
^ image is the filename of an image
941+
^ texture name is the filename of an image
942942
^ Position and size units are inventory slots
943943
^ noclip true meand imagebutton doesn't need to be within specified formsize
944944
^ drawborder draw button bodrer or not
945945

946+
image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]
947+
^ x, y, w, h, and name work as per button
948+
^ texture name is the filename of an image
949+
^ Position and size units are inventory slots
950+
^ noclip true meand imagebutton doesn't need to be within specified formsize
951+
^ drawborder draw button bodrer or not
952+
^ pressed texture name is the filename of an image on pressed state
953+
946954
item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]
947955
^ x, y, w, h, name and label work as per button
948956
^ item name is the registered name of an item/node,

‎src/guiFormSpecMenu.cpp

+21-5
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data,std::string element) {
11161116
void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,std::string type) {
11171117
std::vector<std::string> parts = split(element,';');
11181118

1119-
if ((parts.size() == 5) || (parts.size() == 7)) {
1119+
if ((parts.size() == 5) || (parts.size() == 7) || (parts.size() == 8)) {
11201120
std::vector<std::string> v_pos = split(parts[0],',');
11211121
std::vector<std::string> v_geom = split(parts[1],',');
11221122
std::string image_name = parts[2];
@@ -1136,13 +1136,19 @@ void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,std:
11361136
bool noclip = false;
11371137
bool drawborder = true;
11381138

1139-
if ((parts.size() == 7)) {
1139+
if ((parts.size() >= 7)) {
11401140
if (parts[5] == "true")
11411141
noclip = true;
11421142

11431143
if (parts[6] == "false")
11441144
drawborder = false;
11451145
}
1146+
1147+
std::string pressed_image_name = "";
1148+
1149+
if ((parts.size() == 8)) {
1150+
pressed_image_name = parts[7];
1151+
}
11461152

11471153
core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);
11481154

@@ -1169,21 +1175,31 @@ void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,std:
11691175
spec.is_exit = true;
11701176

11711177
video::ITexture *texture = 0;
1178+
video::ITexture *pressed_texture = 0;
11721179
//if there's no gamedef specified try to get direct
11731180
//TODO check for possible texture leak
1174-
if (m_gamedef != 0)
1181+
if (m_gamedef != 0) {
11751182
texture = m_gamedef->tsrc()->getTexture(image_name);
1176-
else {
1183+
if ((parts.size() == 8)) {
1184+
pressed_texture = m_gamedef->tsrc()->getTexture(pressed_image_name);
1185+
}
1186+
} else {
11771187
if (fs::PathExists(image_name)) {
11781188
texture = Environment->getVideoDriver()->getTexture(image_name.c_str());
11791189
m_Textures.push_back(texture);
11801190
}
1191+
if (fs::PathExists(pressed_image_name)) {
1192+
pressed_texture = Environment->getVideoDriver()->getTexture(pressed_image_name.c_str());
1193+
m_Textures.push_back(pressed_texture);
1194+
}
11811195
}
1196+
if (parts.size() < 8)
1197+
pressed_texture = texture;
11821198

11831199
gui::IGUIButton *e = Environment->addButton(rect, this, spec.fid, spec.flabel.c_str());
11841200
e->setUseAlphaChannel(true);
11851201
e->setImage(texture);
1186-
e->setPressedImage(texture);
1202+
e->setPressedImage(pressed_texture);
11871203
e->setScaleImage(true);
11881204
e->setNotClipped(noclip);
11891205
e->setDrawBorder(drawborder);

0 commit comments

Comments
 (0)
Please sign in to comment.