mirror of
https://github.com/minetest/minetest.git
synced 2024-11-14 03:33:44 +01:00
Formspec button_exit[] and image_button_exit[]
This commit is contained in:
parent
d44f8a854b
commit
6dfefaf229
@ -719,6 +719,12 @@ image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
|
|||||||
^ image is the filename of an image
|
^ image is the filename of an image
|
||||||
^ Position and size units are inventory slots
|
^ Position and size units are inventory slots
|
||||||
|
|
||||||
|
button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]
|
||||||
|
^ When clicked, fields will be sent and the form will quit.
|
||||||
|
|
||||||
|
image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
|
||||||
|
^ When clicked, fields will be sent and the form will quit.
|
||||||
|
|
||||||
Inventory location:
|
Inventory location:
|
||||||
- "context": Selected node metadata (deprecated: "current_name")
|
- "context": Selected node metadata (deprecated: "current_name")
|
||||||
- "current_player": Player to whom the menu is shown
|
- "current_player": Player to whom the menu is shown
|
||||||
|
@ -532,7 +532,7 @@ minetest.register_chatcommand("test1", {
|
|||||||
"list[current_player;craft;8,0;3,3;]"..
|
"list[current_player;craft;8,0;3,3;]"..
|
||||||
"list[current_player;craftpreview;12,1;1,1;]"..
|
"list[current_player;craftpreview;12,1;1,1;]"..
|
||||||
"button[0.5,7;2,1;button1;Button 1]"..
|
"button[0.5,7;2,1;button1;Button 1]"..
|
||||||
"button[2.5,7;2,1;button2;Button 2]"
|
"button_exit[2.5,7;2,1;button2;Exit Button]"
|
||||||
)
|
)
|
||||||
minetest.chat_send_player(name, "Done.");
|
minetest.chat_send_player(name, "Done.");
|
||||||
end,
|
end,
|
||||||
|
@ -149,6 +149,7 @@ GUIFormSpecMenu::~GUIFormSpecMenu()
|
|||||||
|
|
||||||
delete m_selected_item;
|
delete m_selected_item;
|
||||||
delete m_form_src;
|
delete m_form_src;
|
||||||
|
delete m_text_dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIFormSpecMenu::removeChildren()
|
void GUIFormSpecMenu::removeChildren()
|
||||||
@ -398,7 +399,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||||||
Environment->addStaticText(spec.flabel.c_str(), rect, false, true, this, spec.fid);
|
Environment->addStaticText(spec.flabel.c_str(), rect, false, true, this, spec.fid);
|
||||||
m_fields.push_back(spec);
|
m_fields.push_back(spec);
|
||||||
}
|
}
|
||||||
else if(type == "button")
|
else if(type == "button" || type == "button_exit")
|
||||||
{
|
{
|
||||||
v2s32 pos;
|
v2s32 pos;
|
||||||
pos.X = stof(f.next(",")) * (float)spacing.X;
|
pos.X = stof(f.next(",")) * (float)spacing.X;
|
||||||
@ -421,10 +422,12 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||||||
258+m_fields.size()
|
258+m_fields.size()
|
||||||
);
|
);
|
||||||
spec.is_button = true;
|
spec.is_button = true;
|
||||||
|
if(type == "button_exit")
|
||||||
|
spec.is_exit = true;
|
||||||
Environment->addButton(rect, this, spec.fid, spec.flabel.c_str());
|
Environment->addButton(rect, this, spec.fid, spec.flabel.c_str());
|
||||||
m_fields.push_back(spec);
|
m_fields.push_back(spec);
|
||||||
}
|
}
|
||||||
else if(type == "image_button")
|
else if(type == "image_button" || type == "image_button_exit")
|
||||||
{
|
{
|
||||||
v2s32 pos;
|
v2s32 pos;
|
||||||
pos.X = stof(f.next(",")) * (float)spacing.X;
|
pos.X = stof(f.next(",")) * (float)spacing.X;
|
||||||
@ -448,6 +451,8 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||||||
258+m_fields.size()
|
258+m_fields.size()
|
||||||
);
|
);
|
||||||
spec.is_button = true;
|
spec.is_button = true;
|
||||||
|
if(type == "image_button_exit")
|
||||||
|
spec.is_exit = true;
|
||||||
|
|
||||||
video::ITexture *texture = m_gamedef->tsrc()->getTextureRaw(fimage);
|
video::ITexture *texture = m_gamedef->tsrc()->getTextureRaw(fimage);
|
||||||
gui::IGUIButton *e = Environment->addButton(rect, this, spec.fid, spec.flabel.c_str());
|
gui::IGUIButton *e = Environment->addButton(rect, this, spec.fid, spec.flabel.c_str());
|
||||||
@ -813,8 +818,6 @@ void GUIFormSpecMenu::acceptInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_text_dst->gotText(fields);
|
m_text_dst->gotText(fields);
|
||||||
delete m_text_dst;
|
|
||||||
m_text_dst = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1152,8 +1155,13 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
{
|
{
|
||||||
s.send = true;
|
s.send = true;
|
||||||
acceptInput();
|
acceptInput();
|
||||||
quitMenu();
|
if(s.is_exit){
|
||||||
return true;
|
quitMenu();
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
s.send = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,7 @@ class GUIFormSpecMenu : public GUIModalMenu
|
|||||||
{
|
{
|
||||||
send = false;
|
send = false;
|
||||||
is_button = false;
|
is_button = false;
|
||||||
|
is_exit = false;
|
||||||
}
|
}
|
||||||
std::wstring fname;
|
std::wstring fname;
|
||||||
std::wstring flabel;
|
std::wstring flabel;
|
||||||
@ -137,6 +138,7 @@ class GUIFormSpecMenu : public GUIModalMenu
|
|||||||
int fid;
|
int fid;
|
||||||
bool send;
|
bool send;
|
||||||
bool is_button;
|
bool is_button;
|
||||||
|
bool is_exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user