37 if (elementIndex == 0)
39#ifdef MANASERV_SUPPORT
40 if (elementIndex == 1)
47 Window(
_(
"Custom Server"), true, parent),
48 mServerDialog(parent),
53 auto *nameLabel =
new Label(
_(
"Name:"));
54 auto *serverAdressLabel =
new Label(
_(
"Address:"));
55 auto *portLabel =
new Label(
_(
"Port:"));
56#ifdef MANASERV_SUPPORT
57 auto *typeLabel =
new Label(
_(
"Server type:"));
59 auto *descriptionLabel =
new Label(
_(
"Description:"));
63#ifdef MANASERV_SUPPORT
64 mTypeListModel = std::make_unique<TypeListModel>();
65 mTypeField =
new DropDown(mTypeListModel.get());
66 mTypeField->setSelected(0);
78 place(0, 0, nameLabel);
80 place(0, 1, serverAdressLabel);
82 place(0, 2, portLabel);
84#ifdef MANASERV_SUPPORT
85 place(0, 3, typeLabel);
88 place(0, 4, descriptionLabel);
106#ifdef MANASERV_SUPPORT
121 if (event.getId() ==
"ok")
126 if (event.getId() ==
"addServer")
132 _(
"Please type in at least the address of the server."));
133 dlg->addActionListener(
this);
144#ifdef MANASERV_SUPPORT
145 switch (mTypeField->getSelected())
162 serverInfo.
port =
static_cast<uint16_t
>(atoi(
mPortField->getText().c_str()));
165 serverInfo.
save =
true;
172 else if (event.getId() ==
"cancel")
180 gcn::Key key = keyEvent.getKey();
TextField * mServerAddressField
CustomServerDialog(ServerDialog *parent, int index=-1)
TextField * mDescriptionField
~CustomServerDialog() override
void action(const gcn::ActionEvent &event) override
Called when receiving actions from the widgets.
void keyPressed(gcn::KeyEvent &keyEvent) override
ServerDialog * mServerDialog
A drop down box from which you can select different values.
LayoutCell & setPadding(int p)
Sets the padding around the cell content.
The server choice dialog.
void saveCustomServers(const ServerInfo ¤tServer=ServerInfo(), int index=-1)
Saves the new server entry in the custom server list.
static uint16_t defaultPortForServerType(ServerType type)
std::string getElementAt(int elementIndex) override
Used to get an element from the list.
virtual void setVisible(bool visible)
Overloads window setVisible by Guichan to allow sticky window handling.
Window * getParentWindow() const
Returns the parent window.
void setWindowName(const std::string &name)
Sets the name of the window.
void reflowLayout(int w=0, int h=0)
Computes the position of the widgets according to the current layout.
LayoutCell & place(int x, int y, gcn::Widget *, int w=1, int h=1)
Adds a widget to the window and sets it at given cell.
void scheduleDelete()
Schedule this window for deletion.
void setLocationRelativeTo(gcn::Widget *widget)
Sets the location relative to the given widget.
std::string toString(const T &arg)
Converts the given value to a string using std::stringstream.