llpreviewscript.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLPREVIEWSCRIPT_H
00033 #define LL_LLPREVIEWSCRIPT_H
00034 
00035 #include "lldarray.h"
00036 #include "llpreview.h"
00037 #include "lltabcontainer.h"
00038 #include "llinventory.h"
00039 #include "llcombobox.h"
00040 #include "lliconctrl.h"
00041 #include "llframetimer.h"
00042 
00043 
00044 class LLMessageSystem;
00045 class LLTextEditor;
00046 class LLButton;
00047 class LLCheckBoxCtrl;
00048 class LLScrollListCtrl;
00049 class LLViewerObject;
00050 struct  LLEntryAndEdCore;
00051 class LLMenuBarGL;
00052 class LLFloaterScriptSearch;
00053 class LLKeywordToken;
00054 
00055 // Inner, implementation class.  LLPreviewScript and LLLiveScriptEditor each own one of these.
00056 class LLScriptEdCore : public LLPanel
00057 {
00058         friend class LLPreviewScript;
00059         friend class LLPreviewLSL;
00060         friend class LLLiveScriptEditor;
00061         friend class LLLiveLSLEditor;
00062         friend class LLFloaterScriptSearch;
00063 
00064 public:
00065         LLScriptEdCore(
00066                 const std::string& name,
00067                 const LLRect& rect,
00068                 const std::string& sample,
00069                 const std::string& help,
00070                 const LLViewHandle& floater_handle,
00071                 void (*load_callback)(void* userdata),
00072                 void (*save_callback)(void* userdata, BOOL close_after_save),
00073                 void (*search_replace_callback)(void* userdata),
00074                 void* userdata,
00075                 S32 bottom_pad = 0);    // pad below bottom row of buttons
00076         ~LLScriptEdCore();
00077         
00078         void                    initMenu();
00079 
00080         virtual void    draw();
00081 
00082         BOOL                    canClose();
00083 
00084         static void             handleSaveChangesDialog(S32 option, void* userdata);
00085         static void             handleReloadFromServerDialog(S32 option, void* userdata);
00086 
00087         static void             onHelpWebDialog(S32 option, void* userdata);
00088         static void             onBtnHelp(void* userdata);
00089         static void             onBtnDynamicHelp(void* userdata);
00090         static void             onCheckLock(LLUICtrl*, void*);
00091         static void             onHelpComboCommit(LLUICtrl* ctrl, void* userdata);
00092         static void             onClickBack(void* userdata);
00093         static void             onClickForward(void* userdata);
00094         static void             onBtnInsertSample(void*);
00095         static void             onBtnInsertFunction(LLUICtrl*, void*);
00096         static void             doSave( void* userdata, BOOL close_after_save );
00097         static void             onBtnSave(void*);
00098         static void             onBtnUndoChanges(void*);
00099         static void             onSearchMenu(void* userdata);
00100 
00101         static void             onUndoMenu(void* userdata);
00102         static void             onRedoMenu(void* userdata);
00103         static void             onCutMenu(void* userdata);
00104         static void             onCopyMenu(void* userdata);
00105         static void             onPasteMenu(void* userdata);
00106         static void             onSelectAllMenu(void* userdata);
00107         static void             onDeselectMenu(void* userdata);
00108 
00109         static BOOL             enableUndoMenu(void* userdata);
00110         static BOOL             enableRedoMenu(void* userdata);
00111         static BOOL             enableCutMenu(void* userdata);
00112         static BOOL             enableCopyMenu(void* userdata);
00113         static BOOL             enablePasteMenu(void* userdata);
00114         static BOOL             enableSelectAllMenu(void* userdata);
00115         static BOOL             enableDeselectMenu(void* userdata);
00116 
00117         static BOOL             hasChanged(void* userdata);
00118 
00119         void selectFirstError();
00120 
00121         virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
00122 
00123 protected:
00124         void deleteBridges();
00125         void setHelpPage(const LLString& help_string);
00126         void updateDynamicHelp(BOOL immediate = FALSE);
00127         void addHelpItemToHistory(const LLString& help_string);
00128 
00129         static void onErrorList(LLUICtrl*, void* user_data);
00130 
00131 private:
00132         LLString                mSampleText;
00133         std::string             mHelpFile;
00134         LLTextEditor*   mEditor;
00135         void                    (*mLoadCallback)(void* userdata);
00136         void                    (*mSaveCallback)(void* userdata, BOOL close_after_save);
00137         void                    (*mSearchReplaceCallback) (void* userdata);
00138         void*                   mUserdata;
00139         LLComboBox              *mFunctions;
00140         BOOL                    mForceClose;
00141         //LLPanel*              mGuiPanel;
00142         LLPanel*                mCodePanel;
00143         LLScrollListCtrl* mErrorList;
00144         LLDynamicArray<LLEntryAndEdCore*> mBridges;
00145         LLViewHandle    mLiveHelpHandle;
00146         LLKeywordToken* mLastHelpToken;
00147         LLFrameTimer    mLiveHelpTimer;
00148         S32                             mLiveHelpHistorySize;
00149 };
00150 
00151 
00152 // Used to view and edit a LSL from your inventory.
00153 class LLPreviewLSL : public LLPreview
00154 {
00155 public:
00156         LLPreviewLSL(const std::string& name, const LLRect& rect, const std::string& title,
00157                                  const LLUUID& item_uuid );
00158         virtual void callbackLSLCompileSucceeded();
00159         virtual void callbackLSLCompileFailed(const LLSD& compile_errors);
00160 
00161         /*virtual*/ void open();                /*Flawfinder: ignore*/
00162 
00163 protected:
00164         virtual BOOL canClose();
00165         void closeIfNeeded();
00166         virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00167 
00168         virtual void loadAsset();
00169         void saveIfNeeded();
00170         void uploadAssetViaCaps(const std::string& url,
00171                                                         const std::string& filename, 
00172                                                         const LLUUID& item_id);
00173         void uploadAssetLegacy(const std::string& filename,
00174                                                         const LLUUID& item_id,
00175                                                         const LLTransactionID& tid);
00176 
00177         static void onSearchReplace(void* userdata);
00178         static void onLoad(void* userdata);
00179         static void onSave(void* userdata, BOOL close_after_save);
00180         
00181         static void onLoadComplete(LLVFS *vfs, const LLUUID& uuid,
00182                                                            LLAssetType::EType type,
00183                                                            void* user_data, S32 status, LLExtStat ext_status);
00184         static void onSaveComplete(const LLUUID& uuid, void* user_data, S32 status, LLExtStat ext_status);
00185         static void onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status);
00186         static LLPreviewLSL* getInstance(const LLUUID& uuid);
00187 
00188         static void* createScriptEdPanel(void* userdata);
00189 
00190 
00191 protected:
00192         LLScriptEdCore* mScriptEd;
00193         // Can safely close only after both text and bytecode are uploaded
00194         S32 mPendingUploads;
00195 };
00196 
00197 
00198 // Used to view and edit an LSL that is attached to an object.
00199 class LLLiveLSLEditor : public LLPreview
00200 {
00201 public: 
00202         LLLiveLSLEditor(const std::string& name, const LLRect& rect,
00203                                         const std::string& title,
00204                                         const LLUUID& object_id, const LLUUID& item_id);
00205         ~LLLiveLSLEditor();
00206 
00207 
00208         static LLLiveLSLEditor* show(const LLUUID& item_id, const LLUUID& object_id);
00209         static void hide(const LLUUID& item_id, const LLUUID& object_id);
00210         static LLLiveLSLEditor* find(const LLUUID& item_id, const LLUUID& object_id);
00211 
00212         static void processScriptRunningReply(LLMessageSystem* msg, void**);
00213 
00214         virtual void callbackLSLCompileSucceeded(const LLUUID& task_id,
00215                                                                                         const LLUUID& item_id,
00216                                                                                         bool is_script_running);
00217         virtual void callbackLSLCompileFailed(const LLSD& compile_errors);
00218 
00219         // Overide LLPreview::open() to avoid calling loadAsset twice.
00220         /*virtual*/ void open();                /*Flawfinder: ignore*/
00221 
00222 protected:
00223         virtual BOOL canClose();
00224         void closeIfNeeded();
00225         virtual void draw();
00226         virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00227 
00228         virtual void loadAsset();
00229         void loadAsset(BOOL is_new);
00230         void saveIfNeeded();
00231         void uploadAssetViaCaps(const std::string& url,
00232                                                         const std::string& filename, 
00233                                                         const LLUUID& task_id,
00234                                                         const LLUUID& item_id,
00235                                                         BOOL is_running);
00236         void uploadAssetLegacy(const std::string& filename,
00237                                                    LLViewerObject* object,
00238                                                    const LLTransactionID& tid,
00239                                                    BOOL is_running);
00240 
00241         static void onSearchReplace(void* userdata);
00242         static void onLoad(void* userdata);
00243         static void onSave(void* userdata, BOOL close_after_save);
00244 
00245         static void onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid,
00246                                                            LLAssetType::EType type,
00247                                                            void* user_data, S32 status, LLExtStat ext_status);
00248         static void onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status);
00249         static void onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status);
00250         static void onRunningCheckboxClicked(LLUICtrl*, void* userdata);
00251         static void onReset(void* userdata);
00252 
00253         void loadScriptText(const char* filename);
00254         void loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type);
00255 
00256         static void onErrorList(LLUICtrl*, void* user_data);
00257 
00258         static void* createScriptEdPanel(void* userdata);
00259 
00260 
00261 protected:
00262         LLUUID mObjectID;
00263         LLUUID mItemID; // The inventory item this script is associated with
00264         BOOL mIsNew;
00265         LLScriptEdCore* mScriptEd;
00266         //LLUUID mTransmitID;
00267         LLCheckBoxCtrl  *mRunningCheckbox;
00268         BOOL mAskedForRunningInfo;
00269         BOOL mHaveRunningInfo;
00270         LLButton                *mResetButton;
00271         LLPointer<LLViewerInventoryItem> mItem;
00272         BOOL mCloseAfterSave;
00273         // need to save both text and script, so need to decide when done
00274         S32 mPendingUploads;
00275 
00276         static LLMap<LLUUID, LLLiveLSLEditor*> sInstances;
00277 };
00278 
00279 // name of help file for lsl
00280 extern const char HELP_LSL[];
00281 
00282 #endif  // LL_LLPREVIEWSCRIPT_H

Generated on Thu Jul 1 06:09:02 2010 for Second Life Viewer by  doxygen 1.4.7