Remember last sucessfully connected server address
This commit is contained in:
parent
bd5fc33816
commit
789d75bf26
@ -71,6 +71,11 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource)
|
||||
OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
GUIEngine::TextBoxWidget* getTextField() const { return m_text_field; }
|
||||
// ------------------------------------------------------------------------
|
||||
GUIEngine::LabelWidget* getTitle() const { return m_title; }
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/list_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/text_box_widget.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
@ -234,9 +235,10 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
core::stringw instruction =
|
||||
_("Enter the server address with IP followed by : and then port.");
|
||||
new GeneralTextFieldDialog(instruction.c_str(),
|
||||
auto gtfd = new GeneralTextFieldDialog(instruction.c_str(),
|
||||
[] (const irr::core::stringw& text) {},
|
||||
[](GUIEngine::LabelWidget* lw, GUIEngine::TextBoxWidget* tb)->bool
|
||||
[this] (GUIEngine::LabelWidget* lw,
|
||||
GUIEngine::TextBoxWidget* tb)->bool
|
||||
{
|
||||
TransportAddress server_addr(
|
||||
StringUtils::wideToUtf8(tb->getText()));
|
||||
@ -267,11 +269,17 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
return false;
|
||||
}
|
||||
|
||||
m_entered_server_address.copy(server_addr);
|
||||
auto cl = LobbyProtocol::create<ClientLobby>();
|
||||
cl->setAddress(server_addr);
|
||||
cl->requestStart();
|
||||
return true;
|
||||
});
|
||||
if (!m_entered_server_address.isUnset())
|
||||
{
|
||||
gtfd->getTextField()->setText(StringUtils::utf8ToWide(
|
||||
m_entered_server_address.toString()));
|
||||
}
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
#define HEADER_ONLINE_SCREEN_HPP
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "network/transport_address.hpp"
|
||||
|
||||
|
||||
namespace GUIEngine { class CheckBoxWidget; class ListWidget;
|
||||
class ButtonWidget; class IconButtonWidget; }
|
||||
@ -44,6 +46,8 @@ private:
|
||||
|
||||
GUIEngine::CheckBoxWidget* m_enable_splitscreen;
|
||||
|
||||
TransportAddress m_entered_server_address;
|
||||
|
||||
OnlineScreen();
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user