aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llpreviewscript.cpp')
-rw-r--r--linden/indra/newview/llpreviewscript.cpp98
1 files changed, 43 insertions, 55 deletions
diff --git a/linden/indra/newview/llpreviewscript.cpp b/linden/indra/newview/llpreviewscript.cpp
index 3e2a476..e9a0b4a 100644
--- a/linden/indra/newview/llpreviewscript.cpp
+++ b/linden/indra/newview/llpreviewscript.cpp
@@ -288,7 +288,7 @@ LLScriptEdCore::LLScriptEdCore(
288 const LLRect& rect, 288 const LLRect& rect,
289 const std::string& sample, 289 const std::string& sample,
290 const std::string& help, 290 const std::string& help,
291 const LLViewHandle& floater_handle, 291 const LLHandle<LLFloater>& floater_handle,
292 void (*load_callback)(void*), 292 void (*load_callback)(void*),
293 void (*save_callback)(void*, BOOL), 293 void (*save_callback)(void*, BOOL),
294 void (*search_replace_callback) (void* userdata), 294 void (*search_replace_callback) (void* userdata),
@@ -343,19 +343,19 @@ LLScriptEdCore::LLScriptEdCore(
343 343
344 344
345 LLKeywordToken *token; 345 LLKeywordToken *token;
346 LLKeywords::word_token_map_t::iterator token_it; 346 LLKeywords::keyword_iterator_t token_it;
347 for (token_it = mEditor->mKeywords.mWordTokenMap.begin(); token_it != mEditor->mKeywords.mWordTokenMap.end(); ++token_it) 347 for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it)
348 { 348 {
349 token = token_it->second; 349 token = token_it->second;
350 if (token->mColor == color) 350 if (token->getColor() == color)
351 mFunctions->add(wstring_to_utf8str(token->mToken)); 351 mFunctions->add(wstring_to_utf8str(token->getToken()));
352 } 352 }
353 353
354 for (token_it = mEditor->mKeywords.mWordTokenMap.begin(); token_it != mEditor->mKeywords.mWordTokenMap.end(); ++token_it) 354 for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it)
355 { 355 {
356 token = token_it->second; 356 token = token_it->second;
357 if (token->mColor != color) 357 if (token->getColor() != color)
358 mFunctions->add(wstring_to_utf8str(token->mToken)); 358 mFunctions->add(wstring_to_utf8str(token->getToken()));
359 } 359 }
360 360
361 361
@@ -365,7 +365,7 @@ LLScriptEdCore::LLScriptEdCore(
365 initMenu(); 365 initMenu();
366 366
367 // Do the work that addTabPanel() normally does. 367 // Do the work that addTabPanel() normally does.
368 //LLRect tab_panel_rect( 0, mRect.getHeight(), mRect.getWidth(), 0 ); 368 //LLRect tab_panel_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 );
369 //tab_panel_rect.stretch( -LLPANEL_BORDER_WIDTH ); 369 //tab_panel_rect.stretch( -LLPANEL_BORDER_WIDTH );
370 //mCodePanel->setFollowsAll(); 370 //mCodePanel->setFollowsAll();
371 //mCodePanel->translate( tab_panel_rect.mLeft - mCodePanel->getRect().mLeft, tab_panel_rect.mBottom - mCodePanel->getRect().mBottom); 371 //mCodePanel->translate( tab_panel_rect.mLeft - mCodePanel->getRect().mLeft, tab_panel_rect.mBottom - mCodePanel->getRect().mBottom);
@@ -468,29 +468,27 @@ void LLScriptEdCore::draw()
468 468
469void LLScriptEdCore::updateDynamicHelp(BOOL immediate) 469void LLScriptEdCore::updateDynamicHelp(BOOL immediate)
470{ 470{
471 LLFloater* help_floater = LLFloater::getFloaterByHandle(mLiveHelpHandle); 471 LLFloater* help_floater = mLiveHelpHandle.get();
472 if (!help_floater) return; 472 if (!help_floater) return;
473 473
474#if LL_LIBXUL_ENABLED
475 // update back and forward buttons 474 // update back and forward buttons
476 LLButton* fwd_button = LLUICtrlFactory::getButtonByName(help_floater, "fwd_btn"); 475 LLButton* fwd_button = LLUICtrlFactory::getButtonByName(help_floater, "fwd_btn");
477 LLButton* back_button = LLUICtrlFactory::getButtonByName(help_floater, "back_btn"); 476 LLButton* back_button = LLUICtrlFactory::getButtonByName(help_floater, "back_btn");
478 LLWebBrowserCtrl* browser = LLUICtrlFactory::getWebBrowserCtrlByName(help_floater, "lsl_guide_html"); 477 LLWebBrowserCtrl* browser = help_floater->getChild<LLWebBrowserCtrl>("lsl_guide_html");
479 back_button->setEnabled(browser->canNavigateBack()); 478 back_button->setEnabled(browser->canNavigateBack());
480 fwd_button->setEnabled(browser->canNavigateForward()); 479 fwd_button->setEnabled(browser->canNavigateForward());
481#endif // LL_LIBXUL_ENABLED
482 480
483 if (!immediate && !gSavedSettings.getBOOL("ScriptHelpFollowsCursor")) 481 if (!immediate && !gSavedSettings.getBOOL("ScriptHelpFollowsCursor"))
484 { 482 {
485 return; 483 return;
486 } 484 }
487 485
488 LLTextSegment* segment = NULL; 486 const LLTextSegment* segment = NULL;
489 std::vector<LLTextSegment*> selected_segments; 487 std::vector<const LLTextSegment*> selected_segments;
490 mEditor->getSelectedSegments(selected_segments); 488 mEditor->getSelectedSegments(selected_segments);
491 489
492 // try segments in selection range first 490 // try segments in selection range first
493 std::vector<LLTextSegment*>::iterator segment_iter; 491 std::vector<const LLTextSegment*>::iterator segment_iter;
494 for (segment_iter = selected_segments.begin(); segment_iter != selected_segments.end(); ++segment_iter) 492 for (segment_iter = selected_segments.begin(); segment_iter != selected_segments.end(); ++segment_iter)
495 { 493 {
496 if((*segment_iter)->getToken() && (*segment_iter)->getToken()->getType() == LLKeywordToken::WORD) 494 if((*segment_iter)->getToken() && (*segment_iter)->getToken()->getType() == LLKeywordToken::WORD)
@@ -503,7 +501,7 @@ void LLScriptEdCore::updateDynamicHelp(BOOL immediate)
503 // then try previous segment in case we just typed it 501 // then try previous segment in case we just typed it
504 if (!segment) 502 if (!segment)
505 { 503 {
506 LLTextSegment* test_segment = mEditor->getPreviousSegment(); 504 const LLTextSegment* test_segment = mEditor->getPreviousSegment();
507 if(test_segment->getToken() && test_segment->getToken()->getType() == LLKeywordToken::WORD) 505 if(test_segment->getToken() && test_segment->getToken()->getType() == LLKeywordToken::WORD)
508 { 506 {
509 segment = test_segment; 507 segment = test_segment;
@@ -532,10 +530,10 @@ void LLScriptEdCore::updateDynamicHelp(BOOL immediate)
532 530
533void LLScriptEdCore::setHelpPage(const LLString& help_string) 531void LLScriptEdCore::setHelpPage(const LLString& help_string)
534{ 532{
535 LLFloater* help_floater = LLFloater::getFloaterByHandle(mLiveHelpHandle); 533 LLFloater* help_floater = mLiveHelpHandle.get();
536 if (!help_floater) return; 534 if (!help_floater) return;
537 535
538 LLWebBrowserCtrl* web_browser = gUICtrlFactory->getWebBrowserCtrlByName(help_floater, "lsl_guide_html"); 536 LLWebBrowserCtrl* web_browser = help_floater->getChild<LLWebBrowserCtrl>("lsl_guide_html");
539 if (!web_browser) return; 537 if (!web_browser) return;
540 538
541 LLComboBox* history_combo = gUICtrlFactory->getComboBoxByName(help_floater, "history_combo"); 539 LLComboBox* history_combo = gUICtrlFactory->getComboBoxByName(help_floater, "history_combo");
@@ -546,16 +544,16 @@ void LLScriptEdCore::setHelpPage(const LLString& help_string)
546 url_string.setArg("[LSL_STRING]", help_string); 544 url_string.setArg("[LSL_STRING]", help_string);
547 545
548 addHelpItemToHistory(help_string); 546 addHelpItemToHistory(help_string);
549#if LL_LIBXUL_ENABLED 547
550 web_browser->navigateTo(url_string); 548 web_browser->navigateTo(url_string);
551#endif // LL_LIBXUL_ENABLED 549
552} 550}
553 551
554void LLScriptEdCore::addHelpItemToHistory(const LLString& help_string) 552void LLScriptEdCore::addHelpItemToHistory(const LLString& help_string)
555{ 553{
556 if (help_string.empty()) return; 554 if (help_string.empty()) return;
557 555
558 LLFloater* help_floater = LLFloater::getFloaterByHandle(mLiveHelpHandle); 556 LLFloater* help_floater = mLiveHelpHandle.get();
559 if (!help_floater) return; 557 if (!help_floater) return;
560 558
561 LLComboBox* history_combo = gUICtrlFactory->getComboBoxByName(help_floater, "history_combo"); 559 LLComboBox* history_combo = gUICtrlFactory->getComboBoxByName(help_floater, "history_combo");
@@ -662,7 +660,7 @@ void LLScriptEdCore::onBtnDynamicHelp(void* userdata)
662{ 660{
663 LLScriptEdCore* corep = (LLScriptEdCore*)userdata; 661 LLScriptEdCore* corep = (LLScriptEdCore*)userdata;
664 662
665 LLFloater* live_help_floater = LLFloater::getFloaterByHandle(corep->mLiveHelpHandle); 663 LLFloater* live_help_floater = corep->mLiveHelpHandle.get();
666 if (live_help_floater) 664 if (live_help_floater)
667 { 665 {
668 live_help_floater->setFocus(TRUE); 666 live_help_floater->setFocus(TRUE);
@@ -680,20 +678,18 @@ void LLScriptEdCore::onBtnDynamicHelp(void* userdata)
680 live_help_floater->childSetAction("back_btn", onClickBack, userdata); 678 live_help_floater->childSetAction("back_btn", onClickBack, userdata);
681 live_help_floater->childSetAction("fwd_btn", onClickForward, userdata); 679 live_help_floater->childSetAction("fwd_btn", onClickForward, userdata);
682 680
683#if LL_LIBXUL_ENABLED 681 LLWebBrowserCtrl* browser = live_help_floater->getChild<LLWebBrowserCtrl>("lsl_guide_html");
684 LLWebBrowserCtrl* browser = LLUICtrlFactory::getWebBrowserCtrlByName(live_help_floater, "lsl_guide_html");
685 browser->setAlwaysRefresh(TRUE); 682 browser->setAlwaysRefresh(TRUE);
686#endif // LL_LIBXUL_ENABLED
687 683
688 LLComboBox* help_combo = LLUICtrlFactory::getComboBoxByName(live_help_floater, "history_combo"); 684 LLComboBox* help_combo = LLUICtrlFactory::getComboBoxByName(live_help_floater, "history_combo");
689 LLKeywordToken *token; 685 LLKeywordToken *token;
690 LLKeywords::word_token_map_t::iterator token_it; 686 LLKeywords::keyword_iterator_t token_it;
691 for (token_it = corep->mEditor->mKeywords.mWordTokenMap.begin(); 687 for (token_it = corep->mEditor->keywordsBegin();
692 token_it != corep->mEditor->mKeywords.mWordTokenMap.end(); 688 token_it != corep->mEditor->keywordsEnd();
693 ++token_it) 689 ++token_it)
694 { 690 {
695 token = token_it->second; 691 token = token_it->second;
696 help_combo->add(wstring_to_utf8str(token->mToken)); 692 help_combo->add(wstring_to_utf8str(token->getToken()));
697 } 693 }
698 help_combo->sortByName(); 694 help_combo->sortByName();
699 695
@@ -707,35 +703,31 @@ void LLScriptEdCore::onBtnDynamicHelp(void* userdata)
707//static 703//static
708void LLScriptEdCore::onClickBack(void* userdata) 704void LLScriptEdCore::onClickBack(void* userdata)
709{ 705{
710#if LL_LIBXUL_ENABLED
711 LLScriptEdCore* corep = (LLScriptEdCore*)userdata; 706 LLScriptEdCore* corep = (LLScriptEdCore*)userdata;
712 LLFloater* live_help_floater = LLFloater::getFloaterByHandle(corep->mLiveHelpHandle); 707 LLFloater* live_help_floater = corep->mLiveHelpHandle.get();
713 if (live_help_floater) 708 if (live_help_floater)
714 { 709 {
715 LLWebBrowserCtrl* browserp = LLUICtrlFactory::getWebBrowserCtrlByName(live_help_floater, "lsl_guide_html"); 710 LLWebBrowserCtrl* browserp = live_help_floater->getChild<LLWebBrowserCtrl>("lsl_guide_html");
716 if (browserp) 711 if (browserp)
717 { 712 {
718 browserp->navigateBack(); 713 browserp->navigateBack();
719 } 714 }
720 } 715 }
721#endif // LL_LIBXUL_ENABLED
722} 716}
723 717
724//static 718//static
725void LLScriptEdCore::onClickForward(void* userdata) 719void LLScriptEdCore::onClickForward(void* userdata)
726{ 720{
727#if LL_LIBXUL_ENABLED
728 LLScriptEdCore* corep = (LLScriptEdCore*)userdata; 721 LLScriptEdCore* corep = (LLScriptEdCore*)userdata;
729 LLFloater* live_help_floater = LLFloater::getFloaterByHandle(corep->mLiveHelpHandle); 722 LLFloater* live_help_floater = corep->mLiveHelpHandle.get();
730 if (live_help_floater) 723 if (live_help_floater)
731 { 724 {
732 LLWebBrowserCtrl* browserp = LLUICtrlFactory::getWebBrowserCtrlByName(live_help_floater, "lsl_guide_html"); 725 LLWebBrowserCtrl* browserp = live_help_floater->getChild<LLWebBrowserCtrl>("lsl_guide_html");
733 if (browserp) 726 if (browserp)
734 { 727 {
735 browserp->navigateForward(); 728 browserp->navigateForward();
736 } 729 }
737 } 730 }
738#endif // LL_LIBXUL_ENABLED
739} 731}
740 732
741// static 733// static
@@ -765,20 +757,18 @@ void LLScriptEdCore::onHelpComboCommit(LLUICtrl* ctrl, void* userdata)
765{ 757{
766 LLScriptEdCore* corep = (LLScriptEdCore*)userdata; 758 LLScriptEdCore* corep = (LLScriptEdCore*)userdata;
767 759
768 LLFloater* live_help_floater = LLFloater::getFloaterByHandle(corep->mLiveHelpHandle); 760 LLFloater* live_help_floater = corep->mLiveHelpHandle.get();
769 if (live_help_floater) 761 if (live_help_floater)
770 { 762 {
771 LLString help_string = ctrl->getValue().asString(); 763 LLString help_string = ctrl->getValue().asString();
772 764
773 corep->addHelpItemToHistory(help_string); 765 corep->addHelpItemToHistory(help_string);
774 766
775#if LL_LIBXUL_ENABLED 767 LLWebBrowserCtrl* web_browser = live_help_floater->getChild<LLWebBrowserCtrl>("lsl_guide_html");
776 LLWebBrowserCtrl* web_browser = gUICtrlFactory->getWebBrowserCtrlByName(live_help_floater, "lsl_guide_html");
777 LLUIString url_string = gSavedSettings.getString("LSLHelpURL"); 768 LLUIString url_string = gSavedSettings.getString("LSLHelpURL");
778 url_string.setArg("[APP_DIRECTORY]", gDirUtilp->getWorkingDir()); 769 url_string.setArg("[APP_DIRECTORY]", gDirUtilp->getWorkingDir());
779 url_string.setArg("[LSL_STRING]", help_string); 770 url_string.setArg("[LSL_STRING]", help_string);
780 web_browser->navigateTo(url_string); 771 web_browser->navigateTo(url_string);
781#endif // LL_LIBXUL_ENABLED
782 } 772 }
783} 773}
784 774
@@ -981,7 +971,7 @@ void LLScriptEdCore::handleReloadFromServerDialog( S32 option, void* userdata )
981 case 0: // "Yes" 971 case 0: // "Yes"
982 if( self->mLoadCallback ) 972 if( self->mLoadCallback )
983 { 973 {
984 self->mEditor->setText( self->childGetText("loading") ); 974 self->mEditor->setText( self->getString("loading") );
985 self->mLoadCallback( self->mUserdata ); 975 self->mLoadCallback( self->mUserdata );
986 } 976 }
987 break; 977 break;
@@ -1081,7 +1071,7 @@ void* LLPreviewLSL::createScriptEdPanel(void* userdata)
1081 LLRect(), 1071 LLRect(),
1082 HELLO_LSL, 1072 HELLO_LSL,
1083 HELP_LSL, 1073 HELP_LSL,
1084 self->mViewHandle, 1074 self->getHandle(),
1085 LLPreviewLSL::onLoad, 1075 LLPreviewLSL::onLoad,
1086 LLPreviewLSL::onSave, 1076 LLPreviewLSL::onSave,
1087 LLPreviewLSL::onSearchReplace, 1077 LLPreviewLSL::onSearchReplace,
@@ -1114,9 +1104,7 @@ LLPreviewLSL::LLPreviewLSL(const std::string& name, const LLRect& rect,
1114 childSetText("desc", item->getDescription()); 1104 childSetText("desc", item->getDescription());
1115 childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe); 1105 childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
1116 1106
1117 LLMultiFloater* hostp = getHost(); 1107 if (!getFloaterHost() && !getHost() && getAssetStatus() == PREVIEW_ASSET_UNLOADED)
1118
1119 if (!sHostp && !hostp && getAssetStatus() == PREVIEW_ASSET_UNLOADED)
1120 { 1108 {
1121 loadAsset(); 1109 loadAsset();
1122 } 1110 }
@@ -1195,7 +1183,7 @@ void LLPreviewLSL::loadAsset()
1195 } 1183 }
1196 else 1184 else
1197 { 1185 {
1198 mScriptEd->mEditor->setText(mScriptEd->childGetText("can_not_view")); 1186 mScriptEd->mEditor->setText(mScriptEd->getString("can_not_view"));
1199 mScriptEd->mEditor->makePristine(); 1187 mScriptEd->mEditor->makePristine();
1200 mScriptEd->mEditor->setEnabled(FALSE); 1188 mScriptEd->mEditor->setEnabled(FALSE);
1201 mScriptEd->mFunctions->setEnabled(FALSE); 1189 mScriptEd->mFunctions->setEnabled(FALSE);
@@ -1575,7 +1563,7 @@ void LLPreviewLSL::reshape(S32 width, S32 height, BOOL called_from_parent)
1575 { 1563 {
1576 // So that next time you open a script it will have the same height and width 1564 // So that next time you open a script it will have the same height and width
1577 // (although not the same position). 1565 // (although not the same position).
1578 gSavedSettings.setRect("PreviewScriptRect", mRect); 1566 gSavedSettings.setRect("PreviewScriptRect", getRect());
1579 } 1567 }
1580} 1568}
1581 1569
@@ -1597,7 +1585,7 @@ void* LLLiveLSLEditor::createScriptEdPanel(void* userdata)
1597 LLRect(), 1585 LLRect(),
1598 HELLO_LSL, 1586 HELLO_LSL,
1599 HELP_LSL, 1587 HELP_LSL,
1600 self->mViewHandle, 1588 self->getHandle(),
1601 &LLLiveLSLEditor::onLoad, 1589 &LLLiveLSLEditor::onLoad,
1602 &LLLiveLSLEditor::onSave, 1590 &LLLiveLSLEditor::onSave,
1603 &LLLiveLSLEditor::onSearchReplace, 1591 &LLLiveLSLEditor::onSearchReplace,
@@ -1727,7 +1715,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
1727 || !gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE)))) 1715 || !gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE))))
1728 { 1716 {
1729 mItem = new LLViewerInventoryItem(item); 1717 mItem = new LLViewerInventoryItem(item);
1730 mScriptEd->mEditor->setText(childGetText("not_allowed")); 1718 mScriptEd->mEditor->setText(getString("not_allowed"));
1731 mScriptEd->mEditor->makePristine(); 1719 mScriptEd->mEditor->makePristine();
1732 mScriptEd->mEditor->setEnabled(FALSE); 1720 mScriptEd->mEditor->setEnabled(FALSE);
1733 mAssetStatus = PREVIEW_ASSET_LOADED; 1721 mAssetStatus = PREVIEW_ASSET_LOADED;
@@ -1981,12 +1969,12 @@ void LLLiveLSLEditor::draw()
1981 { 1969 {
1982 if(object->permAnyOwner()) 1970 if(object->permAnyOwner())
1983 { 1971 {
1984 runningCheckbox->setLabel(childGetText("script_running")); 1972 runningCheckbox->setLabel(getString("script_running"));
1985 runningCheckbox->setEnabled(TRUE); 1973 runningCheckbox->setEnabled(TRUE);
1986 } 1974 }
1987 else 1975 else
1988 { 1976 {
1989 runningCheckbox->setLabel(childGetText("public_objects_can_not_run")); 1977 runningCheckbox->setLabel(getString("public_objects_can_not_run"));
1990 runningCheckbox->setEnabled(FALSE); 1978 runningCheckbox->setEnabled(FALSE);
1991 // *FIX: Set it to false so that the ui is correct for 1979 // *FIX: Set it to false so that the ui is correct for
1992 // a box that is released to public. It could be 1980 // a box that is released to public. It could be
@@ -2234,7 +2222,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename,
2234 2222
2235 // If we successfully saved it, then we should be able to check/uncheck the running box! 2223 // If we successfully saved it, then we should be able to check/uncheck the running box!
2236 LLCheckBoxCtrl* runningCheckbox = LLUICtrlFactory::getCheckBoxByName(this, "running"); 2224 LLCheckBoxCtrl* runningCheckbox = LLUICtrlFactory::getCheckBoxByName(this, "running");
2237 runningCheckbox->setLabel(childGetText("script_running")); 2225 runningCheckbox->setLabel(getString("script_running"));
2238 runningCheckbox->setEnabled(TRUE); 2226 runningCheckbox->setEnabled(TRUE);
2239} 2227}
2240 2228
@@ -2414,6 +2402,6 @@ void LLLiveLSLEditor::reshape(S32 width, S32 height, BOOL called_from_parent)
2414 { 2402 {
2415 // So that next time you open a script it will have the same height and width 2403 // So that next time you open a script it will have the same height and width
2416 // (although not the same position). 2404 // (although not the same position).
2417 gSavedSettings.setRect("PreviewScriptRect", mRect); 2405 gSavedSettings.setRect("PreviewScriptRect", getRect());
2418 } 2406 }
2419} 2407}