Merge lp:~widelands-dev/widelands/one_world into lp:widelands
- one_world
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 6985 | ||||
Proposed branch: | lp:~widelands-dev/widelands/one_world | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
39927 lines (+11658/-11636) 591 files modified
CMakeLists.txt (+1/-1) campaigns/t02.wmf/scripting/mission_thread.lua (+14/-14) cmake/codecheck/rules/misused_tab (+1/-1) cmake/codecheck/rules/space_as_indentation (+18/-3) doc/sphinx/extract_rst.py (+1/-1) global/conf (+0/-8) maps/Trident of Fire.wmf/scripting/map_editing.lua (+6/-8) src/ai/ai_help_structs.h (+10/-3) src/ai/ai_hints.h (+1/-1) src/ai/defaultai.cc (+3/-3) src/description_maintainer.h (+7/-3) src/economy/flag.h (+2/-2) src/economy/road.h (+2/-2) src/economy/test/test_road.cc (+5/-2) src/economy/wares_queue.h (+0/-1) src/editor/editorinteractive.cc (+29/-43) src/editor/editorinteractive.h (+0/-5) src/editor/tools/editor_decrease_height_tool.cc (+14/-17) src/editor/tools/editor_decrease_height_tool.h (+6/-2) src/editor/tools/editor_decrease_resources_tool.cc (+21/-23) src/editor/tools/editor_decrease_resources_tool.h (+11/-8) src/editor/tools/editor_delete_bob_tool.cc (+13/-11) src/editor/tools/editor_delete_bob_tool.h (+10/-6) src/editor/tools/editor_delete_immovable_tool.cc (+12/-12) src/editor/tools/editor_delete_immovable_tool.h (+10/-6) src/editor/tools/editor_draw_tool.cc (+14/-10) src/editor/tools/editor_draw_tool.h (+10/-7) src/editor/tools/editor_history.cc (+22/-22) src/editor/tools/editor_history.h (+9/-7) src/editor/tools/editor_increase_height_tool.cc (+20/-22) src/editor/tools/editor_increase_height_tool.h (+10/-6) src/editor/tools/editor_increase_resources_tool.cc (+46/-31) src/editor/tools/editor_increase_resources_tool.h (+26/-20) src/editor/tools/editor_info_tool.cc (+9/-17) src/editor/tools/editor_info_tool.h (+12/-7) src/editor/tools/editor_make_infrastructure_tool.cc (+5/-6) src/editor/tools/editor_make_infrastructure_tool.h (+9/-3) src/editor/tools/editor_noise_height_tool.cc (+20/-24) src/editor/tools/editor_noise_height_tool.h (+10/-6) src/editor/tools/editor_place_bob_tool.cc (+13/-11) src/editor/tools/editor_place_bob_tool.h (+10/-6) src/editor/tools/editor_place_immovable_tool.cc (+11/-13) src/editor/tools/editor_place_immovable_tool.h (+10/-6) src/editor/tools/editor_set_height_tool.cc (+16/-19) src/editor/tools/editor_set_height_tool.h (+10/-6) src/editor/tools/editor_set_origin_tool.cc (+11/-10) src/editor/tools/editor_set_origin_tool.h (+10/-6) src/editor/tools/editor_set_port_space_tool.cc (+24/-25) src/editor/tools/editor_set_port_space_tool.h (+20/-12) src/editor/tools/editor_set_resources_tool.cc (+18/-20) src/editor/tools/editor_set_resources_tool.h (+11/-8) src/editor/tools/editor_set_starting_pos_tool.cc (+5/-6) src/editor/tools/editor_set_starting_pos_tool.h (+5/-3) src/editor/tools/editor_set_terrain_tool.cc (+13/-11) src/editor/tools/editor_set_terrain_tool.h (+10/-6) src/editor/tools/editor_tool.h (+20/-11) src/editor/ui_menus/categorized_item_selection_menu.h (+185/-0) src/editor/ui_menus/editor_main_menu_load_map.cc (+0/-17) src/editor/ui_menus/editor_main_menu_load_map.h (+1/-1) src/editor/ui_menus/editor_main_menu_map_options.cc (+0/-6) src/editor/ui_menus/editor_main_menu_map_options.h (+1/-1) src/editor/ui_menus/editor_main_menu_new_map.cc (+8/-32) src/editor/ui_menus/editor_main_menu_new_map.h (+0/-3) src/editor/ui_menus/editor_main_menu_random_map.cc (+31/-48) src/editor/ui_menus/editor_main_menu_random_map.h (+7/-2) src/editor/ui_menus/editor_main_menu_save_map.cc (+0/-9) src/editor/ui_menus/editor_main_menu_save_map.h (+1/-1) src/editor/ui_menus/editor_player_menu.cc (+4/-4) src/editor/ui_menus/editor_tool_change_resources_options_menu.cc (+8/-7) src/editor/ui_menus/editor_tool_menu.cc (+1/-1) src/editor/ui_menus/editor_tool_place_bob_options_menu.cc (+2/-2) src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc (+38/-115) src/editor/ui_menus/editor_tool_place_immovable_options_menu.h (+8/-15) src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc (+97/-182) src/editor/ui_menus/editor_tool_set_terrain_options_menu.h (+10/-14) src/game_io/game_game_class_data_packet.cc (+2/-2) src/game_io/game_map_data_packet.cc (+0/-1) src/game_io/game_preload_data_packet.cc (+1/-6) src/graphic/animation.cc (+114/-80) src/graphic/animation.h (+3/-1) src/graphic/diranimations.h (+6/-3) src/graphic/graphic.cc (+10/-57) src/graphic/graphic.h (+4/-5) src/graphic/render/gamerenderer_gl.cc (+21/-22) src/graphic/render/gamerenderer_gl.h (+2/-2) src/graphic/render/gamerenderer_sdl.cc (+3/-1) src/graphic/render/minimaprenderer.cc (+5/-13) src/graphic/texture.cc (+23/-52) src/graphic/texture.h (+3/-5) src/io/filesystem/disk_filesystem.cc (+2/-1) src/logic/bob.cc (+10/-30) src/logic/bob.h (+7/-13) src/logic/buildcost.h (+1/-1) src/logic/building.h (+2/-2) src/logic/constructionsite.h (+1/-1) src/logic/critter_bob.cc (+113/-67) src/logic/critter_bob.h (+20/-18) src/logic/critter_bob_program.h (+1/-24) src/logic/dismantlesite.h (+1/-1) src/logic/editor_game_base.cc (+87/-70) src/logic/editor_game_base.h (+33/-29) src/logic/field.h (+10/-5) src/logic/findbob.h (+1/-0) src/logic/game.cc (+6/-10) src/logic/immovable.cc (+174/-151) src/logic/immovable.h (+16/-6) src/logic/immovable_program.h (+8/-4) src/logic/instances.cc (+12/-0) src/logic/instances.h (+8/-4) src/logic/map.cc (+103/-137) src/logic/map.h (+32/-38) src/logic/mapastar.cc (+1/-0) src/logic/message_queue.h (+1/-1) src/logic/militarysite.h (+2/-2) src/logic/partially_finished_building.h (+1/-1) src/logic/player.h (+4/-8) src/logic/production_program.cc (+2/-0) src/logic/production_program.h (+2/-2) src/logic/productionsite.cc (+1/-1) src/logic/productionsite.h (+1/-1) src/logic/ship.cc (+6/-2) src/logic/trainingsite.h (+2/-2) src/logic/tribe.cc (+10/-7) src/logic/tribe.h (+4/-9) src/logic/ware_descr.h (+2/-2) src/logic/warehouse.h (+2/-2) src/logic/widelands.h (+1/-1) src/logic/worker.cc (+34/-25) src/logic/worker.h (+0/-1) src/logic/worker_descr.cc (+12/-1) src/logic/worker_descr.h (+3/-2) src/logic/worker_program.cc (+2/-2) src/logic/world/editor_category.cc (+47/-0) src/logic/world/editor_category.h (+56/-0) src/logic/world/map_gen.cc (+387/-0) src/logic/world/map_gen.h (+176/-0) src/logic/world/resource_description.cc (+84/-0) src/logic/world/resource_description.h (+69/-0) src/logic/world/terrain_description.cc (+162/-0) src/logic/world/terrain_description.h (+101/-0) src/logic/world/world.cc (+112/-899) src/logic/world/world.h (+67/-348) src/logic/worlddata.h (+0/-53) src/map_generator.cc (+220/-235) src/map_generator.h (+8/-11) src/map_io/map_loader.h (+2/-2) src/map_io/one_world_legacy_lookup_table.cc (+395/-0) src/map_io/one_world_legacy_lookup_table.h (+50/-0) src/map_io/widelands_map_building_data_packet.h (+3/-6) src/map_io/widelands_map_buildingdata_data_packet.h (+4/-6) src/map_io/widelands_map_data_packet.h (+9/-27) src/map_io/widelands_map_elemental_data_packet.cc (+1/-3) src/map_io/widelands_map_elemental_data_packet.h (+15/-9) src/map_io/widelands_map_extradata_data_packet.cc (+2/-8) src/map_io/widelands_map_extradata_data_packet.h (+9/-1) src/map_io/widelands_map_heights_data_packet.cc (+1/-1) src/map_io/widelands_map_loader.cc (+13/-38) src/map_io/widelands_map_loader.h (+4/-3) src/map_io/widelands_map_node_ownership_data_packet.cc (+1/-1) src/map_io/widelands_map_object_packet.cc (+3/-3) src/map_io/widelands_map_object_packet.h (+2/-1) src/map_io/widelands_map_player_names_and_tribes_data_packet.cc (+1/-1) src/map_io/widelands_map_player_names_and_tribes_data_packet.h (+3/-6) src/map_io/widelands_map_player_position_data_packet.cc (+2/-1) src/map_io/widelands_map_players_view_data_packet.cc (+7/-10) src/map_io/widelands_map_port_spaces_data_packet.cc (+1/-1) src/map_io/widelands_map_port_spaces_data_packet.h (+5/-4) src/map_io/widelands_map_resources_data_packet.cc (+11/-10) src/map_io/widelands_map_resources_data_packet.h (+11/-1) src/map_io/widelands_map_saver.cc (+3/-4) src/map_io/widelands_map_scripting_data_packet.cc (+1/-0) src/map_io/widelands_map_terrain_data_packet.cc (+27/-26) src/map_io/widelands_map_terrain_data_packet.h (+16/-3) src/network/netclient.cc (+1/-0) src/profile/profile.cc (+5/-4) src/profile/profile.h (+6/-5) src/s2map.cc (+734/-710) src/s2map.h (+12/-119) src/scripting/c_utils.cc (+1/-1) src/scripting/lua_map.cc (+27/-23) src/scripting/lua_path.cc (+128/-0) src/scripting/lua_path.h (+41/-0) src/scripting/lua_root.cc (+199/-0) src/scripting/lua_root.h (+30/-0) src/scripting/lua_table.cc (+66/-12) src/scripting/lua_table.h (+67/-29) src/scripting/persistence.cc (+1/-1) src/scripting/scripting.cc (+10/-2) src/sound/fxset.cc (+11/-11) src/sound/fxset.h (+4/-4) src/sound/songset.cc (+31/-31) src/sound/songset.h (+8/-8) src/sound/sound_handler.cc (+87/-88) src/sound/sound_handler.h (+17/-17) src/ui_basic/messagebox.h (+2/-0) src/ui_fsmenu/editor_mapselect.cc (+0/-16) src/ui_fsmenu/editor_mapselect.h (+1/-1) src/ui_fsmenu/launchMPG.cc (+1/-7) src/ui_fsmenu/launchSPG.cc (+1/-0) src/ui_fsmenu/mapselect.cc (+0/-22) src/ui_fsmenu/mapselect.h (+0/-2) src/ui_fsmenu/options.cc (+2/-2) src/ui_fsmenu/options.h (+1/-1) src/wlapplication.cc (+2/-3) src/wui/game_debug_ui.cc (+6/-3) src/wui/game_options_sound_menu.cc (+1/-1) src/wui/general_statistics_menu.cc (+1/-0) src/wui/interactive_player.cc (+1/-1) src/wui/interactive_spectator.cc (+1/-1) src/wui/overlay_manager.h (+1/-0) test/maps/lua_persistence.wmf/scripting/test_persistence.lua (+3/-3) test/maps/lua_testsuite.wmf/scripting/baseimmovables.lua (+14/-15) test/maps/lua_testsuite.wmf/scripting/init.lua (+1/-0) test/maps/lua_testsuite.wmf/scripting/path.lua (+33/-0) tribes/atlanteans/builder/conf (+1/-1) tribes/atlanteans/crystalmine/conf (+19/-19) tribes/atlanteans/forester/conf (+1/-1) tribes/atlanteans/headquarters/conf (+0/-1) tribes/atlanteans/shipwright/conf (+1/-1) tribes/barbarians/builder/conf (+1/-1) tribes/barbarians/granitemine/conf (+2/-2) tribes/barbarians/headquarters/conf (+0/-1) tribes/barbarians/ranger/conf (+1/-1) tribes/barbarians/shipwright/conf (+1/-1) tribes/empire/builder/conf (+1/-1) tribes/empire/deep_marblemine/conf (+3/-3) tribes/empire/forester/conf (+2/-2) tribes/empire/headquarters/conf (+0/-1) tribes/empire/headquarters_shipwreck/conf (+0/-1) tribes/empire/marblemine/conf (+5/-5) tribes/empire/shipwright/conf (+36/-36) utils/buildcat.py (+1/-1) utils/win32/innosetup/Widelands.iss (+2/-2) utils/win32/mingw/Makefile (+1/-1) utils/win32/msvc/Widelands-msvc.iss.cmake (+2/-2) world/critters/badger/init.lua (+20/-16) world/critters/brownbear/init.lua (+20/-16) world/critters/bunny/init.lua (+19/-0) world/critters/chamois/init.lua (+20/-16) world/critters/deer/init.lua (+20/-14) world/critters/duck/init.lua (+24/-9) world/critters/elk/init.lua (+20/-16) world/critters/fox/init.lua (+20/-16) world/critters/lynx/init.lua (+20/-16) world/critters/marten/init.lua (+20/-16) world/critters/reindeer/init.lua (+20/-14) world/critters/sheep/init.lua (+24/-15) world/critters/stag/init.lua (+20/-14) world/critters/wisent/init.lua (+20/-16) world/critters/wolf/init.lua (+20/-16) world/immovables/bush1/init.lua (+15/-2) world/immovables/bush2/init.lua (+15/-2) world/immovables/bush3/init.lua (+15/-2) world/immovables/bush4/init.lua (+15/-2) world/immovables/bush5/init.lua (+15/-2) world/immovables/cactus1/init.lua (+15/-2) world/immovables/cactus2/init.lua (+15/-2) world/immovables/cactus3/init.lua (+15/-2) world/immovables/cactus4/init.lua (+15/-2) world/immovables/grass1/init.lua (+15/-2) world/immovables/grass2/init.lua (+15/-2) world/immovables/grass3/init.lua (+15/-2) world/immovables/manmade/bar-ruin00/init.lua (+15/-3) world/immovables/manmade/bar-ruin01/init.lua (+15/-3) world/immovables/manmade/bar-ruin02/init.lua (+15/-3) world/immovables/manmade/bar-ruin03/init.lua (+15/-3) world/immovables/manmade/debris00/init.lua (+15/-3) world/immovables/manmade/debris01/init.lua (+15/-3) world/immovables/manmade/debris02/init.lua (+15/-3) world/immovables/manmade/snowman/init.lua (+15/-2) world/immovables/mushroom1/init.lua (+15/-2) world/immovables/mushroom2/init.lua (+15/-2) world/immovables/pebble1/init.lua (+15/-2) world/immovables/pebble2/init.lua (+15/-2) world/immovables/pebble3/init.lua (+15/-2) world/immovables/pebble4/init.lua (+15/-2) world/immovables/pebble5/init.lua (+15/-2) world/immovables/pebble6/init.lua (+15/-2) world/immovables/ruin1/init.lua (+15/-2) world/immovables/ruin2/init.lua (+15/-2) world/immovables/ruin3/init.lua (+15/-2) world/immovables/ruin4/init.lua (+15/-2) world/immovables/ruin5/init.lua (+15/-2) world/immovables/skeleton1/init.lua (+15/-2) world/immovables/skeleton2/init.lua (+15/-2) world/immovables/skeleton3/init.lua (+15/-2) world/immovables/skeleton4/init.lua (+15/-2) world/immovables/standing_stones/standing_stone1_desert/init.lua (+15/-3) world/immovables/standing_stones/standing_stone1_summer/init.lua (+15/-3) world/immovables/standing_stones/standing_stone1_wasteland/init.lua (+15/-3) world/immovables/standing_stones/standing_stone1_winter/init.lua (+15/-3) world/immovables/standing_stones/standing_stone2_desert/init.lua (+15/-3) world/immovables/standing_stones/standing_stone2_summer/init.lua (+15/-3) world/immovables/standing_stones/standing_stone2_wasteland/init.lua (+15/-3) world/immovables/standing_stones/standing_stone2_winter/init.lua (+15/-3) world/immovables/standing_stones/standing_stone3_desert/init.lua (+15/-3) world/immovables/standing_stones/standing_stone3_summer/init.lua (+15/-3) world/immovables/standing_stones/standing_stone3_wasteland/init.lua (+15/-3) world/immovables/standing_stones/standing_stone3_winter/init.lua (+15/-3) world/immovables/standing_stones/standing_stone4_desert/init.lua (+15/-3) world/immovables/standing_stones/standing_stone4_summer/init.lua (+15/-3) world/immovables/standing_stones/standing_stone4_wasteland/init.lua (+15/-3) world/immovables/standing_stones/standing_stone4_winter/init.lua (+15/-3) world/immovables/standing_stones/standing_stone5_desert/init.lua (+15/-3) world/immovables/standing_stones/standing_stone5_summer/init.lua (+15/-3) world/immovables/standing_stones/standing_stone5_wasteland/init.lua (+15/-3) world/immovables/standing_stones/standing_stone5_winter/init.lua (+15/-3) world/immovables/standing_stones/standing_stone6/init.lua (+15/-2) world/immovables/standing_stones/standing_stone7/init.lua (+15/-2) world/immovables/stones/blackland_stones1/init.lua (+22/-9) world/immovables/stones/blackland_stones2/init.lua (+22/-9) world/immovables/stones/blackland_stones3/init.lua (+22/-9) world/immovables/stones/blackland_stones4/init.lua (+22/-9) world/immovables/stones/blackland_stones5/init.lua (+22/-9) world/immovables/stones/blackland_stones6/init.lua (+22/-9) world/immovables/stones/desert_stones1/init.lua (+22/-9) world/immovables/stones/desert_stones2/init.lua (+22/-9) world/immovables/stones/desert_stones3/init.lua (+22/-9) world/immovables/stones/desert_stones4/init.lua (+22/-9) world/immovables/stones/desert_stones5/init.lua (+22/-9) world/immovables/stones/desert_stones6/init.lua (+22/-9) world/immovables/stones/greenland_stones1/init.lua (+22/-9) world/immovables/stones/greenland_stones2/init.lua (+22/-9) world/immovables/stones/greenland_stones3/init.lua (+22/-9) world/immovables/stones/greenland_stones4/init.lua (+22/-9) world/immovables/stones/greenland_stones5/init.lua (+22/-9) world/immovables/stones/greenland_stones6/init.lua (+22/-9) world/immovables/stones/winterland_stones1/init.lua (+22/-9) world/immovables/stones/winterland_stones2/init.lua (+22/-9) world/immovables/stones/winterland_stones3/init.lua (+22/-9) world/immovables/stones/winterland_stones4/init.lua (+22/-9) world/immovables/stones/winterland_stones5/init.lua (+22/-9) world/immovables/stones/winterland_stones6/init.lua (+22/-9) world/immovables/track_winter/init.lua (+15/-2) world/immovables/trees/alder_summer_mature/init.lua (+23/-26) world/immovables/trees/alder_summer_old/init.lua (+30/-41) world/immovables/trees/alder_summer_pole/init.lua (+23/-26) world/immovables/trees/alder_summer_sapling/init.lua (+23/-26) world/immovables/trees/aspen_summer_mature/init.lua (+26/-28) world/immovables/trees/aspen_summer_old/init.lua (+36/-0) world/immovables/trees/aspen_summer_pole/init.lua (+23/-25) world/immovables/trees/aspen_summer_sapling/init.lua (+23/-25) world/immovables/trees/beech_summer_mature/init.lua (+23/-25) world/immovables/trees/beech_summer_old/init.lua (+30/-40) world/immovables/trees/beech_summer_pole/init.lua (+23/-25) world/immovables/trees/beech_summer_sapling/init.lua (+23/-25) world/immovables/trees/birch_summer_mature/init.lua (+26/-28) world/immovables/trees/birch_summer_old/init.lua (+30/-40) world/immovables/trees/birch_summer_pole/init.lua (+23/-25) world/immovables/trees/birch_summer_sapling/init.lua (+23/-25) world/immovables/trees/cirrus_wasteland_mature/init.lua (+23/-26) world/immovables/trees/cirrus_wasteland_old/init.lua (+26/-38) world/immovables/trees/cirrus_wasteland_pole/init.lua (+23/-26) world/immovables/trees/cirrus_wasteland_sapling/init.lua (+23/-26) world/immovables/trees/deadtree1/init.lua (+21/-8) world/immovables/trees/deadtree2/init.lua (+21/-8) world/immovables/trees/deadtree3/init.lua (+21/-8) world/immovables/trees/deadtree4/init.lua (+21/-8) world/immovables/trees/deadtree5/init.lua (+21/-8) world/immovables/trees/deadtree6/init.lua (+21/-8) world/immovables/trees/fallentree/init.lua (+23/-10) world/immovables/trees/larch_summer_mature/init.lua (+23/-26) world/immovables/trees/larch_summer_old/init.lua (+30/-39) world/immovables/trees/larch_summer_pole/init.lua (+23/-26) world/immovables/trees/larch_summer_sapling/init.lua (+23/-26) world/immovables/trees/liana_wasteland_mature/init.lua (+26/-29) world/immovables/trees/liana_wasteland_old/init.lua (+26/-38) world/immovables/trees/liana_wasteland_pole/init.lua (+23/-26) world/immovables/trees/liana_wasteland_sapling/init.lua (+23/-26) world/immovables/trees/maple_winter_mature/init.lua (+23/-28) world/immovables/trees/maple_winter_old/init.lua (+30/-42) world/immovables/trees/maple_winter_pole/init.lua (+23/-28) world/immovables/trees/maple_winter_sapling/init.lua (+23/-28) world/immovables/trees/mushroom_dark_wasteland_mature/init.lua (+23/-26) world/immovables/trees/mushroom_dark_wasteland_old/init.lua (+26/-40) world/immovables/trees/mushroom_dark_wasteland_pole/init.lua (+23/-26) world/immovables/trees/mushroom_dark_wasteland_sapling/init.lua (+23/-26) world/immovables/trees/mushroom_green_wasteland_mature/init.lua (+23/-26) world/immovables/trees/mushroom_green_wasteland_old/init.lua (+26/-38) world/immovables/trees/mushroom_green_wasteland_pole/init.lua (+23/-26) world/immovables/trees/mushroom_green_wasteland_sapling/init.lua (+23/-26) world/immovables/trees/mushroom_red_wasteland_mature/init.lua (+26/-29) world/immovables/trees/mushroom_red_wasteland_old/init.lua (+26/-38) world/immovables/trees/mushroom_red_wasteland_pole/init.lua (+23/-26) world/immovables/trees/mushroom_red_wasteland_sapling/init.lua (+23/-26) world/immovables/trees/oak_summer_mature/init.lua (+23/-25) world/immovables/trees/oak_summer_old/init.lua (+36/-46) world/immovables/trees/oak_summer_pole/init.lua (+23/-25) world/immovables/trees/oak_summer_sapling/init.lua (+23/-25) world/immovables/trees/palm_borassus_desert_mature/init.lua (+23/-28) world/immovables/trees/palm_borassus_desert_old/init.lua (+30/-44) world/immovables/trees/palm_borassus_desert_pole/init.lua (+23/-28) world/immovables/trees/palm_borassus_desert_sapling/init.lua (+23/-28) world/immovables/trees/palm_coconut_desert_mature/init.lua (+23/-28) world/immovables/trees/palm_coconut_desert_old/init.lua (+30/-44) world/immovables/trees/palm_coconut_desert_pole/init.lua (+23/-28) world/immovables/trees/palm_coconut_desert_sapling/init.lua (+23/-28) world/immovables/trees/palm_date_desert_mature/init.lua (+26/-31) world/immovables/trees/palm_date_desert_old/init.lua (+30/-43) world/immovables/trees/palm_date_desert_pole/init.lua (+23/-28) world/immovables/trees/palm_date_desert_sapling/init.lua (+23/-28) world/immovables/trees/palm_oil_desert_mature/init.lua (+27/-31) world/immovables/trees/palm_oil_desert_old/init.lua (+30/-47) world/immovables/trees/palm_oil_desert_pole/init.lua (+23/-28) world/immovables/trees/palm_oil_desert_sapling/init.lua (+23/-28) world/immovables/trees/palm_roystonea_desert_mature/init.lua (+23/-28) world/immovables/trees/palm_roystonea_desert_old/init.lua (+30/-49) world/immovables/trees/palm_roystonea_desert_pole/init.lua (+23/-28) world/immovables/trees/palm_roystonea_desert_sapling/init.lua (+23/-28) world/immovables/trees/rowan_summer_mature/init.lua (+26/-29) world/immovables/trees/rowan_summer_old/init.lua (+30/-39) world/immovables/trees/rowan_summer_pole/init.lua (+23/-26) world/immovables/trees/rowan_summer_sapling/init.lua (+23/-26) world/immovables/trees/spruce_summer_mature/init.lua (+23/-25) world/immovables/trees/spruce_summer_old/init.lua (+30/-40) world/immovables/trees/spruce_summer_pole/init.lua (+23/-25) world/immovables/trees/spruce_summer_sapling/init.lua (+23/-25) world/immovables/trees/twine_wasteland_mature/init.lua (+23/-26) world/immovables/trees/twine_wasteland_old/init.lua (+26/-40) world/immovables/trees/twine_wasteland_pole/init.lua (+23/-26) world/immovables/trees/twine_wasteland_sapling/init.lua (+23/-26) world/immovables/trees/umbrella_green_wasteland_mature/init.lua (+23/-26) world/immovables/trees/umbrella_green_wasteland_old/init.lua (+26/-40) world/immovables/trees/umbrella_green_wasteland_pole/init.lua (+23/-26) world/immovables/trees/umbrella_green_wasteland_sapling/init.lua (+23/-26) world/immovables/trees/umbrella_red_wasteland_mature/init.lua (+26/-29) world/immovables/trees/umbrella_red_wasteland_old/init.lua (+26/-43) world/immovables/trees/umbrella_red_wasteland_pole/init.lua (+23/-26) world/immovables/trees/umbrella_red_wasteland_sapling/init.lua (+23/-26) world/init.lua (+300/-0) world/map_generation.lua (+729/-0) world/resources/init.lua (+80/-0) world/terrains/init.lua (+777/-0) worlds/blackland/ToDo - blackland (+0/-22) worlds/blackland/bunny/conf (+0/-12) worlds/blackland/conf (+0/-88) worlds/blackland/duck/conf (+0/-9) worlds/blackland/fox/conf (+0/-16) worlds/blackland/grass1/conf (+0/-3) worlds/blackland/mapgenconf (+0/-156) worlds/blackland/reindeer/conf (+0/-14) worlds/blackland/resconf (+0/-45) worlds/blackland/sheep/conf (+0/-15) worlds/blackland/skeleton1/conf (+0/-3) worlds/blackland/skeleton2/conf (+0/-3) worlds/blackland/skeleton3/conf (+0/-3) worlds/blackland/terrainconf (+0/-97) worlds/desert/ToDo - Desert (+0/-22) worlds/desert/bunny/conf (+0/-12) worlds/desert/bush1/conf (+0/-3) worlds/desert/bush4/conf (+0/-3) worlds/desert/bush5/conf (+0/-3) worlds/desert/cactus1/conf (+0/-3) worlds/desert/cactus4/conf (+0/-3) worlds/desert/conf (+0/-94) worlds/desert/deadtree1/conf (+0/-8) worlds/desert/deadtree4/conf (+0/-8) worlds/desert/deer/conf (+0/-14) worlds/desert/duck/conf (+0/-9) worlds/desert/fox/conf (+0/-16) worlds/desert/grass1/conf (+0/-3) worlds/desert/grass2/conf (+0/-3) worlds/desert/grass3/conf (+0/-3) worlds/desert/mapgenconf (+0/-123) worlds/desert/mushroom1/conf (+0/-3) worlds/desert/mushroom2/conf (+0/-3) worlds/desert/pebble1/conf (+0/-3) worlds/desert/pebble2/conf (+0/-3) worlds/desert/pebble3/conf (+0/-3) worlds/desert/pebble4/conf (+0/-3) worlds/desert/pebble5/conf (+0/-3) worlds/desert/pebble6/conf (+0/-3) worlds/desert/resconf (+0/-45) worlds/desert/sheep/conf (+0/-15) worlds/desert/skeleton1/conf (+0/-3) worlds/desert/skeleton2/conf (+0/-3) worlds/desert/skeleton3/conf (+0/-3) worlds/desert/sstones6/conf (+0/-3) worlds/desert/sstones7/conf (+0/-3) worlds/desert/terrainconf (+0/-98) worlds/desert/tree6/conf (+0/-42) worlds/desert/tree6_m/conf (+0/-28) worlds/desert/tree6_s/conf (+0/-28) worlds/desert/tree6_t/conf (+0/-28) worlds/desert/tree7/conf (+0/-40) worlds/desert/tree7_m/conf (+0/-28) worlds/desert/tree7_s/conf (+0/-28) worlds/desert/tree7_t/conf (+0/-28) worlds/desert/tree8/conf (+0/-40) worlds/desert/tree8_m/conf (+0/-31) worlds/desert/tree8_s/conf (+0/-28) worlds/desert/tree8_t/conf (+0/-28) worlds/greenland/bunny/conf (+0/-12) worlds/greenland/bush1/conf (+0/-3) worlds/greenland/bush2/conf (+0/-3) worlds/greenland/bush3/conf (+0/-3) worlds/greenland/bush4/conf (+0/-3) worlds/greenland/bush5/conf (+0/-3) worlds/greenland/cactus1/conf (+0/-3) worlds/greenland/cactus2/conf (+0/-3) worlds/greenland/conf (+0/-97) worlds/greenland/deadtree1/conf (+0/-8) worlds/greenland/deadtree2/conf (+0/-8) worlds/greenland/deadtree3/conf (+0/-8) worlds/greenland/deadtree4/conf (+0/-8) worlds/greenland/grass2/conf (+0/-3) worlds/greenland/grass3/conf (+0/-3) worlds/greenland/mapgenconf (+0/-149) worlds/greenland/mushroom1/conf (+0/-3) worlds/greenland/mushroom2/conf (+0/-3) worlds/greenland/pebble1/conf (+0/-3) worlds/greenland/pebble2/conf (+0/-3) worlds/greenland/pebble3/conf (+0/-3) worlds/greenland/pebble4/conf (+0/-3) worlds/greenland/pebble5/conf (+0/-3) worlds/greenland/pebble6/conf (+0/-3) worlds/greenland/resconf (+0/-45) worlds/greenland/sstones6/conf (+0/-3) worlds/greenland/sstones7/conf (+0/-3) worlds/greenland/terrainconf (+0/-98) worlds/greenland/tree1/conf (+0/-49) worlds/winterland/ToDo - winterland (+0/-22) worlds/winterland/badger/conf (+0/-16) worlds/winterland/bunny/conf (+0/-12) worlds/winterland/bush1/conf (+0/-3) worlds/winterland/bush2/conf (+0/-3) worlds/winterland/bush3/conf (+0/-3) worlds/winterland/bush4/conf (+0/-3) worlds/winterland/bush5/conf (+0/-3) worlds/winterland/conf (+0/-94) worlds/winterland/deadtree1/conf (+0/-8) worlds/winterland/deadtree2/conf (+0/-8) worlds/winterland/deadtree3/conf (+0/-8) worlds/winterland/deadtree4/conf (+0/-8) worlds/winterland/deer/conf (+0/-14) worlds/winterland/duck/conf (+0/-9) worlds/winterland/elk/conf (+0/-16) worlds/winterland/fox/conf (+0/-16) worlds/winterland/grass1/conf (+0/-3) worlds/winterland/grass2/conf (+0/-3) worlds/winterland/grass3/conf (+0/-3) worlds/winterland/lynx/conf (+0/-16) worlds/winterland/mapgenconf (+0/-133) worlds/winterland/marten/conf (+0/-16) worlds/winterland/mushroom1/conf (+0/-3) worlds/winterland/mushroom2/conf (+0/-3) worlds/winterland/pebble1/conf (+0/-3) worlds/winterland/pebble2/conf (+0/-3) worlds/winterland/pebble3/conf (+0/-3) worlds/winterland/pebble4/conf (+0/-3) worlds/winterland/pebble5/conf (+0/-3) worlds/winterland/pebble6/conf (+0/-3) worlds/winterland/reindeer/conf (+0/-14) worlds/winterland/resconf (+0/-45) worlds/winterland/sheep/conf (+0/-15) worlds/winterland/skeleton1/conf (+0/-3) worlds/winterland/skeleton2/conf (+0/-3) worlds/winterland/skeleton3/conf (+0/-3) worlds/winterland/sstones6/conf (+0/-3) worlds/winterland/sstones7/conf (+0/-3) worlds/winterland/terrainconf (+0/-99) worlds/winterland/tree1/conf (+0/-45) worlds/winterland/tree1_m/conf (+0/-31) worlds/winterland/tree1_s/conf (+0/-28) worlds/winterland/tree1_t/conf (+0/-28) worlds/winterland/tree2/conf (+0/-42) worlds/winterland/tree2_m/conf (+0/-28) worlds/winterland/tree2_s/conf (+0/-28) worlds/winterland/tree2_t/conf (+0/-28) worlds/winterland/tree3/conf (+0/-42) worlds/winterland/tree3_m/conf (+0/-28) worlds/winterland/tree3_s/conf (+0/-28) worlds/winterland/tree3_t/conf (+0/-28) worlds/winterland/tree5/conf (+0/-40) worlds/winterland/tree5_m/conf (+0/-31) worlds/winterland/tree5_s/conf (+0/-28) worlds/winterland/tree5_t/conf (+0/-28) worlds/winterland/tree6/conf (+0/-40) worlds/winterland/tree6_m/conf (+0/-28) worlds/winterland/tree6_s/conf (+0/-28) worlds/winterland/tree6_t/conf (+0/-28) worlds/winterland/tree7/conf (+0/-40) worlds/winterland/tree7_m/conf (+0/-28) worlds/winterland/tree7_s/conf (+0/-28) worlds/winterland/tree7_t/conf (+0/-28) worlds/winterland/tree8/conf (+0/-40) worlds/winterland/tree8_m/conf (+0/-31) worlds/winterland/tree8_s/conf (+0/-28) worlds/winterland/tree8_t/conf (+0/-28) worlds/winterland/wisent/conf (+0/-16) worlds/winterland/wolf/conf (+0/-16) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/one_world | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Shevonar | Approve | ||
GunChleoc | merging world catalogues | Approve | |
SirVer | Needs Information | ||
Review via email: mp+222708@code.launchpad.net |
Commit message
Description of the change
This merges all worlds into one, converts its configuration to Lua, adds the compatibility layer to map loading needed for this.
This also regresses some issues:
- Bug 1328635 deals with terrain affinity of trees.
- Bug 1328637 deals with the hard to see road textures.
- Bug 1328640 introduces a sensible refactoring that I did not finish in this change.
There is also the outstanding issue of how to deal with translations. The worlds .pot files are gone of course, but I have no idea how to reduce them into a single one. Gun, any ideas here?
I am very open for comments on the code and design, as well as suggestion to the new bugs and ways to fixing them. I would like to merge this in the next couple of weeks, so it would be great to get some feedback.
GunChleoc (gunchleoc) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
Commented here: https:/
Set to "Needs fixing", because we still need to work this out and test ;)
SirVer (sirver) wrote : | # |
I'd rather not do the juggling with the translations in this branch/merge request. I did the test merge of all de.po of the old worlds into a new one in a new branch and pushed for inspection: https:/
It looks good to me. It worked exactly as you said :).
I think it is better to first merge this proposal and then merge the translations - otherwise the diff will be very diluted here. Agreed?
GunChleoc (gunchleoc) wrote : | # |
Yes, merge them one after the other.
I noticed that the merged translation has a good number of fuzzy strings in it. Launchpad will kill these - maybe we should upload a translation archive to the homepage to give translators access.
Alternatively, they could download the old world files first and load into their tools to fill up the translation memories, so the will get suggestions for these strings if they are working offline. for this, we would need to keep the old world files around for a bit.
GunChleoc (gunchleoc) : | # |
SirVer (sirver) wrote : | # |
Gun, let me know how you want to do the merge - i.e. announcing the merge or what. There are not that many strings in the world though, so letting the fuzzy strings die is probably alright.
GunChleoc (gunchleoc) wrote : | # |
We could give translators a heads-up in the forum thread, and I can grab an archive in case they need help.
It's not that much as you say, so this should suffice - no need for a big announcement on the homepage.
How close are we to the merge, do you want me to go ahead and post something?
SirVer (sirver) wrote : | # |
I really want to merge this ASAP. I hoped to get a code review - but it seems nobody has the time right now :(.
So grab the archive whenever you can and inform the forum.
Shevonar (shevonar) wrote : | # |
I am currently reviewing your code. I already added some small things for the first 5000 lines as inline comments. I am not yet sure how to add comments for the rest.
SirVer (sirver) wrote : | # |
Cool! I think it is easiest to just litter the code with NOCOMMIT(#sirver) or something greppable. I can then take a look at those things.
SirVer (sirver) wrote : | # |
Inline comments are fine too, of course.
Shevonar (shevonar) wrote : | # |
I changed some formatting issues and small obvious errors. I also changed documentation to doxygen comment style so it gets picked up.
Here are the remaining questions:
- Why did you hard code the compiler in compile.sh
- Why are critter sound_effect split in directory and name and not just a path to the sound file?
- widelands_
- '// TODO "stone" is defined as "granit" in the world': Can this be fixed easily? Seems to fit in the context of this commit.
- ResourceDescrip
- TerrainTypeFrom
- Uint32 in src/sound/fxset.h: What is the difference between Uint32 and uint32_t? Should it be changed?
SirVer (sirver) wrote : | # |
Thanks for the review! It is very much appreciated. You also caught some bugs that I have missed. Code reviews are such an awesome thing! nearly as good as pair programming.
> - Why did you hard code the compiler in compile.sh
good catch. gun did that and probably submitted the change by accident. I didn't see it. Reverted to trunk.
- Why are critter sound_effect split in directory and name and not just a path to the sound file?
That is legacy. The sound_handler randomly picks one file of bird_*.ogg when directory/bird is requested. I am not sure where I should document that better. Changing the sound handler to accept files explicitly (as a list instead of a glob) is probably also a good idea.
- widelands_
Removed.
- - '// TODO "stone" is defined as "granit" in the world': Can this be fixed easily? Seems to fit in the context of this commit.
that code around that area seems wrong to me. This translates attribute = { "stone" } as the name of the resource named granit. I think the correct approach would be to make attributes translatable in the world or let the building define the out of resource message in its configuration, but I did not want to touch even more code for now. I expanded the TODO with this information.
- ResourceDescrip
Well, I think I probably did write this code - way back. I agree to its complexity, I do not fully understand how it does it either, but it essentially just picks one of the defined pictures for a given resource amount. I did not want to touch it for now as this change is already too big.
> TerrainTypeFrom
It is correctly handled like this: it is a stand alone method in a .cc file in an anonymous namespace. That means that it is only visible in this .cc file where it is used.
- Uint32 in src/sound/fxset.h: What is the difference between Uint32 and uint32_t? Should it be changed?
One is the SDL typedef, one the C standard typedef. I agree to change this for consistency, but we should do it more globally. I opened bug 1330599 for that.
Please take another look.
GunChleoc (gunchleoc) wrote : | # |
I have made an announcement on the forum and am grabbing a translation archive today.
Sorry I'm a bit slow reacting to stuff, I'm travelling at the moment ;)
Shevonar (shevonar) wrote : | # |
I just took the time to understand and simplify the ResourceDescrip
You answered all the other questions, so I would say ready to merge from my side.
Shevonar (shevonar) wrote : | # |
One last thing: The diff against target in this merge request says 'Text conflict in src/graphic/
SirVer (sirver) wrote : | # |
Thanks for taking care of this and for the review in general. I'll go ahead and merge then. I also merge the translations as Gun proposed and as we already tested basically works.
TiborB (tiborb95) wrote : | # |
Hi,
this is programming-related question, I can not figure it out (no wonder
with my experiences):
I need to count fields with fishes (currently no such feature in AI), I
somehow came to this:
if (field.
map.find_
FindNodeResourc
field.fish_nearby_ = resource_
}
The problem is that it still calculates 0; so first - is the syntax OK?
Or perhaps the problem is with third argument?
I grepped the code but failed to find piece of code that I would copy/paste
and use for my purposes.
Thanks
SirVer (sirver) wrote : | # |
On 18.06.2014, at 13:21, Tibor Bamhor <email address hidden> wrote:
> Hi,
>
> this is programming-related question, I can not figure it out (no wonder
> with my experiences):
>
> I need to count fields with fishes (currently no such feature in AI), I
> somehow came to this:
>
> if (field.
> map.find_
> FindNodeResourc
this is the issue. You want to find a map resource, so you need to look up the index for the resource in the map (World:
> field.fish_nearby_ = resource_
> }
>
> The problem is that it still calculates 0; so first - is the syntax OK?
>
> Or perhaps the problem is with third argument?
>
> I grepped the code but failed to find piece of code that I would copy/paste
> and use for my purposes.
>
> Thanks
>
> --
> https:/
> Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/one_world.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
TiborB (tiborb95) wrote : | # |
Thanks - it worked!!! (no surprise)
BTW also animals (game) is not counted by now so hunters are placed blindly
- and dismantle is done so ... could you advice how to count them?
I know there is get_bob function, but there is a lot of types of animals...
2014-06-18 13:36 GMT+02:00 SirVer <email address hidden>:
>
> On 18.06.2014, at 13:21, Tibor Bamhor <email address hidden> wrote:
>
> > Hi,
> >
> > this is programming-related question, I can not figure it out (no wonder
> > with my experiences):
> >
> > I need to count fields with fishes (currently no such feature in AI), I
> > somehow came to this:
> >
> > if (field.
> > map.find_
> > FindNodeResourc
>
> this is the issue. You want to find a map resource, so you need to look up
> the index for the resource in the map (World:
>
> > field.fish_nearby_ = resource_
> > }
> >
> > The problem is that it still calculates 0; so first - is the syntax OK?
> >
> > Or perhaps the problem is with third argument?
> >
> > I grepped the code but failed to find piece of code that I would
> copy/paste
> > and use for my purposes.
> >
> > Thanks
> >
> > --
> >
> https:/
> > Your team Widelands Developers is subscribed to branch
> lp:~widelands-dev/widelands/one_world.
> >
> > _______
> > Mailing list: https:/
> > Post to : <email address hidden>
> > Unsubscribe : https:/
> > More help : https:/
>
>
> --
> https:/
> Your team Widelands Developers is subscribed to branch
> lp:~widelands-dev/widelands/one_world.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
SirVer (sirver) wrote : | # |
On 18.06.2014, at 14:00, Tibor Bamhor <email address hidden> wrote:
> Thanks - it worked!!! (no surprise)
>
> BTW also animals (game) is not counted by now so hunters are placed blindly
> - and dismantle is done so ... could you advice how to count them?
>
> I know there is get_bob function, but there is a lot of types of animals…
all of them are editable and huntable. So what?
>
>
>
> 2014-06-18 13:36 GMT+02:00 SirVer <email address hidden>:
>
>>
>> On 18.06.2014, at 13:21, Tibor Bamhor <email address hidden> wrote:
>>
>>> Hi,
>>>
>>> this is programming-related question, I can not figure it out (no wonder
>>> with my experiences):
>>>
>>> I need to count fields with fishes (currently no such feature in AI), I
>>> somehow came to this:
>>>
>>> if (field.
>>> map.find_
>>> FindNodeResourc
>>
>> this is the issue. You want to find a map resource, so you need to look up
>> the index for the resource in the map (World:
>>
>>> field.fish_nearby_ = resource_
>>> }
>>>
>>> The problem is that it still calculates 0; so first - is the syntax OK?
>>>
>>> Or perhaps the problem is with third argument?
>>>
>>> I grepped the code but failed to find piece of code that I would
>> copy/paste
>>> and use for my purposes.
>>>
>>> Thanks
>>>
>>> --
>>>
>> https:/
>>> Your team Widelands Developers is subscribed to branch
>> lp:~widelands-dev/widelands/one_world.
>>>
>>> _______
>>> Mailing list: https:/
>>> Post to : <email address hidden>
>>> Unsubscribe : https:/
>>> More help : https:/
>>
>>
>> --
>> https:/
>> Your team Widelands Developers is subscribed to branch
>> lp:~widelands-dev/widelands/one_world.
>>
>> _______
>> Mailing list: https:/
>> Post to : <email address hidden>
>> Unsubscribe : https:/
>> More help : https:/
>>
>
> --
> https:/
> Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/one_world.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
TiborB (tiborb95) wrote : | # |
That is good. I will just have to count bobs in vicinity...
2014-06-18 15:57 GMT+02:00, SirVer <email address hidden>:
>
> On 18.06.2014, at 14:00, Tibor Bamhor <email address hidden> wrote:
>
>> Thanks - it worked!!! (no surprise)
>>
>> BTW also animals (game) is not counted by now so hunters are placed
>> blindly
>> - and dismantle is done so ... could you advice how to count them?
>>
>> I know there is get_bob function, but there is a lot of types of animals…
>
> all of them are editable and huntable. So what?
>
>>
>>
>>
>> 2014-06-18 13:36 GMT+02:00 SirVer <email address hidden>:
>>
>>>
>>> On 18.06.2014, at 13:21, Tibor Bamhor <email address hidden> wrote:
>>>
>>>> Hi,
>>>>
>>>> this is programming-related question, I can not figure it out (no wonder
>>>> with my experiences):
>>>>
>>>> I need to count fields with fishes (currently no such feature in AI), I
>>>> somehow came to this:
>>>>
>>>> if (field.
>>>> map.find_
>>>> FindNodeResourc
>>>
>>> this is the issue. You want to find a map resource, so you need to look
>>> up
>>> the index for the resource in the map (World:
>>>
>>>> field.fish_nearby_ = resource_
>>>> }
>>>>
>>>> The problem is that it still calculates 0; so first - is the syntax OK?
>>>>
>>>> Or perhaps the problem is with third argument?
>>>>
>>>> I grepped the code but failed to find piece of code that I would
>>> copy/paste
>>>> and use for my purposes.
>>>>
>>>> Thanks
>>>>
>>>> --
>>>>
>>> https:/
>>>> Your team Widelands Developers is subscribed to branch
>>> lp:~widelands-dev/widelands/one_world.
>>>>
>>>> _______
>>>> Mailing list: https:/
>>>> Post to : <email address hidden>
>>>> Unsubscribe : https:/
>>>> More help : https:/
>>>
>>>
>>> --
>>> https:/
>>> Your team Widelands Developers is subscribed to branch
>>> lp:~widelands-dev/widelands/one_world.
>>>
>>> _______
>>> Mailing list: https:/
>>> Post to : <email address hidden>
>>> Unsubscribe : https:/
>>> More help : https:/
>>>
>>
>> --
>> https:/
>> Your team Widelands Developers is subscribed to branch
>> lp:~widelands-dev/widelands/one_world.
>>
>> _______
>> Mailing list: https:/
>> Post to : <email address hidden>
>> Unsubscribe : https:/
>> More help : https:/
>
>
> --
> https:/
> Your team Widelands Developers is subscribed to branch
> lp:~widelands-dev/widelands/one_world.
>
> _______
> Mailing li...
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2014-05-27 19:10:20 +0000 |
3 | +++ CMakeLists.txt 2014-06-17 15:48:25 +0000 |
4 | @@ -453,7 +453,7 @@ |
5 | global |
6 | tribes |
7 | txts |
8 | - worlds |
9 | + world |
10 | pics |
11 | scripting |
12 | DESTINATION ${WL_INSTALL_DATADIR} |
13 | |
14 | === modified file 'campaigns/t02.wmf/scripting/mission_thread.lua' |
15 | --- campaigns/t02.wmf/scripting/mission_thread.lua 2014-03-25 06:18:48 +0000 |
16 | +++ campaigns/t02.wmf/scripting/mission_thread.lua 2014-06-17 15:48:25 +0000 |
17 | @@ -322,20 +322,20 @@ |
18 | end |
19 | |
20 | force_map_immovables{ |
21 | - { "tree3", 55, 19 }, |
22 | - { "tree7_s", 58, 19 }, |
23 | - { "tree5_m", 58, 20 }, |
24 | - { "tree7", 57, 21 }, |
25 | - { "tree4_s", 54, 22 }, |
26 | - { "tree5_s", 56, 24 }, |
27 | - { "tree1", 58, 24 }, |
28 | - { "tree7_s", 56, 25 }, |
29 | - { "tree3", 53, 27 }, |
30 | - { "tree7_s", 57, 27 }, |
31 | - { "tree1_m", 52, 29 }, |
32 | - { "tree5", 54, 30 }, |
33 | - { "tree6", 55, 30 }, |
34 | - { "tree7", 56, 30 }, |
35 | + { "spruce_summer_old", 55, 19 }, |
36 | + { "larch_summer_pole", 58, 19 }, |
37 | + { "birch_summer_mature", 58, 20 }, |
38 | + { "larch_summer_old", 57, 21 }, |
39 | + { "alder_summer_pole", 54, 22 }, |
40 | + { "birch_summer_pole", 56, 24 }, |
41 | + { "aspen_summer_old", 58, 24 }, |
42 | + { "larch_summer_pole", 56, 25 }, |
43 | + { "spruce_summer_old", 53, 27 }, |
44 | + { "larch_summer_pole", 57, 27 }, |
45 | + { "aspen_summer_mature", 52, 29 }, |
46 | + { "birch_summer_pole", 54, 30 }, |
47 | + { "beech_summer_old", 55, 30 }, |
48 | + { "larch_summer_old", 56, 30 }, |
49 | { "field2", 56, 14, "barbarians" }, |
50 | { "field0s",57, 14, "barbarians" }, |
51 | { "field2", 54, 15, "barbarians" }, |
52 | |
53 | === modified file 'cmake/codecheck/rules/misused_tab' |
54 | --- cmake/codecheck/rules/misused_tab 2010-02-05 01:13:20 +0000 |
55 | +++ cmake/codecheck/rules/misused_tab 2014-06-17 15:48:25 +0000 |
56 | @@ -3,7 +3,7 @@ |
57 | |
58 | """ |
59 | This catches a tab that comes after the first non-whitespace character on a |
60 | -line. Tabs should only be used for indentation. |
61 | +line. Tabs should only be used for indentation. |
62 | """ |
63 | |
64 | error_msg = "Tabs are only allowed before the first non-whitespace character in line." |
65 | |
66 | === modified file 'cmake/codecheck/rules/space_as_indentation' |
67 | --- cmake/codecheck/rules/space_as_indentation 2010-02-05 01:13:20 +0000 |
68 | +++ cmake/codecheck/rules/space_as_indentation 2014-06-17 15:48:25 +0000 |
69 | @@ -3,17 +3,32 @@ |
70 | # |
71 | |
72 | """ |
73 | -Cry when space appears as first character on a line. Indentation should be done with tabs. |
74 | -There is no reason to have spaces as the first line |
75 | +Indentation should be done with tabs, but spaces are allowed for alignment. |
76 | |
77 | This is not obligatory for macros, because of the Alignement of the \\ at the end |
78 | """ |
79 | |
80 | +import re |
81 | + |
82 | error_msg="Use tabs for indentation." |
83 | |
84 | strip_comments_and_strings = True |
85 | strip_macros = True |
86 | -regexp = r"^ +" |
87 | + |
88 | +class EvalMatches( object ): |
89 | + STARTS_WITH_SPACES = re.compile(r"^ +") |
90 | + def __call__(self, lines, fn): |
91 | + errors = [] |
92 | + for curline, l in enumerate(lines, 1): |
93 | + if self.STARTS_WITH_SPACES.match(l): |
94 | + last_char = l.rstrip()[-1] if l.rstrip() else "" |
95 | + if last_char in ",{)": |
96 | + continue |
97 | + errors.append( (fn, curline, error_msg)) |
98 | + return errors |
99 | + |
100 | + |
101 | +evaluate_matches = EvalMatches() |
102 | |
103 | forbidden = [ |
104 | " if(a)\n", |
105 | |
106 | === modified file 'doc/sphinx/extract_rst.py' |
107 | --- doc/sphinx/extract_rst.py 2012-06-20 09:07:10 +0000 |
108 | +++ doc/sphinx/extract_rst.py 2014-06-17 15:48:25 +0000 |
109 | @@ -25,7 +25,7 @@ |
110 | Widelands. Return the base directory and the source/ directory.""" |
111 | curdir = p.abspath(p.dirname(__file__)) |
112 | source_dir = p.join(curdir, "source") |
113 | - while not (p.exists(p.join(curdir, "tribes")) and p.exists(p.join(curdir, "worlds"))): |
114 | + while not (p.exists(p.join(curdir, "tribes")) and p.exists(p.join(curdir, "world"))): |
115 | curdir = p.abspath(p.join(curdir, p.pardir)) |
116 | return source_dir, curdir |
117 | source_dir, base_dir = _find_basedir() |
118 | |
119 | === removed directory 'global/bobs' |
120 | === removed file 'global/conf' |
121 | --- global/conf 2009-01-25 19:40:02 +0000 |
122 | +++ global/conf 1970-01-01 00:00:00 +0000 |
123 | @@ -1,8 +0,0 @@ |
124 | -[immovable types] |
125 | -bar-ruin00=_Ruin of a barbarian sentry |
126 | -bar-ruin01=_Ruin of a barbarian citadel |
127 | -bar-ruin02=_Ruin of a barbarian warehouse |
128 | -bar-ruin03=_Ruin of a barbarian farm |
129 | -debris00=_Debris |
130 | -debris01=_Debris |
131 | -debris02=_Debris |
132 | |
133 | === modified file 'maps/Trident of Fire.wmf/scripting/map_editing.lua' |
134 | --- maps/Trident of Fire.wmf/scripting/map_editing.lua 2014-02-22 14:33:44 +0000 |
135 | +++ maps/Trident of Fire.wmf/scripting/map_editing.lua 2014-06-17 15:48:25 +0000 |
136 | @@ -2,14 +2,14 @@ |
137 | function automatic_forester() |
138 | |
139 | local region_to_forest = map:get_field(0,0):region(23) |
140 | - while true do |
141 | + while true do |
142 | for x,field in next,region_to_forest,f do |
143 | - if not _fully_flooded(map:get_field(field.x,field.y)) then |
144 | + if not _fully_flooded(map:get_field(field.x,field.y)) then |
145 | if map:get_field(field.x,field.y).immovable == nil then |
146 | if (field.x + field.y) % 2 == 0 then |
147 | - map:place_immovable("tree1_t", map:get_field(field.x,field.y)) |
148 | + map:place_immovable("aspen_summer_sapling", map:get_field(field.x,field.y)) |
149 | else |
150 | - map:place_immovable("tree2_t", map:get_field(field.x,field.y)) |
151 | + map:place_immovable("oak_summer_sapling", map:get_field(field.x,field.y)) |
152 | end |
153 | sleep(750) |
154 | end |
155 | @@ -109,7 +109,7 @@ |
156 | end |
157 | end |
158 | sleep(10*60*1000) |
159 | --- set back all eruptions |
160 | +-- set back all eruptions |
161 | while fields_to_erupt.size > 0 do |
162 | local ff = fields_to_erupt:pop_at(1) |
163 | local tr_to_setback = Set:new{Triangle:new(ff._f,"d")} |
164 | @@ -163,7 +163,7 @@ |
165 | local rv = { |
166 | _f = f, |
167 | _td = ter_d, |
168 | - _tr = ter_r, |
169 | + _tr = ter_r, |
170 | __hash = ("%i_%i_%s_%s"):format(f.x, f.y, ter_d, ter_r), |
171 | } |
172 | setmetatable(rv,self) |
173 | @@ -178,5 +178,3 @@ |
174 | end |
175 | return t1 |
176 | end |
177 | - |
178 | - |
179 | |
180 | === modified file 'src/ai/ai_help_structs.h' |
181 | --- src/ai/ai_help_structs.h 2014-06-16 13:33:29 +0000 |
182 | +++ src/ai/ai_help_structs.h 2014-06-17 15:48:25 +0000 |
183 | @@ -29,6 +29,8 @@ |
184 | #include "logic/game.h" |
185 | #include "logic/map.h" |
186 | #include "logic/player.h" |
187 | +#include "logic/world/terrain_description.h" |
188 | +#include "logic/world/world.h" |
189 | |
190 | namespace Widelands { |
191 | |
192 | @@ -102,10 +104,15 @@ |
193 | }; |
194 | |
195 | struct FindNodeWater { |
196 | - bool accept(const Map& map, const FCoords& coord) const { |
197 | - return (map.world().terrain_descr(coord.field->terrain_d()).get_is() & TERRAIN_WATER) || |
198 | - (map.world().terrain_descr(coord.field->terrain_r()).get_is() & TERRAIN_WATER); |
199 | + FindNodeWater(const World& world) : world_(world) {} |
200 | + |
201 | + bool accept(const Map& /* map */, const FCoords& coord) const { |
202 | + return (world_.terrain_descr(coord.field->terrain_d()).get_is() & TerrainDescription::WATER) || |
203 | + (world_.terrain_descr(coord.field->terrain_r()).get_is() & TerrainDescription::WATER); |
204 | } |
205 | + |
206 | +private: |
207 | + const World& world_; |
208 | }; |
209 | |
210 | struct FindNodeWithFlagOrRoad { |
211 | |
212 | === modified file 'src/ai/ai_hints.h' |
213 | --- src/ai/ai_hints.h 2014-06-06 20:27:28 +0000 |
214 | +++ src/ai/ai_hints.h 2014-06-17 15:48:25 +0000 |
215 | @@ -23,7 +23,7 @@ |
216 | #include <SDL_types.h> |
217 | #include <boost/noncopyable.hpp> |
218 | |
219 | -struct Section; |
220 | +class Section; |
221 | |
222 | /// This struct is used to read out the data given in [aihints] section of a |
223 | /// buildings conf file. It is used to tell the computer player about the |
224 | |
225 | === modified file 'src/ai/defaultai.cc' |
226 | --- src/ai/defaultai.cc 2014-06-16 13:24:45 +0000 |
227 | +++ src/ai/defaultai.cc 2014-06-17 15:48:25 +0000 |
228 | @@ -42,7 +42,7 @@ |
229 | #include "logic/trainingsite.h" |
230 | #include "logic/tribe.h" |
231 | #include "logic/warehouse.h" |
232 | -#include "logic/world.h" |
233 | +#include "logic/world/world.h" |
234 | #include "profile/profile.h" |
235 | #include "upcast.h" |
236 | |
237 | @@ -260,7 +260,7 @@ |
238 | |
239 | // collect information about the different buildings our tribe can construct |
240 | Building_Index const nr_buildings = tribe->get_nrbuildings(); |
241 | - const World& world = game().map().world(); |
242 | + const World & world = game().world(); |
243 | |
244 | for (Building_Index i = 0; i < nr_buildings; ++i) { |
245 | const Building_Descr& bld = *tribe->get_building_descr(i); |
246 | @@ -530,7 +530,7 @@ |
247 | std::vector<Coords> water_list; |
248 | |
249 | if (field.water_nearby_ == -1) { //-1 means "value has never been calculated" |
250 | - FindNodeWater find_water; |
251 | + FindNodeWater find_water(game().world()); |
252 | map.find_fields(Area<FCoords>(field.coords, 4), &water_list, find_water); |
253 | field.water_nearby_ = water_list.size(); |
254 | } |
255 | |
256 | === modified file 'src/description_maintainer.h' |
257 | --- src/description_maintainer.h 2014-04-21 09:19:14 +0000 |
258 | +++ src/description_maintainer.h 2014-06-17 15:48:25 +0000 |
259 | @@ -20,11 +20,13 @@ |
260 | #ifndef DESCR_MAINTAINER_H |
261 | #define DESCR_MAINTAINER_H |
262 | |
263 | -#include <cassert> |
264 | #include <map> |
265 | #include <memory> |
266 | +#include <string> |
267 | #include <vector> |
268 | |
269 | +#include "wexception.h" |
270 | + |
271 | // Used to have a typesafe maintainer for description classes. |
272 | template <typename T> struct DescriptionMaintainer { |
273 | // Adds the 'entry', will assert() if it is already registered. Returns the |
274 | @@ -62,11 +64,13 @@ |
275 | |
276 | template <typename T> |
277 | int32_t DescriptionMaintainer<T>::add(T * const item) { |
278 | - assert(exists(item->name()) == nullptr); |
279 | + if (exists(item->name()) != nullptr) { |
280 | + throw wexception("Tried to add %s twice.", item->name().c_str()); |
281 | + } |
282 | int32_t index = items_.size(); |
283 | items_.emplace_back(item); |
284 | name_to_index_[item->name()] = index; |
285 | - return index;; |
286 | + return index; |
287 | } |
288 | |
289 | template <typename T> T* DescriptionMaintainer<T>::exists(const std::string& name) const { |
290 | |
291 | === modified file 'src/economy/flag.h' |
292 | --- src/economy/flag.h 2014-04-01 18:15:56 +0000 |
293 | +++ src/economy/flag.h 2014-06-17 15:48:25 +0000 |
294 | @@ -53,11 +53,11 @@ |
295 | typedef std::vector<const WareInstance *> Wares; |
296 | |
297 | friend class Economy; |
298 | - friend struct Router; |
299 | friend class FlagQueue; |
300 | + friend class Map_Flagdata_Data_Packet; // has to read/write this to a file |
301 | friend struct Map_Ware_Data_Packet; // has to look at pending wares |
302 | friend struct Map_Waredata_Data_Packet; // has to look at pending wares |
303 | - friend struct Map_Flagdata_Data_Packet; // has to read/write this to a file |
304 | + friend struct Router; |
305 | |
306 | Flag(); /// empty flag for savegame loading |
307 | Flag(Editor_Game_Base &, Player & owner, Coords); /// create a new flag |
308 | |
309 | === modified file 'src/economy/road.h' |
310 | --- src/economy/road.h 2014-04-01 18:15:56 +0000 |
311 | +++ src/economy/road.h 2014-06-17 15:48:25 +0000 |
312 | @@ -46,8 +46,8 @@ |
313 | * road. |
314 | */ |
315 | struct Road : public PlayerImmovable { |
316 | - friend struct Map_Roaddata_Data_Packet; // For saving |
317 | - friend struct Map_Road_Data_Packet; // For init() |
318 | + friend class Map_Roaddata_Data_Packet; // For saving |
319 | + friend class Map_Road_Data_Packet; // For init() |
320 | |
321 | static bool IsRoadDescr(Map_Object_Descr const *); |
322 | |
323 | |
324 | === modified file 'src/economy/test/test_road.cc' |
325 | --- src/economy/test/test_road.cc 2014-02-22 18:04:02 +0000 |
326 | +++ src/economy/test/test_road.cc 2014-06-17 15:48:25 +0000 |
327 | @@ -27,6 +27,10 @@ |
328 | #include "logic/instances.h" |
329 | #include "logic/player.h" |
330 | |
331 | +namespace Widelands { |
332 | +class World; |
333 | +} // namespace Widelands |
334 | + |
335 | using namespace Widelands; |
336 | |
337 | /******************/ |
338 | @@ -41,7 +45,7 @@ |
339 | struct TestingMap : public Map { |
340 | TestingMap(int const w, int const h) : Map() {set_size(w, h);} |
341 | |
342 | - virtual void recalc_for_field_area(Area<FCoords>) override {} |
343 | + virtual void recalc_for_field_area(const World&, Area<FCoords>) override {} |
344 | |
345 | }; |
346 | |
347 | @@ -102,4 +106,3 @@ |
348 | } |
349 | |
350 | BOOST_AUTO_TEST_SUITE_END() |
351 | - |
352 | |
353 | === modified file 'src/economy/wares_queue.h' |
354 | --- src/economy/wares_queue.h 2014-04-21 10:00:16 +0000 |
355 | +++ src/economy/wares_queue.h 2014-06-17 15:48:25 +0000 |
356 | @@ -32,7 +32,6 @@ |
357 | struct Map_Map_Object_Saver; |
358 | class Player; |
359 | class Request; |
360 | -class WaresQueue; |
361 | class Worker; |
362 | |
363 | /** |
364 | |
365 | === modified file 'src/editor/editorinteractive.cc' |
366 | --- src/editor/editorinteractive.cc 2014-06-10 20:38:57 +0000 |
367 | +++ src/editor/editorinteractive.cc 2014-06-17 15:48:25 +0000 |
368 | @@ -38,6 +38,8 @@ |
369 | #include "logic/map.h" |
370 | #include "logic/player.h" |
371 | #include "logic/tribe.h" |
372 | +#include "logic/world/resource_description.h" |
373 | +#include "logic/world/world.h" |
374 | #include "map_io/widelands_map_loader.h" |
375 | #include "profile/profile.h" |
376 | #include "scoped_timer.h" |
377 | @@ -110,8 +112,10 @@ |
378 | m_toggle_minimap.sigclicked.connect(boost::bind(&Editor_Interactive::toggle_minimap, this)); |
379 | m_toggle_buildhelp.sigclicked.connect(boost::bind(&Editor_Interactive::toggle_buildhelp, this)); |
380 | m_toggle_player_menu.sigclicked.connect(boost::bind(&Editor_Interactive::toggle_playermenu, this)); |
381 | - m_undo.sigclicked.connect(boost::bind(&Editor_History::undo_action, &m_history)); |
382 | - m_redo.sigclicked.connect(boost::bind(&Editor_History::redo_action, &m_history)); |
383 | + m_undo.sigclicked.connect( |
384 | + boost::bind(&Editor_History::undo_action, &m_history, boost::cref(egbase().world()))); |
385 | + m_redo.sigclicked.connect( |
386 | + boost::bind(&Editor_History::redo_action, &m_history, boost::cref(egbase().world()))); |
387 | |
388 | m_toolbar.set_layout_toplevel(true); |
389 | m_toolbar.add(&m_toggle_main_menu, UI::Box::AlignLeft); |
390 | @@ -155,17 +159,14 @@ |
391 | |
392 | // Resources: we do not calculate default resources, therefore we do not |
393 | // expect to meet them here. |
394 | - const Widelands::World & world = map.world(); |
395 | - OverlayManager & overlay_manager = map.overlay_manager(); |
396 | - Widelands::Extent const extent = map.extent(); |
397 | + OverlayManager& overlay_manager = map.overlay_manager(); |
398 | + Widelands::Extent const extent = map.extent(); |
399 | iterate_Map_FCoords(map, extent, fc) { |
400 | if (uint8_t const amount = fc.field->get_resources_amount()) { |
401 | - const std::string & immname = |
402 | - world.get_resource(fc.field->get_resources())->get_editor_pic |
403 | - (amount); |
404 | + const std::string& immname = |
405 | + egbase().world().get_resource(fc.field->get_resources())->get_editor_pic(amount); |
406 | if (immname.size()) |
407 | - overlay_manager.register_overlay |
408 | - (fc, g_gr->images().get(immname), 4); |
409 | + overlay_manager.register_overlay(fc, g_gr->images().get(immname), 4); |
410 | } |
411 | } |
412 | |
413 | @@ -183,36 +184,30 @@ |
414 | egbase().cleanup_for_load(); |
415 | m_history.reset(); |
416 | |
417 | - std::unique_ptr<Widelands::Map_Loader> const ml(map.get_correct_loader(filename)); |
418 | + std::unique_ptr<Widelands::Map_Loader> ml(map.get_correct_loader(filename)); |
419 | if (not ml.get()) |
420 | throw warning |
421 | (_("Unsupported format"), |
422 | _("Widelands could not load the file \"%s\". The file format seems to be incompatible."), |
423 | filename.c_str()); |
424 | + ml->preload_map(true); |
425 | |
426 | UI::ProgressWindow loader_ui("pics/editor.jpg"); |
427 | std::vector<std::string> tipstext; |
428 | tipstext.push_back("editor"); |
429 | + |
430 | + m_history.reset(); |
431 | + |
432 | GameTips editortips(loader_ui, tipstext); |
433 | |
434 | - { |
435 | - std::string const old_world_name = map.get_world_name(); |
436 | - ml->preload_map(true); |
437 | - if (strcmp(map.get_world_name(), old_world_name.c_str())) |
438 | - change_world(); |
439 | - } |
440 | load_all_tribes(&egbase(), &loader_ui); |
441 | |
442 | // Create the players. TODO SirVer this must be managed better |
443 | loader_ui.step(_("Creating players")); |
444 | iterate_player_numbers(p, map.get_nrplayers()) { |
445 | - egbase().add_player |
446 | - (p, 0, map.get_scenario_player_tribe(p), |
447 | - map.get_scenario_player_name(p)); |
448 | + egbase().add_player(p, 0, map.get_scenario_player_tribe(p), map.get_scenario_player_name(p)); |
449 | } |
450 | |
451 | - loader_ui.step(_("Loading world data")); |
452 | - ml->load_world(); |
453 | ml->load_map_complete(egbase(), true); |
454 | loader_ui.step(_("Loading graphics...")); |
455 | egbase().load_graphics(loader_ui); |
456 | @@ -279,7 +274,7 @@ |
457 | void Editor_Interactive::map_clicked(bool should_draw) { |
458 | m_history.do_action |
459 | (tools.current(), |
460 | - tools.use_tool, egbase().map(), |
461 | + tools.use_tool, egbase().map(), egbase().world(), |
462 | get_sel_pos(), *this, should_draw); |
463 | need_complete_redraw(); |
464 | set_need_save(true); |
465 | @@ -469,14 +464,14 @@ |
466 | |
467 | case SDLK_z: |
468 | if ((code.mod & (KMOD_LCTRL | KMOD_RCTRL)) && (code.mod & (KMOD_LSHIFT | KMOD_RSHIFT))) |
469 | - m_history.redo_action(); |
470 | + m_history.redo_action(egbase().world()); |
471 | else if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) |
472 | - m_history.undo_action(); |
473 | + m_history.undo_action(egbase().world()); |
474 | handled = true; |
475 | break; |
476 | case SDLK_y: |
477 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) |
478 | - m_history.redo_action(); |
479 | + m_history.redo_action(egbase().world()); |
480 | handled = true; |
481 | break; |
482 | default: |
483 | @@ -512,8 +507,7 @@ |
484 | // A new tool has been selected. Remove all registered overlay callback |
485 | // functions. |
486 | map.overlay_manager().remove_overlay_callback_function(); |
487 | - map.recalc_whole_map(); |
488 | - |
489 | + map.recalc_whole_map(egbase().world()); |
490 | } |
491 | tools.current_pointer = &primary; |
492 | tools.use_tool = which; |
493 | @@ -579,17 +573,7 @@ |
494 | return false; |
495 | } |
496 | |
497 | - |
498 | -void Editor_Interactive::change_world() { |
499 | - m_history.reset(); |
500 | - delete m_terrainmenu .window; |
501 | - delete m_immovablemenu.window; |
502 | - delete m_bobmenu .window; |
503 | - delete m_resourcesmenu.window; |
504 | -} |
505 | - |
506 | - |
507 | -void Editor_Interactive::run_editor(const std::string & filename, const std::string& script_to_run) { |
508 | +void Editor_Interactive::run_editor(const std::string& filename, const std::string& script_to_run) { |
509 | Widelands::Editor_Game_Base editor(nullptr); |
510 | Editor_Interactive eia(editor); |
511 | editor.set_ibase(&eia); // TODO get rid of this |
512 | @@ -604,10 +588,12 @@ |
513 | editor.set_map(&map); |
514 | if (filename.empty()) { |
515 | loader_ui.step("Creating empty map..."); |
516 | - map.create_empty_map |
517 | - (64, 64, "greenland", _("No Name"), |
518 | - g_options.pull_section("global").get_string |
519 | - ("realname", _("Unknown"))); |
520 | + map.create_empty_map( |
521 | + editor.world(), |
522 | + 64, |
523 | + 64, |
524 | + _("No Name"), |
525 | + g_options.pull_section("global").get_string("realname", _("Unknown"))); |
526 | |
527 | load_all_tribes(&editor, &loader_ui); |
528 | |
529 | |
530 | === modified file 'src/editor/editorinteractive.h' |
531 | --- src/editor/editorinteractive.h 2014-04-20 20:02:13 +0000 |
532 | +++ src/editor/editorinteractive.h 2014-06-17 15:48:25 +0000 |
533 | @@ -81,7 +81,6 @@ |
534 | place_bob(delete_bob), |
535 | increase_resources(decrease_resources, set_resources), |
536 | set_port_space(unset_port_space) |
537 | - |
538 | {} |
539 | Editor_Tool & current() const {return *current_pointer;} |
540 | typedef std::vector<Editor_Tool *> Tool_Vector; |
541 | @@ -121,10 +120,6 @@ |
542 | bool is_player_tribe_referenced(Widelands::Player_Number); |
543 | void set_need_save(bool const t) {m_need_save = t;} |
544 | |
545 | - /// Must be called when the world is changed. Takes care of closing the tool |
546 | - /// menus that are showing elements from the old world. |
547 | - void change_world(); |
548 | - |
549 | private: |
550 | void toggle_buildhelp(); |
551 | void tool_menu_btn(); |
552 | |
553 | === modified file 'src/editor/tools/editor_decrease_height_tool.cc' |
554 | --- src/editor/tools/editor_decrease_height_tool.cc 2013-07-26 20:19:36 +0000 |
555 | +++ src/editor/tools/editor_decrease_height_tool.cc 2014-06-17 15:48:25 +0000 |
556 | @@ -27,12 +27,11 @@ |
557 | #include "logic/mapregion.h" |
558 | |
559 | /// Decreases the heights by a value. Chages surrounding nodes if necessary. |
560 | -int32_t Editor_Decrease_Height_Tool::handle_click_impl |
561 | - (Widelands::Map & map, |
562 | - Widelands::Node_and_Triangle<> center, |
563 | - Editor_Interactive & /* parent */, |
564 | - Editor_Action_Args & args) |
565 | -{ |
566 | +int32_t Editor_Decrease_Height_Tool::handle_click_impl(Widelands::Map& map, |
567 | + const Widelands::World& world, |
568 | + Widelands::Node_and_Triangle<> center, |
569 | + Editor_Interactive& /* parent */, |
570 | + Editor_Action_Args& args) { |
571 | if (args.origHights.empty()) { |
572 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
573 | (map, |
574 | @@ -42,15 +41,15 @@ |
575 | while (mr.advance(map)); |
576 | } |
577 | |
578 | - return |
579 | - map.change_height |
580 | - (Widelands::Area<Widelands::FCoords> |
581 | - (map.get_fcoords(center.node), args.sel_radius), |
582 | - -args.change_by); |
583 | + return map.change_height( |
584 | + world, |
585 | + Widelands::Area<Widelands::FCoords>(map.get_fcoords(center.node), args.sel_radius), |
586 | + -args.change_by); |
587 | } |
588 | |
589 | int32_t Editor_Decrease_Height_Tool::handle_undo_impl |
590 | (Widelands::Map & map, |
591 | + const Widelands::World& world, |
592 | Widelands::Node_and_Triangle<> center, |
593 | Editor_Interactive & /* parent */, |
594 | Editor_Action_Args & args) |
595 | @@ -65,10 +64,10 @@ |
596 | mr.location().field->set_height(*i); ++i; |
597 | } while (mr.advance(map)); |
598 | |
599 | - map.recalc_for_field_area |
600 | - (Widelands::Area<Widelands::FCoords> |
601 | - (map.get_fcoords(center.node), |
602 | - args.sel_radius + MAX_FIELD_HEIGHT / MAX_FIELD_HEIGHT_DIFF + 2)); |
603 | + map.recalc_for_field_area(world, |
604 | + Widelands::Area<Widelands::FCoords>( |
605 | + map.get_fcoords(center.node), |
606 | + args.sel_radius + MAX_FIELD_HEIGHT / MAX_FIELD_HEIGHT_DIFF + 2)); |
607 | |
608 | return mr.radius() + 1; |
609 | } |
610 | @@ -79,5 +78,3 @@ |
611 | a.change_by = m_change_by; |
612 | return a; |
613 | } |
614 | - |
615 | - |
616 | |
617 | === modified file 'src/editor/tools/editor_decrease_height_tool.h' |
618 | --- src/editor/tools/editor_decrease_height_tool.h 2014-02-22 18:04:02 +0000 |
619 | +++ src/editor/tools/editor_decrease_height_tool.h 2014-06-17 15:48:25 +0000 |
620 | @@ -27,11 +27,15 @@ |
621 | Editor_Decrease_Height_Tool() : Editor_Tool(*this, *this), m_change_by(1) {} |
622 | |
623 | int32_t handle_click_impl |
624 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
625 | + (Widelands::Map & map, |
626 | + const Widelands::World& world, |
627 | + Widelands::Node_and_Triangle<> center, |
628 | Editor_Interactive & parent, Editor_Action_Args & args) override; |
629 | |
630 | int32_t handle_undo_impl |
631 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
632 | + (Widelands::Map & map, |
633 | + const Widelands::World& world, |
634 | + Widelands::Node_and_Triangle<> center, |
635 | Editor_Interactive & parent, Editor_Action_Args & args) override; |
636 | |
637 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
638 | |
639 | === modified file 'src/editor/tools/editor_decrease_resources_tool.cc' |
640 | --- src/editor/tools/editor_decrease_resources_tool.cc 2014-03-09 18:32:29 +0000 |
641 | +++ src/editor/tools/editor_decrease_resources_tool.cc 2014-06-17 15:48:25 +0000 |
642 | @@ -26,7 +26,8 @@ |
643 | #include "logic/field.h" |
644 | #include "logic/mapregion.h" |
645 | #include "logic/widelands_geometry.h" |
646 | -#include "logic/world.h" |
647 | +#include "logic/world/resource_description.h" |
648 | +#include "logic/world/world.h" |
649 | #include "wui/overlay_manager.h" |
650 | |
651 | |
652 | @@ -34,12 +35,12 @@ |
653 | * Decrease the resources of the current field by one if |
654 | * there is not already another resource there. |
655 | */ |
656 | -int32_t Editor_Decrease_Resources_Tool::handle_click_impl |
657 | - (Widelands::Map & map, |
658 | - Widelands::Node_and_Triangle<> const center, |
659 | - Editor_Interactive & /* parent */, |
660 | - Editor_Action_Args & args) |
661 | -{ |
662 | +int32_t |
663 | +Editor_Decrease_Resources_Tool::handle_click_impl(Widelands::Map& map, |
664 | + const Widelands::World& world, |
665 | + Widelands::Node_and_Triangle<> const center, |
666 | + Editor_Interactive& /* parent */, |
667 | + Editor_Action_Args& args) { |
668 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
669 | (map, |
670 | Widelands::Area<Widelands::FCoords> |
671 | @@ -55,14 +56,11 @@ |
672 | args.orgResT.push_back(res); |
673 | args.orgRes.push_back(mr.location().field->get_resources_amount()); |
674 | |
675 | - if |
676 | - (res == args.cur_res |
677 | - and |
678 | - Editor_Change_Resource_Tool_Callback(mr.location(), map, args.cur_res)) |
679 | - { |
680 | + if (res == args.cur_res && |
681 | + Editor_Change_Resource_Tool_Callback(mr.location(), map, world, args.cur_res)) { |
682 | // Ok, we're doing something. First remove the current overlays. |
683 | std::string str = |
684 | - map.world().get_resource(res)->get_editor_pic |
685 | + world.get_resource(res)->get_editor_pic |
686 | (mr.location().field->get_resources_amount()); |
687 | const Image* pic = g_gr->images().get(str); |
688 | map.overlay_manager().remove_overlay(mr.location(), pic); |
689 | @@ -73,24 +71,24 @@ |
690 | mr.location().field->set_resources(args.cur_res, amount); |
691 | mr.location().field->set_starting_res_amount(amount); |
692 | // set new overlay |
693 | - str = map.world().get_resource(args.cur_res)->get_editor_pic(amount); |
694 | + str = world.get_resource(args.cur_res)->get_editor_pic(amount); |
695 | pic = g_gr->images().get(str); |
696 | map.overlay_manager().register_overlay(mr.location(), pic, 4); |
697 | - map.recalc_for_field_area |
698 | - (Widelands::Area<Widelands::FCoords>(mr.location(), 0)); |
699 | + map.recalc_for_field_area( |
700 | + world, Widelands::Area<Widelands::FCoords>(mr.location(), 0)); |
701 | } |
702 | } |
703 | } while (mr.advance(map)); |
704 | return mr.radius(); |
705 | } |
706 | |
707 | -int32_t Editor_Decrease_Resources_Tool::handle_undo_impl |
708 | - (Widelands::Map & map, |
709 | - Widelands::Node_and_Triangle< Widelands::Coords > center, |
710 | - Editor_Interactive & parent, |
711 | - Editor_Action_Args & args) |
712 | -{ |
713 | - return parent.tools.set_resources.handle_undo_impl(map, center, parent, args); |
714 | +int32_t Editor_Decrease_Resources_Tool::handle_undo_impl( |
715 | + Widelands::Map& map, |
716 | + const Widelands::World& world, |
717 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
718 | + Editor_Interactive& parent, |
719 | + Editor_Action_Args& args) { |
720 | + return parent.tools.set_resources.handle_undo_impl(map, world, center, parent, args); |
721 | } |
722 | |
723 | Editor_Action_Args Editor_Decrease_Resources_Tool::format_args_impl(Editor_Interactive & parent) |
724 | |
725 | === modified file 'src/editor/tools/editor_decrease_resources_tool.h' |
726 | --- src/editor/tools/editor_decrease_resources_tool.h 2014-02-22 18:04:02 +0000 |
727 | +++ src/editor/tools/editor_decrease_resources_tool.h 2014-06-17 15:48:25 +0000 |
728 | @@ -21,7 +21,6 @@ |
729 | #define EDITOR_DECREASE_RESOURCES_TOOL_H |
730 | |
731 | #include "editor/tools/editor_tool.h" |
732 | -#include "logic/world.h" |
733 | |
734 | /// Decreases the resources of a node by a value. |
735 | struct Editor_Decrease_Resources_Tool : public Editor_Tool { |
736 | @@ -29,13 +28,17 @@ |
737 | : Editor_Tool(*this, *this), m_cur_res(0), m_change_by(1) |
738 | {} |
739 | |
740 | - int32_t handle_click_impl |
741 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
742 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
743 | + int32_t handle_click_impl(Widelands::Map& map, |
744 | + const Widelands::World& world, |
745 | + Widelands::Node_and_Triangle<> center, |
746 | + Editor_Interactive& parent, |
747 | + Editor_Action_Args& args) override; |
748 | |
749 | - int32_t handle_undo_impl |
750 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
751 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
752 | + int32_t handle_undo_impl(Widelands::Map& map, |
753 | + const Widelands::World& world, |
754 | + Widelands::Node_and_Triangle<> center, |
755 | + Editor_Interactive& parent, |
756 | + Editor_Action_Args& args) override; |
757 | |
758 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
759 | |
760 | @@ -52,7 +55,7 @@ |
761 | |
762 | private: |
763 | Widelands::Resource_Index m_cur_res; |
764 | - int32_t m_change_by; |
765 | + int32_t m_change_by; |
766 | }; |
767 | |
768 | #endif |
769 | |
770 | === modified file 'src/editor/tools/editor_delete_bob_tool.cc' |
771 | --- src/editor/tools/editor_delete_bob_tool.cc 2013-07-26 20:19:36 +0000 |
772 | +++ src/editor/tools/editor_delete_bob_tool.cc 2014-06-17 15:48:25 +0000 |
773 | @@ -27,10 +27,12 @@ |
774 | /** |
775 | * Deletes the bob at the given location |
776 | */ |
777 | -int32_t Editor_Delete_Bob_Tool::handle_click_impl |
778 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
779 | - Editor_Interactive & parent, Editor_Action_Args & args) |
780 | -{ |
781 | +int32_t |
782 | +Editor_Delete_Bob_Tool::handle_click_impl(Widelands::Map& map, |
783 | + const Widelands::World&, |
784 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
785 | + Editor_Interactive& parent, |
786 | + Editor_Action_Args& args) { |
787 | Widelands::Editor_Game_Base & egbase = parent.egbase(); |
788 | const int32_t radius = args.sel_radius; |
789 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
790 | @@ -48,12 +50,14 @@ |
791 | return radius + 2; |
792 | } |
793 | |
794 | -int32_t Editor_Delete_Bob_Tool::handle_undo_impl |
795 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
796 | - Editor_Interactive & parent, Editor_Action_Args & args) |
797 | -{ |
798 | +int32_t |
799 | +Editor_Delete_Bob_Tool::handle_undo_impl(Widelands::Map& map, |
800 | + const Widelands::World& world, |
801 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
802 | + Editor_Interactive& parent, |
803 | + Editor_Action_Args& args) { |
804 | |
805 | - uint32_t ret = parent.tools.place_bob.handle_undo_impl(map, center, parent, args); |
806 | + uint32_t ret = parent.tools.place_bob.handle_undo_impl(map, world, center, parent, args); |
807 | args.obob_type.clear(); |
808 | return ret; |
809 | } |
810 | @@ -62,5 +66,3 @@ |
811 | { |
812 | return Editor_Tool::format_args_impl(parent); |
813 | } |
814 | - |
815 | - |
816 | |
817 | === modified file 'src/editor/tools/editor_delete_bob_tool.h' |
818 | --- src/editor/tools/editor_delete_bob_tool.h 2014-02-22 18:04:02 +0000 |
819 | +++ src/editor/tools/editor_delete_bob_tool.h 2014-06-17 15:48:25 +0000 |
820 | @@ -26,13 +26,17 @@ |
821 | struct Editor_Delete_Bob_Tool : public Editor_Tool { |
822 | Editor_Delete_Bob_Tool() : Editor_Tool(*this, *this) {} |
823 | |
824 | - int32_t handle_click_impl |
825 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
826 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
827 | + int32_t handle_click_impl(Widelands::Map& map, |
828 | + const Widelands::World& world, |
829 | + Widelands::Node_and_Triangle<> center, |
830 | + Editor_Interactive& parent, |
831 | + Editor_Action_Args& args) override; |
832 | |
833 | - int32_t handle_undo_impl |
834 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
835 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
836 | + int32_t handle_undo_impl(Widelands::Map& map, |
837 | + const Widelands::World& world, |
838 | + Widelands::Node_and_Triangle<> center, |
839 | + Editor_Interactive& parent, |
840 | + Editor_Action_Args& args) override; |
841 | |
842 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
843 | |
844 | |
845 | === modified file 'src/editor/tools/editor_delete_immovable_tool.cc' |
846 | --- src/editor/tools/editor_delete_immovable_tool.cc 2013-07-26 20:19:36 +0000 |
847 | +++ src/editor/tools/editor_delete_immovable_tool.cc 2014-06-17 15:48:25 +0000 |
848 | @@ -28,12 +28,11 @@ |
849 | /** |
850 | * Deletes the immovable at the given location |
851 | */ |
852 | -int32_t Editor_Delete_Immovable_Tool::handle_click_impl |
853 | - (Widelands::Map & map, |
854 | - Widelands::Node_and_Triangle<> const center, |
855 | - Editor_Interactive & parent, |
856 | - Editor_Action_Args & args) |
857 | -{ |
858 | +int32_t Editor_Delete_Immovable_Tool::handle_click_impl(Widelands::Map& map, |
859 | + const Widelands::World&, |
860 | + Widelands::Node_and_Triangle<> const center, |
861 | + Editor_Interactive& parent, |
862 | + Editor_Action_Args& args) { |
863 | Widelands::Editor_Game_Base & egbase = parent.egbase(); |
864 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
865 | (map, |
866 | @@ -54,15 +53,16 @@ |
867 | return mr.radius() + 2; |
868 | } |
869 | |
870 | -int32_t Editor_Delete_Immovable_Tool::handle_undo_impl |
871 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
872 | - Editor_Interactive & parent, Editor_Action_Args & args) |
873 | -{ |
874 | - return parent.tools.place_immovable.handle_undo_impl(map, center, parent, args); |
875 | +int32_t Editor_Delete_Immovable_Tool::handle_undo_impl( |
876 | + Widelands::Map& map, |
877 | + const Widelands::World& world, |
878 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
879 | + Editor_Interactive& parent, |
880 | + Editor_Action_Args& args) { |
881 | + return parent.tools.place_immovable.handle_undo_impl(map, world, center, parent, args); |
882 | } |
883 | |
884 | Editor_Action_Args Editor_Delete_Immovable_Tool::format_args_impl(Editor_Interactive & parent) |
885 | { |
886 | return Editor_Tool::format_args_impl(parent); |
887 | } |
888 | - |
889 | |
890 | === modified file 'src/editor/tools/editor_delete_immovable_tool.h' |
891 | --- src/editor/tools/editor_delete_immovable_tool.h 2014-02-22 18:04:02 +0000 |
892 | +++ src/editor/tools/editor_delete_immovable_tool.h 2014-06-17 15:48:25 +0000 |
893 | @@ -26,13 +26,17 @@ |
894 | struct Editor_Delete_Immovable_Tool : public Editor_Tool { |
895 | Editor_Delete_Immovable_Tool() : Editor_Tool(*this, *this) {} |
896 | |
897 | - int32_t handle_click_impl |
898 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
899 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
900 | + int32_t handle_click_impl(Widelands::Map& map, |
901 | + const Widelands::World& world, |
902 | + Widelands::Node_and_Triangle<> center, |
903 | + Editor_Interactive& parent, |
904 | + Editor_Action_Args& args) override; |
905 | |
906 | - int32_t handle_undo_impl |
907 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
908 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
909 | + int32_t handle_undo_impl(Widelands::Map& map, |
910 | + const Widelands::World& world, |
911 | + Widelands::Node_and_Triangle<> center, |
912 | + Editor_Interactive& parent, |
913 | + Editor_Action_Args& args) override; |
914 | |
915 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
916 | |
917 | |
918 | === modified file 'src/editor/tools/editor_draw_tool.cc' |
919 | --- src/editor/tools/editor_draw_tool.cc 2013-07-26 20:19:36 +0000 |
920 | +++ src/editor/tools/editor_draw_tool.cc 2014-06-17 15:48:25 +0000 |
921 | @@ -36,10 +36,12 @@ |
922 | args.draw_actions.push_back(new Editor_Tool_Action(ac)); |
923 | } |
924 | |
925 | -int32_t Editor_Draw_Tool::handle_click_impl |
926 | - (Widelands::Map & /* map */, Widelands::Node_and_Triangle<Widelands::Coords> /* center */, |
927 | - Editor_Interactive & /* parent */, Editor_Action_Args & args) |
928 | -{ |
929 | +int32_t |
930 | +Editor_Draw_Tool::handle_click_impl(Widelands::Map& /* map */, |
931 | + const Widelands::World& world, |
932 | + Widelands::Node_and_Triangle<Widelands::Coords> /* center */, |
933 | + Editor_Interactive& /* parent */, |
934 | + Editor_Action_Args& args) { |
935 | |
936 | for |
937 | (std::list<Editor_Tool_Action *>::iterator i = args.draw_actions.begin(); |
938 | @@ -48,15 +50,17 @@ |
939 | { |
940 | (*i)->tool.handle_click |
941 | (static_cast<Editor_Tool::Tool_Index>((*i)->i), |
942 | - (*i)->map, (*i)->center, (*i)->parent, *((*i)->args)); |
943 | + (*i)->map, world, (*i)->center, (*i)->parent, *((*i)->args)); |
944 | } |
945 | return args.draw_actions.size(); |
946 | } |
947 | |
948 | -int32_t Editor_Draw_Tool::handle_undo_impl |
949 | - (Widelands::Map & /* map */, Widelands::Node_and_Triangle<Widelands::Coords> /* center */, |
950 | - Editor_Interactive & /* parent */, Editor_Action_Args & args) |
951 | -{ |
952 | +int32_t |
953 | +Editor_Draw_Tool::handle_undo_impl(Widelands::Map& /* map */, |
954 | + const Widelands::World& world, |
955 | + Widelands::Node_and_Triangle<Widelands::Coords> /* center */, |
956 | + Editor_Interactive& /* parent */, |
957 | + Editor_Action_Args& args) { |
958 | for |
959 | (std::list<Editor_Tool_Action *>::reverse_iterator i = args.draw_actions.rbegin(); |
960 | i != args.draw_actions.rend(); |
961 | @@ -64,7 +68,7 @@ |
962 | { |
963 | (*i)->tool.handle_undo |
964 | (static_cast<Editor_Tool::Tool_Index>((*i)->i), |
965 | - (*i)->map, (*i)->center, (*i)->parent, *((*i)->args)); |
966 | + (*i)->map, world, (*i)->center, (*i)->parent, *((*i)->args)); |
967 | } |
968 | return args.draw_actions.size(); |
969 | } |
970 | |
971 | === modified file 'src/editor/tools/editor_draw_tool.h' |
972 | --- src/editor/tools/editor_draw_tool.h 2014-02-22 18:04:02 +0000 |
973 | +++ src/editor/tools/editor_draw_tool.h 2014-06-17 15:48:25 +0000 |
974 | @@ -28,13 +28,17 @@ |
975 | struct Editor_Draw_Tool : public Editor_Tool { |
976 | Editor_Draw_Tool() : Editor_Tool(*this, *this) {} |
977 | |
978 | - int32_t handle_click_impl |
979 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
980 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
981 | + int32_t handle_click_impl(Widelands::Map& map, |
982 | + const Widelands::World& world, |
983 | + Widelands::Node_and_Triangle<> center, |
984 | + Editor_Interactive& parent, |
985 | + Editor_Action_Args& args) override; |
986 | |
987 | - int32_t handle_undo_impl |
988 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
989 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
990 | + int32_t handle_undo_impl(Widelands::Map& map, |
991 | + const Widelands::World& world, |
992 | + Widelands::Node_and_Triangle<> center, |
993 | + Editor_Interactive& parent, |
994 | + Editor_Action_Args& args) override; |
995 | |
996 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
997 | |
998 | @@ -47,4 +51,3 @@ |
999 | }; |
1000 | |
1001 | #endif |
1002 | - |
1003 | |
1004 | === modified file 'src/editor/tools/editor_history.cc' |
1005 | --- src/editor/tools/editor_history.cc 2013-07-26 20:19:36 +0000 |
1006 | +++ src/editor/tools/editor_history.cc 2014-06-17 15:48:25 +0000 |
1007 | @@ -55,8 +55,7 @@ |
1008 | |
1009 | // === Editor_History === // |
1010 | |
1011 | -uint32_t Editor_History::undo_action() |
1012 | -{ |
1013 | +uint32_t Editor_History::undo_action(const Widelands::World& world) { |
1014 | if (undo_stack.empty()) |
1015 | return 0; |
1016 | |
1017 | @@ -67,14 +66,15 @@ |
1018 | m_undo_button.set_enabled(!undo_stack.empty()); |
1019 | m_redo_button.set_enabled(true); |
1020 | |
1021 | - return |
1022 | - uac.tool.handle_undo |
1023 | - (static_cast<Editor_Tool::Tool_Index>(uac.i), |
1024 | - uac.map, uac.center, uac.parent, *uac.args); |
1025 | + return uac.tool.handle_undo(static_cast<Editor_Tool::Tool_Index>(uac.i), |
1026 | + uac.map, |
1027 | + world, |
1028 | + uac.center, |
1029 | + uac.parent, |
1030 | + *uac.args); |
1031 | } |
1032 | |
1033 | -uint32_t Editor_History::redo_action() |
1034 | -{ |
1035 | +uint32_t Editor_History::redo_action(const Widelands::World& world) { |
1036 | if (redo_stack.empty()) |
1037 | return 0; |
1038 | |
1039 | @@ -85,20 +85,21 @@ |
1040 | m_undo_button.set_enabled(true); |
1041 | m_redo_button.set_enabled(!redo_stack.empty()); |
1042 | |
1043 | - return |
1044 | - rac.tool.handle_click |
1045 | - (static_cast<Editor_Tool::Tool_Index>(rac.i), |
1046 | - rac.map, rac.center, rac.parent, *rac.args); |
1047 | + return rac.tool.handle_click(static_cast<Editor_Tool::Tool_Index>(rac.i), |
1048 | + rac.map, |
1049 | + world, |
1050 | + rac.center, |
1051 | + rac.parent, |
1052 | + *rac.args); |
1053 | } |
1054 | |
1055 | -uint32_t Editor_History::do_action |
1056 | - (Editor_Tool & tool, |
1057 | - Editor_Tool::Tool_Index ind, |
1058 | - Widelands::Map & map, |
1059 | - const Widelands::Node_and_Triangle< Widelands::Coords > center, |
1060 | - Editor_Interactive & parent, |
1061 | - bool draw) |
1062 | -{ |
1063 | +uint32_t Editor_History::do_action(Editor_Tool& tool, |
1064 | + Editor_Tool::Tool_Index ind, |
1065 | + Widelands::Map& map, |
1066 | + const Widelands::World& world, |
1067 | + const Widelands::Node_and_Triangle<Widelands::Coords> center, |
1068 | + Editor_Interactive& parent, |
1069 | + bool draw) { |
1070 | Editor_Tool_Action ac |
1071 | (tool, static_cast<uint32_t>(ind), |
1072 | map, center, parent, tool.format_args(ind, parent)); |
1073 | @@ -130,7 +131,7 @@ |
1074 | m_undo_button.set_enabled(true); |
1075 | m_redo_button.set_enabled(false); |
1076 | } |
1077 | - return tool.handle_click(ind, map, center, parent, *ac.args); |
1078 | + return tool.handle_click(ind, map, world, center, parent, *ac.args); |
1079 | } |
1080 | |
1081 | |
1082 | @@ -141,4 +142,3 @@ |
1083 | m_undo_button.set_enabled(false); |
1084 | m_redo_button.set_enabled(false); |
1085 | } |
1086 | - |
1087 | |
1088 | === modified file 'src/editor/tools/editor_history.h' |
1089 | --- src/editor/tools/editor_history.h 2013-07-26 20:19:36 +0000 |
1090 | +++ src/editor/tools/editor_history.h 2014-06-17 15:48:25 +0000 |
1091 | @@ -39,12 +39,15 @@ |
1092 | Editor_History(UI::Button & undo, UI::Button & redo): |
1093 | m_undo_button(undo), m_redo_button(redo) {}; |
1094 | |
1095 | - uint32_t do_action |
1096 | - (Editor_Tool & tool, Editor_Tool::Tool_Index ind, Widelands::Map & map, |
1097 | - Widelands::Node_and_Triangle<> const center, |
1098 | - Editor_Interactive & parent, bool draw = false); |
1099 | - uint32_t undo_action(); |
1100 | - uint32_t redo_action(); |
1101 | + uint32_t do_action(Editor_Tool& tool, |
1102 | + Editor_Tool::Tool_Index ind, |
1103 | + Widelands::Map& map, |
1104 | + const Widelands::World& world, |
1105 | + Widelands::Node_and_Triangle<> const center, |
1106 | + Editor_Interactive& parent, |
1107 | + bool draw = false); |
1108 | + uint32_t undo_action(const Widelands::World& world); |
1109 | + uint32_t redo_action(const Widelands::World& world); |
1110 | |
1111 | /// Must be called after every change of map, world, or ... to avoid undo errors |
1112 | void reset(); |
1113 | @@ -64,4 +67,3 @@ |
1114 | |
1115 | |
1116 | #endif |
1117 | - |
1118 | |
1119 | === modified file 'src/editor/tools/editor_increase_height_tool.cc' |
1120 | --- src/editor/tools/editor_increase_height_tool.cc 2013-07-26 20:19:36 +0000 |
1121 | +++ src/editor/tools/editor_increase_height_tool.cc 2014-06-17 15:48:25 +0000 |
1122 | @@ -25,36 +25,34 @@ |
1123 | #include "logic/mapregion.h" |
1124 | |
1125 | /// Increases the heights by a value. Chages surrounding nodes if necessary. |
1126 | -int32_t Editor_Increase_Height_Tool::handle_click_impl |
1127 | - (Widelands::Map & map, |
1128 | - Widelands::Node_and_Triangle<> center, |
1129 | - Editor_Interactive & /* parent */, |
1130 | - Editor_Action_Args & args) |
1131 | -{ |
1132 | +int32_t Editor_Increase_Height_Tool::handle_click_impl(Widelands::Map& map, |
1133 | + const Widelands::World& world, |
1134 | + Widelands::Node_and_Triangle<> center, |
1135 | + Editor_Interactive& /* parent */, |
1136 | + Editor_Action_Args& args) { |
1137 | if (args.origHights.empty()) { |
1138 | - Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
1139 | - (map, |
1140 | - Widelands::Area<Widelands::FCoords> |
1141 | - (map.get_fcoords(center.node), args.sel_radius + MAX_FIELD_HEIGHT / MAX_FIELD_HEIGHT_DIFF + 1)); |
1142 | + Widelands::MapRegion<Widelands::Area<Widelands::FCoords>> mr( |
1143 | + map, |
1144 | + Widelands::Area<Widelands::FCoords>( |
1145 | + map.get_fcoords(center.node), |
1146 | + args.sel_radius + MAX_FIELD_HEIGHT / MAX_FIELD_HEIGHT_DIFF + 1)); |
1147 | do { |
1148 | args.origHights.push_back(mr.location().field->get_height()); |
1149 | } while (mr.advance(map)); |
1150 | } |
1151 | |
1152 | - return |
1153 | - map.change_height |
1154 | - (Widelands::Area<Widelands::FCoords> |
1155 | - (map.get_fcoords(center.node), args.sel_radius), |
1156 | - args.change_by); |
1157 | + return map.change_height( |
1158 | + world, |
1159 | + Widelands::Area<Widelands::FCoords>(map.get_fcoords(center.node), args.sel_radius), |
1160 | + args.change_by); |
1161 | } |
1162 | |
1163 | -int32_t Editor_Increase_Height_Tool::handle_undo_impl |
1164 | - (Widelands::Map & map, |
1165 | - Widelands::Node_and_Triangle<> center, |
1166 | - Editor_Interactive & parent, |
1167 | - Editor_Action_Args & args) |
1168 | -{ |
1169 | - return m_decrease_tool.handle_undo_impl(map, center, parent, args); |
1170 | +int32_t Editor_Increase_Height_Tool::handle_undo_impl(Widelands::Map& map, |
1171 | + const Widelands::World& world, |
1172 | + Widelands::Node_and_Triangle<> center, |
1173 | + Editor_Interactive& parent, |
1174 | + Editor_Action_Args& args) { |
1175 | + return m_decrease_tool.handle_undo_impl(map, world, center, parent, args); |
1176 | } |
1177 | |
1178 | Editor_Action_Args Editor_Increase_Height_Tool::format_args_impl(Editor_Interactive & parent) |
1179 | |
1180 | === modified file 'src/editor/tools/editor_increase_height_tool.h' |
1181 | --- src/editor/tools/editor_increase_height_tool.h 2014-02-22 18:04:02 +0000 |
1182 | +++ src/editor/tools/editor_increase_height_tool.h 2014-06-17 15:48:25 +0000 |
1183 | @@ -34,13 +34,17 @@ |
1184 | m_change_by(1) |
1185 | {} |
1186 | |
1187 | - int32_t handle_click_impl |
1188 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1189 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1190 | + int32_t handle_click_impl(Widelands::Map& map, |
1191 | + const Widelands::World& world, |
1192 | + Widelands::Node_and_Triangle<> center, |
1193 | + Editor_Interactive& parent, |
1194 | + Editor_Action_Args& args) override; |
1195 | |
1196 | - int32_t handle_undo_impl |
1197 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1198 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1199 | + int32_t handle_undo_impl(Widelands::Map& map, |
1200 | + const Widelands::World& world, |
1201 | + Widelands::Node_and_Triangle<> center, |
1202 | + Editor_Interactive& parent, |
1203 | + Editor_Action_Args& args) override; |
1204 | |
1205 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
1206 | |
1207 | |
1208 | === modified file 'src/editor/tools/editor_increase_resources_tool.cc' |
1209 | --- src/editor/tools/editor_increase_resources_tool.cc 2014-05-27 11:01:15 +0000 |
1210 | +++ src/editor/tools/editor_increase_resources_tool.cc 2014-06-17 15:48:25 +0000 |
1211 | @@ -23,39 +23,55 @@ |
1212 | #include "graphic/graphic.h" |
1213 | #include "logic/field.h" |
1214 | #include "logic/mapregion.h" |
1215 | -#include "logic/world.h" |
1216 | -#include "logic/worlddata.h" |
1217 | +#include "logic/world/resource_description.h" |
1218 | +#include "logic/world/terrain_description.h" |
1219 | +#include "logic/world/world.h" |
1220 | #include "wui/overlay_manager.h" |
1221 | |
1222 | using Widelands::TCoords; |
1223 | |
1224 | +namespace { |
1225 | + |
1226 | +int32_t resource_value(const Widelands::TerrainDescription& terrain, |
1227 | + const Widelands::Resource_Index resource) { |
1228 | + if (!terrain.is_resource_valid(resource)) { |
1229 | + return -1; |
1230 | + } |
1231 | + if (terrain.get_is() & Widelands::TerrainDescription::UNPASSABLE) { |
1232 | + return 8; |
1233 | + } |
1234 | + return 1; |
1235 | +} |
1236 | + |
1237 | +} // namespace |
1238 | + |
1239 | + |
1240 | int32_t Editor_Change_Resource_Tool_Callback |
1241 | - (const TCoords<Widelands::FCoords>& c, Widelands::Map& map, int32_t const curres) |
1242 | + (const TCoords<Widelands::FCoords>& c, Widelands::Map& map, |
1243 | + const Widelands::World& world, int32_t const curres) |
1244 | { |
1245 | - Widelands::World & world = map.world(); |
1246 | Widelands::FCoords f(c, &map[c]); |
1247 | |
1248 | Widelands::FCoords f1; |
1249 | int32_t count = 0; |
1250 | |
1251 | // this field |
1252 | - count += world.terrain_descr(f.field->terrain_r()).resource_value(curres); |
1253 | - count += world.terrain_descr(f.field->terrain_d()).resource_value(curres); |
1254 | - |
1255 | + count += resource_value(world.terrain_descr(f.field->terrain_r()), curres); |
1256 | + count += resource_value(world.terrain_descr(f.field->terrain_d()), curres); |
1257 | |
1258 | // If one of the neighbours is unpassable, count its resource stronger. |
1259 | // top left neigbour |
1260 | map.get_neighbour(f, Widelands::WALK_NW, &f1); |
1261 | - count += world.terrain_descr(f1.field->terrain_r()).resource_value(curres); |
1262 | - count += world.terrain_descr(f1.field->terrain_d()).resource_value(curres); |
1263 | + count += resource_value(world.terrain_descr(f1.field->terrain_r()), curres); |
1264 | + count += resource_value(world.terrain_descr(f1.field->terrain_d()), curres); |
1265 | |
1266 | // top right neigbour |
1267 | map.get_neighbour(f, Widelands::WALK_NE, &f1); |
1268 | - count += world.terrain_descr(f1.field->terrain_d()).resource_value(curres); |
1269 | + count += resource_value(world.terrain_descr(f1.field->terrain_d()), curres); |
1270 | |
1271 | // left neighbour |
1272 | map.get_neighbour(f, Widelands::WALK_W, &f1); |
1273 | - count += world.terrain_descr(f1.field->terrain_r()).resource_value(curres); |
1274 | + count += resource_value(world.terrain_descr(f1.field->terrain_r()), curres); |
1275 | |
1276 | return count <= 3 ? 0 : f.field->nodecaps(); |
1277 | } |
1278 | @@ -68,23 +84,21 @@ |
1279 | there is not already another resource there. |
1280 | =========== |
1281 | */ |
1282 | -int32_t Editor_Increase_Resources_Tool::handle_click_impl |
1283 | - (Widelands::Map & map, |
1284 | - Widelands::Node_and_Triangle<> const center, |
1285 | - Editor_Interactive & /* parent */, |
1286 | - Editor_Action_Args & args) |
1287 | -{ |
1288 | - const Widelands::World & world = map.world(); |
1289 | +int32_t |
1290 | +Editor_Increase_Resources_Tool::handle_click_impl(Widelands::Map& map, |
1291 | + const Widelands::World& world, |
1292 | + Widelands::Node_and_Triangle<> const center, |
1293 | + Editor_Interactive& /* parent */, |
1294 | + Editor_Action_Args& args) { |
1295 | OverlayManager & overlay_manager = map.overlay_manager(); |
1296 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
1297 | (map, |
1298 | Widelands::Area<Widelands::FCoords> |
1299 | (map.get_fcoords(center.node), args.sel_radius)); |
1300 | do { |
1301 | - int32_t res = mr.location().field->get_resources(); |
1302 | - int32_t amount = mr.location().field->get_resources_amount(); |
1303 | - int32_t max_amount = |
1304 | - map.get_world()->get_resource(args.cur_res)->get_max_amount(); |
1305 | + int32_t res = mr.location().field->get_resources(); |
1306 | + int32_t amount = mr.location().field->get_resources_amount(); |
1307 | + int32_t max_amount = world.get_resource(args.cur_res)->max_amount(); |
1308 | |
1309 | amount += args.change_by; |
1310 | if (amount > max_amount) |
1311 | @@ -96,7 +110,7 @@ |
1312 | if |
1313 | ((res == args.cur_res or not mr.location().field->get_resources_amount()) |
1314 | and |
1315 | - Editor_Change_Resource_Tool_Callback(mr.location(), map, args.cur_res)) |
1316 | + Editor_Change_Resource_Tool_Callback(mr.location(), map, world, args.cur_res)) |
1317 | { |
1318 | // Ok, we're doing something. First remove the current overlays. |
1319 | const Image* pic = |
1320 | @@ -115,20 +129,21 @@ |
1321 | pic = g_gr->images().get |
1322 | (world.get_resource(args.cur_res)->get_editor_pic(amount)); |
1323 | overlay_manager.register_overlay(mr.location(), pic, 4); |
1324 | - map.recalc_for_field_area |
1325 | - (Widelands::Area<Widelands::FCoords>(mr.location(), 0)); |
1326 | + map.recalc_for_field_area( |
1327 | + world, Widelands::Area<Widelands::FCoords>(mr.location(), 0)); |
1328 | } |
1329 | } |
1330 | } while (mr.advance(map)); |
1331 | return mr.radius(); |
1332 | } |
1333 | |
1334 | -int32_t Editor_Increase_Resources_Tool::handle_undo_impl |
1335 | - (Widelands::Map & map, |
1336 | - Widelands::Node_and_Triangle< Widelands::Coords > center, |
1337 | - Editor_Interactive & parent, Editor_Action_Args & args) |
1338 | -{ |
1339 | - return m_set_tool.handle_undo_impl(map, center, parent, args); |
1340 | +int32_t Editor_Increase_Resources_Tool::handle_undo_impl( |
1341 | + Widelands::Map& map, |
1342 | + const Widelands::World& world, |
1343 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
1344 | + Editor_Interactive& parent, |
1345 | + Editor_Action_Args& args) { |
1346 | + return m_set_tool.handle_undo_impl(map, world, center, parent, args); |
1347 | } |
1348 | |
1349 | Editor_Action_Args Editor_Increase_Resources_Tool::format_args_impl(Editor_Interactive & parent) |
1350 | |
1351 | === modified file 'src/editor/tools/editor_increase_resources_tool.h' |
1352 | --- src/editor/tools/editor_increase_resources_tool.h 2014-03-09 18:32:29 +0000 |
1353 | +++ src/editor/tools/editor_increase_resources_tool.h 2014-06-17 15:48:25 +0000 |
1354 | @@ -26,22 +26,26 @@ |
1355 | |
1356 | /// Increases the resources of a node by a value. |
1357 | struct Editor_Increase_Resources_Tool : public Editor_Tool { |
1358 | - Editor_Increase_Resources_Tool |
1359 | - (Editor_Decrease_Resources_Tool & the_decrease_tool, |
1360 | - Editor_Set_Resources_Tool & the_set_to_tool) |
1361 | - : |
1362 | - Editor_Tool(the_decrease_tool, the_set_to_tool), |
1363 | - m_decrease_tool(the_decrease_tool), m_set_tool(the_set_to_tool), |
1364 | - m_change_by(1), m_cur_res(0) |
1365 | - {} |
1366 | - |
1367 | - int32_t handle_click_impl |
1368 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1369 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1370 | - |
1371 | - int32_t handle_undo_impl |
1372 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1373 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1374 | + Editor_Increase_Resources_Tool(Editor_Decrease_Resources_Tool& the_decrease_tool, |
1375 | + Editor_Set_Resources_Tool& the_set_to_tool) |
1376 | + : Editor_Tool(the_decrease_tool, the_set_to_tool), |
1377 | + m_decrease_tool(the_decrease_tool), |
1378 | + m_set_tool(the_set_to_tool), |
1379 | + m_change_by(1), |
1380 | + m_cur_res(0) { |
1381 | + } |
1382 | + |
1383 | + int32_t handle_click_impl(Widelands::Map& map, |
1384 | + const Widelands::World& world, |
1385 | + Widelands::Node_and_Triangle<> center, |
1386 | + Editor_Interactive& parent, |
1387 | + Editor_Action_Args& args) override; |
1388 | + |
1389 | + int32_t handle_undo_impl(Widelands::Map& map, |
1390 | + const Widelands::World& world, |
1391 | + Widelands::Node_and_Triangle<> center, |
1392 | + Editor_Interactive& parent, |
1393 | + Editor_Action_Args& args) override; |
1394 | |
1395 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
1396 | |
1397 | @@ -63,12 +67,14 @@ |
1398 | |
1399 | private: |
1400 | Editor_Decrease_Resources_Tool & m_decrease_tool; |
1401 | - Editor_Set_Resources_Tool & m_set_tool; |
1402 | - int32_t m_change_by; |
1403 | + Editor_Set_Resources_Tool& m_set_tool; |
1404 | + int32_t m_change_by; |
1405 | Widelands::Resource_Index m_cur_res; |
1406 | }; |
1407 | |
1408 | -int32_t Editor_Change_Resource_Tool_Callback |
1409 | - (const Widelands::TCoords<Widelands::FCoords>&, Widelands::Map&, int32_t); |
1410 | +int32_t Editor_Change_Resource_Tool_Callback(const Widelands::TCoords<Widelands::FCoords>& c, |
1411 | + Widelands::Map& map, |
1412 | + const Widelands::World& world, |
1413 | + int32_t const curres); |
1414 | |
1415 | #endif |
1416 | |
1417 | === modified file 'src/editor/tools/editor_info_tool.cc' |
1418 | --- src/editor/tools/editor_info_tool.cc 2014-03-09 10:28:39 +0000 |
1419 | +++ src/editor/tools/editor_info_tool.cc 2014-06-17 15:48:25 +0000 |
1420 | @@ -26,18 +26,17 @@ |
1421 | #include "editor/editorinteractive.h" |
1422 | #include "i18n.h" |
1423 | #include "logic/map.h" |
1424 | -#include "logic/world.h" |
1425 | +#include "logic/world/terrain_description.h" |
1426 | +#include "logic/world/world.h" |
1427 | #include "ui_basic/multilinetextarea.h" |
1428 | #include "ui_basic/window.h" |
1429 | |
1430 | /// Show a window with information about the pointed at node and triangle. |
1431 | -int32_t Editor_Info_Tool::handle_click_impl |
1432 | - (Widelands::Map & map, |
1433 | - Widelands::Node_and_Triangle<> const center, |
1434 | - Editor_Interactive & parent, |
1435 | - Editor_Action_Args & /* args */) |
1436 | -{ |
1437 | - const Widelands::World & world = map.world(); |
1438 | +int32_t Editor_Info_Tool::handle_click_impl(Widelands::Map& map, |
1439 | + const Widelands::World& world, |
1440 | + Widelands::Node_and_Triangle<> center, |
1441 | + Editor_Interactive& parent, |
1442 | + Editor_Action_Args& /* args */) { |
1443 | UI::Window * const w = |
1444 | new UI::Window |
1445 | (&parent, "field_information", 30, 30, 400, 200, |
1446 | @@ -97,9 +96,8 @@ |
1447 | buf += std::string("\n") + _("Terrain:") + "\n"; |
1448 | |
1449 | const Widelands::Field & tf = map[center.triangle]; |
1450 | - const Widelands::Terrain_Descr & ter = world.terrain_descr |
1451 | - (center.triangle.t == Widelands::TCoords<>::D ? |
1452 | - tf.terrain_d() : tf.terrain_r()); |
1453 | + const Widelands::TerrainDescription& ter = world.terrain_descr( |
1454 | + center.triangle.t == Widelands::TCoords<>::D ? tf.terrain_d() : tf.terrain_r()); |
1455 | |
1456 | buf += std::string("• ") + (boost::format(_("Name: %s")) % ter.descname()).str() + "\n"; |
1457 | buf += std::string("• ") + (boost::format(_("Texture Number: %i")) % ter.get_texture()).str() + "\n"; |
1458 | @@ -134,12 +132,6 @@ |
1459 | buf += std::string("• ") + (boost::format(_("Author: %s")) % map.get_author()).str() + "\n"; |
1460 | buf += std::string("• ") + (boost::format(_("Descr: %s")) % map.get_description()).str() + "\n"; |
1461 | |
1462 | - // *** World info |
1463 | - buf += std::string("\n") + _("World:") + "\n"; |
1464 | - buf += std::string("• ") + (boost::format(_("Name: %s")) % world.get_name()).str() + "\n"; |
1465 | - buf += std::string("• ") + (boost::format(_("Author: %s")) % world.get_author()).str() + "\n"; |
1466 | - buf += std::string("• ") + (boost::format(_("Descr: %s")) % world.get_descr()).str() + "\n"; |
1467 | - |
1468 | multiline_textarea->set_text(buf.c_str()); |
1469 | |
1470 | return 0; |
1471 | |
1472 | === modified file 'src/editor/tools/editor_info_tool.h' |
1473 | --- src/editor/tools/editor_info_tool.h 2014-02-22 18:04:02 +0000 |
1474 | +++ src/editor/tools/editor_info_tool.h 2014-06-17 15:48:25 +0000 |
1475 | @@ -24,13 +24,18 @@ |
1476 | |
1477 | /// A simple tool to show information about the clicked node. |
1478 | struct Editor_Info_Tool : public Editor_Tool { |
1479 | - Editor_Info_Tool() : Editor_Tool(*this, *this, false) {} |
1480 | - |
1481 | - int32_t handle_click_impl |
1482 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1483 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1484 | - |
1485 | - char const * get_sel_impl() const override {return "pics/fsel_editor_info.png";} |
1486 | + Editor_Info_Tool() : Editor_Tool(*this, *this, false) { |
1487 | + } |
1488 | + |
1489 | + int32_t handle_click_impl(Widelands::Map& map, |
1490 | + const Widelands::World& world, |
1491 | + Widelands::Node_and_Triangle<> center, |
1492 | + Editor_Interactive& parent, |
1493 | + Editor_Action_Args& args) override; |
1494 | + |
1495 | + char const* get_sel_impl() const override { |
1496 | + return "pics/fsel_editor_info.png"; |
1497 | + } |
1498 | }; |
1499 | |
1500 | #endif |
1501 | |
1502 | === modified file 'src/editor/tools/editor_make_infrastructure_tool.cc' |
1503 | --- src/editor/tools/editor_make_infrastructure_tool.cc 2014-03-09 18:32:29 +0000 |
1504 | +++ src/editor/tools/editor_make_infrastructure_tool.cc 2014-06-17 15:48:25 +0000 |
1505 | @@ -46,12 +46,11 @@ |
1506 | * |
1507 | * Obviously, this function ignores the sel radius |
1508 | */ |
1509 | -int32_t Editor_Make_Infrastructure_Tool::handle_click_impl |
1510 | - (Widelands::Map &, |
1511 | - Widelands::Node_and_Triangle<> const, |
1512 | - Editor_Interactive & parent, |
1513 | - Editor_Action_Args & /* args */) |
1514 | -{ |
1515 | +int32_t Editor_Make_Infrastructure_Tool::handle_click_impl(Widelands::Map&, |
1516 | + const Widelands::World&, |
1517 | + Widelands::Node_and_Triangle<> const, |
1518 | + Editor_Interactive& parent, |
1519 | + Editor_Action_Args& /* args */) { |
1520 | show_field_action |
1521 | (&parent, parent.egbase().get_player(m_player), &m_registry); |
1522 | |
1523 | |
1524 | === modified file 'src/editor/tools/editor_make_infrastructure_tool.h' |
1525 | --- src/editor/tools/editor_make_infrastructure_tool.h 2014-03-09 18:32:29 +0000 |
1526 | +++ src/editor/tools/editor_make_infrastructure_tool.h 2014-06-17 15:48:25 +0000 |
1527 | @@ -23,6 +23,10 @@ |
1528 | #include "editor/tools/editor_tool.h" |
1529 | #include "ui_basic/unique_window.h" |
1530 | |
1531 | +namespace Widelands { |
1532 | +class Editor_Game_Base; |
1533 | +} // namespace Widelands |
1534 | + |
1535 | /** |
1536 | * This places immovables on the map |
1537 | * \TODO Implement undo for this tool |
1538 | @@ -35,9 +39,11 @@ |
1539 | Widelands::Player_Number get_player() const |
1540 | {return m_player;} |
1541 | |
1542 | - int32_t handle_click_impl |
1543 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1544 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1545 | + int32_t handle_click_impl(Widelands::Map& map, |
1546 | + const Widelands::World& world, |
1547 | + Widelands::Node_and_Triangle<> center, |
1548 | + Editor_Interactive& parent, |
1549 | + Editor_Action_Args& args) override; |
1550 | |
1551 | const char * get_sel_impl() const override |
1552 | {return "pics/fsel.png";} // Standard sel icon, most complex tool of all |
1553 | |
1554 | === modified file 'src/editor/tools/editor_noise_height_tool.cc' |
1555 | --- src/editor/tools/editor_noise_height_tool.cc 2013-07-26 20:19:36 +0000 |
1556 | +++ src/editor/tools/editor_noise_height_tool.cc 2014-06-17 15:48:25 +0000 |
1557 | @@ -27,12 +27,11 @@ |
1558 | #include "logic/mapregion.h" |
1559 | |
1560 | /// Sets the heights to random values. Changes surrounding nodes if necessary. |
1561 | -int32_t Editor_Noise_Height_Tool::handle_click_impl |
1562 | - (Widelands::Map & map, |
1563 | - Widelands::Node_and_Triangle<> const center, |
1564 | - Editor_Interactive & /* parent */, |
1565 | - Editor_Action_Args & args) |
1566 | -{ |
1567 | +int32_t Editor_Noise_Height_Tool::handle_click_impl(Widelands::Map& map, |
1568 | + const Widelands::World& world, |
1569 | + Widelands::Node_and_Triangle<> const center, |
1570 | + Editor_Interactive& /* parent */, |
1571 | + Editor_Action_Args& args) { |
1572 | if (args.origHights.empty()) { |
1573 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
1574 | (map, |
1575 | @@ -50,27 +49,25 @@ |
1576 | Widelands::Area<Widelands::FCoords> |
1577 | (map.get_fcoords(center.node), args.sel_radius)); |
1578 | do { |
1579 | - max = |
1580 | - std::max |
1581 | - (max, |
1582 | - map.set_height |
1583 | - (mr.location(), |
1584 | - args.m_interval.min |
1585 | - + |
1586 | - static_cast<int32_t> |
1587 | - (static_cast<double> |
1588 | - (args.m_interval.max - args.m_interval.min + 1) * rand() |
1589 | - / |
1590 | - (RAND_MAX + 1.0)))); |
1591 | + max = std::max( |
1592 | + max, |
1593 | + map.set_height(world, |
1594 | + mr.location(), |
1595 | + args.m_interval.min + |
1596 | + static_cast<int32_t>( |
1597 | + static_cast<double>(args.m_interval.max - args.m_interval.min + 1) * |
1598 | + rand() / (RAND_MAX + 1.0)))); |
1599 | } while (mr.advance(map)); |
1600 | return mr.radius() + max; |
1601 | } |
1602 | |
1603 | -int32_t Editor_Noise_Height_Tool::handle_undo_impl |
1604 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
1605 | - Editor_Interactive & parent, Editor_Action_Args & args) |
1606 | -{ |
1607 | - return m_set_tool.handle_undo_impl(map, center, parent, args); |
1608 | +int32_t |
1609 | +Editor_Noise_Height_Tool::handle_undo_impl(Widelands::Map& map, |
1610 | + const Widelands::World& world, |
1611 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
1612 | + Editor_Interactive& parent, |
1613 | + Editor_Action_Args& args) { |
1614 | + return m_set_tool.handle_undo_impl(map, world, center, parent, args); |
1615 | } |
1616 | |
1617 | Editor_Action_Args Editor_Noise_Height_Tool::format_args_impl(Editor_Interactive & parent) |
1618 | @@ -79,4 +76,3 @@ |
1619 | a.m_interval = m_interval; |
1620 | return a; |
1621 | } |
1622 | - |
1623 | |
1624 | === modified file 'src/editor/tools/editor_noise_height_tool.h' |
1625 | --- src/editor/tools/editor_noise_height_tool.h 2014-02-22 18:04:02 +0000 |
1626 | +++ src/editor/tools/editor_noise_height_tool.h 2014-06-17 15:48:25 +0000 |
1627 | @@ -34,13 +34,17 @@ |
1628 | m_interval(the_interval) |
1629 | {} |
1630 | |
1631 | - int32_t handle_click_impl |
1632 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1633 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1634 | + int32_t handle_click_impl(Widelands::Map& map, |
1635 | + const Widelands::World& world, |
1636 | + Widelands::Node_and_Triangle<> center, |
1637 | + Editor_Interactive& parent, |
1638 | + Editor_Action_Args& args) override; |
1639 | |
1640 | - int32_t handle_undo_impl |
1641 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1642 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1643 | + int32_t handle_undo_impl(Widelands::Map& map, |
1644 | + const Widelands::World& world, |
1645 | + Widelands::Node_and_Triangle<> center, |
1646 | + Editor_Interactive& parent, |
1647 | + Editor_Action_Args& args) override; |
1648 | |
1649 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
1650 | |
1651 | |
1652 | === modified file 'src/editor/tools/editor_place_bob_tool.cc' |
1653 | --- src/editor/tools/editor_place_bob_tool.cc 2014-03-31 20:21:27 +0000 |
1654 | +++ src/editor/tools/editor_place_bob_tool.cc 2014-06-17 15:48:25 +0000 |
1655 | @@ -24,17 +24,17 @@ |
1656 | #include "logic/editor_game_base.h" |
1657 | #include "logic/field.h" |
1658 | #include "logic/mapregion.h" |
1659 | +#include "logic/world/world.h" |
1660 | |
1661 | /** |
1662 | * Choses an object to place randomly from all enabled |
1663 | * and places this on the current field |
1664 | */ |
1665 | -int32_t Editor_Place_Bob_Tool::handle_click_impl |
1666 | - (Widelands::Map & map, |
1667 | - Widelands::Node_and_Triangle<> const center, |
1668 | - Editor_Interactive & parent, |
1669 | - Editor_Action_Args & args) |
1670 | -{ |
1671 | +int32_t Editor_Place_Bob_Tool::handle_click_impl(Widelands::Map& map, |
1672 | + const Widelands::World& world, |
1673 | + Widelands::Node_and_Triangle<> const center, |
1674 | + Editor_Interactive& parent, |
1675 | + Editor_Action_Args& args) { |
1676 | |
1677 | if (get_nr_enabled() && args.obob_type.empty()) { |
1678 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
1679 | @@ -44,7 +44,7 @@ |
1680 | do { |
1681 | Widelands::Bob * const mbob = mr.location().field->get_first_bob(); |
1682 | args.obob_type.push_back((mbob ? &mbob->descr() : nullptr)); |
1683 | - args.nbob_type.push_back(map.world().get_bob_descr(get_random_enabled())); |
1684 | + args.nbob_type.push_back(world.get_bob_descr(get_random_enabled())); |
1685 | } while (mr.advance(map)); |
1686 | } |
1687 | |
1688 | @@ -69,10 +69,12 @@ |
1689 | return 0; |
1690 | } |
1691 | |
1692 | -int32_t Editor_Place_Bob_Tool::handle_undo_impl |
1693 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
1694 | - Editor_Interactive & parent, Editor_Action_Args & args) |
1695 | -{ |
1696 | +int32_t |
1697 | +Editor_Place_Bob_Tool::handle_undo_impl(Widelands::Map& map, |
1698 | + const Widelands::World&, |
1699 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
1700 | + Editor_Interactive& parent, |
1701 | + Editor_Action_Args& args) { |
1702 | if (not args.nbob_type.empty()) { |
1703 | Widelands::Editor_Game_Base & egbase = parent.egbase(); |
1704 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
1705 | |
1706 | === modified file 'src/editor/tools/editor_place_bob_tool.h' |
1707 | --- src/editor/tools/editor_place_bob_tool.h 2014-02-22 18:04:02 +0000 |
1708 | +++ src/editor/tools/editor_place_bob_tool.h 2014-06-17 15:48:25 +0000 |
1709 | @@ -29,13 +29,17 @@ |
1710 | : Editor_Tool(tool, tool) |
1711 | {} |
1712 | |
1713 | - int32_t handle_click_impl |
1714 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1715 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1716 | + int32_t handle_click_impl(Widelands::Map& map, |
1717 | + const Widelands::World& world, |
1718 | + Widelands::Node_and_Triangle<> center, |
1719 | + Editor_Interactive& parent, |
1720 | + Editor_Action_Args& args) override; |
1721 | |
1722 | - int32_t handle_undo_impl |
1723 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1724 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1725 | + int32_t handle_undo_impl(Widelands::Map& map, |
1726 | + const Widelands::World& world, |
1727 | + Widelands::Node_and_Triangle<> center, |
1728 | + Editor_Interactive& parent, |
1729 | + Editor_Action_Args& args) override; |
1730 | |
1731 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
1732 | |
1733 | |
1734 | === modified file 'src/editor/tools/editor_place_immovable_tool.cc' |
1735 | --- src/editor/tools/editor_place_immovable_tool.cc 2014-02-22 18:04:02 +0000 |
1736 | +++ src/editor/tools/editor_place_immovable_tool.cc 2014-06-17 15:48:25 +0000 |
1737 | @@ -32,12 +32,11 @@ |
1738 | * Choses an object to place randomly from all enabled |
1739 | * and places this on the current field |
1740 | */ |
1741 | -int32_t Editor_Place_Immovable_Tool::handle_click_impl |
1742 | - (Widelands::Map & map, |
1743 | - Widelands::Node_and_Triangle<> const center, |
1744 | - Editor_Interactive & parent, |
1745 | - Editor_Action_Args & args) |
1746 | -{ |
1747 | +int32_t Editor_Place_Immovable_Tool::handle_click_impl(Widelands::Map& map, |
1748 | + const Widelands::World&, |
1749 | + Widelands::Node_and_Triangle<> const center, |
1750 | + Editor_Interactive& parent, |
1751 | + Editor_Action_Args& args) { |
1752 | const int32_t radius = args.sel_radius; |
1753 | if (not get_nr_enabled()) |
1754 | return radius; |
1755 | @@ -74,10 +73,12 @@ |
1756 | return radius + 2; |
1757 | } |
1758 | |
1759 | -int32_t Editor_Place_Immovable_Tool::handle_undo_impl |
1760 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
1761 | - Editor_Interactive & parent, Editor_Action_Args & args) |
1762 | -{ |
1763 | +int32_t Editor_Place_Immovable_Tool::handle_undo_impl( |
1764 | + Widelands::Map& map, |
1765 | + const Widelands::World&, |
1766 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
1767 | + Editor_Interactive& parent, |
1768 | + Editor_Action_Args& args) { |
1769 | const int32_t radius = args.sel_radius; |
1770 | if (args.oimmov_types.empty()) |
1771 | return radius; |
1772 | @@ -107,6 +108,3 @@ |
1773 | { |
1774 | return Editor_Tool::format_args_impl(parent); |
1775 | } |
1776 | - |
1777 | - |
1778 | - |
1779 | |
1780 | === modified file 'src/editor/tools/editor_place_immovable_tool.h' |
1781 | --- src/editor/tools/editor_place_immovable_tool.h 2014-02-22 18:04:02 +0000 |
1782 | +++ src/editor/tools/editor_place_immovable_tool.h 2014-06-17 15:48:25 +0000 |
1783 | @@ -31,13 +31,17 @@ |
1784 | : Editor_Tool(tool, tool) |
1785 | {} |
1786 | |
1787 | - int32_t handle_click_impl |
1788 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1789 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1790 | + int32_t handle_click_impl(Widelands::Map& map, |
1791 | + const Widelands::World& world, |
1792 | + Widelands::Node_and_Triangle<> center, |
1793 | + Editor_Interactive& parent, |
1794 | + Editor_Action_Args& args) override; |
1795 | |
1796 | - int32_t handle_undo_impl |
1797 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1798 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1799 | + int32_t handle_undo_impl(Widelands::Map& map, |
1800 | + const Widelands::World& world, |
1801 | + Widelands::Node_and_Triangle<> center, |
1802 | + Editor_Interactive& parent, |
1803 | + Editor_Action_Args& args) override; |
1804 | |
1805 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
1806 | |
1807 | |
1808 | === modified file 'src/editor/tools/editor_set_height_tool.cc' |
1809 | --- src/editor/tools/editor_set_height_tool.cc 2013-07-26 20:19:36 +0000 |
1810 | +++ src/editor/tools/editor_set_height_tool.cc 2014-06-17 15:48:25 +0000 |
1811 | @@ -26,12 +26,11 @@ |
1812 | #include "logic/map.h" |
1813 | #include "logic/mapregion.h" |
1814 | |
1815 | - |
1816 | -int32_t Editor_Set_Height_Tool::handle_click_impl |
1817 | - (Widelands::Map & map, |
1818 | - Widelands::Node_and_Triangle<> const center, |
1819 | - Editor_Interactive & /* parent */, Editor_Action_Args & args) |
1820 | -{ |
1821 | +int32_t Editor_Set_Height_Tool::handle_click_impl(Widelands::Map& map, |
1822 | + const Widelands::World& world, |
1823 | + Widelands::Node_and_Triangle<> const center, |
1824 | + Editor_Interactive& /* parent */, |
1825 | + Editor_Action_Args& args) { |
1826 | if (args.origHights.empty()) |
1827 | { |
1828 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
1829 | @@ -41,17 +40,18 @@ |
1830 | do args.origHights.push_back(mr.location().field->get_height()); |
1831 | while (mr.advance(map)); |
1832 | } |
1833 | - return |
1834 | - map.set_height |
1835 | - (Widelands::Area<Widelands::FCoords> |
1836 | - (map.get_fcoords(center.node), args.sel_radius), |
1837 | - args.m_interval); |
1838 | + return map.set_height( |
1839 | + world, |
1840 | + Widelands::Area<Widelands::FCoords>(map.get_fcoords(center.node), args.sel_radius), |
1841 | + args.m_interval); |
1842 | } |
1843 | |
1844 | -int32_t Editor_Set_Height_Tool::handle_undo_impl |
1845 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
1846 | - Editor_Interactive & /* parent */, Editor_Action_Args & args) |
1847 | -{ |
1848 | +int32_t |
1849 | +Editor_Set_Height_Tool::handle_undo_impl(Widelands::Map& map, |
1850 | + const Widelands::World& world, |
1851 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
1852 | + Editor_Interactive& /* parent */, |
1853 | + Editor_Action_Args& args) { |
1854 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
1855 | (map, |
1856 | Widelands::Area<Widelands::FCoords> |
1857 | @@ -65,7 +65,7 @@ |
1858 | } while (mr.advance(map)); |
1859 | |
1860 | map.recalc_for_field_area |
1861 | - (Widelands::Area<Widelands::FCoords> |
1862 | + (world, Widelands::Area<Widelands::FCoords> |
1863 | (map.get_fcoords(center.node), |
1864 | args.sel_radius + MAX_FIELD_HEIGHT / MAX_FIELD_HEIGHT_DIFF + 2)); |
1865 | |
1866 | @@ -78,6 +78,3 @@ |
1867 | a.m_interval = m_interval; |
1868 | return a; |
1869 | } |
1870 | - |
1871 | - |
1872 | - |
1873 | |
1874 | === modified file 'src/editor/tools/editor_set_height_tool.h' |
1875 | --- src/editor/tools/editor_set_height_tool.h 2014-02-22 18:04:02 +0000 |
1876 | +++ src/editor/tools/editor_set_height_tool.h 2014-06-17 15:48:25 +0000 |
1877 | @@ -30,13 +30,17 @@ |
1878 | : Editor_Tool(*this, *this), m_interval(10, 10) |
1879 | {} |
1880 | |
1881 | - int32_t handle_click_impl |
1882 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1883 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1884 | + int32_t handle_click_impl(Widelands::Map& map, |
1885 | + const Widelands::World& world, |
1886 | + Widelands::Node_and_Triangle<> center, |
1887 | + Editor_Interactive& parent, |
1888 | + Editor_Action_Args& args) override; |
1889 | |
1890 | - int32_t handle_undo_impl |
1891 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1892 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1893 | + int32_t handle_undo_impl(Widelands::Map& map, |
1894 | + const Widelands::World& world, |
1895 | + Widelands::Node_and_Triangle<> center, |
1896 | + Editor_Interactive& parent, |
1897 | + Editor_Action_Args& args) override; |
1898 | |
1899 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
1900 | |
1901 | |
1902 | === modified file 'src/editor/tools/editor_set_origin_tool.cc' |
1903 | --- src/editor/tools/editor_set_origin_tool.cc 2014-03-09 18:32:29 +0000 |
1904 | +++ src/editor/tools/editor_set_origin_tool.cc 2014-06-17 15:48:25 +0000 |
1905 | @@ -24,12 +24,11 @@ |
1906 | #include "wui/mapviewpixelconstants.h" |
1907 | #include "wui/overlay_manager.h" |
1908 | |
1909 | -int32_t Editor_Set_Origin_Tool::handle_click_impl |
1910 | - (Widelands::Map & map, |
1911 | - Widelands::Node_and_Triangle<> const center, |
1912 | - Editor_Interactive & eia, |
1913 | - Editor_Action_Args & /* args */) |
1914 | -{ |
1915 | +int32_t Editor_Set_Origin_Tool::handle_click_impl(Widelands::Map& map, |
1916 | + const Widelands::World&, |
1917 | + Widelands::Node_and_Triangle<> const center, |
1918 | + Editor_Interactive& eia, |
1919 | + Editor_Action_Args& /* args */) { |
1920 | map.set_origin(center.node); |
1921 | eia.register_overlays(); |
1922 | eia.set_rel_viewpoint |
1923 | @@ -40,10 +39,12 @@ |
1924 | return 0; |
1925 | } |
1926 | |
1927 | -int32_t Editor_Set_Origin_Tool::handle_undo_impl |
1928 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
1929 | - Editor_Interactive & parent, Editor_Action_Args & /* args */) |
1930 | -{ |
1931 | +int32_t |
1932 | +Editor_Set_Origin_Tool::handle_undo_impl(Widelands::Map& map, |
1933 | + const Widelands::World&, |
1934 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
1935 | + Editor_Interactive& parent, |
1936 | + Editor_Action_Args& /* args */) { |
1937 | Widelands::Coords nc |
1938 | (map.get_width() - center.node.x, |
1939 | map.get_height() - center.node.y); |
1940 | |
1941 | === modified file 'src/editor/tools/editor_set_origin_tool.h' |
1942 | --- src/editor/tools/editor_set_origin_tool.h 2014-02-22 18:04:02 +0000 |
1943 | +++ src/editor/tools/editor_set_origin_tool.h 2014-06-17 15:48:25 +0000 |
1944 | @@ -27,13 +27,17 @@ |
1945 | struct Editor_Set_Origin_Tool : public Editor_Tool { |
1946 | Editor_Set_Origin_Tool() : Editor_Tool(*this, *this) {} |
1947 | |
1948 | - int32_t handle_click_impl |
1949 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1950 | - Editor_Interactive & eia, Editor_Action_Args & args) override; |
1951 | + int32_t handle_click_impl(Widelands::Map& map, |
1952 | + const Widelands::World& world, |
1953 | + Widelands::Node_and_Triangle<> center, |
1954 | + Editor_Interactive& eia, |
1955 | + Editor_Action_Args& args) override; |
1956 | |
1957 | - int32_t handle_undo_impl |
1958 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
1959 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
1960 | + int32_t handle_undo_impl(Widelands::Map& map, |
1961 | + const Widelands::World& world, |
1962 | + Widelands::Node_and_Triangle<> center, |
1963 | + Editor_Interactive& parent, |
1964 | + Editor_Action_Args& args) override; |
1965 | |
1966 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
1967 | |
1968 | |
1969 | === modified file 'src/editor/tools/editor_set_port_space_tool.cc' |
1970 | --- src/editor/tools/editor_set_port_space_tool.cc 2014-03-09 18:32:29 +0000 |
1971 | +++ src/editor/tools/editor_set_port_space_tool.cc 2014-06-17 15:48:25 +0000 |
1972 | @@ -55,12 +55,11 @@ |
1973 | Editor_Tool(*this, *this) |
1974 | {} |
1975 | |
1976 | - |
1977 | -int32_t Editor_Set_Port_Space_Tool::handle_click_impl |
1978 | - (Map & map, |
1979 | - Widelands::Node_and_Triangle<> const center, |
1980 | - Editor_Interactive &, Editor_Action_Args & args) |
1981 | -{ |
1982 | +int32_t Editor_Set_Port_Space_Tool::handle_click_impl(Map& map, |
1983 | + const Widelands::World& world, |
1984 | + Widelands::Node_and_Triangle<> const center, |
1985 | + Editor_Interactive&, |
1986 | + Editor_Action_Args& args) { |
1987 | assert(0 <= center.node.x); |
1988 | assert(center.node.x < map.get_width()); |
1989 | assert(0 <= center.node.y); |
1990 | @@ -75,7 +74,7 @@ |
1991 | if (Editor_Tool_Set_Port_Space_Callback(mr.location(), map)) { |
1992 | map.set_port_space(mr.location(), true); |
1993 | Area<FCoords> a(mr.location(), 0); |
1994 | - map.recalc_for_field_area(a); |
1995 | + map.recalc_for_field_area(world, a); |
1996 | ++nr; |
1997 | } |
1998 | } while (mr.advance(map)); |
1999 | @@ -83,19 +82,19 @@ |
2000 | return nr; |
2001 | } |
2002 | |
2003 | -int32_t Editor_Set_Port_Space_Tool::handle_undo_impl |
2004 | - (Map & map, Node_and_Triangle< Coords > center, |
2005 | - Editor_Interactive & parent, Editor_Action_Args & args) |
2006 | -{ |
2007 | - return parent.tools.unset_port_space.handle_click_impl(map, center, parent, args); |
2008 | +int32_t Editor_Set_Port_Space_Tool::handle_undo_impl(Map& map, |
2009 | + const Widelands::World& world, |
2010 | + Node_and_Triangle<Coords> center, |
2011 | + Editor_Interactive& parent, |
2012 | + Editor_Action_Args& args) { |
2013 | + return parent.tools.unset_port_space.handle_click_impl(map, world, center, parent, args); |
2014 | } |
2015 | |
2016 | - |
2017 | -int32_t Editor_Unset_Port_Space_Tool::handle_click_impl |
2018 | - (Map & map, |
2019 | - Node_and_Triangle<> const center, |
2020 | - Editor_Interactive &, Editor_Action_Args & args) |
2021 | -{ |
2022 | +int32_t Editor_Unset_Port_Space_Tool::handle_click_impl(Map& map, |
2023 | + const Widelands::World& world, |
2024 | + Node_and_Triangle<> const center, |
2025 | + Editor_Interactive&, |
2026 | + Editor_Action_Args& args) { |
2027 | assert(0 <= center.node.x); |
2028 | assert(center.node.x < map.get_width()); |
2029 | assert(0 <= center.node.y); |
2030 | @@ -110,7 +109,7 @@ |
2031 | if (Editor_Tool_Set_Port_Space_Callback(mr.location(), map)) { |
2032 | map.set_port_space(mr.location(), false); |
2033 | Area<FCoords> a(mr.location(), 0); |
2034 | - map.recalc_for_field_area(a); |
2035 | + map.recalc_for_field_area(world, a); |
2036 | ++nr; |
2037 | } |
2038 | } while (mr.advance(map)); |
2039 | @@ -118,10 +117,10 @@ |
2040 | return nr; |
2041 | } |
2042 | |
2043 | - |
2044 | -int32_t Editor_Unset_Port_Space_Tool::handle_undo_impl |
2045 | - (Map & map, Node_and_Triangle< Coords > center, |
2046 | - Editor_Interactive & parent, Editor_Action_Args & args) |
2047 | -{ |
2048 | - return parent.tools.set_port_space.handle_click_impl(map, center, parent, args); |
2049 | +int32_t Editor_Unset_Port_Space_Tool::handle_undo_impl(Map& map, |
2050 | + const Widelands::World& world, |
2051 | + Node_and_Triangle<Coords> center, |
2052 | + Editor_Interactive& parent, |
2053 | + Editor_Action_Args& args) { |
2054 | + return parent.tools.set_port_space.handle_click_impl(map, world, center, parent, args); |
2055 | } |
2056 | |
2057 | === modified file 'src/editor/tools/editor_set_port_space_tool.h' |
2058 | --- src/editor/tools/editor_set_port_space_tool.h 2014-03-09 18:32:29 +0000 |
2059 | +++ src/editor/tools/editor_set_port_space_tool.h 2014-06-17 15:48:25 +0000 |
2060 | @@ -31,13 +31,17 @@ |
2061 | public: |
2062 | Editor_Unset_Port_Space_Tool(); |
2063 | |
2064 | - int32_t handle_click_impl |
2065 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
2066 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
2067 | + int32_t handle_click_impl(Widelands::Map& map, |
2068 | + const Widelands::World& world, |
2069 | + Widelands::Node_and_Triangle<> center, |
2070 | + Editor_Interactive& parent, |
2071 | + Editor_Action_Args& args) override; |
2072 | |
2073 | - int32_t handle_undo_impl |
2074 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
2075 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
2076 | + int32_t handle_undo_impl(Widelands::Map& map, |
2077 | + const Widelands::World& world, |
2078 | + Widelands::Node_and_Triangle<> center, |
2079 | + Editor_Interactive& parent, |
2080 | + Editor_Action_Args& args) override; |
2081 | |
2082 | char const * get_sel_impl() const override {return FSEL_EUPS_FILENAME;} |
2083 | }; |
2084 | @@ -48,13 +52,17 @@ |
2085 | public: |
2086 | Editor_Set_Port_Space_Tool(Editor_Unset_Port_Space_Tool &); |
2087 | |
2088 | - int32_t handle_click_impl |
2089 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
2090 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
2091 | + int32_t handle_click_impl(Widelands::Map& map, |
2092 | + const Widelands::World& world, |
2093 | + Widelands::Node_and_Triangle<> center, |
2094 | + Editor_Interactive& parent, |
2095 | + Editor_Action_Args& args) override; |
2096 | |
2097 | - int32_t handle_undo_impl |
2098 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
2099 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
2100 | + int32_t handle_undo_impl(Widelands::Map& map, |
2101 | + const Widelands::World& world, |
2102 | + Widelands::Node_and_Triangle<> center, |
2103 | + Editor_Interactive& parent, |
2104 | + Editor_Action_Args& args) override; |
2105 | |
2106 | char const * get_sel_impl() const override {return FSEL_ESPS_FILENAME;} |
2107 | }; |
2108 | |
2109 | === modified file 'src/editor/tools/editor_set_resources_tool.cc' |
2110 | --- src/editor/tools/editor_set_resources_tool.cc 2014-05-27 11:01:15 +0000 |
2111 | +++ src/editor/tools/editor_set_resources_tool.cc 2014-06-17 15:48:25 +0000 |
2112 | @@ -25,19 +25,18 @@ |
2113 | #include "graphic/graphic.h" |
2114 | #include "logic/field.h" |
2115 | #include "logic/mapregion.h" |
2116 | -#include "logic/world.h" |
2117 | +#include "logic/world/resource_description.h" |
2118 | +#include "logic/world/world.h" |
2119 | #include "wui/overlay_manager.h" |
2120 | |
2121 | /** |
2122 | * Sets the resources of the current to a fixed value |
2123 | */ |
2124 | -int32_t Editor_Set_Resources_Tool::handle_click_impl |
2125 | - (Widelands::Map & map, |
2126 | - Widelands::Node_and_Triangle<> const center, |
2127 | - Editor_Interactive & /* parent */, |
2128 | - Editor_Action_Args & args) |
2129 | -{ |
2130 | - const Widelands::World & world = map.world(); |
2131 | +int32_t Editor_Set_Resources_Tool::handle_click_impl(Widelands::Map& map, |
2132 | + const Widelands::World& world, |
2133 | + Widelands::Node_and_Triangle<> const center, |
2134 | + Editor_Interactive& /* parent */, |
2135 | + Editor_Action_Args& args) { |
2136 | OverlayManager & overlay_manager = map.overlay_manager(); |
2137 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
2138 | (map, |
2139 | @@ -46,7 +45,7 @@ |
2140 | do { |
2141 | int32_t res = mr.location().field->get_resources(); |
2142 | int32_t amount = args.set_to; |
2143 | - int32_t max_amount = world.get_resource(args.cur_res)->get_max_amount(); |
2144 | + int32_t max_amount = world.get_resource(args.cur_res)->max_amount(); |
2145 | |
2146 | if (amount < 0) |
2147 | amount = 0; |
2148 | @@ -56,7 +55,7 @@ |
2149 | args.orgResT.push_back(res); |
2150 | args.orgRes.push_back(mr.location().field->get_resources_amount()); |
2151 | |
2152 | - if (Editor_Change_Resource_Tool_Callback(mr.location(), map, args.cur_res)) { |
2153 | + if (Editor_Change_Resource_Tool_Callback(mr.location(), map, world, args.cur_res)) { |
2154 | // Ok, we're doing something. First remove the current overlays. |
2155 | const Image* pic = g_gr->images().get |
2156 | (world.get_resource(res)->get_editor_pic (mr.location().field->get_resources_amount())); |
2157 | @@ -72,19 +71,19 @@ |
2158 | pic = |
2159 | g_gr->images().get(world.get_resource(args.cur_res)->get_editor_pic(amount)); |
2160 | overlay_manager.register_overlay(mr.location(), pic, 4); |
2161 | - map.recalc_for_field_area |
2162 | - (Widelands::Area<Widelands::FCoords>(mr.location(), 0)); |
2163 | + map.recalc_for_field_area(world, Widelands::Area<Widelands::FCoords>(mr.location(), 0)); |
2164 | } |
2165 | } |
2166 | } while (mr.advance(map)); |
2167 | return mr.radius(); |
2168 | } |
2169 | |
2170 | -int32_t Editor_Set_Resources_Tool::handle_undo_impl |
2171 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
2172 | - Editor_Interactive & /* parent */, Editor_Action_Args & args) |
2173 | -{ |
2174 | - const Widelands::World & world = map.world(); |
2175 | +int32_t |
2176 | +Editor_Set_Resources_Tool::handle_undo_impl(Widelands::Map& map, |
2177 | + const Widelands::World& world, |
2178 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
2179 | + Editor_Interactive& /* parent */, |
2180 | + Editor_Action_Args& args) { |
2181 | OverlayManager & overlay_manager = map.overlay_manager(); |
2182 | Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr |
2183 | (map, |
2184 | @@ -94,7 +93,7 @@ |
2185 | do { |
2186 | int32_t res = mr.location().field->get_resources(); |
2187 | int32_t amount = *ir; |
2188 | - int32_t max_amount = world.get_resource(args.cur_res)->get_max_amount(); |
2189 | + int32_t max_amount = world.get_resource(args.cur_res)->max_amount(); |
2190 | |
2191 | if (amount < 0) |
2192 | amount = 0; |
2193 | @@ -115,8 +114,7 @@ |
2194 | // set new overlay |
2195 | pic = g_gr->images().get(world.get_resource(*it)->get_editor_pic(amount)); |
2196 | overlay_manager.register_overlay(mr.location(), pic, 4); |
2197 | - map.recalc_for_field_area |
2198 | - (Widelands::Area<Widelands::FCoords>(mr.location(), 0)); |
2199 | + map.recalc_for_field_area(world, Widelands::Area<Widelands::FCoords>(mr.location(), 0)); |
2200 | } |
2201 | ++ir; |
2202 | ++it; |
2203 | |
2204 | === modified file 'src/editor/tools/editor_set_resources_tool.h' |
2205 | --- src/editor/tools/editor_set_resources_tool.h 2014-02-22 18:04:02 +0000 |
2206 | +++ src/editor/tools/editor_set_resources_tool.h 2014-06-17 15:48:25 +0000 |
2207 | @@ -21,7 +21,6 @@ |
2208 | #define EDITOR_SET_RESOURCES_TOOL_H |
2209 | |
2210 | #include "editor/tools/editor_tool.h" |
2211 | -#include "logic/world.h" |
2212 | |
2213 | /// Decreases the resources of a node by a value. |
2214 | struct Editor_Set_Resources_Tool : public Editor_Tool { |
2215 | @@ -29,13 +28,17 @@ |
2216 | : Editor_Tool(*this, *this), m_cur_res(0), m_set_to(0) |
2217 | {} |
2218 | |
2219 | - int32_t handle_click_impl |
2220 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
2221 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
2222 | + int32_t handle_click_impl(Widelands::Map& map, |
2223 | + const Widelands::World& world, |
2224 | + Widelands::Node_and_Triangle<> center, |
2225 | + Editor_Interactive& parent, |
2226 | + Editor_Action_Args& args) override; |
2227 | |
2228 | - int32_t handle_undo_impl |
2229 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
2230 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
2231 | + int32_t handle_undo_impl(Widelands::Map& map, |
2232 | + const Widelands::World& world, |
2233 | + Widelands::Node_and_Triangle<> center, |
2234 | + Editor_Interactive& parent, |
2235 | + Editor_Action_Args& args) override; |
2236 | |
2237 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
2238 | |
2239 | @@ -51,7 +54,7 @@ |
2240 | |
2241 | private: |
2242 | Widelands::Resource_Index m_cur_res; |
2243 | - uint8_t m_set_to; |
2244 | + uint8_t m_set_to; |
2245 | }; |
2246 | |
2247 | #endif |
2248 | |
2249 | === modified file 'src/editor/tools/editor_set_starting_pos_tool.cc' |
2250 | --- src/editor/tools/editor_set_starting_pos_tool.cc 2014-05-27 11:01:15 +0000 |
2251 | +++ src/editor/tools/editor_set_starting_pos_tool.cc 2014-06-17 15:48:25 +0000 |
2252 | @@ -62,12 +62,11 @@ |
2253 | strcpy(fsel_picsname, FSEL_PIC_FILENAME); |
2254 | } |
2255 | |
2256 | - |
2257 | -int32_t Editor_Set_Starting_Pos_Tool::handle_click_impl |
2258 | - (Widelands::Map & map, |
2259 | - Widelands::Node_and_Triangle<> const center, |
2260 | - Editor_Interactive &, Editor_Action_Args &) |
2261 | -{ |
2262 | +int32_t Editor_Set_Starting_Pos_Tool::handle_click_impl(Widelands::Map& map, |
2263 | + const Widelands::World&, |
2264 | + Widelands::Node_and_Triangle<> const center, |
2265 | + Editor_Interactive&, |
2266 | + Editor_Action_Args&) { |
2267 | assert(0 <= center.node.x); |
2268 | assert(center.node.x < map.get_width()); |
2269 | assert(0 <= center.node.y); |
2270 | |
2271 | === modified file 'src/editor/tools/editor_set_starting_pos_tool.h' |
2272 | --- src/editor/tools/editor_set_starting_pos_tool.h 2014-03-09 18:32:29 +0000 |
2273 | +++ src/editor/tools/editor_set_starting_pos_tool.h 2014-06-17 15:48:25 +0000 |
2274 | @@ -34,9 +34,11 @@ |
2275 | struct Editor_Set_Starting_Pos_Tool : public Editor_Tool { |
2276 | Editor_Set_Starting_Pos_Tool(); |
2277 | |
2278 | - int32_t handle_click_impl |
2279 | - (Widelands::Map &, Widelands::Node_and_Triangle<>, |
2280 | - Editor_Interactive &, Editor_Action_Args &) override; |
2281 | + int32_t handle_click_impl(Widelands::Map&, |
2282 | + const Widelands::World& world, |
2283 | + Widelands::Node_and_Triangle<>, |
2284 | + Editor_Interactive&, |
2285 | + Editor_Action_Args&) override; |
2286 | char const * get_sel_impl() const override |
2287 | {return m_current_sel_pic;} |
2288 | |
2289 | |
2290 | === modified file 'src/editor/tools/editor_set_terrain_tool.cc' |
2291 | --- src/editor/tools/editor_set_terrain_tool.cc 2013-07-26 20:19:36 +0000 |
2292 | +++ src/editor/tools/editor_set_terrain_tool.cc 2014-06-17 15:48:25 +0000 |
2293 | @@ -25,11 +25,11 @@ |
2294 | |
2295 | using Widelands::TCoords; |
2296 | |
2297 | -int32_t Editor_Set_Terrain_Tool::handle_click_impl |
2298 | - (Widelands::Map & map, |
2299 | - Widelands::Node_and_Triangle<> const center, |
2300 | - Editor_Interactive & /* parent */, Editor_Action_Args & args) |
2301 | -{ |
2302 | +int32_t Editor_Set_Terrain_Tool::handle_click_impl(Widelands::Map& map, |
2303 | + const Widelands::World& world, |
2304 | + Widelands::Node_and_Triangle<> const center, |
2305 | + Editor_Interactive& /* parent */, |
2306 | + Editor_Action_Args& args) { |
2307 | assert |
2308 | (center.triangle.t == TCoords<>::D or center.triangle.t == TCoords<>::R); |
2309 | uint16_t const radius = args.sel_radius; |
2310 | @@ -60,17 +60,19 @@ |
2311 | std::list<Widelands::Terrain_Index>::iterator i = args.terrainType.begin(); |
2312 | do { |
2313 | max = std::max |
2314 | - (max, map.change_terrain(mr.location(), *i)); |
2315 | + (max, map.change_terrain(world, mr.location(), *i)); |
2316 | ++i; |
2317 | } while (mr.advance(map)); |
2318 | } |
2319 | return radius + max; |
2320 | } |
2321 | |
2322 | -int32_t Editor_Set_Terrain_Tool::handle_undo_impl |
2323 | - (Widelands::Map & map, Widelands::Node_and_Triangle< Widelands::Coords > center, |
2324 | - Editor_Interactive & /* parent */, Editor_Action_Args & args) |
2325 | -{ |
2326 | +int32_t |
2327 | +Editor_Set_Terrain_Tool::handle_undo_impl(Widelands::Map& map, |
2328 | + const Widelands::World& world, |
2329 | + Widelands::Node_and_Triangle<Widelands::Coords> center, |
2330 | + Editor_Interactive& /* parent */, |
2331 | + Editor_Action_Args& args) { |
2332 | assert |
2333 | (center.triangle.t == TCoords<>::D or center.triangle.t == TCoords<>::R); |
2334 | uint16_t const radius = args.sel_radius; |
2335 | @@ -88,7 +90,7 @@ |
2336 | std::list<Widelands::Terrain_Index>::iterator i = args.origTerrainType.begin(); |
2337 | do { |
2338 | max = std::max |
2339 | - (max, map.change_terrain(mr.location(), *i)); |
2340 | + (max, map.change_terrain(world, mr.location(), *i)); |
2341 | ++i; |
2342 | } while (mr.advance(map)); |
2343 | return radius + max; |
2344 | |
2345 | === modified file 'src/editor/tools/editor_set_terrain_tool.h' |
2346 | --- src/editor/tools/editor_set_terrain_tool.h 2014-02-22 18:04:02 +0000 |
2347 | +++ src/editor/tools/editor_set_terrain_tool.h 2014-06-17 15:48:25 +0000 |
2348 | @@ -26,13 +26,17 @@ |
2349 | struct Editor_Set_Terrain_Tool : public Editor_Tool, public MultiSelect { |
2350 | Editor_Set_Terrain_Tool() : Editor_Tool(*this, *this) {} |
2351 | |
2352 | - int32_t handle_click_impl |
2353 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
2354 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
2355 | + int32_t handle_click_impl(Widelands::Map& map, |
2356 | + const Widelands::World& world, |
2357 | + Widelands::Node_and_Triangle<> center, |
2358 | + Editor_Interactive& parent, |
2359 | + Editor_Action_Args& args) override; |
2360 | |
2361 | - int32_t handle_undo_impl |
2362 | - (Widelands::Map & map, Widelands::Node_and_Triangle<> center, |
2363 | - Editor_Interactive & parent, Editor_Action_Args & args) override; |
2364 | + int32_t handle_undo_impl(Widelands::Map& map, |
2365 | + const Widelands::World& world, |
2366 | + Widelands::Node_and_Triangle<> center, |
2367 | + Editor_Interactive& parent, |
2368 | + Editor_Action_Args& args) override; |
2369 | |
2370 | Editor_Action_Args format_args_impl(Editor_Interactive & parent) override; |
2371 | |
2372 | |
2373 | === modified file 'src/editor/tools/editor_tool.h' |
2374 | --- src/editor/tools/editor_tool.h 2013-09-22 18:01:36 +0000 |
2375 | +++ src/editor/tools/editor_tool.h 2014-06-17 15:48:25 +0000 |
2376 | @@ -28,7 +28,10 @@ |
2377 | #include "logic/widelands_geometry.h" |
2378 | |
2379 | struct Editor_Interactive; |
2380 | -namespace Widelands {class Map;} |
2381 | +namespace Widelands { |
2382 | +class Map; |
2383 | +class World; |
2384 | +} |
2385 | |
2386 | /** |
2387 | * An editor tool is a tool that can be selected in the editor. Examples are: |
2388 | @@ -46,22 +49,22 @@ |
2389 | enum Tool_Index {First, Second, Third}; |
2390 | int32_t handle_click |
2391 | (const Tool_Index i, |
2392 | - Widelands::Map & map, Widelands::Node_and_Triangle<> const center, |
2393 | + Widelands::Map & map, const Widelands::World& world, Widelands::Node_and_Triangle<> const center, |
2394 | Editor_Interactive & parent, Editor_Action_Args & args) |
2395 | { |
2396 | return |
2397 | (i == First ? *this : i == Second ? m_second : m_third) |
2398 | - .handle_click_impl(map, center, parent, args); |
2399 | + .handle_click_impl(map, world, center, parent, args); |
2400 | } |
2401 | |
2402 | int32_t handle_undo |
2403 | (const Tool_Index i, |
2404 | - Widelands::Map & map, Widelands::Node_and_Triangle<> const center, |
2405 | + Widelands::Map & map, const Widelands::World& world, Widelands::Node_and_Triangle<> const center, |
2406 | Editor_Interactive & parent, Editor_Action_Args & args) |
2407 | { |
2408 | return |
2409 | (i == First ? *this : i == Second ? m_second : m_third) |
2410 | - .handle_undo_impl(map, center, parent, args); |
2411 | + .handle_undo_impl(map, world, center, parent, args); |
2412 | } |
2413 | |
2414 | const char * get_sel(const Tool_Index i) { |
2415 | @@ -81,12 +84,18 @@ |
2416 | virtual Editor_Action_Args format_args_impl(Editor_Interactive & parent) { |
2417 | return Editor_Action_Args(parent); |
2418 | } |
2419 | - virtual int32_t handle_click_impl |
2420 | - (Widelands::Map &, Widelands::Node_and_Triangle<>, Editor_Interactive &, Editor_Action_Args &) |
2421 | - = 0; |
2422 | - virtual int32_t handle_undo_impl |
2423 | - (Widelands::Map &, Widelands::Node_and_Triangle<>, Editor_Interactive &, Editor_Action_Args &) |
2424 | - {return 0;} // non unduable tools don't need to implement this. |
2425 | + virtual int32_t handle_click_impl(Widelands::Map&, |
2426 | + const Widelands::World& world, |
2427 | + Widelands::Node_and_Triangle<>, |
2428 | + Editor_Interactive&, |
2429 | + Editor_Action_Args&) = 0; |
2430 | + virtual int32_t handle_undo_impl(Widelands::Map&, |
2431 | + const Widelands::World&, |
2432 | + Widelands::Node_and_Triangle<>, |
2433 | + Editor_Interactive&, |
2434 | + Editor_Action_Args&) { |
2435 | + return 0; |
2436 | + } // non unduable tools don't need to implement this. |
2437 | virtual const char * get_sel_impl() const = 0; |
2438 | virtual bool operates_on_triangles() const {return false;}; |
2439 | |
2440 | |
2441 | === added file 'src/editor/ui_menus/categorized_item_selection_menu.h' |
2442 | --- src/editor/ui_menus/categorized_item_selection_menu.h 1970-01-01 00:00:00 +0000 |
2443 | +++ src/editor/ui_menus/categorized_item_selection_menu.h 2014-06-17 15:48:25 +0000 |
2444 | @@ -0,0 +1,185 @@ |
2445 | +/* |
2446 | + * Copyright (C) 2006-2014 by the Widelands Development Team |
2447 | + * |
2448 | + * This program is free software; you can redistribute it and/or |
2449 | + * modify it under the terms of the GNU General Public License |
2450 | + * as published by the Free Software Foundation; either version 2 |
2451 | + * of the License, or (at your option) any later version. |
2452 | + * |
2453 | + * This program is distributed in the hope that it will be useful, |
2454 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2455 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2456 | + * GNU General Public License for more details. |
2457 | + * |
2458 | + * You should have received a copy of the GNU General Public License |
2459 | + * along with this program; if not, write to the Free Software |
2460 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
2461 | + * |
2462 | + */ |
2463 | + |
2464 | +#ifndef MULTI_SELECT_MENU_H |
2465 | +#define MULTI_SELECT_MENU_H |
2466 | + |
2467 | +#include <string> |
2468 | +#include <cmath> |
2469 | + |
2470 | +#include "description_maintainer.h" |
2471 | +#include "graphic/image.h" |
2472 | +#include "graphic/image_transformations.h" |
2473 | +#include "i18n.h" |
2474 | +#include "logic/world/editor_category.h" |
2475 | +#include "ui_basic/box.h" |
2476 | +#include "ui_basic/checkbox.h" |
2477 | +#include "ui_basic/panel.h" |
2478 | +#include "ui_basic/tabpanel.h" |
2479 | +#include "ui_basic/textarea.h" |
2480 | + |
2481 | +template <typename DescriptionType, typename ToolType> |
2482 | +class CategorizedItemSelectionMenu : public UI::Box { |
2483 | +public: |
2484 | + // Creates a box with a tab panel for each category in 'categories' and |
2485 | + // populates them with the 'descriptions' ordered by the category by calling |
2486 | + // 'create_checkbox' for each of the descriptions. Calls |
2487 | + // 'select_correct_tool' whenever a selection has been made, also keeps a |
2488 | + // text label updated and updates the 'tool' with current selections. Does |
2489 | + // not take ownership. |
2490 | + CategorizedItemSelectionMenu( |
2491 | + UI::Panel* parent, |
2492 | + const DescriptionMaintainer<Widelands::EditorCategory>& categories, |
2493 | + const DescriptionMaintainer<DescriptionType>& descriptions, |
2494 | + std::function<UI::Checkbox*(UI::Panel* parent, const DescriptionType& descr)> create_checkbox, |
2495 | + const std::function<void()> select_correct_tool, |
2496 | + ToolType* const tool); |
2497 | + |
2498 | +private: |
2499 | + // Called when an item was selected. |
2500 | + void selected(int32_t, bool); |
2501 | + |
2502 | + // Update the label with the currently selected object names. |
2503 | + void update_label(); |
2504 | + |
2505 | + const DescriptionMaintainer<DescriptionType>& descriptions_; |
2506 | + std::function<void()> select_correct_tool_; |
2507 | + bool protect_against_recursive_select_; |
2508 | + UI::Textarea current_selection_names_; |
2509 | + std::map<int, UI::Checkbox*> checkboxes_; |
2510 | + ToolType* const tool_; // not owned |
2511 | +}; |
2512 | + |
2513 | +template <typename DescriptionType, typename ToolType> |
2514 | +CategorizedItemSelectionMenu<DescriptionType, ToolType>::CategorizedItemSelectionMenu( |
2515 | + UI::Panel* parent, |
2516 | + const DescriptionMaintainer<Widelands::EditorCategory>& categories, |
2517 | + const DescriptionMaintainer<DescriptionType>& descriptions, |
2518 | + const std::function<UI::Checkbox*(UI::Panel* parent, const DescriptionType& descr)> |
2519 | + create_checkbox, |
2520 | + const std::function<void()> select_correct_tool, |
2521 | + ToolType* const tool) |
2522 | + : UI::Box(parent, 0, 0, UI::Box::Vertical), |
2523 | + descriptions_(descriptions), |
2524 | + select_correct_tool_(select_correct_tool), |
2525 | + protect_against_recursive_select_(false), |
2526 | + current_selection_names_(this, 0, 0, 0, 20, UI::Align_Center), |
2527 | + tool_(tool) |
2528 | +{ |
2529 | + |
2530 | + UI::Tab_Panel* tab_panel = new UI::Tab_Panel(this, 0, 0, nullptr); |
2531 | + this->add(tab_panel, UI::Align_Center); |
2532 | + |
2533 | + for (uint32_t category_index = 0; category_index < categories.get_nitems(); ++category_index) { |
2534 | + const Widelands::EditorCategory& category = *categories.get(category_index); |
2535 | + |
2536 | + std::vector<int> item_indices; |
2537 | + for (size_t j = 0; j < descriptions_.get_nitems(); ++j) { |
2538 | + if (descriptions_.get(j)->editor_category().name() != category.name()) { |
2539 | + continue; |
2540 | + } |
2541 | + item_indices.push_back(j); |
2542 | + } |
2543 | + |
2544 | + UI::Box* vertical = new UI::Box(tab_panel, 0, 0, UI::Box::Vertical); |
2545 | + const int kSpacing = 5; |
2546 | + vertical->add_space(kSpacing); |
2547 | + |
2548 | + const uint32_t items_in_row = |
2549 | + static_cast<uint32_t>(std::ceil(std::sqrt(static_cast<float>(item_indices.size())))); |
2550 | + int nitems_handled = 0; |
2551 | + UI::Box* horizontal = nullptr; |
2552 | + for (const int i : item_indices) { |
2553 | + if (nitems_handled % items_in_row == 0) { |
2554 | + horizontal = new UI::Box(vertical, 0, 0, UI::Box::Horizontal); |
2555 | + horizontal->add_space(kSpacing); |
2556 | + |
2557 | + vertical->add(horizontal, UI::Align_Left); |
2558 | + vertical->add_space(kSpacing); |
2559 | + } |
2560 | + assert(horizontal != nullptr); |
2561 | + |
2562 | + UI::Checkbox* cb = create_checkbox(horizontal, *descriptions_.get(i)); |
2563 | + cb->set_state(tool_->is_enabled(i)); |
2564 | + cb->changedto.connect(boost::bind(&CategorizedItemSelectionMenu::selected, this, i, _1)); |
2565 | + checkboxes_[i] = cb; |
2566 | + horizontal->add(cb, UI::Align_Left); |
2567 | + horizontal->add_space(kSpacing); |
2568 | + ++nitems_handled; |
2569 | + } |
2570 | + |
2571 | + const Image* category_picture = category.picture(); |
2572 | + const int kCategoryImageSize = 24; |
2573 | + if (category_picture->width() > kCategoryImageSize || |
2574 | + category_picture->height() > kCategoryImageSize) { |
2575 | + category_picture = |
2576 | + ImageTransformations::resize(category_picture, kCategoryImageSize, kCategoryImageSize); |
2577 | + } |
2578 | + tab_panel->add(category.name(), category_picture, vertical, category.descname()); |
2579 | + } |
2580 | + this->add(¤t_selection_names_, UI::Align_Center, true); |
2581 | +} |
2582 | + |
2583 | +template <typename DescriptionType, typename ToolType> |
2584 | +void CategorizedItemSelectionMenu<DescriptionType, ToolType>::selected(const int32_t n, |
2585 | + const bool t) { |
2586 | + if (protect_against_recursive_select_) |
2587 | + return; |
2588 | + |
2589 | + // FIXME This code is erroneous. It checks the current key state. What it |
2590 | + // FIXME needs is the key state at the time the mouse was clicked. See the |
2591 | + // FIXME usage comment for get_key_state. |
2592 | + const bool multiselect = get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL); |
2593 | + if (not t and(not multiselect or tool_->get_nr_enabled() == 1)) |
2594 | + checkboxes_[n]->set_state(true); |
2595 | + else { |
2596 | + if (not multiselect) { |
2597 | + for (uint32_t i = 0; tool_->get_nr_enabled(); ++i) |
2598 | + tool_->enable(i, false); |
2599 | + // disable all checkboxes |
2600 | + protect_against_recursive_select_ = true; |
2601 | + const int32_t size = checkboxes_.size(); |
2602 | + for (int32_t i = 0; i < size; ++i) { |
2603 | + if (i != n) |
2604 | + checkboxes_[i]->set_state(false); |
2605 | + } |
2606 | + protect_against_recursive_select_ = false; |
2607 | + } |
2608 | + |
2609 | + tool_->enable(n, t); |
2610 | + select_correct_tool_(); |
2611 | + update_label(); |
2612 | + } |
2613 | +} |
2614 | + |
2615 | +template <typename DescriptionType, typename ToolType> |
2616 | +void CategorizedItemSelectionMenu<DescriptionType, ToolType>::update_label() { |
2617 | + std::string buf = _("Current:"); |
2618 | + int j = tool_->get_nr_enabled(); |
2619 | + for (int i = 0; j; ++i) { |
2620 | + if (tool_->is_enabled(i)) { |
2621 | + buf += " "; |
2622 | + buf += descriptions_.get(i)->descname(); |
2623 | + --j; |
2624 | + } |
2625 | + } |
2626 | + current_selection_names_.set_text(buf); |
2627 | +} |
2628 | + |
2629 | +#endif /* end of include guard: MULTI_SELECT_MENU_H */ |
2630 | |
2631 | === modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc' |
2632 | --- src/editor/ui_menus/editor_main_menu_load_map.cc 2014-04-06 16:58:10 +0000 |
2633 | +++ src/editor/ui_menus/editor_main_menu_load_map.cc 2014-06-17 15:48:25 +0000 |
2634 | @@ -30,7 +30,6 @@ |
2635 | #include "io/filesystem/layered_filesystem.h" |
2636 | #include "logic/building.h" |
2637 | #include "logic/editor_game_base.h" |
2638 | -#include "logic/world.h" |
2639 | #include "map_io/map_loader.h" |
2640 | #include "map_io/widelands_map_loader.h" |
2641 | #include "profile/profile.h" |
2642 | @@ -88,13 +87,6 @@ |
2643 | posy += 20 + spacing; |
2644 | |
2645 | new UI::Textarea |
2646 | - (this, posx, posy, 70, 20, _("World:"), UI::Align_CenterLeft); |
2647 | - m_world = |
2648 | - new UI::Textarea |
2649 | - (this, posx + 70, posy, 200, 20, "---", UI::Align_CenterLeft); |
2650 | - posy += 20 + spacing; |
2651 | - |
2652 | - new UI::Textarea |
2653 | (this, posx, posy, 70, 20, _("Players:"), UI::Align_CenterLeft); |
2654 | m_nrplayers = |
2655 | new UI::Textarea |
2656 | @@ -169,20 +161,12 @@ |
2657 | map_loader->preload_map(true); // This has worked before, no problem. |
2658 | } |
2659 | |
2660 | - // get translated worldsname |
2661 | - std::string world(map.get_world_name()); |
2662 | - std::string worldpath("worlds/" + world); |
2663 | - Profile prof((worldpath + "/conf").c_str(), nullptr, "world_" + world); |
2664 | - Section & global = prof.get_safe_section("world"); |
2665 | - world = global.get_safe_string("name"); |
2666 | - |
2667 | // Translate the map data |
2668 | i18n::Textdomain td("maps"); |
2669 | m_name ->set_text(_(map.get_name())); |
2670 | m_author->set_text(map.get_author()); |
2671 | m_descr ->set_text |
2672 | (_(map.get_description()) + (map.get_hint().empty() ? "" : (std::string("\n") + _(map.get_hint())))); |
2673 | - m_world ->set_text(world); |
2674 | |
2675 | char buf[200]; |
2676 | sprintf(buf, "%i", map.get_nrplayers()); |
2677 | @@ -194,7 +178,6 @@ |
2678 | m_name ->set_text(""); |
2679 | m_author ->set_text(""); |
2680 | m_descr ->set_text(""); |
2681 | - m_world ->set_text(""); |
2682 | m_nrplayers->set_text(""); |
2683 | m_size ->set_text(""); |
2684 | } |
2685 | |
2686 | === modified file 'src/editor/ui_menus/editor_main_menu_load_map.h' |
2687 | --- src/editor/ui_menus/editor_main_menu_load_map.h 2013-07-26 19:16:51 +0000 |
2688 | +++ src/editor/ui_menus/editor_main_menu_load_map.h 2014-06-17 15:48:25 +0000 |
2689 | @@ -44,7 +44,7 @@ |
2690 | |
2691 | void fill_list(); |
2692 | |
2693 | - UI::Textarea * m_name, * m_author, * m_size, * m_world, * m_nrplayers; |
2694 | + UI::Textarea * m_name, * m_author, * m_size, * m_nrplayers; |
2695 | UI::Multiline_Textarea * m_descr; |
2696 | UI::Listselect<const char *> * m_ls; |
2697 | UI::Button * m_ok_btn; |
2698 | |
2699 | === modified file 'src/editor/ui_menus/editor_main_menu_map_options.cc' |
2700 | --- src/editor/ui_menus/editor_main_menu_map_options.cc 2013-07-26 20:19:36 +0000 |
2701 | +++ src/editor/ui_menus/editor_main_menu_map_options.cc 2014-06-17 15:48:25 +0000 |
2702 | @@ -72,11 +72,6 @@ |
2703 | m_nrplayers = |
2704 | new UI::Textarea(this, posx + ta->get_w() + spacing, posy - 2, "1"); |
2705 | posy += height + spacing; |
2706 | - ta = new UI::Textarea(this, posx, posy - 2, _("World:")); |
2707 | - m_world = |
2708 | - new UI::Textarea |
2709 | - (this, posx + ta->get_w() + spacing, posy - 2, "\"Greenland\""); |
2710 | - posy += height + spacing; |
2711 | ta = new UI::Textarea(this, posx, posy - 2, _("Author:")); |
2712 | m_author = |
2713 | new UI::EditBox |
2714 | @@ -125,7 +120,6 @@ |
2715 | m_name ->setText(map.get_name()); |
2716 | sprintf(buf, "%i", map.get_nrplayers()); |
2717 | m_nrplayers->set_text(buf); |
2718 | - m_world ->set_text(map.world().get_name()); |
2719 | m_descr ->set_text(map.get_description()); |
2720 | } |
2721 | |
2722 | |
2723 | === modified file 'src/editor/ui_menus/editor_main_menu_map_options.h' |
2724 | --- src/editor/ui_menus/editor_main_menu_map_options.h 2012-02-15 21:25:34 +0000 |
2725 | +++ src/editor/ui_menus/editor_main_menu_map_options.h 2014-06-17 15:48:25 +0000 |
2726 | @@ -43,7 +43,7 @@ |
2727 | void changed(int32_t); |
2728 | void editbox_changed(); |
2729 | UI::Multiline_Editbox * m_descr; |
2730 | - UI::Textarea * m_world, * m_nrplayers, * m_size; |
2731 | + UI::Textarea * m_nrplayers, * m_size; |
2732 | UI::EditBox * m_name, * m_author; |
2733 | void update(); |
2734 | }; |
2735 | |
2736 | === modified file 'src/editor/ui_menus/editor_main_menu_new_map.cc' |
2737 | --- src/editor/ui_menus/editor_main_menu_new_map.cc 2013-08-05 03:26:31 +0000 |
2738 | +++ src/editor/ui_menus/editor_main_menu_new_map.cc 2014-06-17 15:48:25 +0000 |
2739 | @@ -29,7 +29,7 @@ |
2740 | #include "i18n.h" |
2741 | #include "logic/editor_game_base.h" |
2742 | #include "logic/map.h" |
2743 | -#include "logic/world.h" |
2744 | +#include "logic/world/world.h" |
2745 | #include "profile/profile.h" |
2746 | #include "ui_basic/button.h" |
2747 | #include "ui_basic/progresswindow.h" |
2748 | @@ -43,8 +43,7 @@ |
2749 | UI::Window |
2750 | (&parent, "new_map_menu", |
2751 | (parent.get_w() - 140) / 2, (parent.get_h() - 150) / 2, 140, 150, |
2752 | - _("New Map")), |
2753 | - m_currentworld(0) |
2754 | + _("New Map")) |
2755 | { |
2756 | char buffer[250]; |
2757 | int32_t const offsx = 5; |
2758 | @@ -101,19 +100,6 @@ |
2759 | |
2760 | posy += 20 + spacing + spacing; |
2761 | |
2762 | - Widelands::World::get_all_worlds(m_worlds); |
2763 | - |
2764 | - assert(m_worlds.size()); |
2765 | - while (strcmp(map.get_world_name(), m_worlds[m_currentworld].c_str())) |
2766 | - ++m_currentworld; |
2767 | - |
2768 | - m_world = new UI::Button |
2769 | - (this, "world", |
2770 | - posx, posy, width, height, |
2771 | - g_gr->images().get("pics/but1.png"), |
2772 | - Widelands::World(m_worlds[m_currentworld].c_str()).get_name()); |
2773 | - m_world->sigclicked.connect(boost::bind(&Main_Menu_New_Map::button_clicked, this, 4)); |
2774 | - |
2775 | posy += height + spacing + spacing + spacing; |
2776 | |
2777 | UI::Button * createbtn = new UI::Button |
2778 | @@ -134,14 +120,6 @@ |
2779 | case 1: --m_w; break; |
2780 | case 2: ++m_h; break; |
2781 | case 3: --m_h; break; |
2782 | - case 4: |
2783 | - ++m_currentworld; |
2784 | - if (m_currentworld == m_worlds.size()) |
2785 | - m_currentworld = 0; |
2786 | - m_world->set_title |
2787 | - (Widelands::World(m_worlds[m_currentworld].c_str()).get_name |
2788 | - ()); |
2789 | - break; |
2790 | default: |
2791 | assert(false); |
2792 | } |
2793 | @@ -170,18 +148,16 @@ |
2794 | |
2795 | egbase.cleanup_for_load(); |
2796 | |
2797 | - if (strcmp(map.get_world_name(), m_worlds[m_currentworld].c_str())) |
2798 | - eia.change_world(); |
2799 | - map.create_empty_map |
2800 | - (Widelands::MAP_DIMENSIONS[m_w], Widelands::MAP_DIMENSIONS[m_h], |
2801 | - m_worlds[m_currentworld], |
2802 | - _("No Name"), |
2803 | - g_options.pull_section("global").get_string("realname", _("Unknown"))); |
2804 | + map.create_empty_map(egbase.world(), |
2805 | + Widelands::MAP_DIMENSIONS[m_w], |
2806 | + Widelands::MAP_DIMENSIONS[m_h], |
2807 | + _("No Name"), |
2808 | + g_options.pull_section("global").get_string("realname", _("Unknown"))); |
2809 | |
2810 | egbase.postload (); |
2811 | egbase.load_graphics(loader); |
2812 | |
2813 | - map.recalc_whole_map(); |
2814 | + map.recalc_whole_map(egbase.world()); |
2815 | |
2816 | eia.set_need_save(true); |
2817 | eia.need_complete_redraw(); |
2818 | |
2819 | === modified file 'src/editor/ui_menus/editor_main_menu_new_map.h' |
2820 | --- src/editor/ui_menus/editor_main_menu_new_map.h 2013-07-25 21:05:20 +0000 |
2821 | +++ src/editor/ui_menus/editor_main_menu_new_map.h 2014-06-17 15:48:25 +0000 |
2822 | @@ -40,10 +40,7 @@ |
2823 | |
2824 | private: |
2825 | UI::Textarea * m_width, * m_height; |
2826 | - UI::Button * m_world; |
2827 | int32_t m_w, m_h; |
2828 | - std::vector<std::string>::size_type m_currentworld; |
2829 | - std::vector<std::string> m_worlds; |
2830 | |
2831 | void button_clicked(int32_t); |
2832 | void clicked_create_map(); |
2833 | |
2834 | === modified file 'src/editor/ui_menus/editor_main_menu_random_map.cc' |
2835 | --- src/editor/ui_menus/editor_main_menu_random_map.cc 2013-08-05 03:26:31 +0000 |
2836 | +++ src/editor/ui_menus/editor_main_menu_random_map.cc 2014-06-17 15:48:25 +0000 |
2837 | @@ -29,7 +29,7 @@ |
2838 | #include "i18n.h" |
2839 | #include "logic/editor_game_base.h" |
2840 | #include "logic/map.h" |
2841 | -#include "logic/world.h" |
2842 | +#include "logic/world/world.h" |
2843 | #include "map_generator.h" |
2844 | #include "profile/profile.h" |
2845 | #include "random.h" |
2846 | @@ -40,15 +40,23 @@ |
2847 | |
2848 | using namespace Widelands; |
2849 | |
2850 | -Main_Menu_New_Random_Map::Main_Menu_New_Random_Map |
2851 | - (Editor_Interactive & parent) |
2852 | - : |
2853 | - UI::Window |
2854 | - (&parent, "random_map_menu", |
2855 | - (parent.get_w() - 260) / 2, (parent.get_h() - 450) / 2, 260, 490, |
2856 | - _("New Random Map")), |
2857 | - m_currentworld(0) |
2858 | -{ |
2859 | +Main_Menu_New_Random_Map::Main_Menu_New_Random_Map(Editor_Interactive& parent) : |
2860 | + UI::Window(&parent, |
2861 | + "random_map_menu", |
2862 | + (parent.get_w() - 260) / 2, |
2863 | + (parent.get_h() - 450) / 2, |
2864 | + 260, |
2865 | + 490, |
2866 | + _("New Random Map")), |
2867 | + // TRANSLATORS: The next are world names for the random map generator. |
2868 | + m_world_descriptions( |
2869 | + { |
2870 | + {"greenland", _("Summer")}, |
2871 | + {"winterland", _("Winter")}, |
2872 | + {"desert", _("Desert")}, |
2873 | + {"blackland", _("Black")}, |
2874 | + }), |
2875 | + m_current_world(0) { |
2876 | char buffer[250]; |
2877 | int32_t const offsx = 5; |
2878 | int32_t const offsy = 5; |
2879 | @@ -266,28 +274,17 @@ |
2880 | |
2881 | posy += height + spacing + spacing + spacing; |
2882 | |
2883 | - |
2884 | - |
2885 | // ---------- Worlds ---------- |
2886 | - |
2887 | - Widelands::World::get_all_worlds(m_worlds); |
2888 | - |
2889 | - assert(m_worlds.size()); |
2890 | - while (strcmp(map.get_world_name(), m_worlds[m_currentworld].c_str())) |
2891 | - ++m_currentworld; |
2892 | - |
2893 | m_world = new UI::Button |
2894 | (this, "world", |
2895 | posx, posy, width, height, |
2896 | g_gr->images().get("pics/but1.png"), |
2897 | - Widelands::World(m_worlds[m_currentworld].c_str()).get_name()); |
2898 | + m_world_descriptions[m_current_world].descrname); |
2899 | m_world->sigclicked.connect |
2900 | (boost::bind(&Main_Menu_New_Random_Map::button_clicked, this, SWITCH_WORLD)); |
2901 | |
2902 | posy += height + spacing + spacing + spacing; |
2903 | |
2904 | - |
2905 | - |
2906 | // ---------- Map ID String edit ---------- |
2907 | |
2908 | new UI::Textarea(this, posx + spacing + 20, posy, _("Map ID:")); |
2909 | @@ -395,11 +392,9 @@ |
2910 | m_landval -= 5; |
2911 | break; |
2912 | case SWITCH_WORLD: |
2913 | - ++ m_currentworld; |
2914 | - if (m_currentworld == m_worlds.size()) |
2915 | - m_currentworld = 0; |
2916 | - m_world->set_title |
2917 | - (Widelands::World(m_worlds[m_currentworld].c_str()).get_name()); |
2918 | + ++ m_current_world; |
2919 | + m_current_world %= m_world_descriptions.size(); |
2920 | + m_world->set_title(m_world_descriptions[m_current_world].descrname); |
2921 | break; |
2922 | case SWITCH_ISLAND_MODE: |
2923 | break; |
2924 | @@ -463,16 +458,12 @@ |
2925 | |
2926 | egbase.cleanup_for_load(); |
2927 | |
2928 | - if (strcmp(map.get_world_name(), m_worlds[m_currentworld].c_str())) |
2929 | - eia.change_world(); |
2930 | - |
2931 | UniqueRandomMapInfo mapInfo; |
2932 | set_map_info(mapInfo); |
2933 | |
2934 | std::stringstream sstrm; |
2935 | sstrm << "Random generated map\nRandom number = " |
2936 | << mapInfo.mapNumber << "\n" |
2937 | - << "World = " << m_world->get_title() << "\n" |
2938 | << "Water = " << m_waterval << " %\n" |
2939 | << "Land = " << m_landval << " %\n" |
2940 | << "Wasteland = " << m_wastelandval << " %\n" |
2941 | @@ -480,18 +471,19 @@ |
2942 | << "ID = " << m_idEditbox->text() << "\n"; |
2943 | |
2944 | MapGenerator gen(map, mapInfo, egbase); |
2945 | - map.create_empty_map |
2946 | - (mapInfo.w, mapInfo.h, |
2947 | - m_worlds[m_currentworld].c_str(), _("No Name"), |
2948 | - g_options.pull_section("global").get_string("realname", _("Unknown")), |
2949 | - sstrm.str().c_str()); |
2950 | + map.create_empty_map(egbase.world(), |
2951 | + mapInfo.w, |
2952 | + mapInfo.h, |
2953 | + _("No Name"), |
2954 | + g_options.pull_section("global").get_string("realname", _("Unknown")), |
2955 | + sstrm.str().c_str()); |
2956 | loader.step(_("Generating random map...")); |
2957 | gen.create_random_map(); |
2958 | |
2959 | egbase.postload (); |
2960 | egbase.load_graphics(loader); |
2961 | |
2962 | - map.recalc_whole_map(); |
2963 | + map.recalc_whole_map(egbase.world()); |
2964 | |
2965 | eia.set_need_save(true); |
2966 | eia.need_complete_redraw(); |
2967 | @@ -506,7 +498,7 @@ |
2968 | |
2969 | std::string str = m_idEditbox->text(); |
2970 | |
2971 | - if (!UniqueRandomMapInfo::setFromIdString(mapInfo, str, m_worlds)) |
2972 | + if (!UniqueRandomMapInfo::setFromIdString(mapInfo, str)) |
2973 | m_goButton->set_enabled(false); |
2974 | else { |
2975 | std::stringstream sstrm; |
2976 | @@ -529,15 +521,6 @@ |
2977 | |
2978 | m_res->set_title(m_res_amounts[m_res_amount].c_str()); |
2979 | |
2980 | - // Get world |
2981 | - |
2982 | - m_currentworld = 0; |
2983 | - while |
2984 | - (strcmp(mapInfo.worldName.c_str(), m_worlds[m_currentworld].c_str())) |
2985 | - ++m_currentworld; |
2986 | - m_world->set_title |
2987 | - (Widelands::World(m_worlds[m_currentworld].c_str()).get_name()); |
2988 | - |
2989 | // Update other values in UI as well |
2990 | button_clicked(static_cast<ButtonID>(-1)); |
2991 | |
2992 | @@ -587,5 +570,5 @@ |
2993 | mapInfo.resource_amount = static_cast |
2994 | <Widelands::UniqueRandomMapInfo::Resource_Amount> |
2995 | (m_res_amount); |
2996 | - mapInfo.worldName = m_worlds[m_currentworld]; |
2997 | + mapInfo.world_name = m_world_descriptions[m_current_world].name; |
2998 | } |
2999 | |
3000 | === modified file 'src/editor/ui_menus/editor_main_menu_random_map.h' |
3001 | --- src/editor/ui_menus/editor_main_menu_random_map.h 2013-07-25 21:05:20 +0000 |
3002 | +++ src/editor/ui_menus/editor_main_menu_random_map.h 2014-06-17 15:48:25 +0000 |
3003 | @@ -63,6 +63,13 @@ |
3004 | } ButtonID; |
3005 | |
3006 | private: |
3007 | + struct WorldDescription { |
3008 | + std::string name; |
3009 | + std::string descrname; |
3010 | + }; |
3011 | + |
3012 | + const std::vector<WorldDescription> m_world_descriptions; |
3013 | + int m_current_world; |
3014 | UI::Textarea * m_width, * m_height, * m_land; |
3015 | UI::Textarea * m_water, * m_mountains, * m_wasteland, * m_players; |
3016 | UI::Button * m_res; |
3017 | @@ -72,9 +79,7 @@ |
3018 | int32_t m_w, m_h, m_landval, m_waterval, m_wastelandval; |
3019 | uint8_t m_pn; |
3020 | uint32_t m_mapNumber; |
3021 | - std::vector<std::string>::size_type m_currentworld; |
3022 | uint32_t m_res_amount; |
3023 | - std::vector<std::string> m_worlds; |
3024 | std::vector<std::string> m_res_amounts; |
3025 | |
3026 | UI::EditBox * m_nrEditbox; |
3027 | |
3028 | === modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc' |
3029 | --- src/editor/ui_menus/editor_main_menu_save_map.cc 2014-06-10 20:38:57 +0000 |
3030 | +++ src/editor/ui_menus/editor_main_menu_save_map.cc 2014-06-17 15:48:25 +0000 |
3031 | @@ -100,13 +100,6 @@ |
3032 | posy += 20 + spacing; |
3033 | |
3034 | new UI::Textarea |
3035 | - (this, posx, posy, 70, 20, _("World:"), UI::Align_CenterLeft); |
3036 | - m_world = |
3037 | - new UI::Textarea |
3038 | - (this, posx + 70, posy, 200, 20, "---", UI::Align_CenterLeft); |
3039 | - posy += 20 + spacing; |
3040 | - |
3041 | - new UI::Textarea |
3042 | (this, posx, posy, 70, 20, _("Players:"), UI::Align_CenterLeft); |
3043 | m_nrplayers = |
3044 | new UI::Textarea |
3045 | @@ -237,7 +230,6 @@ |
3046 | m_name ->set_text(map.get_name ()); |
3047 | m_author->set_text(map.get_author ()); |
3048 | m_descr ->set_text(map.get_description()); |
3049 | - m_world ->set_text(map.get_world_name ()); |
3050 | |
3051 | char buf[200]; |
3052 | sprintf(buf, "%i", map.get_nrplayers()); |
3053 | @@ -248,7 +240,6 @@ |
3054 | } else { |
3055 | m_name ->set_text(FileSystem::FS_Filename(name)); |
3056 | m_author ->set_text(""); |
3057 | - m_world ->set_text(""); |
3058 | m_nrplayers->set_text(""); |
3059 | m_size ->set_text(""); |
3060 | if (g_fs->IsDirectory(name)) { |
3061 | |
3062 | === modified file 'src/editor/ui_menus/editor_main_menu_save_map.h' |
3063 | --- src/editor/ui_menus/editor_main_menu_save_map.h 2013-07-26 19:16:51 +0000 |
3064 | +++ src/editor/ui_menus/editor_main_menu_save_map.h 2014-06-17 15:48:25 +0000 |
3065 | @@ -50,7 +50,7 @@ |
3066 | bool save_map(std::string, bool); |
3067 | |
3068 | UI::EditBox * m_editbox; |
3069 | - UI::Textarea * m_name, * m_author, * m_size, * m_world, * m_nrplayers; |
3070 | + UI::Textarea * m_name, * m_author, * m_size, * m_nrplayers; |
3071 | UI::Multiline_Textarea * m_descr; |
3072 | UI::Listselect<const char *> * m_ls; |
3073 | UI::Button * m_ok_btn; |
3074 | |
3075 | === modified file 'src/editor/ui_menus/editor_player_menu.cc' |
3076 | --- src/editor/ui_menus/editor_player_menu.cc 2014-05-27 11:01:15 +0000 |
3077 | +++ src/editor/ui_menus/editor_player_menu.cc 2014-06-17 15:48:25 +0000 |
3078 | @@ -354,9 +354,9 @@ |
3079 | |
3080 | // Register callback function to make sure that only valid locations are |
3081 | // selected. |
3082 | - map.overlay_manager().register_overlay_callback_function |
3083 | - (boost::bind(&Editor_Tool_Set_Starting_Pos_Callback, _1, boost::ref(map))); |
3084 | - map.recalc_whole_map(); |
3085 | + map.overlay_manager().register_overlay_callback_function( |
3086 | + boost::bind(&Editor_Tool_Set_Starting_Pos_Callback, _1, boost::ref(map))); |
3087 | + map.recalc_whole_map(menu.egbase().world()); |
3088 | update(); |
3089 | } |
3090 | |
3091 | @@ -441,5 +441,5 @@ |
3092 | parent.tools.make_infrastructure.set_player(n); |
3093 | overlay_manager.register_overlay_callback_function( |
3094 | boost::bind(&Editor_Make_Infrastructure_Tool_Callback, _1, boost::ref(egbase), n)); |
3095 | - map.recalc_whole_map(); |
3096 | + map.recalc_whole_map(egbase.world()); |
3097 | } |
3098 | |
3099 | === modified file 'src/editor/ui_menus/editor_tool_change_resources_options_menu.cc' |
3100 | --- src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2014-03-09 18:32:29 +0000 |
3101 | +++ src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2014-06-17 15:48:25 +0000 |
3102 | @@ -28,7 +28,8 @@ |
3103 | #include "i18n.h" |
3104 | #include "logic/map.h" |
3105 | #include "logic/widelands.h" |
3106 | -#include "logic/world.h" |
3107 | +#include "logic/world/resource_description.h" |
3108 | +#include "logic/world/world.h" |
3109 | #include "ui_basic/button.h" |
3110 | #include "wui/overlay_manager.h" |
3111 | |
3112 | @@ -124,7 +125,7 @@ |
3113 | m_change_by_decrease.set_repeating(true); |
3114 | m_set_to_increase .set_repeating(true); |
3115 | m_set_to_decrease .set_repeating(true); |
3116 | - const Widelands::World & world = parent.egbase().map().world(); |
3117 | + const Widelands::World & world = parent.egbase().world(); |
3118 | Widelands::Resource_Index const nr_resources = world.get_nr_resources(); |
3119 | |
3120 | // Find the maximal width and height for the resource pictures. |
3121 | @@ -211,11 +212,11 @@ |
3122 | m_increase_tool.set_cur_res(n); |
3123 | m_increase_tool.decrease_tool().set_cur_res(n); |
3124 | |
3125 | - Widelands::Map & map = ref_cast<Editor_Interactive, UI::Panel>(*get_parent()) |
3126 | - .egbase().map(); |
3127 | + Widelands::Editor_Game_Base& egbase = ref_cast<Editor_Interactive, UI::Panel>(*get_parent()).egbase(); |
3128 | + Widelands::Map & map = egbase.map(); |
3129 | map.overlay_manager().register_overlay_callback_function( |
3130 | - boost::bind(&Editor_Change_Resource_Tool_Callback, _1, boost::ref(map), n)); |
3131 | - map.recalc_whole_map(); |
3132 | + boost::bind(&Editor_Change_Resource_Tool_Callback, _1, boost::ref(map), boost::ref(egbase.world()), n)); |
3133 | + map.recalc_whole_map(egbase.world()); |
3134 | select_correct_tool(); |
3135 | |
3136 | update(); |
3137 | @@ -232,7 +233,7 @@ |
3138 | m_set_to_value.set_text(buf); |
3139 | |
3140 | m_cur_selection.set_text |
3141 | - (ref_cast<Editor_Interactive, UI::Panel>(*get_parent()).egbase().map() |
3142 | + (ref_cast<Editor_Interactive, UI::Panel>(*get_parent()).egbase() |
3143 | .world().get_resource(m_increase_tool.set_tool().get_cur_res())->descname()); |
3144 | m_cur_selection.set_pos |
3145 | (Point |
3146 | |
3147 | === modified file 'src/editor/ui_menus/editor_tool_menu.cc' |
3148 | --- src/editor/ui_menus/editor_tool_menu.cc 2014-03-16 20:55:15 +0000 |
3149 | +++ src/editor/ui_menus/editor_tool_menu.cc 2014-06-17 15:48:25 +0000 |
3150 | @@ -143,7 +143,7 @@ |
3151 | Widelands::Map & map = parent.egbase().map(); |
3152 | map.overlay_manager().register_overlay_callback_function( |
3153 | boost::bind(&Editor_Tool_Set_Port_Space_Callback, _1, boost::ref(map))); |
3154 | - map.recalc_whole_map(); |
3155 | + map.recalc_whole_map(parent.egbase().world()); |
3156 | update(); |
3157 | } |
3158 | |
3159 | |
3160 | === modified file 'src/editor/ui_menus/editor_tool_place_bob_options_menu.cc' |
3161 | --- src/editor/ui_menus/editor_tool_place_bob_options_menu.cc 2014-03-31 20:21:27 +0000 |
3162 | +++ src/editor/ui_menus/editor_tool_place_bob_options_menu.cc 2014-06-17 15:48:25 +0000 |
3163 | @@ -27,7 +27,7 @@ |
3164 | #include "i18n.h" |
3165 | #include "logic/critter_bob.h" |
3166 | #include "logic/map.h" |
3167 | -#include "logic/world.h" |
3168 | +#include "logic/world/world.h" |
3169 | #include "ui_basic/box.h" |
3170 | #include "ui_basic/button.h" |
3171 | #include "ui_basic/checkbox.h" |
3172 | @@ -49,7 +49,7 @@ |
3173 | m_click_recursion_protect(false) |
3174 | { |
3175 | int32_t const space = 5; |
3176 | - const Widelands::World & world = parent.egbase().map().world(); |
3177 | + const Widelands::World & world = parent.egbase().world(); |
3178 | int32_t const nr_bobs = world.get_nr_bobs(); |
3179 | const uint32_t bobs_in_row = |
3180 | std::max |
3181 | |
3182 | === modified file 'src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc' |
3183 | --- src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc 2014-04-20 20:02:13 +0000 |
3184 | +++ src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc 2014-06-17 15:48:25 +0000 |
3185 | @@ -26,7 +26,7 @@ |
3186 | #include "graphic/graphic.h" |
3187 | #include "i18n.h" |
3188 | #include "logic/map.h" |
3189 | -#include "logic/world.h" |
3190 | +#include "logic/world/world.h" |
3191 | #include "ui_basic/box.h" |
3192 | #include "ui_basic/button.h" |
3193 | #include "ui_basic/checkbox.h" |
3194 | @@ -34,118 +34,41 @@ |
3195 | #include "wlapplication.h" |
3196 | |
3197 | |
3198 | -using Widelands::Immovable_Descr; |
3199 | - |
3200 | -Editor_Tool_Place_Immovable_Options_Menu:: |
3201 | -Editor_Tool_Place_Immovable_Options_Menu |
3202 | - (Editor_Interactive & parent, |
3203 | - Editor_Place_Immovable_Tool & pit, |
3204 | - UI::UniqueWindow::Registry & registry) |
3205 | -: |
3206 | -Editor_Tool_Options_Menu(parent, registry, 100, 100, _("Immovable Bobs")), |
3207 | -m_tabpanel(this, 0, 0, g_gr->images().get("pics/but1.png")), |
3208 | -m_pit (pit), |
3209 | -m_click_recursion_protect(false) |
3210 | -{ |
3211 | - int32_t const space = 5; |
3212 | - const Widelands::World & world = parent.egbase().map().world(); |
3213 | - const int nr_immovables = world.get_nr_immovables(); |
3214 | - const uint32_t immovables_in_row = std::min |
3215 | - (static_cast<uint32_t> |
3216 | - (ceil(sqrt(static_cast<float>(nr_immovables)))), 6U); |
3217 | - |
3218 | - set_center_panel(&m_tabpanel); |
3219 | - |
3220 | - uint32_t width = 0, height = 0; |
3221 | - for (int32_t j = 0; j < nr_immovables; ++j) { |
3222 | - const Immovable_Descr & descr = *world.get_immovable_descr(j); |
3223 | - const Image& pic = g_gr->animations().get_animation(descr.main_animation()) |
3224 | - .representative_image(RGBColor(0, 0, 0)); |
3225 | - uint16_t w = pic.width(); |
3226 | - uint16_t h = pic.height(); |
3227 | - if (w > width) |
3228 | - width = w; |
3229 | - if (h > height) |
3230 | - height = h; |
3231 | - } |
3232 | - |
3233 | - //box->set_inner_size((immovables_in_row)*(width+1+space)+xstart, |
3234 | - // (immovables_in_row)*(height+1+space)+ystart+yend); |
3235 | - const Image* tab_icon = |
3236 | - g_gr->images().get("pics/list_first_entry.png"); |
3237 | - |
3238 | - Point pos; |
3239 | - uint32_t cur_x = immovables_in_row; |
3240 | - |
3241 | - UI::Box * box; |
3242 | - for (int i = 0; i < nr_immovables; ++cur_x, ++i) { |
3243 | - if (cur_x == immovables_in_row) { |
3244 | - cur_x = 0; |
3245 | - pos = Point(5, 15); |
3246 | - box = |
3247 | - new UI::Box |
3248 | - (&m_tabpanel, 0, 0, UI::Box::Horizontal, |
3249 | - parent.get_inner_w() - 50, parent.get_inner_h() - 50); |
3250 | - box->set_scrolling(true); |
3251 | - m_tabpanel.add("immovables", tab_icon, box); |
3252 | - } |
3253 | - assert(box); |
3254 | - |
3255 | - UI::Checkbox & cb = *new UI::Checkbox |
3256 | - (box, pos, |
3257 | - &g_gr->animations().get_animation(world.get_immovable_descr(i)->main_animation()) |
3258 | - .representative_image(RGBColor(0, 0, 0)), world.get_immovable_descr(i)->descname()); |
3259 | - cb.set_desired_size(width, height); |
3260 | - cb.set_state(m_pit.is_enabled(i)); |
3261 | - cb.changedto.connect |
3262 | - (boost::bind(&Editor_Tool_Place_Immovable_Options_Menu::clicked, this, i, _1)); |
3263 | - m_checkboxes.push_back(&cb); |
3264 | - box->add(&cb, UI::Align_Left); |
3265 | - box->add_space(space); |
3266 | - pos.x += width + 1 + space; |
3267 | - } |
3268 | - |
3269 | - m_tabpanel.activate(0); |
3270 | -} |
3271 | - |
3272 | -/** |
3273 | - * Cleanup |
3274 | - */ |
3275 | -Editor_Tool_Place_Immovable_Options_Menu:: |
3276 | -~Editor_Tool_Place_Immovable_Options_Menu |
3277 | - () |
3278 | -{} |
3279 | - |
3280 | -/** |
3281 | - * Called when one of the state boxes is toggled |
3282 | -*/ |
3283 | -void Editor_Tool_Place_Immovable_Options_Menu::clicked(int32_t n, bool t) |
3284 | -{ |
3285 | - if (m_click_recursion_protect) |
3286 | - return; |
3287 | - |
3288 | - // FIXME This code is erroneous. It checks the current key state. What it |
3289 | - // FIXME needs is the key state at the time the mouse was clicked. See the |
3290 | - // FIXME usage comment for get_key_state. |
3291 | - const bool multiselect = |
3292 | - get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL); |
3293 | - if (not t and (not multiselect or m_pit.get_nr_enabled() == 1)) |
3294 | - m_checkboxes[n]->set_state(true); |
3295 | - else { |
3296 | - if (not multiselect) { |
3297 | - for (uint32_t i = 0; m_pit.get_nr_enabled(); ++i) |
3298 | - m_pit.enable(i, false); |
3299 | - // Disable all checkboxes |
3300 | - const int32_t size = m_checkboxes.size(); |
3301 | - m_click_recursion_protect = true; |
3302 | - for (int32_t i = 0; i < size; ++i) { |
3303 | - if (i != n) |
3304 | - m_checkboxes[i]->set_state(false); |
3305 | - } |
3306 | - m_click_recursion_protect = false; |
3307 | - } |
3308 | - |
3309 | - m_pit.enable(n, t); |
3310 | - select_correct_tool(); |
3311 | - } |
3312 | +namespace { |
3313 | + |
3314 | +using namespace Widelands; |
3315 | + |
3316 | +UI::Checkbox* create_immovable_checkbox(UI::Panel* parent, const Immovable_Descr& immovable_descr) { |
3317 | + const Image& pic = |
3318 | + g_gr->animations().get_animation(immovable_descr.main_animation()).representative_image( |
3319 | + RGBColor(0, 0, 0)); |
3320 | + UI::Checkbox* cb = new UI::Checkbox(parent, Point(0, 0), &pic, immovable_descr.descname()); |
3321 | + const int kMinClickableArea = 24; |
3322 | + cb->set_desired_size(std::max<int>(pic.width(), kMinClickableArea), |
3323 | + std::max<int>(pic.height(), kMinClickableArea)); |
3324 | + return cb; |
3325 | +} |
3326 | + |
3327 | +} // namespace |
3328 | + |
3329 | +Editor_Tool_Place_Immovable_Options_Menu::Editor_Tool_Place_Immovable_Options_Menu( |
3330 | + Editor_Interactive& parent, |
3331 | + Editor_Place_Immovable_Tool& tool, |
3332 | + UI::UniqueWindow::Registry& registry) |
3333 | + : Editor_Tool_Options_Menu(parent, registry, 0, 0, _("Immovable Select")) { |
3334 | + const Widelands::World& world = parent.egbase().world(); |
3335 | + multi_select_menu_.reset( |
3336 | + new CategorizedItemSelectionMenu<Widelands::Immovable_Descr, Editor_Place_Immovable_Tool>( |
3337 | + this, |
3338 | + world.editor_immovable_categories(), |
3339 | + world.immovables(), |
3340 | + [this](UI::Panel* cb_parent, const Immovable_Descr& immovable_descr) { |
3341 | + return create_immovable_checkbox(cb_parent, immovable_descr); |
3342 | + }, |
3343 | + [this] { select_correct_tool(); }, |
3344 | + &tool)); |
3345 | + set_center_panel(multi_select_menu_.get()); |
3346 | +} |
3347 | + |
3348 | +Editor_Tool_Place_Immovable_Options_Menu::~Editor_Tool_Place_Immovable_Options_Menu() { |
3349 | } |
3350 | |
3351 | === modified file 'src/editor/ui_menus/editor_tool_place_immovable_options_menu.h' |
3352 | --- src/editor/ui_menus/editor_tool_place_immovable_options_menu.h 2013-07-26 20:19:36 +0000 |
3353 | +++ src/editor/ui_menus/editor_tool_place_immovable_options_menu.h 2014-06-17 15:48:25 +0000 |
3354 | @@ -22,28 +22,21 @@ |
3355 | |
3356 | #include <vector> |
3357 | |
3358 | +#include "editor/ui_menus/categorized_item_selection_menu.h" |
3359 | #include "editor/ui_menus/editor_tool_options_menu.h" |
3360 | -#include "ui_basic/tabpanel.h" |
3361 | +#include "editor/tools/editor_place_immovable_tool.h" |
3362 | |
3363 | struct Editor_Interactive; |
3364 | -struct Editor_Place_Immovable_Tool; |
3365 | -namespace UI {struct Checkbox;} |
3366 | |
3367 | -struct Editor_Tool_Place_Immovable_Options_Menu : |
3368 | - public Editor_Tool_Options_Menu |
3369 | -{ |
3370 | - Editor_Tool_Place_Immovable_Options_Menu |
3371 | - (Editor_Interactive &, |
3372 | - Editor_Place_Immovable_Tool &, |
3373 | - UI::UniqueWindow::Registry &); |
3374 | +struct Editor_Tool_Place_Immovable_Options_Menu : public Editor_Tool_Options_Menu { |
3375 | + Editor_Tool_Place_Immovable_Options_Menu(Editor_Interactive&, |
3376 | + Editor_Place_Immovable_Tool&, |
3377 | + UI::UniqueWindow::Registry&); |
3378 | virtual ~Editor_Tool_Place_Immovable_Options_Menu(); |
3379 | |
3380 | private: |
3381 | - std::vector<UI::Checkbox *> m_checkboxes; |
3382 | - UI::Tab_Panel m_tabpanel; |
3383 | - Editor_Place_Immovable_Tool & m_pit; |
3384 | - void clicked(int32_t, bool); |
3385 | - bool m_click_recursion_protect; |
3386 | + std::unique_ptr<CategorizedItemSelectionMenu<Widelands::Immovable_Descr, Editor_Place_Immovable_Tool>> |
3387 | + multi_select_menu_; |
3388 | }; |
3389 | |
3390 | #endif |
3391 | |
3392 | === modified file 'src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc' |
3393 | --- src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2014-04-21 10:47:03 +0000 |
3394 | +++ src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2014-06-17 15:48:25 +0000 |
3395 | @@ -30,188 +30,103 @@ |
3396 | #include "graphic/texture.h" |
3397 | #include "i18n.h" |
3398 | #include "logic/map.h" |
3399 | -#include "logic/world.h" |
3400 | -#include "logic/worlddata.h" |
3401 | -#include "ui_basic/button.h" |
3402 | +#include "logic/world/editor_category.h" |
3403 | +#include "logic/world/terrain_description.h" |
3404 | +#include "logic/world/world.h" |
3405 | #include "ui_basic/checkbox.h" |
3406 | #include "ui_basic/panel.h" |
3407 | -#include "wlapplication.h" |
3408 | - |
3409 | -Editor_Tool_Set_Terrain_Options_Menu:: Editor_Tool_Set_Terrain_Options_Menu |
3410 | - (Editor_Interactive & parent, |
3411 | - Editor_Set_Terrain_Tool & tool, |
3412 | - UI::UniqueWindow::Registry & registry) |
3413 | - : |
3414 | - Editor_Tool_Options_Menu(parent, registry, 0, 0, _("Terrain Select")), |
3415 | - m_cur_selection (this, 0, 0, 0, 20, UI::Align_Center), |
3416 | - m_tool (tool), |
3417 | - m_select_recursion_protect(false) |
3418 | -{ |
3419 | - Widelands::World & world = parent.egbase().map().world(); |
3420 | - Widelands::Terrain_Index const nr_terrains = world.get_nr_terrains(); |
3421 | - const uint32_t terrains_in_row = static_cast<uint32_t> |
3422 | - (ceil(sqrt(static_cast<float>(nr_terrains)))); |
3423 | - |
3424 | - static const int32_t check[] = { |
3425 | - 0, // "green" |
3426 | - TERRAIN_DRY, // "dry" |
3427 | - TERRAIN_DRY|TERRAIN_MOUNTAIN, // "mountain" |
3428 | - TERRAIN_DRY|TERRAIN_UNPASSABLE, // "unpassable" |
3429 | - TERRAIN_ACID|TERRAIN_DRY|TERRAIN_UNPASSABLE, // "dead" or "acid" |
3430 | - TERRAIN_UNPASSABLE|TERRAIN_DRY|TERRAIN_WATER, |
3431 | - }; |
3432 | - |
3433 | - m_checkboxes.resize(nr_terrains); |
3434 | - |
3435 | - const Image* green = |
3436 | - g_gr->images().get("pics/terrain_green.png"); |
3437 | - const Image* water = |
3438 | - g_gr->images().get("pics/terrain_water.png"); |
3439 | - const Image* mountain = |
3440 | - g_gr->images().get("pics/terrain_mountain.png"); |
3441 | - const Image* dead = |
3442 | - g_gr->images().get("pics/terrain_dead.png"); |
3443 | - const Image* unpassable = |
3444 | - g_gr->images().get("pics/terrain_unpassable.png"); |
3445 | - const Image* dry = |
3446 | - g_gr->images().get("pics/terrain_dry.png"); |
3447 | - |
3448 | - static const int small_pich = 20; |
3449 | - static const int small_picw = 20; |
3450 | - |
3451 | - uint32_t cur_x = 0; |
3452 | - Point pos(hmargin(), vmargin()); |
3453 | - for (size_t checkfor = 0; checkfor < 6; ++checkfor) { |
3454 | - for (Widelands::Terrain_Index i = 0; i < nr_terrains; ++i) { |
3455 | - const uint8_t ter_is = world.get_ter(i).get_is(); |
3456 | - if (ter_is != check[checkfor]) |
3457 | - continue; |
3458 | - |
3459 | - if (cur_x == terrains_in_row) { |
3460 | - cur_x = 0; |
3461 | - pos.x = hmargin(); |
3462 | - pos.y += TEXTURE_HEIGHT + vspacing(); |
3463 | - } |
3464 | - |
3465 | - Surface* surf = Surface::create(64, 64); |
3466 | - const Image* tex = g_gr->images().get |
3467 | - (g_gr->get_maptexture_data(world.terrain_descr(i).get_texture())->get_texture_image()); |
3468 | - surf->blit(Point(0, 0), tex->surface(), Rect(0, 0, tex->width(), tex->height()), CM_Solid); |
3469 | - |
3470 | - Point pt(1, 64 - small_pich - 1); |
3471 | - |
3472 | - // check is green |
3473 | - if (ter_is == 0) { |
3474 | - surf->blit(pt, green->surface(), Rect(0, 0, green->width(), green->height())); |
3475 | - pt.x += small_picw + 1; |
3476 | - } else { |
3477 | - if (ter_is & TERRAIN_WATER) { |
3478 | - surf->blit(pt, water->surface(), Rect(0, 0, water->width(), water->height())); |
3479 | - pt.x += small_picw + 1; |
3480 | - } |
3481 | - if (ter_is & TERRAIN_MOUNTAIN) { |
3482 | - surf->blit(pt, mountain->surface(), Rect(0, 0, mountain->width(), mountain->height())); |
3483 | - pt.x += small_picw + 1; |
3484 | - } |
3485 | - if (ter_is & TERRAIN_ACID) { |
3486 | - surf->blit(pt, dead->surface(), Rect(0, 0, dead->width(), dead->height())); |
3487 | - pt.x += small_picw + 1; |
3488 | - } |
3489 | - if (ter_is & TERRAIN_UNPASSABLE) { |
3490 | - surf->blit(pt, unpassable->surface(), Rect(0, 0, unpassable->width(), unpassable->height())); |
3491 | - pt.x += small_picw + 1; |
3492 | - } |
3493 | - if (ter_is & TERRAIN_DRY) |
3494 | - surf->blit(pt, dry->surface(), Rect(0, 0, dry->width(), dry->height())); |
3495 | - } |
3496 | - // Make sure we delete this later on. |
3497 | - offscreen_images_.push_back(new_in_memory_image("dummy_hash", surf)); |
3498 | - |
3499 | - UI::Checkbox & cb = *new UI::Checkbox(this, pos, offscreen_images_.back()); |
3500 | - cb.set_size(TEXTURE_WIDTH + 1, TEXTURE_HEIGHT + 1); |
3501 | - cb.set_state(m_tool.is_enabled(i)); |
3502 | - cb.changedto.connect |
3503 | - (boost::bind(&Editor_Tool_Set_Terrain_Options_Menu::selected, this, i, _1)); |
3504 | - m_checkboxes[i] = &cb; |
3505 | - |
3506 | - pos.x += TEXTURE_WIDTH + hspacing(); |
3507 | - ++cur_x; |
3508 | - } |
3509 | - } |
3510 | - pos.y += TEXTURE_HEIGHT + vspacing(); |
3511 | - |
3512 | - set_inner_size |
3513 | - (terrains_in_row * (TEXTURE_WIDTH + hspacing()) + |
3514 | - 2 * hmargin() - hspacing(), |
3515 | - pos.y + m_cur_selection.get_h() + vmargin()); |
3516 | - pos.x = get_inner_w() / 2; |
3517 | - m_cur_selection.set_pos(pos); |
3518 | - |
3519 | - std::string buf = _("Current:"); |
3520 | - uint32_t j = m_tool.get_nr_enabled(); |
3521 | - for (Widelands::Terrain_Index i = 0; j; ++i) |
3522 | - if (m_tool.is_enabled(i)) { |
3523 | - buf += " "; |
3524 | - buf += world.get_ter(i).descname(); |
3525 | - --j; |
3526 | - } |
3527 | - m_cur_selection.set_text(buf); |
3528 | -} |
3529 | - |
3530 | - |
3531 | -Editor_Tool_Set_Terrain_Options_Menu::~Editor_Tool_Set_Terrain_Options_Menu() |
3532 | -{ |
3533 | - for (const Image* pic : offscreen_images_) |
3534 | - delete pic; |
3535 | - offscreen_images_.clear(); |
3536 | -} |
3537 | - |
3538 | -void Editor_Tool_Set_Terrain_Options_Menu::selected |
3539 | - (int32_t const n, bool const t) |
3540 | -{ |
3541 | - if (m_select_recursion_protect) |
3542 | - return; |
3543 | - |
3544 | - // FIXME This code is erroneous. It checks the current key state. What it |
3545 | - // FIXME needs is the key state at the time the mouse was clicked. See the |
3546 | - // FIXME usage comment for get_key_state. |
3547 | - const bool multiselect = |
3548 | - get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL); |
3549 | - if (not t and (not multiselect or m_tool.get_nr_enabled() == 1)) |
3550 | - m_checkboxes[n]->set_state(true); |
3551 | - else { |
3552 | - if (not multiselect) { |
3553 | - for (uint32_t i = 0; m_tool.get_nr_enabled(); ++i) |
3554 | - m_tool.enable(i, false); |
3555 | - // disable all checkboxes |
3556 | - m_select_recursion_protect = true; |
3557 | - const int32_t size = m_checkboxes.size(); |
3558 | - for (int32_t i = 0; i < size; ++i) { |
3559 | - if (i != n) |
3560 | - m_checkboxes[i]->set_state(false); |
3561 | - } |
3562 | - m_select_recursion_protect = false; |
3563 | - } |
3564 | - |
3565 | - m_tool.enable(n, t); |
3566 | - select_correct_tool(); |
3567 | - |
3568 | - std::string buf = _("Current:"); |
3569 | - const Widelands::World & world = |
3570 | - ref_cast<Editor_Interactive, UI::Panel>(*get_parent()) |
3571 | - .egbase().map().world(); |
3572 | - uint32_t j = m_tool.get_nr_enabled(); |
3573 | - for (Widelands::Terrain_Index i = 0; j; ++i) |
3574 | - if (m_tool.is_enabled(i)) { |
3575 | - buf += " "; |
3576 | - buf += world.get_ter(i).descname(); |
3577 | - --j; |
3578 | - } |
3579 | - |
3580 | - m_cur_selection.set_text(buf.c_str()); |
3581 | - m_cur_selection.set_pos |
3582 | - (Point |
3583 | - ((get_inner_w() - m_cur_selection.get_w()) / 2, |
3584 | - m_cur_selection.get_y())); |
3585 | - } |
3586 | +#include "ui_basic/tabpanel.h" |
3587 | + |
3588 | +namespace { |
3589 | + |
3590 | +using namespace Widelands; |
3591 | + |
3592 | +static const int32_t check[] = { |
3593 | + TerrainDescription::GREEN, // "green" |
3594 | + TerrainDescription::DRY, // "dry" |
3595 | + TerrainDescription::DRY | TerrainDescription::MOUNTAIN, // "mountain" |
3596 | + TerrainDescription::DRY | TerrainDescription::UNPASSABLE, // "unpassable" |
3597 | + TerrainDescription::ACID | TerrainDescription::DRY | |
3598 | + TerrainDescription::UNPASSABLE, // "dead" or "acid" |
3599 | + TerrainDescription::UNPASSABLE | TerrainDescription::DRY | TerrainDescription::WATER, |
3600 | + -1, // end marker |
3601 | +}; |
3602 | + |
3603 | +UI::Checkbox* create_terrain_checkbox(UI::Panel* parent, |
3604 | + const TerrainDescription& terrain_descr, |
3605 | + std::vector<std::unique_ptr<const Image>>* offscreen_images) { |
3606 | + const Image* green = g_gr->images().get("pics/terrain_green.png"); |
3607 | + const Image* water = g_gr->images().get("pics/terrain_water.png"); |
3608 | + const Image* mountain = g_gr->images().get("pics/terrain_mountain.png"); |
3609 | + const Image* dead = g_gr->images().get("pics/terrain_dead.png"); |
3610 | + const Image* unpassable = g_gr->images().get("pics/terrain_unpassable.png"); |
3611 | + const Image* dry = g_gr->images().get("pics/terrain_dry.png"); |
3612 | + |
3613 | + constexpr int kSmallPicHeight = 20; |
3614 | + constexpr int kSmallPicWidth = 20; |
3615 | + for (size_t checkfor = 0; check[checkfor] >= 0; ++checkfor) { |
3616 | + const TerrainDescription::Type ter_is = terrain_descr.get_is(); |
3617 | + if (ter_is != check[checkfor]) |
3618 | + continue; |
3619 | + |
3620 | + Surface* surf = Surface::create(TEXTURE_WIDTH, TEXTURE_HEIGHT); |
3621 | + const Image* tex = g_gr->images().get( |
3622 | + g_gr->get_maptexture_data(terrain_descr.get_texture())->get_texture_image()); |
3623 | + surf->blit(Point(0, 0), tex->surface(), Rect(0, 0, tex->width(), tex->height()), CM_Solid); |
3624 | + Point pt(1, TEXTURE_HEIGHT - kSmallPicHeight - 1); |
3625 | + |
3626 | + if (ter_is == TerrainDescription::GREEN) { |
3627 | + surf->blit(pt, green->surface(), Rect(0, 0, green->width(), green->height())); |
3628 | + pt.x += kSmallPicWidth + 1; |
3629 | + } else { |
3630 | + if (ter_is & TerrainDescription::WATER) { |
3631 | + surf->blit(pt, water->surface(), Rect(0, 0, water->width(), water->height())); |
3632 | + pt.x += kSmallPicWidth + 1; |
3633 | + } |
3634 | + if (ter_is & TerrainDescription::MOUNTAIN) { |
3635 | + surf->blit(pt, mountain->surface(), Rect(0, 0, mountain->width(), mountain->height())); |
3636 | + pt.x += kSmallPicWidth + 1; |
3637 | + } |
3638 | + if (ter_is & TerrainDescription::ACID) { |
3639 | + surf->blit(pt, dead->surface(), Rect(0, 0, dead->width(), dead->height())); |
3640 | + pt.x += kSmallPicWidth + 1; |
3641 | + } |
3642 | + if (ter_is & TerrainDescription::UNPASSABLE) { |
3643 | + surf->blit( |
3644 | + pt, unpassable->surface(), Rect(0, 0, unpassable->width(), unpassable->height())); |
3645 | + pt.x += kSmallPicWidth + 1; |
3646 | + } |
3647 | + if (ter_is & TerrainDescription::DRY) |
3648 | + surf->blit(pt, dry->surface(), Rect(0, 0, dry->width(), dry->height())); |
3649 | + } |
3650 | + // Make sure we delete this later on. |
3651 | + offscreen_images->emplace_back(new_in_memory_image("dummy_hash", surf)); |
3652 | + break; |
3653 | + } |
3654 | + |
3655 | + UI::Checkbox* cb = new UI::Checkbox(parent, Point(0, 0), offscreen_images->back().get()); |
3656 | + cb->set_desired_size(TEXTURE_WIDTH + 1, TEXTURE_HEIGHT + 1); |
3657 | + return cb; |
3658 | +} |
3659 | + |
3660 | +} // namespace |
3661 | + |
3662 | +Editor_Tool_Set_Terrain_Options_Menu::Editor_Tool_Set_Terrain_Options_Menu( |
3663 | + Editor_Interactive& parent, Editor_Set_Terrain_Tool& tool, UI::UniqueWindow::Registry& registry) |
3664 | + : Editor_Tool_Options_Menu(parent, registry, 0, 0, _("Terrain Select")) { |
3665 | + const Widelands::World& world = parent.egbase().world(); |
3666 | + multi_select_menu_.reset( |
3667 | + new CategorizedItemSelectionMenu<Widelands::TerrainDescription, Editor_Set_Terrain_Tool>( |
3668 | + this, |
3669 | + world.editor_terrain_categories(), |
3670 | + world.terrains(), |
3671 | + [this](UI::Panel* cb_parent, const TerrainDescription& terrain_descr) { |
3672 | + return create_terrain_checkbox(cb_parent, terrain_descr, &offscreen_images_); |
3673 | + }, |
3674 | + [this] { select_correct_tool(); }, |
3675 | + &tool)); |
3676 | + set_center_panel(multi_select_menu_.get()); |
3677 | +} |
3678 | + |
3679 | +Editor_Tool_Set_Terrain_Options_Menu::~Editor_Tool_Set_Terrain_Options_Menu() { |
3680 | } |
3681 | |
3682 | === modified file 'src/editor/ui_menus/editor_tool_set_terrain_options_menu.h' |
3683 | --- src/editor/ui_menus/editor_tool_set_terrain_options_menu.h 2013-07-26 20:19:36 +0000 |
3684 | +++ src/editor/ui_menus/editor_tool_set_terrain_options_menu.h 2014-06-17 15:48:25 +0000 |
3685 | @@ -20,32 +20,28 @@ |
3686 | #ifndef EDITOR_TOOL_SET_TERRAIN_TOOL_H |
3687 | #define EDITOR_TOOL_SET_TERRAIN_TOOL_H |
3688 | |
3689 | +#include <map> |
3690 | +#include <memory> |
3691 | #include <vector> |
3692 | |
3693 | +#include "editor/ui_menus/categorized_item_selection_menu.h" |
3694 | #include "editor/ui_menus/editor_tool_options_menu.h" |
3695 | +#include "logic/world/terrain_description.h" |
3696 | #include "ui_basic/textarea.h" |
3697 | |
3698 | - |
3699 | struct Editor_Interactive; |
3700 | struct Editor_Set_Terrain_Tool; |
3701 | -namespace UI {struct Checkbox;} |
3702 | |
3703 | struct Editor_Tool_Set_Terrain_Options_Menu : public Editor_Tool_Options_Menu { |
3704 | - Editor_Tool_Set_Terrain_Options_Menu |
3705 | - (Editor_Interactive &, |
3706 | - Editor_Set_Terrain_Tool &, |
3707 | - UI::UniqueWindow::Registry &); |
3708 | + Editor_Tool_Set_Terrain_Options_Menu(Editor_Interactive&, |
3709 | + Editor_Set_Terrain_Tool&, |
3710 | + UI::UniqueWindow::Registry&); |
3711 | virtual ~Editor_Tool_Set_Terrain_Options_Menu(); |
3712 | |
3713 | private: |
3714 | - // When we are using an offscreen surface, we have to delete it, |
3715 | - // when we are closed. So we keep a pointer around. |
3716 | - std::vector<const Image*> offscreen_images_; |
3717 | - UI::Textarea m_cur_selection; |
3718 | - Editor_Set_Terrain_Tool & m_tool; |
3719 | - void selected(int32_t, bool); |
3720 | - std::vector<UI::Checkbox *> m_checkboxes; |
3721 | - bool m_select_recursion_protect; |
3722 | + std::unique_ptr<CategorizedItemSelectionMenu<Widelands::TerrainDescription, Editor_Set_Terrain_Tool>> |
3723 | + multi_select_menu_; |
3724 | + std::vector<std::unique_ptr<const Image>> offscreen_images_; |
3725 | }; |
3726 | |
3727 | |
3728 | |
3729 | === modified file 'src/game_io/game_game_class_data_packet.cc' |
3730 | --- src/game_io/game_game_class_data_packet.cc 2014-05-11 07:38:01 +0000 |
3731 | +++ src/game_io/game_game_class_data_packet.cc 2014-06-17 15:48:25 +0000 |
3732 | @@ -38,7 +38,7 @@ |
3733 | uint16_t const packet_version = fr.Unsigned16(); |
3734 | if (packet_version <= CURRENT_PACKET_VERSION) { |
3735 | fr.Signed16(); // This used to be game speed |
3736 | - game.m_gametime = fr.Unsigned32(); |
3737 | + game.gametime_ = fr.Unsigned32(); |
3738 | } else |
3739 | throw game_data_error |
3740 | ("unknown/unhandled version %u", packet_version); |
3741 | @@ -70,7 +70,7 @@ |
3742 | |
3743 | // EDITOR GAME CLASS |
3744 | // Write gametime |
3745 | - fw.Unsigned32(game.m_gametime); |
3746 | + fw.Unsigned32(game.gametime_); |
3747 | |
3748 | // We do not care for players, since they were set |
3749 | // on game initialization to match Map::scenario_player_[names|tribes] |
3750 | |
3751 | === modified file 'src/game_io/game_map_data_packet.cc' |
3752 | --- src/game_io/game_map_data_packet.cc 2014-06-10 20:38:57 +0000 |
3753 | +++ src/game_io/game_map_data_packet.cc 2014-06-17 15:48:25 +0000 |
3754 | @@ -46,7 +46,6 @@ |
3755 | m_wml = new WL_Map_Loader(fs.MakeSubFileSystem("map"), &game.map()); |
3756 | |
3757 | m_wml->preload_map(true); |
3758 | - m_wml->load_world(); |
3759 | |
3760 | // DONE, mapfs gets deleted by WidelandsMapLoader. |
3761 | |
3762 | |
3763 | === modified file 'src/game_io/game_preload_data_packet.cc' |
3764 | --- src/game_io/game_preload_data_packet.cc 2014-04-14 06:17:25 +0000 |
3765 | +++ src/game_io/game_preload_data_packet.cc 2014-06-17 15:48:25 +0000 |
3766 | @@ -105,13 +105,8 @@ |
3767 | } |
3768 | s.set_int(PLAYERS_AMOUNT_KEY_V4, game.player_manager()->get_number_of_players()); |
3769 | |
3770 | - std::string bg(map.get_background()); |
3771 | - if (bg.empty()) |
3772 | - bg = map.get_world_name(); |
3773 | - s.set_string("background", bg); |
3774 | - |
3775 | + s.set_string("background", map.get_background()); |
3776 | s.set_string("win_condition", game.get_win_condition_displayname()); |
3777 | - |
3778 | prof.write("preload", false, fs); |
3779 | |
3780 | // Write minimap image |
3781 | |
3782 | === modified file 'src/graphic/animation.cc' |
3783 | --- src/graphic/animation.cc 2014-06-16 13:24:45 +0000 |
3784 | +++ src/graphic/animation.cc 2014-06-17 15:48:25 +0000 |
3785 | @@ -43,8 +43,9 @@ |
3786 | #include "io/filesystem/layered_filesystem.h" |
3787 | #include "log.h" |
3788 | #include "logic/bob.h" |
3789 | -#include "logic/instances.h" // For Map_Object_Descr. |
3790 | +#include "logic/instances.h" |
3791 | #include "profile/profile.h" |
3792 | +#include "scripting/lua_table.h" |
3793 | #include "sound/sound_handler.h" |
3794 | #include "wexception.h" |
3795 | |
3796 | @@ -54,6 +55,16 @@ |
3797 | |
3798 | namespace { |
3799 | |
3800 | +// Parses an array { 12, 23 } into a point. |
3801 | +void get_point(const LuaTable& table, Point* p) { |
3802 | + std::vector<int> pts = table.array_entries<int>(); |
3803 | + if (pts.size() != 2) { |
3804 | + throw wexception("Expected 2 entries, but got %" PRIuS ".", pts.size()); |
3805 | + } |
3806 | + p->x = pts[0]; |
3807 | + p->y = pts[1]; |
3808 | +} |
3809 | + |
3810 | /** |
3811 | * An Image Implementation that draws a static animation into a surface. |
3812 | */ |
3813 | @@ -96,7 +107,8 @@ |
3814 | class NonPackedAnimation : public Animation { |
3815 | public: |
3816 | virtual ~NonPackedAnimation() {} |
3817 | - NonPackedAnimation(const string& directory, Section & s); |
3818 | + NonPackedAnimation(const string& directory, Section & section); |
3819 | + NonPackedAnimation(const LuaTable& table); |
3820 | |
3821 | // Implements Animation. |
3822 | virtual uint16_t width() const override; |
3823 | @@ -121,114 +133,129 @@ |
3824 | uint32_t frametime_; |
3825 | Point hotspot_; |
3826 | bool hasplrclrs_; |
3827 | - std::string picnametempl_; |
3828 | + std::vector<std::string> image_files_; |
3829 | + std::vector<std::string> pc_mask_image_files_; |
3830 | |
3831 | vector<const Image*> frames_; |
3832 | vector<const Image*> pcmasks_; |
3833 | |
3834 | - /// mapping of soundeffect name to frame number, indexed by frame number . |
3835 | - map<uint32_t, string> sfx_cues; |
3836 | + // name of sound effect that will be played at frame 0. |
3837 | + // TODO(sirver): this should be done using playFX in a program instead of |
3838 | + // binding it to the animation. |
3839 | + string sound_effect_; |
3840 | }; |
3841 | |
3842 | -NonPackedAnimation::NonPackedAnimation(const string& directory, Section& s) |
3843 | +NonPackedAnimation::NonPackedAnimation(const string& directory, Section& section) |
3844 | : frametime_(FRAME_LENGTH), |
3845 | hasplrclrs_(false) { |
3846 | - // Read mapping from frame numbers to sound effect names and load effects |
3847 | - while (Section::Value * const v = s.get_next_val("sfx")) { |
3848 | - char * parameters = v->get_string(), * endp; |
3849 | - string fx_name; |
3850 | - unsigned long long int const value = strtoull(parameters, &endp, 0); |
3851 | - const uint32_t frame_number = value; |
3852 | - try { |
3853 | - if (endp == parameters or frame_number != value) |
3854 | - throw wexception("expected %s but found \"%s\"", "frame number", parameters); |
3855 | - parameters = endp; |
3856 | - force_skip(parameters); |
3857 | - |
3858 | - fx_name = string(directory) + "/" + string(parameters); |
3859 | - g_sound_handler.load_fx_if_needed(directory, parameters, fx_name); |
3860 | - map<uint32_t, string>::const_iterator const it = |
3861 | - sfx_cues.find(frame_number); |
3862 | - if (it != sfx_cues.end()) |
3863 | - throw wexception |
3864 | - ("redefinition for frame %u to \"%s\" (previously defined to " |
3865 | - "\"%s\")", |
3866 | - frame_number, parameters, it->second.c_str()); |
3867 | - } catch (const _wexception & e) { |
3868 | - throw wexception("sfx: %s", e.what()); |
3869 | - } |
3870 | - sfx_cues[frame_number] = fx_name; |
3871 | + // If this animation has a sound effect associated, try to load it now. |
3872 | + const std::string sfx = section.get_string("sfx", ""); |
3873 | + if (!sfx.empty()) { |
3874 | + sound_effect_ = string(directory) + "/" + sfx; |
3875 | + g_sound_handler.load_fx_if_needed(directory, sfx, sound_effect_); |
3876 | } |
3877 | |
3878 | - int32_t const fps = s.get_int("fps"); |
3879 | + int32_t const fps = section.get_int("fps"); |
3880 | if (fps < 0) |
3881 | throw wexception("fps is %i, must be non-negative", fps); |
3882 | if (fps > 0) |
3883 | frametime_ = 1000 / fps; |
3884 | |
3885 | - hotspot_ = s.get_Point("hotspot"); |
3886 | + hotspot_ = section.get_Point("hotspot"); |
3887 | |
3888 | // In the filename template, the last sequence of '?' characters (if any) |
3889 | // is replaced with a number, for example the template "idle_??" is |
3890 | // replaced with "idle_00". Then the code looks if there is a PNG with that |
3891 | // name, increments the number and continues . on until it can not find any |
3892 | // file. Then it is assumed that there are no more frames in the animation. |
3893 | - if (char const * const pics = s.get_string("pics")) { |
3894 | - picnametempl_ = directory + pics; |
3895 | + string picnametempl; |
3896 | + if (char const * const pics = section.get_string("pics")) { |
3897 | + picnametempl = directory + pics; |
3898 | } else { |
3899 | - picnametempl_ = directory + s.get_name(); |
3900 | + picnametempl = directory + section.get_name(); |
3901 | } |
3902 | // Strip the .png extension if it has one. |
3903 | - boost::replace_all(picnametempl_, ".png", ""); |
3904 | -} |
3905 | + boost::replace_all(picnametempl, ".png", ""); |
3906 | |
3907 | -void NonPackedAnimation::load_graphics() { |
3908 | - NumberGlob glob(picnametempl_); |
3909 | + NumberGlob glob(picnametempl); |
3910 | string filename_wo_ext; |
3911 | while (glob.next(&filename_wo_ext)) { |
3912 | const string filename = filename_wo_ext + ".png"; |
3913 | if (!g_fs->FileExists(filename)) |
3914 | break; |
3915 | - |
3916 | - const Image* image = g_gr->images().get(filename); |
3917 | - if |
3918 | - (frames_.size() && |
3919 | - (frames_[0]->width() != image->width() or frames_[0]->height() != image->height())) |
3920 | - throw wexception |
3921 | - ("wrong size: (%u, %u), should be (%u, %u) like the first frame", |
3922 | - image->width(), image->height(), frames_[0]->width(), frames_[0]->height()); |
3923 | - frames_.push_back(image); |
3924 | - |
3925 | - //TODO Do not load playercolor mask as opengl texture or use it as |
3926 | - // opengl texture. |
3927 | + image_files_.push_back(filename); |
3928 | + |
3929 | const string pc_filename = filename_wo_ext + "_pc.png"; |
3930 | if (g_fs->FileExists(pc_filename)) { |
3931 | hasplrclrs_ = true; |
3932 | - const Image* pc_image = g_gr->images().get(pc_filename); |
3933 | - if (frames_[0]->width() != pc_image->width() or frames_[0]->height() != pc_image->height()) { |
3934 | - log("ANIMATION ERROR: playercolor mask has wrong size: (%s: %u, %u), should " |
3935 | - "be (%u, %u) like the animation frame\n", |
3936 | - pc_filename.c_str(), pc_image->width(), pc_image->height(), frames_[0]->width(), |
3937 | - frames_[0]->height()); |
3938 | - hasplrclrs_ = false; |
3939 | - break; |
3940 | - } |
3941 | - //throw wexception |
3942 | - //("playercolor mask has wrong size: (%s: %u, %u), should " |
3943 | - //"be (%u, %u) like the animation frame", |
3944 | - //pc_filename.c_str(),pc_image->width(), pc_image->height(), frames_[0]->width(), |
3945 | - //frames_[0]->height()); |
3946 | - pcmasks_.push_back(pc_image); |
3947 | - } |
3948 | - } |
3949 | - |
3950 | - if (frames_.empty()) |
3951 | - throw wexception("animation %s has no frames", picnametempl_.c_str()); |
3952 | - |
3953 | - if (pcmasks_.size() and pcmasks_.size() != frames_.size()) |
3954 | + pc_mask_image_files_.push_back(pc_filename); |
3955 | + } |
3956 | + } |
3957 | +} |
3958 | + |
3959 | +NonPackedAnimation::NonPackedAnimation(const LuaTable& table) |
3960 | + : frametime_(FRAME_LENGTH), |
3961 | + hasplrclrs_(false) { |
3962 | + // TODO(sirver): the LuaTable constructor has no support for player_colors right now. |
3963 | + get_point(*table.get_table("hotspot"), &hotspot_); |
3964 | + |
3965 | + if (table.has_key("sound_effect")) { |
3966 | + std::unique_ptr<LuaTable> sound_effects = table.get_table("sound_effect"); |
3967 | + |
3968 | + const std::string name = sound_effects->get_string("name"); |
3969 | + const std::string directory = sound_effects->get_string("directory"); |
3970 | + sound_effect_ = directory + "/" + name; |
3971 | + g_sound_handler.load_fx_if_needed(directory, name, sound_effect_); |
3972 | + } |
3973 | + |
3974 | + image_files_ = table.get_table("pictures")->array_entries<std::string>(); |
3975 | + if (image_files_.empty()) { |
3976 | + throw wexception("Animation without pictures."); |
3977 | + } else if (image_files_.size() == 1) { |
3978 | + if (table.has_key("fps")) { |
3979 | + throw wexception("Animation with one picture must not have 'fps'."); |
3980 | + } |
3981 | + } else { |
3982 | + frametime_ = 1000 / get_positive_int(table, "fps"); |
3983 | + } |
3984 | +} |
3985 | + |
3986 | +void NonPackedAnimation::load_graphics() { |
3987 | + if (image_files_.empty()) |
3988 | + throw wexception("animation without pictures."); |
3989 | + |
3990 | + if (pc_mask_image_files_.size() and pc_mask_image_files_.size() != image_files_.size()) |
3991 | throw wexception |
3992 | ("animation has %" PRIuS " frames but playercolor mask has %" PRIuS " frames", |
3993 | - frames_.size(), pcmasks_.size()); |
3994 | + image_files_.size(), pc_mask_image_files_.size()); |
3995 | + |
3996 | + for (const std::string& filename : image_files_) { |
3997 | + const Image* image = g_gr->images().get(filename); |
3998 | + if (frames_.size() && |
3999 | + (frames_[0]->width() != image->width() or frames_[0]->height() != image->height())) { |
4000 | + throw wexception("wrong size: (%u, %u), should be (%u, %u) like the first frame", |
4001 | + image->width(), |
4002 | + image->height(), |
4003 | + frames_[0]->width(), |
4004 | + frames_[0]->height()); |
4005 | + } |
4006 | + frames_.push_back(image); |
4007 | + } |
4008 | + |
4009 | + for (const std::string& filename : pc_mask_image_files_) { |
4010 | + // TODO Do not load playercolor mask as opengl texture or use it as |
4011 | + // opengl texture. |
4012 | + const Image* pc_image = g_gr->images().get(filename); |
4013 | + if (frames_[0]->width() != pc_image->width() or frames_[0]->height() != pc_image->height()) { |
4014 | + throw wexception("playercolor mask has wrong size: (%u, %u), should " |
4015 | + "be (%u, %u) like the animation frame", |
4016 | + pc_image->width(), |
4017 | + pc_image->height(), |
4018 | + frames_[0]->width(), |
4019 | + frames_[0]->height()); |
4020 | + } |
4021 | + pcmasks_.push_back(pc_image); |
4022 | + } |
4023 | } |
4024 | |
4025 | uint16_t NonPackedAnimation::width() const { |
4026 | @@ -268,12 +295,14 @@ |
4027 | return get_frame(0, nullptr); |
4028 | } |
4029 | |
4030 | -void NonPackedAnimation::trigger_soundfx |
4031 | - (uint32_t time, uint32_t stereo_position) const { |
4032 | +void NonPackedAnimation::trigger_soundfx(uint32_t time, uint32_t stereo_position) const { |
4033 | + if (sound_effect_.empty()) { |
4034 | + return; |
4035 | + } |
4036 | const uint32_t framenumber = time / frametime_ % nr_frames(); |
4037 | - const map<uint32_t, string>::const_iterator sfx_cue = sfx_cues.find(framenumber); |
4038 | - if (sfx_cue != sfx_cues.end()) |
4039 | - g_sound_handler.play_fx(sfx_cue->second, stereo_position, 1); |
4040 | + if (framenumber == 0) { |
4041 | + g_sound_handler.play_fx(sound_effect_, stereo_position, 1); |
4042 | + } |
4043 | } |
4044 | |
4045 | void NonPackedAnimation::blit |
4046 | @@ -411,6 +440,11 @@ |
4047 | return m_animations.size(); |
4048 | } |
4049 | |
4050 | +uint32_t AnimationManager::load(const LuaTable& table) { |
4051 | + m_animations.push_back(new NonPackedAnimation(table)); |
4052 | + return m_animations.size(); |
4053 | +} |
4054 | + |
4055 | const Animation& AnimationManager::get_animation(uint32_t id) const |
4056 | { |
4057 | if (!id || id > m_animations.size()) |
4058 | |
4059 | === modified file 'src/graphic/animation.h' |
4060 | --- src/graphic/animation.h 2014-04-06 15:46:29 +0000 |
4061 | +++ src/graphic/animation.h 2014-06-17 15:48:25 +0000 |
4062 | @@ -31,9 +31,10 @@ |
4063 | #include "rect.h" |
4064 | |
4065 | class Image; |
4066 | +class LuaTable; |
4067 | +class Section; |
4068 | class Surface; |
4069 | struct RGBColor; |
4070 | -struct Section; |
4071 | |
4072 | /** |
4073 | * Representation of an Animation in the game. An animation is a looping set of |
4074 | @@ -103,6 +104,7 @@ |
4075 | * \param s conffile section to search for data on this animation |
4076 | */ |
4077 | uint32_t load(const std::string & directory, Section& s); |
4078 | + uint32_t load(const LuaTable& table); |
4079 | |
4080 | /// Returns the animation with the given ID or throws an exception if it is |
4081 | /// unknown. |
4082 | |
4083 | === modified file 'src/graphic/diranimations.h' |
4084 | --- src/graphic/diranimations.h 2014-03-16 20:55:15 +0000 |
4085 | +++ src/graphic/diranimations.h 2014-06-17 15:48:25 +0000 |
4086 | @@ -28,12 +28,12 @@ |
4087 | |
4088 | namespace Widelands {struct Map_Object_Descr;} |
4089 | |
4090 | -struct Profile; |
4091 | -struct Section; |
4092 | +class Profile; |
4093 | +class Section; |
4094 | |
4095 | /// Manages a set of 6 animations, one for each possible direction. |
4096 | struct DirAnimations { |
4097 | - explicit DirAnimations |
4098 | + DirAnimations |
4099 | (uint32_t dir1 = 0, uint32_t dir2 = 0, uint32_t dir3 = 0, |
4100 | uint32_t dir4 = 0, uint32_t dir5 = 0, uint32_t dir6 = 0); |
4101 | |
4102 | @@ -48,6 +48,9 @@ |
4103 | uint32_t get_animation(Widelands::Direction const dir) const { |
4104 | return m_animations[dir - 1]; |
4105 | } |
4106 | + void set_animation(const Widelands::Direction dir, const uint32_t anim) { |
4107 | + m_animations[dir - 1] = anim; |
4108 | + } |
4109 | |
4110 | static DirAnimations Null() { |
4111 | return DirAnimations(0); // Since real animation IDs are positive, this is safe |
4112 | |
4113 | === modified file 'src/graphic/graphic.cc' |
4114 | --- src/graphic/graphic.cc 2014-06-10 20:38:57 +0000 |
4115 | +++ src/graphic/graphic.cc 2014-06-17 15:48:25 +0000 |
4116 | @@ -314,6 +314,9 @@ |
4117 | |
4118 | m_sdl_screen = sdlsurface; |
4119 | m_rendertarget.reset(new RenderTarget(screen_.get())); |
4120 | + |
4121 | + pic_road_normal_.reset(image_loader_->load("world/pics/roadt_normal.png")); |
4122 | + pic_road_busy_.reset(image_loader_->load("world/pics/roadt_busy.png")); |
4123 | } |
4124 | |
4125 | bool Graphic::check_fallback_settings_in_effect() |
4126 | @@ -322,7 +325,7 @@ |
4127 | } |
4128 | |
4129 | void Graphic::cleanup() { |
4130 | - flush_maptextures(); |
4131 | + m_maptextures.clear(); |
4132 | surface_cache_->flush(); |
4133 | // TODO: this should really not be needed, but currently is :( |
4134 | if (UI::g_fh) |
4135 | @@ -526,34 +529,9 @@ |
4136 | png_destroy_write_struct(&png_ptr, &info_ptr); |
4137 | } |
4138 | |
4139 | -void Graphic::flush_maptextures() |
4140 | -{ |
4141 | - for (Texture* texture : m_maptextures) |
4142 | - delete texture; |
4143 | - m_maptextures.clear(); |
4144 | -} |
4145 | - |
4146 | -/** |
4147 | - * Creates a terrain texture. |
4148 | - * |
4149 | - * fnametempl is a filename with possible wildcard characters '?'. The function |
4150 | - * fills the wildcards with decimal numbers to get the different frames of a |
4151 | - * texture animation. For example, if fnametempl is "foo_??.png", it tries |
4152 | - * "foo_00.png", "foo_01.png" etc... |
4153 | - * frametime is in milliseconds. |
4154 | - * \return 0 if the texture couldn't be loaded. |
4155 | - * \note Terrain textures are not reused, even if fnametempl matches. |
4156 | -*/ |
4157 | -uint32_t Graphic::get_maptexture(const string& fnametempl, uint32_t frametime) |
4158 | -{ |
4159 | - try { |
4160 | - m_maptextures.push_back |
4161 | - (new Texture(fnametempl, frametime, *m_sdl_screen->format)); |
4162 | - } catch (exception& e) { |
4163 | - log("Failed to load maptexture %s: %s\n", fnametempl.c_str(), e.what()); |
4164 | - return 0; |
4165 | - } |
4166 | - |
4167 | +uint32_t Graphic::new_maptexture(const std::vector<std::string>& texture_files, const uint32_t frametime) |
4168 | +{ |
4169 | + m_maptextures.emplace_back(new Texture(texture_files, frametime, *m_sdl_screen->format)); |
4170 | return m_maptextures.size(); // ID 1 is at m_maptextures[0] |
4171 | } |
4172 | |
4173 | @@ -568,16 +546,6 @@ |
4174 | } |
4175 | |
4176 | /** |
4177 | - * reset that the map texture have been animated |
4178 | - */ |
4179 | -void Graphic::reset_texture_animation_reminder() |
4180 | -{ |
4181 | - for (uint32_t i = 0; i < m_maptextures.size(); ++i) { |
4182 | - m_maptextures[i]->reset_was_animated(); |
4183 | - } |
4184 | -} |
4185 | - |
4186 | -/** |
4187 | * Save a screenshot to the given file. |
4188 | */ |
4189 | void Graphic::screenshot(const string& fname) const |
4190 | @@ -618,24 +586,9 @@ |
4191 | Texture * Graphic::get_maptexture_data(uint32_t id) |
4192 | { |
4193 | --id; // ID 1 is at m_maptextures[0] |
4194 | - if (id < m_maptextures.size()) |
4195 | - return m_maptextures[id]; |
4196 | - else |
4197 | - return nullptr; |
4198 | -} |
4199 | - |
4200 | - |
4201 | -/** |
4202 | - * Sets the name of the current world and loads the fitting road and edge textures |
4203 | - */ |
4204 | -void Graphic::set_world(string worldname) { |
4205 | - char buf[255]; |
4206 | - |
4207 | - // Load the road textures |
4208 | - snprintf(buf, sizeof(buf), "worlds/%s/pics/roadt_normal.png", worldname.c_str()); |
4209 | - pic_road_normal_.reset(image_loader_->load(buf)); |
4210 | - snprintf(buf, sizeof(buf), "worlds/%s/pics/roadt_busy.png", worldname.c_str()); |
4211 | - pic_road_busy_.reset(image_loader_->load(buf)); |
4212 | + |
4213 | + assert(id < m_maptextures.size()); |
4214 | + return m_maptextures[id].get(); |
4215 | } |
4216 | |
4217 | /** |
4218 | |
4219 | === modified file 'src/graphic/graphic.h' |
4220 | --- src/graphic/graphic.h 2014-03-16 20:55:15 +0000 |
4221 | +++ src/graphic/graphic.h 2014-06-17 15:48:25 +0000 |
4222 | @@ -109,15 +109,14 @@ |
4223 | |
4224 | void save_png(const Image*, StreamWrite*) const; |
4225 | |
4226 | - void flush_maptextures(); |
4227 | - uint32_t get_maptexture(const std::string& fnametempl, uint32_t frametime); |
4228 | + // Creates a new Texture() with the given 'frametime' and using the given |
4229 | + // 'texture_files' as the images for it and returns it id. |
4230 | + uint32_t new_maptexture(const std::vector<std::string>& texture_files, uint32_t frametime); |
4231 | void animate_maptextures(uint32_t time); |
4232 | - void reset_texture_animation_reminder(); |
4233 | |
4234 | void screenshot(const std::string& fname) const; |
4235 | Texture * get_maptexture_data(uint32_t id); |
4236 | |
4237 | - void set_world(std::string); |
4238 | Surface& get_road_texture(int32_t roadtex); |
4239 | |
4240 | const GraphicCaps& caps() const {return m_caps;} |
4241 | @@ -171,7 +170,7 @@ |
4242 | std::unique_ptr<Surface> pic_road_normal_; |
4243 | std::unique_ptr<Surface> pic_road_busy_; |
4244 | |
4245 | - std::vector<Texture *> m_maptextures; |
4246 | + std::vector<std::unique_ptr<Texture>> m_maptextures; |
4247 | }; |
4248 | |
4249 | extern Graphic * g_gr; |
4250 | |
4251 | === modified file 'src/graphic/render/gamerenderer_gl.cc' |
4252 | --- src/graphic/render/gamerenderer_gl.cc 2014-05-11 07:38:01 +0000 |
4253 | +++ src/graphic/render/gamerenderer_gl.cc 2014-06-17 15:48:25 +0000 |
4254 | @@ -29,6 +29,8 @@ |
4255 | #include "io/fileread.h" |
4256 | #include "logic/editor_game_base.h" |
4257 | #include "logic/player.h" |
4258 | +#include "logic/world/terrain_description.h" |
4259 | +#include "logic/world/world.h" |
4260 | #include "wui/mapviewpixelconstants.h" |
4261 | #include "wui/mapviewpixelfunctions.h" |
4262 | #include "wui/overlay_manager.h" |
4263 | @@ -49,9 +51,9 @@ |
4264 | { |
4265 | } |
4266 | |
4267 | -const GLSurfaceTexture * GameRendererGL::get_dither_edge_texture(const Widelands::World & world) |
4268 | +const GLSurfaceTexture * GameRendererGL::get_dither_edge_texture() |
4269 | { |
4270 | - const std::string fname = world.basedir() + "/pics/edge.png"; |
4271 | + const std::string fname = "world/pics/edge.png"; |
4272 | const std::string cachename = std::string("gltex#") + fname; |
4273 | |
4274 | if (Surface* surface = g_gr->surfaces().get(cachename)) |
4275 | @@ -117,6 +119,12 @@ |
4276 | |
4277 | void GameRendererGL::draw() |
4278 | { |
4279 | + const World & world = m_egbase->world(); |
4280 | + if (m_terrain_freq.size() < world.terrains().get_nitems()) { |
4281 | + m_terrain_freq.resize(world.terrains().get_nitems()); |
4282 | + m_terrain_edge_freq.resize(world.terrains().get_nitems()); |
4283 | + } |
4284 | + |
4285 | m_surface = dynamic_cast<GLSurface *>(m_dst->get_surface()); |
4286 | if (!m_surface) |
4287 | return; |
4288 | @@ -242,8 +250,6 @@ |
4289 | m_patch_vertices_size = reqsize; |
4290 | } |
4291 | |
4292 | - if (m_terrain_freq.size() < 16) |
4293 | - m_terrain_freq.resize(16); |
4294 | m_terrain_freq.assign(m_terrain_freq.size(), 0); |
4295 | |
4296 | collect_terrain_base(true); |
4297 | @@ -273,8 +279,7 @@ |
4298 | |
4299 | void GameRendererGL::draw_terrain_base() |
4300 | { |
4301 | - const Map & map = m_egbase->map(); |
4302 | - const World & world = map.world(); |
4303 | + const World & world = m_egbase->world(); |
4304 | |
4305 | glMatrixMode(GL_TEXTURE); |
4306 | glLoadIdentity(); |
4307 | @@ -313,8 +318,7 @@ |
4308 | (bool onlyscan, Terrain_Index ter, const Coords & edge1, const Coords & edge2, const Coords & opposite) |
4309 | { |
4310 | if (onlyscan) { |
4311 | - if (ter >= m_terrain_edge_freq.size()) |
4312 | - m_terrain_edge_freq.resize(ter + 1); |
4313 | + assert(ter < m_terrain_edge_freq.size()); |
4314 | m_terrain_edge_freq[ter] += 1; |
4315 | } else { |
4316 | static const float TyZero = 1.0 / TEXTURE_HEIGHT; |
4317 | @@ -340,7 +344,7 @@ |
4318 | void GameRendererGL::collect_terrain_dither(bool onlyscan) |
4319 | { |
4320 | const Map & map = m_egbase->map(); |
4321 | - const World & world = map.world(); |
4322 | + const World & world = m_egbase->world(); |
4323 | |
4324 | for (int32_t fy = m_minfy; fy <= m_maxfy; ++fy) { |
4325 | for (int32_t fx = m_minfx; fx <= m_maxfx; ++fx) { |
4326 | @@ -354,12 +358,12 @@ |
4327 | Terrain_Index ter_rr = map.r_n(fcoords).field->get_terrains().d; |
4328 | Terrain_Index ter_l = map.l_n(fcoords).field->get_terrains().r; |
4329 | Terrain_Index ter_dd = map.bl_n(fcoords).field->get_terrains().r; |
4330 | - int32_t lyr_d = world.get_ter(ter_d).dither_layer(); |
4331 | - int32_t lyr_r = world.get_ter(ter_r).dither_layer(); |
4332 | - int32_t lyr_u = world.get_ter(ter_u).dither_layer(); |
4333 | - int32_t lyr_rr = world.get_ter(ter_rr).dither_layer(); |
4334 | - int32_t lyr_l = world.get_ter(ter_l).dither_layer(); |
4335 | - int32_t lyr_dd = world.get_ter(ter_dd).dither_layer(); |
4336 | + int32_t lyr_d = world.terrain_descr(ter_d).dither_layer(); |
4337 | + int32_t lyr_r = world.terrain_descr(ter_r).dither_layer(); |
4338 | + int32_t lyr_u = world.terrain_descr(ter_u).dither_layer(); |
4339 | + int32_t lyr_rr = world.terrain_descr(ter_rr).dither_layer(); |
4340 | + int32_t lyr_l = world.terrain_descr(ter_l).dither_layer(); |
4341 | + int32_t lyr_dd = world.terrain_descr(ter_dd).dither_layer(); |
4342 | |
4343 | Coords f(fx, fy); |
4344 | Coords rn(fx + 1, fy); |
4345 | @@ -408,8 +412,6 @@ |
4346 | { |
4347 | static_assert(sizeof(dithervertex) == 32, "assert(sizeof(dithervertex) == 32) failed."); |
4348 | |
4349 | - if (m_terrain_edge_freq.size() < 16) |
4350 | - m_terrain_edge_freq.resize(16); |
4351 | m_terrain_edge_freq.assign(m_terrain_edge_freq.size(), 0); |
4352 | |
4353 | collect_terrain_dither(true); |
4354 | @@ -439,9 +441,6 @@ |
4355 | |
4356 | void GameRendererGL::draw_terrain_dither() |
4357 | { |
4358 | - const Map & map = m_egbase->map(); |
4359 | - const World & world = map.world(); |
4360 | - |
4361 | if (m_edge_vertices_size == 0) |
4362 | return; |
4363 | |
4364 | @@ -456,7 +455,7 @@ |
4365 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
4366 | glTexCoordPointer(2, GL_FLOAT, sizeof(dithervertex), &m_edge_vertices[0].edgex); |
4367 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
4368 | - GLuint edge = get_dither_edge_texture(world)->get_gl_texture(); |
4369 | + GLuint edge = get_dither_edge_texture()->get_gl_texture(); |
4370 | glBindTexture(GL_TEXTURE_2D, edge); |
4371 | glEnable(GL_TEXTURE_2D); |
4372 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); |
4373 | @@ -478,7 +477,7 @@ |
4374 | |
4375 | const Texture & texture = |
4376 | *g_gr->get_maptexture_data |
4377 | - (world.terrain_descr(ter).get_texture()); |
4378 | + (m_egbase->world().terrain_descr(ter).get_texture()); |
4379 | glBindTexture(GL_TEXTURE_2D, texture.getTexture()); |
4380 | glDrawArrays |
4381 | (GL_TRIANGLES, |
4382 | |
4383 | === modified file 'src/graphic/render/gamerenderer_gl.h' |
4384 | --- src/graphic/render/gamerenderer_gl.h 2014-02-22 18:04:02 +0000 |
4385 | +++ src/graphic/render/gamerenderer_gl.h 2014-06-17 15:48:25 +0000 |
4386 | @@ -30,7 +30,7 @@ |
4387 | namespace Widelands { |
4388 | struct Coords; |
4389 | struct FCoords; |
4390 | -struct World; |
4391 | +class World; |
4392 | } |
4393 | |
4394 | class GLSurface; |
4395 | @@ -65,7 +65,7 @@ |
4396 | uint32_t pad[1]; |
4397 | }; |
4398 | |
4399 | - const GLSurfaceTexture * get_dither_edge_texture(const Widelands::World & world); |
4400 | + const GLSurfaceTexture * get_dither_edge_texture(); |
4401 | |
4402 | void draw() override; |
4403 | void prepare_terrain_base(); |
4404 | |
4405 | === modified file 'src/graphic/render/gamerenderer_sdl.cc' |
4406 | --- src/graphic/render/gamerenderer_sdl.cc 2013-07-26 20:19:36 +0000 |
4407 | +++ src/graphic/render/gamerenderer_sdl.cc 2014-06-17 15:48:25 +0000 |
4408 | @@ -24,6 +24,8 @@ |
4409 | #include "logic/field.h" |
4410 | #include "logic/map.h" |
4411 | #include "logic/player.h" |
4412 | +#include "logic/world/terrain_description.h" |
4413 | +#include "logic/world/world.h" |
4414 | #include "wui/overlay_manager.h" |
4415 | |
4416 | |
4417 | @@ -66,7 +68,7 @@ |
4418 | m_dst->get_surface()->fill_rect(m_dst->get_rect(), RGBAColor(0, 0, 0, 255)); |
4419 | |
4420 | const Map & map = m_egbase->map(); |
4421 | - const World & world = map.world(); |
4422 | + const World & world = m_egbase->world(); |
4423 | uint32_t const mapwidth = map.get_width(); |
4424 | |
4425 | #define get_terrain_texture(ter) \ |
4426 | |
4427 | === modified file 'src/graphic/render/minimaprenderer.cc' |
4428 | --- src/graphic/render/minimaprenderer.cc 2013-10-13 15:03:08 +0000 |
4429 | +++ src/graphic/render/minimaprenderer.cc 2014-06-17 15:48:25 +0000 |
4430 | @@ -31,6 +31,8 @@ |
4431 | #include "logic/field.h" |
4432 | #include "logic/map.h" |
4433 | #include "logic/player.h" |
4434 | +#include "logic/world/terrain_description.h" |
4435 | +#include "logic/world/world.h" |
4436 | #include "upcast.h" |
4437 | #include "wui/mapviewpixelconstants.h" |
4438 | #include "wui/mapviewpixelfunctions.h" |
4439 | @@ -66,7 +68,7 @@ |
4440 | pixelcolor = |
4441 | g_gr-> |
4442 | get_maptexture_data |
4443 | - (egbase.map().world() |
4444 | + (egbase.world() |
4445 | .terrain_descr(f.field->terrain_d()).get_texture()) |
4446 | ->get_minimap_color(f.field->get_brightness()) | format.Amask; |
4447 | } |
4448 | @@ -91,10 +93,7 @@ |
4449 | |
4450 | if (upcast(PlayerImmovable const, immovable, f.field->get_immovable())) { |
4451 | if ((flags & MiniMap::Roads) and dynamic_cast<Road const *>(immovable)) { |
4452 | - if (!(flags & MiniMap::Owner) && !strcmp(egbase.map().get_world_name(), "winterland")) |
4453 | - pixelcolor = blend_color(format, pixelcolor, 255, 127, 0); |
4454 | - else //ownership layer displayed or greenland |
4455 | - pixelcolor = blend_color(format, pixelcolor, 255, 255, 255); |
4456 | + pixelcolor = blend_color(format, pixelcolor, 255, 255, 255); |
4457 | } |
4458 | |
4459 | if |
4460 | @@ -104,14 +103,7 @@ |
4461 | and |
4462 | dynamic_cast<Widelands::Building const *>(immovable))) |
4463 | { |
4464 | - if (!(flags & MiniMap::Owner) && !strcmp(egbase.map().get_world_name(), "winterland")) |
4465 | - pixelcolor = |
4466 | - SDL_MapRGB |
4467 | - (&const_cast<SDL_PixelFormat &>(format), 255, 127, 0); |
4468 | - else //ownership layer displayed or greenland |
4469 | - pixelcolor = |
4470 | - SDL_MapRGB |
4471 | - (&const_cast<SDL_PixelFormat &>(format), 255, 255, 255); |
4472 | + pixelcolor = SDL_MapRGB(&const_cast<SDL_PixelFormat&>(format), 255, 255, 255); |
4473 | } |
4474 | } |
4475 | } |
4476 | |
4477 | === modified file 'src/graphic/texture.cc' |
4478 | --- src/graphic/texture.cc 2014-05-10 16:56:38 +0000 |
4479 | +++ src/graphic/texture.cc 2014-06-17 15:48:25 +0000 |
4480 | @@ -37,62 +37,39 @@ |
4481 | * Currently it converts a 16 bit image to a 8 bit texture. This should |
4482 | * be changed to load a 8 bit file directly, however. |
4483 | */ |
4484 | -Texture::Texture(const string& fnametmpl, uint32_t frametime, const SDL_PixelFormat& format) |
4485 | - : m_pixels (nullptr), |
4486 | - m_curframe (nullptr), |
4487 | - m_frame_num(0), |
4488 | - m_nrframes (0), |
4489 | - m_frametime(frametime), |
4490 | - m_was_animated(false) |
4491 | -{ |
4492 | - // Load the images one by one |
4493 | - char fname[256]; |
4494 | - |
4495 | - for (;;) { |
4496 | - int32_t nr = m_nrframes; |
4497 | - |
4498 | - // create the file name by reverse-scanning for '?' and replacing |
4499 | - snprintf(fname, sizeof(fname), "%s", fnametmpl.c_str()); |
4500 | - char * p = fname + strlen(fname); |
4501 | - while (p > fname) { |
4502 | - if (*--p != '?') |
4503 | - continue; |
4504 | - |
4505 | - *p = '0' + (nr % 10); |
4506 | - nr = nr / 10; |
4507 | +Texture::Texture(const std::vector<std::string>& texture_files, |
4508 | + const uint32_t frametime, |
4509 | + const SDL_PixelFormat& format) |
4510 | + : m_colormap(nullptr), |
4511 | + m_pixels(nullptr), |
4512 | + m_curframe(nullptr), |
4513 | + m_frame_num(0), |
4514 | + m_nrframes(0), |
4515 | + m_frametime(frametime) { |
4516 | + if (texture_files.empty()) { |
4517 | + throw wexception("No images for texture."); |
4518 | + } |
4519 | + |
4520 | + for (const std::string& fname : texture_files) { |
4521 | + if (!g_fs->FileExists(fname)) { |
4522 | + throw wexception("Could not find %s.", fname.c_str()); |
4523 | } |
4524 | |
4525 | - if (nr) // cycled up to maximum possible frame number |
4526 | - break; |
4527 | - |
4528 | - if (!g_fs->FileExists(fname)) |
4529 | - break; |
4530 | - |
4531 | SDL_Surface * surf; |
4532 | - |
4533 | m_texture_image = fname; |
4534 | - |
4535 | FileRead fr; |
4536 | - |
4537 | fr.Open(*g_fs, fname); |
4538 | |
4539 | surf = IMG_Load_RW(SDL_RWFromMem(fr.Data(0), fr.GetSize()), 1); |
4540 | - |
4541 | if (!surf) { |
4542 | - log |
4543 | - ("WARNING: Failed to load texture frame %s: %s\n", |
4544 | - fname, IMG_GetError()); |
4545 | - break; |
4546 | + throw wexception("WARNING: Failed to load texture frame %s: %s\n", fname.c_str(), IMG_GetError()); |
4547 | } |
4548 | - |
4549 | if (surf->w != TEXTURE_WIDTH || surf->h != TEXTURE_HEIGHT) { |
4550 | SDL_FreeSurface(surf); |
4551 | - log |
4552 | - ("WARNING: %s: texture must be %ix%i pixels big\n", |
4553 | - fname, |
4554 | - TEXTURE_WIDTH, |
4555 | - TEXTURE_HEIGHT); |
4556 | - break; |
4557 | + throw wexception("WARNING: %s: texture must be %ix%i pixels big\n", |
4558 | + fname.c_str(), |
4559 | + TEXTURE_WIDTH, |
4560 | + TEXTURE_HEIGHT); |
4561 | } |
4562 | |
4563 | if (g_opengl) { |
4564 | @@ -138,7 +115,7 @@ |
4565 | } else { |
4566 | SDL_Color pal[256]; |
4567 | |
4568 | - log("WARNING: %s: using 332 default palette\n", fname); |
4569 | + log("WARNING: %s: using 332 default palette\n", fname.c_str()); |
4570 | |
4571 | for (int32_t r = 0; r < 8; ++r) |
4572 | for (int32_t g = 0; g < 8; ++g) |
4573 | @@ -192,7 +169,7 @@ |
4574 | } |
4575 | |
4576 | if (!m_nrframes) |
4577 | - throw wexception("%s: texture has no frames", fnametmpl.c_str()); |
4578 | + throw wexception("Texture has no frames"); |
4579 | } |
4580 | |
4581 | |
4582 | @@ -220,13 +197,7 @@ |
4583 | void Texture::animate(uint32_t time) |
4584 | { |
4585 | m_frame_num = (time / m_frametime) % m_nrframes; |
4586 | - |
4587 | if (g_opengl) |
4588 | return; |
4589 | - |
4590 | - uint8_t * const lastframe = m_curframe; |
4591 | - |
4592 | m_curframe = &m_pixels[TEXTURE_WIDTH * TEXTURE_HEIGHT * m_frame_num]; |
4593 | - if (lastframe != m_curframe) |
4594 | - m_was_animated = true; |
4595 | } |
4596 | |
4597 | === modified file 'src/graphic/texture.h' |
4598 | --- src/graphic/texture.h 2014-06-10 20:42:45 +0000 |
4599 | +++ src/graphic/texture.h 2014-06-17 15:48:25 +0000 |
4600 | @@ -40,8 +40,9 @@ |
4601 | * changed to load 8 bit bitmaps directly. |
4602 | */ |
4603 | struct Texture { |
4604 | - Texture |
4605 | - (const std::string& fnametempl, uint32_t frametime, const SDL_PixelFormat&); |
4606 | + Texture(const std::vector<std::string>& texture_files, |
4607 | + uint32_t frametime, |
4608 | + const SDL_PixelFormat&); |
4609 | ~Texture(); |
4610 | |
4611 | const std::string & get_texture_image() const {return m_texture_image;} |
4612 | @@ -53,8 +54,6 @@ |
4613 | uint32_t get_minimap_color(char shade); |
4614 | |
4615 | void animate(uint32_t time); |
4616 | - void reset_was_animated() {m_was_animated = false;} |
4617 | - bool was_animated() const {return m_was_animated;} |
4618 | uint32_t getTexture() const |
4619 | {return m_glFrames.at(m_frame_num)->get_gl_texture();} |
4620 | |
4621 | @@ -67,7 +66,6 @@ |
4622 | std::string m_texture_image; |
4623 | uint32_t m_nrframes; |
4624 | uint32_t m_frametime; |
4625 | - bool m_was_animated; |
4626 | std::vector<std::unique_ptr<GLSurfaceTexture>> m_glFrames; |
4627 | }; |
4628 | |
4629 | |
4630 | === modified file 'src/io/filesystem/disk_filesystem.cc' |
4631 | --- src/io/filesystem/disk_filesystem.cc 2014-06-14 13:53:57 +0000 |
4632 | +++ src/io/filesystem/disk_filesystem.cc 2014-06-17 15:48:25 +0000 |
4633 | @@ -383,8 +383,9 @@ |
4634 | |
4635 | length = size; |
4636 | } catch (...) { |
4637 | - if (file) |
4638 | + if (file) { |
4639 | fclose(file); |
4640 | + } |
4641 | free(data); |
4642 | throw; |
4643 | } |
4644 | |
4645 | === modified file 'src/logic/bob.cc' |
4646 | --- src/logic/bob.cc 2014-05-11 07:38:01 +0000 |
4647 | +++ src/logic/bob.cc 2014-06-17 15:48:25 +0000 |
4648 | @@ -21,10 +21,11 @@ |
4649 | |
4650 | #include <cstdlib> |
4651 | |
4652 | +#include <stdint.h> |
4653 | + |
4654 | #include "backtrace.h" |
4655 | #include "economy/route.h" |
4656 | #include "economy/transfer.h" |
4657 | -#include "graphic/graphic.h" |
4658 | #include "graphic/rendertarget.h" |
4659 | #include "io/fileread.h" |
4660 | #include "io/filewrite.h" |
4661 | @@ -49,6 +50,12 @@ |
4662 | |
4663 | namespace Widelands { |
4664 | |
4665 | +BobDescr::BobDescr(const std::string& init_name, |
4666 | + const std::string& init_descname, |
4667 | + Tribe_Descr const* tribe) |
4668 | + : Map_Object_Descr(init_name, init_descname), owner_tribe_(tribe) { |
4669 | +} |
4670 | + |
4671 | /** |
4672 | * Only tribe bobs have a vision range, since it would be irrelevant |
4673 | * for world bobs. |
4674 | @@ -59,42 +66,15 @@ |
4675 | */ |
4676 | uint32_t BobDescr::vision_range() const |
4677 | { |
4678 | - if (m_owner_tribe) { |
4679 | + if (owner_tribe_) { |
4680 | if (upcast(const Ship_Descr, ship, this)) |
4681 | return ship->vision_range(); |
4682 | - return m_owner_tribe->get_bob_vision_range(); |
4683 | + return owner_tribe_->get_bob_vision_range(); |
4684 | } |
4685 | |
4686 | return 0; |
4687 | } |
4688 | |
4689 | - |
4690 | -BobDescr::BobDescr |
4691 | - (char const * const _name, char const * const _descname, |
4692 | - const std::string & directory, Profile & prof, Section & global_s, |
4693 | - Tribe_Descr const * const tribe) |
4694 | - : |
4695 | - Map_Object_Descr(_name, _descname), |
4696 | - m_owner_tribe(tribe) |
4697 | -{ |
4698 | - { // global options |
4699 | - Section & idle_s = prof.get_safe_section("idle"); |
4700 | - |
4701 | - add_animation("idle", g_gr->animations().load(directory, idle_s)); |
4702 | - } |
4703 | - |
4704 | - // Parse attributes |
4705 | - while (Section::Value const * val = global_s.get_next_val("attrib")) { |
4706 | - uint32_t const attrib = get_attribute_id(val->get_string()); |
4707 | - |
4708 | - if (attrib < Map_Object::HIGHEST_FIXED_ATTRIBUTE) |
4709 | - throw game_data_error("bad attribute \"%s\"", val->get_string()); |
4710 | - |
4711 | - add_attribute(attrib); |
4712 | - } |
4713 | -} |
4714 | - |
4715 | - |
4716 | /** |
4717 | * Create a bob of this type |
4718 | */ |
4719 | |
4720 | === modified file 'src/logic/bob.h' |
4721 | --- src/logic/bob.h 2014-05-11 07:38:01 +0000 |
4722 | +++ src/logic/bob.h 2014-06-17 15:48:25 +0000 |
4723 | @@ -29,7 +29,7 @@ |
4724 | #include "point.h" |
4725 | #include "port.h" |
4726 | |
4727 | -struct Profile; |
4728 | +class Profile; |
4729 | |
4730 | namespace Widelands { |
4731 | class Map; |
4732 | @@ -55,21 +55,15 @@ |
4733 | public: |
4734 | friend struct Map_Bobdata_Data_Packet; |
4735 | |
4736 | - BobDescr(char const* name, |
4737 | - char const* descname, |
4738 | - const std::string& directory, |
4739 | - Profile&, |
4740 | - Section& global_s, |
4741 | - Tribe_Descr const*); |
4742 | + BobDescr(const std::string& init_name, |
4743 | + const std::string& init_descname, |
4744 | + Tribe_Descr const* tribe); |
4745 | |
4746 | virtual ~BobDescr() {}; |
4747 | Bob& create(Editor_Game_Base&, Player* owner, const Coords&) const; |
4748 | - bool is_world_bob() const { |
4749 | - return not m_owner_tribe; |
4750 | - } |
4751 | |
4752 | Tribe_Descr const* get_owner_tribe() const { |
4753 | - return m_owner_tribe; |
4754 | + return owner_tribe_; |
4755 | } |
4756 | |
4757 | virtual uint32_t movecaps() const { |
4758 | @@ -80,7 +74,8 @@ |
4759 | protected: |
4760 | virtual Bob& create_object() const = 0; |
4761 | |
4762 | - const Tribe_Descr* const m_owner_tribe; // 0 if world bob |
4763 | +private: |
4764 | + const Tribe_Descr* const owner_tribe_; // nullptr if world bob |
4765 | }; |
4766 | |
4767 | /** |
4768 | @@ -248,7 +243,6 @@ |
4769 | void set_position(Editor_Game_Base &, const Coords &); |
4770 | const FCoords & get_position() const {return m_position;} |
4771 | Bob * get_next_bob() const {return m_linknext;} |
4772 | - bool is_world_bob() const {return descr().is_world_bob();} |
4773 | |
4774 | uint32_t vision_range() const {return descr().vision_range();} |
4775 | |
4776 | |
4777 | === modified file 'src/logic/buildcost.h' |
4778 | --- src/logic/buildcost.h 2014-05-11 07:38:01 +0000 |
4779 | +++ src/logic/buildcost.h 2014-06-17 15:48:25 +0000 |
4780 | @@ -26,7 +26,7 @@ |
4781 | |
4782 | class FileRead; |
4783 | class FileWrite; |
4784 | -struct Section; |
4785 | +class Section; |
4786 | |
4787 | namespace Widelands { |
4788 | |
4789 | |
4790 | === modified file 'src/logic/building.h' |
4791 | --- src/logic/building.h 2014-05-11 07:38:01 +0000 |
4792 | +++ src/logic/building.h 2014-06-17 15:48:25 +0000 |
4793 | @@ -38,7 +38,7 @@ |
4794 | namespace UI {class Window;} |
4795 | struct BuildingHints; |
4796 | class Interactive_GameBase; |
4797 | -struct Profile; |
4798 | +class Profile; |
4799 | class Image; |
4800 | |
4801 | namespace Widelands { |
4802 | @@ -160,7 +160,7 @@ |
4803 | |
4804 | class Building : public PlayerImmovable { |
4805 | friend struct Building_Descr; |
4806 | - friend struct Map_Buildingdata_Data_Packet; |
4807 | + friend class Map_Buildingdata_Data_Packet; |
4808 | |
4809 | MO_DESCR(Building_Descr) |
4810 | |
4811 | |
4812 | === modified file 'src/logic/constructionsite.h' |
4813 | --- src/logic/constructionsite.h 2014-04-06 10:50:39 +0000 |
4814 | +++ src/logic/constructionsite.h 2014-06-17 15:48:25 +0000 |
4815 | @@ -59,7 +59,7 @@ |
4816 | }; |
4817 | |
4818 | class ConstructionSite : public Partially_Finished_Building { |
4819 | - friend struct Map_Buildingdata_Data_Packet; |
4820 | + friend class Map_Buildingdata_Data_Packet; |
4821 | |
4822 | static const uint32_t CONSTRUCTIONSITE_STEP_TIME = 30000; |
4823 | |
4824 | |
4825 | === modified file 'src/logic/critter_bob.cc' |
4826 | --- src/logic/critter_bob.cc 2014-05-11 07:38:01 +0000 |
4827 | +++ src/logic/critter_bob.cc 2014-06-17 15:48:25 +0000 |
4828 | @@ -21,6 +21,9 @@ |
4829 | |
4830 | #include <cstdio> |
4831 | |
4832 | +#include <stdint.h> |
4833 | + |
4834 | +#include "graphic/graphic.h" |
4835 | #include "helper.h" |
4836 | #include "io/fileread.h" |
4837 | #include "io/filewrite.h" |
4838 | @@ -29,57 +32,67 @@ |
4839 | #include "logic/game.h" |
4840 | #include "logic/game_data_error.h" |
4841 | #include "logic/tribe.h" |
4842 | +#include "logic/world/world.h" |
4843 | +#include "map_io/one_world_legacy_lookup_table.h" |
4844 | #include "profile/profile.h" |
4845 | +#include "scripting/lua_table.h" |
4846 | #include "wexception.h" |
4847 | |
4848 | |
4849 | namespace Widelands { |
4850 | |
4851 | -const Critter_BobProgram::ParseMap Critter_BobProgram::s_parsemap[] = { |
4852 | - {"remove", &Critter_BobProgram::parse_remove}, |
4853 | - {nullptr, nullptr} |
4854 | -}; |
4855 | - |
4856 | - |
4857 | -void Critter_BobProgram::parse(Parser * const parser, char const * const name) |
4858 | -{ |
4859 | - Section & program_s = parser->prof->get_safe_section(name); |
4860 | - |
4861 | +namespace { |
4862 | + |
4863 | +// Parses program lines in a section into a vector of strings. |
4864 | +std::vector<std::string> section_to_strings(Section* section) { |
4865 | + std::vector<std::string> return_value; |
4866 | for (uint32_t idx = 0;; ++idx) { |
4867 | + char buffer[32]; |
4868 | + snprintf(buffer, sizeof(buffer), "%i", idx); |
4869 | + char const* const string = section->get_string(buffer, nullptr); |
4870 | + if (!string) |
4871 | + break; |
4872 | + return_value.emplace_back(string); |
4873 | + } |
4874 | + // Check for line numbering problems |
4875 | + if (section->get_num_values() != return_value.size()) |
4876 | + throw wexception("Line numbers appear to be wrong"); |
4877 | + return return_value; |
4878 | +} |
4879 | + |
4880 | +// Sets the dir animations in 'anims' with the animations |
4881 | +// '<prefix>_(ne|e|se|sw|w|nw)' which must be defined in 'mo'. |
4882 | +void assign_diranimation(DirAnimations* anims, Map_Object_Descr& mo, const std::string& prefix) { |
4883 | + static char const* const dirstrings[6] = {"ne", "e", "se", "sw", "w", "nw"}; |
4884 | + for (int32_t dir = 1; dir <= 6; ++dir) { |
4885 | + anims->set_animation(dir, mo.get_animation(prefix + std::string("_") + dirstrings[dir - 1])); |
4886 | + } |
4887 | +} |
4888 | + |
4889 | +} // namespace |
4890 | + |
4891 | +void Critter_BobProgram::parse(const std::vector<std::string>& lines) { |
4892 | + for (const std::string& line : lines) { |
4893 | try { |
4894 | - char buffer[32]; |
4895 | - |
4896 | - snprintf(buffer, sizeof(buffer), "%i", idx); |
4897 | - char const * const string = program_s.get_string(buffer, nullptr); |
4898 | - if (!string) |
4899 | - break; |
4900 | - |
4901 | - const std::vector<std::string> cmd(split_string(string, " \t\r\n")); |
4902 | + const std::vector<std::string> cmd(split_string(line, " \t\r\n")); |
4903 | if (cmd.empty()) |
4904 | continue; |
4905 | |
4906 | - // find the appropriate parser |
4907 | Critter_BobAction act; |
4908 | - uint32_t mapidx; |
4909 | - |
4910 | - for (mapidx = 0; s_parsemap[mapidx].name; ++mapidx) |
4911 | - if (cmd[0] == s_parsemap[mapidx].name) |
4912 | - break; |
4913 | - |
4914 | - if (!s_parsemap[mapidx].name) |
4915 | + if (cmd[0] == "remove") { |
4916 | + if (cmd.size() != 1) |
4917 | + throw wexception("Usage: remove"); |
4918 | + act.function = &Critter_Bob::run_remove; |
4919 | + } else { |
4920 | throw wexception("unknown command type \"%s\"", cmd[0].c_str()); |
4921 | - |
4922 | - (this->*s_parsemap[mapidx].function)(&act, parser, cmd); |
4923 | + } |
4924 | |
4925 | m_actions.push_back(act); |
4926 | - } catch (const std::exception & e) { |
4927 | - throw wexception("Line %i: %s", idx, e.what()); |
4928 | + } |
4929 | + catch (const std::exception& e) { |
4930 | + throw wexception("Line '%s': %s", line.c_str(), e.what()); |
4931 | } |
4932 | } |
4933 | - |
4934 | - // Check for line numbering problems |
4935 | - if (program_s.get_num_values() != m_actions.size()) |
4936 | - throw wexception("Line numbers appear to be wrong"); |
4937 | } |
4938 | |
4939 | /* |
4940 | @@ -99,15 +112,6 @@ |
4941 | |
4942 | ============================== |
4943 | */ |
4944 | -void Critter_BobProgram::parse_remove |
4945 | - (Critter_BobAction * act, Parser *, const std::vector<std::string> & cmd) |
4946 | -{ |
4947 | - if (cmd.size() != 1) |
4948 | - throw wexception("Usage: remove"); |
4949 | - |
4950 | - act->function = &Critter_Bob::run_remove; |
4951 | -} |
4952 | - |
4953 | bool Critter_Bob::run_remove |
4954 | (Game & game, State & state, const Critter_BobAction &) |
4955 | { |
4956 | @@ -126,14 +130,27 @@ |
4957 | =========================================================================== |
4958 | */ |
4959 | |
4960 | -Critter_Bob_Descr::Critter_Bob_Descr |
4961 | - (char const * const _name, char const * const _descname, |
4962 | - const std::string & directory, Profile & prof, Section & global_s, |
4963 | - Tribe_Descr const * const _tribe) |
4964 | - : |
4965 | - BobDescr(_name, _descname, directory, prof, global_s, _tribe), |
4966 | - m_swimming(global_s.get_bool("swimming", false)) |
4967 | -{ |
4968 | +Critter_Bob_Descr::Critter_Bob_Descr(char const* const _name, |
4969 | + char const* const _descname, |
4970 | + const std::string& directory, |
4971 | + Profile& prof, |
4972 | + Section& global_s, |
4973 | + Tribe_Descr const* const _tribe) |
4974 | + : BobDescr(_name, _descname, _tribe) { |
4975 | + { // global options |
4976 | + Section & idle_s = prof.get_safe_section("idle"); |
4977 | + add_animation("idle", g_gr->animations().load(directory, idle_s)); |
4978 | + } |
4979 | + |
4980 | + // Parse attributes |
4981 | + { |
4982 | + std::vector<std::string> attributes; |
4983 | + while (Section::Value const* val = global_s.get_next_val("attrib")) { |
4984 | + attributes.emplace_back(val->get_string()); |
4985 | + } |
4986 | + add_attributes(attributes, std::set<uint32_t>()); |
4987 | + } |
4988 | + |
4989 | char defaultpics[256]; |
4990 | snprintf(defaultpics, sizeof(defaultpics), "%s_walk_!!_??.png", _name); |
4991 | m_walk_anims.parse(*this, directory, prof, "walk", false, defaultpics); |
4992 | @@ -147,14 +164,10 @@ |
4993 | try { |
4994 | if (m_programs.count(program_name)) |
4995 | throw wexception("this program has already been declared"); |
4996 | - Critter_BobProgram::Parser parser; |
4997 | - |
4998 | - parser.descr = this; |
4999 | - parser.directory = directory; |
5000 | - parser.prof = &prof; |
For the translations, the best thing to keep as much as we can is to use the msgmerge utility - I guess you are already using this when integrating updates from Launchpad? We could do something like the following:
1. reconfigure our script for xgettext to collect all world-related strings into one .pot catalog, e.g. worlds/worlds.pot.
2. Grab the current Launchpad translations
3. Use msgmerge to merge the 4 old worlds into one, creating a new po file in the process. Something like this:
msgmerge -o worlds/de.po world-blackland /de.po worlds/worlds.pot /de.po worlds/worlds.pot d/de.po worlds/worlds.pot
msgmerge -o worlds/de.po world-desert/de.po worlds/worlds.pot
msgmerge -o worlds/de.po world-greenland
msgmerge -o worlds/de.po world-winterlan
I think it would be a good idea to test this with German, because more than one of us speak the language, and we could open the resulting worlds/de.po and have a look if everything's OK.