mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Allow taking screenshots of formspecs and move message to chat
This commit is contained in:
parent
2b7a1ca572
commit
a020d1b653
6 changed files with 53 additions and 40 deletions
|
@ -2538,16 +2538,14 @@ void Client::typeChatMessage(const std::wstring &message)
|
|||
// Show locally
|
||||
if (message[0] == L'/')
|
||||
{
|
||||
m_chat_queue.push_back(
|
||||
(std::wstring)L"issued command: "+message);
|
||||
m_chat_queue.push_back((std::wstring)L"issued command: " + message);
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalPlayer *player = m_env.getLocalPlayer();
|
||||
assert(player != NULL);
|
||||
std::wstring name = narrow_to_wide(player->getName());
|
||||
m_chat_queue.push_back(
|
||||
(std::wstring)L"<"+name+L"> "+message);
|
||||
m_chat_queue.push_back((std::wstring)L"<" + name + L"> " + message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2732,6 +2730,34 @@ float Client::getAvgRate(void)
|
|||
m_con.getLocalStat(con::AVG_DL_RATE));
|
||||
}
|
||||
|
||||
void Client::makeScreenshot(IrrlichtDevice *device)
|
||||
{
|
||||
irr::video::IVideoDriver *driver = device->getVideoDriver();
|
||||
irr::video::IImage* const raw_image = driver->createScreenShot();
|
||||
if (raw_image) {
|
||||
irr::video::IImage* const image = driver->createImage(video::ECF_R8G8B8,
|
||||
raw_image->getDimension());
|
||||
|
||||
if (image) {
|
||||
raw_image->copyTo(image);
|
||||
irr::c8 filename[256];
|
||||
snprintf(filename, sizeof(filename), "%s" DIR_DELIM "screenshot_%u.png",
|
||||
g_settings->get("screenshot_path").c_str(),
|
||||
device->getTimer()->getRealTime());
|
||||
std::stringstream sstr;
|
||||
if (driver->writeImageToFile(image, filename)) {
|
||||
sstr << "Saved screenshot to '" << filename << "'";
|
||||
} else {
|
||||
sstr << "Failed to save screenshot '" << filename << "'";
|
||||
}
|
||||
m_chat_queue.push_back(narrow_to_wide(sstr.str()));
|
||||
infostream << sstr << std::endl;
|
||||
image->drop();
|
||||
}
|
||||
raw_image->drop();
|
||||
}
|
||||
}
|
||||
|
||||
// IGameDef interface
|
||||
// Under envlock
|
||||
IItemDefManager* Client::getItemDefManager()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue