AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
LuxVideoModeList.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: de-duplication of the options-menu resolution list, as a template so it can be
3 * unit tested without the engine (tests/cpp/test_video_mode_list.cpp).
4 * T needs mlDisplay, mvScreenSize (with ==) and mlRefreshRate.
5 */
6#ifndef LUX_VIDEO_MODE_LIST_H
7#define LUX_VIDEO_MODE_LIST_H
8
9#include <vector>
10
11/**
12 * Collapses runs of adjacent modes with the same size into one entry with the highest
13 * refresh rate. The input is expected sorted so equal modes are adjacent.
14 */
15template<class T>
16void LuxDedupVideoModes(std::vector<T> &avModes)
17{
18 // Stock code (LuxMainMenu_Options.cpp) read [i] instead of [j] for the refresh rate and
19 // ignored the display, merging equal sizes on adjacent monitors.
20 std::vector<T> vOut;
21 vOut.reserve(avModes.size());
22 for(size_t i=0;i<avModes.size();++i)
23 {
24 const T &mode = avModes[i];
25 if(!vOut.empty() && vOut.back().mlDisplay == mode.mlDisplay &&
26 vOut.back().mvScreenSize == mode.mvScreenSize)
27 {
28 if(mode.mlRefreshRate > vOut.back().mlRefreshRate)
29 vOut.back().mlRefreshRate = mode.mlRefreshRate;
30 }
31 else
32 {
33 vOut.push_back(mode);
34 }
35 }
36 avModes.swap(vOut);
37}
38
39#endif
void LuxDedupVideoModes(std::vector< T > &avModes)
Collapses runs of adjacent modes with the same size into one entry with the highest refresh rate.