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

Return-To-The-Roots / s25client / 22797872430

07 Mar 2026 11:05AM UTC coverage: 50.156% (-0.2%) from 50.327%
22797872430

Pull #1890

github

web-flow
Merge 4597ccbf9 into d2a3730c9
Pull Request #1890: Add support for borderless Windows

155 of 626 new or added lines in 44 files covered. (24.76%)

26 existing lines in 9 files now uncovered.

23041 of 45939 relevant lines covered (50.16%)

44513.07 hits per line

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

0.0
/libs/s25main/ingameWindows/iwDirectIPCreate.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 "iwDirectIPCreate.h"
6
#include "Loader.h"
7
#include "Settings.h"
8
#include "WindowManager.h"
9
#include "controls/ctrlButton.h"
10
#include "controls/ctrlEdit.h"
11
#include "controls/ctrlOptionGroup.h"
12
#include "controls/ctrlText.h"
13
#include "desktops/dskSelectMap.h"
14
#include "network/CreateServerInfo.h"
15
#include "ogl/FontStyle.h"
16
#include "gameData/const_gui_ids.h"
17

18
iwDirectIPCreate::iwDirectIPCreate(ServerType server_type)
×
19
    : IngameWindow(CGI_DIRECTIPCREATE, IngameWindow::posLastOrCenter, Extent(300, 285), _("Create Game"),
×
20
                   LOADER.GetImageN("resource", 41), true, CloseBehavior::Custom),
×
21
      server_type(server_type)
