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

Return-To-The-Roots / s25client / 15651837780

14 Jun 2025 12:06PM UTC coverage: 50.443% (-0.03%) from 50.476%
15651837780

Pull #1534

github

web-flow
Merge 4685d273f into 19c9b91c8
Pull Request #1534: Portrait support

56 of 155 new or added lines in 18 files covered. (36.13%)

23 existing lines in 5 files now uncovered.

22500 of 44605 relevant lines covered (50.44%)

35606.31 hits per line

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

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

5
#include "Settings.h"
6
#include "DrawPoint.h"
7
#include "RTTR_Version.h"
8
#include "RttrConfig.h"
9
#include "drivers/AudioDriverWrapper.h"
10
#include "drivers/VideoDriverWrapper.h"
11
#include "files.h"
12
#include "helpers/strUtils.h"
13
#include "languages.h"
14
#include "gameData/PortraitConsts.h"
15
#include "gameData/const_gui_ids.h"
16
#include "libsiedler2/ArchivItem_Ini.h"
17
#include "libsiedler2/ArchivItem_Text.h"
18
#include "libsiedler2/libsiedler2.h"
19
#include "s25util/StringConversion.h"
20
#include "s25util/System.h"
21
#include "s25util/error.h"
22
#include <boost/filesystem/operations.hpp>
23

24
const int Settings::VERSION = 13;
25
const std::array<std::string, 10> Settings::SECTION_NAMES = {
26
  {"global", "video", "language", "driver", "sound", "lobby", "server", "proxy", "interface", "addons"}};
27

28
const std::array<short, 13> Settings::SCREEN_REFRESH_RATES = {
29
  {-1, 25, 30, 50, 60, 75, 80, 100, 120, 150, 180, 200, 240}};
30

31
const std::map<GUI_ID, std::string> persistentWindows = {{CGI_CHAT, "wnd_chat"},
32
                                                         {CGI_POSTOFFICE, "wnd_postoffice"},
33
                                                         {CGI_DISTRIBUTION, "wnd_distribution"},
34
                                                         {CGI_BUILDORDER, "wnd_buildorder"},
35
                                                         {CGI_TRANSPORT, "wnd_transport"},
36
                                                         {CGI_MILITARY, "wnd_military"},
37
                                                         {CGI_TOOLS, "wnd_tools"},
38
                                                         {CGI_INVENTORY, "wnd_inventory"},
39
                                                         {CGI_MINIMAP, "wnd_minimap"},
40
                                                         {CGI_BUILDINGS, "wnd_buildings"},
41
                                                         {CGI_BUILDINGSPRODUCTIVITY, "wnd_buildingsproductivity"},
42
                                                         {CGI_MUSICPLAYER, "wnd_musicplayer"},
43
                                                         {CGI_STATISTICS, "wnd_statistics"},
44
                                                         {CGI_ECONOMICPROGRESS, "wnd_economicprogress"},
45
                                                         {CGI_DIPLOMACY, "wnd_diplomacy"},
46
                                                         {CGI_SHIP, "wnd_ship"},
47
                                                         {CGI_MERCHANDISE_STATISTICS, "wnd_merchandise_statistics"}};
48

49
namespace validate {
50
boost::optional<uint16_t> checkPort(const std::string& port)
9✔
51
{
52
    int32_t iPort;
53
    if((helpers::tryFromString(port, iPort) || s25util::tryFromStringClassic(port, iPort)) && checkPort(iPort))
9✔
54
        return static_cast<uint16_t>(iPort);
3✔
55
    else
56
        return boost::none;
6✔
57
}
58
bool checkPort(int port)
7✔
59
{
60
    // Disallow port 0 as it may cause problems
61
    return port > 0 && port <= 65535;
7✔
62
}
63
} // namespace validate
64

65
Settings::Settings() //-V730
5✔
66
{
67
    LoadDefaults();
5✔
68
}
5✔
69

70
void Settings::LoadDefaults()
5✔
71
{
72
    // global
73
    // {
74
    // 0 = ask user at start, 1 = enabled, 2 = always ask
75
    global.submit_debug_data = 0;
5✔
76
    global.use_upnp = false;
5✔
77
    global.smartCursor = true;
5✔
78
    global.debugMode = false;
5✔
79
    global.showGFInfo = false;
5✔
80
    // }
81

82
    // video
83
    // {
84
    if(VIDEODRIVER.IsLoaded())
5✔
85
    {
86
        video.fullscreenSize = VIDEODRIVER.GetWindowSize();
3✔
87
        video.windowedSize = VIDEODRIVER.IsFullscreen() ? VideoMode(800, 600) : video.fullscreenSize;
3✔
88
        video.fullscreen = VIDEODRIVER.IsFullscreen();
3✔
89
    } else
90
    {
91
        video.windowedSize = video.fullscreenSize = VideoMode(800, 600);
2✔
92
        video.fullscreen = false;
2✔
93
    }
94
    video.framerate = 0; // Special value for HW vsync
5✔
95
    video.vbo = true;
5✔
96
    video.shared_textures = true;
5✔
97
    video.guiScale = 0; // special value indicating automatic selection
5✔
98
    // }
99

100
    // language
101
    // {
102
    language.language.clear();
5✔
103
    // }
104

105
    LANGUAGES.setLanguage(language.language);
5✔
106

107
    // driver
108
    // {
109
    driver.audio = AUDIODRIVER.GetName();
5✔
110
    driver.video = VIDEODRIVER.GetName();
5✔
111
    // }
112

113
    // sound
114
    // {
115
    sound.musicEnabled = false;
5✔
116
    sound.musicVolume = 30;
5✔
117
    sound.effectsEnabled = true;
5✔
118
    sound.effectsVolume = 75;
5✔
119
    sound.playlist = s25::files::defaultPlaylist;
5✔
120
    // }
121

122
    // lobby
123
    // {
124

125
    lobby.name = System::getUserName();
5✔
126
    lobby.portraitIndex = 0;
5✔
127
    lobby.password.clear();
5✔
128
    lobby.save_password = false;
5✔
129
    // }
130

131
    // server
132
    // {
133
    server.last_ip.clear();
5✔
134
    server.localPort = 3665;
5✔
135
    server.ipv6 = false;
5✔
136
    // }
137

138
    proxy = ProxySettings();
5✔
139
    proxy.port = 1080;
5✔
140

141
    // interface
142
    // {
143
    interface.autosave_interval = 0;
5✔
144
    interface.invertMouse = false;
5✔
145
    interface.enableWindowPinning = false;
5✔
146
    interface.windowSnapDistance = 8;
5✔
147
    // }
148

149
    // addons
150
    // {
151
    addons.configuration.clear();
5✔
152
    // }
153

154
    LoadIngameDefaults();
5✔
155
}
5✔
156

157
void Settings::LoadIngameDefaults()
5✔
158
{
159
    // ingame
160
    // {
161
    ingame.scale_statistics = false;
5✔
162
    ingame.showBQ = false;
5✔
163
    ingame.showNames = false;
5✔
164
    ingame.showProductivity = false;
5✔
165
    ingame.minimapExtended = false;
5✔
166
    // }
167

168
    // windows
169
    // {
170
    for(const auto& window : persistentWindows)
90✔
171
        windows.persistentSettings[window.first] = PersistentWindowSettings();
85✔
172
    // }
173
}
5✔
174

175
///////////////////////////////////////////////////////////////////////////////
176
// Routine zum Laden der Konfiguration
177
void Settings::Load()
×
178
{
179
    libsiedler2::Archiv settings;
×
180
    const auto settingsPath = RTTRCONFIG.ExpandPath(s25::resources::config);
×
181
    try
182
    {
183
        if(libsiedler2::Load(settingsPath, settings) != 0 || settings.size() < SECTION_NAMES.size())
×
184
            throw std::runtime_error("File missing or invalid");
×
185

186
        const libsiedler2::ArchivItem_Ini* iniGlobal =
187
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("global"));
×
188
        const libsiedler2::ArchivItem_Ini* iniVideo = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("video"));
×
189
        const libsiedler2::ArchivItem_Ini* iniLanguage =
190
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("language"));
×
191
        const libsiedler2::ArchivItem_Ini* iniDriver =
192
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("driver"));
×
193
        const libsiedler2::ArchivItem_Ini* iniSound = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("sound"));
×
194
        const libsiedler2::ArchivItem_Ini* iniLobby = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("lobby"));
×
195
        const libsiedler2::ArchivItem_Ini* iniServer =
196
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("server"));
×
197
        const libsiedler2::ArchivItem_Ini* iniProxy = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("proxy"));
×
198
        const libsiedler2::ArchivItem_Ini* iniInterface =
199
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("interface"));
×
200
        const libsiedler2::ArchivItem_Ini* iniAddons =
201
          static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("addons"));
×
202

203
        // ist eine der Kategorien nicht vorhanden?
204
        if(!iniGlobal || !iniVideo || !iniLanguage || !iniDriver || !iniSound || !iniLobby || !iniServer || !iniProxy
×
205
           || !iniInterface || !iniAddons)
×
206
        {
207
            throw std::runtime_error("Missing section");
×
208
        }
209
        // stimmt die Settingsversion?
210
        if(iniGlobal->getValue("version", 0) != VERSION)
×
211
            throw std::runtime_error("Wrong version");
×
212

213
        // global
214
        // {
215
        if(iniGlobal->getValue("gameversion") != rttr::version::GetRevision())
×
216
            s25util::warning("Your application version has changed - please recheck your settings!");
×
217

218
        global.submit_debug_data = iniGlobal->getIntValue("submit_debug_data");
×
219
        global.use_upnp = iniGlobal->getBoolValue("use_upnp");
×
220
        global.smartCursor = iniGlobal->getValue("smartCursor", true);
×
221
        global.debugMode = iniGlobal->getValue("debugMode", false);
×
222
        global.showGFInfo = iniGlobal->getValue("showGFInfo", false);
×
223
        // };
224

225
        // video
226
        // {
227
        video.windowedSize.width = iniVideo->getIntValue("windowed_width");
×
228
        video.windowedSize.height = iniVideo->getIntValue("windowed_height");
×
229
        video.fullscreenSize.width = iniVideo->getIntValue("fullscreen_width");
×
230
        video.fullscreenSize.height = iniVideo->getIntValue("fullscreen_height");
×
231
        video.fullscreen = iniVideo->getBoolValue("fullscreen");
×
232
        video.framerate = iniVideo->getValue("framerate", 0);
×
233
        video.vbo = iniVideo->getBoolValue("vbo");
×
234
        video.shared_textures = iniVideo->getBoolValue("shared_textures");
×
235
        video.guiScale = iniVideo->getValue("gui_scale", 0);
×
236
        // };
237

238
        if(video.fullscreenSize.width == 0 || video.fullscreenSize.height == 0 || video.windowedSize.width == 0
×
239
           || video.windowedSize.height == 0)
×
240
            throw std::runtime_error("Invalid video settings");
×
241

242
        // language
243
        // {
244
        language.language = iniLanguage->getValue("language");
×
245
        // }
246

247
        LANGUAGES.setLanguage(language.language);
×
248

249
        // driver
250
        // {
251
        driver.video = iniDriver->getValue("video");
×
252
        driver.audio = iniDriver->getValue("audio");
×
253
        // }
254

255
        // sound
256
        // {
257
        sound.musicEnabled = iniSound->getBoolValue("musik");
×
258
        sound.musicVolume = iniSound->getIntValue("musik_volume");
×
259
        sound.effectsEnabled = iniSound->getBoolValue("effekte");
×
260
        sound.effectsVolume = iniSound->getIntValue("effekte_volume");
×
261
        sound.playlist = iniSound->getValue("playlist");
×
262
        // }
263

264
        // lobby
265
        // {
266
        lobby.name = iniLobby->getValue("name");
×
NEW
267
        lobby.portraitIndex = iniLobby->getIntValue("portrait_index");
×
268
        lobby.password = iniLobby->getValue("password");
×
269
        lobby.save_password = iniLobby->getBoolValue("save_password");
×
270
        // }
271

272
        if(lobby.name.empty())
×
273
            lobby.name = System::getUserName();
×
274

NEW
275
        if(lobby.portraitIndex >= Portraits.size())
×
276
        {
NEW
277
            lobby.portraitIndex = 0;
×
278
        }
279

280
        // server
281
        // {
282
        server.last_ip = iniServer->getValue("last_ip");
×
283
        boost::optional<uint16_t> port = validate::checkPort(iniServer->getValue("local_port"));
×
284
        server.localPort = port.value_or(3665);
×
285
        server.ipv6 = iniServer->getBoolValue("ipv6");
×
286
        // }
287

288
        // proxy
289
        // {
290
        proxy.hostname = iniProxy->getValue("proxy");
×
291
        port = validate::checkPort(iniProxy->getValue("port"));
×
292
        proxy.port = port.value_or(1080);
×
293
        proxy.type = ProxyType(iniProxy->getIntValue("typ"));
×
294
        // }
295

296
        // leere proxyadresse deaktiviert proxy komplett
297
        // deaktivierter proxy entfernt proxyadresse
298
        if(proxy.hostname.empty() || (proxy.type != ProxyType::Socks4 && proxy.type != ProxyType::Socks5))
×
299
        {
300
            proxy.type = ProxyType::None;
×
301
            proxy.hostname.clear();
×
302
        }
303
        // aktivierter Socks v4 deaktiviert ipv6
304
        else if(proxy.type == ProxyType::Socks4 && server.ipv6)
×
305
            server.ipv6 = false;
×
306

307
        // interface
308
        // {
309
        interface.autosave_interval = iniInterface->getIntValue("autosave_interval");
×
310
        interface.invertMouse = iniInterface->getValue("invert_mouse", false);
×
311
        interface.enableWindowPinning = iniInterface->getValue("enable_window_pinning", false);
×
312
        interface.windowSnapDistance = iniInterface->getValue("window_snap_distance", 8);
×
313
        // }
314

315
        // addons
316
        // {
317
        for(unsigned addon = 0; addon < iniAddons->size(); ++addon)
×
318
        {
319
            const auto* item = dynamic_cast<const libsiedler2::ArchivItem_Text*>(iniAddons->get(addon));
×
320

321
            if(item)
×
322
                addons.configuration.insert(std::make_pair(s25util::fromStringClassic<unsigned>(item->getName()),
×
323
                                                           s25util::fromStringClassic<unsigned>(item->getText())));
×
324
        }
325

326
        LoadIngame();
×
327
        // }
328
    } catch(const std::runtime_error& e)
×
329
    {
330
        s25util::warning(std::string("Could not use settings from \"") + settingsPath.string()
×
331
                         + "\", using default values. Reason: " + e.what());
×
332
        LoadDefaults();
×
333
        Save();
×
334
    }
335
}
×
336

337
void Settings::LoadIngame()
×
338
{
339
    libsiedler2::Archiv settingsIngame;
×
340
    const auto settingsPathIngame = RTTRCONFIG.ExpandPath(s25::resources::ingameOptions);
×
341
    try
342
    {
343
        if(libsiedler2::Load(settingsPathIngame, settingsIngame) != 0)
×
344
            throw std::runtime_error("File missing");
×
345

346
        const libsiedler2::ArchivItem_Ini* iniIngame =
347
          static_cast<libsiedler2::ArchivItem_Ini*>(settingsIngame.find("ingame"));
×
348
        if(!iniIngame)
×
349
            throw std::runtime_error("Missing section");
×
350
        // ingame
351
        // {
352
        ingame.scale_statistics = iniIngame->getBoolValue("scale_statistics");
×
353
        ingame.showBQ = iniIngame->getBoolValue("show_building_quality");
×
354
        ingame.showNames = iniIngame->getBoolValue("show_names");
×
355
        ingame.showProductivity = iniIngame->getBoolValue("show_productivity");
×
356
        ingame.minimapExtended = iniIngame->getBoolValue("minimap_extended");
×
357
        // }
358
        // ingame windows
359
        for(const auto& window : persistentWindows)
×
360
        {
361
            const auto* iniWindow = static_cast<const libsiedler2::ArchivItem_Ini*>(settingsIngame.find(window.second));
×
362
            if(!iniWindow)
×
363
                continue;
×
364
            auto& settings = windows.persistentSettings[window.first];
×
365
            const auto lastPos = settings.lastPos =
×
366
              DrawPoint(iniWindow->getIntValue("pos_x"), iniWindow->getIntValue("pos_y"));
×
367
            settings.restorePos = DrawPoint(iniWindow->getValue("restore_pos_x", lastPos.x),
×
368
                                            iniWindow->getValue("restore_pos_y", lastPos.y));
×
369
            settings.isOpen = iniWindow->getIntValue("is_open");
×
370
            settings.isPinned = iniWindow->getValue("is_pinned", false);
×
371
            settings.isMinimized = iniWindow->getValue("is_minimized", false);
×
372
        }
373
    } catch(const std::runtime_error& e)
×
374
    {
375
        s25util::warning(std::string("Could not use ingame settings from \"") + settingsPathIngame.string()
×
376
                         + "\", using default values. Reason: " + e.what());
×
377
        LoadIngameDefaults();
×
378
        SaveIngame();
×
379
    }
380
}
×
381

