Ticket #2882: t2882_limit_fps_v3.patch

File t2882_limit_fps_v3.patch, 5.0 KB (added by elexis, 9 years ago)

Use the prefix "gui.menu" to the setting name and adds an entry to default.cfg.

  • binaries/data/config/default.cfg

     
    317317
    318318[gui]
    319319cursorblinkrate = 0.5             ; Cursor blink rate in seconds (0.0 to disable blinking)
    320320scale = 1.0                       ; GUI scaling factor, for improved compatibility with 4K displays
    321321
     322[gui.menu]
     323limit_fps = true                  ; Limit FPS in the menus and loading screen
     324
    322325[gui.session]
    323326attacknotificationmessage = true  ; Show attack notification messages
    324327camerajump.threshold = 40         ; How close do we have to be to the actual location in order to jump back to the previous one?
    325328timeelapsedcounter = false        ; Show the game duration in the top right corner
    326329
  • binaries/data/mods/public/gui/options/options.js

     
    1212        [translate("Detailed Tooltips"), translate("Show detailed tooltips for trainable units in unit-producing buildings."), {"config":"showdetailedtooltips"}, "boolean"],
    1313        [translate("FPS Overlay"), translate("Show frames per second in top right corner."), {"config":"overlay.fps"}, "boolean"],
    1414        [translate("Realtime Overlay"), translate("Show current system time in top right corner."), {"config":"overlay.realtime"}, "boolean"],
    1515        [translate("Gametime Overlay"), translate("Show current simulation time in top right corner."), {"config":"gui.session.timeelapsedcounter"}, "boolean"],
    1616        [translate("Ceasefire Time Overlay"), translate("Always show the remaining ceasefire time."), {"config":"gui.session.ceasefirecounter"}, "boolean"],
    17         [translate("Persist match settings"), translate("Save and restore match settings for quick reuse when hosting another game"), {"config":"persistmatchsettings"}, "boolean"],
     17        [translate("Persist Match Settings"), translate("Save and restore match settings for quick reuse when hosting another game"), {"config":"persistmatchsettings"}, "boolean"],
    1818    ],
    1919    "graphicsSetting":
    2020    [
    2121        [translate("Prefer GLSL"), translate("Use OpenGL 2.0 shaders (recommended)"), {"renderer":"PreferGLSL", "config":"preferglsl"}, "boolean"],
    2222        [translate("Post Processing"), translate("Use screen-space postprocessing filters (HDR, Bloom, DOF, etc)"), {"renderer":"Postproc", "config":"postproc"}, "boolean"],
     
    3131        [translate("Real Water Depth"), translate("Use actual water depth in rendering calculations"), {"renderer":"WaterRealDepth", "config":"waterrealdepth"}, "boolean"],
    3232        [translate("Water Reflections"), translate("Allow water to reflect a mirror image"), {"renderer":"WaterReflection", "config":"waterreflection"}, "boolean"],
    3333        [translate("Water Refraction"), translate("Use a real water refraction map and not transparency"), {"renderer":"WaterRefraction", "config":"waterrefraction"}, "boolean"],
    3434        [translate("Shadows on Water"), translate("Cast shadows on water"), {"renderer":"WaterShadows", "config":"watershadows"}, "boolean"],
    3535        [translate("VSync"), translate("Run vertical sync to fix screen tearing. REQUIRES GAME RESTART"), {"config":"vsync"}, "boolean"],
     36        [translate("Limit FPS in Menus"), translate("Limit frames per second in all menus."), {"config":"gui.menu.limit_fps"}, "boolean"],
    3637    ],
    3738    "soundSetting":
    3839    [
    3940        [translate("Master Gain"), translate("Master audio gain"), {"config":"sound.mastergain", "function":"Engine.SetMasterGain(Number(this.caption));"}, "number"],
    4041        [translate("Music Gain"), translate("In game music gain"), {"config":"sound.musicgain", "function":"Engine.SetMusicGain(Number(this.caption));"}, "number"],
  • source/main.cpp

     
    4141#include "lib/external_libraries/libsdl.h"
    4242
    4343#include "ps/ArchiveBuilder.h"
    4444#include "ps/CConsole.h"
    4545#include "ps/CLogger.h"
     46#include "ps/ConfigDB.h"
    4647#include "ps/Filesystem.h"
    4748#include "ps/Game.h"
    4849#include "ps/Globals.h"
    4950#include "ps/Hotkey.h"
    5051#include "ps/Loader.h"
     
    298299        need_update = false;
    299300        // don't use SDL_WaitEvent: don't want the main loop to freeze until app focus is restored
    300301        SDL_Delay(10);
    301302    }
    302303
    303     // TODO: throttling: limit update and render frequency to the minimum.
     304    // Throttling: limit update and render frequency to the minimum.
    304305    // this is mostly relevant for "inactive" state, so that other windows
    305306    // get enough CPU time, but it's always nice for power+thermal management.
     307    const float maxFPSMenu = 50.0;
     308    bool limit_fps = false;
     309    CFG_GET_VAL("gui.menu.limit_fps", limit_fps);
     310    if (limit_fps && (!g_Game || !g_Game->IsGameStarted()))
     311        SDL_Delay((1000.0 / maxFPSMenu) - realTimeSinceLastFrame);
    306312
    307313
    308314    // this scans for changed files/directories and reloads them, thus
    309315    // allowing hotloading (changes are immediately assimilated in-game).
    310316    ReloadChangedFiles();