summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2023-09-08 17:00:42 +0300
committerMnikolenko Productengine <mnikolenko@productengine.com>2023-09-08 17:00:42 +0300
commit5b09d6372ff0900f67714af61bea100ee9a6d87b (patch)
tree23c49d7dafde5a5e3b11373ca0bd916ab6cd3ca0 /indra
parentb51cef8c8eaafa873f2a62d967cc4fe62cc0d94e (diff)
allow to take snapshot; bind more funcs to call from lua
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llluamanager.cpp77
-rw-r--r--indra/newview/llviewermenu.cpp125
-rw-r--r--indra/newview/llviewermenu.h1
-rw-r--r--indra/newview/llviewermenufile.cpp24
-rw-r--r--indra/newview/llviewermenufile.h2
5 files changed, 162 insertions, 67 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index bb86731140..edfd5c3cad 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -30,8 +30,16 @@
#include "llagent.h"
#include "llappearancemgr.h"
+#include "llcallbacklist.h"
#include "llfloaterreg.h"
#include "llfloaterimnearbychat.h"
+#include "llfloatersidepanelcontainer.h"
+#include "llvoavatarself.h"
+#include "llviewermenu.h"
+#include "llviewermenufile.h"
+#include "llviewerwindow.h"
+
+#include <boost/algorithm/string/replace.hpp>
extern "C"
{
@@ -95,6 +103,66 @@ int lua_open_floater(lua_State *L)
return 1;
}
+int lua_close_all_floaters(lua_State *L)
+{
+ close_all_windows();
+ return 1;
+}
+
+int lua_snapshot_to_file(lua_State *L)
+{
+ std::string filename(lua_tostring(L, 1));
+
+ //don't take snapshot from coroutine
+ doOnIdleOneTime([filename]()
+ {
+ gViewerWindow->saveSnapshot(filename,
+ gViewerWindow->getWindowWidthRaw(),
+ gViewerWindow->getWindowHeightRaw(),
+ gSavedSettings.getBOOL("RenderUIInSnapshot"),
+ gSavedSettings.getBOOL("RenderHUDInSnapshot"),
+ FALSE,
+ LLSnapshotModel::SNAPSHOT_TYPE_COLOR,
+ LLSnapshotModel::SNAPSHOT_FORMAT_PNG);
+ });
+
+ return 1;
+}
+
+int lua_open_wearing_tab(lua_State *L)
+{
+ LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "now_wearing"));
+ return 1;
+}
+
+int lua_set_debug_setting_bool(lua_State *L)
+{
+ std::string setting_name(lua_tostring(L, 1));
+ bool value(lua_toboolean(L, 2));
+
+ gSavedSettings.setBOOL(setting_name, value);
+ return 1;
+}
+
+ int lua_get_avatar_name(lua_State *L)
+{
+ std::string name = gAgentAvatarp->getFullname();
+ lua_pushstring(L, name.c_str());
+ return 1;
+}
+
+int lua_is_avatar_flying(lua_State *L)
+{
+ lua_pushboolean(L, gAgent.getFlying());
+ return 1;
+}
+
+int lua_env_setting_event(lua_State *L)
+{
+ handle_env_setting_event(lua_tostring(L, 1));
+ return 1;
+}
+
bool checkLua(lua_State *L, int r, std::string &error_msg)
{
if (r != LUA_OK)
@@ -117,6 +185,15 @@ void initLUA(lua_State *L)
lua_register(L, "nearby_chat_send", lua_nearby_chat_send);
lua_register(L, "wear_by_name", lua_wear_by_name);
lua_register(L, "open_floater", lua_open_floater);
+ lua_register(L, "close_all_floaters", lua_close_all_floaters);
+ lua_register(L, "open_wearing_tab", lua_open_wearing_tab);
+ lua_register(L, "snapshot_to_file", lua_snapshot_to_file);
+
+ lua_register(L, "get_avatar_name", lua_get_avatar_name);
+ lua_register(L, "is_avatar_flying", lua_is_avatar_flying);
+
+ lua_register(L, "env_setting_event", lua_env_setting_event);
+ lua_register(L, "set_debug_setting_bool", lua_set_debug_setting_bool);
}
void LLLUAmanager::runScriptFile(const std::string &filename, script_finished_fn cb)
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index cc59e559e9..240fa15685 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -8895,71 +8895,80 @@ class LLToolsSelectTool : public view_listener_t
};
/// WINDLIGHT callbacks
-class LLWorldEnvSettings : public view_listener_t
-{
- void defocusEnvFloaters()
+void defocusEnvFloaters()
+{
+ // currently there is only one instance of each floater
+ std::vector<std::string> env_floaters_names = {"env_edit_extdaycycle", "env_fixed_environmentent_water",
+ "env_fixed_environmentent_sky"};
+ for (std::vector<std::string>::const_iterator it = env_floaters_names.begin(); it != env_floaters_names.end(); ++it)
{
- //currently there is only one instance of each floater
- std::vector<std::string> env_floaters_names = { "env_edit_extdaycycle", "env_fixed_environmentent_water", "env_fixed_environmentent_sky" };
- for (std::vector<std::string>::const_iterator it = env_floaters_names.begin(); it != env_floaters_names.end(); ++it)
+ LLFloater *env_floater = LLFloaterReg::findTypedInstance<LLFloater>(*it);
+ if (env_floater)
{
- LLFloater* env_floater = LLFloaterReg::findTypedInstance<LLFloater>(*it);
- if (env_floater)
- {
- env_floater->setFocus(FALSE);
- }
+ env_floater->setFocus(FALSE);
}
}
+}
+
+bool handle_env_setting_event(std::string event_name)
+{
+ if (event_name == "sunrise")
+ {
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNRISE,
+ LLEnvironment::TRANSITION_INSTANT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
+ defocusEnvFloaters();
+ }
+ else if (event_name == "noon")
+ {
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDDAY,
+ LLEnvironment::TRANSITION_INSTANT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
+ defocusEnvFloaters();
+ }
+ else if (event_name == "sunset")
+ {
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNSET,
+ LLEnvironment::TRANSITION_INSTANT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
+ defocusEnvFloaters();
+ }
+ else if (event_name == "midnight")
+ {
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDNIGHT,
+ LLEnvironment::TRANSITION_INSTANT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
+ defocusEnvFloaters();
+ }
+ else if (event_name == "region")
+ {
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
+ defocusEnvFloaters();
+ }
+ else if (event_name == "pause_clouds")
+ {
+ if (LLEnvironment::instance().isCloudScrollPaused())
+ LLEnvironment::instance().resumeCloudScroll();
+ else
+ LLEnvironment::instance().pauseCloudScroll();
+ }
+ else if (event_name == "adjust_tool")
+ {
+ LLFloaterReg::showInstance("env_adjust_snapshot");
+ }
+ else if (event_name == "my_environs")
+ {
+ LLFloaterReg::showInstance("my_environments");
+ }
+ return true;
+}
+class LLWorldEnvSettings : public view_listener_t
+{
bool handleEvent(const LLSD& userdata)
{
- std::string event_name = userdata.asString();
-
- if (event_name == "sunrise")
- {
- LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNRISE, LLEnvironment::TRANSITION_INSTANT);
- LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
- defocusEnvFloaters();
- }
- else if (event_name == "noon")
- {
- LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDDAY, LLEnvironment::TRANSITION_INSTANT);
- LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
- defocusEnvFloaters();
- }
- else if (event_name == "sunset")
- {
- LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_SUNSET, LLEnvironment::TRANSITION_INSTANT);
- LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
- defocusEnvFloaters();
- }
- else if (event_name == "midnight")
- {
- LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::KNOWN_SKY_MIDNIGHT, LLEnvironment::TRANSITION_INSTANT);
- LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
- defocusEnvFloaters();
- }
- else if (event_name == "region")
- {
- LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
- LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::TRANSITION_INSTANT);
- defocusEnvFloaters();
- }
- else if (event_name == "pause_clouds")
- {
- if (LLEnvironment::instance().isCloudScrollPaused())
- LLEnvironment::instance().resumeCloudScroll();
- else
- LLEnvironment::instance().pauseCloudScroll();
- }
- else if (event_name == "adjust_tool")
- {
- LLFloaterReg::showInstance("env_adjust_snapshot");
- }
- else if (event_name == "my_environs")
- {
- LLFloaterReg::showInstance("my_environments");
- }
+ handle_env_setting_event(userdata.asString());
return true;
}
diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h
index a90b32c984..b17a5d8b96 100644
--- a/indra/newview/llviewermenu.h
+++ b/indra/newview/llviewermenu.h
@@ -140,6 +140,7 @@ void handle_give_money_dialog();
bool enable_pay_object();
bool enable_buy_object();
bool handle_go_to();
+bool handle_env_setting_event(std::string event_name);
// Export to XML or Collada
void handle_export_selected( void * );
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 2634c8d908..9d5f5377b0 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -743,19 +743,25 @@ class LLFileEnableCloseAllWindows : public view_listener_t
}
};
+void close_all_windows()
+{
+ bool app_quitting = false;
+ gFloaterView->closeAllChildren(app_quitting);
+ LLFloaterSnapshot *floater_snapshot = LLFloaterSnapshot::findInstance();
+ if (floater_snapshot)
+ floater_snapshot->closeFloater(app_quitting);
+ LLFloaterSimpleOutfitSnapshot *floater_outfit_snapshot = LLFloaterSimpleOutfitSnapshot::findInstance();
+ if (floater_outfit_snapshot)
+ floater_outfit_snapshot->closeFloater(app_quitting);
+ if (gMenuHolder)
+ gMenuHolder->hideMenus();
+}
+
class LLFileCloseAllWindows : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- bool app_quitting = false;
- gFloaterView->closeAllChildren(app_quitting);
- LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance();
- if (floater_snapshot)
- floater_snapshot->closeFloater(app_quitting);
- LLFloaterSimpleOutfitSnapshot* floater_outfit_snapshot = LLFloaterSimpleOutfitSnapshot::findInstance();
- if (floater_outfit_snapshot)
- floater_outfit_snapshot->closeFloater(app_quitting);
- if (gMenuHolder) gMenuHolder->hideMenus();
+ close_all_windows();
return true;
}
};
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 61572b9996..fd13eef8b7 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -72,6 +72,8 @@ void assign_defaults_and_show_upload_message(
const std::string& display_name,
std::string& description);
+void close_all_windows();
+
//consider moving all file pickers below to more suitable place
class LLFilePickerThread : public LLThread
{ //multi-threaded file picker (runs system specific file picker in background and calls "notify" from main thread)