382
///////////////////////////////////////////////////////////////////////////////
383
// Routine zum Speichern der Konfiguration
384
void Settings::Save()
×
385
{
386
    libsiedler2::Archiv settings;
×
387
    settings.alloc(SECTION_NAMES.size());
×
388
    for(unsigned i = 0; i < SECTION_NAMES.size(); ++i)
×
389
        settings.set(i, std::make_unique<libsiedler2::ArchivItem_Ini>(SECTION_NAMES[i]));
×
390

391
    libsiedler2::ArchivItem_Ini* iniGlobal = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("global"));
×
392
    libsiedler2::ArchivItem_Ini* iniVideo = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("video"));
×
393
    libsiedler2::ArchivItem_Ini* iniLanguage = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("language"));
×
394
    libsiedler2::ArchivItem_Ini* iniDriver = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("driver"));
×
395
    libsiedler2::ArchivItem_Ini* iniSound = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("sound"));
×
396
    libsiedler2::ArchivItem_Ini* iniLobby = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("lobby"));
×
397
    libsiedler2::ArchivItem_Ini* iniServer = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("server"));
×
398
    libsiedler2::ArchivItem_Ini* iniProxy = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("proxy"));
×
399
    libsiedler2::ArchivItem_Ini* iniInterface = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("interface"));
×
400
    libsiedler2::ArchivItem_Ini* iniAddons = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("addons"));
×
401

402
    // ist eine der Kategorien nicht vorhanden?
403
    RTTR_Assert(iniGlobal && iniVideo && iniLanguage && iniDriver && iniSound && iniLobby && iniServer && iniProxy
×
404
                && iniInterface && iniAddons);
405

406
    // global
407
    // {
408
    iniGlobal->setValue("version", VERSION);
×
409
    iniGlobal->setValue("gameversion", rttr::version::GetRevision());
×
410
    iniGlobal->setValue("submit_debug_data", global.submit_debug_data);
×
411
    iniGlobal->setValue("use_upnp", global.use_upnp);
×
412
    iniGlobal->setValue("smartCursor", global.smartCursor);
×
413
    iniGlobal->setValue("debugMode", global.debugMode);
×
414
    iniGlobal->setValue("showGFInfo", global.showGFInfo);
×
415
    // };
416

417
    // video
418
    // {
419
    iniVideo->setValue("fullscreen_width", video.fullscreenSize.width);
×
420
    iniVideo->setValue("fullscreen_height", video.fullscreenSize.height);
×
421
    iniVideo->setValue("windowed_width", video.windowedSize.width);
×
422
    iniVideo->setValue("windowed_height", video.windowedSize.height);
×
423
    iniVideo->setValue("fullscreen", video.fullscreen);
×
424
    iniVideo->setValue("framerate", video.framerate);
×
425
    iniVideo->setValue("vbo", video.vbo);
×
426
    iniVideo->setValue("shared_textures", video.shared_textures);
×
427
    iniVideo->setValue("gui_scale", video.guiScale);
×
428
    // };
429

430
    // language
431
    // {
432
    iniLanguage->setValue("language", language.language);
×
433
    // }
434

435
    // driver
436
    // {
437
    iniDriver->setValue("video", driver.video);
×
438
    iniDriver->setValue("audio", driver.audio);
×
439
    // }
440

441
    // sound
442
    // {
443
    iniSound->setValue("musik", sound.musicEnabled);
×
444
    iniSound->setValue("musik_volume", sound.musicVolume);
×
445
    iniSound->setValue("effekte", sound.effectsEnabled);
×
446
    iniSound->setValue("effekte_volume", sound.effectsVolume);
×
447
    iniSound->setValue("playlist", sound.playlist);
×
448
    // }
449

450
    // lobby
451
    // {
452
    iniLobby->setValue("name", lobby.name);
×
NEW
453
    iniLobby->setValue("portrait_index", lobby.portraitIndex);
