Merge branch 'master' of github.com:evennia/evennia
This commit is contained in:
commit
06588f6695
4 changed files with 81 additions and 5 deletions
|
|
@ -2856,7 +2856,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
key = "@spawn"
|
key = "@spawn"
|
||||||
aliases = ["olc"]
|
aliases = ["olc"]
|
||||||
switch_options = ("noloc", "search", "list", "show", "save", "delete", "menu", "olc", "update")
|
switch_options = ("noloc", "search", "list", "show", "examine", "save", "delete", "menu", "olc", "update", "edit")
|
||||||
locks = "cmd:perm(spawn) or perm(Builder)"
|
locks = "cmd:perm(spawn) or perm(Builder)"
|
||||||
help_category = "Building"
|
help_category = "Building"
|
||||||
|
|
||||||
|
|
@ -2907,12 +2907,13 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
|
|
||||||
if self.cmdstring == "olc" or 'menu' in self.switches or 'olc' in self.switches:
|
if self.cmdstring == "olc" or 'menu' in self.switches \
|
||||||
|
or 'olc' in self.switches or 'edit' in self.switches:
|
||||||
# OLC menu mode
|
# OLC menu mode
|
||||||
prototype = None
|
prototype = None
|
||||||
if self.lhs:
|
if self.lhs:
|
||||||
key = self.lhs
|
key = self.lhs
|
||||||
prototype = spawner.search_prototype(key=key, return_meta=True)
|
prototype = protlib.search_prototype(key=key)
|
||||||
if len(prototype) > 1:
|
if len(prototype) > 1:
|
||||||
caller.msg("More than one match for {}:\n{}".format(
|
caller.msg("More than one match for {}:\n{}".format(
|
||||||
key, "\n".join(proto.get('prototype_key', '') for proto in prototype)))
|
key, "\n".join(proto.get('prototype_key', '') for proto in prototype)))
|
||||||
|
|
@ -2920,6 +2921,10 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||||
elif prototype:
|
elif prototype:
|
||||||
# one match
|
# one match
|
||||||
prototype = prototype[0]
|
prototype = prototype[0]
|
||||||
|
else:
|
||||||
|
# no match
|
||||||
|
caller.msg("No prototype '{}' was found.".format(key))
|
||||||
|
return
|
||||||
olc_menus.start_olc(caller, session=self.session, prototype=prototype)
|
olc_menus.start_olc(caller, session=self.session, prototype=prototype)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -478,6 +478,61 @@ class TestBuilding(CommandTest):
|
||||||
# Test listing commands
|
# Test listing commands
|
||||||
self.call(building.CmdSpawn(), "/list", "Key ")
|
self.call(building.CmdSpawn(), "/list", "Key ")
|
||||||
|
|
||||||
|
# @spawn/edit (missing prototype)
|
||||||
|
# brings up olc menu
|
||||||
|
msg = self.call(
|
||||||
|
building.CmdSpawn(),
|
||||||
|
'/edit')
|
||||||
|
assert 'Prototype wizard' in msg
|
||||||
|
|
||||||
|
# @spawn/edit with valid prototype
|
||||||
|
# brings up olc menu loaded with prototype
|
||||||
|
msg = self.call(
|
||||||
|
building.CmdSpawn(),
|
||||||
|
'/edit testball')
|
||||||
|
assert 'Prototype wizard' in msg
|
||||||
|
assert hasattr(self.char1.ndb._menutree, "olc_prototype")
|
||||||
|
assert dict == type(self.char1.ndb._menutree.olc_prototype) \
|
||||||
|
and 'prototype_key' in self.char1.ndb._menutree.olc_prototype \
|
||||||
|
and 'key' in self.char1.ndb._menutree.olc_prototype \
|
||||||
|
and 'testball' == self.char1.ndb._menutree.olc_prototype['prototype_key'] \
|
||||||
|
and 'Ball' == self.char1.ndb._menutree.olc_prototype['key']
|
||||||
|
assert 'Ball' in msg and 'testball' in msg
|
||||||
|
|
||||||
|
# @spawn/edit with valid prototype (synomym)
|
||||||
|
msg = self.call(
|
||||||
|
building.CmdSpawn(),
|
||||||
|
'/edit BALL')
|
||||||
|
assert 'Prototype wizard' in msg
|
||||||
|
assert 'Ball' in msg and 'testball' in msg
|
||||||
|
|
||||||
|
# @spawn/edit with invalid prototype
|
||||||
|
msg = self.call(
|
||||||
|
building.CmdSpawn(),
|
||||||
|
'/edit NO_EXISTS',
|
||||||
|
"No prototype 'NO_EXISTS' was found.")
|
||||||
|
|
||||||
|
# @spawn/examine (missing prototype)
|
||||||
|
# lists all prototypes that exist
|
||||||
|
msg = self.call(
|
||||||
|
building.CmdSpawn(),
|
||||||
|
'/examine')
|
||||||
|
assert 'testball' in msg and 'testprot' in msg
|
||||||
|
|
||||||
|
# @spawn/examine with valid prototype
|
||||||
|
# prints the prototype
|
||||||
|
msg = self.call(
|
||||||
|
building.CmdSpawn(),
|
||||||
|
'/examine BALL')
|
||||||
|
assert 'Ball' in msg and 'testball' in msg
|
||||||
|
|
||||||
|
# @spawn/examine with invalid prototype
|
||||||
|
# shows error
|
||||||
|
self.call(
|
||||||
|
building.CmdSpawn(),
|
||||||
|
'/examine NO_EXISTS',
|
||||||
|
"No prototype 'NO_EXISTS' was found.")
|
||||||
|
|
||||||
|
|
||||||
class TestComms(CommandTest):
|
class TestComms(CommandTest):
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -562,6 +562,7 @@ def node_index(caller):
|
||||||
|
|
||||||
text = """
|
text = """
|
||||||
|c --- Prototype wizard --- |n
|
|c --- Prototype wizard --- |n
|
||||||
|
%s
|
||||||
|
|
||||||
A |cprototype|n is a 'template' for |wspawning|n an in-game entity. A field of the prototype
|
A |cprototype|n is a 'template' for |wspawning|n an in-game entity. A field of the prototype
|
||||||
can either be hard-coded, left empty or scripted using |w$protfuncs|n - for example to
|
can either be hard-coded, left empty or scripted using |w$protfuncs|n - for example to
|
||||||
|
|
@ -599,6 +600,17 @@ def node_index(caller):
|
||||||
{pfuncs}
|
{pfuncs}
|
||||||
""".format(pfuncs=_format_protfuncs())
|
""".format(pfuncs=_format_protfuncs())
|
||||||
|
|
||||||
|
# If a prototype is being edited, show its key and
|
||||||
|
# prototype_key under the title
|
||||||
|
loaded_prototype = ''
|
||||||
|
if 'prototype_key' in prototype \
|
||||||
|
or 'key' in prototype:
|
||||||
|
loaded_prototype = ' --- Editing: |y{}({})|n --- '.format(
|
||||||
|
prototype.get('key', ''),
|
||||||
|
prototype.get('prototype_key', '')
|
||||||
|
)
|
||||||
|
text = text % (loaded_prototype)
|
||||||
|
|
||||||
text = (text, helptxt)
|
text = (text, helptxt)
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,12 @@ let history_plugin = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (history_entry !== null) {
|
if (history_entry !== null) {
|
||||||
// Doing a history navigation; replace the text in the input.
|
// Performing a history navigation
|
||||||
inputfield.val(history_entry);
|
// replace the text in the input and move the cursor to the end of the new value
|
||||||
|
inputfield.val('');
|
||||||
|
inputfield.blur().focus().val(history_entry);
|
||||||
|
event.preventDefault();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue