示例#1
0
/*
 * Examine a grid, return a keypress.
 *
 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
 * indicates that the "space" key should scan through the contents
 * of the grid, instead of simply returning immediately.  This lets
 * the "look" command get complete information, without making the
 * "target" command annoying.
 *
 * The "info" argument contains the "commands" which should be shown
 * inside the "[xxx]" text.  This string must never be empty, or grids
 * containing monsters will be displayed with an extra comma.
 *
 * Note that if a monster is in the grid, we update both the monster
 * recall info and the health bar info to track that monster.
 *
 * This function correctly handles multiple objects per grid, and objects
 * and terrain features in the same grid, though the latter never happens.
 *
 * This function must handle blindness/hallucination.
 */
static ui_event_data target_set_interactive_aux(int y, int x, int mode, cptr info, bool list_floor_objects)
{
	s16b this_o_idx, next_o_idx = 0;
	s16b this_x_idx, next_x_idx = 0;

	cptr s1, s2, s3;

	bool floored;

	u16b feat;

	ui_event_data query;

	char out_val[256];

	char coords[20];

	/* Describe the square location */
	coords_desc(coords, sizeof(coords), y, x);

	/* Repeat forever */
	while (1)
	{
		int i;

		char feat_name[80];
		/* Terrain suffix for monsters and objects */
		char terrain_suffix[200];

		/* Temporary array of visible effects */
		s16b x_seen[50];
		u16b size_x_seen = 0;

		/* Paranoia */
		query.key = ' ';

		/* Default */
		s1 = "You see ";
		s2 = "";
		s3 = "on ";


		/* The player */
		if (cave_m_idx[y][x] < 0)
		{
			/* Description */
			s1 = "You are ";

			/* Preposition */
			s2 = "on ";
		}

		/* Feature (apply "mimic") */
		feat = f_info[cave_feat[y][x]].f_mimic;

		/* Require knowledge about grid, or ability to see grid */
		if (!(cave_info[y][x] & (CAVE_MARK)) && !player_can_see_bold(y,x))
		{
			/* Forget feature */
			feat = FEAT_NONE;
		}

		else
		{
			/* Hack -- track the current feature */
			feature_kind_track(feat);

			/* Window stuff */
			p_ptr->redraw |= (PR_FEATURE);
		}

		/* Pick a prefix */
		if (*s2 && (!feat_ff1_match(feat, FF1_MOVE) ||
			!feat_ff1_match(feat, FF1_LOS) ||
			feat_ff1_match(feat, FF1_SHOP | FF1_DOOR) ||
			feat_ff2_match(feat, FF2_SHALLOW | FF2_DEEP) ||
			feat_ff3_match(feat, FF3_NEED_TREE)))
		{
			s3 = "in ";
		}

		/* Get a default name */
		if (feat <= FEAT_NONE)
		{
			my_strcpy(feat_name, "an unknown grid", sizeof(feat_name));
		}
		/* Get the real name */
		else
		{
			feature_desc(feat_name, sizeof (feat_name), feat, TRUE, FALSE);
		}

		/* List all effects in the grid */
		for (this_x_idx = cave_x_idx[y][x]; this_x_idx; this_x_idx = next_x_idx)
		{
			effect_type *x_ptr;

			/* Get the effect */
			x_ptr = &x_list[this_x_idx];

			/* Get the next effect */
			next_x_idx = x_ptr->next_x_idx;

			/* Describe it, if not hidden */
			if (!(x_ptr->x_flags & (EF1_HIDDEN)) && x_ptr->x_f_idx)
			{
				/* Check for available space */
				if (size_x_seen < N_ELEMENTS(x_seen))
				{
					x_seen[size_x_seen++] = x_ptr->x_f_idx;
				}
			}
		}

		/* Prepare the terrain suffix for monsters and objects */
		my_strcpy(terrain_suffix, format(" %s%s", s3, feat_name), sizeof(terrain_suffix));

		/* Concat the collected effect names */
		for (i = 0; i < size_x_seen; i++)
		{
			char x_name[80];

			/* Obtain an object description */
			feature_desc(x_name, sizeof(x_name), x_seen[i], TRUE, TRUE);

			/* First effect */
			if (i == 0)
			{
				if ((feat == FEAT_NONE) || !feat_ff1_match(feat, FF1_MOVE) ||
					cave_any_trap_bold(y, x))
				{
					/* Basic info */
					my_strcat(terrain_suffix, format(" with %s", x_name),
						sizeof(terrain_suffix));
				}
				else
				{
					/* Basic info */
					my_strcat(terrain_suffix, format(" beneath %s", x_name),
						sizeof(terrain_suffix));
				}
			}

			/* Basic info */
			else if (i < (size_x_seen - 1))
			{
				my_strcat(terrain_suffix, format(", %s", x_name), sizeof(terrain_suffix));
			}

			/* Basic info */
			else
			{
				my_strcat(terrain_suffix, format(" and %s", x_name), sizeof(terrain_suffix));
			}
		}

		/* Ignore the terrain suffix if certain things happen */
		if ((size_x_seen == 0) && (feat <= FEAT_FLOOR))
		{
			terrain_suffix[0] = '\0';
		}

		/* Hack -- hallucination */
		if (p_ptr->timed[TMD_IMAGE])
		{
			cptr name = "something strange";

			/* Display a message */
			if (p_ptr->wizard)
			{
				strnfmt(out_val, sizeof(out_val),
						"%s%s%s, [%s] %s (%d:%d).", s1, s2, name, info, coords, y, x);
			}
			else
			{
				strnfmt(out_val, sizeof(out_val),
						"%s%s%s [%s], %s.", s1, s2, name, info, coords);
			}

			prt(out_val, 0, 0);
			move_cursor_relative(y, x);

			query = inkey_ex();

			/* Stop on everything but "return" */
			if ((query.key != '\n') && (query.key != '\r')) break;

			/* Repeat forever */
			continue;
		}

		/* Actual monsters */
		if (cave_m_idx[y][x] > 0)
		{
			monster_type *m_ptr = &mon_list[cave_m_idx[y][x]];
			monster_race *r_ptr = &r_info[m_ptr->r_idx];

			/* Visible */
			if (m_ptr->ml)
			{
				bool recall = FALSE;

				char m_name[80];

				if (m_ptr->mimic_k_idx)
				{
					/*get the description*/
					mimic_desc_object(m_name, sizeof(m_name), m_ptr->mimic_k_idx);
				}

				else
				{
					/* Get the monster name ("a kobold") */
					monster_desc(m_name, sizeof(m_name), m_ptr, 0x08);

					/* Hack -- track this monster race */
					monster_race_track(m_ptr->r_idx);

					/* Hack -- health bar for this monster */
					health_track(cave_m_idx[y][x]);

					/*Track the feature*/
					feature_kind_track(cave_feat[y][x]);

					/* Window stuff */
					p_ptr->redraw |= (PR_FEATURE);

					/* Hack -- handle stuff */
					handle_stuff();
				}

				/* Interact */
				while (1)
				{
					if (recall)	button_add("[CLEAR_RECALL]", 'r');
					else 		button_add("[RECALL]", 'r');
					if (cave_o_idx[y][x] > 0)button_add("[VIEW_FLOOR]", 'f');
					event_signal(EVENT_MOUSEBUTTONS);

					/* Recall, but not mimics */
					if ((recall) && (!(m_ptr->mimic_k_idx)))
					{
						/* Save screen */
						screen_save();

						/* Recall on screen */
						screen_roff(m_ptr->r_idx);

						/* Hack -- Complete the prompt (again) */
						Term_addstr(-1, TERM_WHITE, format(" [r,%s]", info));

						/* Command */
						query = inkey_ex();

						/* Load screen */
						screen_load();
					}

					/* Normal */
					else
					{

						/* Basic info */
						strnfmt(out_val, sizeof(out_val),
							"%s%s%s", s1, s2, m_name);

						/* Describe the monster, unless a mimic */
						if (!(m_ptr->mimic_k_idx))
						{
							char buf[80];

							look_mon_desc(buf, sizeof(buf), cave_m_idx[y][x]);

							/* Monster state, terrain suffix, options  */
							my_strcat(out_val, format(" (%s)%s [r,%s]",
								buf, terrain_suffix, info),
								sizeof(out_val));
						}

						/* Mimics */
						else
						{
							/* Terrain suffix, options */
							my_strcat(out_val,
								format("%s [I,%s]", terrain_suffix,
								info), sizeof(out_val));
						}

						/* Wizards want coordinates */
						if (p_ptr->wizard)
						{
							my_strcat(out_val, format(" (%d:%d)", y, x),
								sizeof(out_val));
						}

						prt(out_val, 0, 0);

						/* Place cursor */
						move_cursor_relative(y, x);

						/* Command */
						query = inkey_ex();
					}

					button_kill('r');
					button_kill('f');
					event_signal(EVENT_MOUSEBUTTONS);

					/* Handle fake object recall */
					if (m_ptr->mimic_k_idx)
					{
						object_type body;
						object_type *o_ptr = &body;

						/* Validate input first */
						if (query.key != 'I') break;

						/* Paranoia */
						object_wipe(o_ptr);

						/* Prepare */
						object_prep(o_ptr, m_ptr->mimic_k_idx);

						/* Fake history */
						object_history(o_ptr, ORIGIN_FLOOR, 0);

						/* Clear prompt. Place cursor */
						prt("", 0, 0);

						/* Show the fake info - EXPERIMENTAL */
						object_info_screen(o_ptr);
					}
					/* Regular monsters */
					else
					{
						/* Normal commands */
						if (query.key != 'r') break;

						/* Toggle recall */
						recall = !recall;
					}
				}

				/* Stop on everything but "return"/"space", or floor */
				if ((query.key != '\n') && (query.key != '\r') &&
					(query.key != ' ') && (query.key != 'f')) break;

				/* continue with 'f' only if there are floor items....*/
				if ((query.key == 'f') && (!cave_o_idx[y][x])) break;

				/* Sometimes stop at "space" key */
				if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break;

				/* Change the intro */
				s1 = "It is ";

				/* Hack -- take account of gender */
				if (r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
				else if (r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";

				/* Use a preposition */
				s2 = "carrying ";

				/* Scan all objects being carried */
				for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
				{
					char o_name[80];

					object_type *o_ptr;

					/* Get the object */
					o_ptr = &o_list[this_o_idx];

					/* Get the next object */
					next_o_idx = o_ptr->next_o_idx;

					/*Don't let the player see certain objects (used for vault treasure)*/
					if ((o_ptr->ident & (IDENT_HIDE_CARRY)) && (!p_ptr->wizard) &&
						(!cheat_peek))	 continue;

					/* Obtain an object description */
					object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL);

					/* Describe the object */
					strnfmt(out_val, sizeof(out_val),
						"%s%s%s [%s]", s1, s2, o_name, info);

					/* Wizards want coordinates */
					if (p_ptr->wizard)
					{
						my_strcat(out_val, format(" (%d:%d)", y, x), sizeof(out_val));
					}

					prt(out_val, 0, 0);
					move_cursor_relative(y, x);
					query = inkey_ex();

					/* Stop on everything but "return"/"space" */
					if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break;

					/* Sometimes stop at "space" key */
					if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break;

					/* Change the intro */
					s2 = "also carrying ";
				}

				/* Double break */
				if (this_o_idx) break;

				/* Use a preposition */
				s2 = "on ";
			}
		}

		/* Assume not floored */
		floored = FALSE;

		/* Scan all objects in the grid */
		if (TRUE)
		{
			int floor_list[MAX_FLOOR_STACK];
			int floor_num;

			track_object(-floor_list[0]);
			handle_stuff();

			/* Scan for floor objects */
			floor_num = scan_floor(floor_list, MAX_FLOOR_STACK, y, x, 0x02);

			/* Actual pile */
			if (floor_num > 1)
			{
				/* Floored */
				floored = TRUE;

				/* Describe */
				while (1)
				{
					/* Basic info */
					strnfmt(out_val, sizeof(out_val),
						"%s%sa pile of %d objects%s [r,%s]", s1, s2,
						floor_num, terrain_suffix, info);

					/* Wizards want coordinates */
					if (p_ptr->wizard)
					{
						my_strcat(out_val, format(" (%d:%d)", y, x), sizeof(out_val));
					}

					prt(out_val, 0, 0);

					if (list_floor_objects)
					{
						/* Save screen */
						screen_save();

						/* Display */
						show_floor(floor_list, floor_num, (OLIST_WEIGHT | OLIST_GOLD));
					}
					move_cursor_relative(y, x);
					query = inkey_ex();

					if (list_floor_objects)
					{
						screen_load();
					}

					/* Display objects */
					if (query.key == 'r')
					{
						int pos;

						pos = query.key - 'a';
						if (0 <= pos && pos < floor_num)
						{
							track_object(-floor_list[pos]);
							handle_stuff();
						}
					}

					/* Done */
					break;
				}

				/* Stop on everything but "return"/"space" */
				if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break;

				/* Sometimes stop at "space" key */
				if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break;

				/* Change the intro */
				s1 = "It is ";

				/* Preposition */
				s2 = "on ";
			}
		}

		/* Scan all objects in the grid */
		for (this_o_idx = cave_o_idx[y][x]; this_o_idx; this_o_idx = next_o_idx)
		{
			object_type *o_ptr;

			/* Get the object */
			o_ptr = &o_list[this_o_idx];

			/* Get the next object */
			next_o_idx = o_ptr->next_o_idx;

			/* Skip objects if floored */
			if (floored) continue;

			/* Describe it */
			if (o_ptr->marked)
			{
				char o_name[80];

				/* Obtain an object description */
				object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL);

				/* Basic info */
				strnfmt(out_val, sizeof(out_val), "%s%s%s%s [I,%s]",
					s1, s2, o_name, terrain_suffix, info);

				/* Wizards want coordinates */
				if (p_ptr->wizard)
				{
					my_strcat(out_val, format(" (%d:%d)", y, x),
						sizeof(out_val));
				}

				/* Show object. Handle object recall */
				while (TRUE)
				{
					/* Print the prompt */
					prt(out_val, 0, 0);

					/* Move cursor to that location */
					move_cursor_relative(y, x);

					/* Read input key */
					query = inkey_ex();

					/* No object recall */
					if (query.key != 'I') break;

					/* Object recall. Clear the first line */
					prt("", 0, 0);

					/* Do it */
					object_info_screen(o_ptr);
				}

				/* Stop on everything but "return"/"space" */
				if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break;

				/* Sometimes stop at "space" key */
				if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break;

				/* Change the intro */
				s1 = "It is ";

				/* Plurals */
				if (o_ptr->number != 1) s1 = "They are ";

				/* Preposition */
				s2 = "on ";
			}
		}

		/* Double break */
		if (this_o_idx) break;

		/* Display terrain */
		if (TRUE)
		{
			u16b temp_feat;
			bool enable_recall;
			bool show_recall = FALSE;
			char temp_name[80];

			/*
			 * Display terrain and effects
			 */
			for (i = 0; i <= size_x_seen; i++)
			{
				/* Hack - This is the mark for the feature stored in cave_feat */
				if (i == size_x_seen)
				{
				       	temp_feat = feat;

					/* Just copy the feature name */
					my_strcpy(temp_name, feat_name, sizeof(temp_name));
				}
				/* Any other value is an effect stored x_list */
				else
				{
					temp_feat = x_seen[i];

					/* Get the effect's name */
					feature_desc(temp_name, sizeof(temp_name), temp_feat, TRUE, TRUE);
				}

				/* Don't display feature recall if the grid is unknown */
				enable_recall = (temp_feat != FEAT_NONE);

				/* Handle recall */
				while (TRUE)
				{

					/* Handle recall mode */
					if (show_recall && enable_recall)
					{
						/* Save screen */
						screen_save();

						/* Recall feature on screen */
						screen_feature_roff(temp_feat);
					}

					/* Display a message */
					strnfmt(out_val, sizeof(out_val),
						"%s%s%s [%s%s]%s", s1, s2, temp_name,
						(enable_recall ? "r,": ""), info,
						(i < size_x_seen) ? " (more)": "");

					/* Wizards want coordinates */
					if (p_ptr->wizard)
					{
						my_strcat(out_val, format(" (%d:%d)", y, x), sizeof(out_val));
					}

					/*Track this feature*/
					feature_kind_track(temp_feat);

					/* Hack -- handle stuff */
					handle_stuff();

					prt(out_val, 0, 0);
					move_cursor_relative(y, x);
					query = inkey_ex();

					/* Load screen if necessary */
					if (show_recall && enable_recall)
					{
						screen_load();
					}

					/* Stop on everything but the recall command, if enabled */
					if (!enable_recall || (query.key != 'r')) break;

					/* Toggle recall */
					show_recall = !show_recall;
				}

				/* Stop on everything but "return"/"space" */
				if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break;
			}
		}

		/* Hack -- handle stuff */
		handle_stuff();

		/* Stop on everything but "return" */
		if ((query.key != '\n') && (query.key != '\r')) break;
	}

	/* Keep going */
	return (query);
}
示例#2
0
GridDialog::GridDialog(int _y, int _x): NPPDialog()
{
    y = _y;
    x = _x;
    dungeon_type *d_ptr = &dungeon_info[y][x];

    int n = 0;

    bool drugged = (p_ptr->timed[TMD_IMAGE] > 0);

    central = new QWidget;
    QPointer<QVBoxLayout> lay1 = new QVBoxLayout;
    central->setLayout(lay1);
    this->setClient(central);   // Do this after setting layout

    QPointer<QWidget> area2 = new QWidget;
    lay1->addWidget(area2);
    QPointer<QGridLayout> lay2 = new QGridLayout;
    lay2->setContentsMargins(0, 0, 0, 0);
    area2->setLayout(lay2);

    lay2->setColumnStretch(3, 1);

    QFont font = ui_main_window_font();

    int col = 0;
    int row = 0;
    int m_idx = d_ptr->monster_idx;
    if (m_idx > 0 && mon_list[m_idx].ml && !drugged)
    {
        ++n;

        monster_type *m_ptr = mon_list + m_idx;
        monster_race *r_ptr = r_info + m_ptr->r_idx;

        QPointer<QLabel> lb = new QLabel(QString(" %1 ").arg(r_ptr->d_char));
        lb->setStyleSheet(QString("background-color: black; color: %1;").arg(r_ptr->d_color.name()));
        lb->setFont(font);
        lay2->addWidget(lb, row, col++);

        QPixmap pix = ui_get_tile(r_ptr->tile_id, TRUE);
        QPointer<QLabel> lb2 = new QLabel;
        lb2->setPixmap(pix);
        lay2->addWidget(lb2, row, col++);

        int gain_m = calc_energy_gain(m_ptr->m_speed);
        int gain_p = calc_energy_gain(p_ptr->state.p_speed);
        QString msg = monster_desc(m_ptr, 0x08);
        if (p_ptr->is_wizard)
        {
            msg.append(QString(" - HP: %4 - Energy: %2 - Player energy: %3")
                        .arg(gain_m).arg(gain_p).arg(m_ptr->hp));
        }
        msg = capitalize_first(msg);
        QPointer<QPushButton> btn1 = new QPushButton(msg);
        QString item_id = QString("m%1").arg(m_idx);
        btn1->setObjectName(item_id);
        btn1->setStyleSheet("text-align: left;");
        lay2->addWidget(btn1, row, col++);
        connect(btn1, SIGNAL(clicked()), this, SLOT(item_click()));

        monster_race_track(m_ptr->r_idx);

        ++row;
    }

    int o_idx = d_ptr->object_idx;

    bool tracked_item = FALSE;

    while (o_idx && !drugged)
    {
        object_type *o_ptr = o_list + o_idx;
        int cur_o_idx = o_idx;
        o_idx = o_ptr->next_o_idx;

        if (!o_ptr->marked) continue;

        if (!tracked_item)
        {
            track_object(-cur_o_idx);
            tracked_item = TRUE;
        }

        ++n;

        col = 0;

        object_kind *k_ptr = k_info + o_ptr->k_idx;

        QChar chr = k_ptr->get_char();
        QColor color = k_ptr->get_color();
        QString tile = k_ptr->get_tile_id();

        QPointer<QLabel> lb = new QLabel(QString(" %1 ").arg(chr));
        lb->setStyleSheet(QString("background-color: black; color: %1;").arg(color.name()));
        lb->setFont(font);
        lay2->addWidget(lb, row, col++);

        QPixmap pix = ui_get_tile(tile, TRUE);
        QPointer<QLabel> lb2 = new QLabel;
        lb2->setPixmap(pix);
        lay2->addWidget(lb2, row, col++);

        QString name = object_desc(o_ptr, ODESC_FULL | ODESC_PREFIX);
        name = capitalize_first(name);
        QPointer<QPushButton> btn1 = new QPushButton(name);
        QString item_id = QString("o%1").arg(cur_o_idx);
        btn1->setObjectName(item_id);
        btn1->setStyleSheet("text-align: left;");
        lay2->addWidget(btn1, row, col++);
        connect(btn1, SIGNAL(clicked()), this, SLOT(item_click()));

        ++row;
    }

    if (d_ptr->cave_info & (CAVE_MARK | CAVE_SEEN))
    {
        ++n;

        col = 0;

        int feat = d_ptr->feature_idx;
        feat = f_info[feat].f_mimic;
        feature_type *f_ptr = f_info + feat;

        QPointer<QLabel> lb = new QLabel(QString(" %1 ").arg(f_ptr->d_char));
        lb->setStyleSheet(QString("background-color: black; color: %1;").arg(f_ptr->d_color.name()));
        lb->setFont(font);
        lay2->addWidget(lb, row, col++);

        QPixmap pix = ui_get_tile(f_ptr->tile_id, TRUE);
        QPointer<QLabel> lb2 = new QLabel;
        lb2->setPixmap(pix);
        lay2->addWidget(lb2, row, col++);

        QString name = feature_desc(feat, true, false);
        name = capitalize_first(name);
        QPointer<QPushButton> btn1 = new QPushButton(name);
        QString item_id = QString("f%1").arg(feat);
        btn1->setObjectName(item_id);
        btn1->setStyleSheet("text-align: left;");
        lay2->addWidget(btn1, row, col++);
        connect(btn1, SIGNAL(clicked()), this, SLOT(item_click()));

        ++row;

        feature_kind_track(feat);
    }

    int x_idx = d_ptr->effect_idx;
    while (x_idx && (d_ptr->cave_info & (CAVE_MARK | CAVE_SEEN))) {
        effect_type *x_ptr = x_list + x_idx;
        x_idx = x_ptr->next_x_idx;

        if (x_ptr->x_flags & EF1_HIDDEN) continue;

        int feat = x_ptr->x_f_idx;
        if (!feat) continue;
        feat = f_info[feat].f_mimic;
        if (!feat) continue;
        feature_type *f_ptr = f_info + feat;

        col = 0;

        QPointer<QLabel> lb = new QLabel(QString(" %1 ").arg(f_ptr->d_char));
        lb->setStyleSheet(QString("background-color: black; color: %1;").arg(f_ptr->d_color.name()));
        lb->setFont(font);
        lay2->addWidget(lb, row, col++);

        QPixmap pix = ui_get_tile(f_ptr->tile_id, TRUE);
        QPointer<QLabel> lb2 = new QLabel;
        lb2->setPixmap(pix);
        lay2->addWidget(lb2, row, col++);

        QString name = feature_desc(feat, true, false);
        name = capitalize_first(name);
        QPointer<QPushButton> btn1 = new QPushButton(name);
        QString item_id = QString("f%1").arg(feat);
        btn1->setObjectName(item_id);
        btn1->setStyleSheet("text-align: left;");
        lay2->addWidget(btn1, row, col++);
        connect(btn1, SIGNAL(clicked()), this, SLOT(item_click()));

        ++n;
        ++row;
    }

    QSpacerItem *spacer = new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding);
    lay2->addItem(spacer, row, 0);
    ++row;

    QPointer<QWidget> area3 = new QWidget;
    lay1->addWidget(area3);
    QPointer<QHBoxLayout> lay3 = new QHBoxLayout;
    lay3->setContentsMargins(0, 0, 0, 0);
    area3->setLayout(lay3);

    QSpacerItem *spacer2 = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed);
    lay3->addItem(spacer2);

    QPointer<QPushButton> btn_close = new QPushButton("Ok");
    lay3->addWidget(btn_close);
    connect(btn_close, SIGNAL(clicked()), this, SLOT(reject()));

    this->clientSizeUpdated();

    handle_stuff();

    if (n > 0) {
        (this->findChildren<QPushButton *>().at(0))->setFocus();
        this->exec();
    }

    else message(tr("There is nothing to see here"));
}