×
454
    iniLobby->setValue("password", lobby.password);
×
455
    iniLobby->setValue("save_password", lobby.save_password);
×
456
    // }
457

458
    // server
459
    // {
460
    iniServer->setValue("last_ip", server.last_ip);
×
461
    iniServer->setValue("local_port", server.localPort);
×
462
    iniServer->setValue("ipv6", server.ipv6);
×
463
    // }
464

465
    // proxy
466
    // {
467
    iniProxy->setValue("proxy", proxy.hostname);
×
468
    iniProxy->setValue("port", proxy.port);
×
469
    iniProxy->setValue("typ", static_cast<int>(proxy.type));
×
470
    // }
471

472
    // interface
473
    // {
474
    iniInterface->setValue("autosave_interval", interface.autosave_interval);
×
475
    iniInterface->setValue("invert_mouse", interface.invertMouse);
×
476
    iniInterface->setValue("enable_window_pinning", interface.enableWindowPinning);
×
477
    iniInterface->setValue("window_snap_distance", interface.windowSnapDistance);
×
478
    // }
479

480
    // addons
481
    // {
482
    iniAddons->clear();
×
483
    for(const auto& it : addons.configuration)
×
484
        iniAddons->setValue(s25util::toStringClassic(it.first), s25util::toStringClassic(it.second));
×
485
    // }
486

487
    bfs::path settingsPath = RTTRCONFIG.ExpandPath(s25::resources::config);
×
488
    if(libsiedler2::Write(settingsPath, settings) == 0)
×
489
        bfs::permissions(settingsPath, bfs::owner_read | bfs::owner_write);
×
490

491
    SaveIngame();
×
492
}
×
493

494
void Settings::SaveIngame()
×
495
{
496
    libsiedler2::Archiv settingsIngame;
×
497
    settingsIngame.alloc(1 + persistentWindows.size());
×
498
    settingsIngame.set(0, std::make_unique<libsiedler2::ArchivItem_Ini>("ingame"));
×
499
    unsigned i = 1;
×
500
    for(const auto& window : persistentWindows)
×
501
    {
502
        settingsIngame.set(i, std::make_unique<libsiedler2::ArchivItem_Ini>(window.second));
×
503
        i++;
×
504
    }
505

506
    auto* iniIngame = static_cast<libsiedler2::ArchivItem_Ini*>(settingsIngame.find("ingame"));
×
507

508
    RTTR_Assert(iniIngame);
×
509

510
    // ingame
511
    // {
512
    iniIngame->setValue("scale_statistics", ingame.scale_statistics);
×
513
    iniIngame->setValue("show_building_quality", ingame.showBQ);
×
514
    iniIngame->setValue("show_names", ingame.showNames);
×
515
    iniIngame->setValue("show_productivity", ingame.showProductivity);
×
516
    iniIngame->setValue("minimap_extended", ingame.minimapExtended);
×
517
    // }
518

519
    // ingame windows
520
    for(const auto& window : persistentWindows)
×
521
    {
522
        auto* iniWindow = static_cast<libsiedler2::ArchivItem_Ini*>(settingsIngame.find(window.second));
×
523
        if(!iniWindow)
×
524
            continue;
×
525
        const auto& settings = windows.persistentSettings[window.first];
×
526
        iniWindow->setValue("pos_x", settings.lastPos.x);
×
527
        iniWindow->setValue("pos_y", settings.lastPos.y);
×
528
        if(settings.restorePos != settings.lastPos)
×
529
        {
530
            // only save if different; defaults to lastPos on load
531
            iniWindow->setValue("restore_pos_x", settings.restorePos.x);
×
532
            iniWindow->setValue("restore_pos_y", settings.restorePos.y);
×
533
        }
534
        iniWindow->setValue("is_open", settings.isOpen);
×
535
        iniWindow->setValue("is_pinned", settings.isPinned);
×
536
        iniWindow->setValue("is_minimized", settings.isMinimized);
×
537
    }
538

539
    bfs::path settingsPathIngame = RTTRCONFIG.ExpandPath(s25::resources::ingameOptions);
×
540
    if(libsiedler2::Write(settingsPathIngame, settingsIngame) == 0)
×
541
        bfs::permissions(settingsPathIngame, bfs::owner_read | bfs::owner_write);
×
542
}
×
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