mirror of
https://github.com/evennia/evennia.git
synced 2026-03-31 13:07:16 +02:00
This fixes issue #569
This commit is contained in:
parent
46781d3ee1
commit
dbbacb4bb3
6 changed files with 82 additions and 13 deletions
|
|
@ -21,3 +21,4 @@ class UnloggedinCmdSet(CmdSet):
|
|||
self.add(unloggedin.CmdUnconnectedQuit())
|
||||
self.add(unloggedin.CmdUnconnectedLook())
|
||||
self.add(unloggedin.CmdUnconnectedHelp())
|
||||
self.add(unloggedin.CmdUnconnectedEncoding())
|
||||
|
|
|
|||
|
|
@ -457,19 +457,21 @@ class CmdEncoding(MuxPlayerCommand):
|
|||
"""
|
||||
Sets the encoding.
|
||||
"""
|
||||
player = self.player
|
||||
|
||||
if self.session is None:
|
||||
return
|
||||
|
||||
if 'clear' in self.switches:
|
||||
# remove customization
|
||||
old_encoding = player.db.encoding
|
||||
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."
|
||||
del player.db.encoding
|
||||
self.session.encoding = "utf-8"
|
||||
elif not self.args:
|
||||
# just list the encodings supported
|
||||
pencoding = player.db.encoding
|
||||
pencoding = self.session.encoding
|
||||
string = ""
|
||||
if pencoding:
|
||||
string += "Default encoding: {g%s{n (change with {w@encoding <encoding>{n)" % pencoding
|
||||
|
|
@ -480,9 +482,9 @@ class CmdEncoding(MuxPlayerCommand):
|
|||
string = "No encodings found."
|
||||
else:
|
||||
# change encoding
|
||||
old_encoding = player.db.encoding
|
||||
old_encoding = self.session.encoding
|
||||
encoding = self.args
|
||||
player.db.encoding = encoding
|
||||
self.session.encoding = encoding
|
||||
string = "Your custom text encoding was changed from '%s' to '%s'." % (old_encoding, encoding)
|
||||
self.msg(string.strip())
|
||||
|
||||
|
|
|
|||
|
|
@ -334,6 +334,69 @@ You can use the {wlook{n command if you want to see the connect screen again.
|
|||
self.caller.msg(string)
|
||||
|
||||
|
||||
class CmdUnconnectedEncoding(MuxCommand):
|
||||
"""
|
||||
set which text encoding to use in unconnected-in state
|
||||
|
||||
Usage:
|
||||
@encoding/switches [<encoding>]
|
||||
|
||||
Switches:
|
||||
clear - clear your custom encoding
|
||||
|
||||
|
||||
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"
|
||||
locks = "cmd:all()"
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
Sets the encoding.
|
||||
"""
|
||||
|
||||
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:
|
||||
# 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.caller.msg(string.strip())
|
||||
|
||||
|
||||
def _create_player(session, playername, password,
|
||||
default_home, permissions, typeclass=None):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue