本文整理汇总了C++中window::set_retval方法的典型用法代码示例。如果您正苦于以下问题:C++ window::set_retval方法的具体用法?C++ window::set_retval怎么用?C++ window::set_retval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类window
的用法示例。
在下文中一共展示了window::set_retval方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: network_handler
void mp_staging::network_handler(window& window)
{
// First, send off any changes if they've been accumulated
if(state_changed_) {
connect_engine_.update_and_send_diff();
}
// Next, check for any incoming changes
config data;
if(!state_changed_ && (!network_connection_ || !network_connection_->receive_data(data))) {
return;
}
// Update chat
find_widget<chatbox>(&window, "chat", false).process_network_data(data);
// TODO: why is this needed...
const bool was_able_to_start = connect_engine_.can_start_game();
bool quit_signal_received;
std::tie(quit_signal_received, std::ignore) = connect_engine_.process_network_data(data);
if(quit_signal_received) {
window.set_retval(retval::CANCEL);
}
// Update side leader displays
// This is basically only needed when a new player joins and selects their faction
for(auto& tree_entry : side_tree_map_) {
ng::side_engine_ptr side = tree_entry.first;
grid& row_grid = tree_entry.second->get_grid();
update_leader_display(side, row_grid);
std::vector<config> controller_names;
for(const auto& controller : side->controller_options()) {
controller_names.emplace_back("label", controller.second);
}
menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
controller_selection.set_values(controller_names, side->current_controller_index());
controller_selection.set_active(controller_names.size() > 1);
}
// Update player list
if(data.has_child("user")) {
player_list_->update_list(data.child_range("user"));
}
// Update status label and buttons
update_status_label_and_buttons(window);
if(!was_able_to_start && connect_engine_.can_start_game()) {
mp_ui_alerts::ready_for_start();
}
state_changed_ = false;
}
示例2: dismiss_unit
void unit_recall::dismiss_unit(window& window)
{
LOG_DP << "Recall list units:\n"; dump_recall_list_to_console(recall_list_);
listbox& list = find_widget<listbox>(&window, "recall_list", false);
const int index = list.get_selected_row();
const unit& u = *recall_list_[index].get();
// If the unit is of level > 1, or is close to advancing, we warn the player about it
std::stringstream message;
if(u.loyal()) {
message << _("This unit is loyal and requires no upkeep.") << " " << (u.gender() == unit_race::MALE
? _("Do you really want to dismiss him?")
: _("Do you really want to dismiss her?"));
} else if(u.level() > 1) {
message << _("This unit is an experienced one, having advanced levels.") << " " << (u.gender() == unit_race::MALE
? _("Do you really want to dismiss him?")
: _("Do you really want to dismiss her?"));
} else if(u.experience() > u.max_experience()/2) {
message << _("This unit is close to advancing a level.") << " " << (u.gender() == unit_race::MALE
? _("Do you really want to dismiss him?")
: _("Do you really want to dismiss her?"));
}
if(!message.str().empty()) {
const int res = gui2::show_message(_("Dismiss Unit"), message.str(), message::yes_no_buttons);
if(res != gui2::retval::OK) {
return;
}
}
recall_list_.erase(recall_list_.begin() + index);
// Remove the entry from the dialog list
list.remove_row(index);
list_item_clicked(window);
// Remove the entry from the filter list
filter_options_.erase(filter_options_.begin() + index);
assert(filter_options_.size() == list.get_item_count());
LOG_DP << "Dismissing a unit, side = " << u.side() << ", id = '" << u.id() << "'\n";
LOG_DP << "That side's recall list:\n";
dump_recall_list_to_console(team_.recall_list());
// Find the unit in the recall list.
unit_ptr dismissed_unit = team_.recall_list().find_if_matches_id(u.id());
assert(dismissed_unit);
// Record the dismissal, then delete the unit.
synced_context::run_and_throw("disband", replay_helper::get_disband(dismissed_unit->id()));
// Close the dialog if all units are dismissed
if(list.get_item_count() == 0) {
window.set_retval(retval::CANCEL);
}
}
示例3: callback_stepout_button
void formula_debugger::callback_stepout_button(window& window)
{
fdb_.add_breakpoint_step_out();
window.set_retval(retval::OK);
}
示例4: join_global_button_callback
void lobby_main::join_global_button_callback(window& window)
{
if(do_game_join(gamelistbox_->get_selected_row(), false)) {
window.set_retval(JOIN);
}
}
示例5: observe_global_button_callback
void lobby_main::observe_global_button_callback(window& window)
{
if(do_game_join(gamelistbox_->get_selected_row(), true)) {
window.set_retval(OBSERVE);
}
}
示例6: pre_show
void lobby_main::pre_show(window& window)
{
SCOPE_LB;
gamelistbox_ = find_widget<listbox>(&window, "game_list", false, true);
#ifdef GUI2_EXPERIMENTAL_LISTBOX
connect_signal_notify_modified(
*gamelistbox_,
std::bind(&lobby_main::gamelist_change_callback, *this, std::ref(window)));
#else
gamelistbox_->set_callback_value_change(
dialog_callback<lobby_main, &lobby_main::gamelist_change_callback>);
#endif
window.keyboard_capture(gamelistbox_);
player_list_.init(window);
player_list_.sort_by_name->set_value(preferences::playerlist_sort_name());
player_list_.sort_by_relation->set_value(preferences::playerlist_sort_relation());
player_list_.update_sort_icons();
player_list_.sort_by_name->set_callback_state_change(
std::bind(&lobby_main::player_filter_callback, this, _1));
player_list_.sort_by_relation->set_callback_state_change(
std::bind(&lobby_main::player_filter_callback, this, _1));
window.set_enter_disabled(true);
window.set_escape_disabled(true);
// A new key handler to deal with escape in a different manner.
window.connect_signal<event::SDL_KEY_DOWN>(
std::bind(&lobby_main::signal_handler_key_down, this, _5, _3, _4),
event::dispatcher::front_pre_child);
window_ = &window;
chatbox_ = find_widget<chatbox>(&window, "chat", false, true);
chatbox_->set_lobby_info(lobby_info_);
chatbox_->set_wesnothd_connection(wesnothd_connection_);
chatbox_->set_active_window_changed_callback([this]() { player_list_dirty_ = true; });
find_widget<button>(&window, "create", false).set_retval(CREATE);
connect_signal_mouse_left_click(
find_widget<button>(&window, "refresh", false),
std::bind(&lobby_main::refresh_button_callback, this, std::ref(window)));
connect_signal_mouse_left_click(
find_widget<button>(&window, "show_preferences", false),
std::bind(&lobby_main::show_preferences_button_callback, this, std::ref(window)));
connect_signal_mouse_left_click(
find_widget<button>(&window, "join_global", false),
std::bind(&lobby_main::join_global_button_callback, this, std::ref(window)));
find_widget<button>(&window, "join_global", false).set_active(false);
connect_signal_mouse_left_click(
find_widget<button>(&window, "observe_global", false),
std::bind(&lobby_main::observe_global_button_callback, this, std::ref(window)));
find_widget<button>(&window, "observe_global", false).set_active(false);
menu_button& replay_options = find_widget<menu_button>(&window, "replay_options", false);
if(preferences::skip_mp_replay()) {
replay_options.set_selected(1);
}
if(preferences::blindfold_replay()) {
replay_options.set_selected(2);
}
replay_options.connect_click_handler(
std::bind(&lobby_main::skip_replay_changed_callback, this, std::ref(window)));
filter_friends_ = find_widget<toggle_button>(&window, "filter_with_friends", false, true);
filter_ignored_ = find_widget<toggle_button>(&window, "filter_without_ignored", false, true);
filter_slots_ = find_widget<toggle_button>(&window, "filter_vacant_slots", false, true);
filter_invert_ = find_widget<toggle_button>(&window, "filter_invert", false, true);
filter_text_ = find_widget<text_box>(&window, "filter_text", false, true);
filter_friends_->set_callback_state_change(
std::bind(&lobby_main::game_filter_change_callback, this, _1));
filter_ignored_->set_callback_state_change(
std::bind(&lobby_main::game_filter_change_callback, this, _1));
filter_slots_->set_callback_state_change(
std::bind(&lobby_main::game_filter_change_callback, this, _1));
filter_invert_->set_callback_state_change(
std::bind(&lobby_main::game_filter_change_callback, this, _1));
connect_signal_pre_key_press(
*filter_text_,
std::bind(&lobby_main::game_filter_keypress_callback, this, _5));
chatbox_->room_window_open("lobby", true, false);
chatbox_->active_window_changed();
game_filter_reload();
// Force first update to be directly.
//.........这里部分代码省略.........