| 182 | } |
| 183 | |
| 184 | void GraphicsMenu::syncGui() { |
| 185 | Vec2U res = jsonToVec2U(m_localChanges.get("fullscreenResolution")); |
| 186 | auto resSlider = fetchChild<SliderBarWidget>("resSlider"); |
| 187 | auto resIt = std::lower_bound(m_resList.begin(), m_resList.end(), res, [&](Vec2U const& a, Vec2U const& b) { |
| 188 | return a[0] * a[1] < b[0] * b[1]; // sort by number of pixels |
| 189 | }); |
| 190 | if (resIt != m_resList.end()) { |
| 191 | size_t resIndex = resIt - m_resList.begin(); |
| 192 | resIndex = std::min(resIndex, m_resList.size() - 1); |
| 193 | resSlider->setVal(resIndex, false); |
| 194 | } else { |
| 195 | resSlider->setVal(m_resList.size() - 1); |
| 196 | } |
| 197 | fetchChild<LabelWidget>("resValueLabel")->setText(strf("{}x{}", res[0], res[1])); |
| 198 | |
| 199 | auto interfaceScaleSlider = fetchChild<SliderBarWidget>("interfaceScaleSlider"); |
| 200 | auto interfaceScale = m_localChanges.get("interfaceScale").optUInt().value(); |
| 201 | auto interfaceScaleIt = std::lower_bound(m_interfaceScaleList.begin(), m_interfaceScaleList.end(), interfaceScale); |
| 202 | if (interfaceScaleIt != m_interfaceScaleList.end()) { |
| 203 | size_t scaleIndex = interfaceScaleIt - m_interfaceScaleList.begin(); |
| 204 | interfaceScaleSlider->setVal(std::min(scaleIndex, m_interfaceScaleList.size() - 1), false); |
| 205 | } else { |
| 206 | interfaceScaleSlider->setVal(m_interfaceScaleList.size() - 1); |
| 207 | } |
| 208 | fetchChild<LabelWidget>("interfaceScaleValueLabel")->setText(interfaceScale ? toString(interfaceScale) : "AUTO"); |
| 209 | |
| 210 | auto zoomSlider = fetchChild<SliderBarWidget>("zoomSlider"); |
| 211 | auto zoomLevel = m_localChanges.get("zoomLevel").toFloat(); |
| 212 | auto zoomIt = std::lower_bound(m_zoomList.begin(), m_zoomList.end(), zoomLevel); |
| 213 | if (zoomIt != m_zoomList.end()) { |
| 214 | size_t zoomIndex = zoomIt - m_zoomList.begin(); |
| 215 | zoomSlider->setVal(std::min(zoomIndex, m_zoomList.size() - 1), false); |
| 216 | } else { |
| 217 | zoomSlider->setVal(m_zoomList.size() - 1); |
| 218 | } |
| 219 | fetchChild<LabelWidget>("zoomValueLabel")->setText(strf("{}x", zoomLevel)); |
| 220 | |
| 221 | auto cameraSpeedSlider = fetchChild<SliderBarWidget>("cameraSpeedSlider"); |
| 222 | auto cameraSpeedFactor = m_localChanges.get("cameraSpeedFactor").toFloat(); |
| 223 | auto speedIt = std::lower_bound(m_cameraSpeedList.begin(), m_cameraSpeedList.end(), cameraSpeedFactor); |
| 224 | if (speedIt != m_cameraSpeedList.end()) { |
| 225 | size_t speedIndex = speedIt - m_cameraSpeedList.begin(); |
| 226 | cameraSpeedSlider->setVal(std::min(speedIndex, m_cameraSpeedList.size() - 1), false); |
| 227 | } else { |
| 228 | cameraSpeedSlider->setVal(m_cameraSpeedList.size() - 1); |
| 229 | } |
| 230 | fetchChild<LabelWidget>("cameraSpeedValueLabel")->setText(strf("{}x", cameraSpeedFactor)); |
| 231 | |
| 232 | fetchChild<ButtonWidget>("speechBubbleCheckbox")->setChecked(m_localChanges.get("speechBubbles").toBool()); |
| 233 | fetchChild<ButtonWidget>("interactiveHighlightCheckbox")->setChecked(m_localChanges.get("interactiveHighlight").toBool()); |
| 234 | fetchChild<ButtonWidget>("fullscreenCheckbox")->setChecked(m_localChanges.get("fullscreen").toBool()); |
| 235 | fetchChild<ButtonWidget>("borderlessCheckbox")->setChecked(m_localChanges.get("borderless").toBool()); |
| 236 | fetchChild<ButtonWidget>("textureLimitCheckbox")->setChecked(m_localChanges.get("limitTextureAtlasSize").toBool()); |
| 237 | fetchChild<ButtonWidget>("multiTextureCheckbox")->setChecked(m_localChanges.get("useMultiTexturing").optBool().value(true)); |
| 238 | fetchChild<ButtonWidget>("antiAliasingCheckbox")->setChecked(m_localChanges.get("antiAliasing").toBool()); |
| 239 | fetchChild<ButtonWidget>("monochromeCheckbox")->setChecked(m_localChanges.get("monochromeLighting").toBool()); |
| 240 | fetchChild<ButtonWidget>("newLightingCheckbox")->setChecked(m_localChanges.get("newLighting").optBool().value(true)); |
| 241 | fetchChild<ButtonWidget>("hardwareCursorCheckbox")->setChecked(m_localChanges.get("hardwareCursor").toBool()); |
nothing calls this directly
no test coverage detected