Files
Ansariel 0ecfbc3de9 Merge remote-tracking branch 'LGPL/master'
# Conflicts:
#	autobuild.xml
#	indra/cmake/CMakeLists.txt
#	indra/cmake/GoogleMock.cmake
#	indra/llappearance/llwearable.cpp
#	indra/llcharacter/llmultigesture.cpp
#	indra/llcharacter/llmultigesture.h
#	indra/llimage/llimage.cpp
#	indra/llimage/llimagepng.cpp
#	indra/llimage/llimageworker.cpp
#	indra/llmessage/tests/llmockhttpclient.h
#	indra/llrender/llfontfreetype.cpp
#	indra/llui/llcombobox.cpp
#	indra/llui/llfolderview.cpp
#	indra/llui/llfolderviewmodel.h
#	indra/llui/lllineeditor.cpp
#	indra/llui/lllineeditor.h
#	indra/llui/lltextbase.cpp
#	indra/llui/lltextbase.h
#	indra/llui/lltexteditor.cpp
#	indra/llui/lltextvalidate.cpp
#	indra/llui/lltextvalidate.h
#	indra/llui/lluictrl.h
#	indra/llui/llview.cpp
#	indra/llwindow/llwindowmacosx.cpp
#	indra/newview/app_settings/settings.xml
#	indra/newview/llappearancemgr.cpp
#	indra/newview/llappearancemgr.h
#	indra/newview/llavatarpropertiesprocessor.h
#	indra/newview/llbreadcrumbview.cpp
#	indra/newview/llbreadcrumbview.h
#	indra/newview/llbreastmotion.cpp
#	indra/newview/llbreastmotion.h
#	indra/newview/llconversationmodel.h
#	indra/newview/lldensityctrl.cpp
#	indra/newview/lldensityctrl.h
#	indra/newview/llface.inl
#	indra/newview/llfloatereditsky.cpp
#	indra/newview/llfloatereditwater.cpp
#	indra/newview/llfloateremojipicker.h
#	indra/newview/llfloaterimsessiontab.cpp
#	indra/newview/llfloaterprofiletexture.cpp
#	indra/newview/llfloaterprofiletexture.h
#	indra/newview/llgesturemgr.cpp
#	indra/newview/llgesturemgr.h
#	indra/newview/llgroupactions.cpp
#	indra/newview/llimpanel.cpp
#	indra/newview/llinventorybridge.cpp
#	indra/newview/llinventorybridge.h
#	indra/newview/llinventoryclipboard.cpp
#	indra/newview/llinventoryclipboard.h
#	indra/newview/llinventoryfunctions.cpp
#	indra/newview/llinventoryfunctions.h
#	indra/newview/llinventorygallery.cpp
#	indra/newview/lllistbrowser.cpp
#	indra/newview/lllistbrowser.h
#	indra/newview/llpaneleditwearable.cpp
#	indra/newview/llpanelobjectinventory.cpp
#	indra/newview/llpanelprofile.cpp
#	indra/newview/llpreviewgesture.cpp
#	indra/newview/llsavedsettingsglue.cpp
#	indra/newview/llsavedsettingsglue.h
#	indra/newview/lltooldraganddrop.cpp
#	indra/newview/llurllineeditorctrl.cpp
#	indra/newview/llvectorperfoptions.cpp
#	indra/newview/llvectorperfoptions.h
#	indra/newview/llviewermenu.cpp
#	indra/newview/llviewerparceloverlay.cpp
#	indra/newview/llviewertexlayer.cpp
#	indra/newview/llviewertexturelist.cpp
#	indra/newview/macmain.h
2024-05-16 14:10:55 +02:00

103 lines
3.6 KiB
C++

/*
* @file fsscriptlibrary.cpp
* @brief Dynamically loaded script library
*
* $LicenseInfo:firstyear=2013&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2013, Cinder Roxley <cinder.roxley@phoenixviewer.com>
*
* This library 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;
* version 2.1 of the License only.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "fsscriptlibrary.h"
#include "lluictrlfactory.h"
#include "llxmlnode.h"
LLScriptLibrary::LLScriptLibrary()
{
}
bool LLScriptLibrary::loadLibrary(const std::string& filename)
{
LLXMLNodePtr xml_root;
if ( (!LLUICtrlFactory::getLayeredXMLNode(filename, xml_root)) || (xml_root.isNull()) || (!xml_root->hasName("script_library")) )
{
LL_WARNS() << "Could not read the script library (" << filename << ")" << LL_ENDL;
return false;
}
LL_INFOS() << "Loading script library at: " << filename << LL_ENDL;
for (LLXMLNode* pNode = xml_root->getFirstChild(); pNode != NULL; pNode = pNode->getNextSibling())
{
if (pNode->hasName("functions"))
{
std::string function;
for (LLXMLNode* pStringNode = pNode->getFirstChild(); pStringNode != NULL; pStringNode = pStringNode->getNextSibling())
{
if (!pStringNode->getAttributeString("name", function) ||
!pStringNode->hasName("function"))
{
continue;
}
bool god_only = false;
std::string tool_tip;
F32 sleep_time;
F32 energy;
if (!pStringNode->getAttributeBOOL("god-only", god_only))
{
god_only = false;
}
if (!pStringNode->getAttributeString("desc", tool_tip))
{
// TODO: Should this be localized? Tooltips aren't translated. <FS:CR>
tool_tip = "No Description available";
}
if (!pStringNode->getAttributeF32("sleep", sleep_time))
{
sleep_time = 0;
}
if (!pStringNode->getAttributeF32("energy", energy))
{
energy = 10;
}
addFunction(function, tool_tip, sleep_time, energy, god_only);
}
}
}
return true;
}
void LLScriptLibrary::addFunction(std::string name, std::string desc, F32 sleep, F32 energy, bool god_only)
{
LLScriptLibraryFunction func(name, desc, sleep, energy, god_only);
mFunctions.push_back(func);
}
LLScriptLibraryFunction::LLScriptLibraryFunction(std::string name, std::string desc, F32 sleep, F32 energy, bool god_only)
: mName(name),
mDesc(desc),
mSleepTime(sleep),
mEnergy(energy),
mGodOnly(god_only)
{
}
LLScriptLibrary gScriptLibrary;