diff options
Diffstat (limited to 'linden/indra/newview/llpreviewscript.cpp')
-rw-r--r-- | linden/indra/newview/llpreviewscript.cpp | 305 |
1 files changed, 188 insertions, 117 deletions
diff --git a/linden/indra/newview/llpreviewscript.cpp b/linden/indra/newview/llpreviewscript.cpp index 9ef711d..52fca27 100644 --- a/linden/indra/newview/llpreviewscript.cpp +++ b/linden/indra/newview/llpreviewscript.cpp | |||
@@ -88,7 +88,7 @@ | |||
88 | #include "llpanelinventory.h" | 88 | #include "llpanelinventory.h" |
89 | 89 | ||
90 | 90 | ||
91 | const char HELLO_LSL[] = | 91 | const std::string HELLO_LSL = |
92 | "default\n" | 92 | "default\n" |
93 | "{\n" | 93 | "{\n" |
94 | " state_entry()\n" | 94 | " state_entry()\n" |
@@ -101,10 +101,10 @@ const char HELLO_LSL[] = | |||
101 | " llSay(0, \"Touched.\");\n" | 101 | " llSay(0, \"Touched.\");\n" |
102 | " }\n" | 102 | " }\n" |
103 | "}\n"; | 103 | "}\n"; |
104 | const char HELP_LSL[] = "lsl_guide.html"; | 104 | const std::string HELP_LSL = "lsl_guide.html"; |
105 | 105 | ||
106 | const char DEFAULT_SCRIPT_NAME[] = "New Script"; // *TODO:Translate? | 106 | const std::string DEFAULT_SCRIPT_NAME = "New Script"; // *TODO:Translate? |
107 | const char DEFAULT_SCRIPT_DESC[] = "(No Description)"; // *TODO:Translate? | 107 | const std::string DEFAULT_SCRIPT_DESC = "(No Description)"; // *TODO:Translate? |
108 | 108 | ||
109 | // Description and header information | 109 | // Description and header information |
110 | 110 | ||
@@ -139,6 +139,12 @@ const S32 TEXT_EDIT_COLUMN_HEIGHT = 16; | |||
139 | const S32 MAX_HISTORY_COUNT = 10; | 139 | const S32 MAX_HISTORY_COUNT = 10; |
140 | const F32 LIVE_HELP_REFRESH_TIME = 1.f; | 140 | const F32 LIVE_HELP_REFRESH_TIME = 1.f; |
141 | 141 | ||
142 | static bool have_script_upload_cap(LLUUID& object_id) | ||
143 | { | ||
144 | LLViewerObject* object = gObjectList.findObject(object_id); | ||
145 | return object && (! object->getRegion()->getCapability("UpdateScriptTask").empty()); | ||
146 | } | ||
147 | |||
142 | /// --------------------------------------------------------------------------- | 148 | /// --------------------------------------------------------------------------- |
143 | /// LLFloaterScriptSearch | 149 | /// LLFloaterScriptSearch |
144 | /// --------------------------------------------------------------------------- | 150 | /// --------------------------------------------------------------------------- |
@@ -173,7 +179,7 @@ private: | |||
173 | LLFloaterScriptSearch* LLFloaterScriptSearch::sInstance = NULL; | 179 | LLFloaterScriptSearch* LLFloaterScriptSearch::sInstance = NULL; |
174 | 180 | ||
175 | LLFloaterScriptSearch::LLFloaterScriptSearch(std::string title, LLRect rect, LLScriptEdCore* editor_core) | 181 | LLFloaterScriptSearch::LLFloaterScriptSearch(std::string title, LLRect rect, LLScriptEdCore* editor_core) |
176 | : LLFloater("script search",rect,title), mEditorCore(editor_core) | 182 | : LLFloater("script search",rect,title), mEditorCore(editor_core) |
177 | { | 183 | { |
178 | 184 | ||
179 | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_search.xml"); | 185 | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_search.xml"); |
@@ -296,7 +302,7 @@ LLScriptEdCore::LLScriptEdCore( | |||
296 | void* userdata, | 302 | void* userdata, |
297 | S32 bottom_pad) | 303 | S32 bottom_pad) |
298 | : | 304 | : |
299 | LLPanel( "name", rect ), | 305 | LLPanel( std::string("name"), rect ), |
300 | mSampleText(sample), | 306 | mSampleText(sample), |
301 | mHelpFile ( help ), | 307 | mHelpFile ( help ), |
302 | mEditor( NULL ), | 308 | mEditor( NULL ), |
@@ -306,14 +312,15 @@ LLScriptEdCore::LLScriptEdCore( | |||
306 | mUserdata( userdata ), | 312 | mUserdata( userdata ), |
307 | mForceClose( FALSE ), | 313 | mForceClose( FALSE ), |
308 | mLastHelpToken(NULL), | 314 | mLastHelpToken(NULL), |
309 | mLiveHelpHistorySize(0) | 315 | mLiveHelpHistorySize(0), |
316 | mEnableSave(FALSE) | ||
310 | { | 317 | { |
311 | setFollowsAll(); | 318 | setFollowsAll(); |
312 | setBorderVisible(FALSE); | 319 | setBorderVisible(FALSE); |
313 | 320 | ||
314 | 321 | ||
315 | LLUICtrlFactory::getInstance()->buildPanel(this, "floater_script_ed_panel.xml"); | 322 | LLUICtrlFactory::getInstance()->buildPanel(this, "floater_script_ed_panel.xml"); |
316 | 323 | ||
317 | mErrorList = getChild<LLScrollListCtrl>("lsl errors"); | 324 | mErrorList = getChild<LLScrollListCtrl>("lsl errors"); |
318 | 325 | ||
319 | mFunctions = getChild<LLComboBox>( "Insert..."); | 326 | mFunctions = getChild<LLComboBox>( "Insert..."); |
@@ -326,15 +333,15 @@ LLScriptEdCore::LLScriptEdCore( | |||
326 | mEditor->setEnabled(TRUE); | 333 | mEditor->setEnabled(TRUE); |
327 | mEditor->setWordWrap(TRUE); | 334 | mEditor->setWordWrap(TRUE); |
328 | 335 | ||
329 | LLDynamicArray<const char*> funcs; | 336 | std::vector<std::string> funcs; |
330 | LLDynamicArray<const char*> tooltips; | 337 | std::vector<std::string> tooltips; |
331 | for (S32 i = 0; i < gScriptLibrary.mNextNumber; i++) | 338 | for (S32 i = 0; i < gScriptLibrary.mNextNumber; i++) |
332 | { | 339 | { |
333 | // Make sure this isn't a god only function, or the agent is a god. | 340 | // Make sure this isn't a god only function, or the agent is a god. |
334 | if (!gScriptLibrary.mFunctions[i]->mGodOnly || gAgent.isGodlike()) | 341 | if (!gScriptLibrary.mFunctions[i]->mGodOnly || gAgent.isGodlike()) |
335 | { | 342 | { |
336 | funcs.put(gScriptLibrary.mFunctions[i]->mName); | 343 | funcs.push_back(ll_safe_string(gScriptLibrary.mFunctions[i]->mName)); |
337 | tooltips.put(gScriptLibrary.mFunctions[i]->mDesc); | 344 | tooltips.push_back(ll_safe_string(gScriptLibrary.mFunctions[i]->mDesc)); |
338 | } | 345 | } |
339 | } | 346 | } |
340 | LLColor3 color(0.5f, 0.0f, 0.15f); | 347 | LLColor3 color(0.5f, 0.0f, 0.15f); |
@@ -439,13 +446,13 @@ BOOL LLScriptEdCore::hasChanged(void* userdata) | |||
439 | LLScriptEdCore* self = (LLScriptEdCore*)userdata; | 446 | LLScriptEdCore* self = (LLScriptEdCore*)userdata; |
440 | if (!self || !self->mEditor) return FALSE; | 447 | if (!self || !self->mEditor) return FALSE; |
441 | 448 | ||
442 | return !self->mEditor->isPristine(); | 449 | return !self->mEditor->isPristine() || self->mEnableSave; |
443 | } | 450 | } |
444 | 451 | ||
445 | void LLScriptEdCore::draw() | 452 | void LLScriptEdCore::draw() |
446 | { | 453 | { |
447 | BOOL script_changed = !mEditor->isPristine(); | 454 | BOOL script_changed = hasChanged(this); |
448 | childSetEnabled("Save_btn", script_changed); | 455 | childSetEnabled("Save_btn", script_changed); |
449 | 456 | ||
450 | if( mEditor->hasFocus() ) | 457 | if( mEditor->hasFocus() ) |
451 | { | 458 | { |
@@ -458,7 +465,7 @@ void LLScriptEdCore::draw() | |||
458 | } | 465 | } |
459 | else | 466 | else |
460 | { | 467 | { |
461 | childSetText("line_col", LLString::null); | 468 | childSetText("line_col", LLStringUtil::null); |
462 | } | 469 | } |
463 | 470 | ||
464 | updateDynamicHelp(); | 471 | updateDynamicHelp(); |
@@ -517,18 +524,18 @@ void LLScriptEdCore::updateDynamicHelp(BOOL immediate) | |||
517 | } | 524 | } |
518 | if (immediate || (mLiveHelpTimer.getStarted() && mLiveHelpTimer.getElapsedTimeF32() > LIVE_HELP_REFRESH_TIME)) | 525 | if (immediate || (mLiveHelpTimer.getStarted() && mLiveHelpTimer.getElapsedTimeF32() > LIVE_HELP_REFRESH_TIME)) |
519 | { | 526 | { |
520 | LLString help_string = mEditor->getText().substr(segment->getStart(), segment->getEnd() - segment->getStart()); | 527 | std::string help_string = mEditor->getText().substr(segment->getStart(), segment->getEnd() - segment->getStart()); |
521 | setHelpPage(help_string); | 528 | setHelpPage(help_string); |
522 | mLiveHelpTimer.stop(); | 529 | mLiveHelpTimer.stop(); |
523 | } | 530 | } |
524 | } | 531 | } |
525 | else if (immediate) | 532 | else if (immediate) |
526 | { | 533 | { |
527 | setHelpPage(""); | 534 | setHelpPage(LLStringUtil::null); |
528 | } | 535 | } |
529 | } | 536 | } |
530 | 537 | ||
531 | void LLScriptEdCore::setHelpPage(const LLString& help_string) | 538 | void LLScriptEdCore::setHelpPage(const std::string& help_string) |
532 | { | 539 | { |
533 | LLFloater* help_floater = mLiveHelpHandle.get(); | 540 | LLFloater* help_floater = mLiveHelpHandle.get(); |
534 | if (!help_floater) return; | 541 | if (!help_floater) return; |
@@ -549,7 +556,7 @@ void LLScriptEdCore::setHelpPage(const LLString& help_string) | |||
549 | 556 | ||
550 | } | 557 | } |
551 | 558 | ||
552 | void LLScriptEdCore::addHelpItemToHistory(const LLString& help_string) | 559 | void LLScriptEdCore::addHelpItemToHistory(const std::string& help_string) |
553 | { | 560 | { |
554 | if (help_string.empty()) return; | 561 | if (help_string.empty()) return; |
555 | 562 | ||
@@ -594,7 +601,7 @@ void LLScriptEdCore::addHelpItemToHistory(const LLString& help_string) | |||
594 | 601 | ||
595 | BOOL LLScriptEdCore::canClose() | 602 | BOOL LLScriptEdCore::canClose() |
596 | { | 603 | { |
597 | if(mForceClose || mEditor->isPristine()) | 604 | if(mForceClose || !hasChanged(this)) |
598 | { | 605 | { |
599 | return TRUE; | 606 | return TRUE; |
600 | } | 607 | } |
@@ -640,7 +647,7 @@ void LLScriptEdCore::onHelpWebDialog(S32 option, void* userdata) | |||
640 | switch(option) | 647 | switch(option) |
641 | { | 648 | { |
642 | case 0: | 649 | case 0: |
643 | load_url_local_file(corep->mHelpFile.c_str()); | 650 | load_url_local_file(corep->mHelpFile); |
644 | break; | 651 | break; |
645 | default: | 652 | default: |
646 | break; | 653 | break; |
@@ -669,7 +676,7 @@ void LLScriptEdCore::onBtnDynamicHelp(void* userdata) | |||
669 | return; | 676 | return; |
670 | } | 677 | } |
671 | 678 | ||
672 | live_help_floater = new LLFloater("lsl_help"); | 679 | live_help_floater = new LLFloater(std::string("lsl_help")); |
673 | LLUICtrlFactory::getInstance()->buildFloater(live_help_floater, "floater_lsl_guide.xml"); | 680 | LLUICtrlFactory::getInstance()->buildFloater(live_help_floater, "floater_lsl_guide.xml"); |
674 | ((LLFloater*)corep->getParent())->addDependentFloater(live_help_floater, TRUE); | 681 | ((LLFloater*)corep->getParent())->addDependentFloater(live_help_floater, TRUE); |
675 | live_help_floater->childSetCommitCallback("lock_check", onCheckLock, userdata); | 682 | live_help_floater->childSetCommitCallback("lock_check", onCheckLock, userdata); |
@@ -760,7 +767,7 @@ void LLScriptEdCore::onHelpComboCommit(LLUICtrl* ctrl, void* userdata) | |||
760 | LLFloater* live_help_floater = corep->mLiveHelpHandle.get(); | 767 | LLFloater* live_help_floater = corep->mLiveHelpHandle.get(); |
761 | if (live_help_floater) | 768 | if (live_help_floater) |
762 | { | 769 | { |
763 | LLString help_string = ctrl->getValue().asString(); | 770 | std::string help_string = ctrl->getValue().asString(); |
764 | 771 | ||
765 | corep->addHelpItemToHistory(help_string); | 772 | corep->addHelpItemToHistory(help_string); |
766 | 773 | ||
@@ -947,10 +954,10 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data) | |||
947 | S32 row = 0; | 954 | S32 row = 0; |
948 | S32 column = 0; | 955 | S32 column = 0; |
949 | const LLScrollListCell* cell = item->getColumn(0); | 956 | const LLScrollListCell* cell = item->getColumn(0); |
950 | LLString line(cell->getValue().asString()); | 957 | std::string line(cell->getValue().asString()); |
951 | line.erase(0, 1); | 958 | line.erase(0, 1); |
952 | LLString::replaceChar(line, ',',' '); | 959 | LLStringUtil::replaceChar(line, ',',' '); |
953 | LLString::replaceChar(line, ')',' '); | 960 | LLStringUtil::replaceChar(line, ')',' '); |
954 | sscanf(line.c_str(), "%d %d", &row, &column); | 961 | sscanf(line.c_str(), "%d %d", &row, &column); |
955 | //llinfos << "LLScriptEdCore::onErrorList() - " << row << ", " | 962 | //llinfos << "LLScriptEdCore::onErrorList() - " << row << ", " |
956 | //<< column << llendl; | 963 | //<< column << llendl; |
@@ -1047,10 +1054,10 @@ BOOL LLScriptEdCore::handleKeyHere(KEY key, MASK mask) | |||
1047 | struct LLScriptSaveInfo | 1054 | struct LLScriptSaveInfo |
1048 | { | 1055 | { |
1049 | LLUUID mItemUUID; | 1056 | LLUUID mItemUUID; |
1050 | LLString mDescription; | 1057 | std::string mDescription; |
1051 | LLTransactionID mTransactionID; | 1058 | LLTransactionID mTransactionID; |
1052 | 1059 | ||
1053 | LLScriptSaveInfo(const LLUUID& uuid, const LLString& desc, LLTransactionID tid) : | 1060 | LLScriptSaveInfo(const LLUUID& uuid, const std::string& desc, LLTransactionID tid) : |
1054 | mItemUUID(uuid), mDescription(desc), mTransactionID(tid) {} | 1061 | mItemUUID(uuid), mDescription(desc), mTransactionID(tid) {} |
1055 | }; | 1062 | }; |
1056 | 1063 | ||
@@ -1117,8 +1124,9 @@ LLPreviewLSL::LLPreviewLSL(const std::string& name, const LLRect& rect, | |||
1117 | void LLPreviewLSL::callbackLSLCompileSucceeded() | 1124 | void LLPreviewLSL::callbackLSLCompileSucceeded() |
1118 | { | 1125 | { |
1119 | llinfos << "LSL Bytecode saved" << llendl; | 1126 | llinfos << "LSL Bytecode saved" << llendl; |
1120 | mScriptEd->mErrorList->addCommentText("Compile successful!"); | 1127 | // *TODO: Translate |
1121 | mScriptEd->mErrorList->addCommentText("Save complete."); | 1128 | mScriptEd->mErrorList->addCommentText(std::string("Compile successful!")); |
1129 | mScriptEd->mErrorList->addCommentText(std::string("Save complete.")); | ||
1122 | closeIfNeeded(); | 1130 | closeIfNeeded(); |
1123 | } | 1131 | } |
1124 | 1132 | ||
@@ -1132,7 +1140,9 @@ void LLPreviewLSL::callbackLSLCompileFailed(const LLSD& compile_errors) | |||
1132 | line++) | 1140 | line++) |
1133 | { | 1141 | { |
1134 | LLSD row; | 1142 | LLSD row; |
1135 | row["columns"][0]["value"] = line->asString(); | 1143 | std::string error_message = line->asString(); |
1144 | LLStringUtil::stripNonprintable(error_message); | ||
1145 | row["columns"][0]["value"] = error_message; | ||
1136 | row["columns"][0]["font"] = "OCRA"; | 1146 | row["columns"][0]["font"] = "OCRA"; |
1137 | mScriptEd->mErrorList->addElement(row); | 1147 | mScriptEd->mErrorList->addElement(row); |
1138 | } | 1148 | } |
@@ -1189,7 +1199,7 @@ void LLPreviewLSL::loadAsset() | |||
1189 | } | 1199 | } |
1190 | else | 1200 | else |
1191 | { | 1201 | { |
1192 | mScriptEd->mEditor->setText(LLString(HELLO_LSL)); | 1202 | mScriptEd->mEditor->setText(std::string(HELLO_LSL)); |
1193 | mAssetStatus = PREVIEW_ASSET_LOADED; | 1203 | mAssetStatus = PREVIEW_ASSET_LOADED; |
1194 | } | 1204 | } |
1195 | } | 1205 | } |
@@ -1246,7 +1256,7 @@ void LLPreviewLSL::onSave(void* userdata, BOOL close_after_save) | |||
1246 | void LLPreviewLSL::saveIfNeeded() | 1256 | void LLPreviewLSL::saveIfNeeded() |
1247 | { | 1257 | { |
1248 | // llinfos << "LLPreviewLSL::saveIfNeeded()" << llendl; | 1258 | // llinfos << "LLPreviewLSL::saveIfNeeded()" << llendl; |
1249 | if(mScriptEd->mEditor->isPristine()) | 1259 | if(!LLScriptEdCore::hasChanged(mScriptEd)) |
1250 | { | 1260 | { |
1251 | return; | 1261 | return; |
1252 | } | 1262 | } |
@@ -1260,9 +1270,9 @@ void LLPreviewLSL::saveIfNeeded() | |||
1260 | tid.generate(); | 1270 | tid.generate(); |
1261 | LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); | 1271 | LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); |
1262 | std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString()); | 1272 | std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString()); |
1263 | std::string filename = llformat("%s.lsl", filepath.c_str()); | 1273 | std::string filename = filepath + ".lsl"; |
1264 | 1274 | ||
1265 | LLFILE* fp = LLFile::fopen(filename.c_str(), "wb"); | 1275 | LLFILE* fp = LLFile::fopen(filename, "wb"); |
1266 | if(!fp) | 1276 | if(!fp) |
1267 | { | 1277 | { |
1268 | llwarns << "Unable to write to " << filename << llendl; | 1278 | llwarns << "Unable to write to " << filename << llendl; |
@@ -1274,14 +1284,14 @@ void LLPreviewLSL::saveIfNeeded() | |||
1274 | return; | 1284 | return; |
1275 | } | 1285 | } |
1276 | 1286 | ||
1277 | LLString utf8text = mScriptEd->mEditor->getText(); | 1287 | std::string utf8text = mScriptEd->mEditor->getText(); |
1278 | fputs(utf8text.c_str(), fp); | 1288 | fputs(utf8text.c_str(), fp); |
1279 | fclose(fp); | 1289 | fclose(fp); |
1280 | fp = NULL; | 1290 | fp = NULL; |
1281 | 1291 | ||
1282 | const LLInventoryItem *inv_item = getItem(); | 1292 | const LLInventoryItem *inv_item = getItem(); |
1283 | // save it out to asset server | 1293 | // save it out to asset server |
1284 | std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgentInventory"); | 1294 | std::string url = gAgent.getRegion()->getCapability("UpdateScriptAgent"); |
1285 | if(inv_item) | 1295 | if(inv_item) |
1286 | { | 1296 | { |
1287 | getWindow()->incBusyCount(); | 1297 | getWindow()->incBusyCount(); |
@@ -1304,7 +1314,8 @@ void LLPreviewLSL::uploadAssetViaCaps(const std::string& url, | |||
1304 | llinfos << "Update Agent Inventory via capability" << llendl; | 1314 | llinfos << "Update Agent Inventory via capability" << llendl; |
1305 | LLSD body; | 1315 | LLSD body; |
1306 | body["item_id"] = item_id; | 1316 | body["item_id"] = item_id; |
1307 | LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename)); | 1317 | body["target"] = "lsl2"; |
1318 | LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); | ||
1308 | } | 1319 | } |
1309 | 1320 | ||
1310 | void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, | 1321 | void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, |
@@ -1315,7 +1326,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, | |||
1315 | LLScriptSaveInfo* info = new LLScriptSaveInfo(item_id, | 1326 | LLScriptSaveInfo* info = new LLScriptSaveInfo(item_id, |
1316 | descEditor->getText(), | 1327 | descEditor->getText(), |
1317 | tid); | 1328 | tid); |
1318 | gAssetStorage->storeAssetData(filename.c_str(), tid, | 1329 | gAssetStorage->storeAssetData(filename, tid, |
1319 | LLAssetType::AT_LSL_TEXT, | 1330 | LLAssetType::AT_LSL_TEXT, |
1320 | &LLPreviewLSL::onSaveComplete, | 1331 | &LLPreviewLSL::onSaveComplete, |
1321 | info); | 1332 | info); |
@@ -1325,22 +1336,25 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, | |||
1325 | std::string dst_filename = llformat("%s.lso", filepath.c_str()); | 1336 | std::string dst_filename = llformat("%s.lso", filepath.c_str()); |
1326 | std::string err_filename = llformat("%s.out", filepath.c_str()); | 1337 | std::string err_filename = llformat("%s.out", filepath.c_str()); |
1327 | 1338 | ||
1339 | const BOOL compile_to_mono = FALSE; | ||
1328 | if(!lscript_compile(filename.c_str(), | 1340 | if(!lscript_compile(filename.c_str(), |
1329 | dst_filename.c_str(), | 1341 | dst_filename.c_str(), |
1330 | err_filename.c_str(), | 1342 | err_filename.c_str(), |
1343 | compile_to_mono, | ||
1344 | asset_id.asString().c_str(), | ||
1331 | gAgent.isGodlike())) | 1345 | gAgent.isGodlike())) |
1332 | { | 1346 | { |
1333 | llinfos << "Compile failed!" << llendl; | 1347 | llinfos << "Compile failed!" << llendl; |
1334 | //char command[256]; | 1348 | //char command[256]; |
1335 | //sprintf(command, "type %s\n", err_filename); | 1349 | //sprintf(command, "type %s\n", err_filename.c_str()); |
1336 | //system(command); | 1350 | //system(command); |
1337 | 1351 | ||
1338 | // load the error file into the error scrolllist | 1352 | // load the error file into the error scrolllist |
1339 | LLFILE* fp = LLFile::fopen(err_filename.c_str(), "r"); | 1353 | LLFILE* fp = LLFile::fopen(err_filename, "r"); |
1340 | if(fp) | 1354 | if(fp) |
1341 | { | 1355 | { |
1342 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ | 1356 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ |
1343 | LLString line; | 1357 | std::string line; |
1344 | while(!feof(fp)) | 1358 | while(!feof(fp)) |
1345 | { | 1359 | { |
1346 | if (fgets(buffer, MAX_STRING, fp) == NULL) | 1360 | if (fgets(buffer, MAX_STRING, fp) == NULL) |
@@ -1354,7 +1368,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, | |||
1354 | else | 1368 | else |
1355 | { | 1369 | { |
1356 | line.assign(buffer); | 1370 | line.assign(buffer); |
1357 | LLString::stripNonprintable(line); | 1371 | LLStringUtil::stripNonprintable(line); |
1358 | 1372 | ||
1359 | LLSD row; | 1373 | LLSD row; |
1360 | row["columns"][0]["value"] = line; | 1374 | row["columns"][0]["value"] = line; |
@@ -1374,7 +1388,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, | |||
1374 | getWindow()->incBusyCount(); | 1388 | getWindow()->incBusyCount(); |
1375 | mPendingUploads++; | 1389 | mPendingUploads++; |
1376 | LLUUID* this_uuid = new LLUUID(mItemUUID); | 1390 | LLUUID* this_uuid = new LLUUID(mItemUUID); |
1377 | gAssetStorage->storeAssetData(dst_filename.c_str(), | 1391 | gAssetStorage->storeAssetData(dst_filename, |
1378 | tid, | 1392 | tid, |
1379 | LLAssetType::AT_LSL_BYTECODE, | 1393 | LLAssetType::AT_LSL_BYTECODE, |
1380 | &LLPreviewLSL::onSaveBytecodeComplete, | 1394 | &LLPreviewLSL::onSaveBytecodeComplete, |
@@ -1383,9 +1397,9 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, | |||
1383 | } | 1397 | } |
1384 | 1398 | ||
1385 | // get rid of any temp files left lying around | 1399 | // get rid of any temp files left lying around |
1386 | LLFile::remove(filename.c_str()); | 1400 | LLFile::remove(filename); |
1387 | LLFile::remove(err_filename.c_str()); | 1401 | LLFile::remove(err_filename); |
1388 | LLFile::remove(dst_filename.c_str()); | 1402 | LLFile::remove(dst_filename); |
1389 | } | 1403 | } |
1390 | 1404 | ||
1391 | 1405 | ||
@@ -1431,7 +1445,7 @@ void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 | |||
1431 | else | 1445 | else |
1432 | { | 1446 | { |
1433 | llwarns << "Problem saving script: " << status << llendl; | 1447 | llwarns << "Problem saving script: " << status << llendl; |
1434 | LLStringBase<char>::format_map_t args; | 1448 | LLStringUtil::format_map_t args; |
1435 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); | 1449 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); |
1436 | gViewerWindow->alertXml("SaveScriptFailReason", args); | 1450 | gViewerWindow->alertXml("SaveScriptFailReason", args); |
1437 | } | 1451 | } |
@@ -1469,7 +1483,7 @@ void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_d | |||
1469 | else | 1483 | else |
1470 | { | 1484 | { |
1471 | llwarns << "Problem saving LSL Bytecode (Preview)" << llendl; | 1485 | llwarns << "Problem saving LSL Bytecode (Preview)" << llendl; |
1472 | LLStringBase<char>::format_map_t args; | 1486 | LLStringUtil::format_map_t args; |
1473 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); | 1487 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); |
1474 | gViewerWindow->alertXml("SaveBytecodeFailReason", args); | 1488 | gViewerWindow->alertXml("SaveBytecodeFailReason", args); |
1475 | } | 1489 | } |
@@ -1600,7 +1614,8 @@ LLLiveLSLEditor::LLLiveLSLEditor(const std::string& name, | |||
1600 | mAskedForRunningInfo(FALSE), | 1614 | mAskedForRunningInfo(FALSE), |
1601 | mHaveRunningInfo(FALSE), | 1615 | mHaveRunningInfo(FALSE), |
1602 | mCloseAfterSave(FALSE), | 1616 | mCloseAfterSave(FALSE), |
1603 | mPendingUploads(0) | 1617 | mPendingUploads(0), |
1618 | mIsModifiable(FALSE) | ||
1604 | { | 1619 | { |
1605 | 1620 | ||
1606 | 1621 | ||
@@ -1614,13 +1629,14 @@ LLLiveLSLEditor::LLLiveLSLEditor(const std::string& name, | |||
1614 | 1629 | ||
1615 | LLLiveLSLEditor::sInstances.addData(mItemID ^ mObjectID, this); | 1630 | LLLiveLSLEditor::sInstances.addData(mItemID ^ mObjectID, this); |
1616 | 1631 | ||
1617 | |||
1618 | |||
1619 | LLCallbackMap::map_t factory_map; | 1632 | LLCallbackMap::map_t factory_map; |
1620 | factory_map["script ed panel"] = LLCallbackMap(LLLiveLSLEditor::createScriptEdPanel, this); | 1633 | factory_map["script ed panel"] = LLCallbackMap(LLLiveLSLEditor::createScriptEdPanel, this); |
1621 | 1634 | ||
1622 | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_live_lsleditor.xml", &factory_map); | 1635 | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_live_lsleditor.xml", &factory_map); |
1623 | 1636 | ||
1637 | mMonoCheckbox = getChild<LLCheckBoxCtrl>("mono"); | ||
1638 | childSetCommitCallback("mono", &LLLiveLSLEditor::onMonoCheckboxClicked, this); | ||
1639 | childSetEnabled("mono", FALSE); | ||
1624 | 1640 | ||
1625 | childSetCommitCallback("running", LLLiveLSLEditor::onRunningCheckboxClicked, this); | 1641 | childSetCommitCallback("running", LLLiveLSLEditor::onRunningCheckboxClicked, this); |
1626 | childSetEnabled("running", FALSE); | 1642 | childSetEnabled("running", FALSE); |
@@ -1632,7 +1648,6 @@ LLLiveLSLEditor::LLLiveLSLEditor(const std::string& name, | |||
1632 | mScriptEd->mEditor->makePristine(); | 1648 | mScriptEd->mEditor->makePristine(); |
1633 | loadAsset(is_new); | 1649 | loadAsset(is_new); |
1634 | mScriptEd->mEditor->setFocus(TRUE); | 1650 | mScriptEd->mEditor->setFocus(TRUE); |
1635 | |||
1636 | 1651 | ||
1637 | if (!getHost()) | 1652 | if (!getHost()) |
1638 | { | 1653 | { |
@@ -1661,8 +1676,9 @@ void LLLiveLSLEditor::callbackLSLCompileSucceeded(const LLUUID& task_id, | |||
1661 | bool is_script_running) | 1676 | bool is_script_running) |
1662 | { | 1677 | { |
1663 | lldebugs << "LSL Bytecode saved" << llendl; | 1678 | lldebugs << "LSL Bytecode saved" << llendl; |
1664 | mScriptEd->mErrorList->addCommentText("Compile successful!"); | 1679 | // *TODO: Translate |
1665 | mScriptEd->mErrorList->addCommentText("Save complete."); | 1680 | mScriptEd->mErrorList->addCommentText(std::string("Compile successful!")); |
1681 | mScriptEd->mErrorList->addCommentText(std::string("Save complete.")); | ||
1666 | closeIfNeeded(); | 1682 | closeIfNeeded(); |
1667 | } | 1683 | } |
1668 | 1684 | ||
@@ -1675,7 +1691,9 @@ void LLLiveLSLEditor::callbackLSLCompileFailed(const LLSD& compile_errors) | |||
1675 | line++) | 1691 | line++) |
1676 | { | 1692 | { |
1677 | LLSD row; | 1693 | LLSD row; |
1678 | row["columns"][0]["value"] = line->asString(); | 1694 | std::string error_message = line->asString(); |
1695 | LLStringUtil::stripNonprintable(error_message); | ||
1696 | row["columns"][0]["value"] = error_message; | ||
1679 | row["columns"][0]["font"] = "OCRA"; | 1697 | row["columns"][0]["font"] = "OCRA"; |
1680 | mScriptEd->mErrorList->addElement(row); | 1698 | mScriptEd->mErrorList->addElement(row); |
1681 | } | 1699 | } |
@@ -1710,6 +1728,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) | |||
1710 | mScriptEd->mEditor->setText(getString("not_allowed")); | 1728 | mScriptEd->mEditor->setText(getString("not_allowed")); |
1711 | mScriptEd->mEditor->makePristine(); | 1729 | mScriptEd->mEditor->makePristine(); |
1712 | mScriptEd->mEditor->setEnabled(FALSE); | 1730 | mScriptEd->mEditor->setEnabled(FALSE); |
1731 | mScriptEd->enableSave(FALSE); | ||
1713 | mAssetStatus = PREVIEW_ASSET_LOADED; | 1732 | mAssetStatus = PREVIEW_ASSET_LOADED; |
1714 | } | 1733 | } |
1715 | else if(item && mItem.notNull()) | 1734 | else if(item && mItem.notNull()) |
@@ -1738,17 +1757,19 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) | |||
1738 | } | 1757 | } |
1739 | else | 1758 | else |
1740 | { | 1759 | { |
1741 | mScriptEd->mEditor->setText(LLString::null); | 1760 | mScriptEd->mEditor->setText(LLStringUtil::null); |
1742 | mScriptEd->mEditor->makePristine(); | 1761 | mScriptEd->mEditor->makePristine(); |
1743 | mAssetStatus = PREVIEW_ASSET_LOADED; | 1762 | mAssetStatus = PREVIEW_ASSET_LOADED; |
1744 | } | 1763 | } |
1745 | 1764 | ||
1746 | if(item | 1765 | mIsModifiable = item && gAgent.allowOperation(PERM_MODIFY, |
1747 | && !gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), | 1766 | item->getPermissions(), |
1748 | GP_OBJECT_MANIPULATE)) | 1767 | GP_OBJECT_MANIPULATE); |
1768 | if(!mIsModifiable) | ||
1749 | { | 1769 | { |
1750 | mScriptEd->mEditor->setEnabled(FALSE); | 1770 | mScriptEd->mEditor->setEnabled(FALSE); |
1751 | } | 1771 | } |
1772 | |||
1752 | // This is commented out, because we don't completely | 1773 | // This is commented out, because we don't completely |
1753 | // handle script exports yet. | 1774 | // handle script exports yet. |
1754 | /* | 1775 | /* |
@@ -1773,7 +1794,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) | |||
1773 | // This may be better than having a accessible null pointer around, | 1794 | // This may be better than having a accessible null pointer around, |
1774 | // though this newly allocated object will most likely be replaced. | 1795 | // though this newly allocated object will most likely be replaced. |
1775 | mItem = new LLViewerInventoryItem(); | 1796 | mItem = new LLViewerInventoryItem(); |
1776 | mScriptEd->mEditor->setText(LLString::null); | 1797 | mScriptEd->mEditor->setText(LLStringUtil::null); |
1777 | mScriptEd->mEditor->makePristine(); | 1798 | mScriptEd->mEditor->makePristine(); |
1778 | mScriptEd->mEditor->setEnabled(FALSE); | 1799 | mScriptEd->mEditor->setEnabled(FALSE); |
1779 | mAssetStatus = PREVIEW_ASSET_LOADED; | 1800 | mAssetStatus = PREVIEW_ASSET_LOADED; |
@@ -1781,9 +1802,8 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) | |||
1781 | } | 1802 | } |
1782 | else | 1803 | else |
1783 | { | 1804 | { |
1784 | mScriptEd->mEditor->setText(LLString(HELLO_LSL)); | 1805 | mScriptEd->mEditor->setText(std::string(HELLO_LSL)); |
1785 | //mScriptEd->mEditor->setText(LLString::null); | 1806 | mScriptEd->enableSave(FALSE); |
1786 | //mScriptEd->mEditor->makePristine(); | ||
1787 | LLPermissions perm; | 1807 | LLPermissions perm; |
1788 | perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, gAgent.getGroupID()); | 1808 | perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, gAgent.getGroupID()); |
1789 | perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); | 1809 | perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); |
@@ -1844,37 +1864,38 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id, | |||
1844 | delete xored_id; | 1864 | delete xored_id; |
1845 | } | 1865 | } |
1846 | 1866 | ||
1847 | void LLLiveLSLEditor::loadScriptText(const char* filename) | 1867 | // unused |
1848 | { | 1868 | // void LLLiveLSLEditor::loadScriptText(const std::string& filename) |
1849 | if(!filename) | 1869 | // { |
1850 | { | 1870 | // if(!filename) |
1851 | llerrs << "Filename is Empty!" << llendl; | 1871 | // { |
1852 | return; | 1872 | // llerrs << "Filename is Empty!" << llendl; |
1853 | } | 1873 | // return; |
1854 | LLFILE* file = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ | 1874 | // } |
1855 | if(file) | 1875 | // LLFILE* file = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ |
1856 | { | 1876 | // if(file) |
1857 | // read in the whole file | 1877 | // { |
1858 | fseek(file, 0L, SEEK_END); | 1878 | // // read in the whole file |
1859 | long file_length = ftell(file); | 1879 | // fseek(file, 0L, SEEK_END); |
1860 | fseek(file, 0L, SEEK_SET); | 1880 | // long file_length = ftell(file); |
1861 | char* buffer = new char[file_length+1]; | 1881 | // fseek(file, 0L, SEEK_SET); |
1862 | size_t nread = fread(buffer, 1, file_length, file); | 1882 | // char* buffer = new char[file_length+1]; |
1863 | if (nread < (size_t) file_length) | 1883 | // size_t nread = fread(buffer, 1, file_length, file); |
1864 | { | 1884 | // if (nread < (size_t) file_length) |
1865 | llwarns << "Short read" << llendl; | 1885 | // { |
1866 | } | 1886 | // llwarns << "Short read" << llendl; |
1867 | buffer[nread] = '\0'; | 1887 | // } |
1868 | fclose(file); | 1888 | // buffer[nread] = '\0'; |
1869 | mScriptEd->mEditor->setText(LLStringExplicit(buffer)); | 1889 | // fclose(file); |
1870 | mScriptEd->mEditor->makePristine(); | 1890 | // mScriptEd->mEditor->setText(LLStringExplicit(buffer)); |
1871 | delete[] buffer; | 1891 | // mScriptEd->mEditor->makePristine(); |
1872 | } | 1892 | // delete[] buffer; |
1873 | else | 1893 | // } |
1874 | { | 1894 | // else |
1875 | llwarns << "Error opening " << filename << llendl; | 1895 | // { |
1876 | } | 1896 | // llwarns << "Error opening " << filename << llendl; |
1877 | } | 1897 | // } |
1898 | // } | ||
1878 | 1899 | ||
1879 | void LLLiveLSLEditor::loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type) | 1900 | void LLLiveLSLEditor::loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type) |
1880 | { | 1901 | { |
@@ -1952,29 +1973,51 @@ void LLLiveLSLEditor::draw() | |||
1952 | { | 1973 | { |
1953 | LLViewerObject* object = gObjectList.findObject(mObjectID); | 1974 | LLViewerObject* object = gObjectList.findObject(mObjectID); |
1954 | LLCheckBoxCtrl* runningCheckbox = getChild<LLCheckBoxCtrl>( "running"); | 1975 | LLCheckBoxCtrl* runningCheckbox = getChild<LLCheckBoxCtrl>( "running"); |
1955 | if(object && mAskedForRunningInfo && mHaveRunningInfo) | 1976 | if(object && mAskedForRunningInfo && mHaveRunningInfo) |
1956 | { | 1977 | { |
1957 | if(object->permAnyOwner()) | 1978 | if(object->permAnyOwner()) |
1958 | { | 1979 | { |
1959 | runningCheckbox->setLabel(getString("script_running")); | 1980 | runningCheckbox->setLabel(getString("script_running")); |
1960 | runningCheckbox->setEnabled(TRUE); | 1981 | runningCheckbox->setEnabled(TRUE); |
1982 | |||
1983 | if(object->permAnyOwner()) | ||
1984 | { | ||
1985 | runningCheckbox->setLabel(getString("script_running")); | ||
1986 | runningCheckbox->setEnabled(TRUE); | ||
1987 | } | ||
1988 | else | ||
1989 | { | ||
1990 | runningCheckbox->setLabel(getString("public_objects_can_not_run")); | ||
1991 | runningCheckbox->setEnabled(FALSE); | ||
1992 | // *FIX: Set it to false so that the ui is correct for | ||
1993 | // a box that is released to public. It could be | ||
1994 | // incorrect after a release/claim cycle, but will be | ||
1995 | // correct after clicking on it. | ||
1996 | runningCheckbox->set(FALSE); | ||
1997 | mMonoCheckbox->set(FALSE); | ||
1998 | } | ||
1961 | } | 1999 | } |
1962 | else | 2000 | else |
1963 | { | 2001 | { |
1964 | runningCheckbox->setLabel(getString("public_objects_can_not_run")); | 2002 | runningCheckbox->setLabel(getString("public_objects_can_not_run")); |
1965 | runningCheckbox->setEnabled(FALSE); | 2003 | runningCheckbox->setEnabled(FALSE); |
2004 | |||
1966 | // *FIX: Set it to false so that the ui is correct for | 2005 | // *FIX: Set it to false so that the ui is correct for |
1967 | // a box that is released to public. It could be | 2006 | // a box that is released to public. It could be |
1968 | // incorrect after a release/claim cycle, but will be | 2007 | // incorrect after a release/claim cycle, but will be |
1969 | // correct after clicking on it. | 2008 | // correct after clicking on it. |
1970 | runningCheckbox->set(FALSE); | 2009 | runningCheckbox->set(FALSE); |
2010 | mMonoCheckbox->setEnabled(FALSE); | ||
2011 | // object may have fallen out of range. | ||
2012 | mHaveRunningInfo = FALSE; | ||
1971 | } | 2013 | } |
1972 | } | 2014 | } |
1973 | else if(!object) | 2015 | else if(!object) |
1974 | { | 2016 | { |
1975 | // HACK: Display this information in the title bar. | 2017 | // HACK: Display this information in the title bar. |
1976 | // Really ought to put in main window. | 2018 | // Really ought to put in main window. |
1977 | setTitle("Script (object out of range)"); | 2019 | // *TODO: Translate |
2020 | setTitle(std::string("Script (object out of range)")); | ||
1978 | runningCheckbox->setEnabled(FALSE); | 2021 | runningCheckbox->setEnabled(FALSE); |
1979 | // object may have fallen out of range. | 2022 | // object may have fallen out of range. |
1980 | mHaveRunningInfo = FALSE; | 2023 | mHaveRunningInfo = FALSE; |
@@ -2040,7 +2083,7 @@ void LLLiveLSLEditor::saveIfNeeded() | |||
2040 | } | 2083 | } |
2041 | 2084 | ||
2042 | // Don't need to save if we're pristine | 2085 | // Don't need to save if we're pristine |
2043 | if(mScriptEd->mEditor->isPristine()) | 2086 | if(!LLScriptEdCore::hasChanged(mScriptEd)) |
2044 | { | 2087 | { |
2045 | return; | 2088 | return; |
2046 | } | 2089 | } |
@@ -2048,6 +2091,7 @@ void LLLiveLSLEditor::saveIfNeeded() | |||
2048 | mPendingUploads = 0; | 2091 | mPendingUploads = 0; |
2049 | 2092 | ||
2050 | // save the script | 2093 | // save the script |
2094 | mScriptEd->enableSave(FALSE); | ||
2051 | mScriptEd->mEditor->makePristine(); | 2095 | mScriptEd->mEditor->makePristine(); |
2052 | mScriptEd->mErrorList->deleteAllItems(); | 2096 | mScriptEd->mErrorList->deleteAllItems(); |
2053 | 2097 | ||
@@ -2063,7 +2107,7 @@ void LLLiveLSLEditor::saveIfNeeded() | |||
2063 | mItem->setTransactionID(tid); | 2107 | mItem->setTransactionID(tid); |
2064 | 2108 | ||
2065 | // write out the data, and store it in the asset database | 2109 | // write out the data, and store it in the asset database |
2066 | LLFILE* fp = LLFile::fopen(filename.c_str(), "wb"); | 2110 | LLFILE* fp = LLFile::fopen(filename, "wb"); |
2067 | if(!fp) | 2111 | if(!fp) |
2068 | { | 2112 | { |
2069 | llwarns << "Unable to write to " << filename << llendl; | 2113 | llwarns << "Unable to write to " << filename << llendl; |
@@ -2074,7 +2118,7 @@ void LLLiveLSLEditor::saveIfNeeded() | |||
2074 | mScriptEd->mErrorList->addElement(row); | 2118 | mScriptEd->mErrorList->addElement(row); |
2075 | return; | 2119 | return; |
2076 | } | 2120 | } |
2077 | LLString utf8text = mScriptEd->mEditor->getText(); | 2121 | std::string utf8text = mScriptEd->mEditor->getText(); |
2078 | 2122 | ||
2079 | // Special case for a completely empty script - stuff in one space so it can store properly. See SL-46889 | 2123 | // Special case for a completely empty script - stuff in one space so it can store properly. See SL-46889 |
2080 | if ( utf8text.size() == 0 ) | 2124 | if ( utf8text.size() == 0 ) |
@@ -2087,7 +2131,7 @@ void LLLiveLSLEditor::saveIfNeeded() | |||
2087 | fp = NULL; | 2131 | fp = NULL; |
2088 | 2132 | ||
2089 | // save it out to asset server | 2133 | // save it out to asset server |
2090 | std::string url = gAgent.getRegion()->getCapability("UpdateScriptTaskInventory"); | 2134 | std::string url = object->getRegion()->getCapability("UpdateScriptTask"); |
2091 | getWindow()->incBusyCount(); | 2135 | getWindow()->incBusyCount(); |
2092 | mPendingUploads++; | 2136 | mPendingUploads++; |
2093 | BOOL is_running = getChild<LLCheckBoxCtrl>( "running")->get(); | 2137 | BOOL is_running = getChild<LLCheckBoxCtrl>( "running")->get(); |
@@ -2113,8 +2157,9 @@ void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url, | |||
2113 | body["task_id"] = task_id; | 2157 | body["task_id"] = task_id; |
2114 | body["item_id"] = item_id; | 2158 | body["item_id"] = item_id; |
2115 | body["is_script_running"] = is_running; | 2159 | body["is_script_running"] = is_running; |
2160 | body["target"] = monoChecked() ? "mono" : "lsl2"; | ||
2116 | LLHTTPClient::post(url, body, | 2161 | LLHTTPClient::post(url, body, |
2117 | new LLUpdateTaskInventoryResponder(body, filename)); | 2162 | new LLUpdateTaskInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); |
2118 | } | 2163 | } |
2119 | 2164 | ||
2120 | void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, | 2165 | void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, |
@@ -2125,7 +2170,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, | |||
2125 | LLLiveLSLSaveData* data = new LLLiveLSLSaveData(mObjectID, | 2170 | LLLiveLSLSaveData* data = new LLLiveLSLSaveData(mObjectID, |
2126 | mItem, | 2171 | mItem, |
2127 | is_running); | 2172 | is_running); |
2128 | gAssetStorage->storeAssetData(filename.c_str(), tid, | 2173 | gAssetStorage->storeAssetData(filename, tid, |
2129 | LLAssetType::AT_LSL_TEXT, | 2174 | LLAssetType::AT_LSL_TEXT, |
2130 | &onSaveTextComplete, | 2175 | &onSaveTextComplete, |
2131 | (void*)data, | 2176 | (void*)data, |
@@ -2137,17 +2182,20 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, | |||
2137 | std::string err_filename = llformat("%s.out", filepath.c_str()); | 2182 | std::string err_filename = llformat("%s.out", filepath.c_str()); |
2138 | 2183 | ||
2139 | LLFILE *fp; | 2184 | LLFILE *fp; |
2185 | const BOOL compile_to_mono = FALSE; | ||
2140 | if(!lscript_compile(filename.c_str(), | 2186 | if(!lscript_compile(filename.c_str(), |
2141 | dst_filename.c_str(), | 2187 | dst_filename.c_str(), |
2142 | err_filename.c_str(), | 2188 | err_filename.c_str(), |
2189 | compile_to_mono, | ||
2190 | asset_id.asString().c_str(), | ||
2143 | gAgent.isGodlike())) | 2191 | gAgent.isGodlike())) |
2144 | { | 2192 | { |
2145 | // load the error file into the error scrolllist | 2193 | // load the error file into the error scrolllist |
2146 | llinfos << "Compile failed!" << llendl; | 2194 | llinfos << "Compile failed!" << llendl; |
2147 | if(NULL != (fp = LLFile::fopen(err_filename.c_str(), "r"))) | 2195 | if(NULL != (fp = LLFile::fopen(err_filename, "r"))) |
2148 | { | 2196 | { |
2149 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ | 2197 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ |
2150 | LLString line; | 2198 | std::string line; |
2151 | while(!feof(fp)) | 2199 | while(!feof(fp)) |
2152 | { | 2200 | { |
2153 | 2201 | ||
@@ -2162,7 +2210,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, | |||
2162 | else | 2210 | else |
2163 | { | 2211 | { |
2164 | line.assign(buffer); | 2212 | line.assign(buffer); |
2165 | LLString::stripNonprintable(line); | 2213 | LLStringUtil::stripNonprintable(line); |
2166 | 2214 | ||
2167 | LLSD row; | 2215 | LLSD row; |
2168 | row["columns"][0]["value"] = line; | 2216 | row["columns"][0]["value"] = line; |
@@ -2182,7 +2230,8 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, | |||
2182 | else | 2230 | else |
2183 | { | 2231 | { |
2184 | llinfos << "Compile worked!" << llendl; | 2232 | llinfos << "Compile worked!" << llendl; |
2185 | mScriptEd->mErrorList->addCommentText("Compile successful, saving..."); | 2233 | // *TODO: Translate |
2234 | mScriptEd->mErrorList->addCommentText(std::string("Compile successful, saving...")); | ||
2186 | if(gAssetStorage) | 2235 | if(gAssetStorage) |
2187 | { | 2236 | { |
2188 | llinfos << "LLLiveLSLEditor::saveAsset " | 2237 | llinfos << "LLLiveLSLEditor::saveAsset " |
@@ -2193,7 +2242,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, | |||
2193 | data = new LLLiveLSLSaveData(mObjectID, | 2242 | data = new LLLiveLSLSaveData(mObjectID, |
2194 | mItem, | 2243 | mItem, |
2195 | is_running); | 2244 | is_running); |
2196 | gAssetStorage->storeAssetData(dst_filename.c_str(), | 2245 | gAssetStorage->storeAssetData(dst_filename, |
2197 | tid, | 2246 | tid, |
2198 | LLAssetType::AT_LSL_BYTECODE, | 2247 | LLAssetType::AT_LSL_BYTECODE, |
2199 | &LLLiveLSLEditor::onSaveBytecodeComplete, | 2248 | &LLLiveLSLEditor::onSaveBytecodeComplete, |
@@ -2203,9 +2252,9 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, | |||
2203 | } | 2252 | } |
2204 | 2253 | ||
2205 | // get rid of any temp files left lying around | 2254 | // get rid of any temp files left lying around |
2206 | LLFile::remove(filename.c_str()); | 2255 | LLFile::remove(filename); |
2207 | LLFile::remove(err_filename.c_str()); | 2256 | LLFile::remove(err_filename); |
2208 | LLFile::remove(dst_filename.c_str()); | 2257 | LLFile::remove(dst_filename); |
2209 | 2258 | ||
2210 | // If we successfully saved it, then we should be able to check/uncheck the running box! | 2259 | // If we successfully saved it, then we should be able to check/uncheck the running box! |
2211 | LLCheckBoxCtrl* runningCheckbox = getChild<LLCheckBoxCtrl>( "running"); | 2260 | LLCheckBoxCtrl* runningCheckbox = getChild<LLCheckBoxCtrl>( "running"); |
@@ -2220,7 +2269,7 @@ void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_da | |||
2220 | if (status) | 2269 | if (status) |
2221 | { | 2270 | { |
2222 | llwarns << "Unable to save text for a script." << llendl; | 2271 | llwarns << "Unable to save text for a script." << llendl; |
2223 | LLStringBase<char>::format_map_t args; | 2272 | LLStringUtil::format_map_t args; |
2224 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); | 2273 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); |
2225 | gViewerWindow->alertXml("CompileQueueSaveText", args); | 2274 | gViewerWindow->alertXml("CompileQueueSaveText", args); |
2226 | } | 2275 | } |
@@ -2256,7 +2305,8 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use | |||
2256 | if(self) | 2305 | if(self) |
2257 | { | 2306 | { |
2258 | // Tell the user that the compile worked. | 2307 | // Tell the user that the compile worked. |
2259 | self->mScriptEd->mErrorList->addCommentText("Save complete."); | 2308 | // *TODO: Translate |
2309 | self->mScriptEd->mErrorList->addCommentText(std::string("Save complete.")); | ||
2260 | // close the window if this completes both uploads | 2310 | // close the window if this completes both uploads |
2261 | self->getWindow()->decBusyCount(); | 2311 | self->getWindow()->decBusyCount(); |
2262 | self->mPendingUploads--; | 2312 | self->mPendingUploads--; |
@@ -2280,14 +2330,14 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use | |||
2280 | llinfos << "Problem saving LSL Bytecode (Live Editor)" << llendl; | 2330 | llinfos << "Problem saving LSL Bytecode (Live Editor)" << llendl; |
2281 | llwarns << "Unable to save a compiled script." << llendl; | 2331 | llwarns << "Unable to save a compiled script." << llendl; |
2282 | 2332 | ||
2283 | LLStringBase<char>::format_map_t args; | 2333 | LLStringUtil::format_map_t args; |
2284 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); | 2334 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); |
2285 | gViewerWindow->alertXml("CompileQueueSaveBytecode", args); | 2335 | gViewerWindow->alertXml("CompileQueueSaveBytecode", args); |
2286 | } | 2336 | } |
2287 | 2337 | ||
2288 | std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_uuid.asString()); | 2338 | std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_uuid.asString()); |
2289 | std::string dst_filename = llformat("%s.lso", filepath.c_str()); | 2339 | std::string dst_filename = llformat("%s.lso", filepath.c_str()); |
2290 | LLFile::remove(dst_filename.c_str()); | 2340 | LLFile::remove(dst_filename); |
2291 | delete data; | 2341 | delete data; |
2292 | } | 2342 | } |
2293 | 2343 | ||
@@ -2378,6 +2428,11 @@ void LLLiveLSLEditor::processScriptRunningReply(LLMessageSystem* msg, void**) | |||
2378 | msg->getBOOLFast(_PREHASH_Script, _PREHASH_Running, running); | 2428 | msg->getBOOLFast(_PREHASH_Script, _PREHASH_Running, running); |
2379 | LLCheckBoxCtrl* runningCheckbox = instance->getChild<LLCheckBoxCtrl>("running"); | 2429 | LLCheckBoxCtrl* runningCheckbox = instance->getChild<LLCheckBoxCtrl>("running"); |
2380 | runningCheckbox->set(running); | 2430 | runningCheckbox->set(running); |
2431 | BOOL mono; | ||
2432 | msg->getBOOLFast(_PREHASH_Script, "Mono", mono); | ||
2433 | LLCheckBoxCtrl* monoCheckbox = instance->getChild<LLCheckBoxCtrl>("mono"); | ||
2434 | monoCheckbox->setEnabled(instance->getIsModifiable() && have_script_upload_cap(object_id)); | ||
2435 | monoCheckbox->set(mono); | ||
2381 | } | 2436 | } |
2382 | } | 2437 | } |
2383 | 2438 | ||
@@ -2392,3 +2447,19 @@ void LLLiveLSLEditor::reshape(S32 width, S32 height, BOOL called_from_parent) | |||
2392 | gSavedSettings.setRect("PreviewScriptRect", getRect()); | 2447 | gSavedSettings.setRect("PreviewScriptRect", getRect()); |
2393 | } | 2448 | } |
2394 | } | 2449 | } |
2450 | |||
2451 | void LLLiveLSLEditor::onMonoCheckboxClicked(LLUICtrl*, void* userdata) | ||
2452 | { | ||
2453 | LLLiveLSLEditor* self = static_cast<LLLiveLSLEditor*>(userdata); | ||
2454 | self->mMonoCheckbox->setEnabled(have_script_upload_cap(self->mObjectID)); | ||
2455 | self->mScriptEd->enableSave(self->getIsModifiable()); | ||
2456 | } | ||
2457 | |||
2458 | BOOL LLLiveLSLEditor::monoChecked() const | ||
2459 | { | ||
2460 | if(NULL != mMonoCheckbox) | ||
2461 | { | ||
2462 | return mMonoCheckbox->getValue()? TRUE : FALSE; | ||
2463 | } | ||
2464 | return FALSE; | ||
2465 | } | ||