00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034
00035 #include "llpanelcontents.h"
00036
00037
00038 #include "llerror.h"
00039 #include "llrect.h"
00040 #include "llstring.h"
00041 #include "llmaterialtable.h"
00042 #include "llfontgl.h"
00043 #include "m3math.h"
00044 #include "llpermissionsflags.h"
00045 #include "lleconomy.h"
00046 #include "material_codes.h"
00047
00048
00049 #include "llui.h"
00050 #include "llspinctrl.h"
00051 #include "llcheckboxctrl.h"
00052 #include "lltextbox.h"
00053 #include "llbutton.h"
00054 #include "llcombobox.h"
00055
00056 #include "llagent.h"
00057 #include "llviewerwindow.h"
00058 #include "llworld.h"
00059 #include "llviewerobject.h"
00060 #include "llviewerregion.h"
00061 #include "llresmgr.h"
00062 #include "llselectmgr.h"
00063 #include "llpreviewscript.h"
00064 #include "lltool.h"
00065 #include "lltoolmgr.h"
00066 #include "lltoolcomp.h"
00067 #include "llpanelinventory.h"
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 BOOL LLPanelContents::postBuild()
00079 {
00080 LLRect rect = this->getRect();
00081
00082 setMouseOpaque(FALSE);
00083
00084 childSetAction("button new script",&LLPanelContents::onClickNewScript, this);
00085
00086 return TRUE;
00087 }
00088
00089 LLPanelContents::LLPanelContents(const std::string& name)
00090 : LLPanel(name),
00091 mPanelInventory(NULL)
00092 {
00093 }
00094
00095
00096 LLPanelContents::~LLPanelContents()
00097 {
00098
00099 }
00100
00101
00102 void LLPanelContents::getState(LLViewerObject *objectp )
00103 {
00104 if( !objectp )
00105 {
00106 childSetEnabled("button new script",FALSE);
00107
00108 return;
00109 }
00110
00111 LLUUID group_id;
00112 LLSelectMgr::getInstance()->selectGetGroup(group_id);
00113
00114
00115 BOOL editable = gAgent.isGodlike()
00116 || (objectp->permModify()
00117 && ( objectp->permYouOwner() || ( !group_id.isNull() && gAgent.isInGroup(group_id) )));
00118 BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
00119
00120
00121
00122 if( editable &&
00123 all_volume &&
00124 ((LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() == 1)
00125 || (LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 1)))
00126 {
00127
00128 childSetEnabled("button new script",TRUE);
00129 }
00130 else
00131 {
00132
00133 childSetEnabled("button new script",FALSE);
00134 }
00135 }
00136
00137
00138 void LLPanelContents::refresh()
00139 {
00140 const BOOL children_ok = TRUE;
00141 LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok);
00142
00143 getState(object);
00144 if (mPanelInventory)
00145 {
00146 mPanelInventory->refresh();
00147 }
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157 void LLPanelContents::onClickNewScript(void *userdata)
00158 {
00159 const BOOL children_ok = TRUE;
00160 LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok);
00161 if(object)
00162 {
00163 LLPermissions perm;
00164 perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
00165 perm.initMasks(
00166 PERM_ALL,
00167 PERM_ALL,
00168 PERM_NONE,
00169 PERM_NONE,
00170 PERM_MOVE | PERM_TRANSFER);
00171 LLString desc;
00172 LLAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc);
00173 LLPointer<LLViewerInventoryItem> new_item =
00174 new LLViewerInventoryItem(
00175 LLUUID::null,
00176 LLUUID::null,
00177 perm,
00178 LLUUID::null,
00179 LLAssetType::AT_LSL_TEXT,
00180 LLInventoryType::IT_LSL,
00181 LLString("New Script"),
00182 desc,
00183 LLSaleInfo::DEFAULT,
00184 LLViewerInventoryItem::II_FLAGS_NONE,
00185 time_corrected());
00186 object->saveScript(new_item, TRUE, true);
00187
00188
00189
00190
00191
00192
00193
00194 #if 0
00195 S32 left, top;
00196 gFloaterView->getNewFloaterPosition(&left, &top);
00197 LLRect rect = gSavedSettings.getRect("PreviewScriptRect");
00198 rect.translate( left - rect.mLeft, top - rect.mTop );
00199
00200 LLLiveLSLEditor* editor;
00201 editor = new LLLiveLSLEditor("script ed",
00202 rect,
00203 "Script: New Script",
00204 object->mID,
00205 LLUUID::null);
00206 editor->open();
00207
00208
00209 gFloaterView->adjustToFitScreen(editor, FALSE);
00210 #endif
00211 }
00212 }