• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / s25client / 24903561834

24 Apr 2026 05:43PM UTC coverage: 50.223% (-0.2%) from 50.384%
24903561834

Pull #1890

github

web-flow
Merge 70c42b3ee into 45e8bc010
Pull Request #1890: Add support for borderless Windows

167 of 641 new or added lines in 44 files covered. (26.05%)

25 existing lines in 8 files now uncovered.

23077 of 45949 relevant lines covered (50.22%)

43513.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/libs/s25main/desktops/dskOptions.cpp
1
// Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "dskOptions.h"
6
#include "GlobalGameSettings.h"
7
#include "Loader.h"
8
#include "MusicPlayer.h"
9
#include "Settings.h"
10
#include "WindowManager.h"
11
#include "controls/ctrlComboBox.h"
12
#include "controls/ctrlEdit.h"
13
#include "controls/ctrlGroup.h"
14
#include "controls/ctrlImageButton.h"
15
#include "controls/ctrlOptionGroup.h"
16
#include "controls/ctrlProgress.h"
17
#include "controls/ctrlTextButton.h"
18
#include "driver/VideoDriver.h"
19
#include "drivers/AudioDriverWrapper.h"
20
#include "drivers/VideoDriverWrapper.h"
21
#include "dskMainMenu.h"
22
#include "helpers/containerUtils.h"
23
#include "helpers/format.hpp"
24
#include "helpers/mathFuncs.h"
25
#include "helpers/toString.h"
26
#include "ingameWindows/iwAddons.h"
27
#include "ingameWindows/iwMsgbox.h"
28
#include "ingameWindows/iwMusicPlayer.h"
29
#include "ingameWindows/iwTextfile.h"
30
#include "languages.h"
31
#include "ogl/FontStyle.h"
32
#include "gameData/PortraitConsts.h"
33
#include "s25util/StringConversion.h"
34
#include "s25util/colors.h"
35
#include <mygettext/mygettext.h>
36
#include <sstream>
37

38
namespace {
39
using Offset = DrawPoint;
40

41
enum
42
{
43
    ID_btBack = dskMenuBase::ID_FIRST_FREE,
44
    ID_txtOptions,
45
    ID_btAddons,
46
    ID_grpOptions,
47
    ID_btCommon,
48
    ID_btGraphics,
49
    ID_btSound,
50
    ID_grpCommon,
51
    ID_grpGraphics,
52
    ID_grpSound,
53
    ID_txtName,
54
    ID_edtName,
55
    ID_txtLanguage,
56
    ID_cbLanguage,
57
    ID_txtKeyboardLayout,
58
    ID_btKeyboardLayout,
59
    ID_txtPort,
60
    ID_edtPort,
61
    ID_txtIpv6,
62
    ID_grpIpv6,
63
    ID_txtProxy,
64
    ID_edtProxy,
65
    ID_edtProxyPort,
66
    ID_txtProxyType,
67
    ID_cbProxyType,
68
    ID_txtDebugData,
69
    ID_grpDebugData,
70
    ID_grpUPNP,
71
    ID_txtMapScrollMode,
72
    ID_cbMapScrollMode,
73
    ID_grpSmartCursor,
74
    ID_grpWindowPinning,
75
    ID_grpGFInfo,
76
    ID_grpResolution,
77
    ID_txtResolution,
78
    ID_cbResolution,
79
    ID_grpWindowSize,
80
    ID_txtWindowSize,
81
    ID_cbWindowSize,
82
    ID_txtDisplayMode,
83
    ID_cbDisplayMode,
84
    ID_grpLockWindowSize,
85
    ID_txtFramerate,
86
    ID_cbFramerate,
87
    ID_grpVBO,
88
    ID_txtVideoDriver,
89
    ID_cbVideoDriver,
90
    ID_grpOptTextures,
91
    ID_txtGuiScale,
92
    ID_cbGuiScale,
93
    ID_txtAudioDriver,
94
    ID_cbAudioDriver,
95
    ID_grpMusic,
96
    ID_pgMusicVol,
97
    ID_grpEffects,
98
    ID_pgEffectsVol,
99
    ID_btMusicPlayer,
100
    ID_txtCommonPortrait,
101
    ID_btCommonPortrait,
102
    ID_cbCommonPortrait,
103
    ID_grpBirdSounds,
104
    ID_txtsStart, // First ID for texts used by options (ID of option is used as offset on top)
105
};
106
// Use these as IDs in dedicated groups
107
constexpr auto ID_btOn = 1;
108
constexpr auto ID_btOff = 0;
109
// Special case: Submit debug data uses "2" for "ask user" and "0" for "unset, ask at start"
110
constexpr auto ID_btSubmitDebugOn = 1;
111
constexpr auto ID_btSubmitDebugAsk = 2;
112

113
constexpr auto rowHeight = 30;
114
constexpr auto sectionSpacing = 20;
115
constexpr auto sectionSpacingCommon = 10;
116
constexpr auto optionRowsStartPosition = DrawPoint(80, 75);
117
constexpr auto tabButtonsStartPosition = optionRowsStartPosition + Offset(0, static_cast<int>(rowHeight * 15.5));
118

119
constexpr Offset ctrlOffset(200, -5);                       // Offset of control to its description text
120
constexpr Offset ctrlOffset2 = ctrlOffset + Offset(200, 0); // Offset of 2nd control to its description text
121
constexpr Extent ctrlSize(190, 22);
122
constexpr Extent ctrlSizeLarge = ctrlSize + Extent(ctrlOffset2 - ctrlOffset);
123

NEW
124
VideoMode getAspectRatio(const VideoMode vm)
×
125
{
126
    // First some a bit off values where the aspect ratio is defined by convention
127
    if(vm == VideoMode(1360, 1024))
×
128
        return VideoMode(4, 3);
×
129
    else if(vm == VideoMode(1360, 768) || vm == VideoMode(1366, 768))
×
130
        return VideoMode(16, 9);
×
131

132
    // Normally Aspect ration is simply width/height as integer numbers (e.g. 4:3)
133
    int divisor = helpers::gcd(vm.width, vm.height);
×
134
    VideoMode ratio(vm.width / divisor, vm.height / divisor);
×
135
    // But there are some special cases:
136
    if(ratio == VideoMode(8, 5))
×
137
        return VideoMode(16, 10);
×
138
    else if(ratio == VideoMode(5, 3))
×
139
        return VideoMode(15, 9);
×
140
    else
141
        return ratio;
×
142
}
143

144
enum class ButtonSize
145
{
146
    Normal,
147
    Half /// Both buttons take up the same space as a single button
148
};
149

NEW
150
ctrlOptionGroup& addOnOffOption(ctrlGroup& parentGroup, DrawPoint pos, unsigned id, const std::string& title,
×
151
                                bool value, ButtonSize btSize = ButtonSize::Normal)
152
{
NEW
153
    constexpr auto spacing = 10;
×
NEW
154
    auto size = ctrlSize;
×
NEW
155
    if(btSize == ButtonSize::Half)
×
NEW
156
        size.x = (ctrlSize.x - spacing) / 2;
×
157

NEW
158
    parentGroup.AddText(ID_txtsStart + id, pos, title, COLOR_YELLOW, FontStyle{}, NormalFont);
×
NEW
159
    auto* option = parentGroup.AddOptionGroup(id, GroupSelectType::Check);
×
NEW
160
    pos += ctrlOffset;
×
NEW
161
    option->AddTextButton(ID_btOn, pos, size, TextureColor::Grey, _("On"), NormalFont);
×
NEW
162
    pos.x += size.x + spacing;
×
NEW
163
    option->AddTextButton(ID_btOff, pos, size, TextureColor::Grey, _("Off"), NormalFont);
×
NEW
164
    option->SetSelection(value);
×
NEW
165
    return *option;
×
166
}
167

168
} // namespace
169

