diff options
Diffstat (limited to 'linden/indra/newview/llpreviewscript.h')
-rw-r--r-- | linden/indra/newview/llpreviewscript.h | 231 |
1 files changed, 231 insertions, 0 deletions
diff --git a/linden/indra/newview/llpreviewscript.h b/linden/indra/newview/llpreviewscript.h new file mode 100644 index 0000000..fd17388 --- /dev/null +++ b/linden/indra/newview/llpreviewscript.h | |||
@@ -0,0 +1,231 @@ | |||
1 | /** | ||
2 | * @file llpreviewscript.h | ||
3 | * @brief LLPreviewScript class definition | ||
4 | * | ||
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLPREVIEWSCRIPT_H | ||
29 | #define LL_LLPREVIEWSCRIPT_H | ||
30 | |||
31 | #include "lldarray.h" | ||
32 | #include "llpreview.h" | ||
33 | #include "lltabcontainer.h" | ||
34 | #include "llinventory.h" | ||
35 | #include "llcombobox.h" | ||
36 | #include "lliconctrl.h" | ||
37 | |||
38 | |||
39 | class LLMessageSystem; | ||
40 | class LLTextEditor; | ||
41 | class LLButton; | ||
42 | class LLCheckBoxCtrl; | ||
43 | class LLScrollListCtrl; | ||
44 | class LLViewerObject; | ||
45 | struct LLEntryAndEdCore; | ||
46 | class LLMenuBarGL; | ||
47 | class LLFloaterScriptSearch; | ||
48 | |||
49 | // Inner, implementation class. LLPreviewScript and LLLiveScriptEditor each own one of these. | ||
50 | class LLScriptEdCore : public LLPanel | ||
51 | { | ||
52 | friend class LLPreviewScript; | ||
53 | friend class LLPreviewLSL; | ||
54 | friend class LLLiveScriptEditor; | ||
55 | friend class LLLiveLSLEditor; | ||
56 | friend class LLFloaterScriptSearch; | ||
57 | |||
58 | public: | ||
59 | LLScriptEdCore( | ||
60 | const std::string& name, | ||
61 | const LLRect& rect, | ||
62 | const std::string& sample, | ||
63 | const std::string& help, | ||
64 | const LLViewHandle& floater_handle, | ||
65 | void (*load_callback)(void* userdata), | ||
66 | void (*save_callback)(void* userdata, BOOL close_after_save), | ||
67 | void* userdata, | ||
68 | S32 bottom_pad = 0); // pad below bottom row of buttons | ||
69 | ~LLScriptEdCore(); | ||
70 | |||
71 | void initMenu(); | ||
72 | |||
73 | virtual void draw(); | ||
74 | |||
75 | BOOL canClose(); | ||
76 | |||
77 | static void handleSaveChangesDialog(S32 option, void* userdata); | ||
78 | static void handleReloadFromServerDialog(S32 option, void* userdata); | ||
79 | |||
80 | static void onHelpWebDialog(S32 option, void* userdata); | ||
81 | static void onBtnHelp(void* userdata); | ||
82 | static void onBtnInsertSample(void*); | ||
83 | static void onBtnInsertFunction(LLUICtrl*, void*); | ||
84 | static void doSave( void* userdata, BOOL close_after_save ); | ||
85 | static void onBtnSave(void*); | ||
86 | static void onBtnUndoChanges(void*); | ||
87 | static void onSearchMenu(void* userdata); | ||
88 | |||
89 | static void onUndoMenu(void* userdata); | ||
90 | static void onRedoMenu(void* userdata); | ||
91 | static void onCutMenu(void* userdata); | ||
92 | static void onCopyMenu(void* userdata); | ||
93 | static void onPasteMenu(void* userdata); | ||
94 | static void onSelectAllMenu(void* userdata); | ||
95 | static void onDeselectMenu(void* userdata); | ||
96 | |||
97 | static BOOL enableUndoMenu(void* userdata); | ||
98 | static BOOL enableRedoMenu(void* userdata); | ||
99 | static BOOL enableCutMenu(void* userdata); | ||
100 | static BOOL enableCopyMenu(void* userdata); | ||
101 | static BOOL enablePasteMenu(void* userdata); | ||
102 | static BOOL enableSelectAllMenu(void* userdata); | ||
103 | static BOOL enableDeselectMenu(void* userdata); | ||
104 | |||
105 | static BOOL hasChanged(void* userdata); | ||
106 | |||
107 | void selectFirstError(); | ||
108 | |||
109 | virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); | ||
110 | |||
111 | protected: | ||
112 | void deleteBridges(); | ||
113 | |||
114 | static void onErrorList(LLUICtrl*, void* user_data); | ||
115 | |||
116 | private: | ||
117 | LLString mSampleText; | ||
118 | std::string mHelpFile; | ||
119 | LLTextEditor* mEditor; | ||
120 | void (*mLoadCallback)(void* userdata); | ||
121 | void (*mSaveCallback)(void* userdata, BOOL close_after_save); | ||
122 | void* mUserdata; | ||
123 | LLComboBox *mFunctions; | ||
124 | BOOL mForceClose; | ||
125 | //LLPanel* mGuiPanel; | ||
126 | LLPanel* mCodePanel; | ||
127 | LLScrollListCtrl* mErrorList; | ||
128 | LLDynamicArray<LLEntryAndEdCore*> mBridges; | ||
129 | }; | ||
130 | |||
131 | |||
132 | // Used to view and edit a LSL from your inventory. | ||
133 | class LLPreviewLSL : public LLPreview | ||
134 | { | ||
135 | public: | ||
136 | LLPreviewLSL(const std::string& name, const LLRect& rect, const std::string& title, | ||
137 | const LLUUID& item_uuid ); | ||
138 | |||
139 | /*virtual*/ void open(); | ||
140 | |||
141 | protected: | ||
142 | virtual BOOL canClose(); | ||
143 | virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); | ||
144 | |||
145 | virtual void loadAsset(); | ||
146 | void saveIfNeeded(); | ||
147 | |||
148 | static void onLoad(void* userdata); | ||
149 | static void onSave(void* userdata, BOOL close_after_save); | ||
150 | |||
151 | static void onLoadComplete(LLVFS *vfs, const LLUUID& uuid, | ||
152 | LLAssetType::EType type, | ||
153 | void* user_data, S32 status); | ||
154 | static void onSaveComplete(const LLUUID& uuid, void* user_data, S32 status); | ||
155 | static void onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status); | ||
156 | static LLPreviewLSL* getInstance(const LLUUID& uuid); | ||
157 | |||
158 | static void* createScriptEdPanel(void* userdata); | ||
159 | |||
160 | |||
161 | protected: | ||
162 | LLScriptEdCore* mScriptEd; | ||
163 | // Can safely close only after both text and bytecode are uploaded | ||
164 | S32 mPendingUploads; | ||
165 | }; | ||
166 | |||
167 | |||
168 | // Used to view and edit an LSL that is attached to an object. | ||
169 | class LLLiveLSLEditor : public LLFloater | ||
170 | { | ||
171 | public: | ||
172 | LLLiveLSLEditor(const std::string& name, const LLRect& rect, | ||
173 | const std::string& title, | ||
174 | const LLUUID& object_id, const LLUUID& item_id); | ||
175 | ~LLLiveLSLEditor(); | ||
176 | |||
177 | |||
178 | static LLLiveLSLEditor* show(const LLUUID& item_id, const LLUUID& object_id); | ||
179 | static void hide(const LLUUID& item_id, const LLUUID& object_id); | ||
180 | |||
181 | static void processScriptRunningReply(LLMessageSystem* msg, void**); | ||
182 | |||
183 | protected: | ||
184 | virtual BOOL canClose(); | ||
185 | virtual void draw(); | ||
186 | virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); | ||
187 | |||
188 | void loadAsset(BOOL is_new = FALSE); | ||
189 | void saveIfNeeded(); | ||
190 | |||
191 | static void onLoad(void* userdata); | ||
192 | static void onSave(void* userdata, BOOL close_after_save); | ||
193 | |||
194 | static void onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, | ||
195 | LLAssetType::EType type, | ||
196 | void* user_data, S32 status); | ||
197 | static void onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status); | ||
198 | static void onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status); | ||
199 | static void onRunningCheckboxClicked(LLUICtrl*, void* userdata); | ||
200 | static void onReset(void* userdata); | ||
201 | |||
202 | void loadScriptText(const char* filename); | ||
203 | void loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type); | ||
204 | |||
205 | static void onErrorList(LLUICtrl*, void* user_data); | ||
206 | |||
207 | static void* createScriptEdPanel(void* userdata); | ||
208 | |||
209 | |||
210 | protected: | ||
211 | LLUUID mObjectID; | ||
212 | LLUUID mItemID; // The inventory item this script is associated with | ||
213 | BOOL mIsNew; | ||
214 | LLScriptEdCore* mScriptEd; | ||
215 | //LLUUID mTransmitID; | ||
216 | LLCheckBoxCtrl *mRunningCheckbox; | ||
217 | BOOL mAskedForRunningInfo; | ||
218 | BOOL mHaveRunningInfo; | ||
219 | LLButton *mResetButton; | ||
220 | LLPointer<LLViewerInventoryItem> mItem; | ||
221 | BOOL mCloseAfterSave; | ||
222 | // need to save both text and script, so need to decide when done | ||
223 | S32 mPendingUploads; | ||
224 | |||
225 | static LLMap<LLUUID, LLLiveLSLEditor*> sInstances; | ||
226 | }; | ||
227 | |||
228 | // name of help file for lsl | ||
229 | extern const char HELP_LSL[]; | ||
230 | |||
231 | #endif // LL_LLPREVIEWSCRIPT_H | ||