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 #include "viewer.h"
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 BOOL LLPanelContents::postBuild()
00080 {
00081 LLRect rect = this->getRect();
00082
00083 setMouseOpaque(FALSE);
00084
00085 childSetAction("button new script",&LLPanelContents::onClickNewScript, this);
00086
00087 return TRUE;
00088 }
00089
00090 LLPanelContents::LLPanelContents(const std::string& name)
00091 : LLPanel(name),
00092 mPanelInventory(NULL)
00093 {
00094 }
00095
00096
00097 LLPanelContents::~LLPanelContents()
00098 {
00099
00100 }
00101
00102
00103 void LLPanelContents::getState(LLViewerObject *objectp )
00104 {
00105 if( !objectp )
00106 {
00107 childSetEnabled("button new script",FALSE);
00108
00109 return;
00110 }
00111
00112 LLUUID group_id;
00113 gSelectMgr->selectGetGroup(group_id);
00114
00115
00116 BOOL editable = gAgent.isGodlike()
00117 || (objectp->permModify()
00118 && ( objectp->permYouOwner() || ( !group_id.isNull() && gAgent.isInGroup(group_id) )));
00119 BOOL all_volume = gSelectMgr->selectionAllPCode( LL_PCODE_VOLUME );
00120
00121
00122
00123 if( editable &&
00124 all_volume &&
00125 ((gSelectMgr->getSelection()->getRootObjectCount() == 1)
00126 || (gSelectMgr->getSelection()->getObjectCount() == 1)))
00127 {
00128
00129 childSetEnabled("button new script",TRUE);
00130 }
00131 else
00132 {
00133
00134 childSetEnabled("button new script",FALSE);
00135 }
00136 }
00137
00138
00139 void LLPanelContents::refresh()
00140 {
00141 const BOOL children_ok = TRUE;
00142 LLViewerObject* object = gSelectMgr->getSelection()->getFirstRootObject(children_ok);
00143
00144 getState(object);
00145 if (mPanelInventory)
00146 {
00147 mPanelInventory->refresh();
00148 }
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158 void LLPanelContents::onClickNewScript(void *userdata)
00159 {
00160 const BOOL children_ok = TRUE;
00161 LLViewerObject* object = gSelectMgr->getSelection()->getFirstRootObject(children_ok);
00162 if(object)
00163 {
00164 LLPermissions perm;
00165 perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
00166 perm.initMasks(
00167 PERM_ALL,
00168 PERM_ALL,
00169 PERM_NONE,
00170 PERM_NONE,
00171 PERM_MOVE | PERM_TRANSFER);
00172 LLString desc;
00173 LLAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc);
00174 LLPointer<LLViewerInventoryItem> new_item =
00175 new LLViewerInventoryItem(
00176 LLUUID::null,
00177 LLUUID::null,
00178 perm,
00179 LLUUID::null,
00180 LLAssetType::AT_LSL_TEXT,
00181 LLInventoryType::IT_LSL,
00182 LLString("New Script"),
00183 desc,
00184 LLSaleInfo::DEFAULT,
00185 LLViewerInventoryItem::II_FLAGS_NONE,
00186 time_corrected());
00187 object->saveScript(new_item, TRUE, true);
00188
00189
00190
00191
00192
00193
00194
00195 #if 0
00196 S32 left, top;
00197 gFloaterView->getNewFloaterPosition(&left, &top);
00198 LLRect rect = gSavedSettings.getRect("PreviewScriptRect");
00199 rect.translate( left - rect.mLeft, top - rect.mTop );
00200
00201 LLLiveLSLEditor* editor;
00202 editor = new LLLiveLSLEditor("script ed",
00203 rect,
00204 "Script: New Script",
00205 object->mID,
00206 LLUUID::null);
00207 editor->open();
00208
00209
00210 gFloaterView->adjustToFitScreen(editor, FALSE);
00211 #endif
00212 }
00213 }