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

Return-To-The-Roots / s25client / 28198631398

25 Jun 2026 08:31PM UTC coverage: 50.373% (-0.004%) from 50.377%
28198631398

Pull #1949

github

web-flow
Merge 96c5682c4 into d70b8eccf
Pull Request #1949: Fix and extend AI-Battle

1 of 3 new or added lines in 2 files covered. (33.33%)

2 existing lines in 2 files now uncovered.

23182 of 46021 relevant lines covered (50.37%)

43612.97 hits per line

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

75.86
/libs/s25main/addons/AddonList.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 "AddonList.h"
6
#include "Loader.h"
7
#include "Window.h"
8
#include "controls/ctrlComboBox.h"
9
#include <stdexcept>
10

11
AddonList::AddonList(const AddonId id, AddonGroup groups, const std::string& name, const std::string& description,
6,625✔
12
                     std::vector<std::string> options, unsigned defaultStatus /*=0*/)
6,625✔
13
    : Addon(id, groups, name, description, defaultStatus), options(std::move(options))
6,625✔
14
{
15
    if(defaultStatus >= this->options.size())
6,625✔
16
        throw std::logic_error("Invalid default option");
×
17
}
6,625✔
18

19
std::unique_ptr<AddonGui> AddonList::createGui(Window& window, bool readonly) const
50✔
20
{
21
    return std::make_unique<Gui>(*this, window, readonly);
50✔
22
}
23

24
unsigned AddonList::getNumOptions() const
50✔
25
{
26
    return options.size();
50✔
27
}
28

NEW
29
const std::string& AddonList::getOptionName(unsigned status) const
×
30
{
NEW
31
    return options.at(status);
×
32
}
33

34
AddonList::Gui::Gui(const AddonList& addon, Window& window, bool readonly) : AddonGui(addon, window, readonly)
50✔
35
{
36
    DrawPoint cbPos(430, 0);
50✔
37

38
    auto* cb = window.AddComboBox(2, cbPos, Extent(220, 20), TextureColor::Grey, NormalFont, 100, readonly);
50✔
39
    for(const auto& option : addon.options)
284✔
40
        cb->AddItem(option);
234✔
41
    if(readonly)
50✔
42
        window.AddImage(3, cbPos - DrawPoint(1, 0), LOADER.GetImageN("io_new", 14), _("Locked"));
50✔
43
}
50✔
44

45
void AddonList::Gui::setStatus(Window& window, unsigned status)
50✔
46
{
47
    auto* cb = window.GetCtrl<ctrlComboBox>(2);
50✔
48
    RTTR_Assert(cb);
50✔
49
    cb->SetSelection(status);
50✔
50
}
50✔
51

52
unsigned AddonList::Gui::getStatus(const Window& window)
×
53
{
54
    const auto* cb = window.GetCtrl<ctrlComboBox>(2);
×
55
    RTTR_Assert(cb);
×
56
    return *cb->GetSelection();
×
57
}
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