Author: mordante
Date: Sat Apr 5 13:10:16 2008
New Revision: 25560
URL: http://svn.gna.org/viewcvs/wesnoth?rev=25560&view=rev
Log:
Make the addon connection a class, this way we can fetch the data and retrieve
the results easily. The addon dialog starts to look like the first working
dialog.
More testing and polishing is still required.
Modified:
trunk/src/gui/dialogs/addon_connect.cpp
trunk/src/gui/dialogs/addon_connect.hpp
trunk/src/gui/widgets/grid.cpp
trunk/src/gui/widgets/grid.hpp
trunk/src/gui/widgets/widget.hpp
Modified: trunk/src/gui/dialogs/addon_connect.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/addon_connect.cpp?rev=25560&r1=25559&r2=25560&view=diff
==============================================================================
--- trunk/src/gui/dialogs/addon_connect.cpp (original)
+++ trunk/src/gui/dialogs/addon_connect.cpp Sat Apr 5 13:10:16 2008
@@ -30,20 +30,23 @@
namespace gui2 {
-static void hello()
-{
- std::cerr << "\n\n\nHello world.\n\n\n";
-}
-
-int addon_connect(CVideo& video, const std::string& server)
+void taddon_connect::show(CVideo& video)
{
gui2::init();
- gui2::twindow window = build(video, get_id(ADDON_CONNECT));
-// window.connect("connect", &hello);
+ twindow window = build(video, get_id(ADDON_CONNECT));
- return window.show(true);
+ tcontrol* host_widget =
dynamic_cast<tcontrol*>(window.get_widget_by_id("host_name"));
+ if(host_widget) {
+ host_widget->set_label(host_name_);
+ }
+
+ retval_ = window.show(true);
+
+ if(host_widget) {
+ host_name_= host_widget->label();
+ }
}
Modified: trunk/src/gui/dialogs/addon_connect.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/addon_connect.hpp?rev=25560&r1=25559&r2=25560&view=diff
==============================================================================
--- trunk/src/gui/dialogs/addon_connect.hpp (original)
+++ trunk/src/gui/dialogs/addon_connect.hpp Sat Apr 5 13:10:16 2008
@@ -21,6 +21,29 @@
namespace gui2 {
+class taddon_connect
+{
+public:
+ taddon_connect() :
+ retval_(0),
+ host_name_()
+ {}
+
+ void show(CVideo& video);
+
+ int get_retval() const { return retval_; }
+
+ const std::string& host_name() const { return host_name_; }
+
+ void set_host_name(const std::string& host_name)
+ { host_name_ = host_name; }
+
+private:
+ int retval_;
+ std::string host_name_;
+
+};
+
int addon_connect(CVideo& video, const std::string& server);
} // namespace gui2
Modified: trunk/src/gui/widgets/grid.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.cpp?rev=25560&r1=25559&r2=25560&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.cpp (original)
+++ trunk/src/gui/widgets/grid.cpp Sat Apr 5 13:10:16 2008
@@ -247,6 +247,31 @@
return 0;
}
+//! Gets a widget with the wanted id.
+//! Override base class.
+twidget* tgrid::get_widget_by_id(const std::string& id)
+{
+
+ //! FIXME we need to store the sizes, since this is quite
+ //! pathatic.
+ for(unsigned row = 0; row < rows_; ++row) {
+ for(unsigned col = 0; col < cols_; ++col) {
+
+ twidget* widget = child(row, col).widget();
+ if(!widget) {
+ continue;
+ }
+
+ widget = widget->get_widget_by_id(id);
+ if(widget) {
+ return widget;
+ }
+ }
+ }
+
+ return twidget::get_widget_by_id(id);
+}
+
tpoint tgrid::tchild::get_best_size()
{
if(!dirty_ && (!widget_ || !widget_->dirty())) {
Modified: trunk/src/gui/widgets/grid.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.hpp?rev=25560&r1=25559&r2=25560&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.hpp (original)
+++ trunk/src/gui/widgets/grid.hpp Sat Apr 5 13:10:16 2008
@@ -82,6 +82,10 @@
//! Gets the widget at the wanted coordinates.
//! Override base class.
twidget* get_widget(const tpoint& coordinate);
+
+ //! Gets a widget with the wanted id.
+ //! Override base class.
+ twidget* get_widget_by_id(const std::string& id);
private:
class tchild
Modified: trunk/src/gui/widgets/widget.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.hpp?rev=25560&r1=25559&r2=25560&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.hpp (original)
+++ trunk/src/gui/widgets/widget.hpp Sat Apr 5 13:10:16 2008
@@ -240,6 +240,10 @@
coordinate.y >= y_ && coordinate.y < (y_ + h_) ? this :
0;
}
+ //! Gets a widget with the wanted id.
+ twidget* get_widget_by_id(const std::string& id)
+ { return id_ == id ? this : 0; }
+
//! The toplevel item should always be a window if not null is returned
twindow* get_window();
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits