Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Inputvalue.disable_on_enter #4849

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions renpy/common/00inputvalues.rpy
Expand Up @@ -86,6 +86,7 @@ init -1510 python:
default = True
editable = True
returnable = False
disable_on_enter = False

def get_text(self):
raise NotImplementedError
Expand All @@ -96,8 +97,9 @@ init -1510 python:
def enter(self):
if self.returnable:
return self.get_text()
else:
return None
elif self.disable_on_enter:
renpy.run(self.Disable())
raise renpy.IgnoreEvent

def Enable(self):
if self.editable:
Expand All @@ -123,11 +125,12 @@ init -1510 python:
common features of the documented input value classes.
"""

equality_fields = ("default", "returnable")
equality_fields = ("default", "returnable", "disable_on_enter")

def __init__(self, default=True, returnable=False):
def __init__(self, default=True, returnable=False, disable_on_enter=False):
self.default = default
self.returnable = returnable
self.disable_on_enter = disable_on_enter

class ScreenVariableInputValue(__GenericInputValue):
"""
Expand Down Expand Up @@ -287,6 +290,9 @@ init -1510 python hide:
`returnable`
If true, the value of this input will be returned when the
user presses enter.
`disable_on_enter`
If true, and if `returnable` is not true, pressing enter
will disable this input.
""")

for ivalue in (ScreenVariableInputValue, FieldInputValue, VariableInputValue, DictInputValue, LocalVariableInputValue):
Expand Down
27 changes: 15 additions & 12 deletions sphinx/source/changelog.rst
Expand Up @@ -124,27 +124,30 @@ displayed. Clicking on the filename and line will open
the file in the default text editor, at the given line,
if possible.

Data Actions
------------
Actions and Screen Values
-------------------------

The :ref:`data-actions` are now presented and explained in a more
condensed manner. These actions have been reimplemented using a data
manager that describes what to do with the data (Set-, Toggle-, Cycle-, Increment-)
and a data accessor that describes the kind of data to change (-Variable, -ScreenVariable, -LocalVariable, -Field, -Dict).
The :ref:`data-actions` are now presented and explained in a more condensed
manner. These actions have been reimplemented using a data manager that
describes what to do with the data (Set-, Toggle-, Cycle-, Increment-) and a
data accessor that describes the kind of data to change
(-Variable, -ScreenVariable, -LocalVariable, -Field, -Dict).

There are two new managers:

* The Cycle- actions (CycleVariable, CycleLocalVariable, CycleField...)
take a list of values and each time the action is run (i.e each time
the button is clicked), the target value is set to be the next element in
the list.
* The Cycle- actions (CycleVariable, CycleLocalVariable, CycleField...) take a
list of values and each time the action is run (i.e each time the button is
clicked), the target value is set to be the next element in the list.
* The Increment- actions (IncrementVariable, IncrementDict, IncrementField...)
add a certain value (by default, 1) to the target value. These can also be used
to decrement the field.
add a certain value (by default, 1) to the target value. These can also be
used to decrement the field.

The :class:`LocalVariableValue` bar value and :class:`LocalVariableInputValue` input
values have been added, for completeness.

:ref:`input-values` now take an optional `disable_on_enter` parameter which
makes them disable themselves when the enter key is pressed.

HTTPS/HTTP Fetch
----------------

Expand Down