STORM-1708 Adding ability to save/load scripts from file.
parent
4bcdcd02fb
commit
b28492fbff
|
|
@ -482,6 +482,7 @@ Ima Mechanique
|
|||
OPEN-76
|
||||
STORM-959
|
||||
STORM-1175
|
||||
STORM-1708
|
||||
Imnotgoing Sideways
|
||||
Inma Rau
|
||||
Innula Zenovka
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ LLFilePicker LLFilePicker::sInstance;
|
|||
#define SLOBJECT_FILTER L"Objects (*.slobject)\0*.slobject\0"
|
||||
#define RAW_FILTER L"RAW files (*.raw)\0*.raw\0"
|
||||
#define MODEL_FILTER L"Model files (*.dae)\0*.dae\0"
|
||||
#define SCRIPT_FILTER L"Script files (*.lsl; *.txt)\0*.lsl;*.txt\0"
|
||||
#endif
|
||||
|
||||
//
|
||||
|
|
@ -213,6 +214,10 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)
|
|||
mOFN.lpstrFilter = MODEL_FILTER \
|
||||
L"\0";
|
||||
break;
|
||||
case FFLOAD_SCRIPT:
|
||||
mOFN.lpstrFilter = SCRIPT_FILTER \
|
||||
L"\0";
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
break;
|
||||
|
|
@ -497,6 +502,16 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename)
|
|||
L"Compressed Images (*.j2c)\0*.j2c\0" \
|
||||
L"\0";
|
||||
break;
|
||||
case FFSAVE_SCRIPT:
|
||||
if (filename.empty())
|
||||
{
|
||||
wcsncpy( mFilesW,L"untitled.lsl", FILENAME_BUFFER_SIZE);
|
||||
}
|
||||
mOFN.lpstrDefExt = L"txt";
|
||||
mOFN.lpstrFilter =
|
||||
L"LSL Files (*.lsl; *.txt)\0*.lsl;*.txt\0"
|
||||
L"\0";
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ public:
|
|||
FFLOAD_RAW = 8,
|
||||
FFLOAD_MODEL = 9,
|
||||
FFLOAD_COLLADA = 10,
|
||||
FFLOAD_SCRIPT = 11,
|
||||
};
|
||||
|
||||
enum ESaveFilter
|
||||
|
|
@ -103,6 +104,7 @@ public:
|
|||
FFSAVE_J2C = 12,
|
||||
FFSAVE_PNG = 13,
|
||||
FFSAVE_JPEG = 14,
|
||||
FFSAVE_SCRIPT = 15,
|
||||
};
|
||||
|
||||
// open the dialog. This is a modal operation
|
||||
|
|
|
|||
|
|
@ -204,3 +204,24 @@ BOOL LLFloaterSoundPreview::postBuild()
|
|||
getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLFloaterScriptPreview()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LLFloaterScriptPreview::LLFloaterScriptPreview(const LLSD& filename )
|
||||
: LLFloaterNameDesc(filename)
|
||||
{
|
||||
mIsAudio = TRUE;
|
||||
}
|
||||
|
||||
BOOL LLFloaterScriptPreview::postBuild()
|
||||
{
|
||||
if (!LLFloaterNameDesc::postBuild())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this));
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ protected:
|
|||
|
||||
protected:
|
||||
BOOL mIsAudio;
|
||||
bool mIsText;
|
||||
|
||||
std::string mFilenameAndPath;
|
||||
std::string mFilename;
|
||||
|
|
@ -62,5 +63,12 @@ public:
|
|||
LLFloaterSoundPreview(const LLSD& filename );
|
||||
virtual BOOL postBuild();
|
||||
};
|
||||
|
||||
|
||||
class LLFloaterScriptPreview : public LLFloaterNameDesc
|
||||
{
|
||||
public:
|
||||
LLFloaterScriptPreview(const LLSD& filename );
|
||||
virtual BOOL postBuild();
|
||||
};
|
||||
|
||||
#endif // LL_LLFLOATERNAMEDESC_H
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include "llcombobox.h"
|
||||
#include "lldir.h"
|
||||
#include "llexternaleditor.h"
|
||||
#include "llfilepicker.h"
|
||||
#include "llfloaterreg.h"
|
||||
#include "llinventorydefines.h"
|
||||
#include "llinventorymodel.h"
|
||||
|
|
@ -89,15 +90,15 @@
|
|||
const std::string HELLO_LSL =
|
||||
"default\n"
|
||||
"{\n"
|
||||
" state_entry()\n"
|
||||
" {\n"
|
||||
" llSay(0, \"Hello, Avatar!\");\n"
|
||||
" }\n"
|
||||
"\tstate_entry()\n"
|
||||
"\t{\n"
|
||||
"\t\tllOwnerSay(\"Hello, Avatar!\");\n"
|
||||
"\t}\n"
|
||||
"\n"
|
||||
" touch_start(integer total_number)\n"
|
||||
" {\n"
|
||||
" llSay(0, \"Touched.\");\n"
|
||||
" }\n"
|
||||
"\ttouch_start(integer total_number)\n"
|
||||
"\t{\n"
|
||||
"\t\tllSay(llDetectedKey(0), \"Touched.\");\n"
|
||||
"\t}\n"
|
||||
"}\n";
|
||||
const std::string HELP_LSL_PORTAL_TOPIC = "LSL_Portal";
|
||||
|
||||
|
|
@ -503,6 +504,14 @@ void LLScriptEdCore::initMenu()
|
|||
|
||||
menuItem = getChild<LLMenuItemCallGL>("Keyword Help...");
|
||||
menuItem->setClickCallback(boost::bind(&LLScriptEdCore::onBtnDynamicHelp, this));
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("LoadFromFile");
|
||||
menuItem->setClickCallback(boost::bind(&LLScriptEdCore::onBtnLoadFromFile, this));
|
||||
// menuItem->setEnabledCallback(NULL);
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("SaveToFile");
|
||||
menuItem->setClickCallback(boost::bind(&LLScriptEdCore::onBtnSaveToFile, this));
|
||||
menuItem->setEnableCallback(boost::bind(&LLScriptEdCore::hasChanged, this));
|
||||
}
|
||||
|
||||
void LLScriptEdCore::setScriptText(const std::string& text, BOOL is_valid)
|
||||
|
|
@ -1096,6 +1105,59 @@ BOOL LLScriptEdCore::handleKeyHere(KEY key, MASK mask)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void LLScriptEdCore::onBtnLoadFromFile( void* data )
|
||||
{
|
||||
|
||||
LLScriptEdCore* self = (LLScriptEdCore*) data;
|
||||
|
||||
LLFilePicker& file_picker = LLFilePicker::instance();
|
||||
if( !file_picker.getOpenFile( LLFilePicker::FFLOAD_SCRIPT ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string filename = file_picker.getFirstFile();
|
||||
|
||||
std::ifstream fin(filename.c_str());
|
||||
|
||||
std::string line;
|
||||
std::string linetotal;
|
||||
self->mEditor->clear();
|
||||
while (!fin.eof())
|
||||
{
|
||||
getline(fin,line);
|
||||
line=line+"\n";
|
||||
self->mEditor->insertText(line);
|
||||
|
||||
}
|
||||
fin.close();
|
||||
}
|
||||
|
||||
void LLScriptEdCore::onBtnSaveToFile( void* userdata )
|
||||
{
|
||||
|
||||
LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT );
|
||||
|
||||
LLScriptEdCore* self = (LLScriptEdCore*) userdata;
|
||||
|
||||
if( self->mSaveCallback )
|
||||
{
|
||||
LLFilePicker& file_picker = LLFilePicker::instance();
|
||||
if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_SCRIPT ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string filename = file_picker.getFirstFile();
|
||||
std::string scriptText=self->mEditor->getText();
|
||||
std::ofstream fout(filename.c_str());
|
||||
fout<<(scriptText);
|
||||
fout.close();
|
||||
self->mSaveCallback( self->mUserdata, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// ---------------------------------------------------------------------------
|
||||
/// LLScriptEdContainer
|
||||
/// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ public:
|
|||
static void onClickForward(void* userdata);
|
||||
static void onBtnInsertSample(void*);
|
||||
static void onBtnInsertFunction(LLUICtrl*, void*);
|
||||
static void onBtnLoadFromFile(void*);
|
||||
static void onBtnSaveToFile(void*);
|
||||
|
||||
virtual bool hasAccelerators() const { return true; }
|
||||
|
||||
|
|
|
|||
|
|
@ -292,9 +292,10 @@ void LLViewerFloaterReg::registerFloaters()
|
|||
LLFloaterUIPreviewUtil::registerFloater();
|
||||
LLFloaterReg::add("upload_anim", "floater_animation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload");
|
||||
LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
|
||||
LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
|
||||
LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
|
||||
LLFloaterReg::add("upload_model_wizard", "floater_model_wizard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelWizard>);
|
||||
LLFloaterReg::add("upload_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptPreview>, "upload");
|
||||
LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
|
||||
|
||||
LLFloaterReg::add("voice_controls", "floater_voice_controls.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLCallFloater>);
|
||||
LLFloaterReg::add("voice_effect", "floater_voice_effect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceEffect>);
|
||||
|
|
|
|||
|
|
@ -87,6 +87,14 @@ class LLFileEnableUpload : public view_listener_t
|
|||
}
|
||||
};
|
||||
|
||||
class LLFileEnableUploadScript : public view_listener_t
|
||||
{
|
||||
bool handleEvent(const LLSD& userdata)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class LLFileEnableUploadModel : public view_listener_t
|
||||
{
|
||||
bool handleEvent(const LLSD& userdata)
|
||||
|
|
@ -391,6 +399,20 @@ class LLFileUploadAnim : public view_listener_t
|
|||
}
|
||||
};
|
||||
|
||||
class LLFileUploadScript : public view_listener_t
|
||||
{
|
||||
bool handleEvent(const LLSD& userdata)
|
||||
{
|
||||
const std::string filename = upload_pick((void*)LLFilePicker::FFLOAD_SCRIPT);
|
||||
if (!filename.empty())
|
||||
{
|
||||
LLFloaterReg::showInstance("upload_script", LLSD(filename));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class LLFileUploadBulk : public view_listener_t
|
||||
{
|
||||
bool handleEvent(const LLSD& userdata)
|
||||
|
|
|
|||
|
|
@ -1101,7 +1101,20 @@
|
|||
<menu_item_call.on_visible
|
||||
function="File.VisibleUploadModel"/>
|
||||
</menu_item_call>
|
||||
<menu_item_call
|
||||
<menu_item_call
|
||||
label="Script (L$ 0)..."
|
||||
layout="topleft"
|
||||
name="Upload Script">
|
||||
<menu_item_call.on_click
|
||||
function="File.UploadScript"
|
||||
parameter="" />
|
||||
<menu_item_call.on_enable
|
||||
function="File.EnableUploadScript" />
|
||||
<!--menu_item_call.on_visible
|
||||
function="Upload.CalculateCosts"
|
||||
parameter="Upload Script" /-->
|
||||
</menu_item_call>
|
||||
<menu_item_call
|
||||
label="Bulk (L$[COST] per file)..."
|
||||
layout="topleft"
|
||||
name="Bulk Upload">
|
||||
|
|
|
|||
|
|
@ -54,12 +54,22 @@
|
|||
label="Save"
|
||||
layout="topleft"
|
||||
name="Save" />
|
||||
<menu_item_separator
|
||||
layout="topleft" />
|
||||
<menu_item_call
|
||||
label="Revert All Changes"
|
||||
layout="topleft"
|
||||
name="Revert All Changes" />
|
||||
<menu_item_separator
|
||||
layout="topleft" />
|
||||
<menu_item_call
|
||||
label="Revert All Changes"
|
||||
layout="topleft"
|
||||
name="Revert All Changes" />
|
||||
<menu_item_separator
|
||||
layout="topleft" />
|
||||
<menu_item_call
|
||||
label="Load from file..."
|
||||
layout="topleft"
|
||||
name="LoadFromFile" />
|
||||
<menu_item_call
|
||||
label="Save to file..."
|
||||
layout="topleft"
|
||||
name="SaveToFile" />
|
||||
</menu>
|
||||
<menu
|
||||
top="0"
|
||||
|
|
|
|||
Loading…
Reference in New Issue