fix: prevents illegal WPM values and uses default in those cases.

This commit is contained in:
Duncan Brown
2022-12-02 13:10:18 -05:00
committed by Julian Murgia
parent d676e50284
commit e4414141cb
3 changed files with 27 additions and 1 deletions

View File

@@ -18,6 +18,8 @@ const LEFT_CLICK_ACTION_SPEED_UP = "Speed up"
const LEFT_CLICK_ACTION_INSTANT_FINISH = "Instant finish"
const LEFT_CLICK_ACTION_NOTHING = "None"
const READING_SPEED_IN_WPM_DEFAULT_VALUE = 200
var leftClickActions: Array = [
LEFT_CLICK_ACTION_SPEED_UP,
@@ -113,7 +115,7 @@ func enable_plugin():
ESCProjectSettingsManager.register_setting(
READING_SPEED_IN_WPM,
200,
READING_SPEED_IN_WPM_DEFAULT_VALUE,
{
"type": TYPE_INT
}

View File

@@ -53,6 +53,18 @@ func _ready():
SimpleDialogPlugin.READING_SPEED_IN_WPM
)
if _reading_speed_in_wpm <= 0:
escoria.logger.warn(
self,
"%s setting must be a positive number. Will use default value of %s." %
[
SimpleDialogPlugin.READING_SPEED_IN_WPM,
SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
]
)
_reading_speed_in_wpm = SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
_word_regex.compile("\\S+")
text_node.bbcode_enabled = true

View File

@@ -52,6 +52,18 @@ func _ready():
SimpleDialogPlugin.READING_SPEED_IN_WPM
)
if _reading_speed_in_wpm <= 0:
escoria.logger.warn(
self,
"%s setting must be a positive number. Will use default value of %s." %
[
SimpleDialogPlugin.READING_SPEED_IN_WPM,
SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
]
)
_reading_speed_in_wpm = SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
_word_regex.compile("\\S+")
bbcode_enabled = true