diff options
author | Jacek Antonelli | 2008-08-15 23:45:11 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:11 -0500 |
commit | 215f423cbe18fe9ca14a26caef918d303bad28ff (patch) | |
tree | 0743442b286216cc8e19aa487c26f4e9345ffd64 /linden/indra/newview/llpreviewscript.cpp | |
parent | Second Life viewer sources 1.18.3.5-RC (diff) | |
download | meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.zip meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.gz meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.bz2 meta-impy-215f423cbe18fe9ca14a26caef918d303bad28ff.tar.xz |
Second Life viewer sources 1.18.4.0-RC
Diffstat (limited to 'linden/indra/newview/llpreviewscript.cpp')
-rw-r--r-- | linden/indra/newview/llpreviewscript.cpp | 84 |
1 files changed, 53 insertions, 31 deletions
diff --git a/linden/indra/newview/llpreviewscript.cpp b/linden/indra/newview/llpreviewscript.cpp index cce672b..7eac589 100644 --- a/linden/indra/newview/llpreviewscript.cpp +++ b/linden/indra/newview/llpreviewscript.cpp | |||
@@ -2,6 +2,8 @@ | |||
2 | * @file llpreviewscript.cpp | 2 | * @file llpreviewscript.cpp |
3 | * @brief LLPreviewScript class implementation | 3 | * @brief LLPreviewScript class implementation |
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
6 | * | ||
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | 7 | * Copyright (c) 2002-2007, Linden Research, Inc. |
6 | * | 8 | * |
7 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
@@ -24,6 +26,7 @@ | |||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
26 | * COMPLETENESS OR PERFORMANCE. | 28 | * COMPLETENESS OR PERFORMANCE. |
29 | * $/LicenseInfo$ | ||
27 | */ | 30 | */ |
28 | 31 | ||
29 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
@@ -100,11 +103,8 @@ const char HELLO_LSL[] = | |||
100 | "}\n"; | 103 | "}\n"; |
101 | const char HELP_LSL[] = "lsl_guide.html"; | 104 | const char HELP_LSL[] = "lsl_guide.html"; |
102 | 105 | ||
103 | const char DEFAULT_SCRIPT_NAME[] = "New Script"; | 106 | const char DEFAULT_SCRIPT_NAME[] = "New Script"; // *TODO:Translate? |
104 | const char DEFAULT_SCRIPT_DESC[] = "(No Description)"; | 107 | const char DEFAULT_SCRIPT_DESC[] = "(No Description)"; // *TODO:Translate? |
105 | |||
106 | const char ENABLED_RUNNING_CHECKBOX_LABEL[] = "Running"; | ||
107 | const char DISABLED_RUNNING_CHECKBOX_LABEL[] = "Public Objects cannot run scripts"; | ||
108 | 108 | ||
109 | // Description and header information | 109 | // Description and header information |
110 | 110 | ||
@@ -318,7 +318,6 @@ LLScriptEdCore::LLScriptEdCore( | |||
318 | mFunctions = LLUICtrlFactory::getComboBoxByName(this, "Insert..."); | 318 | mFunctions = LLUICtrlFactory::getComboBoxByName(this, "Insert..."); |
319 | 319 | ||
320 | childSetCommitCallback("Insert...", &LLScriptEdCore::onBtnInsertFunction, this); | 320 | childSetCommitCallback("Insert...", &LLScriptEdCore::onBtnInsertFunction, this); |
321 | mFunctions->setLabel("Insert..."); | ||
322 | 321 | ||
323 | mEditor = LLViewerUICtrlFactory::getViewerTextEditorByName(this, "Script Editor"); | 322 | mEditor = LLViewerUICtrlFactory::getViewerTextEditorByName(this, "Script Editor"); |
324 | mEditor->setReadOnlyBgColor(gColors.getColor( "ScriptBgReadOnlyColor" ) ); | 323 | mEditor->setReadOnlyBgColor(gColors.getColor( "ScriptBgReadOnlyColor" ) ); |
@@ -453,13 +452,13 @@ void LLScriptEdCore::draw() | |||
453 | S32 line = 0; | 452 | S32 line = 0; |
454 | S32 column = 0; | 453 | S32 column = 0; |
455 | mEditor->getCurrentLineAndColumn( &line, &column, FALSE ); // don't include wordwrap | 454 | mEditor->getCurrentLineAndColumn( &line, &column, FALSE ); // don't include wordwrap |
456 | char cursor_pos[STD_STRING_BUF_SIZE]; /*Flawfinder: ignore*/ | 455 | std::string cursor_pos; |
457 | snprintf( cursor_pos, STD_STRING_BUF_SIZE, "Line %d, Column %d", line, column ); /* Flawfinder: ignore */ | 456 | cursor_pos = llformat("Line %d, Column %d", line, column ); |
458 | childSetText("line_col", cursor_pos); | 457 | childSetText("line_col", cursor_pos); |
459 | } | 458 | } |
460 | else | 459 | else |
461 | { | 460 | { |
462 | childSetText("line_col", ""); | 461 | childSetText("line_col", LLString::null); |
463 | } | 462 | } |
464 | 463 | ||
465 | updateDynamicHelp(); | 464 | updateDynamicHelp(); |
@@ -982,7 +981,7 @@ void LLScriptEdCore::handleReloadFromServerDialog( S32 option, void* userdata ) | |||
982 | case 0: // "Yes" | 981 | case 0: // "Yes" |
983 | if( self->mLoadCallback ) | 982 | if( self->mLoadCallback ) |
984 | { | 983 | { |
985 | self->mEditor->setText( "Loading..." ); | 984 | self->mEditor->setText( self->childGetText("loading") ); |
986 | self->mLoadCallback( self->mUserdata ); | 985 | self->mLoadCallback( self->mUserdata ); |
987 | } | 986 | } |
988 | break; | 987 | break; |
@@ -1196,7 +1195,7 @@ void LLPreviewLSL::loadAsset() | |||
1196 | } | 1195 | } |
1197 | else | 1196 | else |
1198 | { | 1197 | { |
1199 | mScriptEd->mEditor->setText("You are not allowed to view this script."); | 1198 | mScriptEd->mEditor->setText(mScriptEd->childGetText("can_not_view")); |
1200 | mScriptEd->mEditor->makePristine(); | 1199 | mScriptEd->mEditor->makePristine(); |
1201 | mScriptEd->mEditor->setEnabled(FALSE); | 1200 | mScriptEd->mEditor->setEnabled(FALSE); |
1202 | mScriptEd->mFunctions->setEnabled(FALSE); | 1201 | mScriptEd->mFunctions->setEnabled(FALSE); |
@@ -1207,7 +1206,7 @@ void LLPreviewLSL::loadAsset() | |||
1207 | } | 1206 | } |
1208 | else | 1207 | else |
1209 | { | 1208 | { |
1210 | mScriptEd->mEditor->setText(HELLO_LSL); | 1209 | mScriptEd->mEditor->setText(LLString(HELLO_LSL)); |
1211 | mAssetStatus = PREVIEW_ASSET_LOADED; | 1210 | mAssetStatus = PREVIEW_ASSET_LOADED; |
1212 | } | 1211 | } |
1213 | } | 1212 | } |
@@ -1514,7 +1513,7 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset | |||
1514 | 1513 | ||
1515 | // put a EOS at the end | 1514 | // put a EOS at the end |
1516 | buffer[file_length] = 0; | 1515 | buffer[file_length] = 0; |
1517 | preview->mScriptEd->mEditor->setText(buffer); | 1516 | preview->mScriptEd->mEditor->setText(LLStringExplicit(buffer)); |
1518 | preview->mScriptEd->mEditor->makePristine(); | 1517 | preview->mScriptEd->mEditor->makePristine(); |
1519 | delete [] buffer; | 1518 | delete [] buffer; |
1520 | LLInventoryItem* item = gInventory.getItem(*item_uuid); | 1519 | LLInventoryItem* item = gInventory.getItem(*item_uuid); |
@@ -1663,7 +1662,6 @@ LLLiveLSLEditor::LLLiveLSLEditor(const std::string& name, | |||
1663 | 1662 | ||
1664 | 1663 | ||
1665 | setTitle(title); | 1664 | setTitle(title); |
1666 | |||
1667 | } | 1665 | } |
1668 | 1666 | ||
1669 | LLLiveLSLEditor::~LLLiveLSLEditor() | 1667 | LLLiveLSLEditor::~LLLiveLSLEditor() |
@@ -1715,9 +1713,8 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) | |||
1715 | { | 1713 | { |
1716 | // HACK! we "know" that mItemID refers to a LLViewerInventoryItem... | 1714 | // HACK! we "know" that mItemID refers to a LLViewerInventoryItem... |
1717 | LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(mItemID); | 1715 | LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(mItemID); |
1718 | if(item | 1716 | if(item |
1719 | && (gAgent.allowOperation(PERM_COPY, item->getPermissions(), | 1717 | && (gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE) |
1720 | GP_OBJECT_MANIPULATE) | ||
1721 | || gAgent.isGodlike())) | 1718 | || gAgent.isGodlike())) |
1722 | { | 1719 | { |
1723 | mItem = new LLViewerInventoryItem(item); | 1720 | mItem = new LLViewerInventoryItem(item); |
@@ -1726,13 +1723,11 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) | |||
1726 | 1723 | ||
1727 | if(!gAgent.isGodlike() | 1724 | if(!gAgent.isGodlike() |
1728 | && (item | 1725 | && (item |
1729 | && (!gAgent.allowOperation(PERM_COPY, item->getPermissions(), | 1726 | && (!gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE) |
1730 | GP_OBJECT_MANIPULATE) | 1727 | || !gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE)))) |
1731 | || !gAgent.allowOperation(PERM_MODIFY, | ||
1732 | item->getPermissions(), GP_OBJECT_MANIPULATE)))) | ||
1733 | |||
1734 | { | 1728 | { |
1735 | mScriptEd->mEditor->setText("You are not allowed to view this script."); | 1729 | mItem = new LLViewerInventoryItem(item); |
1730 | mScriptEd->mEditor->setText(childGetText("not_allowed")); | ||
1736 | mScriptEd->mEditor->makePristine(); | 1731 | mScriptEd->mEditor->makePristine(); |
1737 | mScriptEd->mEditor->setEnabled(FALSE); | 1732 | mScriptEd->mEditor->setEnabled(FALSE); |
1738 | mAssetStatus = PREVIEW_ASSET_LOADED; | 1733 | mAssetStatus = PREVIEW_ASSET_LOADED; |
@@ -1763,7 +1758,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) | |||
1763 | } | 1758 | } |
1764 | else | 1759 | else |
1765 | { | 1760 | { |
1766 | mScriptEd->mEditor->setText(""); | 1761 | mScriptEd->mEditor->setText(LLString::null); |
1767 | mScriptEd->mEditor->makePristine(); | 1762 | mScriptEd->mEditor->makePristine(); |
1768 | mAssetStatus = PREVIEW_ASSET_LOADED; | 1763 | mAssetStatus = PREVIEW_ASSET_LOADED; |
1769 | } | 1764 | } |
@@ -1789,11 +1784,25 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) | |||
1789 | gMessageSystem->sendReliable(host); | 1784 | gMessageSystem->sendReliable(host); |
1790 | */ | 1785 | */ |
1791 | } | 1786 | } |
1787 | |||
1788 | // Initialization of the asset failed. Probably the result | ||
1789 | // of a bug somewhere else. Set up this editor in a no-go mode. | ||
1790 | if(mItem.isNull()) | ||
1791 | { | ||
1792 | // Set the inventory item to an incomplete item. | ||
1793 | // This may be better than having a accessible null pointer around, | ||
1794 | // though this newly allocated object will most likely be replaced. | ||
1795 | mItem = new LLViewerInventoryItem(); | ||
1796 | mScriptEd->mEditor->setText(LLString::null); | ||
1797 | mScriptEd->mEditor->makePristine(); | ||
1798 | mScriptEd->mEditor->setEnabled(FALSE); | ||
1799 | mAssetStatus = PREVIEW_ASSET_LOADED; | ||
1800 | } | ||
1792 | } | 1801 | } |
1793 | else | 1802 | else |
1794 | { | 1803 | { |
1795 | mScriptEd->mEditor->setText(HELLO_LSL); | 1804 | mScriptEd->mEditor->setText(LLString(HELLO_LSL)); |
1796 | //mScriptEd->mEditor->setText(""); | 1805 | //mScriptEd->mEditor->setText(LLString::null); |
1797 | //mScriptEd->mEditor->makePristine(); | 1806 | //mScriptEd->mEditor->makePristine(); |
1798 | LLPermissions perm; | 1807 | LLPermissions perm; |
1799 | perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, gAgent.getGroupID()); | 1808 | perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, gAgent.getGroupID()); |
@@ -1880,7 +1889,7 @@ void LLLiveLSLEditor::loadScriptText(const char* filename) | |||
1880 | } | 1889 | } |
1881 | buffer[nread] = '\0'; | 1890 | buffer[nread] = '\0'; |
1882 | fclose(file); | 1891 | fclose(file); |
1883 | mScriptEd->mEditor->setText(buffer); | 1892 | mScriptEd->mEditor->setText(LLStringExplicit(buffer)); |
1884 | mScriptEd->mEditor->makePristine(); | 1893 | mScriptEd->mEditor->makePristine(); |
1885 | delete[] buffer; | 1894 | delete[] buffer; |
1886 | } | 1895 | } |
@@ -1905,7 +1914,7 @@ void LLLiveLSLEditor::loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType | |||
1905 | 1914 | ||
1906 | buffer[file_length] = '\0'; | 1915 | buffer[file_length] = '\0'; |
1907 | 1916 | ||
1908 | mScriptEd->mEditor->setText(buffer); | 1917 | mScriptEd->mEditor->setText(LLStringExplicit(buffer)); |
1909 | mScriptEd->mEditor->makePristine(); | 1918 | mScriptEd->mEditor->makePristine(); |
1910 | delete[] buffer; | 1919 | delete[] buffer; |
1911 | 1920 | ||
@@ -1972,12 +1981,12 @@ void LLLiveLSLEditor::draw() | |||
1972 | { | 1981 | { |
1973 | if(object->permAnyOwner()) | 1982 | if(object->permAnyOwner()) |
1974 | { | 1983 | { |
1975 | runningCheckbox->setLabel(ENABLED_RUNNING_CHECKBOX_LABEL); | 1984 | runningCheckbox->setLabel(childGetText("script_running")); |
1976 | runningCheckbox->setEnabled(TRUE); | 1985 | runningCheckbox->setEnabled(TRUE); |
1977 | } | 1986 | } |
1978 | else | 1987 | else |
1979 | { | 1988 | { |
1980 | runningCheckbox->setLabel(DISABLED_RUNNING_CHECKBOX_LABEL); | 1989 | runningCheckbox->setLabel(childGetText("public_objects_can_not_run")); |
1981 | runningCheckbox->setEnabled(FALSE); | 1990 | runningCheckbox->setEnabled(FALSE); |
1982 | // *FIX: Set it to false so that the ui is correct for | 1991 | // *FIX: Set it to false so that the ui is correct for |
1983 | // a box that is released to public. It could be | 1992 | // a box that is released to public. It could be |
@@ -2036,6 +2045,14 @@ void LLLiveLSLEditor::saveIfNeeded() | |||
2036 | return; | 2045 | return; |
2037 | } | 2046 | } |
2038 | 2047 | ||
2048 | if(mItem.isNull() || !mItem->isComplete()) | ||
2049 | { | ||
2050 | // $NOTE: While the error message may not be exactly correct, | ||
2051 | // it's pretty close. | ||
2052 | gViewerWindow->alertXml("SaveScriptFailObjectNotFound"); | ||
2053 | return; | ||
2054 | } | ||
2055 | |||
2039 | // get the latest info about it. We used to be losing the script | 2056 | // get the latest info about it. We used to be losing the script |
2040 | // name on save, because the viewer object version of the item, | 2057 | // name on save, because the viewer object version of the item, |
2041 | // and the editor version would get out of synch. Here's a good | 2058 | // and the editor version would get out of synch. Here's a good |
@@ -2217,7 +2234,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, | |||
2217 | 2234 | ||
2218 | // If we successfully saved it, then we should be able to check/uncheck the running box! | 2235 | // If we successfully saved it, then we should be able to check/uncheck the running box! |
2219 | LLCheckBoxCtrl* runningCheckbox = LLUICtrlFactory::getCheckBoxByName(this, "running"); | 2236 | LLCheckBoxCtrl* runningCheckbox = LLUICtrlFactory::getCheckBoxByName(this, "running"); |
2220 | runningCheckbox->setLabel(ENABLED_RUNNING_CHECKBOX_LABEL); | 2237 | runningCheckbox->setLabel(childGetText("script_running")); |
2221 | runningCheckbox->setEnabled(TRUE); | 2238 | runningCheckbox->setEnabled(TRUE); |
2222 | } | 2239 | } |
2223 | 2240 | ||
@@ -2299,6 +2316,11 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use | |||
2299 | delete data; | 2316 | delete data; |
2300 | } | 2317 | } |
2301 | 2318 | ||
2319 | void LLLiveLSLEditor::open() | ||
2320 | { | ||
2321 | LLFloater::open(); /*Flawfinder: ignore*/ | ||
2322 | } | ||
2323 | |||
2302 | BOOL LLLiveLSLEditor::canClose() | 2324 | BOOL LLLiveLSLEditor::canClose() |
2303 | { | 2325 | { |
2304 | return (mScriptEd->canClose()); | 2326 | return (mScriptEd->canClose()); |