Skip to content

Commit 23ac8f6

Browse files
authored
Merge pull request #3535 from secondlife/marchcat/lua_editor
Lua editor: initial PR to start the project viewer
2 parents 5029f03 + ad7dee8 commit 23ac8f6

17 files changed

+443
-318
lines changed

indra/llmessage/message_prehash.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ char const* const _PREHASH_FirstName = LLMessageStringTable::getInstance()->getS
714714
char const* const _PREHASH_AttachedSoundGainChange = LLMessageStringTable::getInstance()->getString("AttachedSoundGainChange");
715715
char const* const _PREHASH_LocationID = LLMessageStringTable::getInstance()->getString("LocationID");
716716
char const* const _PREHASH_Running = LLMessageStringTable::getInstance()->getString("Running");
717+
char const* const _PREHASH_Mono = LLMessageStringTable::getInstance()->getString("Mono");
718+
char const* const _PREHASH_Luau = LLMessageStringTable::getInstance()->getString("Luau");
719+
char const* const _PREHASH_LuauLanguage = LLMessageStringTable::getInstance()->getString("LuauLanguage");
717720
char const* const _PREHASH_AgentThrottle = LLMessageStringTable::getInstance()->getString("AgentThrottle");
718721
char const* const _PREHASH_NeighborList = LLMessageStringTable::getInstance()->getString("NeighborList");
719722
char const* const _PREHASH_PathTaperX = LLMessageStringTable::getInstance()->getString("PathTaperX");

indra/llmessage/message_prehash.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ extern char const* const _PREHASH_FirstName;
714714
extern char const* const _PREHASH_AttachedSoundGainChange;
715715
extern char const* const _PREHASH_LocationID;
716716
extern char const* const _PREHASH_Running;
717+
extern char const* const _PREHASH_Mono;
718+
extern char const* const _PREHASH_Luau;
719+
extern char const* const _PREHASH_LuauLanguage;
717720
extern char const* const _PREHASH_AgentThrottle;
718721
extern char const* const _PREHASH_NeighborList;
719722
extern char const* const _PREHASH_PathTaperX;

indra/llui/llcombobox.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,26 @@ void LLComboBox::resetDirty()
251251
}
252252
}
253253

254-
bool LLComboBox::itemExists(const std::string& name)
254+
bool LLComboBox::itemExists(const std::string& name) const
255255
{
256256
return mList->getItemByLabel(name);
257257
}
258258

259+
bool LLComboBox::valueExists(const std::string& value) const
260+
{
261+
return mList->getItemByValue(value);
262+
}
263+
264+
LLScrollListItem* LLComboBox::findItemByValue(const std::string& value) const
265+
{
266+
return mList->getItemByValue(value);
267+
}
268+
269+
std::vector<LLScrollListItem*> LLComboBox::getAllData() const
270+
{
271+
return mList->getAllData();
272+
}
273+
259274
// add item "name" to menu
260275
LLScrollListItem* LLComboBox::add(const std::string& name, EAddPosition pos, bool enabled)
261276
{

indra/llui/llcombobox.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ class LLComboBox
143143
LLScrollListItem* addSeparator(EAddPosition pos = ADD_BOTTOM);
144144
bool remove( S32 index ); // remove item by index, return true if found and removed
145145
void removeall() { clearRows(); }
146-
bool itemExists(const std::string& name);
146+
bool itemExists(const std::string& name) const;
147+
bool valueExists(const std::string& value) const;
148+
LLScrollListItem* findItemByValue(const std::string& value) const;
149+
std::vector<LLScrollListItem*> getAllData() const;
147150

148151
void sortByName(bool ascending = true); // Sort the entries in the combobox by name
149152

indra/llui/llkeywords.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ void LLKeywords::processTokens()
239239
addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", LLUIColorTable::instance().getColor("SyntaxLslComment"), "Comment (multi-line)\nNon-functional commentary or disabled code", "*/" );
240240
addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", LLUIColorTable::instance().getColor("SyntaxLslStringLiteral"), "String literal", "\"" );
241241

