Skip to content

Add Limit fps slider to in-game options - #7806

Open
Shivansps wants to merge 3 commits into
scp-fs2open:masterfrom
Shivansps:fps-limit
Open

Shivansps wants to merge 3 commits into
scp-fs2open:masterfrom
Shivansps:fps-limit

Conversation

@Shivansps

Copy link
Copy Markdown
Contributor

Brings the MaxFPS control from the ini file to the option system. When -no_fps_capping is used the option is disabled and displays "unlimited".

@Goober5000 Goober5000 left a comment

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.

Mostly good, but the new option doesn't have a parser. A .parser() option is needed for default_settings.tbl support.

@Shivansps

Copy link
Copy Markdown
Contributor Author

Mostly good, but the new option doesn't have a parser. A .parser() option is needed for default_settings.tbl support.

I just added that.

@dustinspace217 dustinspace217 left a comment

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.

I built this with Vulkan on and played SM1-01 with MediaVPs 5.0.2 under both OpenGL and -vulkan. The slider works live: setting 30, 45 and 15 capped the game at those rates right away, and a saved 30 was still applied after a restart. With -no_fps_capping the slider is greyed out and reads "Unlimited", the saved value is left alone, and the game runs uncapped. An old MaxFPS=30 in fs2_open.ini still caps at 30 the same as master does, and a value in default_settings.tbl is picked up by the new parser.

The branch conflicts with master now, and the string IDs need to change when that's fixed (inline). I couldn't check how it interacts with vsync, since the test runs on a virtual display with no refresh rate.

// but internal strings should still increment XSTR_SIZE to avoid collisions.
// retail XSTR_SIZE = 1570
// #define XSTR_SIZE 1936 // This is the next available ID
// #define XSTR_SIZE 1939 // This is the next available ID

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.

This line conflicts with master now. The Android build (#6992) took 1936-1939 for the touch overlay options in osapi.cpp, so the next free ID on master is 1940. With the three strings below moved to 1940-1942 this becomes:

Suggested change
// #define XSTR_SIZE 1939 // This is the next available ID
// #define XSTR_SIZE 1943 // This is the next available ID

Heads up: my #7998 also claims 1940-1945, so whichever of the two lands second will need to renumber.

Comment thread freespace2/freespace.cpp
Comment on lines +1924 to +1925
std::pair<const char*, int>{"Frame Rate Limit", 1936},
std::pair<const char*, int>{"Maximum frames per second. Vertical sync may lower the actual frame rate.", 1937})

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.

1936 and 1937 are "Touch Overlay" and its description on master, so a translation would show the wrong text here. Fixing the merge conflict on the localize.cpp comment alone would keep these duplicates without any warning.

Suggested change
std::pair<const char*, int>{"Frame Rate Limit", 1936},
std::pair<const char*, int>{"Maximum frames per second. Vertical sync may lower the actual frame rate.", 1937})
std::pair<const char*, int>{"Frame Rate Limit", 1940},
std::pair<const char*, int>{"Maximum frames per second. Vertical sync may lower the actual frame rate.", 1941})

Comment thread freespace2/freespace.cpp
// Clamp saved out-of-range values
return std::clamp(saved, MIN_FRAMERATE_CAP, MAX_FRAMERATE_CAP);
})
.display([](int value) { return Cmdline_NoFPSCap ? SCP_string(XSTR("Unlimited", 1938)) : std::to_string(value); })

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.

1938 is "Touch Overlay Opacity" on master.

Suggested change
.display([](int value) { return Cmdline_NoFPSCap ? SCP_string(XSTR("Unlimited", 1938)) : std::to_string(value); })
.display([](int value) { return Cmdline_NoFPSCap ? SCP_string(XSTR("Unlimited", 1942)) : std::to_string(value); })

Comment thread freespace2/freespace.cpp

mod_table_init(); // load in all the mod dependent settings

// Keep the old MaxFPS setting as the default when no Graphics.FramerateCap value is saved.

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.

Small thing, not blocking: when a mod sets this option in default_settings.tbl, the parser runs after this and replaces the player's MaxFPS. MaxFPS=30 plus a mod default of 45 ran at 45. If MaxFPS is meant to win, as this comment says, reading it between default_settings_init() and loadInitialValues() would do that.

@Shivansps

Copy link
Copy Markdown
Contributor Author

Right, yes ill fix that and the localization after #7708

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.

3 participants