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

Return-To-The-Roots / s25client / 17208623929

25 Aug 2025 12:19PM UTC coverage: 50.497% (-0.005%) from 50.502%
17208623929

Pull #1794

github

web-flow
Merge 136f11398 into e99b7a27a
Pull Request #1794: Fix lags in right-click scrolling for SDL2

14 of 35 new or added lines in 8 files covered. (40.0%)

8 existing lines in 5 files now uncovered.

22514 of 44585 relevant lines covered (50.5%)

35961.31 hits per line

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

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

5
#include "dskMainMenu.h"
6
#include "CollisionDetection.h"
7
#include "GlobalVars.h"
8
#include "Loader.h"
9
#include "Settings.h"
10
#include "WindowManager.h"
11
#include "controls/ctrlButton.h"
12
#include "controls/ctrlTimer.h"
13
#include "desktops/dskCredits.h"
14
#include "desktops/dskIntro.h"
15
#include "desktops/dskMultiPlayer.h"
16
#include "desktops/dskOptions.h"
17
#include "desktops/dskSinglePlayer.h"
18
#include "desktops/dskTest.h"
19
#include "ingameWindows/iwMsgbox.h"
20
#include "ingameWindows/iwTextfile.h"
21

22
enum
23
{
24
    ID_btSingleplayer = dskMenuBase::ID_FIRST_FREE,
25
    ID_btMultiplayer,
26
    ID_btOptions,
27
    ID_btIntro,
28
    ID_btReadme,
29
    ID_btCredits,
30
    ID_btQuit,
31
    ID_logo,
32
    ID_tmrDebugData
33
};
34

35
dskMainMenu::dskMainMenu()
×
36
{
37
    RTTR_Assert(dskMenuBase::ID_FIRST_FREE <= 3);
38

UNCOV
39
    AddTextButton(ID_btSingleplayer, DrawPoint(115, 180), Extent(220, 22), TextureColor::Green2, _("Singleplayer"),
×
40
                  NormalFont);
×
UNCOV
41
    AddTextButton(ID_btMultiplayer, DrawPoint(115, 210), Extent(220, 22), TextureColor::Green2, _("Multiplayer"),
×
42
                  NormalFont);
×
UNCOV
43
    AddTextButton(ID_btOptions, DrawPoint(115, 250), Extent(220, 22), TextureColor::Green2, _("Options"), NormalFont);
×
44
    AddTextButton(ID_btIntro, DrawPoint(115, 280), Extent(220, 22), TextureColor::Green2, _("Intro"), NormalFont)
×
45
      ->SetEnabled(false);
×
UNCOV
46
    AddTextButton(ID_btReadme, DrawPoint(115, 310), Extent(220, 22), TextureColor::Green2, _("Readme"), NormalFont);
×
47
    AddTextButton(ID_btCredits, DrawPoint(115, 340), Extent(220, 22), TextureColor::Green2, _("Credits"), NormalFont);
×
48
    AddTextButton(ID_btQuit, DrawPoint(115, 390), Extent(220, 22), TextureColor::Red1, _("Quit program"), NormalFont);
×
49

50
    AddImage(ID_logo, DrawPoint(20, 20), LOADER.GetImageN("logo", 0));
×
51

52
    using namespace std::chrono_literals;
53
    if(SETTINGS.global.submit_debug_data == 0)
×
54
        AddTimer(ID_tmrDebugData, 250ms);
×
55

56
    /*AddText(20, DrawPoint(50, 450), _("Font Test"), COLOR_YELLOW, FontStyle::LEFT, SmallFont);
57
    AddText(21, DrawPoint(50, 470), _("Font Test"), COLOR_YELLOW, FontStyle::LEFT, NormalFont);
58
    AddText(22, DrawPoint(50, 490), _("Font Test"), COLOR_YELLOW, FontStyle::LEFT, LargeFont);*/
59
    //  !\"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz\\_ABCDEFGHIJKLMNOPQRSTUVWXYZÇüéâäàåçêëèïîì©ÄÅôöòûùÖÜáíóúñ
60
}
×
61

62
void dskMainMenu::Msg_Timer(const unsigned ctrl_id)
×
63
{
64
    GetCtrl<ctrlTimer>(ctrl_id)->Stop();
×
65
    WINDOWMANAGER.Show(std::make_unique<iwMsgbox>(
×
66
      _("Submit debug data?"),
×
67
      _("RttR now supports sending debug data. Would you like to help us improving this game by sending debug data?"),
×
68
      this, MsgboxButton::YesNo, MsgboxIcon::QuestionRed, 100));
×
69
}
×
70

71
void dskMainMenu::Msg_MsgBoxResult(const unsigned msgbox_id, const MsgboxResult mbr)
×
72
{
73
    if(msgbox_id == 100)
×
74
    {
75
        if(mbr == MsgboxResult::Yes)
×
76
            SETTINGS.global.submit_debug_data = 1;
×
77
        else
78
            SETTINGS.global.submit_debug_data = 2;
×
79

80
        SETTINGS.Save();
×
81
    }
82
}
×
83

84
bool dskMainMenu::Msg_LeftUp(const MouseCoords& mc)
×
85
{
86
    auto* txtVersion = GetCtrl<Window>(dskMenuBase::ID_txtVersion);
×
87
    if(mc.dbl_click && IsPointInRect(mc.GetPos(), txtVersion->GetBoundaryRect()))
×
88
    {
89
        WINDOWMANAGER.Switch(std::make_unique<dskTest>());
×
90
        return true;
×
91
    }
92
    return false;
×
93
}
94

95
void dskMainMenu::Msg_ButtonClick(const unsigned ctrl_id)
×
96
{
97
    switch(ctrl_id)
×
98
    {
99
        case ID_btSingleplayer: // "Single Player"
×
100
            WINDOWMANAGER.Switch(std::make_unique<dskSinglePlayer>());
×
101
            break;
×
102
        case ID_btMultiplayer: // "Multiplayer"
×
103
            WINDOWMANAGER.Switch(std::make_unique<dskMultiPlayer>());
×
104
            break;
×
105
        case ID_btOptions: // "Options"
×
106
            WINDOWMANAGER.Switch(std::make_unique<dskOptions>());
×
107
            break;
×
108
        case ID_btIntro: // "Intro"
×
109
            WINDOWMANAGER.Switch(std::make_unique<dskIntro>());
×
110
            break;
×
111
        case ID_btCredits: // "Credits"
×
112
            WINDOWMANAGER.Switch(std::make_unique<dskCredits>());
×
113
            break;
×
114
        case ID_btQuit: // "Quit"
×
115
            GLOBALVARS.notdone = false;
×
116
            break;
×
117
        case ID_btReadme: // "Readme"
×
118
            WINDOWMANAGER.ToggleWindow(std::make_unique<iwTextfile>("readme.txt", _("Readme!")));
×
119
            break;
×
120
    }
121
}
×
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