×
22
{
23
    ctrlEdit *name, *port;
24

25
    // "Name des Spiels"
26
    AddText(0, DrawPoint(20, 30), _("Game's Name:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
27
    name = AddEdit(1, DrawPoint(20, 45), Extent(260, 22), TextureColor::Green2, NormalFont, 0, false, false, true);
×
28

29
    // "Server-Port"
30
    AddText(2, DrawPoint(20, 80), _("Server-Port:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
31
    port = AddEdit(3, DrawPoint(20, 95), Extent(260, 22), TextureColor::Green2, NormalFont, 0, false, false, true);
×
32

33
    // "Passwort"
34
    AddText(4, DrawPoint(20, 130), _("Password:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
35
    AddEdit(5, DrawPoint(20, 145), Extent(260, 22), TextureColor::Green2, NormalFont, 0, false, false, true);
×
36

37
    // ipv6 oder ipv4 benutzen
38
    AddText(11, DrawPoint(20, 185), _("Use IPv6:"), COLOR_YELLOW, FontStyle{}, NormalFont);
×
39

40
    ctrlOptionGroup* ipv6 = AddOptionGroup(12, GroupSelectType::Check);
×
41
    ipv6->AddTextButton(0, DrawPoint(120, 180), Extent(75, 22), TextureColor::Green2, _("IPv4"), NormalFont);
×
42
    ipv6->AddTextButton(1, DrawPoint(205, 180), Extent(75, 22), TextureColor::Green2, _("IPv6"), NormalFont);
×
43
    ipv6->SetSelection((SETTINGS.server.ipv6 ? 1 : 0));
×
44

45
    // Status
46
    AddText(6, DrawPoint(150, 215), "", COLOR_RED, FontStyle::CENTER, NormalFont);
×
47

48
    // "Starten"
49
    AddTextButton(7, DrawPoint(20, 240), Extent(125, 22), TextureColor::Green2, _("Start"), NormalFont);
×
50

51
    // "Zurück"
52
    AddTextButton(8, DrawPoint(155, 240), Extent(125, 22), TextureColor::Red1, _("Back"), NormalFont);
×
53

54
    name->SetText(SETTINGS.lobby.name + _("'s Game"));
×
55
    name->SetFocus();
×
56
    port->SetText(SETTINGS.server.localPort);
×
57
}
×
58

59
/**
60
 *  Statustext resetten
61
 */
62
void iwDirectIPCreate::Msg_EditChange(const unsigned /*ctrl_id*/)
×
63
{
64
    // Statustext resetten
65
    SetText("", COLOR_RED, true);
×
66
}
×
67

68
/**
69
 *  Bei Enter nächstes Steuerelement auswählen
70
 */
71
void iwDirectIPCreate::Msg_EditEnter(const unsigned ctrl_id)
×
72
{
73
    auto* name = GetCtrl<ctrlEdit>(1);
×
74
    auto* port = GetCtrl<ctrlEdit>(3);
×
75
    auto* pass = GetCtrl<ctrlEdit>(5);
×
76

77
    switch(ctrl_id)
×
78
    {
79
        case 1:
×
80
        {
81
            name->SetFocus(false);
×
82
            port->SetFocus(true);
×
83
            pass->SetFocus(false);
×
84
        }
85
        break;
×
86
        case 3:
×
87
        {
88
            name->SetFocus(false);
×
89
            port->SetFocus(false);
×
90
            pass->SetFocus(false);
×
91
        }
92
        break;
×
93
        case 5:
×
94
        {
95
            // Starten klicken
96
            Msg_ButtonClick(7);
×
97
        }
98
        break;
×
99
    }
100
}
×
101

102
void iwDirectIPCreate::Msg_OptionGroupChange(const unsigned ctrl_id, const unsigned selection)
×
103
{
104
    switch(ctrl_id)
×
105
    {
106
        case 12: // IPv6 Ja/Nein
×
107
        {
108
            SETTINGS.server.ipv6 = (selection == 1);
×
109
        }
110
        break;
×
111
    }
112
}
×
113

114
/**
115
 *  Button Clicki-Di-Bunti-Li
116
 */
117
void iwDirectIPCreate::Msg_ButtonClick(const unsigned ctrl_id)
×
118
{
119
    switch(ctrl_id)
×
120
    {
121
        case 7: // "Starten"
×
122
        {
123
            auto* edtName = GetCtrl<ctrlEdit>(1);
×
124
            auto* edtPort = GetCtrl<ctrlEdit>(3);
×
125
            auto* edtPw = GetCtrl<ctrlEdit>(5);
×
126

127
            if(edtName->GetText().empty())
×
128
            {
129
                SetText(_("Please enter a name for the game"), COLOR_RED, false);
×
130
                edtName->SetFocus(true);
×
131
                edtPort->SetFocus(false);
×
132
                edtPw->SetFocus(false);
×
133
                break;
×
134
            }
135
            boost::optional<uint16_t> port = validate::checkPort(edtPort->GetText());
×
136
            if(!port)
×
137
            {
138
                SetText(_("Invalid port. The valid port-range is 1 to 65535!"), COLOR_RED, false);
×
139
                edtName->SetFocus(false);
×
140
                edtPort->SetFocus(true);
×
141
                edtPw->SetFocus(false);
×
142
                break;
×
143
            }
144

145
            CreateServerInfo csi(server_type, *port, edtName->GetText(), edtPw->GetText(), SETTINGS.server.ipv6,
×
NEW
146
                                 SETTINGS.global.useUPNP);
×
147

148
            // Map auswählen
149
            WINDOWMANAGER.Switch(std::make_unique<dskSelectMap>(csi));
×
150
        }
151
        break;
×
152
        case 8:
×
153
        {
154
            Close();
×
155
        }
156
        break;
×
157
    }
158
}
×
159

160
/**
161
 *  Setzt den Text und Schriftfarbe vom Textfeld und den Status des
162
 *  Buttons.
163
 */
164
void iwDirectIPCreate::SetText(const std::string& text, unsigned color, bool button)
×
165
{
166
    // Text setzen
167
    GetCtrl<ctrlText>(6)->SetTextColor(color);
×
168
    GetCtrl<ctrlText>(6)->SetText(text);
×
169

170
    // Button (de)aktivieren
171
    GetCtrl<ctrlButton>(7)->SetEnabled(button);
×
172
}
×
173

174
/**
175
 *  Status: Benutzerdefinierter Fehler
176
 */
177
void iwDirectIPCreate::LC_Status_Error(const std::string& error)
×
178
{
179
    auto* name = GetCtrl<ctrlEdit>(1);
×
180
    auto* port = GetCtrl<ctrlEdit>(3);
×
181
    auto* pass = GetCtrl<ctrlEdit>(5);
×
182

183
    name->SetFocus(true);
×
184
    port->SetFocus(false);
×
185
    pass->SetFocus(false);
×
186

187
    name->SetDisabled(false);
×
188
    port->SetDisabled(false);
×
189
    pass->SetDisabled(false);
×
190

191
    SetText(error, COLOR_RED, true);
×
192
}
×
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