Skip to content

Commit

Permalink
Fixed '/settings show' command when some settings exist only on world…
Browse files Browse the repository at this point in the history
…s but not globally (so, net.*).
  • Loading branch information
pvaret committed Jan 20, 2015
1 parent df7347a commit 5c4cdb3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
7 changes: 4 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ This is an unordered list of features that need implementing sooner or later:
* Aliases (/alias str 'send something to the world with [PARAMETERS]')
* Clean up ActionSet with config/shortcut-aware QAction subclasses and no closures.
* Fix paging when it starts off and is turned on later.
* Move every setting (so, net.*) to the global scope. The distinction just isn't useful.

Protocol support:

* Telnet (non-trivial option negotiation: ECHO, TTYPE, GA, SGA, EOR, NAWS; see http://www.mudpedia.org/wiki/TELNET)
* VT100 escape codes (even if we ignore them, they shouldn't be displayed! See http://www.mudpedia.org/wiki/VT100 & http://ascii-table.com/ansi-escape-sequences-vt-100.php).
* 256 color ANSI (see http://www.mudpedia.org/wiki/Xterm_color)
* Telnet (non-trivial option negotiation: ECHO, TTYPE, GA, SGA, EOR, NAWS; see http://www.mudpedia.org/mediawiki/index.php/TELNET)
* VT100 escape codes (even if we ignore them, they shouldn't be displayed! See http://www.mudpedia.org/mediawiki/index.php/VT100 & http://ascii-table.com/ansi-escape-sequences-vt-100.php).
* 256 color ANSI (see http://www.mudpedia.org/mediawiki/index.php/Xterm_color)
* MCCP
* MCP? MXP?
* FANSI 2.0 (see http://fansi.org/)
8 changes: 8 additions & 0 deletions src/Serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,19 @@ class Str( BaseSerializer ):

def deserialize( self, string ):

## The empty string deserializes to None.
if not string:
return None

return unquote( string )


def serialize( self, string ):

## None serializes to the empty string.
if string is None:
return u''

return quote( string )


Expand Down
2 changes: 1 addition & 1 deletion src/SpyritSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@

'ui.window.alert': u"animate taskbar when text is received from the server",

#'net.encoding': u"server character encoding",
'net.encoding': u"server character encoding",
'net.login_script': u"arbitrary text to send on connect",

'shortcuts.about': u"shortcut: About... dialog",
Expand Down
24 changes: 18 additions & 6 deletions src/commands/SettingsCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,15 @@ def cmd_show( self, world, setting=None ):

for k in sorted( DESCRIPTIONS ):

if not all( s.get( k ).isEmpty() for s in ( settings, worldsettings ) ):
list_settings.append( k )
for context in ( settings, worldsettings ):

try:
if not context.get( k ).isEmpty():
list_settings.append( k )
break

except KeyError: ## Happens if a key exists only on worlds.
pass

if not list_settings:
world.info( u"All the settings have default values." )
Expand All @@ -261,16 +268,21 @@ def cmd_show( self, world, setting=None ):

columns = [ list_settings ]

for node in ( None, settings, worldsettings ):
DEFAULT = object() ## marker for the case of default values.

for node in ( DEFAULT, settings, worldsettings ):

column = []

for k in list_settings:

s = self._getSerializer( node or settings, k )
s = self._getSerializer( node if node is not DEFAULT else worldsettings, k )

if s is None: ## The key doesn't exist in this context. This is
value = u" " ## likely a world-only key.

if node is None: ## Hackish: 'None' here means defaults.
value = s.serialize( settings.get( k ).proto.default_value )
elif node is DEFAULT:
value = s.serialize( worldsettings.get( k ).proto.default_value )

else:
value = s.serialize( node[ k ] ) if not node.get( k ).isEmpty() else u"-"
Expand Down

0 comments on commit 5c4cdb3

Please sign in to comment.