UNCOV
170
dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0))
×
171
{
172
    AddText(ID_txtOptions, DrawPoint(400, 10), _("Options"), COLOR_YELLOW, FontStyle::CENTER, LargeFont);
×
173

174
    ctrlOptionGroup* mainGroup = AddOptionGroup(ID_grpOptions, GroupSelectType::Check);
×
175

176
    DrawPoint curPos = tabButtonsStartPosition;
×
177
    mainGroup->AddTextButton(ID_btCommon, DrawPoint(curPos.x, curPos.y), Extent(200, 22), TextureColor::Green2,
×
178
                             _("Common"), NormalFont);
×
179
    mainGroup->AddTextButton(ID_btGraphics, DrawPoint(curPos.x + 220, curPos.y), Extent(200, 22), TextureColor::Green2,
×
180
                             _("Graphics"), NormalFont);
×
181
    mainGroup->AddTextButton(ID_btSound, DrawPoint(curPos.x + 440, curPos.y), Extent(200, 22), TextureColor::Green2,
×
182
                             _("Sound/Music"), NormalFont);
×
183
    curPos.y += rowHeight;
×
184

185
    AddTextButton(ID_btBack, DrawPoint(curPos.x + 220, curPos.y), Extent(200, 22), TextureColor::Red1, _("Back"),
×
186
                  NormalFont);
×
187
    AddTextButton(ID_btAddons, DrawPoint(curPos.x + 440, curPos.y), Extent(200, 22), TextureColor::Green2, _("Addons"),
×
188
                  NormalFont);
×
189

190
    ctrlGroup* groupCommon = AddGroup(ID_grpCommon);
×
191
    ctrlGroup* groupGraphics = AddGroup(ID_grpGraphics);
×
192
    ctrlGroup* groupSound = AddGroup(ID_grpSound);
×
193
    ctrlComboBox* combo;
194

195
    // Common
196
    // {
197

198
    curPos = optionRowsStartPosition;
×
199

200
    groupCommon->AddText(ID_txtName, curPos, _("Name in Game:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
201
    ctrlEdit* name =
202
      groupCommon->AddEdit(ID_edtName, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont, 15);
×
203
    name->SetText(SETTINGS.lobby.name);
×
204

205
    const auto& currentPortrait = Portraits[SETTINGS.lobby.portraitIndex];
×
206
    groupCommon->AddImageButton(ID_btCommonPortrait, DrawPoint(500, curPos.y + ctrlOffset.y), Extent(40, rowHeight * 2),
×
207
                                TextureColor::Grey,
208
                                LOADER.GetImageN(currentPortrait.resourceId, currentPortrait.resourceIndex));
×
209
    curPos.y += rowHeight;
×
210

211
    groupCommon->AddText(ID_txtCommonPortrait, curPos, _("Portrait:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
212
    combo =
213
      groupCommon->AddComboBox(ID_cbCommonPortrait, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont, 100);
×
214

215
    for(unsigned i = 0; i < Portraits.size(); ++i)
×
216
    {
NEW
217
        combo->AddItem(_(Portraits[i].name));
×
218
        if(SETTINGS.lobby.portraitIndex == i)
×
219
            combo->SetSelection(i);
×
220
    }
221
    curPos.y += rowHeight;
×
222

223
    groupCommon->AddText(ID_txtLanguage, curPos, _("Language:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
224
    combo = groupCommon->AddComboBox(ID_cbLanguage, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont, 100);
×
225

226
    bool selected = false;
×
227
    for(unsigned i = 0; i < LANGUAGES.size(); ++i)
×
228
    {
229
        const Language& l = LANGUAGES.getLanguage(i);
×
230

NEW
231
        combo->AddItem(_(l.name));
×
232
        if(SETTINGS.language.language == l.code)
×
233
        {
234
            combo->SetSelection(static_cast<unsigned short>(i));
×
235
            selected = true;
×
236
        }
237
    }
238
    if(!selected)
×
239
        combo->SetSelection(0);
×
240
    curPos.y += rowHeight;
×
241

242
    groupCommon->AddTextButton(ID_btKeyboardLayout, curPos + ctrlOffset, ctrlSizeLarge, TextureColor::Grey,
×
243
                               _("Keyboard layout"), NormalFont);
×
244
    curPos.y += rowHeight;
×
245

246
    curPos.y += sectionSpacingCommon;
×
247
    groupCommon->AddText(ID_txtPort, curPos, _("Local Port:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
248
    ctrlEdit* edtPort =
249
      groupCommon->AddEdit(ID_edtPort, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont, 15);
×
250
    edtPort->SetNumberOnly(true);
×
251
    edtPort->SetText(SETTINGS.server.localPort);
×
252
    curPos.y += rowHeight;
×
253

254
    // IPv4/6
NEW
255
    auto& grpIPv6 = addOnOffOption(*groupCommon, curPos, ID_grpIpv6, _("Use IPv6:"), SETTINGS.server.ipv6);
×
NEW
256
    grpIPv6.GetCtrl<ctrlTextButton>(ID_btOn)->SetText(_("IPv6"));
×
NEW
257
    grpIPv6.GetCtrl<ctrlTextButton>(ID_btOff)->SetText(_("IPv4"));
×
258
    // Enable/disable the IPv6 field if necessary
NEW
259
    grpIPv6.GetCtrl<ctrlButton>(ID_btOn)->SetEnabled(SETTINGS.proxy.type != ProxyType::Socks5); //-V807
×
260
    curPos.y += rowHeight;
×
261

262
    curPos.y += sectionSpacingCommon;
×
263
    // Proxy server
264
    groupCommon->AddText(ID_txtProxy, curPos, _("Proxyserver:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
265
    ctrlEdit* proxy = groupCommon->AddEdit(ID_edtProxy, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont);
×
266
    proxy->SetText(SETTINGS.proxy.hostname);
×
267
    proxy =
268
      groupCommon->AddEdit(ID_edtProxyPort, curPos + ctrlOffset2, Extent(50, 22), TextureColor::Grey, NormalFont, 5);
×
269
    proxy->SetNumberOnly(true);
×
270
    proxy->SetText(SETTINGS.proxy.port);
×
271
    curPos.y += rowHeight;
×
272

NEW
273
    addOnOffOption(*groupCommon, curPos, ID_grpUPNP, _("Use UPnP"), SETTINGS.global.useUPNP);
×
274
    curPos.y += rowHeight;
×
275

276
    // Proxy type
277
    groupCommon->AddText(ID_txtProxyType, curPos, _("Proxytyp:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
278
    combo =
279
      groupCommon->AddComboBox(ID_cbProxyType, curPos + ctrlOffset, ctrlSizeLarge, TextureColor::Grey, NormalFont, 100);
×
NEW
280
    combo->AddItem(_("No Proxy"));
×
NEW
281
    combo->AddItem(_("Socks v4"));
×
282
    // TODO: not implemented
283
    // combo->AddString(_("Socks v5"));
284

285
    switch(SETTINGS.proxy.type)
×
286
    {
287
        default: combo->SetSelection(0); break;
×
288
        case ProxyType::Socks4: combo->SetSelection(1); break;
×
289
        case ProxyType::Socks5: combo->SetSelection(2); break;
×
290
    }
291
    curPos.y += rowHeight;
×
292

293
    curPos.y += sectionSpacingCommon;
×
294
    groupCommon->AddText(ID_txtMapScrollMode, curPos, _("Map scroll mode:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
295
    combo = groupCommon->AddComboBox(ID_cbMapScrollMode, curPos + ctrlOffset, ctrlSizeLarge, TextureColor::Grey,
×
296
                                     NormalFont, 100);
×
NEW
297
    combo->AddItem(_("Scroll same (Map moves in the same direction the mouse is moved when scrolling/panning.)"));
×
NEW
298
    combo->AddItem(
×
299
      _("Scroll opposite (Map moves in the opposite direction the mouse is moved when scrolling/panning.)"));
NEW
300
    combo->AddItem(_("Grab and drag (Map moves with your cursor when scrolling/panning.)"));
×
301
    combo->SetSelection(static_cast<int>(SETTINGS.interface.mapScrollMode));
×
302
    curPos.y += rowHeight;
×
303

304
    auto& grpSmartCursor =
NEW
305
      addOnOffOption(*groupCommon, curPos, ID_grpSmartCursor, _("Smart Cursor"), SETTINGS.global.smartCursor);
×
NEW
306
    grpSmartCursor.GetCtrl<ctrlButton>(ID_btOn)->SetTooltip(
×
307
      _("Place cursor on default button for new dialogs / action windows (default)"));
NEW
308
    grpSmartCursor.GetCtrl<ctrlButton>(ID_btOff)->SetTooltip(
×
309
      _("Don't move cursor automatically\nUseful e.g. for split-screen / dual-mice multiplayer (see wiki)"));
310
    curPos.y += rowHeight;
×
311

312
    auto& grpWindowPinning = addOnOffOption(*groupCommon, curPos, ID_grpWindowPinning, _("Window pinning"),
NEW
313
                                            SETTINGS.interface.enableWindowPinning);
×
NEW
314
    grpWindowPinning.GetCtrl<ctrlButton>(ID_btOn)->SetTooltip(
×
315
      _("Replace minimize button on windows by pin button avoiding closing the window with "
316
        "ESC.\nMinimize by double-clicking the title bar."));
UNCOV
317
    curPos.y += rowHeight;
×
318

319
    curPos.y += sectionSpacingCommon;
×
320
    groupCommon->AddText(ID_txtDebugData, curPos, _("Submit debug data:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
321
    mainGroup = groupCommon->AddOptionGroup(ID_grpDebugData, GroupSelectType::Check);
×
322
    mainGroup->AddTextButton(ID_btSubmitDebugOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("On"),
×
323
                             NormalFont);
×
324
    mainGroup->AddTextButton(ID_btSubmitDebugAsk, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Ask always"),
×
325
                             NormalFont);
×
326

NEW
327
    mainGroup->SetSelection((SETTINGS.global.submitDebugData == SubmitDebugData::Yes) ? ID_btSubmitDebugOn :
×
328
                                                                                        ID_btSubmitDebugAsk); //-V807
UNCOV
329
    curPos.y += rowHeight;
×
330

NEW
331
    addOnOffOption(*groupCommon, curPos, ID_grpGFInfo, _("Show GameFrame Info:"), SETTINGS.global.showGFInfo);
×
332

333
    curPos = optionRowsStartPosition;
×
334

NEW
335
    groupGraphics->AddText(ID_txtDisplayMode, curPos, _("Mode:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
NEW
336
    ctrlComboBox* cbDisplayMode = groupGraphics->AddComboBox(ID_cbDisplayMode, curPos + ctrlOffset, ctrlSizeLarge,
×
NEW
337
                                                             TextureColor::Grey, NormalFont, 100);
×
NEW
338
    cbDisplayMode->AddItem(_("Windowed"));
×
NEW
339
    cbDisplayMode->AddItem(_("Fullscreen"));
×
NEW
340
    cbDisplayMode->AddItem(_("Borderless window"));
×
NEW
341
    cbDisplayMode->SetSelection(rttr::enum_cast(SETTINGS.video.displayMode.type));
×
NEW
342
    curPos.y += rowHeight;
×
343

NEW
344
    auto* grpResolution = groupGraphics->AddGroup(ID_grpResolution);
×
NEW
345
    grpResolution->AddText(ID_txtResolution, curPos, _("Fullscreen resolution:"), COLOR_YELLOW, FontStyle{},
×
346
                           NormalFont);
×
NEW
347
    grpResolution->AddComboBox(ID_cbResolution, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont, 150);
×
NEW
348
    auto* grpWindowSize = groupGraphics->AddGroup(ID_grpWindowSize);
×
NEW
349
    grpWindowSize->AddText(ID_txtWindowSize, curPos, _("Window size:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
NEW
350
    grpWindowSize->AddComboBox(ID_cbWindowSize, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont, 150);
×
UNCOV
351
    curPos.y += rowHeight;
×
352

353
    addOnOffOption(*grpWindowSize, curPos, ID_grpLockWindowSize, _("Lock window size:"),
NEW
354
                   !SETTINGS.video.displayMode.resizeable);
×
UNCOV
355
    curPos.y += rowHeight;
×
356

357
    curPos.y += sectionSpacing;
×
358
    groupGraphics->AddText(ID_txtFramerate, curPos, _("Limit Framerate:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
359
    groupGraphics->AddComboBox(ID_cbFramerate, curPos + ctrlOffset, ctrlSizeLarge, TextureColor::Grey, NormalFont, 150);
×
360
    curPos.y += rowHeight;
×
361

362
    curPos.y += sectionSpacing;
×
NEW
363
    addOnOffOption(*groupGraphics, curPos, ID_grpVBO, _("Vertex Buffer Objects:"), SETTINGS.video.vbo);
×
364
    curPos.y += rowHeight;
×
365

366
    curPos.y += sectionSpacing;
×
367
    groupGraphics->AddText(ID_txtVideoDriver, curPos, _("Graphics Driver"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
368
    combo = groupGraphics->AddComboBox(ID_cbVideoDriver, curPos + ctrlOffset, ctrlSizeLarge, TextureColor::Grey,
×
369
                                       NormalFont, 100);
×
370

371
    const auto video_drivers = drivers::DriverWrapper::LoadDriverList(drivers::DriverType::Video);
×
372

373
    for(const auto& video_driver : video_drivers)
×
374
    {
NEW
375
        combo->AddItem(video_driver.GetName());
×
376
        if(video_driver.GetName() == SETTINGS.driver.video)
×
377
            combo->SetSelection(combo->GetNumItems() - 1);
×
378
    }
379
    curPos.y += rowHeight;
×
380

381
    curPos.y += sectionSpacing;
×
NEW
382
    addOnOffOption(*groupGraphics, curPos, ID_grpOptTextures, _("Optimized Textures:"), SETTINGS.video.sharedTextures);
×
383
    curPos.y += rowHeight;
×
384

385
    curPos.y += sectionSpacing;
×
386
    groupGraphics->AddText(ID_txtGuiScale, curPos, _("GUI Scale:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
387
    groupGraphics->AddComboBox(ID_cbGuiScale, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont, 100);
×
388
    updateGuiScale();
×
389

390
    curPos = optionRowsStartPosition;
×
391

NEW
392
    addOnOffOption(*groupSound, curPos, ID_grpEffects, _("Effects"), SETTINGS.sound.effectsEnabled, ButtonSize::Half);
×
393

394
    ctrlProgress* FXvolume =
NEW
395
      groupSound->AddProgress(ID_pgEffectsVol, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, 139, 138, 100);
×
396
    FXvolume->SetPosition((SETTINGS.sound.effectsVolume * 100) / 255);
×
397
    curPos.y += rowHeight;
×
398

399
    curPos.y += sectionSpacing;
×
NEW
400
    addOnOffOption(*groupSound, curPos, ID_grpBirdSounds, _("Bird sounds"), SETTINGS.sound.birdsEnabled,
×
NEW
401
                   ButtonSize::Half);
×
UNCOV
402
    curPos.y += rowHeight;
×
403

404
    curPos.y += sectionSpacing;
×
NEW
405
    addOnOffOption(*groupSound, curPos, ID_grpMusic, _("Music"), SETTINGS.sound.musicEnabled, ButtonSize::Half);
×
406

407
    ctrlProgress* Mvolume =
NEW
408
      groupSound->AddProgress(ID_pgMusicVol, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, 139, 138, 100);
×
409
    Mvolume->SetPosition((SETTINGS.sound.musicVolume * 100) / 255); //-V807
×
410
    curPos.y += rowHeight;
×
411

412
    curPos.y += sectionSpacing;
×
413
    groupSound->AddTextButton(ID_btMusicPlayer, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Music player"),
×
414
                              NormalFont);
×
415
    curPos.y += rowHeight;
×
416

417
    curPos.y += sectionSpacing;
×
418
    groupSound->AddText(ID_txtAudioDriver, curPos, _("Sounddriver"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
419
    combo = groupSound->AddComboBox(ID_cbAudioDriver, curPos + ctrlOffset, ctrlSizeLarge, TextureColor::Grey,
×
420
                                    NormalFont, 100);
×
421

422
    const auto audio_drivers = drivers::DriverWrapper::LoadDriverList(drivers::DriverType::Audio);
×
423

424
    for(const auto& audio_driver : audio_drivers)
×
425
    {
NEW
426
        combo->AddItem(audio_driver.GetName());
×
427
        if(audio_driver.GetName() == SETTINGS.driver.audio)
×
428
            combo->SetSelection(combo->GetNumItems() - 1);
×
429
    }
430

431
    // Select "General"
432
    mainGroup = GetCtrl<ctrlOptionGroup>(ID_grpOptions);
×
433
    mainGroup->SetSelection(ID_btCommon, true);
×
434

435
    // Graphics
436
    // {
437

438
    loadVideoModes();
×
439

440
    // and add to the combo box
NEW
441
    ctrlComboBox& cbVideoModes = *grpResolution->GetCtrl<ctrlComboBox>(ID_cbResolution);
×
NEW
442
    for(const auto& videoMode : videoModes_)
×
443
    {
444
        VideoMode ratio = getAspectRatio(videoMode);
×
445
        s25util::ClassicImbuedStream<std::ostringstream> str;
×
446
        str << videoMode.width << "x" << videoMode.height;
×
447
        // Make the length always the same as 'iiiixiiii' to align the ratio
448
        int len = str.str().length();
×
449
        for(int i = len; i < 4 + 1 + 4; i++)
×
450
            str << " ";
×
451
        str << " (" << ratio.width << ":" << ratio.height << ")";
×
452

NEW
453
        cbVideoModes.AddItem(str.str());
×
454

455
        // Select, if this is the current resolution
456
        if(videoMode == SETTINGS.video.fullscreenSize) //-V807
×
457
            cbVideoModes.SetSelection(cbVideoModes.GetNumItems() - 1);
×
458
    }
NEW
459
    ctrlComboBox& cbWindowSize = *grpWindowSize->GetCtrl<ctrlComboBox>(ID_cbWindowSize);
×
NEW
460
    cbWindowSize.AddItem(""); // Placeholder for current window size
×
NEW
461
    for(const auto& size : windowSizes_)
×
462
    {
NEW
463
        s25util::ClassicImbuedStream<std::ostringstream> str;
×
NEW
464
        str << size.width << "x" << size.height;
×
NEW
465
        cbWindowSize.AddItem(str.str());
×
466
    }
NEW
467
    updateWindowSizeComboBox();
×
NEW
468
    updateResolutionGroups();
×
469

470
    // Fill "Limit Framerate"
471
    auto* cbFrameRate = groupGraphics->GetCtrl<ctrlComboBox>(ID_cbFramerate);
×
472
    if(VIDEODRIVER.HasVSync())
×
NEW
473
        cbFrameRate->AddItem(_("Dynamic (Limits to display refresh rate, works with most drivers)"));
×
474
    for(int framerate : Settings::SCREEN_REFRESH_RATES)
×
475
    {
476
        if(framerate == -1)
×
NEW
477
            cbFrameRate->AddItem(_("Disabled"));
×
478
        else
NEW
479
            cbFrameRate->AddItem(helpers::toString(framerate) + " FPS");
×
480
        if(SETTINGS.video.framerate == framerate)
×
481
            cbFrameRate->SetSelection(cbFrameRate->GetNumItems() - 1);
×
482
    }
483
    if(!cbFrameRate->GetSelection())
×
484
        cbFrameRate->SetSelection(0);
×
485

486
    // }
487

488
    // Sound
489
    // {
490

491
    groupSound->GetCtrl<ctrlOptionGroup>(ID_grpEffects)->SetSelection(SETTINGS.sound.effectsEnabled);
×
492
    groupSound->GetCtrl<ctrlOptionGroup>(ID_grpBirdSounds)->SetSelection(SETTINGS.sound.birdsEnabled);
×
493
    groupSound->GetCtrl<ctrlOptionGroup>(ID_grpMusic)->SetSelection(SETTINGS.sound.musicEnabled);
×
494

495
    // }
496

497
    // Load game settings
498
    ggs.LoadSettings();
×
499
}
×
500

501
dskOptions::~dskOptions()
×
502
{
503
    // Save game settings
504
    ggs.SaveSettings();
×
505
}
×
506

507
void dskOptions::Msg_Group_ProgressChange(const unsigned /*group_id*/, const unsigned ctrl_id,
×
508
                                          const unsigned short position)
509
{
510
    switch(ctrl_id)
×
511
    {
512
        case ID_pgEffectsVol:
×
513
            SETTINGS.sound.effectsVolume = static_cast<uint8_t>((position * 255) / 100);
×
514
            AUDIODRIVER.SetMasterEffectVolume(SETTINGS.sound.effectsVolume);
×
515
            break;
×
516
        case ID_pgMusicVol:
×
517
            SETTINGS.sound.musicVolume = static_cast<uint8_t>((position * 255) / 100);
×
518
            AUDIODRIVER.SetMusicVolume(SETTINGS.sound.musicVolume);
×
519
            break;
×
520
    }
521
}
×
522

523
void dskOptions::Msg_Group_ComboSelectItem(const unsigned group_id, const unsigned ctrl_id, const unsigned selection)
×
524
{
525
    auto* group = GetCtrl<ctrlGroup>(group_id);
×
526
    auto* combo = group->GetCtrl<ctrlComboBox>(ctrl_id);
×
527

528
    switch(ctrl_id)
×
529
    {
530
        case ID_cbCommonPortrait:
×
531
            SETTINGS.lobby.portraitIndex = selection;
×
532
            updatePortraitControls();
×
533
            break;
×
534
        case ID_cbLanguage:
×
535
        {
536
            // Language changed?
537
            std::string old_lang = SETTINGS.language.language; //-V807
×
538
            SETTINGS.language.language = LANGUAGES.setLanguage(selection);
×
539
            if(SETTINGS.language.language != old_lang)
×
540
                WINDOWMANAGER.Switch(std::make_unique<dskOptions>());
×
541
        }
542
        break;
×
543
        case ID_cbProxyType:
×
544
            switch(selection)
545
            {
546
                case 0: SETTINGS.proxy.type = ProxyType::None; break;
×
547
                case 1: SETTINGS.proxy.type = ProxyType::Socks4; break;
×
548
                case 2: SETTINGS.proxy.type = ProxyType::Socks5; break;
×
549
            }
550

551
            // Disable IPv6 visually
552
            if(SETTINGS.proxy.type == ProxyType::Socks4 && SETTINGS.server.ipv6)
×
553
            {
554
                GetCtrl<ctrlGroup>(ID_grpCommon)->GetCtrl<ctrlOptionGroup>(ID_grpIpv6)->SetSelection(0);
×
555
                GetCtrl<ctrlGroup>(ID_grpCommon)
×
556
                  ->GetCtrl<ctrlOptionGroup>(ID_grpIpv6)
×
557
                  ->GetCtrl<ctrlButton>(1)
558
                  ->SetEnabled(false);
×
559
                SETTINGS.server.ipv6 = false;
×
560
            }
561

562
            if(SETTINGS.proxy.type != ProxyType::Socks4)
×
563
                GetCtrl<ctrlGroup>(ID_grpCommon)
×
564
                  ->GetCtrl<ctrlOptionGroup>(ID_grpIpv6)
×
565
                  ->GetCtrl<ctrlButton>(1)
566
                  ->SetEnabled(true);
×
567
            break;
×
568
        case ID_cbMapScrollMode: SETTINGS.interface.mapScrollMode = static_cast<MapScrollMode>(selection); break;
×
NEW
569
        case ID_cbResolution: SETTINGS.video.fullscreenSize = videoModes_[selection]; break;
×
NEW
570
        case ID_cbWindowSize:
×
NEW
571
            if(selection > 0)
×
572
            {
NEW
573
                SETTINGS.video.windowedSize = windowSizes_[selection - 1];
×
NEW
574
                if(SETTINGS.video.displayMode == DisplayMode::Windowed
×
NEW
575
                   && VIDEODRIVER.GetDisplayMode() == DisplayMode::Windowed)
×
NEW
576
                    VIDEODRIVER.ResizeScreen(SETTINGS.video.windowedSize, DisplayMode::Windowed);
×
577
            }
NEW
578
            break;
×
579
        case ID_cbFramerate:
×
580
            if(VIDEODRIVER.HasVSync())
×
581
            {
582
                if(selection == 0)
×
583
                    SETTINGS.video.framerate = 0;
×
584
                else
585
                    SETTINGS.video.framerate = Settings::SCREEN_REFRESH_RATES[selection - 1];
×
586
            } else
587
                SETTINGS.video.framerate = Settings::SCREEN_REFRESH_RATES[selection];
×
588

589
            VIDEODRIVER.setTargetFramerate(SETTINGS.video.framerate);
×
590
            break;
×
591
        case ID_cbVideoDriver: SETTINGS.driver.video = combo->GetText(selection); break;
×
592
        case ID_cbGuiScale:
×
593
            SETTINGS.video.guiScale = guiScales_[selection];
×
594
            VIDEODRIVER.setGuiScalePercent(SETTINGS.video.guiScale);
×
595
            break;
×
596
        case ID_cbAudioDriver: SETTINGS.driver.audio = combo->GetText(selection); break;
×
NEW
597
        case ID_cbDisplayMode:
×
NEW
598
            SETTINGS.video.displayMode = DisplayMode(selection);
×
NEW
599
            updateResolutionGroups();
×
NEW
600
            break;
×
601
    }
602
}
×
603

604
void dskOptions::Msg_Group_OptionGroupChange(const unsigned /*group_id*/, const unsigned ctrl_id,
×
605
                                             const unsigned selection)
606
{
607
    const bool enabled = selection == ID_btOn;
×
608
    switch(ctrl_id)
×
609
    {
610
        case ID_grpIpv6: SETTINGS.server.ipv6 = enabled; break;
×
NEW
611
        case ID_grpLockWindowSize:
×
612
        {
NEW
613
            SETTINGS.video.displayMode.resizeable = !enabled;
×
NEW
614
            const auto newDisplayMode = SETTINGS.video.displayMode;
×
NEW
615
            if(newDisplayMode == DisplayMode::Windowed && VIDEODRIVER.GetDisplayMode() == DisplayMode::Windowed)
×
NEW
616
                VIDEODRIVER.ResizeScreen(VIDEODRIVER.GetWindowSize(), newDisplayMode);
×
617
        }
NEW
618
        break;
×
619
        case ID_grpVBO: SETTINGS.video.vbo = enabled; break;
×
NEW
620
        case ID_grpOptTextures: SETTINGS.video.sharedTextures = enabled; break;
×
621
        case ID_grpEffects: SETTINGS.sound.effectsEnabled = enabled; break;
×
622
        case ID_grpBirdSounds: SETTINGS.sound.birdsEnabled = enabled; break;
×
623
        case ID_grpMusic:
×
624
            SETTINGS.sound.musicEnabled = enabled;
×
625
            if(enabled)
×
626
                MUSICPLAYER.Play();
×
627
            else
628
                MUSICPLAYER.Stop();
×
629
            break;
×
630
        case ID_grpDebugData:
×
631
            // Special case: Uses e.g. ID_btSubmitDebugOn directly
NEW
632
            SETTINGS.global.submitDebugData = SubmitDebugData(selection);
×
633
            break;
×
NEW
634
        case ID_grpUPNP: SETTINGS.global.useUPNP = enabled; break;
×
635
        case ID_grpSmartCursor:
×
636
            SETTINGS.global.smartCursor = enabled;
×
637
            VIDEODRIVER.SetMouseWarping(enabled);
×
638
            break;
×
639
        case ID_grpWindowPinning: SETTINGS.interface.enableWindowPinning = enabled; break;
×
640
        case ID_grpGFInfo: SETTINGS.global.showGFInfo = enabled; break;
×
NEW
641
        default: RTTR_Assert(false);
×
642
    }
643
}
×
644

645
void dskOptions::Msg_OptionGroupChange(const unsigned ctrl_id, const unsigned selection)
×
646
{
647
    if(ctrl_id == ID_grpOptions)
×
648
    {
649
        const auto visGrp = selection + ID_grpCommon - ID_btCommon;
×
650
        for(const unsigned id : {ID_grpCommon, ID_grpGraphics, ID_grpSound})
×
651
            GetCtrl<ctrlGroup>(id)->SetVisible(id == visGrp);
×
652
    }
653
}
×
654

655
/// Check that the port is valid and sets outPort to it. Shows an error otherwise
656
static bool validatePort(const std::string& sPort, uint16_t& outPort)
×
657
{
658
    boost::optional<uint16_t> port = validate::checkPort(sPort);
×
659
    if(port)
×
660
        outPort = *port;
×
661
    else
662
    {
663
        WINDOWMANAGER.Show(std::make_unique<iwMsgbox>(_("Error"),
×
664
                                                      _("Invalid port. The valid port-range is 1 to 65535!"), nullptr,
×
665
                                                      MsgboxButton::Ok, MsgboxIcon::ExclamationRed, 1));
×
666
    }
667
    return static_cast<bool>(port);
×
668
}
669

670
void dskOptions::Msg_ButtonClick(const unsigned ctrl_id)
×
671
{
672
    switch(ctrl_id)
×
673
    {
674
        case ID_btBack:
×
675
        {
676
            auto* groupCommon = GetCtrl<ctrlGroup>(ID_grpCommon);
×
677

678
            // Save the name
679
            SETTINGS.lobby.name = groupCommon->GetCtrl<ctrlEdit>(ID_edtName)->GetText();
×
680
            if(!validatePort(groupCommon->GetCtrl<ctrlEdit>(ID_edtPort)->GetText(), SETTINGS.server.localPort))
×
681
                return;
×
682

683
            SETTINGS.proxy.hostname = groupCommon->GetCtrl<ctrlEdit>(ID_edtProxy)->GetText();
×
684
            if(!validatePort(groupCommon->GetCtrl<ctrlEdit>(ID_edtProxyPort)->GetText(), SETTINGS.proxy.port))
×
685
                return;
×
686

687
            SETTINGS.Save();
×
688

689
            // Is the selected backend required to support GUI scaling to fulfill the user's choice?
690
            // If so, warn the user if the backend is unable to support GUI scaling.
NEW
691
            const auto requestedGuiScale = SETTINGS.video.guiScale;
×
NEW
692
            const bool autoGuiScale = requestedGuiScale == 0;
×
NEW
693
            if((!autoGuiScale && requestedGuiScale != VIDEODRIVER.getGuiScale().percent())
×
NEW
694
               || (autoGuiScale
×
NEW
695
                   && VIDEODRIVER.getGuiScaleRange().recommendedPercent != VIDEODRIVER.getGuiScale().percent()))
×
696

697
            {
698
                WINDOWMANAGER.Show(std::make_unique<iwMsgbox>(
×
699
                  _("Sorry!"), _("The selected video driver does not support GUI scaling! Setting won't be used."),
×
700
                  this, MsgboxButton::Ok, MsgboxIcon::ExclamationGreen, 1));
×
701
            }
702

NEW
703
            const auto fullscreen = SETTINGS.video.displayMode == DisplayMode::Fullscreen;
×
NEW
704
            if((fullscreen && SETTINGS.video.fullscreenSize != VIDEODRIVER.GetWindowSize()) //-V807
×
NEW
705
               || VIDEODRIVER.GetDisplayMode() != SETTINGS.video.displayMode)
×
706
            {
NEW
707
                const auto screenSize = fullscreen ? SETTINGS.video.fullscreenSize : SETTINGS.video.windowedSize;
×
NEW
708
                if(!VIDEODRIVER.ResizeScreen(screenSize, SETTINGS.video.displayMode))
×
709
                {
710
                    WINDOWMANAGER.Show(std::make_unique<iwMsgbox>(
×
711
                      _("Sorry!"), _("You need to restart your game to change the screen resolution!"), this,
×
712
                      MsgboxButton::Ok, MsgboxIcon::ExclamationGreen, 1));
×
713
                    return;
×
714
                }
715
            }
716
            if(SETTINGS.driver.video != VIDEODRIVER.GetName() || SETTINGS.driver.audio != AUDIODRIVER.GetName())
×
717
            {
718
                WINDOWMANAGER.Show(std::make_unique<iwMsgbox>(
×
719
                  _("Sorry!"), _("You need to restart your game to change the video or audio driver!"), this,
×
720
                  MsgboxButton::Ok, MsgboxIcon::ExclamationGreen, 1));
×
721
                return;
×
722
            }
723

724
            WINDOWMANAGER.Switch(std::make_unique<dskMainMenu>());
×
725
        }
726
        break;
×
727
        case ID_btAddons: WINDOWMANAGER.ToggleWindow(std::make_unique<iwAddons>(ggs)); break;
×
728
    }
729
}
730

731
void dskOptions::Msg_Group_ButtonClick(const unsigned /*group_id*/, const unsigned ctrl_id)
×
732
{
733
    switch(ctrl_id)
×
734
    {
735
        default: break;
×
736
        case ID_btCommonPortrait:
×
737
            SETTINGS.lobby.portraitIndex = (SETTINGS.lobby.portraitIndex + 1) % Portraits.size();
×
738
            updatePortraitControls();
×
739
            break;
×
740
        case ID_btMusicPlayer: WINDOWMANAGER.ToggleWindow(std::make_unique<iwMusicPlayer>()); break;
×
741
        case ID_btKeyboardLayout:
×
742
            WINDOWMANAGER.ToggleWindow(std::make_unique<iwTextfile>("keyboardlayout.txt", _("Keyboard layout")));
×
743
            break;
×
744
    }
745
}
×
746

747
void dskOptions::Msg_MsgBoxResult(const unsigned msgbox_id, const MsgboxResult /*mbr*/)
×
748
{
749
    switch(msgbox_id)
×
750
    {
751
        default: break;
×
752
        // "You need to restart your game ..."
753
        // "The selected video driver does not support GUI scaling!"
754
        case 1: WINDOWMANAGER.Switch(std::make_unique<dskMainMenu>()); break;
×
755
    }
756
}
×
757

758
void dskOptions::loadVideoModes()
×
759
{
760
    // Get available modes
NEW
761
    const auto videoModes = VIDEODRIVER.ListVideoModes();
×
762
    // random access is need for selection
NEW
763
    videoModes_.assign(videoModes.begin(), videoModes.end());
×
NEW
764
    const auto windowSizes = VIDEODRIVER.GetDefaultWindowSizes();
×
NEW
765
    windowSizes_.assign(windowSizes.begin(), windowSizes.end());
×
UNCOV
766
}
×
767

768
void dskOptions::Msg_ScreenResize(const ScreenResizeEvent& sr)
×
769
{
770
    Desktop::Msg_ScreenResize(sr);
×
771
    updateGuiScale();
×
NEW
772
    updateWindowSizeComboBox();
×
UNCOV
773
}
×
774

775
bool dskOptions::Msg_WheelUp(const MouseCoords& mc)
×
776
{
777
    if(VIDEODRIVER.GetModKeyState().ctrl)
×
778
    {
779
        scrollGuiScale(true);
×
780
        return true;
×
781
    } else
782
        return Desktop::Msg_WheelUp(mc);
×
783
}
784

785
bool dskOptions::Msg_WheelDown(const MouseCoords& mc)
×
786
{
787
    if(VIDEODRIVER.GetModKeyState().ctrl)
×
788
    {
789
        scrollGuiScale(false);
×
790
        return true;
×
791
    } else
792
        return Desktop::Msg_WheelDown(mc);
×
793
}
794

795
void dskOptions::updateGuiScale()
×
796
{
797
    // generate GUI scale percentages in 10% increments
798
    constexpr auto stepSize = 10u;
×
799
    const auto roundGuiScale = [=](unsigned percent) {
×
800
        return helpers::iround<unsigned>(static_cast<float>(percent) / stepSize) * stepSize;
×
801
    };
802

803
    const auto range = VIDEODRIVER.getGuiScaleRange();
×
804
    const auto recommendedPercentRounded = roundGuiScale(range.recommendedPercent);
×
805
    auto* combo = GetCtrl<ctrlGroup>(ID_grpGraphics)->GetCtrl<ctrlComboBox>(ID_cbGuiScale);
×
806

807
    guiScales_.clear();
×
808
    combo->DeleteAllItems();
×
809

810
    guiScales_.push_back(0);
×
NEW
811
    combo->AddItem(helpers::format(_("Auto (%u%%)"), range.recommendedPercent));
×
812
    if(SETTINGS.video.guiScale == 0)
×
813
        combo->SetSelection(0);
×
814

815
    for(unsigned percent = roundGuiScale(range.minPercent); percent <= range.maxPercent; percent += stepSize)
×
816
    {
817
        if(percent == recommendedPercentRounded)
×
818
            recommendedGuiScaleIndex_ = guiScales_.size();
×
819
        guiScales_.push_back(percent);
×
820

NEW
821
        combo->AddItem(helpers::toString(percent) + "%");
×
822
        if(percent == SETTINGS.video.guiScale)
×
823
            combo->SetSelection(combo->GetNumItems() - 1);
×
824
    }
825

826
    // if GUI scale exceeds maximum, lower it to keep UI elements on screen
827
    if(SETTINGS.video.guiScale > guiScales_.back())
×
828
    {
829
        combo->SetSelection(combo->GetNumItems() - 1);
×
830
        SETTINGS.video.guiScale = guiScales_.back();
×
831
        VIDEODRIVER.setGuiScalePercent(SETTINGS.video.guiScale);
×
832
    }
833
}
×
834

835
void dskOptions::scrollGuiScale(bool up)
×
836
{
837
    auto* combo = GetCtrl<ctrlGroup>(ID_grpGraphics)->GetCtrl<ctrlComboBox>(ID_cbGuiScale);
×
838
    const auto& selection = combo->GetSelection();
×
839
    unsigned newSelection = 0;
×
840
    if(!selection || *selection == 0) // No selection or "Auto" item selected
×
841
        newSelection = recommendedGuiScaleIndex_;
×
842
    else
843
        newSelection = std::clamp<unsigned>(*selection + (up ? 1 : -1), 1, combo->GetNumItems() - 1);
×
844

845
    if(newSelection != selection)
×
846
    {
847
        combo->SetSelection(newSelection);
×
848
        SETTINGS.video.guiScale = guiScales_[newSelection];
×
849
        VIDEODRIVER.setGuiScalePercent(SETTINGS.video.guiScale);
×
850
    }
851
}
×
852

853
void dskOptions::updatePortraitControls()
×
854
{
855
    const auto& newPortrait = Portraits[SETTINGS.lobby.portraitIndex];
×
856
    auto* groupCommon = GetCtrl<ctrlGroup>(ID_grpCommon);
×
857

858
    auto* portraitButton = groupCommon->GetCtrl<ctrlImageButton>(ID_btCommonPortrait);
×
859
    auto* newPortraitTexture = LOADER.GetTextureN(newPortrait.resourceId, newPortrait.resourceIndex);
×
860
    portraitButton->SetImage(newPortraitTexture);
×
861

862
    auto* portraitCombo = groupCommon->GetCtrl<ctrlComboBox>(ID_cbCommonPortrait);
×
863
    portraitCombo->SetSelection(SETTINGS.lobby.portraitIndex);
×
864
}
×
865

NEW
866
void dskOptions::updateWindowSizeComboBox()
×
867
{
868
    auto* cbWindowSize =
NEW
869
      GetCtrl<ctrlGroup>(ID_grpGraphics)->GetCtrl<ctrlGroup>(ID_grpWindowSize)->GetCtrl<ctrlComboBox>(ID_cbWindowSize);
×
870

871
    const VideoMode currentSize =
NEW
872
      VIDEODRIVER.GetDisplayMode() == DisplayMode::Windowed ? VIDEODRIVER.GetWindowSize() : SETTINGS.video.windowedSize;
×
NEW
873
    s25util::ClassicImbuedStream<std::ostringstream> curStr;
×
NEW
874
    curStr << currentSize.width << "x" << currentSize.height;
×
NEW
875
    cbWindowSize->SetText(0, curStr.str());
×
876
    // Not found == -1 -> First entry selected
NEW
877
    cbWindowSize->SetSelection(static_cast<unsigned>(helpers::indexOf(windowSizes_, currentSize) + 1));
×
NEW
878
}
×
879

NEW
880
void dskOptions::updateResolutionGroups()
×
881
{
NEW
882
    const auto currentDisplayMode = SETTINGS.video.displayMode;
×
NEW
883
    auto& grpGraphics = *GetCtrl<ctrlGroup>(ID_grpGraphics);
×
NEW
884
    grpGraphics.GetCtrl<ctrlGroup>(ID_grpResolution)->SetVisible(currentDisplayMode == DisplayMode::Fullscreen);
×
NEW
885
    grpGraphics.GetCtrl<ctrlGroup>(ID_grpWindowSize)->SetVisible(currentDisplayMode == DisplayMode::Windowed);
×
NEW
886
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc