[Widelands-cvs] SF.net SVN: widelands: [2910] trunk
Status: Beta
Brought to you by:
sirver
From: <si...@us...> - 2008-02-15 06:49:34
|
Revision: 2910 http://widelands.svn.sourceforge.net/widelands/?rev=2910&view=rev Author: sigra Date: 2008-02-14 22:49:29 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Move 2 buttons from the game main menu to the centerbottom of the screen. Add a toolbar to Interactive_Base. Put all the centerbottom buttons inside the toolbar instead of placing them directly. This makes it much easier to move them around together, for example when the window is resized (see tracker item #1880121). In the Checkmate map, move some ducks from land to water and place some animals of the new types. Modified Paths: -------------- trunk/maps/Checkmate.wmf/binary/bob trunk/maps/Checkmate.wmf/binary/bob_data trunk/src/editor/editorinteractive.cc trunk/src/editor/editorinteractive.h trunk/src/events/event_unhide_area.cc trunk/src/game_main_menu.cc trunk/src/game_main_menu.h trunk/src/interactive_base.cc trunk/src/interactive_base.h trunk/src/interactive_player.cc trunk/src/interactive_player.h trunk/src/interactive_spectator.cc trunk/src/interactive_spectator.h trunk/src/ui/ui_basic/ui_box.cc trunk/src/widelands_map_event_chain_data_packet.cc trunk/src/worker.cc trunk/src/world.cc trunk/utils/spurious_source_code/Makefile trunk/utils/spurious_source_code/whitespace_checker.adb Modified: trunk/maps/Checkmate.wmf/binary/bob =================================================================== (Binary files differ) Modified: trunk/maps/Checkmate.wmf/binary/bob_data =================================================================== (Binary files differ) Modified: trunk/src/editor/editorinteractive.cc =================================================================== --- trunk/src/editor/editorinteractive.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/editor/editorinteractive.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -35,7 +35,6 @@ #include "overlay_manager.h" #include "player.h" #include "tribe.h" -#include "ui_button.h" #include "widelands_map_loader.h" #include "wlapplication.h" @@ -47,97 +46,72 @@ using Widelands::Building; Editor_Interactive::Editor_Interactive(Widelands::Editor_Game_Base & e) : -Interactive_Base(e), m_egbase(e) -{ +Interactive_Base(e), +m_need_save (false), +m_realtime (WLApplication::get()->get_time()), - // Disable debug. It is no use for editor. -#ifndef DEBUG - set_display_flag(Interactive_Base::dfDebug, false); -#else - set_display_flag(Interactive_Base::dfDebug, true); -#endif +#define INIT_BUTTON(picture, callback, tooltip) \ + TOOLBAR_BUTTON_COMMON_PARAMETERS, \ + g_gr->get_picture(PicMod_Game, "pics/" picture ".png"), \ + &Editor_Interactive::callback, this, \ + tooltip \ - m_realtime = WLApplication::get()->get_time(); +m_toggle_main_menu +(INIT_BUTTON + ("menu_toggle_menu", toggle_mainmenu, _("Menu"))), - fieldclicked.set(this, &Editor_Interactive::map_clicked); +m_toggle_tool_menu +(INIT_BUTTON + ("editor_menu_toggle_tool_menu", tool_menu_btn, _("Tool"))), - // user interface buttons - int32_t x = (get_w() - (7*34)) >> 1; - int32_t y = get_h() - 34; +m_toggle_toolsize_menu +(INIT_BUTTON + ("editor_menu_set_toolsize_menu", toolsize_menu_btn, _("Toolsize"))), - new UI::Button<Editor_Interactive> - (this, - x, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_menu.png"), - &Editor_Interactive::toggle_mainmenu, this, - _("Menu")); +m_toggle_minimap +(INIT_BUTTON + ("menu_toggle_minimap", toggle_minimap, _("Minimap"))), - new UI::Button<Editor_Interactive> - (this, - x + 34, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/editor_menu_toggle_tool_menu.png"), - &Editor_Interactive::tool_menu_btn, this, - _("Tool")); +m_toggle_buildhelp +(INIT_BUTTON + ("menu_toggle_buildhelp", toggle_buildhelp, _("Buildhelp"))), - new UI::Button<Editor_Interactive> - (this, - x + 68, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/editor_menu_set_toolsize_menu.png"), - &Editor_Interactive::toolsize_menu_btn, this, - _("Toolsize")); +m_toggle_player_menu +(INIT_BUTTON + ("editor_menu_player_menu", toggle_playermenu, _("Players"))), - new UI::Button<Editor_Interactive> - (this, - x + 102, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_minimap.png"), - &Editor_Interactive::toggle_minimap, this, - _("Minimap")); +m_toggle_event_menu +(INIT_BUTTON + ("menu_toggle_event_menu", toggle_eventmenu, _("Events"))), - new UI::Button<Editor_Interactive> - (this, - x + 136, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_buildhelp.png"), - &Editor_Interactive::toggle_buildhelp, this, - _("Buildhelp")); +m_toggle_variables_menu +(INIT_BUTTON + ("menu_toggle_variables_menu", toggle_variablesmenu, _("Variables"))), - new UI::Button<Editor_Interactive> - (this, - x + 170, y, 34, 43, - 2, - g_gr->get_picture(PicMod_Game, "pics/editor_menu_player_menu.png"), - &Editor_Interactive::toggle_playermenu, this, - _("Players")); +m_toggle_objectives_menu +(INIT_BUTTON + ("menu_toggle_objectives_menu", toggle_objectivesmenu, _("Objectives"))) +{ + m_toolbar.add(&m_toggle_main_menu, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_tool_menu, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_toolsize_menu, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_minimap, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_buildhelp, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_player_menu, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_event_menu, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_variables_menu, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_objectives_menu, UI::Box::AlignLeft); + m_toolbar.resize(); + adjust_toolbar_position(); - new UI::Button<Editor_Interactive> - (this, - x + 204, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_event_menu.png"), - &Editor_Interactive::toggle_eventmenu, this, - _("Events")); + // Disable debug. It is no use for editor. +#ifndef DEBUG + set_display_flag(Interactive_Base::dfDebug, false); +#else + set_display_flag(Interactive_Base::dfDebug, true); +#endif - new UI::Button<Editor_Interactive> - (this, - x + 238, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_variables_menu.png"), - &Editor_Interactive::toggle_variablesmenu, this, - _("Variables")); - - new UI::Button<Editor_Interactive> - (this, - x + 272, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_objectives_menu.png"), - &Editor_Interactive::toggle_objectivesmenu, this, - _("Objectives")); - - m_need_save = false; + fieldclicked.set(this, &Editor_Interactive::map_clicked); } /// Restore default sel. Modified: trunk/src/editor/editorinteractive.h =================================================================== --- trunk/src/editor/editorinteractive.h 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/editor/editorinteractive.h 2008-02-15 06:49:29 UTC (rev 2910) @@ -30,6 +30,8 @@ #include "editor_set_terrain_tool.h" #include "editor_set_starting_pos_tool.h" #include "interactive_base.h" + +#include "ui_button.h" #include "ui_unique_window.h" class Editor; @@ -49,9 +51,6 @@ ~Editor_Interactive(); public: - Widelands::Editor_Game_Base const & egbase() const {return m_egbase;} - Widelands::Editor_Game_Base & egbase() {return m_egbase;} - void load(std::string const & filename); // leaf functions from base class @@ -131,7 +130,6 @@ int32_t m_realtime; - Widelands::Editor_Game_Base & m_egbase; UI::UniqueWindow::Registry m_toolmenu; UI::UniqueWindow::Registry m_toolsizemenu; UI::UniqueWindow::Registry m_playermenu; @@ -145,6 +143,16 @@ UI::UniqueWindow::Registry m_immovablemenu; UI::UniqueWindow::Registry m_bobmenu; UI::UniqueWindow::Registry m_resourcesmenu; + + UI::Button<Editor_Interactive> m_toggle_main_menu; + UI::Button<Editor_Interactive> m_toggle_tool_menu; + UI::Button<Editor_Interactive> m_toggle_toolsize_menu; + UI::Button<Editor_Interactive> m_toggle_minimap; + UI::Button<Editor_Interactive> m_toggle_buildhelp; + UI::Button<Editor_Interactive> m_toggle_player_menu; + UI::Button<Editor_Interactive> m_toggle_event_menu; + UI::Button<Editor_Interactive> m_toggle_variables_menu; + UI::Button<Editor_Interactive> m_toggle_objectives_menu; }; #endif Modified: trunk/src/events/event_unhide_area.cc =================================================================== --- trunk/src/events/event_unhide_area.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/events/event_unhide_area.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -37,11 +37,11 @@ player.add_areawatcher(m_player_area).schedule_act(game, duration); else player.see_area - (Player_Area<Area<FCoords> > - (m_player_area.player_number, - Area<FCoords> - (game->map().get_fcoords(m_player_area), m_player_area.radius)), - false); + (Player_Area<Area<FCoords> > + (m_player_area.player_number, + Area<FCoords> + (game->map().get_fcoords(m_player_area), m_player_area.radius)), + false); } return m_state = DONE; Modified: trunk/src/game_main_menu.cc =================================================================== --- trunk/src/game_main_menu.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/game_main_menu.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -20,10 +20,8 @@ #include "game_main_menu.h" #include "building_statistics_menu.h" -#include "game_chat_menu.h" #include "game_main_menu_save_game.h" #include "game_main_menu_load_game.h" -#include "game_options_menu.h" #include "general_statistics_menu.h" #include "graphic.h" #include "i18n.h" @@ -39,13 +37,13 @@ UI::UniqueWindow::Registry & registry, Interactive_Player::Game_Main_Menu_Windows & windows) : -UI::UniqueWindow(&plr, ®istry, 180, 160, _("Main Menu")), +UI::UniqueWindow(&plr, ®istry, 180, 55, _("Main Menu")), m_player (plr), m_windows (windows), general_stats (this, - posx(0, 4), posy(0, 3), buttonw(4), buttonh(3), + posx(0, 4), posy(0, 3), buttonw(4), buttonh(1), 4, g_gr->get_picture(PicMod_Game, "pics/menu_general_stats.png"), &GameMainMenu::clicked_general_stats, this, @@ -53,7 +51,7 @@ ware_stats (this, - posx(1, 4), posy(0, 3), buttonw(4), buttonh(3), + posx(1, 4), posy(0, 3), buttonw(4), buttonh(1), 4, g_gr->get_picture(PicMod_Game, "pics/menu_ware_stats.png"), &GameMainMenu::clicked_ware_stats, this, @@ -61,7 +59,7 @@ building_stats (this, - posx(2, 4), posy(0, 3), buttonw(4), buttonh(3), + posx(2, 4), posy(0, 3), buttonw(4), buttonh(1), 4, g_gr->get_picture(PicMod_Game, "pics/menu_building_stats.png"), &GameMainMenu::clicked_building_stats, this, @@ -69,28 +67,11 @@ stock (this, - posx(3, 4), posy(0, 3), buttonw(4), buttonh(3), + posx(3, 4), posy(0, 3), buttonw(4), buttonh(1), 4, g_gr->get_picture(PicMod_Game, "pics/menu_stock.png"), &GameMainMenu::clicked_stock, this, - _("Stock")), - -chat -(this, - posx(1, 2), posy(1, 3), buttonw(2), buttonh(3), - 4, - g_gr->get_picture(PicMod_Game, "pics/menu_chat.png"), - &GameMainMenu::clicked_chat, this, - _("Chat")), - -options_menu -(this, - posx(0, 1), posy(2, 3), buttonw(1), buttonh(3), - 4, - g_gr->get_picture(PicMod_Game, "pics/menu_options_menu.png"), - &GameMainMenu::clicked_options_menu, this, - _("Options")) - + _("Stock")) {if (get_usedefaultpos()) center_to_parent();} @@ -118,16 +99,3 @@ else new Stock_Menu(m_player, m_windows.stock); } -void GameMainMenu::clicked_chat() { - if (m_windows.chat.window) - delete m_windows.chat.window; - else - new GameChatMenu - (m_player, m_windows.chat, m_player.game().get_netgame()); -} -void GameMainMenu::clicked_options_menu() { - if (m_windows.options.window) - delete m_windows.options.window; - else - new GameOptionsMenu(m_player, m_windows.options, m_windows); -} Modified: trunk/src/game_main_menu.h =================================================================== --- trunk/src/game_main_menu.h 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/game_main_menu.h 2008-02-15 06:49:29 UTC (rev 2910) @@ -38,8 +38,6 @@ UI::Button<GameMainMenu> ware_stats; UI::Button<GameMainMenu> building_stats; UI::Button<GameMainMenu> stock; - UI::Button<GameMainMenu> chat; - UI::Button<GameMainMenu> options_menu; /** Returns the horizontal/vertical spacing between buttons. */ uint32_t hspacing() const {return 5;}; @@ -75,8 +73,6 @@ void clicked_ware_stats (); void clicked_building_stats(); void clicked_stock (); - void clicked_chat (); - void clicked_options_menu (); }; #endif Modified: trunk/src/interactive_base.cc =================================================================== --- trunk/src/interactive_base.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/interactive_base.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -67,6 +67,7 @@ m_buildroad (false), m_road_build_player (0), m_flag_to_connect (Coords::Null()), +m_toolbar (this, 0, 0, UI::Box::Horizontal), m_shift_down (false), m_ctrl_down (false) { Modified: trunk/src/interactive_base.h =================================================================== --- trunk/src/interactive_base.h 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/interactive_base.h 2008-02-15 06:49:29 UTC (rev 2910) @@ -25,7 +25,7 @@ #include "mapview.h" #include "overlay_manager.h" -#include "ui_panel.h" +#include "ui_box.h" #include "ui_unique_window.h" #include <SDL_keysym.h> @@ -161,10 +161,16 @@ void unset_sel_picture(); void set_sel_picture(const char * const); + void adjust_toolbar_position() { + m_toolbar.set_pos + (Point((get_inner_w() - m_toolbar.get_w()) >> 1, get_inner_h() - 34)); + } + UI::Box m_toolbar; Widelands::Coords m_flag_to_connect; bool m_shift_down; bool m_ctrl_down; }; +#define TOOLBAR_BUTTON_COMMON_PARAMETERS &m_toolbar, 0, 0, 34U, 34U, 2U #endif Modified: trunk/src/interactive_player.cc =================================================================== --- trunk/src/interactive_player.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/interactive_player.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -28,7 +28,9 @@ #include "font_handler.h" #include "game_loader.h" #include "game_main_menu.h" +#include "game_chat_menu.h" #include "game_objectives_menu.h" +#include "game_options_menu.h" #include "graphic.h" #include "general_statistics_menu.h" #include "helper.h" @@ -82,66 +84,54 @@ m_type_message (this, 10, get_inner_h()-50, get_inner_w(), 50, "", Align_TopLeft), +#define INIT_BUTTON(picture, callback, tooltip) \ + TOOLBAR_BUTTON_COMMON_PARAMETERS, \ + g_gr->get_picture(PicMod_Game, "pics/" picture ".png"), \ + &Interactive_Player::callback, this, \ + tooltip \ -#define BUTTON_WIDTH 34 -#define BUTTON_HEIGHT 34 +m_toggle_chat +(INIT_BUTTON("menu_chat", toggle_chat, _("Chat"))), +m_toggle_options_menu +(INIT_BUTTON("menu_options_menu", toggle_options_menu, _("Options"))), + m_toggle_main_menu -(this, - get_w() - 5 * BUTTON_WIDTH >> 1, get_h() - BUTTON_HEIGHT, - BUTTON_WIDTH, BUTTON_HEIGHT, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_menu.png"), - &Interactive_Player::toggle_main_menu, this, - _("Menu")), +(INIT_BUTTON("menu_toggle_menu", toggle_main_menu, _("Menu"))), m_toggle_objectives -(this, - m_toggle_main_menu.get_x() + BUTTON_WIDTH, m_toggle_main_menu.get_y(), - BUTTON_WIDTH, BUTTON_HEIGHT, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_objectives.png"), - &Interactive_Player::toggle_objectives, this, - _("Objectives")), +(INIT_BUTTON("menu_objectives", toggle_objectives, _("Objectives"))), m_toggle_minimap -(this, - m_toggle_objectives.get_x() + BUTTON_WIDTH, m_toggle_objectives.get_y(), - BUTTON_WIDTH, BUTTON_HEIGHT, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_minimap.png"), - &Interactive_Player::toggle_minimap, this, - _("Minimap")), +(INIT_BUTTON("menu_toggle_minimap", toggle_minimap, _("Minimap"))), m_toggle_buildhelp -(this, - m_toggle_minimap.get_x() + BUTTON_WIDTH, m_toggle_minimap.get_y(), - BUTTON_WIDTH, BUTTON_HEIGHT, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_buildhelp.png"), - &Interactive_Player::toggle_buildhelp, this, - _("Buildhelp")), +(INIT_BUTTON("menu_toggle_buildhelp", toggle_buildhelp, _("Buildhelp"))), +#if 0 m_toggle_resources -(this, - m_toggle_buildhelp.get_x() + BUTTON_WIDTH, m_toggle_buildhelp.get_y(), - BUTTON_WIDTH, BUTTON_HEIGHT, - 2, - g_gr->get_picture(PicMod_Game, "pics/editor_menu_tool_change_resources.png"), - &Interactive_Player::toggle_resources, this, - _("Geologic survey information")), +(INIT_BUTTON + ("editor_menu_tool_change_resources", + toggle_resources, + _("Resource information"))), +#endif m_toggle_help -(this, - m_toggle_resources.get_x()/* + BUTTON_WIDTH "hide the geologic survey button until it does something"*/, m_toggle_resources.get_y(), - BUTTON_WIDTH, BUTTON_HEIGHT, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_help.png"), - &Interactive_Player::toggle_help, this, - _("Tribe's ware encyclopedia")), +(INIT_BUTTON("menu_help", toggle_help, _("Ware help"))), m_do_chat_overlays(true), m_is_typing_msg(false) { + m_toolbar.add(&m_toggle_chat, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_options_menu, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_main_menu, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_objectives, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_minimap, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_buildhelp, UI::Box::AlignLeft); + //m_toolbar.add(&m_toggle_resources, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_help, UI::Box::AlignLeft); + m_toolbar.resize(); + adjust_toolbar_position(); + set_player_number(plyn); fieldclicked.set(this, &Interactive_Player::field_action); } @@ -246,43 +236,37 @@ } -/* -=============== -Interactive_Player::main_menu_btn - -Bring up or close the main menu -=============== -*/ -void Interactive_Player::toggle_main_menu() { +// Toolbar button callback functions. +void Interactive_Player::toggle_chat () { + if (m_chat.window) + delete m_chat.window; + else + new GameChatMenu(*this, m_chat, game().get_netgame()); +} +void Interactive_Player::toggle_options_menu() { + if (m_options.window) + delete m_options.window; + else + new GameOptionsMenu(*this, m_options, m_mainm_windows); +} +void Interactive_Player::toggle_main_menu () { if (m_mainmenu.window) delete m_mainmenu.window; else new GameMainMenu(*this, m_mainmenu, m_mainm_windows); } - -void Interactive_Player::toggle_objectives() { +void Interactive_Player::toggle_objectives () { if (m_objectives.window) delete m_objectives.window; else new GameObjectivesMenu(*this, m_objectives); } - -// -// Toggles buildhelp rendering in the main MapView -// -void Interactive_Player::toggle_buildhelp() -{ +void Interactive_Player::toggle_buildhelp () { egbase().map().overlay_manager().toggle_buildhelp(); } - - -void Interactive_Player::toggle_resources() {} - - -// -// Shows wares encyclopedia for wares -// -void Interactive_Player::toggle_help() { +void Interactive_Player::toggle_resources () { +} +void Interactive_Player::toggle_help () { if (m_encyclopedia.window) delete m_encyclopedia.window; else Modified: trunk/src/interactive_player.h =================================================================== --- trunk/src/interactive_player.h 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/interactive_player.h 2008-02-15 06:49:29 UTC (rev 2910) @@ -51,16 +51,12 @@ UI::UniqueWindow::Registry keys; UI::UniqueWindow::Registry authors; UI::UniqueWindow::Registry licence; - UI::UniqueWindow::Registry options; UI::UniqueWindow::Registry sound_options; UI::UniqueWindow::Registry building_stats; UI::UniqueWindow::Registry general_stats; UI::UniqueWindow::Registry ware_stats; UI::UniqueWindow::Registry stock; - - UI::UniqueWindow::Registry chat; - UI::UniqueWindow::Registry objectives; }; Interactive_Player(Widelands::Game &, Widelands::Player_Number); @@ -71,6 +67,8 @@ void start(); void toggle_main_menu (); + void toggle_chat (); + void toggle_options_menu(); void toggle_objectives(); void toggle_buildhelp (); void toggle_resources (); @@ -116,13 +114,18 @@ UI::Textarea m_label_speed; UI::Multiline_Textarea m_chat_messages; UI::Textarea m_type_message; + UI::Button<Interactive_Player> m_toggle_chat; + UI::Button<Interactive_Player> m_toggle_options_menu; UI::Button<Interactive_Player> m_toggle_main_menu; UI::Button<Interactive_Player> m_toggle_objectives; UI::Button<Interactive_Player> m_toggle_minimap; UI::Button<Interactive_Player> m_toggle_buildhelp; - UI::Button<Interactive_Player> m_toggle_resources; + //UI::Button<Interactive_Player> m_toggle_resources; UI::Button<Interactive_Player> m_toggle_help; + + UI::UniqueWindow::Registry m_chat; + UI::UniqueWindow::Registry m_options; UI::UniqueWindow::Registry m_mainmenu; UI::UniqueWindow::Registry m_objectives; UI::UniqueWindow::Registry m_fieldaction; Modified: trunk/src/interactive_spectator.cc =================================================================== --- trunk/src/interactive_spectator.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/interactive_spectator.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -24,7 +24,6 @@ #include "i18n.h" #include "ui_editbox.h" -#include "ui_button.h" #include "ui_multilinetextarea.h" #include "ui_textarea.h" #include "ui_unique_window.h" @@ -40,31 +39,29 @@ Interactive_Spectator::Interactive_Spectator(Widelands::Game * const g) : Interactive_Base(*g), + +#define INIT_BUTTON(picture, callback, tooltip) \ + TOOLBAR_BUTTON_COMMON_PARAMETERS, \ + g_gr->get_picture(PicMod_Game, "pics/" picture ".png"), \ + &Interactive_Spectator::callback, this, \ + tooltip \ + +m_exit +(INIT_BUTTON("menu_exit_game", exit_btn, _("Menu"))), + +m_toggle_minimap +(INIT_BUTTON("menu_toggle_minimap", toggle_minimap, _("Minimap"))), + m(new Internals) { + m_toolbar.add(&m_exit, UI::Box::AlignLeft); + m_toolbar.add(&m_toggle_minimap, UI::Box::AlignLeft); + m_toolbar.resize(); + adjust_toolbar_position(); + // Setup all screen elements fieldclicked.set(this, &Interactive_Spectator::field_action); - // user interface buttons - int32_t x = (get_w() - (4*34)) >> 1; - int32_t y = get_h() - 34; - - new UI::Button<Interactive_Spectator> - (this, - x + 34, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_exit_game.png"), - &Interactive_Spectator::exit_btn, this, - _("Menu")); - - new UI::Button<Interactive_Spectator> - (this, - x + 68, y, 34, 34, - 2, - g_gr->get_picture(PicMod_Game, "pics/menu_toggle_minimap.png"), - &Interactive_Spectator::toggle_minimap, this, - _("Minimap")); - // Speed info m->label_speed = new UI::Textarea(this, get_w(), 0, 0, 0, "", Align_TopRight); } Modified: trunk/src/interactive_spectator.h =================================================================== --- trunk/src/interactive_spectator.h 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/interactive_spectator.h 2008-02-15 06:49:29 UTC (rev 2910) @@ -20,6 +20,8 @@ #ifndef INTERACTIVE_SPECTATOR_H #define INTERACTIVE_SPECTATOR_H +#include "ui_button.h" + #include "interactive_base.h" #include <SDL_keyboard.h> @@ -51,6 +53,9 @@ void field_action(); private: + UI::Button<Interactive_Spectator> m_exit; + UI::Button<Interactive_Spectator> m_toggle_minimap; + class Internals; Internals* m; Modified: trunk/src/ui/ui_basic/ui_box.cc =================================================================== --- trunk/src/ui/ui_basic/ui_box.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/ui/ui_basic/ui_box.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -26,10 +26,8 @@ Initialize an empty box */ Box::Box(Panel* parent, int32_t x, int32_t y, uint32_t orientation) - : Panel(parent, x, y, 0, 0) -{ - m_orientation = orientation; -} + : Panel(parent, x, y, 0, 0), m_orientation(orientation) +{} /** Modified: trunk/src/widelands_map_event_chain_data_packet.cc =================================================================== --- trunk/src/widelands_map_event_chain_data_packet.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/widelands_map_event_chain_data_packet.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -155,9 +155,9 @@ event_chain.m_state = EventChain::DONE; else throw wexception - ("state is \"%s\" but must be one of {init (default), " - "running, done}", - state); + ("state is \"%s\" but must be one of {init (default), " + "running, done}", + state); } } catch (std::exception const & e) { throw wexception("%s: %s", name, e.what()); Modified: trunk/src/worker.cc =================================================================== --- trunk/src/worker.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/worker.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -286,7 +286,8 @@ if (action->sparam1 == "immovable") { std::vector<ImmovableFound> list; if (action->iparam2 < 0) - map.find_reachable_immovables(area, &list, cstep); + map.find_reachable_immovables + (area, &list, cstep); else map.find_reachable_immovables (area, &list, cstep, FindImmovableAttribute(action->iparam2)); @@ -304,7 +305,8 @@ std::vector<Bob*> list; log("BOB: searching bob with attribute (%i)\n", action->iparam2); if (action->iparam2 < 0) - map.find_reachable_bobs(area, &list, cstep); + map.find_reachable_bobs + (area, &list, cstep); else map.find_reachable_bobs (area, &list, cstep, FindBobAttribute(action->iparam2)); Modified: trunk/src/world.cc =================================================================== --- trunk/src/world.cc 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/src/world.cc 2008-02-15 06:49:29 UTC (rev 2910) @@ -469,8 +469,8 @@ snprintf(fnametmpl, sizeof(fnametmpl), "%s/%s", directory, texture); else snprintf - (fnametmpl, sizeof(fnametmpl), - "%s/pics/%s_??.png", directory, m_name.c_str()); + (fnametmpl, sizeof(fnametmpl), + "%s/pics/%s_??.png", directory, m_name.c_str()); m_picnametempl = strdup(fnametmpl); } Modified: trunk/utils/spurious_source_code/Makefile =================================================================== --- trunk/utils/spurious_source_code/Makefile 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/utils/spurious_source_code/Makefile 2008-02-15 06:49:29 UTC (rev 2910) @@ -1,4 +1,4 @@ -leading_whitespace_checker: whitespace_checker.adb +whitespace_checker: whitespace_checker.adb gnatmake -gnatafnN -gnatwa -gnaty whitespace_checker clean: Modified: trunk/utils/spurious_source_code/whitespace_checker.adb =================================================================== --- trunk/utils/spurious_source_code/whitespace_checker.adb 2008-02-13 09:44:27 UTC (rev 2909) +++ trunk/utils/spurious_source_code/whitespace_checker.adb 2008-02-15 06:49:29 UTC (rev 2910) @@ -1,16 +1,16 @@ -- Detecs errors in leading whitespace and a few other things in C++ source -- code. -- --- It checks the beginning of each line, the so called line begin, which --- consists of 3 parts: +-- Checks the beginning of each line, the so called line begin, which consists +-- of 3 parts: -- 1. Indentation: -- A sequence of horizontal tab characters. Their count is called the -- indentation depth of that line. Some validation is done for the -- indentation depth of lines, for example a line with a closing brace -- must have the same indentation depth as the line with the matching -- opening brace. --- 2. Padding: --- A sequence of space characters. Their count is called the padding +-- 2. Alignment: +-- A sequence of space characters. Their count is called the alignment -- depth of that line. It must equal the depth of open parentheses from -- preceding lines. -- 3. Opening parentheses: @@ -19,12 +19,12 @@ -- The line begin is read in 3 stages. First characters are read until one is -- found, that is not a horizontal tab. After this stage the indentation depth -- of the line is known. Then characters are read until one is found, that is --- not a space. After this stage the padding depth of the line is known. Then --- characters are reade until one is found that is not a '(' or '['. After --- this stage the whole line begin has been read some errors are reported, --- such as wrong amount of padding. If a '#' is found (a preprocessor macro), --- the macro is read and ignored. Otherwise the rest of the line is read by --- Read_Code. +-- not a space. After this stage the alignment depth of the line is known. +-- Then characters are reade until one is found that is not a '(' or '['. +-- After this stage the whole line begin has been read some errors are +-- reported, such as wrong amount of alignment. If a '#' is found (a +-- preprocessor macro), the macro is read and ignored. Otherwise the rest of +-- the line is read by Read_Code. -- -- Read_Code reads everything that comes after the line begin, until the end -- of the line. Any opening parenthesis that it finds must be closed on that @@ -68,6 +68,7 @@ Indentation : Indentation_Level; Parentheses : Parentheses_Level; end record; + for Opening_Brace'Size use 32; type Brace_Index is range 0 .. 63; Opening_Braces : array (Brace_Index) of Opening_Brace; Brace_Level : Brace_Index := 0; @@ -316,7 +317,7 @@ Allowed_Indentation_Increase : Indentation_Level := 0; Previous_Depth_Indentation : Indentation_Level := 0; - Depth_Padding : Parentheses_Level := 0; + Depth_Alignment : Parentheses_Level := 0; begin Open (The_File, In_File, Argument (1)); while not End_Of_File (The_File) loop @@ -329,7 +330,7 @@ Next_Character; end loop; while Current_Character = ' ' loop - Depth_Padding := Depth_Padding + 1; + Depth_Alignment := Depth_Alignment + 1; Next_Character; end loop; while Current_Character = '(' or Current_Character = '[' loop @@ -347,11 +348,11 @@ end if; Next_Line; Depth_Indentation := 0; - Depth_Padding := 0; + Depth_Alignment := 0; when '#' => Read_Macro; Depth_Indentation := 0; - Depth_Padding := 0; + Depth_Alignment := 0; when others => -- Put_Line -- ("DEBUG: line number =" & Line_Number 'Img & @@ -374,9 +375,9 @@ Put_Error ("indentation is too deep"); end if; - if Depth_Padding /= Depth_Parentheses then + if Depth_Alignment /= Depth_Parentheses then Put_Error - ("wrong amount of leading padding:" & Depth_Padding'Img & + ("wrong amount of leading padding:" & Depth_Alignment'Img & " (should be" & Depth_Parentheses'Img & ')'); end if; Depth_Parentheses := @@ -396,7 +397,7 @@ "at line begin"); end if; if - (0 < Parentheses_At_Line_Begin or 0 < Depth_Padding) + (0 < Parentheses_At_Line_Begin or 0 < Depth_Alignment) and Initial_Brace_Level < Brace_Level then @@ -415,7 +416,7 @@ end; Previous_Depth_Indentation := Depth_Indentation; Depth_Indentation := 0; - Depth_Padding := 0; + Depth_Alignment := 0; case Previous_Character is when ',' | ';' | '}' => This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |