Skip to content

Commit

Permalink
allowed more control over menu item's key repeat rates
Browse files Browse the repository at this point in the history
  • Loading branch information
imprity committed Aug 14, 2024
1 parent 0d26b60 commit 5a21217
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 15 additions & 5 deletions menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ type MenuItem struct {
KeyStrokeWidthRegular float32
KeyStrokeWidthSelected float32

LeftRightKeyFirstRate time.Duration
LeftRightKeyRepeatRate time.Duration

// variables for animations
NameClickTimer time.Duration
ValueClickTimer time.Duration
Expand Down Expand Up @@ -164,6 +167,9 @@ var MenuItemDefaults = MenuItem{
KeyColorStrokeSelected: FnfColor{0, 0, 0, 0xFF},

KeyStrokeWidthSelected: 10,

LeftRightKeyFirstRate: time.Millisecond * 200,
LeftRightKeyRepeatRate: time.Millisecond * 100,
}

func NewMenuItem() *MenuItem {
Expand Down Expand Up @@ -615,11 +621,15 @@ func (md *MenuDrawer) Update(deltaTime time.Duration) {
switch selected.Type {
case MenuItemList, MenuItemNumber, MenuItemToggle, MenuItemKey:
// check if user wants to go left or right
const firstRate = time.Millisecond * 200
const repeateRate = time.Millisecond * 110

wantGoLeft := HandleKeyRepeat(md.InputId, firstRate, repeateRate, NoteKeys(NoteDirLeft)...)
wantGoRight := HandleKeyRepeat(md.InputId, firstRate, repeateRate, NoteKeys(NoteDirRight)...)
wantGoLeft := HandleKeyRepeat(md.InputId,
selected.LeftRightKeyFirstRate,
selected.LeftRightKeyRepeatRate,
NoteKeys(NoteDirLeft)...)
wantGoRight := HandleKeyRepeat(
md.InputId,
selected.LeftRightKeyFirstRate,
selected.LeftRightKeyRepeatRate,
NoteKeys(NoteDirRight)...)

// check if item can go left or right
canGoLeft := true
Expand Down
4 changes: 3 additions & 1 deletion options_screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ func NewOptionsMainScreen() *BaseOptionsScreen {
fpsItem.NValue = float32(TheOptions.TargetFPS)
fpsItem.NValueMin = 30
fpsItem.NValueMax = 500
fpsItem.NValueInterval = 10
fpsItem.NValueInterval = 1
fpsItem.NValueFmtString = "%1.f"
fpsItem.LeftRightKeyRepeatRate = time.Millisecond * 25
fpsItem.NumberCallback = func(nValue float32) {
TheOptions.TargetFPS = int32(nValue)
}
Expand Down Expand Up @@ -434,6 +435,7 @@ func NewOptionsGamePlayScreen() *BaseOptionsScreen {
ratingOpt.NValueMin = 15
ratingOpt.NValueMax = 2000
ratingOpt.NValueInterval = 1
ratingOpt.LeftRightKeyRepeatRate = time.Millisecond * 60
ratingOpt.NValueFmtString = "%1.f"
ratingOpt.NumberCallback = func(nValue float32) {
TheOptions.HitWindows[rating] = time.Duration(nValue) * time.Millisecond
Expand Down

0 comments on commit 5a21217

Please sign in to comment.