242+
// Lua-style comments
243+
addToken(LLKeywordToken::TT_ONE_SIDED_DELIMITER, "--", LLUIColorTable::instance().getColor("SyntaxLslComment"), "Comment (Lua-style single-line)\nNon-functional commentary or disabled code", delimiter);
244+
addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "--[[", LLUIColorTable::instance().getColor("SyntaxLslComment"), "Comment (Lua-style multi-line)\nNon-functional commentary or disabled code", "]]");
245+
242246
LLSD::map_iterator itr = mSyntax.beginMap();
243247
for ( ; itr != mSyntax.endMap(); ++itr)
244248
{
@@ -627,7 +631,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
627631

628632
if( *cur )
629633
{
630-
cur += cur_delimiter->getLengthHead();
634+
cur += cur_delimiter->getLengthTail();
631635
seg_end = seg_start + between_delimiters + cur_delimiter->getLengthHead() + cur_delimiter->getLengthTail();
632636
}
633637
else

indra/llui/llscrolllistctrl.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,19 @@ LLScrollListItem* LLScrollListCtrl::getItemByLabel(const std::string& label, boo
12811281
return NULL;
12821282
}
12831283

1284+
LLScrollListItem* LLScrollListCtrl::getItemByValue(const std::string& value)
1285+
{
1286+
for (LLScrollListItem* item : mItemList)
1287+
{
1288+
if (item->getValue().asString() == value)
1289+
{
1290+
return item;
1291+
}
1292+
}
1293+
1294+
return NULL;
1295+
}
1296+
12841297
LLScrollListItem* LLScrollListCtrl::getItemByIndex(S32 index)
12851298
{
12861299
if (index >= 0 && index < (S32)mItemList.size())

indra/llui/llscrolllistctrl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler,
263263
bool selectItemByLabel(const std::string& item, bool case_sensitive = true, S32 column = 0); // false if item not found
264264
bool selectItemByPrefix(const std::string& target, bool case_sensitive = true, S32 column = -1);
265265
bool selectItemByPrefix(const LLWString& target, bool case_sensitive = true, S32 column = -1);
266-
LLScrollListItem* getItemByLabel(const std::string& item, bool case_sensitive = true, S32 column = 0);
266+
LLScrollListItem* getItemByLabel(const std::string& label, bool case_sensitive = true, S32 column = 0);
267+
LLScrollListItem* getItemByValue(const std::string& value);
267268
LLScrollListItem* getItemByIndex(S32 index);
268269
std::string getSelectedItemLabel(S32 column = 0) const;
269270
LLSD getSelectedValue();

indra/newview/app_settings/keywords_lsl_default.xml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,88 @@
33
<map>
44
<key>controls</key>
55
<map>
6+
<!-- Lua-only keywords -->
7+
<key>and</key>
8+
<map>
9+
<key>tooltip</key>
10+
<string>Logical AND operator. (Lua)</string>
11+
</map>
12+
<key>break</key>
13+
<map>
14+
<key>tooltip</key>
15+
<string>Exits a loop immediately. (Lua)</string>
16+
</map>
17+
<key>elseif</key>
18+
<map>
19+
<key>tooltip</key>
20+
<string>Provides an additional conditional branch in an if–else chain. (Lua)</string>
21+
</map>
22+
<key>end</key>
23+
<map>
24+
<key>tooltip</key>
25+
<string>Terminates a block initiated by if, do, or function. (Lua)</string>
26+
</map>
27+
<key>false</key>
28+
<map>
29+
<key>tooltip</key>
30+
<string>Boolean constant representing false. (Lua)</string>
31+
</map>
32+
<key>function</key>
33+
<map>
34+
<key>tooltip</key>
35+
<string>Declares a function. (Lua)</string>
36+
</map>
37+
<key>goto</key>
38+
<map>
39+
<key>tooltip</key>
40+
<string>Transfers control to a labeled statement. (Lua)</string>
41+
</map>
42+
<key>in</key>
43+
<map>
44+
<key>tooltip</key>
45+
<string>Used in for loops to iterate over elements in a collection. (Lua)</string>
46+
</map>
47+
<key>local</key>
48+
<map>
49+
<key>tooltip</key>
50+
<string>Declares a variable or function with local scope. (Lua)</string>
51+
</map>
52+
<key>nil</key>
53+
<map>
54+
<key>tooltip</key>
55+
<string>Represents a non-existent or undefined value. (Lua)</string>
56+
</map>
57+
<key>not</key>
58+
<map>
59+
<key>tooltip</key>
60+
<string>Logical NOT operator; inverts a boolean value. (Lua)</string>
61+
</map>
62+
<key>or</key>
63+
<map>
64+
<key>tooltip</key>
65+
<string>Logical OR operator. (Lua)</string>
66+
</map>
67+
<key>repeat</key>
68+
<map>
69+
<key>tooltip</key>
70+
<string>Begins a repeat-until loop. (Lua)</string>
71+
</map>
72+
<key>then</key>
73+
<map>
74+
<key>tooltip</key>
75+
<string>Follows an if condition to indicate the start of the consequent block. (Lua)</string>
76+
</map>
77+
<key>true</key>
78+
<map>
79+
<key>tooltip</key>
80+
<string>Boolean constant representing true. (Lua)</string>
81+
</map>
82+
<key>until</key>
83+
<map>
84+
<key>tooltip</key>
85+
<string>Ends a repeat-until loop, specifying the condition to exit. (Lua)</string>
86+
</map>
87+
<!-- LSL keywords -->
688
<key>do</key>
789
<map>
890
<key>tooltip</key>

indra/newview/llcompilequeue.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ namespace
122122
class LLQueuedScriptAssetUpload : public LLScriptAssetUpload
123123
{
124124
public:
125-
LLQueuedScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLUUID assetId, TargetType_t targetType,
125+
LLQueuedScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLUUID assetId, std::string compileTarget,
126126
bool isRunning, std::string scriptName, LLUUID queueId, LLUUID exerienceId, taskUploadFinish_f finish) :
127-
LLScriptAssetUpload(taskId, itemId, targetType, isRunning,
127+
LLScriptAssetUpload(taskId, itemId, compileTarget, isRunning,
128128
exerienceId, std::string(), finish, nullptr),
129129
mScriptName(scriptName),
130130
mQueueId(queueId)
@@ -183,9 +183,7 @@ struct LLScriptQueueData
183183

184184
// Default constructor
185185
LLFloaterScriptQueue::LLFloaterScriptQueue(const LLSD& key) :
186-
LLFloater(key),
187-
mDone(false),
188-
mMono(false)
186+
LLFloater(key)
189187
{
190188

191189
}
@@ -197,7 +195,7 @@ LLFloaterScriptQueue::~LLFloaterScriptQueue()
197195

198196
bool LLFloaterScriptQueue::postBuild()
199197
{
200-
childSetAction("close",onCloseBtn,this);
198+
childSetAction("close", onCloseBtn, this);
201199
getChildView("close")->setEnabled(false);
202200
setVisible(true);
203201
return true;
@@ -222,8 +220,8 @@ bool LLFloaterScriptQueue::start()
222220

223221
LLStringUtil::format_map_t args;
224222
args["[START]"] = mStartString;
225-
args["[COUNT]"] = llformat ("%d", mObjectList.size());
226-
buffer = getString ("Starting", args);
223+
args["[COUNT]"] = llformat("%d", mObjectList.size());
224+
buffer = getString("Starting", args);
227225

228226
getChild<LLScrollListCtrl>("queue output")->addSimpleElement(buffer, ADD_BOTTOM);
229227

@@ -276,8 +274,8 @@ bool LLFloaterCompileQueue::hasExperience( const LLUUID& id ) const
276274
return mExperienceIds.find(id) != mExperienceIds.end();
277275
}
278276

279-
// //Attempt to record this asset ID. If it can not be inserted into the set
280-
// //then it has already been processed so return false.
277+
// Attempt to record this asset ID. If it can not be inserted into the set
278+
// then it has already been processed so return false.
281279

282280
void LLFloaterCompileQueue::handleHTTPResponse(std::string pumpName, const LLSD &expresult)
283281
{
@@ -359,7 +357,7 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat
359357
LLCheckedHandle<LLFloaterCompileQueue> floater(hfloater);
360358
// Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle.
361359
// which is caught in objectScriptProcessingQueueCoro
362-
bool monocompile = floater->mMono;
360+
std::string compile_target = floater->mCompileTarget;
363361

364362
// Initial test to see if we can (or should) attempt to compile the script.
365363
LLInventoryItem *item = dynamic_cast<LLInventoryItem *>(inventory);
@@ -470,7 +468,7 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat
470468
LLResourceUploadInfo::ptr_t uploadInfo(new LLQueuedScriptAssetUpload(object->getID(),
471469
inventory->getUUID(),
472470
assetId,
473-
monocompile ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2,
471+
compile_target,
474472
true,
475473
inventory->getName(),
476474
LLUUID(),

indra/newview/llcompilequeue.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class LLFloaterScriptQueue : public LLFloater/*, public LLVOInventoryListener*/
5555

5656
/*virtual*/ bool postBuild();
5757

58-
void setMono(bool mono) { mMono = mono; }
58+
void setCompileTarget(std::string target) { mCompileTarget = target; }
5959

6060
// addObject() accepts an object id.
6161
void addObject(const LLUUID& id, std::string name);
@@ -80,8 +80,8 @@ class LLFloaterScriptQueue : public LLFloater/*, public LLVOInventoryListener*/
8080

8181
protected:
8282
// UI
83-
LLScrollListCtrl* mMessages;
84-
LLButton* mCloseBtn;
83+
LLScrollListCtrl* mMessages { nullptr };
84+
LLButton* mCloseBtn { nullptr };
8585

8686
// Object Queue
8787
struct ObjectData
@@ -93,14 +93,13 @@ class LLFloaterScriptQueue : public LLFloater/*, public LLVOInventoryListener*/
9393

9494
object_data_list_t mObjectList;
9595
LLUUID mCurrentObjectID;
96-
bool mDone;
96+
bool mDone { false };
9797

9898
std::string mStartString;
99-
bool mMono;
99+
std::string mCompileTarget { "lsl2" };
100100

101101
typedef boost::function<bool(const LLPointer<LLViewerObject> &, LLInventoryObject*, LLEventPump &)> fnQueueAction_t;
102102
static void objectScriptProcessingQueueCoro(std::string action, LLHandle<LLFloaterScriptQueue> hfloater, object_data_list_t objectList, fnQueueAction_t func);
103-
104103
};
105104

106105
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)