diff --git a/docs/Colors.md b/docs/API/Colors.md similarity index 67% rename from docs/Colors.md rename to docs/API/Colors.md index 94b1481..189fd2e 100644 --- a/docs/Colors.md +++ b/docs/API/Colors.md @@ -1,6 +1,6 @@ # Colors -The main, and possibly only, notable thing abotu **Acedia**'s colors is it's support for parsing their text representation. To be precise, **Acedia** understands: +The main notable thing about **Acedia**'s colors is it's support for parsing their text representation. To be precise, **Acedia** understands: 1. Hex color definitions in format of `#ffc0cb`; 2. RGB color definitions that look like either `rgb(255,192,203)` or `rgb(r=255,g=192,b=203)`; @@ -9,6 +9,15 @@ The main, and possibly only, notable thing abotu **Acedia**'s colors is it's sup You should be able to use any form you like while working with **Acedia**. +## Color constants + +`ColorAPI` accessed through `_.color.` also provides a large amount of color constants: + +* Constants named after their respective colors, such as `White`, ``Black` or `DeepPink`; +* System colors used by Acedia for particular purpose, such as `TextDefault`, `TextEmphasis` or `TypeNumber`. + +All of them can be changed using `AcediaSystem.ini` config. + ## [Technical] Color fixing Killing floor's standard methods of rendering colored `string`s make use of inserting 4-byte sequence into them: first bytes denotes the start of the sequence, 3 following bytes denote rgb color components. Unfortunately these methods also have issues with rendering `string`s if you specify certain values (`0` and `10`) as red-green-blue color components. diff --git a/docs/API/Console.md b/docs/API/Console.md new file mode 100644 index 0000000..feee5f9 --- /dev/null +++ b/docs/API/Console.md @@ -0,0 +1,36 @@ +# Console + +Default Killing Floor console output is ill-fit for printing long text messages due to it's automatic line breaking of long enough messages: it breaks formatting and can lead to an ugly text overlapping. To fix this `ConsoleAPI` breaks up user's output into lines by itself, before game does. + +We are not 100% sure how Killing Floor decides when to break the line, but it seems to calculate how much text can actually fit in a certain area on screen. There are two issues: + +1. We do not know for sure what this limit value is. Even if we knew how to compute it, we cannot do that in server mode, since it depends on a screen resolution and font, which can vary for different players. +2. Even invisible characters, such as color change sequences, that do not take any space on the screen, contribute towards that limit. So for a heavily colored text we will have to break line much sooner than for the plain text. + +Both issues are solved by introducing two limits: + +* Total character limit will be a hard limit on a character amount in a line (including hidden ones used for color change sequences) that will be used to prevent Killing Floor's native line breaks. +* Visible character limit will be a lower limit on amount of actually visible character. It introduction basically reserves some space that can be used only for color change sequences. Without this limit lines with colored lines will appear to be shorter that mono-colored ones. Visible limit will help to alleviate this problem. + +These limits depend on resolution and even with access to clients it's hard to determine their optimal values precisely. Acedia provides default values for these limits that should work for most people, which can be configured through `AcediaSystem.ini` file (`ConsoleAPI` section). + +## Basic usage + +Most of your interactions with `ConsoleAPI` will be through `ConsoleWriter` object that provides convenient facade to `ConsoleBuffer` (which does the actual work of breaking user messages into lines). + +It provides several useful methods for outputting `Text` console messages, all properly using it's color information: + +|Method|Short description| +|------|-----------------| +|`WriteLine()` |Outputs all the contents of `Text` in the console, breaking a line.| +|`Write()` |Writes contents of provided `Text` into the output buffer, without actually outputting it. If you chain several `Write()` calls - all of their content will be put together. To actually display them you'll need to use `Flush()` method. If accumulated buffer can't fit into a single line - it will be output as several lines, each starting with a sequence designating a line wrapping: "\| ".| +|`WriteBlock()`|Acts as `WriteLine()`, but appends additional indentation in front of all output.| +|`Say()` |Acts as `WriteLine()`, but appends player's name in front every message, like regular chat messages.| + +Simplest way to access it is from `APlayer` instance: `player.Console()`. You can also get `ConsoleWriter` that outputs messages to all players at the same time with `_.console.ForAll()`. + +## Configuration + +Total and visible character limits can be configured with `GetVisibleLineLength()`/`SetVisibleLineLength()`/`GetTotalLineLength()`/`SetTotalLineLength()` defined in both `ConsoleAPI` and `ConsoleWriter`. `ConsoleAPI`'s methods change default setting s for all future `CnosoleWriter`s and `ConsoleWriter`'s only change it's particular settings. + +Additionally default text color can be managed with `GetColor()`/`SetColor()` methods. diff --git a/docs/index.md b/docs/index.md index 1430292..181b238 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,7 +35,7 @@ Related to that is the question of `string`s. Acedia provides it's own type `Tex [Read more](introduction/Text.md) -## API +## API details ### Aliases @@ -48,3 +48,15 @@ Acedia provides mechanism to give certain values aliases: alternative names that Acedia provides dynamic and associative array collections capable of storing `AcediaObject`s. Thanks to boxing we can store essentially any type of variable inside them. [Read more](API/Collections.md) + +### Console + +Default Killing Floor console output is ill-fit for printing long text messages due to it's automatic line breaking of long enough messages. Acedia provides `ConsoleAPI` that resolves this issue in a nice and easy-to-use way. + +[Read more](API/Console.md) + +### Colors + +Acedia provides some convenience methods and constant that have to do with colors: + +[Read more](API/Colors.md)