Added support for screen readers via the new option command (which merges the ability to set the screenreader mode with the encoding command). The new setting.SCREENREADER_REGEX_STRIP allows to customize what the screenreader mode strips.
This commit is contained in:
parent
10dbae9849
commit
4f384dc514
7 changed files with 85 additions and 55 deletions
|
|
@ -32,7 +32,7 @@ class PlayerCmdSet(CmdSet):
|
|||
self.add(player.CmdCharCreate())
|
||||
#self.add(player.CmdSessions())
|
||||
self.add(player.CmdWho())
|
||||
self.add(player.CmdEncoding())
|
||||
self.add(player.CmdOption())
|
||||
self.add(player.CmdQuit())
|
||||
self.add(player.CmdPassword())
|
||||
self.add(player.CmdColorTest())
|
||||
|
|
|
|||
|
|
@ -22,3 +22,4 @@ class UnloggedinCmdSet(CmdSet):
|
|||
self.add(unloggedin.CmdUnconnectedLook())
|
||||
self.add(unloggedin.CmdUnconnectedHelp())
|
||||
self.add(unloggedin.CmdUnconnectedEncoding())
|
||||
self.add(unloggedin.CmdUnconnectedScreenreader())
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ MULTISESSION_MODE = settings.MULTISESSION_MODE
|
|||
|
||||
# limit symbol import for API
|
||||
__all__ = ("CmdOOCLook", "CmdIC", "CmdOOC", "CmdPassword", "CmdQuit",
|
||||
"CmdCharCreate", "CmdEncoding", "CmdSessions", "CmdWho",
|
||||
"CmdCharCreate", "CmdOption", "CmdSessions", "CmdWho",
|
||||
"CmdColorTest", "CmdQuell")
|
||||
|
||||
# force max nr chars to 1 if mode is 0 or 1
|
||||
|
|
@ -405,67 +405,62 @@ class CmdWho(MuxPlayerCommand):
|
|||
self.msg(string)
|
||||
|
||||
|
||||
class CmdEncoding(MuxPlayerCommand):
|
||||
class CmdOption(MuxPlayerCommand):
|
||||
"""
|
||||
set which text encoding to use
|
||||
Set an account option
|
||||
|
||||
Usage:
|
||||
@encoding/switches [<encoding>]
|
||||
@option
|
||||
@option encoding = [encoding]
|
||||
@option screenreader = on|off
|
||||
|
||||
Switches:
|
||||
clear - clear your custom encoding
|
||||
The text encoding is mostly an issue only if you want to use
|
||||
non-ASCII characters (i.e. letters/symbols not found in English).
|
||||
If you see that your characters look strange (or you get encoding
|
||||
errors), you should use this command to set the server encoding to
|
||||
be the same used in your client program. If given the empty string
|
||||
(default), the custom encoding will be removed and only Evennia's
|
||||
defaults will be used.
|
||||
|
||||
The screenreader setting strips the text output for users using
|
||||
screen readers. It strips based on settings.SCREENREADER_REGEX_STRIP.
|
||||
|
||||
This sets the text encoding for communicating with Evennia. This is mostly
|
||||
an issue only if you want to use non-ASCII characters (i.e. letters/symbols
|
||||
not found in English). If you see that your characters look strange (or you
|
||||
get encoding errors), you should use this command to set the server
|
||||
encoding to be the same used in your client program.
|
||||
|
||||
Common encodings are utf-8 (default), latin-1, ISO-8859-1 etc.
|
||||
|
||||
If you don't submit an encoding, the current encoding will be displayed
|
||||
instead.
|
||||
"""
|
||||
|
||||
key = "@encoding"
|
||||
aliases = "@encode"
|
||||
"""
|
||||
key = "@option"
|
||||
aliases = "@options"
|
||||
locks = "cmd:all()"
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
Sets the encoding.
|
||||
Implements the command
|
||||
"""
|
||||
|
||||
if self.session is None:
|
||||
return
|
||||
|
||||
if 'clear' in self.switches:
|
||||
# remove customization
|
||||
old_encoding = self.session.encoding
|
||||
if old_encoding:
|
||||
string = "Your custom text encoding ('%s') was cleared." % old_encoding
|
||||
else:
|
||||
string = "No custom encoding was set."
|
||||
self.session.encoding = "utf-8"
|
||||
elif not self.args:
|
||||
# just list the encodings supported
|
||||
pencoding = self.session.encoding
|
||||
string = ""
|
||||
if pencoding:
|
||||
string += "Default encoding: {g%s{n (change with {w@encoding <encoding>{n)" % pencoding
|
||||
encodings = settings.ENCODINGS
|
||||
if encodings:
|
||||
string += "\nServer's alternative encodings (tested in this order):\n {g%s{n" % ", ".join(encodings)
|
||||
if not string:
|
||||
string = "No encodings found."
|
||||
else:
|
||||
if not self.args:
|
||||
# list the option settings
|
||||
string = "{wEncoding{n:\n"
|
||||
pencoding = self.session.encoding or "None"
|
||||
sencodings = settings.ENCODINGS
|
||||
string += " Custom: %s\n Server: %s" % (pencoding, ", ".join(sencodings))
|
||||
string += "\n{wScreen Reader mode:{n %s" % self.session.screenreader
|
||||
self.caller.msg(string)
|
||||
return
|
||||
|
||||
if not self.rhs:
|
||||
self.caller.msg("Usage: @option [name = [value]]")
|
||||
|
||||
if self.lhs == "encoding":
|
||||
# change encoding
|
||||
old_encoding = self.session.encoding
|
||||
encoding = self.args
|
||||
self.session.encoding = encoding
|
||||
string = "Your custom text encoding was changed from '%s' to '%s'." % (old_encoding, encoding)
|
||||
self.msg(string.strip())
|
||||
new_encoding = self.rhs.strip() or "utf-8"
|
||||
self.session.encoding = new_encoding
|
||||
self.caller.msg("Encoding was changed from %s to %s." % (old_encoding, new_encoding))
|
||||
return
|
||||
|
||||
if self.lhs == "screenreader":
|
||||
onoff = self.rhs.lower() == "on"
|
||||
self.session.screenreader = onoff
|
||||
self.caller.msg("Screen reader mode was turned {w%s{n." % ("on" if onoff else "off"))
|
||||
|
||||
|
||||
class CmdPassword(MuxPlayerCommand):
|
||||
|
|
|
|||
|
|
@ -361,6 +361,7 @@ You are not yet logged into the game. Commands available at this point:
|
|||
{wlook{n - re-show the connection screen
|
||||
{whelp{n - show this help
|
||||
{wencoding{n - change the text encoding to match your client
|
||||
{wscreenreader{n - make the server more suitable for use with screen readers
|
||||
{wquit{n - abort the connection
|
||||
|
||||
First create an account e.g. with {wcreate Anna c67jHL8p{n
|
||||
|
|
@ -397,7 +398,7 @@ class CmdUnconnectedEncoding(MuxCommand):
|
|||
"""
|
||||
|
||||
key = "encoding"
|
||||
aliases = "@encoding, @encode"
|
||||
aliases = ("@encoding", "@encode")
|
||||
locks = "cmd:all()"
|
||||
|
||||
def func(self):
|
||||
|
|
@ -435,6 +436,25 @@ class CmdUnconnectedEncoding(MuxCommand):
|
|||
string = "Your custom text encoding was changed from '%s' to '%s'." % (old_encoding, encoding)
|
||||
self.caller.msg(string.strip())
|
||||
|
||||
class CmdUnconnectedScreenreader(MuxCommand):
|
||||
"""
|
||||
Activate screenreader mode.
|
||||
|
||||
Usage:
|
||||
screenreader
|
||||
|
||||
Used to flip screenreader mode on and off before logging in (when
|
||||
logged in, use @option screenreader on).
|
||||
"""
|
||||
key = "screenreader"
|
||||
aliases = "@screenreader"
|
||||
|
||||
def func(self):
|
||||
"Flips screenreader setting."
|
||||
self.session.screenreader = not self.session.screenreader
|
||||
string = "Screenreader mode turned {w%s{n." % ("on" if self.session.screenreader else "off")
|
||||
self.caller.msg(string)
|
||||
|
||||
|
||||
def _create_player(session, playername, password, permissions, typeclass=None):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue