Open Barsonax opened 7 years ago
Two things to consider:
As mentioned, there are different newline characters on different platforms. It will not be enough to simply check for Environment.NewLine
wherever /n
was used before, because the content will be produced on one platform while the game can be run on another one.
It might be easiest to ignore \r
as a control character completely and use \n
directly, as this is the common denominator of both Windows and Unix.
Building up on this, time might be ripe for a proper design of text formatting. This is a task that first requires a lot of concept work, but since text formatting is one part of Duality that hasn't seen a considerable amount of design work in total, there might be a bit to gain. It depends, but a brainstorming on this wouldn't hurt.
Example: The choice of using special character-like markup consisting of /xy
strings is a historic one. Consider using a proper markup format, something like a markdown- or simple-html-like?
Maybe BB code would work
What context are we talking about here?
@BobGneu We're talking about the text markup in the FormattedText
class, which is used by TextRenderer
and a lot of regular game / editor code for displaying "rich text", i.e. text blocks with automatic word wrap, alignment, multiple fonts, and colors.
The key idea would be to take some time and redesign both the FormattedText
internals and the "markup language" that is used. Right now, it's sort of an ugly slash-prefix command style like "/n", "/f[1]", "/cFF0000FF" and similar. It's not yet defined what a better markup would look like, or what changes would need to be done to the implementation.
There are quite a few options for markup here, but I don't think they tend to be as capable as richtext markup is. What about adding WYSIWYG editor and internalize a format that makes sense on the technical side? Is the intent to be able to edit the text outside of the editor?
One requirement would definitely be to allow comfortably editing the markup in text form, without any kind of specialized editor: A typical use case for this will be to specify marked-up texts in source code or data files.
Maybe we could collect a few samples on how a simple markup language could look like. It definitely shouldn't be too complex, but bonus points for being recognizable and easy to use. The operations we need to cover are:
Newline: /n
Switch color: /cRRGGBBAA
Switch font: /f[index]
Change alignment: /al /ar /ac
Invisible element separator: /e
Newline: <br>
Switch color: <color=RRGGBBAA>Text</color>
Switch font: <font=index>Text</font>
Change alignment: <align=dir>
Invisible element separator: <element>Text</element>
Newline: \n
Switch color: [Text](color=RRGGBBAA)
Switch font: [Text](font=index)
Change alignment: ?
Invisible element separator: `Text`
Newline: [br]
Switch color: [color=RRGGBBAA]Text[/color]
Switch font: [font=index]Text[/font]
Change alignment: [align=dir]
Invisible element separator: [element]Text[/element]
[]
is more widely used than <>
that is.Overall not sure where exactly to go with this. Maybe we could just keep the current markup for now and simply evaluate the proper newline char \n
in addition to the newline markup /n
, while deferring a redesign until we have found a good alternative. Could be a self-contained Pull Request actually.
Summary
Currently duality is using /n as a newline character. This is a non standard way for newline characters. It would be better if it would follow the standard way:
Environment.NewLine (https://msdn.microsoft.com/en-us/library/system.environment.newline(v=vs.110).aspx) does exactly this
Analysis
This would make it easier to work with newlines in duality since its using the standard way. On top of that it will be more consistent across different OS systems.