mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 12:56:30 +01:00
Fix regressions in yes_no_handler helper
This commit is contained in:
parent
cb821229c4
commit
addf7247d0
3 changed files with 30 additions and 17 deletions
|
|
@ -69,7 +69,7 @@ class TaskHandlerTask:
|
|||
|
||||
"""
|
||||
d = self.deferred
|
||||
if d:
|
||||
if d is not None:
|
||||
d.pause()
|
||||
|
||||
def unpause(self):
|
||||
|
|
@ -78,7 +78,7 @@ class TaskHandlerTask:
|
|||
|
||||
"""
|
||||
d = self.deferred
|
||||
if d:
|
||||
if d is not None:
|
||||
d.unpause()
|
||||
|
||||
@property
|
||||
|
|
@ -94,7 +94,7 @@ class TaskHandlerTask:
|
|||
|
||||
"""
|
||||
d = self.deferred
|
||||
if d:
|
||||
if d is not None:
|
||||
return d.paused
|
||||
else:
|
||||
return None
|
||||
|
|
@ -176,7 +176,7 @@ class TaskHandlerTask:
|
|||
|
||||
"""
|
||||
d = self.deferred
|
||||
if d:
|
||||
if d is not None:
|
||||
return d.called
|
||||
else:
|
||||
return None
|
||||
|
|
@ -446,7 +446,7 @@ class TaskHandler:
|
|||
if task_id in self.tasks:
|
||||
# if the task has not been run, cancel it
|
||||
deferred = self.get_deferred(task_id)
|
||||
return not (deferred and deferred.called)
|
||||
return not (deferred is not None and deferred.called)
|
||||
else:
|
||||
return False
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ class TaskHandler:
|
|||
if task_id in self.tasks:
|
||||
# if the task has not been run, cancel it
|
||||
d = self.get_deferred(task_id)
|
||||
if d: # it is remotely possible for a task to not have a deferred
|
||||
if d is not None: # it is remotely possible for a task to not have a deferred
|
||||
if d.called:
|
||||
return False
|
||||
else: # the callback has not been called yet.
|
||||
|
|
@ -568,7 +568,7 @@ class TaskHandler:
|
|||
date, callback, args, kwargs, persistent, d = self.tasks.get(task_id)
|
||||
else: # the task does not exist
|
||||
return False
|
||||
if d: # it is remotely possible for a task to not have a deferred
|
||||
if d is not None: # it is remotely possible for a task to not have a deferred
|
||||
if not d.called: # the task's deferred has not been called yet
|
||||
d.cancel() # cancel the automated callback
|
||||
else: # this task has no deferred, and should not be called
|
||||
|
|
|
|||
|
|
@ -1638,17 +1638,19 @@ class CmdYesNoQuestion(Command):
|
|||
"""
|
||||
|
||||
key = _CMD_NOINPUT
|
||||
aliases = [_CMD_NOMATCH, "yes", "no", "y", "n", "a", "abort"]
|
||||
aliases = [_CMD_NOMATCH]
|
||||
arg_regex = r"^$"
|
||||
|
||||
def _clean(self, caller):
|
||||
del caller.ndb._yes_no_question
|
||||
if not caller.cmdset.has(YesNoQuestionCmdSet) and inherits_from(
|
||||
caller, evennia.DefaultObject
|
||||
):
|
||||
caller.account.cmdset.remove(YesNoQuestionCmdSet)
|
||||
else:
|
||||
if hasattr(caller.ndb, "_yes_no_question"):
|
||||
del caller.ndb._yes_no_question
|
||||
while caller.cmdset.has(YesNoQuestionCmdSet):
|
||||
caller.cmdset.remove(YesNoQuestionCmdSet)
|
||||
if inherits_from(caller, evennia.DefaultObject) and caller.account:
|
||||
if hasattr(caller.account.ndb, "_yes_no_question"):
|
||||
del caller.account.ndb._yes_no_question
|
||||
while caller.account.cmdset.has(YesNoQuestionCmdSet):
|
||||
caller.account.cmdset.remove(YesNoQuestionCmdSet)
|
||||
|
||||
def func(self):
|
||||
"""This is called when user enters anything."""
|
||||
|
|
@ -1665,7 +1667,7 @@ class CmdYesNoQuestion(Command):
|
|||
|
||||
inp = self.cmdname
|
||||
|
||||
if inp == _CMD_NOINPUT:
|
||||
if inp in (_CMD_NOINPUT, _CMD_NOMATCH):
|
||||
raw = self.raw_cmdname.strip()
|
||||
if not raw:
|
||||
# use default
|
||||
|
|
@ -1673,6 +1675,9 @@ class CmdYesNoQuestion(Command):
|
|||
else:
|
||||
inp = raw
|
||||
|
||||
if isinstance(inp, str):
|
||||
inp = inp.lower()
|
||||
|
||||
if inp in ("a", "abort") and yes_no_question.allow_abort:
|
||||
caller.msg(_("Aborted."))
|
||||
self._clean(caller)
|
||||
|
|
@ -1820,7 +1825,14 @@ def ask_yes_no(
|
|||
caller.ndb._yes_no_question.args = args
|
||||
caller.ndb._yes_no_question.kwargs = kwargs
|
||||
|
||||
caller.cmdset.add(YesNoQuestionCmdSet)
|
||||
# Avoid duplicate yes/no cmdsets across account/object command merges.
|
||||
while caller.cmdset.has(YesNoQuestionCmdSet):
|
||||
caller.cmdset.remove(YesNoQuestionCmdSet)
|
||||
if inherits_from(caller, evennia.DefaultObject) and caller.account:
|
||||
while caller.account.cmdset.has(YesNoQuestionCmdSet):
|
||||
caller.account.cmdset.remove(YesNoQuestionCmdSet)
|
||||
|
||||
caller.cmdset.add(YesNoQuestionCmdSet, persistent=False)
|
||||
caller.msg(prompt, session=session)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -561,7 +561,8 @@ class EvCell:
|
|||
# Preserve manually spaced/pre-formatted lines (like nested tables).
|
||||
raw_line = line.raw() if hasattr(line, "raw") else str(line)
|
||||
has_link_markup = strip_mxp(raw_line) != raw_line
|
||||
if " " in line or has_link_markup:
|
||||
has_manual_spacing = " " in raw_line.lstrip(" ")
|
||||
if has_manual_spacing or has_link_markup:
|
||||
line_width = d_len(line)
|
||||
if line_width >= width:
|
||||
aligned.append(justify(line, width, align="a", fillchar=hfill_char))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue