void custom_tod::do_delete_tod(window& window) { assert(tods_.begin() + current_tod_ < tods_.end()); if(tods_.size() == 1) { tods_.at(0) = time_of_day(); update_selected_tod_info(window); return; } tods_.erase(tods_.begin() + current_tod_); if(tods_.begin() + current_tod_ >= tods_.end()) { current_tod_ = tods_.size() - 1; } update_selected_tod_info(window); }
void custom_tod::select_file(window& window, const std::string& default_dir) { const string_pair& data = (*fptr)(get_selected_tod()); std::string fn = filesystem::base_name(data.second); std::string dn = filesystem::directory_name(fn); if(dn.empty()) { dn = default_dir; } gui2::dialogs::file_dialog dlg; dlg.set_title(_("Choose File")) .set_ok_label(_("Select")) .set_path(dn) .set_read_only(true); if(dlg.show()) { dn = dlg.path(); if(data.first == "image") { times_[current_tod_].image = dn; } else if(data.first == "mask") { times_[current_tod_].image_mask = dn; } else if(data.first == "sound") { times_[current_tod_].sounds = dn; } } update_selected_tod_info(window); }
void tcustom_tod::select_file(const std::string& filename, const std::string& default_dir, const std::string& attribute, twindow& window) { std::string fn = filesystem::base_name(filename); std::string dn = filesystem::directory_name(fn); if(dn.empty()) { dn = default_dir; } gui2::tfile_dialog dlg; dlg.set_title(_("Choose File")) .set_ok_label(_("Select")) .set_path(dn) .set_read_only(true); if(dlg.show(display_.video())) { dn = dlg.path(); if(attribute == "image") { tods_[current_tod_].image = dn; } else if(attribute == "mask") { tods_[current_tod_].image_mask = dn; } else if(attribute == "sound") { tods_[current_tod_].sounds = dn; } } update_selected_tod_info(window); }
void teditor_settings::do_next_tod(twindow& window) { current_tod_++; current_tod_ %= tods_.size(); custom_tod_toggle_->set_value(false); update_selected_tod_info(window); }
void custom_tod::do_delete_tod(window& window) { assert(times_.begin() + current_tod_ < times_.end()); if(times_.size() == 1) { times_.emplace_back(); } else { times_.erase(times_.begin() + current_tod_); if(times_.begin() + current_tod_ >= times_.end()) { current_tod_ = times_.size() - 1; } } update_selected_tod_info(window); }
void teditor_settings::pre_show(CVideo& /*video*/, twindow& window) { assert(!tods_.empty()); current_tod_label_ = find_widget<tlabel>( &window, "current_tod", false, true); current_tod_image_ = find_widget<tlabel>( &window, "current_tod_image", false, true); custom_tod_toggle_ = find_widget<ttoggle_button>( &window, "custom_tod_toggle", false, true); custom_tod_auto_refresh_ = find_widget<ttoggle_button>( &window, "custom_tod_auto_refresh", false, true); custom_tod_red_ = find_widget<tslider>( &window, "custom_tod_red", false, true); custom_tod_green_ = find_widget<tslider>( &window, "custom_tod_green", false, true); custom_tod_blue_ = find_widget<tslider>( &window, "custom_tod_blue", false, true); tbutton& next_tod_button = find_widget<tbutton>( &window, "next_tod", false); next_tod_button.set_callback_mouse_left_click( dialog_callback<teditor_settings , &teditor_settings::do_next_tod>); tbutton& apply_button = find_widget<tbutton>( &window, "apply", false); apply_button.set_callback_mouse_left_click( dialog_callback<teditor_settings , &teditor_settings::update_tod_display>); custom_tod_toggle_->set_callback_state_change( dialog_callback<teditor_settings , &teditor_settings::update_selected_tod_info>); custom_tod_red_->set_callback_positioner_move( dialog_callback<teditor_settings , &teditor_settings::slider_update_callback>); custom_tod_green_->set_callback_positioner_move( dialog_callback<teditor_settings , &teditor_settings::slider_update_callback>); custom_tod_blue_->set_callback_positioner_move( dialog_callback<teditor_settings , &teditor_settings::slider_update_callback>); update_selected_tod_info(window); }
void tcustom_tod::select_file(const std::string& filename, const std::string& default_dir, const std::string& attribute, twindow& window) { std::string fn = filesystem::base_name(filename); std::string dn = filesystem::directory_name(fn); if(dn.empty()) { dn = default_dir; } int res = dialogs::show_file_chooser_dialog( display_->video(), dn, _("Choose File")); if(res == 0) { if(attribute == "image") { tods_[current_tod_].image = dn; } else if(attribute == "mask") { tods_[current_tod_].image_mask = dn; } else if(attribute == "sound") { tods_[current_tod_].sounds = dn; } } update_selected_tod_info(window); }
void custom_tod::pre_show(window& window) { assert(!tods_.empty()); tod_red_field_ = find_widget<slider>(&window, "tod_red", false, true); tod_green_field_ = find_widget<slider>(&window, "tod_green", false, true); tod_blue_field_ = find_widget<slider>(&window, "tod_blue", false, true); current_tod_name_ = find_widget<text_box>(&window, "tod_name", false, true); current_tod_id_ = find_widget<text_box>(&window, "tod_id", false, true); current_tod_image_ = find_widget<image>(&window, "current_tod_image", false, true); current_tod_mask_ = find_widget<image>(&window, "current_tod_mask", false, true); current_tod_sound_ = find_widget<label>(&window, "current_sound", false, true); current_tod_number_ = find_widget<label>(&window, "tod_number", false, true); connect_signal_mouse_left_click(find_widget<button>(&window, "image_button", false), std::bind(&custom_tod::select_file, this, get_selected_tod().image, "data/core/images/misc", "image", std::ref(window))); connect_signal_mouse_left_click(find_widget<button>(&window, "mask_button", false), std::bind(&custom_tod::select_file, this, get_selected_tod().image_mask, "data/core/images", "mask", std::ref(window))); connect_signal_mouse_left_click(find_widget<button>(&window, "sound_button", false), std::bind(&custom_tod::select_file, this, get_selected_tod().sounds, "data/core/sounds/ambient", "sound", std::ref(window))); connect_signal_mouse_left_click( find_widget<button>(&window, "next_tod", false), std::bind(&custom_tod::do_next_tod, this, std::ref(window))); connect_signal_mouse_left_click( find_widget<button>(&window, "previous_tod", false), std::bind(&custom_tod::do_prev_tod, this, std::ref(window))); connect_signal_mouse_left_click( find_widget<button>(&window, "new", false), std::bind(&custom_tod::do_new_tod, this, std::ref(window))); connect_signal_mouse_left_click( find_widget<button>(&window, "delete", false), std::bind(&custom_tod::do_delete_tod, this, std::ref(window))); connect_signal_notify_modified( *(lawful_bonus_field_->get_widget()), std::bind(&custom_tod::update_lawful_bonus, this, std::ref(window))); connect_signal_notify_modified( *tod_red_field_, std::bind(&custom_tod::update_tod_display, this, std::ref(window))); connect_signal_notify_modified( *tod_green_field_, std::bind(&custom_tod::update_tod_display, this, std::ref(window))); connect_signal_notify_modified( *tod_blue_field_, std::bind(&custom_tod::update_tod_display, this, std::ref(window))); for(size_t i = 0; i < tods_.size(); ++i) { time_of_day& tod = tods_[i]; const int r = tod_red_field_->get_value(); const int g = tod_green_field_->get_value(); const int b = tod_blue_field_->get_value(); if(tod.color.r == r && tod.color.g == g && tod.color.b == b) { current_tod_ = i; update_selected_tod_info(window); return; } } update_selected_tod_info(window); }
void custom_tod::do_new_tod(window& window) { tods_.insert(tods_.begin() + current_tod_, time_of_day()); update_selected_tod_info(window); }
void custom_tod::do_prev_tod(window& window) { current_tod_ = (current_tod_ ? current_tod_ : tods_.size()) - 1; update_selected_tod_info(window); }
void custom_tod::do_next_tod(window& window) { current_tod_ = (current_tod_ + 1) % times_.size(); update_selected_tod_info(window); }
void teditor_settings::pre_show(CVideo& /*video*/, twindow& window) { assert(!tods_.empty()); current_tod_label_ = find_widget<tlabel>( &window, "current_tod", false, true); current_tod_image_ = find_widget<tlabel>( &window, "current_tod_image", false, true); custom_tod_toggle_ = find_widget<ttoggle_button>( &window, "custom_tod_toggle", false, true); custom_tod_auto_refresh_ = find_widget<ttoggle_button>( &window, "custom_tod_auto_refresh", false, true); tbutton& next_tod_button = find_widget<tbutton>( &window, "next_tod", false); connect_signal_mouse_left_click(next_tod_button, boost::bind( &teditor_settings::do_next_tod , this , boost::ref(window))); tbutton& apply_button = find_widget<tbutton>( &window, "apply", false); connect_signal_mouse_left_click(apply_button, boost::bind( &teditor_settings::update_tod_display , this , boost::ref(window))); custom_tod_toggle_->set_callback_state_change( dialog_callback<teditor_settings , &teditor_settings::update_selected_tod_info>); connect_signal_notify_modified(*(custom_tod_red_field_->widget()) , boost::bind( &teditor_settings::slider_update_callback , this , boost::ref(window))); connect_signal_notify_modified(*(custom_tod_green_field_->widget()) , boost::bind( &teditor_settings::slider_update_callback , this , boost::ref(window))); connect_signal_notify_modified(*(custom_tod_blue_field_->widget()) , boost::bind( &teditor_settings::slider_update_callback , this , boost::ref(window))); for (size_t i = 0; i < tods_.size(); ++i) { time_of_day& tod = tods_[i]; const int r = custom_tod_red_field_->get_widget_value(window); const int g = custom_tod_green_field_->get_widget_value(window); const int b = custom_tod_blue_field_->get_widget_value(window); if (tod.color.r == r && tod.color.g == g && tod.color.b == b) { current_tod_ = i; custom_tod_toggle_->set_value(false); update_selected_tod_info(window); can_update_display_ = true; return; } } /* custom tod */ custom_tod_toggle_->set_value(true); update_selected_tod_info(window); can_update_display_ = true; }