[Widelands-cvs] SF.net SVN: widelands: [3181] trunk/src
Status: Beta
Brought to you by:
sirver
From: <si...@us...> - 2008-04-18 11:56:40
|
Revision: 3181 http://widelands.svn.sourceforge.net/widelands/?rev=3181&view=rev Author: sigra Date: 2008-04-18 04:56:37 -0700 (Fri, 18 Apr 2008) Log Message: ----------- Attempt to get rid of the format string warnings on 64bit systems the quick and easy way (we could still do fancy stuff later if we want): * Work around missing "%ti" (ptrdiff_t) by changing to "%li" and adding a static_cast<long int>. 1 occurence (in exception). * Work around missing "%zu" (size_t) by changing to "%lu" and adding a static_cast<long unsigned int>. 25 occurences (11 in exception, 2 in log, 12 in molog). See bug #1879249. Get rid of do_nothing. Clean up UI::Checkbox. Change a bunch of posx, posy to pos. Modified Paths: -------------- trunk/src/bob.cc trunk/src/building.cc trunk/src/computer_player.cc trunk/src/constructionsite.cc trunk/src/editor/ui_menus/editor_event_menu_edit_eventchain.cc trunk/src/editor/ui_menus/editor_objectives_menu.cc trunk/src/editor/ui_menus/editor_tool_change_resources_options_menu.cc trunk/src/editor/ui_menus/editor_tool_menu.cc trunk/src/editor/ui_menus/editor_tool_place_bob_options_menu.cc trunk/src/editor/ui_menus/editor_tool_place_bob_options_menu.h trunk/src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc trunk/src/editor/ui_menus/editor_tool_place_immovable_options_menu.h trunk/src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc trunk/src/editor/ui_menus/event_allow_building_option_menu.cc trunk/src/editor/ui_menus/event_message_box_option_menu.cc trunk/src/events/event_road.cc trunk/src/fieldaction.cc trunk/src/filesystem/disk_filesystem.cc trunk/src/game_options_sound_menu.cc trunk/src/general_statistics_menu.cc trunk/src/graphic.cc trunk/src/playerdescrgroup.cc trunk/src/streamread.cc trunk/src/ui/ui_basic/ui_checkbox.cc trunk/src/ui/ui_basic/ui_checkbox.h trunk/src/ui/ui_basic/ui_radiobutton.cc trunk/src/ui/ui_basic/ui_radiobutton.h trunk/src/ui/ui_fs_menus/fullscreen_menu_mapselect.cc trunk/src/ui/ui_fs_menus/fullscreen_menu_options.cc trunk/src/ware_statistics_menu.cc trunk/src/widelands_map_players_areawatchers_data_packet.cc trunk/src/widelands_map_players_view_data_packet.cc trunk/src/worker.cc trunk/src/wui_plot_area.cc Modified: trunk/src/bob.cc =================================================================== --- trunk/src/bob.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/bob.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -1086,10 +1086,13 @@ molog("Signal: %s\n", m_signal.c_str()); - molog("Stack size: %i\n", m_stack.size()); + molog("Stack size: %lu\n", static_cast<long unsigned int>(m_stack.size())); - for (uint32_t i = 0; i < m_stack.size(); ++i) { - molog("Stack dump %i/%i\n", i+1, m_stack.size()); + for (size_t i = 0; i < m_stack.size(); ++i) { + molog + ("Stack dump %lu/%lu\n", + static_cast<long unsigned int>(i + 1), + static_cast<long unsigned int>(m_stack.size())); molog("* task->name: %s\n", m_stack[i].task->name); @@ -1106,11 +1109,16 @@ if (m_stack[i].path) { const Path & path = *m_stack[i].path; Path::Step_Vector::size_type nr_steps = path.get_nsteps(); - molog("** Path length: %i\n", nr_steps); + molog + ("** Path length: %lu\n", + static_cast<long unsigned int>(nr_steps)); molog("** Start: (%i, %i)\n", path.get_start().x, path.get_start().y); molog("** End: (%i, %i)\n", path.get_end().x, path.get_end().y); for (Path::Step_Vector::size_type j = 0; j < nr_steps; ++j) - molog("** Step %i/%i: %i\n", j + 1, nr_steps, path[j]); + molog + ("** Step %lu/%lu: %i\n", + static_cast<long unsigned int>(j + 1), + static_cast<long unsigned int>(nr_steps), path[j]); } molog("* transfer: %p\n", m_stack[i].transfer); molog("* route: %p\n", m_stack[i].route); Modified: trunk/src/building.cc =================================================================== --- trunk/src/building.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/building.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -877,7 +877,9 @@ molog("m_leave_time: %i\n", m_leave_time); molog("m_stop: %i\n", m_stop); - molog("m_leave_queue.size(): %i\n", m_leave_queue.size()); + molog + ("m_leave_queue.size(): %lu\n", + static_cast<long unsigned int>(m_leave_queue.size())); molog("m_leave_allow.get(): %p\n", m_leave_allow.get(egbase)); } Modified: trunk/src/computer_player.cc =================================================================== --- trunk/src/computer_player.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/computer_player.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -1317,7 +1317,9 @@ } log - ("Computer_Player(%u): %u spots for road building (%f seconds) \n", player_number, spots.size(), static_cast<double>(clock() - time_before) / CLOCKS_PER_SEC); + ("Computer_Player(%u): %lu spots for road building (%f seconds) \n", + player_number, static_cast<long unsigned int>(spots.size()), + static_cast<double>(clock() - time_before) / CLOCKS_PER_SEC); while (!queue.empty()) { WalkableSpot & from = spots[queue.front()]; @@ -1364,9 +1366,8 @@ game().send_player_build_flag (player_number, pc.front()); log - ("Computer_Player(%u): New road has length %u\n", - player_number, - pc.size()); + ("Computer_Player(%u): New road has length %lu\n", + player_number, static_cast<long unsigned int>(pc.size())); Path & path = *new Path(pc.front()); pc.pop_front(); Modified: trunk/src/constructionsite.cc =================================================================== --- trunk/src/constructionsite.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/constructionsite.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -41,7 +41,7 @@ namespace Widelands { -static const int32_t CONSTRUCTIONSITE_STEP_TIME = 30000; +#define CONSTRUCTIONSITE_STEP_TIME 30000 /* @@ -144,11 +144,16 @@ molog("m_work_completed: %i\n", m_work_completed); molog("m_work_steps: %i\n", m_work_steps); - molog("WaresQueue size: %i\n", m_wares.size()); + molog + ("WaresQueue size: %lu\n", + static_cast<long unsigned int>(m_wares.size())); const std::vector<WaresQueue *>::size_type nr_wares = m_wares.size(); for (std::vector<WaresQueue *>::size_type i = 0; i < nr_wares; ++i) { - molog("Dumping WaresQueue %i/%i\n", i + 1, m_wares.size()); molog + ("Dumping WaresQueue %lu/%lu\n", + static_cast<long unsigned int>(i + 1), + static_cast<long unsigned int>(m_wares.size())); + molog ("* Owner: %i (player nr)\n", m_wares[i]->get_owner()->get_player_number()); molog("* Ware: %u (index)\n", m_wares[i]->get_ware().value()); Modified: trunk/src/editor/ui_menus/editor_event_menu_edit_eventchain.cc =================================================================== --- trunk/src/editor/ui_menus/editor_event_menu_edit_eventchain.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_event_menu_edit_eventchain.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -48,81 +48,80 @@ UI::Window (&parent, 0, 0, 505, 340, _("Edit Event Chain")), m_event_chain(chain) { - int32_t const offsx = 5; - int32_t const offsy = 25; int32_t const spacing = 5; - int32_t posx = offsx; - int32_t posy = offsy; int32_t const ls_width = 200; + Point pos (5, 25); - new UI::Textarea(this, posx, posy, 60, 20, _("Name: "), Align_CenterLeft); - m_name = new UI::EditBox(this, posx + 60, posy, get_inner_w()-2*spacing-60, 20, 0, 0); + new UI::Textarea(this, pos.x, pos.y, 60, 20, _("Name: "), Align_CenterLeft); + m_name = + new UI::EditBox + (this, pos.x + 60, pos.y, get_inner_w() - 2 * spacing - 60, 20, 0, 0); m_name->setText(m_event_chain.name()); - posy += 20 + spacing; + pos.y += 20 + spacing; new UI::Textarea (this, - posx + STATEBOX_WIDTH + spacing, posy, 120, STATEBOX_HEIGHT, + pos.x + STATEBOX_WIDTH + spacing, pos.y, 120, STATEBOX_HEIGHT, _("Runs multiple times"), Align_CenterLeft); - m_morethanonce = new UI::Checkbox(this, posx, posy); + m_morethanonce = new UI::Checkbox(this, pos); m_morethanonce->set_state(m_event_chain.get_repeating()); - posy += STATEBOX_HEIGHT + spacing; - int32_t const lsoffsy = posy; + pos.y += STATEBOX_HEIGHT + spacing; + int32_t const lsoffsy = pos.y; - new UI::Textarea(this, posx, lsoffsy, _("Events: "), Align_Left); + new UI::Textarea(this, pos.x, lsoffsy, _("Events: "), Align_Left); m_events = new UI::Listselect<Widelands::Event &> - (this, spacing, lsoffsy + 20, ls_width, get_inner_h() - lsoffsy - 55); + (this, spacing, lsoffsy + 20, ls_width, get_inner_h() - lsoffsy - 55); m_events->selected.set(this, &Editor_Event_Menu_Edit_EventChain::cs_selected); m_events->double_clicked.set(this, &Editor_Event_Menu_Edit_EventChain::cs_double_clicked); - posx += ls_width + spacing; + pos.x += ls_width + spacing; - posy = 75; + pos.y = 75; new UI::Button<Editor_Event_Menu_Edit_EventChain> (this, - posx, posy, 80, 20, + pos.x, pos.y, 80, 20, 0, &Editor_Event_Menu_Edit_EventChain::clicked_edit_trigger_contitional, this, _("Conditional")); - posy += 20 + spacing + spacing; + pos.y += 20 + spacing + spacing; new UI::Button<Editor_Event_Menu_Edit_EventChain> (this, - posx, posy, 80, 20, + pos.x, pos.y, 80, 20, 0, &Editor_Event_Menu_Edit_EventChain::clicked_new_event, this, _("New Event")); - posy += 20 + spacing + spacing; + pos.y += 20 + spacing + spacing; m_insert_btn = new UI::Button<Editor_Event_Menu_Edit_EventChain> (this, - posx, posy, 80, 20, + pos.x, pos.y, 80, 20, 0, &Editor_Event_Menu_Edit_EventChain::clicked_ins_event, this, "<-", _("Insert"), false); - posy += 20 + spacing + spacing; + pos.y += 20 + spacing + spacing; m_delete_btn = new UI::Button<Editor_Event_Menu_Edit_EventChain> (this, - posx, posy, 80, 20, + pos.x, pos.y, 80, 20, 0, &Editor_Event_Menu_Edit_EventChain::clicked_del_event, this, _("Delete"), std::string(), false); - posy += 20 + spacing + spacing + spacing; + pos.y += 20 + spacing + spacing + spacing; m_mvup_btn = new UI::Button<Editor_Event_Menu_Edit_EventChain> (this, - posx + 5, posy, 24, 24, + pos.x + 5, pos.y, 24, 24, 0, g_gr->get_picture(PicMod_UI, "pics/scrollbar_up.png"), &Editor_Event_Menu_Edit_EventChain::clicked_move_up, this, @@ -131,18 +130,19 @@ m_mvdown_btn = new UI::Button<Editor_Event_Menu_Edit_EventChain> (this, - posx + 51, posy, 24, 24, + pos.x + 51, pos.y, 24, 24, 0, g_gr->get_picture(PicMod_UI, "pics/scrollbar_down.png"), &Editor_Event_Menu_Edit_EventChain::clicked_move_down, this, std::string(), false); - posy += 24 + spacing + spacing; - - posx += 80 + spacing; - new UI::Textarea(this, posx, lsoffsy, _("Available Events: "), Align_Left); - m_available_events=new UI::Listselect<Widelands::Event &>(this, posx, lsoffsy+20, ls_width, get_inner_h()-lsoffsy-55); + pos += Point(80 + spacing, 24 + spacing + spacing); + new UI::Textarea + (this, pos.x, lsoffsy, _("Available Events: "), Align_Left); + m_available_events = + new UI::Listselect<Widelands::Event &> + (this, pos.x, lsoffsy + 20, ls_width, get_inner_h() - lsoffsy - 55); m_available_events->selected.set (this, &Editor_Event_Menu_Edit_EventChain::tl_selected); m_available_events->double_clicked.set @@ -155,21 +155,20 @@ } m_available_events->sort(); - posy = get_inner_h() - 30; - posx = get_inner_w() / 2 - 80 - spacing; + pos = Point(get_inner_h() - 30, get_inner_w() / 2 - 80 - spacing); new UI::Button<Editor_Event_Menu_Edit_EventChain> (this, - posx, posy, 80, 20, + pos.x, pos.y, 80, 20, 0, &Editor_Event_Menu_Edit_EventChain::clicked_ok, this, _("Ok")); - posx=(get_inner_w()/2)+spacing; + pos.x = get_inner_w() / 2 + spacing; new UI::IDButton<Editor_Event_Menu_Edit_EventChain, int32_t> (this, - posx, posy, 80, 20, + pos.x, pos.y, 80, 20, 1, &Editor_Event_Menu_Edit_EventChain::end_modal, this, 0, _("Cancel")); Modified: trunk/src/editor/ui_menus/editor_objectives_menu.cc =================================================================== --- trunk/src/editor/ui_menus/editor_objectives_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_objectives_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -69,55 +69,54 @@ m_te (te) { int32_t const spacing = 5; - int32_t posy = 5; + Point pos (get_inner_w() - STATEBOX_WIDTH - spacing, 5); Objective & obj = UI::Table<Objective &>::get(te); new UI::Textarea(this, 5, 5, 120, 20, _("Name"), Align_CenterLeft); m_name = new UI::EditBox(this, 120, 5, 120, 20, 0, 0); m_name->setText(obj.name()); - posy += 20 + spacing; + pos.y += 20 + spacing; new UI::Textarea (this, - 5, posy, 120, STATEBOX_HEIGHT, + 5, pos.y, 120, STATEBOX_HEIGHT, _("Visible at Begin: "), Align_CenterLeft); - m_visibleAtBegin = - new UI::Checkbox(this, get_inner_w() - STATEBOX_WIDTH - spacing, posy); + m_visibleAtBegin = new UI::Checkbox(this, pos); m_visibleAtBegin->set_state(obj.get_is_visible()); - posy += STATEBOX_HEIGHT + spacing; + pos.x = 5; + pos.y += STATEBOX_HEIGHT + spacing; new UI::Textarea (this, - 5, posy, 120, STATEBOX_HEIGHT, + pos.x, pos.y, 120, STATEBOX_HEIGHT, _("Objective text: "), Align_CenterLeft); - posy += 20 + spacing; + pos.y += 20 + spacing; int32_t const editbox_height = 140; m_descr = new UI::Multiline_Editbox (this, - 5, posy, get_inner_w() - 2 * spacing, editbox_height, + pos.x, pos.y, get_inner_w() - 2 * spacing, editbox_height, obj.descr().c_str()); - posy += editbox_height + spacing + spacing; + pos.x = get_inner_w() / 2 - 80 - spacing; + pos.y += editbox_height + spacing + spacing; new UI::Button<Edit_Objective_Window> (this, - get_inner_w() / 2 - 80 - spacing, posy, 80, 20, + pos.x, pos.y, 80, 20, 1, &Edit_Objective_Window::clicked_ok, this, _("Ok")); + pos.x += 80 + 2 * spacing; new UI::IDButton<Edit_Objective_Window, int32_t> (this, - get_inner_w() / 2 + spacing, posy, 80, 20, + pos.x, pos.y, 80, 20, 1, &Edit_Objective_Window::end_modal, this, 0, _("Back")); - posy += 20 + spacing; - - set_inner_size(get_inner_w(), posy); - + set_inner_size(get_inner_w(), pos.y + 20 + spacing); center_to_parent(); } Modified: trunk/src/editor/ui_menus/editor_tool_change_resources_options_menu.cc =================================================================== --- trunk/src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -143,7 +143,7 @@ } m_radiogroup.add_button (this, - pos.x, pos.y, + pos, g_gr->get_picture (PicMod_Game, world.get_resource(i)->get_editor_pic(100000).c_str())); Modified: trunk/src/editor/ui_menus/editor_tool_menu.cc =================================================================== --- trunk/src/editor/ui_menus/editor_tool_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_tool_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -45,60 +45,31 @@ UI::UniqueWindow(&parent, ®istry, 350, 400, _("Tool Menu")) { - int32_t const offsx = 5; - int32_t const offsy = 5; - int32_t const spacing = 5; +#define spacing 5 + Point const offs (spacing, spacing); + Point pos = offs; int32_t const width = 34; int32_t const height = 34; - int32_t posx = offsx; - int32_t posy = offsy; int32_t const num_tools = 6; - m_radioselect.add_button - (this, - posx, posy, - g_gr->get_picture - (PicMod_Game, "pics/editor_menu_tool_change_height.png"), - _("Change height")); - posx += width + spacing; - m_radioselect.add_button - (this, - posx, posy, - g_gr->get_picture - (PicMod_Game, "pics/editor_menu_tool_noise_height.png"), - _("Noise height")); - posx += width + spacing; - m_radioselect.add_button - (this, - posx, posy, - g_gr->get_picture - (PicMod_Game, "pics/editor_menu_tool_set_terrain.png"), - _("Terrain")); - posx += width + spacing; - m_radioselect.add_button - (this, - posx, posy, - g_gr->get_picture - (PicMod_Game, "pics/editor_menu_tool_place_immovable.png"), - _("Immovable")); - posx += width + spacing; - m_radioselect.add_button - (this, - posx, posy, - g_gr->get_picture - (PicMod_Game, "pics/editor_menu_tool_place_bob.png"), - _("Bob")); - posx += width + spacing; - m_radioselect.add_button - (this, - posx, posy, - g_gr->get_picture - (PicMod_Game, "pics/editor_menu_tool_change_resources.png"), - _("Resource")); +#define ADD_BUTTON(pic, tooltip) \ + m_radioselect.add_button \ + (this, \ + pos, \ + g_gr->get_picture \ + (PicMod_Game, "pics/editor_menu_tool_" pic ".png"), \ + tooltip); \ + pos.x += width + spacing; + ADD_BUTTON("change_height", _("Change height")); + ADD_BUTTON("noise_height", _("Noise height")); + ADD_BUTTON("set_terrain", _("Terrain")); + ADD_BUTTON("place_immovable", _("Immovable")); + ADD_BUTTON("place_bob", _("Bob")); + ADD_BUTTON("change_resources", _("Resource")); set_inner_size - (offsx + (width + spacing) * num_tools, offsy + (height + spacing)); + (offs.x + (width + spacing) * num_tools, offs.y + (height + spacing)); { const Editor_Tool & current = parent.tools.current(); Modified: trunk/src/editor/ui_menus/editor_tool_place_bob_options_menu.cc =================================================================== --- trunk/src/editor/ui_menus/editor_tool_place_bob_options_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_tool_place_bob_options_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -49,15 +49,14 @@ m_pit (pit) { int32_t const space = 5; - int32_t const xstart = 5; - int32_t const ystart = 15; Widelands::World const & world = parent.egbase().map().world(); int32_t const nr_bobs = world.get_nr_bobs(); const uint32_t bobs_in_row = std::max - (std::min - (static_cast<uint32_t>(ceil(sqrt(static_cast<float>(nr_bobs)))), 24U), - 12U); + (std::min + (static_cast<uint32_t>(ceil(sqrt(static_cast<float>(nr_bobs)))), + 24U), + 12U); m_tabpanel.set_snapparent(true); @@ -74,16 +73,14 @@ const uint32_t tab_icon = g_gr->get_picture(PicMod_Game, "pics/list_first_entry.png"); - int32_t ypos = ystart; - int32_t xpos = xstart; + Point pos; uint32_t cur_x = bobs_in_row; int32_t i = 0; UI::Box * box; while (i < nr_bobs) { if (cur_x == bobs_in_row) { cur_x = 0; - ypos = ystart; - xpos = xstart; + pos = Point(5, 15); box = new UI::Box(&m_tabpanel, 0, 0, UI::Box::Horizontal); box->resize(); m_tabpanel.add(tab_icon, box); @@ -93,7 +90,7 @@ upcast(Widelands::Critter_Bob_Descr const, critter_descr, &descr); UI::Checkbox & cb = *new UI::Checkbox (box, - xpos, ypos, + pos, g_gr->get_picture(PicMod_Game, descr.get_picture()), critter_descr ? critter_descr->descname() : std::string()); @@ -104,11 +101,10 @@ m_checkboxes.push_back(&cb); box->add(&cb, Align_Left); box->add_space(space); - xpos += width + 1 + space; + pos.x += width + 1 + space; ++cur_x; ++i; } - ypos += height + 1 + space + 5; m_tabpanel.activate(0); m_tabpanel.resize(); @@ -118,7 +114,9 @@ /** * This is called when one of the state boxes is toggled */ -void Editor_Tool_Place_Bob_Options_Menu::clicked(int32_t n, bool t) { +void Editor_Tool_Place_Bob_Options_Menu::clicked + (int32_t const n, bool const t) +{ // FIXME This code is erroneous. It checks the current key state. What it // FIXME needs is the key state at the time the mouse was clicked. See the // FIXME usage comment for get_key_state. @@ -135,7 +133,10 @@ // TODO The uint32_t cast is ugly! for (uint32_t i = 0; i < m_checkboxes.size(); ++i, i += i == static_cast<uint32_t>(n)) { m_checkboxes[i]->changedtoid.set - (this, &Editor_Tool_Place_Bob_Options_Menu::do_nothing); + (this, + static_cast + <void (Editor_Tool_Place_Bob_Options_Menu::*)(int32_t, bool)> + (0)); m_checkboxes[i]->set_state(false); m_checkboxes[i]->changedtoid.set (this, &Editor_Tool_Place_Bob_Options_Menu::clicked); @@ -145,8 +146,3 @@ m_pit.enable(n, t); select_correct_tool(); } - -/** - * Do nothing -*/ -void Editor_Tool_Place_Bob_Options_Menu::do_nothing(int32_t, bool) {} Modified: trunk/src/editor/ui_menus/editor_tool_place_bob_options_menu.h =================================================================== --- trunk/src/editor/ui_menus/editor_tool_place_bob_options_menu.h 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_tool_place_bob_options_menu.h 2008-04-18 11:56:37 UTC (rev 3181) @@ -40,7 +40,6 @@ std::vector<UI::Checkbox *> m_checkboxes; Editor_Place_Bob_Tool & m_pit; void clicked(int32_t, bool); - void do_nothing(int32_t, bool); }; #endif Modified: trunk/src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc =================================================================== --- trunk/src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -46,8 +46,6 @@ m_pit (pit) { int32_t const space = 5; - int32_t const xstart = 5; - int32_t const ystart = 15; Widelands::World const & world = parent.egbase().map().world(); const Immovable_Descr::Index nr_immovables = world.get_nr_immovables(); const uint32_t immovables_in_row = std::min @@ -71,15 +69,13 @@ const uint32_t tab_icon = g_gr->get_picture(PicMod_Game, "pics/list_first_entry.png"); - int32_t ypos = ystart; - int32_t xpos = xstart; + Point pos; uint32_t cur_x = immovables_in_row; - UI::Box * box = 0; + UI::Box * box; for (Immovable_Descr::Index i = 0; i < nr_immovables; ++cur_x, ++i) { - if (cur_x==immovables_in_row) { + if (cur_x == immovables_in_row) { cur_x = 0; - ypos = ystart; - xpos = xstart; + pos = Point(5, 15); box = new UI::Box(&m_tabpanel, 0, 0, UI::Box::Horizontal); box->resize(); m_tabpanel.add(tab_icon, box); @@ -87,7 +83,7 @@ assert(box); UI::Checkbox & cb = *new UI::Checkbox - (box, xpos, ypos, + (box, pos, g_gr->get_picture (PicMod_Game, world.get_immovable_descr(i)->get_picture())); @@ -98,9 +94,8 @@ m_checkboxes.push_back(&cb); box->add(&cb, Align_Left); box->add_space(space); - xpos += width + 1 + space; + pos.x += width + 1 + space; } - ypos += height + 1 + space + 5; m_tabpanel.activate(0); m_tabpanel.resize(); @@ -133,7 +128,11 @@ //TODO: the uint32_t cast is ugly! for (uint32_t i = 0; i < size; ++i, i += i == static_cast<uint32_t>(n)) { m_checkboxes[i]->changedtoid.set - (this, &Editor_Tool_Place_Immovable_Options_Menu::do_nothing); + (this, + static_cast + <void (Editor_Tool_Place_Immovable_Options_Menu::*) + (int32_t, bool)> + (0)); m_checkboxes[i]->set_state(false); m_checkboxes[i]->changedtoid.set (this, &Editor_Tool_Place_Immovable_Options_Menu::clicked); @@ -144,6 +143,3 @@ select_correct_tool(); } } - -void Editor_Tool_Place_Immovable_Options_Menu::do_nothing(int32_t, bool) -{} Modified: trunk/src/editor/ui_menus/editor_tool_place_immovable_options_menu.h =================================================================== --- trunk/src/editor/ui_menus/editor_tool_place_immovable_options_menu.h 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_tool_place_immovable_options_menu.h 2008-04-18 11:56:37 UTC (rev 3181) @@ -42,7 +42,6 @@ UI::Tab_Panel m_tabpanel; Editor_Place_Immovable_Tool & m_pit; void clicked(int32_t, bool); - void do_nothing(int32_t, bool); }; #endif Modified: trunk/src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc =================================================================== --- trunk/src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -136,7 +136,7 @@ // Save this surface, so we can free it later on. m_surfaces.push_back(surface); - UI::Checkbox & cb = *new UI::Checkbox(this, pos.x, pos.y, surface); + UI::Checkbox & cb = *new UI::Checkbox(this, pos, surface); cb.set_size(TEXTURE_WIDTH + 1, TEXTURE_HEIGHT + 1); cb.set_id(i); cb.set_state(m_tool.is_enabled(i)); Modified: trunk/src/editor/ui_menus/event_allow_building_option_menu.cc =================================================================== --- trunk/src/editor/ui_menus/event_allow_building_option_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/event_allow_building_option_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -117,7 +117,7 @@ m_increment_building.get_y() + m_increment_building.get_h() + spacing, get_inner_w() - 3 * spacing - 20, 20, _("Allow Building: "), Align_CenterLeft), -m_allow(this, get_inner_w() - spacing - 20, m_label_allow.get_y()), +m_allow(this, Point(get_inner_w() - spacing - 20, m_label_allow.get_y())), m_button_ok (this, (get_inner_w() >> 1) - 60 - spacing, Modified: trunk/src/editor/ui_menus/event_message_box_option_menu.cc =================================================================== --- trunk/src/editor/ui_menus/event_message_box_option_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/editor/ui_menus/event_message_box_option_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -47,11 +47,8 @@ UI::Window(&parent, 0, 0, 430, 400, _("Message Box Event Options")), m_event (event) { - int32_t const offsx = 5; - int32_t const offsy = 25; int32_t const spacing = 5; - int32_t posx = offsx; - int32_t posy = offsy; + Point pos (spacing, 25); m_nr_buttons = m_event.get_nr_buttons(); m_ls_selected =0; @@ -65,119 +62,130 @@ m_buttons[3].trigger = -1; - new UI::Textarea(this, spacing, posy, 50, 20, _("Name:"), Align_CenterLeft); + new UI::Textarea(this, pos.x, pos.y, 50, 20, _("Name:"), Align_CenterLeft); m_name = new UI::EditBox (this, - spacing + 60, posy, get_inner_w() / 2 - 60 - 2 * spacing, 20, + spacing + 60, pos.y, get_inner_w() / 2 - 60 - 2 * spacing, 20, 0, 0); m_name->setText(event.name()); - posy += 20 + spacing; + pos.y += 20 + spacing; new UI::Textarea (this, - get_inner_w() / 2 + spacing, posy, 150, 20, + get_inner_w() / 2 + spacing, pos.y, 150, 20, _("Is Modal: "), Align_CenterLeft); - m_is_modal = - new UI::Checkbox(this, get_inner_w() - STATEBOX_WIDTH - spacing, posy); + pos.x = get_inner_w() - STATEBOX_WIDTH - spacing; + m_is_modal = new UI::Checkbox(this, pos); m_is_modal->set_state(m_event.get_is_modal()); - posy += 20 + spacing; + pos.x = spacing; + pos.y += 20 + spacing; new UI::Textarea - (this, spacing, posy, 50, 20, _("Window Title:"), Align_CenterLeft); + (this, pos.x, pos.y, 50, 20, _("Window Title:"), Align_CenterLeft); + pos.x += 100; m_window_title = new UI::EditBox - (this, spacing + 100, posy, get_inner_w() - 100 - 2 * spacing, 20, 0, 2); + (this, pos.x, pos.y, get_inner_w() - 100 - 2 * spacing, 20, 0, 2); m_window_title->setText(m_event.get_window_title()); - posy += 20 + spacing; - new UI::Textarea(this, spacing, posy, 50, 20, _("Text:"), Align_CenterLeft); - posy += 20 + spacing; + pos.x = spacing; + pos.y += 20 + spacing; + new UI::Textarea(this, pos.x, pos.y, 50, 20, _("Text:"), Align_CenterLeft); + pos.y += 20 + spacing; m_text = new UI::Multiline_Editbox - (this, spacing, posy, get_inner_w()-2*spacing, 80, event.get_text()); + (this, pos.x, pos.y, get_inner_w() - 2 * spacing, 80, event.get_text()); - posy += 80 + spacing; + pos.y += 80 + spacing; new UI::Textarea (this, - spacing, posy, 130, 20, + pos.x, pos.y, 130, 20, _("Number of Buttons: "), Align_CenterLeft); + pos.x += 140; new UI::Button<Event_Message_Box_Option_Menu> (this, - spacing + 140, posy, 20, 20, + pos.x, pos.y, 20, 20, 0, g_gr->get_picture(PicMod_UI, "pics/scrollbar_down.png"), &Event_Message_Box_Option_Menu::clicked_number_of_buttons_decrease, this); - m_nr_buttons_ta=new UI::Textarea(this, spacing+160+spacing, posy, 15, 20, "1", Align_CenterLeft); + m_nr_buttons_ta = + new UI::Textarea(this, spacing + 160 + spacing, pos.y, 15, 20, "1", Align_CenterLeft); + pos.x += 30 + spacing; new UI::Button<Event_Message_Box_Option_Menu> (this, - spacing + 175 + spacing, posy, 20, 20, + pos.x, pos.y, 20, 20, 0, g_gr->get_picture(PicMod_UI, "pics/scrollbar_up.png"), &Event_Message_Box_Option_Menu::clicked_number_of_buttons_increase, this); - posy += 20 + spacing; + pos.x = spacing; + pos.y += 20 + spacing; new UI::Textarea - (this, spacing, posy, 100, 20, _("Button Name: "), Align_CenterLeft); - m_button_name = - new UI::EditBox(this, spacing+110, posy, 100, 20, 0, 3); + (this, pos.x, pos.y, 100, 20, _("Button Name: "), Align_CenterLeft); + pos.x += 110; + m_button_name = new UI::EditBox(this, pos.x, pos.y, 100, 20, 0, 3); m_button_name->changedid.set (this, &Event_Message_Box_Option_Menu::edit_box_edited); // Listbox for buttons + pos.x = get_inner_w() / 2 + spacing; m_buttons_ls = new UI::Listselect<void *> (this, - get_inner_w() / 2 + spacing, posy, get_inner_w() / 2 - 2 * spacing, 80, + pos.x, pos.y, get_inner_w() / 2 - 2 * spacing, 80, Align_Left); m_buttons_ls->selected.set (this, &Event_Message_Box_Option_Menu::ls_selected); - posy += 20 + spacing; + pos.x = spacing; + pos.y += 20 + spacing; new UI::Textarea - (this, spacing, posy, 100, 20, _("Select Trigger: "), Align_CenterLeft); + (this, pos.x, pos.y, 100, 20, _("Select Trigger: "), Align_CenterLeft); + pos.x += 110; new UI::Button<Event_Message_Box_Option_Menu> (this, - spacing + 110, posy, 20, 20, + pos.x, pos.y, 20, 20, 0, g_gr->get_picture(PicMod_UI, "pics/scrollbar_down.png"), &Event_Message_Box_Option_Menu::clicked_trigger_sel_decrease, this); + pos.x += 20 + spacing; new UI::Button<Event_Message_Box_Option_Menu> (this, - spacing + 130 + spacing, posy, 20, 20, + pos.x, pos.y, 20, 20, 0, g_gr->get_picture(PicMod_UI, "pics/scrollbar_up.png"), &Event_Message_Box_Option_Menu::clicked_trigger_sel_increase, this); - posy += 20 + spacing; + pos.x = spacing; + pos.y += 20 + spacing; new UI::Textarea - (this, spacing, posy, 100, 20, _("Current: "), Align_CenterLeft); + (this, pos.x, pos.y, 100, 20, _("Current: "), Align_CenterLeft); m_current_trigger_ta = new UI::Textarea (this, - spacing + 15, posy + 15 + spacing, get_inner_w() / 2, 20, + pos.x + 15, pos.y + 15 + spacing, get_inner_w() / 2, 20, _("No trigger selected!"), Align_CenterLeft); - posx = get_inner_w() / 2 - 60 - spacing; - posy = get_inner_h() - 30; + pos = Point(get_inner_w() / 2 - 60 - spacing, get_inner_h() - 30); new UI::Button<Event_Message_Box_Option_Menu> (this, - posx, posy, 60, 20, 0, + pos.x, pos.y, 60, 20, 0, &Event_Message_Box_Option_Menu::clicked_ok, this, _("Ok")); - posx = get_inner_w() / 2 + spacing; + pos.x = get_inner_w() / 2 + spacing; new UI::IDButton<Event_Message_Box_Option_Menu, int32_t> (this, - posx, posy, 60, 20, + pos.x, pos.y, 60, 20, 1, &Event_Message_Box_Option_Menu::end_modal, this, 0, _("Cancel")); Modified: trunk/src/events/event_road.cc =================================================================== --- trunk/src/events/event_road.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/events/event_road.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -44,10 +44,10 @@ for (char const * p = steps; *p; ++p) { if (*p < '1' or '6' < *p) throw wexception - ("step %u has direction '%c', must be one of {1 " + ("step %li has direction '%c', must be one of {1 " "(northeast), 2 (east), 3 (southeast), 4 (southwest), 5 " "(west), 6 (northwest)}", - p - steps, *p); + static_cast<long int>(p - steps), *p); m_path.append(map, *p - '0'); cstep.add_allowed_location(m_path.get_end()); } Modified: trunk/src/fieldaction.cc =================================================================== --- trunk/src/fieldaction.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/fieldaction.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -605,7 +605,7 @@ { return m_tabpanel->add - (g_gr->get_picture(PicMod_Game, picname), panel, tooltip_text); + (g_gr->get_picture(PicMod_Game, picname), panel, tooltip_text); } Modified: trunk/src/filesystem/disk_filesystem.cc =================================================================== --- trunk/src/filesystem/disk_filesystem.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/filesystem/disk_filesystem.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -352,8 +352,9 @@ data = malloc(size + 1); // FIXME memory leak! if (size and fread(data, size, 1, file) != 1) throw wexception - ("RealFSImpl::Load: read failed for %s (%s) with size %u", - fname.c_str(), fullname.c_str(), size); + ("RealFSImpl::Load: read failed for %s (%s) with size %lu", + fname.c_str(), fullname.c_str(), + static_cast<long unsigned int>(size)); static_cast<int8_t *>(data)[size] = 0; fclose(file); Modified: trunk/src/game_options_sound_menu.cc =================================================================== --- trunk/src/game_options_sound_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/game_options_sound_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -25,12 +25,12 @@ (Interactive_Player & plr, UI::UniqueWindow::Registry & registry) : UI::UniqueWindow(&plr, ®istry, 160, 160, _("Sound options")), -ingame_music(this, hmargin(), vmargin()), +ingame_music(this, Point(hmargin(), vmargin())), ingame_music_label (this, hmargin() + STATEBOX_WIDTH + hspacing(), vmargin(), _("Ingame Music")), -ingame_sound(this, hmargin(), vmargin() + STATEBOX_HEIGHT + vspacing()), +ingame_sound(this, Point(hmargin(), vmargin() + STATEBOX_HEIGHT + vspacing())), ingame_sound_label (this, hmargin() + STATEBOX_WIDTH + hspacing(), Modified: trunk/src/general_statistics_menu.cc =================================================================== --- trunk/src/general_statistics_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/general_statistics_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -66,8 +66,7 @@ { uint32_t const offsy = 35; uint32_t const spacing = 5; - uint32_t posx = spacing; - uint32_t posy = offsy; + Point pos (spacing, offsy); // plotter m_plot = @@ -77,7 +76,7 @@ PLOT_HEIGHT); m_plot->set_sample_rate(STATISTICS_SAMPLE_TIME); m_plot->set_plotmode(WUIPlot_Area::PLOTMODE_ABSOLUTE); - posy += PLOT_HEIGHT + spacing + spacing; + pos.y += PLOT_HEIGHT + spacing + spacing; const Game & game = *parent.get_game(); const Game::General_Stats_vector & genstats = @@ -114,7 +113,7 @@ const Player_Number nr_players = game.map().get_nrplayers(); iterate_players_existing_const(p, nr_players, game, player) ++plr_in_game; - posx = spacing; + pos.x = spacing; int32_t button_size = (get_inner_w() - (spacing * (plr_in_game + 1))) / plr_in_game; iterate_players_existing_const(p, nr_players, game, player) { @@ -122,149 +121,149 @@ snprintf(buffer, sizeof(buffer), "pics/genstats_enable_plr_%02u.png", p); UI::Checkbox & cb = *new UI::Checkbox - (this, posx, posy, g_gr->get_picture(PicMod_Game, buffer)); + (this, pos, g_gr->get_picture(PicMod_Game, buffer)); cb.set_size(button_size, 25); cb.set_id(p); cb.set_state(1); cb.changedtoid.set(this, &General_Statistics_Menu::cb_changed_to); m_cbs[p - 1] = &cb; - posx += button_size + spacing; + pos.x += button_size + spacing; } else // player nr p does not exist m_cbs[p - 1] = 0; - posx = spacing; - posy += 25 + spacing + spacing; + pos.x = spacing; + pos.y += 25 + spacing + spacing; m_radiogroup = new UI::Radiogroup(); button_size = (get_inner_w() - spacing * 8) / 7; m_radiogroup->add_button (this, - posx, posy, + pos, g_gr->get_picture(PicMod_Game, "pics/genstats_landsize.png"), _("Land")); - posx += button_size + spacing; + pos.x += button_size + spacing; m_radiogroup->add_button (this, - posx, posy, + pos, g_gr->get_picture(PicMod_Game, "pics/genstats_nrworkers.png"), _("Workers")); - posx += button_size + spacing; + pos.x += button_size + spacing; m_radiogroup->add_button (this, - posx, posy, + pos, g_gr->get_picture(PicMod_Game, "pics/genstats_nrbuildings.png"), _("Buildings")); - posx += button_size + spacing; + pos.x += button_size + spacing; m_radiogroup->add_button (this, - posx, posy, + pos, g_gr->get_picture(PicMod_Game, "pics/genstats_nrwares.png"), _("Wares")); - posx += button_size + spacing; + pos.x += button_size + spacing; m_radiogroup->add_button (this, - posx, posy, + pos, g_gr->get_picture(PicMod_Game, "pics/genstats_productivity.png"), _("Productivity")); - posx += button_size + spacing; + pos.x += button_size + spacing; m_radiogroup->add_button (this, - posx, posy, + pos, g_gr->get_picture(PicMod_Game, "pics/genstats_kills.png"), _("Kills")); - posx += button_size + spacing; + pos.x += button_size + spacing; m_radiogroup->add_button (this, - posx, posy, + pos, g_gr->get_picture(PicMod_Game, "pics/genstats_militarystrength.png"), _("Military")); m_radiogroup->set_state(0); m_selected_information = 0; m_radiogroup->changedto.set (this, &General_Statistics_Menu::radiogroup_changed); - posy += 25; + pos.y += 25; // time buttons button_size = (get_inner_w() - spacing * 5) / 4; - posx = spacing; - posy += spacing + spacing; + pos.x = spacing; + pos.y += spacing + spacing; new UI::IDButton<WUIPlot_Area, WUIPlot_Area::TIME> (this, - posx, posy, button_size, 25, + pos.x, pos.y, button_size, 25, 4, &WUIPlot_Area::set_time, m_plot, WUIPlot_Area::TIME_15_MINS, _("15 m")); - posx += button_size + spacing; + pos.x += button_size + spacing; new UI::IDButton<WUIPlot_Area, WUIPlot_Area::TIME> (this, - posx, posy, button_size, 25, + pos.x, pos.y, button_size, 25, 4, &WUIPlot_Area::set_time, m_plot, WUIPlot_Area::TIME_30_MINS, _("30 m")); - posx += button_size + spacing; + pos.x += button_size + spacing; new UI::IDButton<WUIPlot_Area, WUIPlot_Area::TIME> (this, - posx, posy, button_size, 25, + pos.x, pos.y, button_size, 25, 4, &WUIPlot_Area::set_time, m_plot, WUIPlot_Area::TIME_ONE_HOUR, _("1 h")); - posx += button_size+spacing; + pos.x += button_size + spacing; new UI::IDButton<WUIPlot_Area, WUIPlot_Area::TIME> (this, - posx, posy, button_size, 25, + pos.x, pos.y, button_size, 25, 4, &WUIPlot_Area::set_time, m_plot, WUIPlot_Area::TIME_TWO_HOURS, _("2 h")); - posy += 25 + spacing; - posx = spacing; + pos.y += 25 + spacing; + pos.x = spacing; new UI::Button<General_Statistics_Menu> (this, - posx, posy, 32, 32, + pos.x, pos.y, 32, 32, 4, g_gr->get_picture(PicMod_Game, "pics/menu_help.png"), &General_Statistics_Menu::clicked_help, this, _("Help")); - posx += button_size + spacing; + pos.x += button_size + spacing; new UI::IDButton<WUIPlot_Area, WUIPlot_Area::TIME> (this, - posx, posy, button_size, 25, + pos.x, pos.y, button_size, 25, 4, &WUIPlot_Area::set_time, m_plot, WUIPlot_Area::TIME_FOUR_HOURS, _("4 h")); - posx += button_size+spacing; + pos.x += button_size+spacing; new UI::IDButton<WUIPlot_Area, WUIPlot_Area::TIME> (this, - posx, posy, button_size, 25, + pos.x, pos.y, button_size, 25, 4, &WUIPlot_Area::set_time, m_plot, WUIPlot_Area::TIME_EIGHT_HOURS, _("8 h")); - posx += button_size + spacing; + pos.x += button_size + spacing; new UI::IDButton<WUIPlot_Area, WUIPlot_Area::TIME> (this, - posx, posy, button_size, 25, + pos.x, pos.y, button_size, 25, 4, &WUIPlot_Area::set_time, m_plot, WUIPlot_Area::TIME_16_HOURS, _("16 h")); - posx += button_size + spacing; - posy += 32 + spacing; + pos.x += button_size + spacing; + pos.y += 32 + spacing; - set_inner_size(get_inner_w(), posy); + set_inner_size(get_inner_w(), pos.y); } /* @@ -289,16 +288,17 @@ /* * Cb has been changed to this state */ -void General_Statistics_Menu::cb_changed_to(int32_t id, bool what) { +void General_Statistics_Menu::cb_changed_to(int32_t const id, bool const what) +{ // This represents our player number m_plot->show_plot - ((id - 1)* NR_DIFFERENT_DATASETS + m_selected_information, what); + ((id - 1) * NR_DIFFERENT_DATASETS + m_selected_information, what); } /* * The radiogroup has changed */ -void General_Statistics_Menu::radiogroup_changed(int32_t id) { +void General_Statistics_Menu::radiogroup_changed(int32_t const id) { for (uint32_t i = 0; i < m_parent->game().get_general_statistics().size(); ++i) if (m_cbs[i]) { m_plot->show_plot Modified: trunk/src/graphic.cc =================================================================== --- trunk/src/graphic.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/graphic.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -67,10 +67,7 @@ * Initialize the SDL video mode. */ Graphic::Graphic(int32_t w, int32_t h, int32_t bpp, bool fullscreen) -: -m_nr_update_rects (0), -m_update_fullscreen(false), -m_roadtextures (0) +: m_nr_update_rects(0), m_update_fullscreen(false), m_roadtextures(0) { for (uint32_t i = 0, r = 0, g = 0, b = 0; Modified: trunk/src/playerdescrgroup.cc =================================================================== --- trunk/src/playerdescrgroup.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/playerdescrgroup.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -54,7 +54,7 @@ d->plnum = plnum; d->plr_name = new UI::Textarea(this, 0, 0, 100, 20, std::string(), Align_Left); - d->btnEnablePlayer = new UI::Checkbox(this, 88, 0); + d->btnEnablePlayer = new UI::Checkbox(this, Point(88, 0)); d->btnEnablePlayer->changedto.set(this, &PlayerDescriptionGroup::enable_player); d->btnPlayerType = new UI::Button<PlayerDescriptionGroup> (this, Modified: trunk/src/streamread.cc =================================================================== --- trunk/src/streamread.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/streamread.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -48,8 +48,9 @@ if (read != size) throw data_error - ("Stream ended unexpectedly (%u bytes read, %u expected)", - read, size); + ("Stream ended unexpectedly (%lu bytes read, %lu expected)", + static_cast<long unsigned int>(read), + static_cast<long unsigned int>(size)); } int8_t StreamRead::Signed8() { Modified: trunk/src/ui/ui_basic/ui_checkbox.cc =================================================================== --- trunk/src/ui/ui_basic/ui_checkbox.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/ui/ui_basic/ui_checkbox.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -29,40 +29,35 @@ * checkbox graphics. */ Statebox::Statebox - (Panel * parent, - int32_t x, int32_t y, - uint32_t picid, - std::string const & tooltip_text) - : Panel(parent, x, y, STATEBOX_WIDTH, STATEBOX_HEIGHT, tooltip_text) + (Panel * const parent, + Point const p, + uint32_t const picid, + std::string const & tooltip_text) + : + Panel (parent, p.x, p.y, STATEBOX_WIDTH, STATEBOX_HEIGHT, tooltip_text), + m_flags(Is_Enabled) { - if (picid) - { + if (picid) { uint32_t w, h; g_gr->get_picture_size(picid, w, h); set_size(w, h); - m_custom_picture = true; + set_flags(Has_Custom_Picture, true); m_pic_graphics = picid; - } - else - { - m_custom_picture = false; + } else m_pic_graphics = g_gr->get_picture(PicMod_UI, "pics/checkbox_light_new.png"); - } - m_highlighted = false; - m_enabled = true; - m_state = false; - - m_clr_highlight = RGBColor(100, 100, 80); - m_clr_state = RGBColor(229, 161, 2); - m_id = -1; } -Statebox::~Statebox() {} +Statebox::~Statebox() { + if (m_flags & Owns_Custom_Picture) { + assert(m_flags & Has_Custom_Picture); + g_gr->free_surface(m_pic_graphics); + } +} /** @@ -73,13 +68,14 @@ */ void Statebox::set_enabled(bool enabled) { - m_enabled = enabled; + set_flags(Is_Enabled, enabled); - if (!m_custom_picture) { + if (not (m_flags & Has_Custom_Picture)) { m_pic_graphics = g_gr->get_picture (PicMod_UI, - m_enabled ? "pics/checkbox_light_new.png" : "pics/checkbox.png"); - m_highlighted &= m_enabled; + enabled ? "pics/checkbox_light_new.png" : "pics/checkbox.png"); + set_flags + (Is_Highlighted, m_flags & Is_Highlighted and m_flags & Is_Enabled); } update(0, 0, get_w(), get_h()); @@ -91,16 +87,14 @@ * * Args: on true if the checkbox should be checked */ -void Statebox::set_state(bool on) -{ - if (on == m_state) - return; - - m_state = on; - changed.call(); - changedto.call(on); - if (m_id!=-1) changedtoid.call(m_id, on); - update(0, 0, get_w(), get_h()); +void Statebox::set_state(bool const on) { + if (on xor m_flags & Is_Checked) { + set_flags(Is_Checked, on); + changed .call (); + changedto .call (on); + changedtoid.call(m_id, on); + update(0, 0, get_w(), get_h()); + } } @@ -109,8 +103,7 @@ */ void Statebox::draw(RenderTarget* dst) { - if (m_custom_picture) - { + if (m_flags & Has_Custom_Picture) { // center picture uint32_t w, h; g_gr->get_picture_size(m_pic_graphics, w, h); @@ -119,24 +112,25 @@ (Point((get_inner_w() - w) / 2, (get_inner_h() - h) / 2), m_pic_graphics); - if (m_state) - dst->draw_rect(Rect(Point(0, 0), get_w(), get_h()), m_clr_state); - else if (m_highlighted) - dst->draw_rect(Rect(Point(0, 0), get_w(), get_h()), m_clr_highlight); - } - else - { + if (m_flags & Is_Checked) + dst->draw_rect + (Rect(Point(0, 0), get_w(), get_h()), RGBColor(229, 116, 2)); + else if (m_flags & Is_Highlighted) + dst->draw_rect + (Rect(Point(0, 0), get_w(), get_h()), RGBColor(100, 100, 80)); + } else { compile_assert(0 <= STATEBOX_WIDTH); compile_assert(0 <= STATEBOX_HEIGHT); dst->blitrect (Point(0, 0), m_pic_graphics, Rect - (Point(m_state ? STATEBOX_WIDTH : 0, 0), + (Point(m_flags & Is_Checked ? STATEBOX_WIDTH : 0, 0), STATEBOX_WIDTH, STATEBOX_HEIGHT)); - if (m_highlighted) - dst->draw_rect(Rect(Point(0, 0), get_w(), get_h()), m_clr_highlight); + if (m_flags & Is_Highlighted) + dst->draw_rect + (Rect(Point(0, 0), get_w(), get_h()), RGBColor(100, 100, 80)); } } @@ -144,9 +138,8 @@ /** * Highlight the checkbox when the mouse moves into it */ -void Statebox::handle_mousein(bool inside) -{ - m_highlighted = inside; +void Statebox::handle_mousein(bool const inside) { + set_flags(Is_Highlighted, inside); update(0, 0, get_w(), get_h()); } @@ -155,11 +148,11 @@ * Left-click: Toggle checkbox state */ bool Statebox::handle_mousepress(const Uint8 btn, int32_t, int32_t) { - if (btn != SDL_BUTTON_LEFT) return false; - - if (m_enabled) clicked(); - - return true; + if (btn == SDL_BUTTON_LEFT and m_flags & Is_Enabled) { + clicked(); + return true; + } else + return false; } bool Statebox::handle_mouserelease(const Uint8 btn, int32_t, int32_t) {return btn == SDL_BUTTON_LEFT;} Modified: trunk/src/ui/ui_basic/ui_checkbox.h =================================================================== --- trunk/src/ui/ui_basic/ui_checkbox.h 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/ui/ui_basic/ui_checkbox.h 2008-04-18 11:56:37 UTC (rev 3181) @@ -36,7 +36,7 @@ struct Statebox : public Panel { Statebox (Panel * parent, - int32_t x, int32_t y, + Point, uint32_t picid = 0, std::string const & tooltip_text = std::string()); ~Statebox(); @@ -47,10 +47,14 @@ void set_enabled(bool enabled); - bool get_state() const throw () {return m_state;} + bool get_state() const throw () {return m_flags & Is_Checked;} void set_state(bool on); void set_id(int32_t n) {m_id = n;} + void set_owns_custom_picture() throw () { + assert(m_flags & Has_Custom_Picture); + set_flags(Owns_Custom_Picture, true); + } // Drawing and event handlers void draw(RenderTarget* dst); @@ -63,16 +67,18 @@ virtual void clicked() = 0; int32_t m_id; - - bool m_custom_picture; ///< the statebox displays a custom picture + enum Flags { + Is_Highlighted = 0x01, + Is_Enabled = 0x02, + Is_Checked = 0x04, + Has_Custom_Picture = 0x08, + Owns_Custom_Picture = 0x10 + }; + uint8_t m_flags; + void set_flags(uint8_t const flags, bool const enable) throw () { + m_flags &=~flags; if (enable) m_flags |= flags; + } uint32_t m_pic_graphics; - - bool m_highlighted; - bool m_enabled; ///< true if the checkbox can be clicked - bool m_state; ///< true if the box is checked - - RGBColor m_clr_state; ///< color of border when checked (custom picture only) - RGBColor m_clr_highlight; ///< color of border when highlighted }; @@ -82,14 +88,13 @@ * A checkbox only differs from a Statebox in that clicking on it toggles the * state */ -class Checkbox : public Statebox { -public: +struct Checkbox : public Statebox { Checkbox - (Panel * parent, - int32_t x, int32_t y, - int32_t picid = 0, - std::string const & tooltip_text = std::string()) - : Statebox(parent, x, y, picid, tooltip_text) + (Panel * const parent, + Point const p, + uint32_t const picid = 0, + std::string const & tooltip_text = std::string()) + : Statebox(parent, p, picid, tooltip_text) {} private: Modified: trunk/src/ui/ui_basic/ui_radiobutton.cc =================================================================== --- trunk/src/ui/ui_basic/ui_radiobutton.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/ui/ui_basic/ui_radiobutton.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -26,28 +26,34 @@ struct Radiobutton : public Statebox { friend class Radiogroup; - Radiobutton(Panel *parent, int32_t x, int32_t y, uint32_t picid, Radiogroup *group, int32_t id); + Radiobutton + (Panel * parent, Point, uint32_t picid, Radiogroup &, int32_t id); ~Radiobutton(); private: void clicked(); Radiobutton * m_nextbtn; - Radiogroup * m_group; + Radiogroup & m_group; int32_t m_id; }; /** * Initialize the radiobutton and link it into the group's linked list */ -Radiobutton::Radiobutton(Panel *parent, int32_t x, int32_t y, uint32_t picid, Radiogroup *group, int32_t id) - : Statebox(parent, x, y, picid) +Radiobutton::Radiobutton + (Panel * const parent, + Point const p, + uint32_t const picid, + Radiogroup & group, + int32_t const id) + : + Statebox (parent, p, picid), + m_nextbtn(group.m_buttons), + m_group (group), + m_id (id) { - m_group = group; - m_id = id; - - m_nextbtn = group->m_buttons; - group->m_buttons = this; + group.m_buttons = this; } /** @@ -55,7 +61,7 @@ */ Radiobutton::~Radiobutton() { - for (Radiobutton **pp = &m_group->m_buttons; *pp; pp = &(*pp)->m_nextbtn) { + for (Radiobutton **pp = &m_group.m_buttons; *pp; pp = &(*pp)->m_nextbtn) { if (*pp == this) { *pp = m_nextbtn; break; @@ -69,7 +75,7 @@ */ void Radiobutton::clicked() { - m_group->set_state(m_id); + m_group.set_state(m_id); play_click(); } @@ -103,12 +109,13 @@ * Returns the ID of the new button. */ int32_t Radiogroup::add_button - (Panel * const parent, - int32_t const x, int32_t const y, - uint32_t const picid, char const * const tooltip) + (Panel * const parent, + Point const p, + uint32_t const picid, + char const * const tooltip) { ++m_highestid; - (new Radiobutton(parent, x, y, picid, this, m_highestid))->set_tooltip + (new Radiobutton(parent, p, picid, *this, m_highestid))->set_tooltip (tooltip); return m_highestid; } @@ -119,8 +126,7 @@ * * Args: state the ID of the checked button (-1 means don't check any button) */ -void Radiogroup::set_state(int32_t state) -{ +void Radiogroup::set_state(int32_t const state) { if (state == m_state) { clicked.call(); return; Modified: trunk/src/ui/ui_basic/ui_radiobutton.h =================================================================== --- trunk/src/ui/ui_basic/ui_radiobutton.h 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/ui/ui_basic/ui_radiobutton.h 2008-04-18 11:56:37 UTC (rev 3181) @@ -20,8 +20,10 @@ #ifndef UI_RADIOBUTTON_H #define UI_RADIOBUTTON_H +#include "point.h" #include "ui_signal.h" + #include <stdint.h> namespace UI { @@ -44,9 +46,7 @@ Signal clicked; // clicked without things changed int32_t add_button - (Panel * parent, - int32_t x, int32_t y, - uint32_t picid, char const * tooltip = 0); + (Panel * parent, Point, uint32_t picid, char const * tooltip = 0); int32_t get_state() const throw () {return m_state;} void set_state(int32_t state); Modified: trunk/src/ui/ui_fs_menus/fullscreen_menu_mapselect.cc =================================================================== --- trunk/src/ui/ui_fs_menus/fullscreen_menu_mapselect.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/ui/ui_fs_menus/fullscreen_menu_mapselect.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -67,10 +67,8 @@ title->set_font(UI_FONT_BIG, UI_FONT_CLR_FG); UI::Textarea* label = new UI::Textarea(this, MENU_XRES - 300, 180, _("Load Map as scenario: "), Align_VCenter); - d->load_map_as_scenario = new UI::Checkbox - (this, - label->get_x() + label->get_w() + 10, - 170); + d->load_map_as_scenario = + new UI::Checkbox(this, Point(label->get_x() + label->get_w() + 10, 170)); d->load_map_as_scenario->set_state(false); d->list = new UI::Listselect<MapData>(this, 15, 205, 455, 365); Modified: trunk/src/ui/ui_fs_menus/fullscreen_menu_options.cc =================================================================== --- trunk/src/ui/ui_fs_menus/fullscreen_menu_options.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/ui/ui_fs_menus/fullscreen_menu_options.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -50,13 +50,13 @@ &Fullscreen_Menu_Options::end_modal, this, om_ok, _("Apply")), m_title(this, MENU_XRES / 2, 0, _("General Options"), Align_HCenter), -m_fullscreen(this, 300, 80), +m_fullscreen (this, Point(300, 80)), m_label_fullscreen(this, 325, 90, _("Fullscreen"), Align_VCenter), -m_inputgrab(this, 300, 140), +m_inputgrab (this, Point(300, 140)), m_label_inputgrab(this, 325, 120, _("Grab Input"), Align_VCenter), -m_music(this, 300, 140), +m_music (this, Point(300, 140)), m_label_music(this, 325, 150, _("Enable Music"), Align_VCenter), -m_fx(this, 300, 170), +m_fx (this, Point(300, 170)), m_label_fx(this, 325, 180, _("Enable Sound"), Align_VCenter), m_reslist(this, 80, 80, 190, 150, Align_Left, true), m_label_resolution(this, 85, 65, _("In-game resolution"), Align_VCenter), @@ -64,22 +64,22 @@ m_language_list(this, MENU_XRES / 2 + 75, 80, 210, 150, Align_Left, true), m_label_game_options (this, MENU_XRES / 2, 270, _("In-game Options"), Align_HCenter), -m_single_watchwin(this, 85, 325), +m_single_watchwin (this, Point(85, 325)), m_label_single_watchwin (this, 110, 335, _("Use single Watchwindow Mode"), Align_VCenter), -m_auto_roadbuild_mode(this, 85, 355), +m_auto_roadbuild_mode (this, Point(85, 355)), m_label_auto_roadbuild_mode (this, 110, 365, _("Start roadbuilding after placing flag"), Align_VCenter), -m_show_workarea_preview(this, 85, 385), +m_show_workarea_preview (this, Point(85, 385)), m_label_show_workarea_preview (this, 110, 395, _("Show buildings area preview"), Align_VCenter), -m_snap_windows_only_when_overlapping(this, 85, 415), +m_snap_windows_only_when_overlapping(this, Point(85, 415)), m_label_snap_windows_only_when_overlapping (this, 110, 425, _("Snap windows only when overlapping"), Align_VCenter), -m_dock_windows_to_edges(this, 85, 445), +m_dock_windows_to_edges (this, Point(85, 445)), m_label_dock_windows_to_edges (this, 110, 455, _("Dock windows to edges"), Align_VCenter), -m_autosave(this, 85, 475), +m_autosave (this, Point(85, 475)), m_label_autosave (this, 110, 485, "Autosave game every XXX minutes", Align_VCenter) { Modified: trunk/src/ware_statistics_menu.cc =================================================================== --- trunk/src/ware_statistics_menu.cc 2008-04-16 08:57:37 UTC (rev 3180) +++ trunk/src/ware_statistics_menu.cc 2008-04-18 11:56:37 UTC (rev 3181) @@ -299,11 +299,7 @@ * of the graph and it needs a picture */ struct WSM_Checkbox : public UI::Checkbox { - WSM_Checkbox - (UI::Panel *, - int32_t x, int32_t y, - int32_t id, uint32_t picid, - RGBColor); + WSM_Checkbox(UI::Panel *, Point, int32_t id, uint32_t picid, RGBColor); virtual void draw(RenderTarget *t); @@ -315,15 +311,16 @@ WSM_Checkbox::WSM_Checkbox (UI::Panel * const parent, - int32_t const x, int32_t const y, - int32_t const id, uint32_t const picid, - RGBColor const color) -: UI::Checkbox(parent, x, y, g_gr->get_picture(PicMod_Game, WARES_DISPLAY_BG)) + Point const p, + int32_t const id, + uint32_t const picid, + RGBColor const color) +: +UI::Checkbox(parent, p, g_gr->get_picture(PicMod_Game, WARES_DISPLAY_BG)), +m_pic (picid), +m_color (color) { - - m_pic = picid; set_id(id); - m_color = color; } /* @@ -366,30 +363,30 @@ const uint32_t nr_rows = nr_wares / wares_per_row + (nr_wares % wares_per_row ? 1 : 0); - int32_t const spacing = 5; - int32_t offsx = spacing; - int32_t offsy = 30; - int32_t posx = offsx; - int32_t posy = offsy; +#define spacing 5 + Point const offs(spacing, 30); + Point pos (offs); - set_inner_size (10, - (offsy + spacing + PLOT_HEIGHT + spacing + + (offs.y + spacing + PLOT_HEIGHT + spacing + nr_rows * (WARE_MENU_PIC_HEIGHT + spacing) + 100)); - m_plot = new WUIPlot_Area(this, spacing, offsy+spacing, get_inner_w()-2*spacing, PLOT_HEIGHT); + m_plot = + new WUIPlot_Area + (this, + spacing, offs.y + spacing, get_inner_w() - 2 * spacing, PLOT_HEIGHT); m_plot->set_sample_rate(STATISTICS_SAMPLE_TIME); m_plot->set_plotmode(WUIPlot_Area::PLOTMODE_RELATIVE); // all wares Widelands::Item_Ware_Descr::Index cur_ware = 0; int32_t dposy = 0; - posy += PLOT_HEIGHT+ 2 * spacing; + pos.y += PLOT_HEIGHT+ 2 * spacing; Widelands::Tribe_Descr const & tribe = parent.get_player()->tribe(); for (uint32_t y = 0; y < nr_rows; ++y) { - posx = spacing; + pos.x = spacing; for (uint32_t x = 0; x < wares_per_row and cur_ware < nr_wares; @@ -397,11 +394,12 @@ { Widelands::Item_Ware_Descr const & ware = *tribe.get_ware_descr(Widelands::Ware_Index(cur_ware)); - WSM_Checkbox & cb = *new WSM_Checkbox - (this, posx, posy, cur_ware, ware.get_icon(), colors[cur_ware]); + WSM_Checkbox & cb = + *new WSM_Checkbox + (this, pos, cur_ware, ware.get_icon(), colors[cur_ware]); cb.set_tooltip(ware.descname().c_str()); cb.changedtoid.set(this, &Ware_Statistics_Menu::cb_changed_to); - posx += cb.get_w() + spacing; + pos.x += cb.get_w() + spacing; dposy = cb.get_h() + spacing; set_inner_size (spacing + (cb.get_w() + spacing) * wares_per_row, get_inner_h()); @@ -411,92 +409,91 @@ (Widelands::Ware_Index(cur_ware)), colors[cur_ware]); } - posy += dposy; + pos.y += dposy; } m_plot->set_size(get_inner_w()-2*spacing, PLOT_HEIGHT); int32_t button_size = (get_inner_w() - spacing * 5) / 4;... [truncated message content] |