From 0e7a70fcc2b4c3336267c0684bb22674ec6f2ba3 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 29 Sep 2024 13:53:52 +0200 Subject: [PATCH] Update truecolor docs, improve `color truecolor` display --- CHANGELOG.md | 1 + docs/source/Coding/Changelog.md | 3 +++ docs/source/Concepts/Colors.md | 20 ++++++-------------- evennia/commands/default/account.py | 11 +++++++---- evennia/utils/hex_colors.py | 5 +++++ 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46aaa3721f..45a3017e03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ did not add it to the handler's object (Griatch) - [Fix][issue3620]: Better handle TaskHandler running against an attribute that was removed since last reload (Griatch) - [Fix][issue3616]: The `color ansi` command output was broken (Griatch) +- Fix: Extended the `color truecolor` display with usage examples. Also updated docs (Griatch) - [Docs][issue3591]: Fix of NPC reaction tutorial code (Griatch) - Docs: Tutorial fixes (Griatch, aMiss-aWry, feyrkh) diff --git a/docs/source/Coding/Changelog.md b/docs/source/Coding/Changelog.md index 13ff374afd..45a3017e03 100644 --- a/docs/source/Coding/Changelog.md +++ b/docs/source/Coding/Changelog.md @@ -38,6 +38,8 @@ did not add it to the handler's object (Griatch) - [Fix][issue3615]: Using `print()` in `py` caused an infinite loop (Griatch) - [Fix][issue3620]: Better handle TaskHandler running against an attribute that was removed since last reload (Griatch) +- [Fix][issue3616]: The `color ansi` command output was broken (Griatch) +- Fix: Extended the `color truecolor` display with usage examples. Also updated docs (Griatch) - [Docs][issue3591]: Fix of NPC reaction tutorial code (Griatch) - Docs: Tutorial fixes (Griatch, aMiss-aWry, feyrkh) @@ -49,6 +51,7 @@ did not add it to the handler's object (Griatch) [issue3624]: https://github.com/evennia/evennia/issues/3624 [issue3615]: https://github.com/evennia/evennia/issues/3615 [issue3620]: https://github.com/evennia/evennia/issues/3620 +[issue3616]: https://github.com/evennia/evennia/issues/3616 [pull3595]: https://github.com/evennia/evennia/pull/3595 [pull3533]: https://github.com/evennia/evennia/pull/3533 [pull3594]: https://github.com/evennia/evennia/pull/3594 diff --git a/docs/source/Concepts/Colors.md b/docs/source/Concepts/Colors.md index 96a9f8b810..c59d3099f5 100644 --- a/docs/source/Concepts/Colors.md +++ b/docs/source/Concepts/Colors.md @@ -5,25 +5,19 @@ Color can be a very useful tool for your game. It can be used to increase readability and make your game more appealing visually. -Remember however that, with the exception of the webclient, you generally don't control the client -used to connect to the game. There is, for example, one special tag meaning "yellow". But exactly -*which* hue of yellow is actually displayed on the user's screen depends on the settings of their -particular mud client. They could even swap the colours around or turn them off altogether if so -desired. Some clients don't even support color - text games are also played with special reading -equipment by people who are blind or have otherwise diminished eyesight. +Remember however that, with the exception of the webclient, you generally don't control the client used to connect to the game. There is, for example, one special tag meaning "yellow". But exactly *which* hue of yellow is actually displayed on the user's screen depends on the settings of their particular mud client. They could even swap the colours around or turn them off altogether if so desired. Some clients don't even support color - text games are also played with special reading equipment by people who are blind or have otherwise diminished eyesight. So a good rule of thumb is to use colour to enhance your game but don't *rely* on it to display -critical information. If you are coding the game, you can add functionality to let users disable -colours as they please, as described [here](../Howtos/Manually-Configuring-Color.md). +critical information. The default `screenreader` command will automatically turn off all color for a user (as well as clean up many line decorations etc). Make sure your game is still playable and understandable with this active. Evennia supports two color standards: - `ANSI` - 16 foreground colors + 8 background colors. Widely supported. -- `Xterm256` - 128 RGB colors, 32 greyscales. Not always supported in old clients. +- `Xterm256` - 128 RGB colors, 32 greyscales. Not always supported in old clients. Falls back to ANSI. +- `Truecolor` - 24B RGB colors using hex notation. Not supported by many clients. Falls back to `XTerm256`. To see which colours your client support, use the default `color` command. This will list all -available colours for ANSI and Xterm256 along with the codes you use for them. The -central ansi/xterm256 parser is located in [evennia/utils/ansi.py](evennia.utils.ansi). +available colours for ANSI and Xterm256, as well as a selection of True color codes along with the codes you use for them. The central ansi/xterm256 parser is located in [evennia/utils/ansi.py](evennia.utils.ansi), the true color one in [evennia/utils/true/hex_colors.py](evennia.utils.hex_colors). ## ANSI colours and symbols @@ -187,11 +181,9 @@ See the [Wikipedia entry on web colors](https://en.wikipedia.org/wiki/Web_colors ``` Some clients support 24-bit colors. This is also called [true color](https://en.wikipedia.org/wiki/Color_depth#True_color_(24-bit)). -Not all clients support true color, they will instead see the closest equivalent. It's important to bear in mind that things may look quite -different from what you intended if you use subtle gradations in true color and it's viewed with a client that doesn't support true color. +Not all clients support true color, they will instead see the closest equivalent. It's important to bear in mind that things may look quite different from what you intended if you use subtle gradations in true color and it's viewed with a client that doesn't support true color. The hexadecimal color codes used here are the same ones used in web design. - | Tag | Effect | | -------- | ---- | | \|#$$$$$$ | foreground RGB (red/green/blue), 6-digit hexadecimal format, where $ = 0-F | diff --git a/evennia/commands/default/account.py b/evennia/commands/default/account.py index 93c8e17e92..51f3978de9 100644 --- a/evennia/commands/default/account.py +++ b/evennia/commands/default/account.py @@ -931,14 +931,17 @@ class CmdColorTest(COMMAND_DEFAULT_CLASS): elif self.args.startswith("t"): # show abbreviated truecolor sample (16.7 million colors in truecolor) - string = "" + string = ( + "\n" + "True Colors (if this is not a smooth rainbow transition, your client might not " + "report that it can handle truecolor): \n" + ) for i in range(76): string += f"|[{self.make_hex_color_from_column(i)} |n" string += ( - "\n" - + "some of the truecolor colors (if not all hues show, your client might not report that it can" - " handle trucolor.):" + "\n|nfg: |#FF0000||#FF0000|n (|#F00||#F00|n) to |#0000FF||#0000FF|n (|#00F||#00F|n)" + "\n|nbg: |[#FF0000||[#FF0000|n (|[#F00||[#F00|n) to |n|[#0000FF||[#0000FF |n(|[#00F||[#00F|n)" ) self.msg(string) diff --git a/evennia/utils/hex_colors.py b/evennia/utils/hex_colors.py index 3ca921bc3b..dedfadc515 100644 --- a/evennia/utils/hex_colors.py +++ b/evennia/utils/hex_colors.py @@ -1,3 +1,8 @@ +""" +Truecolor 24bit hex color support, on the form `|#00FF00`, `|[00FF00` or `|#0F0 or `|[#0F0` + +""" + import re