Skip to content

Commit

Permalink
fix: prevents illegal WPM values and uses default in those cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
BHSDuncan authored and StraToN committed Dec 4, 2022
1 parent d676e50 commit e441414
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/escoria-dialog-simple/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand 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
}
Expand Down
12 changes: 12 additions & 0 deletions addons/escoria-dialog-simple/types/avatar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions addons/escoria-dialog-simple/types/floating.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e441414

Please sign in to comment.