mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.18k stars 1.76k forks source link

Script editor/syntax highlighting in properties #1671

Open xSke opened 7 years ago

xSke commented 7 years ago

A lot of the time you'll want to add rudimentary scripting snippets to an object. It would be nice to have some form for script editor in Tiled. This should probably be a different "property type" (like int, float, color, string, etc). Editing one would pop open a lightweight code editor with syntax highlighting. There should be a dropdown somewhere to select a language for highlighting, which would be saved together with the property in the .tmx file.

Forgive my horrible UI mockups:

ketanhwr commented 7 years ago

Hi @xSke! A similar issue has been opened up previously. You can have a look here: #949

bjorn commented 7 years ago

@ketanhwr Well, this is not about Tiled itself being scriptable, but about adding language-specific syntax highlighting to the text editor.

@xSke Note that you can already write scripts by using the "string" property type and pressing the small "..." button after selecting the property value to open a primitive text editor. The only difference with your feature request is that there is no syntax highlighting.

I think currently language-specific syntax highlighting is outside the scope of Tiled, but a simple highlighter could be added that changes the color of numbers and string literals. For any kind of serious scripting, I would recommend you save your scripts in separate files and use a proper text editor to edit them. You can use the custom "file" property to refer to them from your maps (and of course, there should be a quick way to open them from Tiled then, which was planned but wasn't done yet).

xSke commented 7 years ago

I'm sure there's some sort of library for simple syntax highlighting (QScintilla, perhaps?).

The point of this would be for small inline scripts that aren't worth moving to a new file.