mp_method_selection.cpp

Go to the documentation of this file.
00001 /* $Id: mp_method_selection.cpp 26800 2008-05-23 18:25:20Z mordante $ */
00002 /*
00003    copyright (c) 2008 by mark de wever <koraq@xs4all.nl>
00004    part of the battle for wesnoth project http://www.wesnoth.org/
00005 
00006    this program is free software; you can redistribute it and/or modify
00007    it under the terms of the gnu general public license version 2
00008    or at your option any later version.
00009    this program is distributed in the hope that it will be useful,
00010    but without any warranty.
00011 
00012    see the copying file for more details.
00013 */
00014 
00015 #include "gui/dialogs/mp_method_selection.hpp"
00016 
00017 #include "game_preferences.hpp"
00018 #include "gui/widgets/button.hpp"
00019 #include "gui/widgets/listbox.hpp"
00020 #include "gui/widgets/toggle_button.hpp"
00021 #include "gui/widgets/widget.hpp"
00022 #include "gui/widgets/window.hpp"
00023 #include "gui/widgets/window_builder.hpp"
00024 #include "gui/widgets/settings.hpp"
00025 #include "gui/widgets/text_box.hpp"
00026 #include "log.hpp"
00027 #include "video.hpp"
00028 #include "wml_exception.hpp"
00029 
00030 #define DBG_GUI LOG_STREAM_INDENT(debug, widget)
00031 #define LOG_GUI LOG_STREAM_INDENT(info, widget)
00032 #define WRN_GUI LOG_STREAM_INDENT(warn, widget)
00033 #define ERR_GUI LOG_STREAM_INDENT(err, widget)
00034 
00035 namespace gui2 {
00036 
00037 void tmp_method_selection::show(CVideo& video)
00038 {
00039 
00040     gui2::init();
00041 
00042     twindow window = build(video, get_id(MP_METHOD_SELECTION));
00043 
00044     user_name_ = preferences::login();
00045     ttext_box* user_widget = dynamic_cast<ttext_box*>(window.find_widget("user_name", false));
00046     if(user_widget) {
00047         user_widget->set_text(user_name_);
00048         window.keyboard_capture(user_widget);
00049     }
00050 
00051     tlistbox* list = dynamic_cast<tlistbox*>(window.find_widget("method_list", false));
00052     VALIDATE(list, "No list defined.");
00053 
00054     list->add_item("Join Official Server");
00055     list->add_item("Connect to Server");
00056     list->add_item("Local Game");
00057     list->select_row(0);
00058 
00059     window.recalculate_size();
00060 
00061     retval_ = window.show(true);
00062 
00063     if(retval_ == tbutton::OK) {
00064 
00065         choice_ = list->get_selected_row();
00066         user_widget->save_to_history();
00067         user_name_= user_widget->get_text();
00068         preferences::set_login(user_name_);
00069     }
00070 }
00071 
00072 } // namespace gui2

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs