void tmp_cmd_wrapper::pre_show(CVideo& /*video*/, twindow& window)
{
	ttext_box* message =
		dynamic_cast<ttext_box*>(window.find("message", false));
	if(message) {
		/**
		 * @todo For some reason the text wrapping fails on Windows and Mac,
		 * this causes an exception to be thrown, which brings the user back
		 * to the main menu. So avoid that problem by imposing a maximum
		 * length (the number of letters W that fit).
		 */
#if defined(_WIN32) || defined(__APPLE__)
		message->set_maximum_length(18);
#endif
		window.keyboard_capture(message);
	}

	message = dynamic_cast<ttext_box*>(window.find("reason", false));
	if(message) message->set_active(preferences::is_authenticated());

	message = dynamic_cast<ttext_box*>(window.find("time", false));
	if(message) message->set_active(preferences::is_authenticated());

	tlabel* label =
		dynamic_cast<tlabel*>(window.find("user_label", false));
	if(label) label->set_label(user_);


	tbutton* b = dynamic_cast<tbutton*>(window.find("add_friend", false));
	if(b) b->set_retval(1);

	b = dynamic_cast<tbutton*>(window.find("add_ignore", false));
	if(b) b->set_retval(2);

	b = dynamic_cast<tbutton*>(window.find("remove", false));
	if(b) b->set_retval(3);

	b = dynamic_cast<tbutton*>(window.find("status", false));
	if(b) {
		b->set_retval(4);
		b->set_active(preferences::is_authenticated());
	}

	b = dynamic_cast<tbutton*>(window.find("kick", false));
	if(b) {
		b->set_retval(5);
		b->set_active(preferences::is_authenticated());
	}

	b = dynamic_cast<tbutton*>(window.find("ban", false));
	if(b) {
		b->set_retval(6);
		b->set_active(preferences::is_authenticated());
	}

}
void tmp_cmd_wrapper::post_show(twindow& window)
{
	ttext_box* message =
		dynamic_cast<ttext_box*>(window.find("message", false));
	message_ = message ? message_ = message->get_value() : "";

	ttext_box* reason =
		dynamic_cast<ttext_box*>(window.find("reason", false));
	reason_ = reason ? reason_ = reason->get_value() : "";

	ttext_box* time =
		dynamic_cast<ttext_box*>(window.find("time", false));
	time_ = time ? time_ = time->get_value() : "";

}
Beispiel #3
0
	/** Overridden from tfield_. */
	void finalize_specialized(twindow& window)
	{
		ttext_box* widget = dynamic_cast<ttext_box*>(window.find(id(), false));

		if(widget) {
			widget->save_to_history();
		}
	}
Beispiel #4
0
	/** Overridden from tfield_. */
	void init_specialized(twindow& window)
	{
		if(callback_change_) {
			tselectable_* widget =
				dynamic_cast<tselectable_*>(window.find(id(), false));

			if(widget) {
				widget->set_callback_state_change(callback_change_);
			}
		}
	}
Beispiel #5
0
void tdialog::init_fields(twindow& window)
{
	for(auto field : fields_)
	{
		field->attach_to_window(window);
		field->widget_init(window);
	}

	if(!focus_.empty()) {
		if(twidget* widget = window.find(focus_, false)) {
			window.keyboard_capture(widget);
		}
	}
}
void tlobby_player_info::pre_show(CVideo& /*video*/, twindow& window)
{
	relation_ = find_widget<tlabel>(&window, "relation_info", false, true);
	GUI2_EASY_BUTTON_CALLBACK(start_whisper, tlobby_player_info);

	GUI2_EASY_BUTTON_CALLBACK(add_to_friends, tlobby_player_info);
	GUI2_EASY_BUTTON_CALLBACK(add_to_ignores, tlobby_player_info);
	GUI2_EASY_BUTTON_CALLBACK(remove_from_list, tlobby_player_info);
	add_to_friends_ = add_to_friends_btn;
	add_to_ignores_ = add_to_ignores_btn;
	remove_from_list_ = remove_from_list_btn;

	GUI2_EASY_BUTTON_CALLBACK(check_status, tlobby_player_info);
	GUI2_EASY_BUTTON_CALLBACK(kick, tlobby_player_info);
	GUI2_EASY_BUTTON_CALLBACK(kick_ban, tlobby_player_info);

	find_widget<tlabel>(&window, "player_name", false)
			.set_label(info_.name);

	std::stringstream loc;
	const game_info* game = lobby_info_.get_game_by_id(info_.game_id);
	if (game != NULL) {
		loc << _("In game:") << " " << game->name << " ";
		if (info_.observing) {
			loc << _("(observing)");
		} else {
			loc << _("(playing)");
		}
	} else {
		loc << _("In lobby");
	}

	find_widget<tlabel>(&window, "location_info", false).set_label(loc.str());

	update_relation(window);

	if (!preferences::is_authenticated()) {
		twidget* aw = window.find("admin", false);
		aw->set_visible(twidget::INVISIBLE);
	}
}
Beispiel #7
0
	/**
	 * Enables a widget.
	 *
	 * @param window              The window containing the widget.
	 * @param enable              If true enables the widget, disables
	 *                            otherwise.
	 * @param sync                If the state is changed do we need to
	 *                            synchronize. Upon disabling, write the value
	 *                            of the widget in the variable value_. Upon
	 *                            enabling write the value of value_ in the
	 *                            widget.
	 */
	void widget_set_enabled(twindow& window, const bool enable, const bool sync)
	{
		tcontrol* widget = dynamic_cast<tcontrol*>(window.find(id(), false));

		if(!widget) {
			return;
		}

		const bool widget_state = widget->get_active();
		if(widget_state == enable) {
			return;
		}

		if(sync) {
			if(enable) {
				widget_restore(window);
			} else {
				widget_save(window);
			}
		}

		widget->set_active(enable);
	}
Beispiel #8
0
void tlobby_player_info::pre_show(twindow& window)
{
	relation_ = find_widget<tlabel>(&window, "relation_info", false, true);
	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "start_whisper", false),
			std::bind(&tlobby_player_info::start_whisper_button_callback,
						this,
						std::ref(window)));

	add_to_friends_ = &find_widget<tbutton>(&window, "add_to_friends", false);
	connect_signal_mouse_left_click(
			*add_to_friends_,
			std::bind(&tlobby_player_info::add_to_friends_button_callback,
						this,
						std::ref(window)));

	add_to_ignores_ = &find_widget<tbutton>(&window, "add_to_ignores", false);
	connect_signal_mouse_left_click(
			*add_to_ignores_,
			std::bind(&tlobby_player_info::add_to_ignores_button_callback,
						this,
						std::ref(window)));

	remove_from_list_
			= &find_widget<tbutton>(&window, "remove_from_list", false);
	connect_signal_mouse_left_click(
			*remove_from_list_,
			std::bind(&tlobby_player_info::remove_from_list_button_callback,
						this,
						std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "check_status", false),
			std::bind(&tlobby_player_info::check_status_button_callback,
						this,
						std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "kick", false),
			std::bind(&tlobby_player_info::kick_button_callback,
						this,
						std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "kick_ban", false),
			std::bind(&tlobby_player_info::kick_ban_button_callback,
						this,
						std::ref(window)));

	find_widget<tlabel>(&window, "player_name", false).set_label(info_.name);

	std::stringstream loc;
	const game_info* game = lobby_info_.get_game_by_id(info_.game_id);
	if(game != nullptr) {
		loc << _("In game:") << " " << game->name << " ";
		if(info_.observing) {
			loc << _("(observing)");
		} else {
			loc << _("(playing)");
		}
	} else {
		loc << _("In lobby");
	}

	find_widget<tlabel>(&window, "location_info", false).set_label(loc.str());

	update_relation(window);

	if(!preferences::is_authenticated()) {
		twidget* aw = window.find("admin", false);
		aw->set_visible(twidget::tvisible::invisible);
	}
}