Skip to content

Add numeric framerate limit input#3632

Open
Riqqqque wants to merge 6 commits into
CaffeineMC:devfrom
Riqqqque:rique/custom-fps-cap
Open

Add numeric framerate limit input#3632
Riqqqque wants to merge 6 commits into
CaffeineMC:devfrom
Riqqqque:rique/custom-fps-cap

Conversation

@Riqqqque
Copy link
Copy Markdown

@Riqqqque Riqqqque commented May 6, 2026

Closes #3556.

Adds a numeric input for the framerate limit so exact caps can be entered instead of being limited to 10 FPS slider steps.

Changes:

  • uses a text box for Sodium's framerate limit option
  • replaces Minecraft's framerate limit option with an exact integer range before options are loaded
  • keeps the existing Sodium apply/save flow

The standalone addon this was ported from is Unlicense.

Validation:

  • ./gradlew.bat build
  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks

Copy link
Copy Markdown
Contributor

@douira douira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't have a suggestion for changes to the API to accomodate a second type of integer option, I can also do that myself during merge.

Copy link
Copy Markdown
Contributor

@douira douira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed some changes to this branch to clean up some things, faster than going back and forth here.

  • However, I've noticed that once I enter a number into the text field, it doesn't let me change it.
  • Focusing it by keyboard navigation works, but it doesn't let me enter text
  • In the video the reset button shows up sometimes, but that's just because pressing shift + tab activates it because of the shift key
  • Clicking on the text field doesn't activate the cursor once it's been used
  • When the text field is activated and there's an outline around the option, the outlines touch which is not nice
  • The text in the textbox seems to be around 1-2 pixels too high and not vertically centered
output.mp4

@Riqqqque
Copy link
Copy Markdown
Author

Riqqqque commented May 8, 2026

Pushed a fix for the textbox focus/click handling and tightened the textbox height/vertical positioning.

Checked with:

  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks
  • ./gradlew.bat build

@Riqqqque
Copy link
Copy Markdown
Author

Riqqqque commented May 8, 2026

Added one more follow-up for the textbox behavior.

Tab focus now routes input to the actual text field, so typing/backspace should work instead of only showing the cursor. The click focus, focus-out commit, and spacing tweaks are still in place.

Checked with:

  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks
  • ./gradlew.bat build

Copy link
Copy Markdown
Contributor

@douira douira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work now but I'm somewhat confused why we need dragging. This flag doesn't seem to be doing anything. Maybe it would be appropriate to instead implement AbstractParentWidget rather than reimplementing a bunch of its code?
Thanks for improving this patch thus far!

private final EditBox textBox;

private @Nullable GuiEventListener focusedElement;
private boolean dragging;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain why we have this dragging flag?

@Riqqqque
Copy link
Copy Markdown
Author

Riqqqque commented May 9, 2026

Cleaned up the textbox focus handling.

ControlElement now has the parent-widget focus support, and the textbox registers its EditBox as a child instead of carrying its own focused-child/dragging state. The textbox control only keeps the focus-out commit hook now.

Checked with:

  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks
  • ./gradlew.bat build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the framerate slider with a numeric input for custom FPS caps

2 participants