diff --git a/gui/baum_edit.cc b/gui/baum_edit.cc index ecda1c180..0aab0f7e8 100644 --- a/gui/baum_edit.cc +++ b/gui/baum_edit.cc @@ -65,7 +65,7 @@ void baum_edit_frame_t::fill_list( bool translate ) { tree_list.clear(); FOR(vector_tpl, const i, baum_t::get_all_desc()) { - if (i) { + if ( i && (i->get_allowed_climate_bits() & get_climate()) ) { tree_list.insert_ordered(i, compare_tree_desc); } } diff --git a/gui/citybuilding_edit.cc b/gui/citybuilding_edit.cc index 1ca25d6dc..87187f7ba 100644 --- a/gui/citybuilding_edit.cc +++ b/gui/citybuilding_edit.cc @@ -100,13 +100,15 @@ void citybuilding_edit_frame_t::fill_list( bool translate ) const bool allow_obsolete = bt_obsolete.pressed; const bool use_timeline = bt_timeline.pressed; const sint32 month_now = bt_timeline.pressed ? welt->get_current_month() : 0; + uint8 chosen_climate = get_climate(); building_list.clear(); if(bt_res.pressed) { FOR(vector_tpl, const desc, *hausbauer_t::get_citybuilding_list(building_desc_t::city_res)) { - if(!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) { - // timeline allows for this + if( (!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) + && ( desc->get_allowed_climate_bits() & chosen_climate) ) { + // timeline allows for this, and so does climates setting building_list.insert_ordered(desc, translate?compare_building_desc_trans:compare_building_desc ); } } @@ -114,8 +116,9 @@ void citybuilding_edit_frame_t::fill_list( bool translate ) if(bt_com.pressed) { FOR(vector_tpl, const desc, *hausbauer_t::get_citybuilding_list(building_desc_t::city_com)) { - if(!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) { - // timeline allows for this + if( (!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) + && ( desc->get_allowed_climate_bits() & chosen_climate) ) { + // timeline allows for this, and so does climates setting building_list.insert_ordered(desc, translate?compare_building_desc_trans:compare_building_desc ); } } @@ -123,8 +126,9 @@ void citybuilding_edit_frame_t::fill_list( bool translate ) if(bt_ind.pressed) { FOR(vector_tpl, const desc, *hausbauer_t::get_citybuilding_list(building_desc_t::city_ind)) { - if(!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) { - // timeline allows for this + if( (!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) + && ( desc->get_allowed_climate_bits() & chosen_climate) ) { + // timeline allows for this, and so does climates setting building_list.insert_ordered(desc, translate?compare_building_desc_trans:compare_building_desc ); } } @@ -244,6 +248,7 @@ void citybuilding_edit_frame_t::change_item_info(sint32 entry) if(welt->get_tool(player->get_player_nr())==&haus_tool) { welt->set_tool( tool_t::general_tool[TOOL_QUERY], player ); } + buf.clear(); building_image.init(NULL, 0); cb_rotation.clear_elements(); cb_rotation.new_component(gui_rotation_item_t::random); diff --git a/gui/curiosity_edit.cc b/gui/curiosity_edit.cc index b046a5f07..fd517fa2b 100644 --- a/gui/curiosity_edit.cc +++ b/gui/curiosity_edit.cc @@ -85,13 +85,15 @@ void curiosity_edit_frame_t::fill_list( bool translate ) const bool allow_obsolete = bt_obsolete.pressed; const bool use_timeline = bt_timeline.pressed; const sint32 month_now = bt_timeline.pressed ? welt->get_current_month() : 0; + uint8 chosen_climate = get_climate(); building_list.clear(); if(bt_city_attraction.pressed) { FOR(vector_tpl, const desc, *hausbauer_t::get_list(building_desc_t::attraction_city)) { - if(!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) { - // timeline allows for this + if( (!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) + && ( desc->get_allowed_climate_bits() & chosen_climate) ) { + // timeline allows for this, and so does climates setting building_list.insert_ordered( desc, translate?compare_building_desc_trans:compare_building_desc ); } } @@ -99,8 +101,9 @@ void curiosity_edit_frame_t::fill_list( bool translate ) if(bt_land_attraction.pressed) { FOR(vector_tpl, const desc, *hausbauer_t::get_list(building_desc_t::attraction_land)) { - if(!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) { - // timeline allows for this + if( (!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) + && ( desc->get_allowed_climate_bits() & chosen_climate) ) { + // timeline allows for this, and so does climates setting building_list.insert_ordered( desc, translate?compare_building_desc_trans:compare_building_desc ); } } @@ -108,8 +111,9 @@ void curiosity_edit_frame_t::fill_list( bool translate ) if(bt_monuments.pressed) { FOR(vector_tpl, const desc, *hausbauer_t::get_list(building_desc_t::monument)) { - if(!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) { - // timeline allows for this + if( (!use_timeline || (!desc->is_future(month_now) && (!desc->is_retired(month_now) || allow_obsolete)) ) + && ( desc->get_allowed_climate_bits() & chosen_climate) ) { + // timeline allows for this, and so does climates setting building_list.insert_ordered( desc, translate?compare_building_desc_trans:compare_building_desc ); } } @@ -236,6 +240,7 @@ void curiosity_edit_frame_t::change_item_info(sint32 entry) building_image.init(NULL, 0); cb_rotation.clear_elements(); cb_rotation.new_component(gui_rotation_item_t::random); + buf.clear(); } reset_min_windowsize(); } diff --git a/gui/extend_edit.cc b/gui/extend_edit.cc index eabe572a1..569c57f7c 100644 --- a/gui/extend_edit.cc +++ b/gui/extend_edit.cc @@ -9,29 +9,39 @@ #include "../simevent.h" #include "../dataobj/translator.h" +#include "../descriptor/ground_desc.h" #include "../player/simplay.h" #include "extend_edit.h" - -static const char* numbers[] = { "0", "1", "2", "3" }; - gui_rotation_item_t::gui_rotation_item_t(uint8 r) : gui_scrolled_list_t::const_text_scrollitem_t(NULL, SYSCOL_TEXT) { rotation = r; - - if (rotation <= 3) { - text = numbers[rotation]; - } - else if (rotation == automatic) { - text = translator::translate("auto"); + switch(rotation) { + case 0: text = translator::translate("[0] south-facing"); break; + case 1: text = translator::translate("[1] east-facing"); break; + case 2: text = translator::translate("[2] north-facing"); break; + case 3: text = translator::translate("[3] west-facing"); break; + case 4: text = translator::translate("[4] southeast corner"); break; + case 5: text = translator::translate("[5] northeast corner"); break; + case 6: text = translator::translate("[6] northwest corner"); break; + case 7: text = translator::translate("[7] southwest corner"); break; + case automatic: text = translator::translate("auto"); break; + case random: text = translator::translate("random"); break; + default: text = ""; } - else if (rotation == random) { - text = translator::translate("random"); +} + +gui_climates_item_t::gui_climates_item_t(uint8 c) : gui_scrolled_list_t::const_text_scrollitem_t(NULL, SYSCOL_TEXT) +{ + if(cnew_component("Climate"); + tbl->add_component(&cb_climates); + cb_climates.add_listener(this); + cb_climates.new_component(climate::MAX_CLIMATES); + for(uint8 i=climate::desert_climate; i(i); + } + cb_climates.set_selection(0); + cont_right.end_table(); + add_component(&cont_right); cont_right.set_table_layout(1,0); @@ -156,6 +178,10 @@ bool extend_edit_gui_t::action_triggered( gui_action_creator_t *comp,value_t /* bt_timeline.pressed ^= 1; fill_list( is_show_trans_name ); } + else if( comp==&cb_climates ) { + fill_list( is_show_trans_name ); + change_item_info(scl.get_selection()); + } return true; } @@ -167,3 +193,10 @@ uint8 extend_edit_gui_t::get_rotation() const } return 0; } +uint8 extend_edit_gui_t::get_climate() const +{ + if (gui_climates_item_t *item = dynamic_cast( cb_climates.get_selected_item() ) ) { + return item->get_climate(); + } + return ALL_CLIMATES; +} \ No newline at end of file diff --git a/gui/extend_edit.h b/gui/extend_edit.h index 83cf89851..51df1784d 100644 --- a/gui/extend_edit.h +++ b/gui/extend_edit.h @@ -45,6 +45,26 @@ public: sint8 get_rotation() const { return rotation; } }; +/** + * Entries for climate selection. + */ +class gui_climates_item_t : public gui_scrolled_list_t::const_text_scrollitem_t +{ +private: + const char *text; + uint8 climate_; + +public: + gui_climates_item_t(uint8 r); + + char const* get_text () const OVERRIDE { return text; } + + sint8 get_climate() const { return climate_; } +}; + + + + /** * Base class map editor dialogues to select object to place on map. */ @@ -69,7 +89,7 @@ protected: button_t bt_obsolete, bt_timeline, bt_climates; // we make this available for child classes - gui_combobox_t cb_rotation; + gui_combobox_t cb_rotation, cb_climates; /// show translated names bool is_show_trans_name; @@ -84,6 +104,12 @@ protected: * defaults to zero. */ uint8 get_rotation() const; + + /** + * @returns selected climate of cb_climates. + */ + uint8 get_climate() const; + public: extend_edit_gui_t(const char *name, player_t* player_); diff --git a/gui/factory_edit.cc b/gui/factory_edit.cc index 6cf76682d..6bccda58a 100644 --- a/gui/factory_edit.cc +++ b/gui/factory_edit.cc @@ -58,6 +58,9 @@ factory_edit_frame_t::factory_edit_frame_t(player_t* player_) : bt_land_chain.add_listener(this); cont_right.add_component(&bt_land_chain); + // add water to climate selection + cb_climates.new_component(climate::water_climate); + // rotation, production gui_aligned_container_t *tbl = cont_right.add_table(2,2); tbl->new_component("Rotation"); @@ -96,8 +99,9 @@ void factory_edit_frame_t::fill_list( bool translate ) if(desc->get_distribution_weight()>0) { // DistributionWeight=0 is obsoleted item, only for backward compatibility - if(!use_timeline || (!desc->get_building()->is_future(month_now) && (!desc->get_building()->is_retired(month_now) || allow_obsolete)) ) { - // timeline allows for this + if( (!use_timeline || (!desc->get_building()->is_future(month_now) && (!desc->get_building()->is_retired(month_now) || allow_obsolete))) + && ( desc->get_building()->get_allowed_climate_bits() & get_climate()) ) { + // timeline allows for this, and so does climates setting if(city_chain) { if (desc->get_placement() == factory_desc_t::City && desc->is_consumer_only()) { @@ -307,6 +311,7 @@ void factory_edit_frame_t::change_item_info(sint32 entry) building_image.init(NULL, 0); fac_desc = NULL; welt->set_tool( tool_t::general_tool[TOOL_QUERY], player ); + buf.clear(); } info_text.recalc_size(); reset_min_windowsize();