void t_mage_guild_window::create_buttons( t_screen_point book_origin )
{
	t_button*     button;
	t_screen_rect rect;
	t_help_block const & detail_help = get_help_block( "mage_guild" );
	t_help_block const&	shared_help = get_help_block( "shared" );

	// create close button
	rect = m_book_bitmaps->find( "close_button" )->get_rect();
	button = new t_button( k_close_button.get(), rect.top_left() + book_origin, this );
	button->set_click_handler( bound_handler( *this, &t_mage_guild_window::close_click ));
	set_help( button, shared_help, "cancel" );

	// next and last spell buttons
	rect = m_book_bitmaps->find( "last_spell_button" )->get_rect();
	m_last_spell_button = new t_button( k_last_spell_button.get(), rect.top_left(), 
		                                m_detail_window );
	m_last_spell_button->set_click_handler( bound_handler( *this, 
											&t_mage_guild_window::last_spell_click ));
	rect = m_book_bitmaps->find( "next_spell_button" )->get_rect();
	m_next_spell_button = new t_button( k_next_spell_button.get(), rect.top_left(), 
		                                m_detail_window );
	m_next_spell_button->set_click_handler( bound_handler( *this, 
											&t_mage_guild_window::next_spell_click ));

	// next and last page buttons
	rect = m_book_bitmaps->find( "previous_page" )->get_rect();
	m_last_page_button = new t_button( k_last_spell_button.get(), rect.top_left(), 
		                                m_index_window );
	m_last_page_button->set_click_handler( bound_handler( *this, 
											&t_mage_guild_window::last_page_click ));
	m_last_page_button->set_visible( false );

	rect = m_book_bitmaps->find( "next_page" )->get_rect();
	m_next_page_button = new t_button( k_next_spell_button.get(), rect.top_left(), 
		                                m_index_window );
	m_next_page_button->set_click_handler( bound_handler( *this, 
											&t_mage_guild_window::next_page_click ));
	m_next_page_button->set_visible( true );

	// next and last hero buttons
	rect = m_book_bitmaps->find( "last_hero_button" )->get_rect();
	m_last_hero_button = new t_button( k_last_hero_button.get(), rect.top_left(), 
		                                m_detail_window );
	rect = m_book_bitmaps->find( "next_hero_button" )->get_rect();
	m_next_hero_button = new t_button( k_next_hero_button.get(), rect.top_left(), 
		                                m_detail_window );
	m_last_hero_button->set_click_handler( bound_handler( *this, 
											&t_mage_guild_window::last_hero_click ));
	m_next_hero_button->set_click_handler( bound_handler( *this, 
											&t_mage_guild_window::next_hero_click ));
	// close detail button
	rect = m_book_bitmaps->find( "index_button" )->get_rect();
	button = new t_button( k_spellbook_index_button.get(), rect.top_left(), m_detail_window );
	button->set_click_handler( bound_handler( *this, &t_mage_guild_window::index_click ));
	set_help( button, detail_help, "back_to_index" );
}
Beispiel #2
0
master::master(main_model& model)
        : pimpl_{std::make_unique<impl>(model)} {
    set_help("model viewport",
             "This area displays the currently loaded 3D model. Click and drag "
             "to rotate the model, or use the mouse wheel to zoom in and out.");

    addAndMakeVisible(*pimpl_);
}
Beispiel #3
0
// ---------------------------------------------------------------------
// create buttons
// ---------------------------------------------------------------------
void t_score_dialog::create_buttons()
{
	t_screen_rect rect;
	t_button*     button;
	t_help_block const& help = get_help_block( "shared" );


	// create ok button
	rect = m_layout->find( "close_button" )->get_rect();
	button = new t_button( g_ok_button.get(), rect.top_left(), this );
	button->set_click_handler( bound_handler(*this, &t_score_dialog::ok_clicked ) );
	set_help( button, help, "ok" );
}
Beispiel #4
0
t_quest_log_window::t_quest_log_window( t_window* parent, t_adventure_frame *frame_ptr )
    : t_window( k_completely_transparent, parent )
{
    m_frame = frame_ptr;
    m_map = frame_ptr->get_map();
    m_bitmaps_ptr = k_quest_log_bitmaps.get();

    t_screen_rect rect;

    /*
    ** Create background bitmap.
    */
    t_bitmap_layer const*   layer;
    t_window*               background;
    t_window*               window_ptr;
    t_screen_point          origin(0,0);

    layer = m_bitmaps_ptr->find( "background" );
    background = new t_bitmap_layer_window( layer, origin, this );
    layer = m_bitmaps_ptr->find( "title_scroll" );
    window_ptr = new t_bitmap_layer_window( layer, origin, this );

    // Set position.
    t_screen_rect parent_rect;
    parent_rect = get_parent()->get_client_rect();
    rect = m_bitmaps_ptr->get_rect();
    rect += (parent_rect.size() - rect.size()) / 2;
    init( rect );

    // Add buttons.
    t_button* button_ptr;
    t_help_block const& shared_help_block = get_help_block( "shared" );

    rect = m_bitmaps_ptr->find( "close_button" )->get_rect();
    button_ptr = new t_button( g_ok_button.get(), rect.top_left(), this );
    button_ptr->set_click_handler( bound_handler( *this, &t_quest_log_window::close_clicked ));
    set_help( button_ptr, shared_help_block, "ok" );

    // Text windows.
    t_text_window*  text_window_ptr;

    rect = m_bitmaps_ptr->find( "title" )->get_rect();
    text_window_ptr  = new t_text_window( get_font( rect.height() ), rect, this, "", t_pixel_24(0,0,0) );
    text_window_ptr->set_text ( k_text_title );
    text_window_ptr->set_center_horizontal();

    gather_data();
    create_quests_windows();
    show_quests( 0 );
}
// -------------------------------------------------------------------
// dialog for purchasing buildings in town
// -------------------------------------------------------------------
t_buy_building_window::t_buy_building_window( t_town* town, t_window* parent )
					 : t_window( k_no_transparency, parent ), m_town( town )
{
	m_interface = g_interface.get();
	t_help_block const& help = get_help_block( "town_hall" );

	// put up background
	t_window*             background;
	t_bitmap_layer const* background_layer;

	background_layer = m_interface->find( "background" );
	background = new t_bitmap_layer_window( background_layer, t_screen_point(0,0), this );

    // Text windows.
    t_text_window*  text_window_ptr;
	t_screen_rect   rect;

	rect = m_interface->find( "title" )->get_rect();
	text_window_ptr  = new t_text_window( get_font( rect.height() ), rect, this, "", t_pixel_24(0,0,0) );
    text_window_ptr->set_text ( k_text_town_hall_title );
	text_window_ptr->set_center_horizontal();

	// add OK button
	t_button*             button;
	t_bitmap_layer const* layer;

	layer = m_interface->find( "ok_button" );
	button = new t_button( g_ok_button.get(), layer->get_rect().top_left(), background );
	button->set_click_handler( bound_handler( *this, &t_buy_building_window::close_click ) );
  set_help( button, help, "ok" );

	create_buttons( background );

	m_material_display.init( m_interface, &town->get_map()->get_player(), t_screen_point(0,0),
		                     background );

	// figure out the client coordinates for this window
	// center it
	t_screen_rect background_rect = background->get_client_rect();
	background_rect += t_screen_point( (parent->get_width() - background_rect.width()) / 2, 
		                               (parent->get_height() - background_rect.height()) / 2 );
	init( background_rect );
	set_drop_shadow();
}
static t_button* create_marketplace_player_button ( t_screen_point &point, t_window *parent_window, int material_type,
                std::string keyword, t_help_block const& help_block )
{
	t_button*		        button;
	t_window*               window;
	t_screen_point          origin(0,0);
	t_bitmap_layer const*   layer;
	t_bitmap_group_ptr      material_bitmaps_ptr = k_large_material_bitmaps.get();
    
	button = new t_button( point, parent_window );
    layer = material_bitmaps_ptr->find ( k_material_keyword[ material_type ] );
    window = new t_bitmap_layer_window( layer, origin, button );
	set_help( window, help_block, keyword );

	button->set_released_image( window );
	button->set_pressed_image( window );

	button->update_size();

	return button;
}
Beispiel #7
0
static struct curses_form *
curses_form_construct_from_dfui_form_multiple(const struct dfui_form *f)
{
	struct curses_form *cf;
	struct curses_form_userdata *cfu;
	const char *min_width_str;
	unsigned int desc_width, min_width = 0;
	unsigned int len, max_label_width, total_label_width;
	unsigned int max_button_width, total_button_width;
	struct dfui_field *fi;
	struct dfui_action *a;
	struct curses_widget *label, *button;
	struct dfui_dataset *ds;
	const char *name;
	int left_acc, top_acc;
	int row = 1, col = 0, ins_x = 1, is_menu = 0;

	dfui_debug("-----\nconstructing multiple form: %s\n",
	    dfui_info_get_name(dfui_form_get_info(f)));

	cf = curses_form_new(dfui_info_get_name(dfui_form_get_info(f)));
	AURA_MALLOC(cfu, curses_form_userdata);
	cfu->f = f;
	cf->userdata = cfu;
	cf->cleanup = 1;

	set_help(f, cf);

	/* Calculate offsets for nice positioning of labels and buttons. */

	/*
	 * Determine the widths of the widest field and the widest
	 * button, and the total widths of all fields and all buttons.
	 */

	max_label_width = 0;
	total_label_width = 0;
	max_button_width = 0;
	total_button_width = 0;

	for (fi = dfui_form_field_get_first(f); fi != NULL;
	     fi = dfui_field_get_next(fi)) {
		len = MIN(60, strlen(dfui_info_get_name(dfui_field_get_info(fi))));
		if (len > max_label_width)
			max_label_width = len;
		total_label_width += (len + 2);
	}
	for (a = dfui_form_action_get_first(f); a != NULL;
	     a = dfui_action_get_next(a)) {
		len = strlen(dfui_info_get_name(dfui_action_get_info(a)));
		if (len > max_button_width)
			max_button_width = len;
		total_button_width += (len + 6);
	}

	/* Take the short description and turn it into a set of labels. */

	if ((min_width_str = dfui_form_property_get(f, "minimum_width")) != NULL)
		min_width = atoi(min_width_str);

	desc_width = 40;
	desc_width = MAX(desc_width, min_width);
	desc_width = MAX(desc_width, total_button_width);
	desc_width = MAX(desc_width, total_label_width);
	desc_width = MIN(desc_width, xmax - 3);

	dfui_debug("min width: %d\n", min_width);
	dfui_debug("button width: %d\n", total_button_width);
	dfui_debug("label width: %d\n", total_label_width);
	dfui_debug("resulting width: %d\n", desc_width);
	dfui_debug("form width: %d\n", cf->width);

	cf->height = curses_form_descriptive_labels_add(cf,
	    dfui_info_get_short_desc(dfui_form_get_info(f)),
	    1, cf->height + 1, desc_width);

	dfui_debug("form width now: %d\n", cf->width);

	/* Add the fields. */

	top_acc = cf->height + 1;
	cf->height += dfui_form_dataset_count(f) + 2;

	/*
	 * Create the widgets for a multiple=true form.  For each field
	 * in the form, a label containing the field's name, which serves
	 * as a heading, is created.  Underneath these labels, for each
	 * dataset in the form, a row of input widgets (typically textboxes)
	 * is added.  Non-action, manipulation buttons are also added to
	 * the right of each row.
	 */
	left_acc = 1;
	for (fi = dfui_form_field_get_first(f); fi != NULL;
	     fi = dfui_field_get_next(fi)) {
		/*
		 * Create a label to serve as a heading for the column.
		 */
		name = dfui_info_get_name(dfui_field_get_info(fi));
		label = curses_form_widget_add(cf, left_acc,
		    top_acc, 0, CURSES_LABEL, name, 0,
		    CURSES_WIDGET_WIDEN);
		cfu->widths[col++] = label->width + 2;
		left_acc += (label->width + 2);
	}

	/*
	 * Create a row of widgets for each dataset.
	 */
	top_acc++;
	for (ds = dfui_form_dataset_get_first(f); ds != NULL;
	     ds = dfui_dataset_get_next(ds)) {
		ins_x = curses_form_create_widget_row(cf, NULL, ds,
		     1, top_acc++, row++);
	}

	/*
	 * Finally, create an 'Add' button to add a new row
	 * if this is an extensible form.
	 */
	if (dfui_form_is_extensible(f)) {
		button = curses_form_widget_add(cf,
		    ins_x, top_acc, 0,
		    CURSES_BUTTON, "Add", 0, CURSES_WIDGET_WIDEN);
		button->user_id = row;
		curses_widget_set_click_cb(button, cb_click_insert_row);
		cf->height++;
	}

	cf->height++;

	/* Add the buttons. */

	create_buttons(f, cf, is_menu);

	cf->height++;

	curses_form_finalize(cf);

	return(cf);
}
Beispiel #8
0
static struct curses_form *
curses_form_construct_from_dfui_form_single(const struct dfui_form *f)
{
	struct curses_form *cf;
	struct curses_form_userdata *cfu;
	const char *min_width_str;
	unsigned int desc_width, min_width = 0;
	unsigned int len, max_label_width, total_label_width;
	unsigned int max_button_width, total_button_width;
	struct dfui_field *fi;
	struct dfui_action *a;
	struct curses_widget *label, *xbox;
	struct dfui_celldata *cd;
	const char *value;
	int is_menu;

	dfui_debug("-----\nconstructing single form: %s\n",
	    dfui_info_get_name(dfui_form_get_info(f)));

	is_menu = dfui_form_property_is(f, "role", "menu");
	cf = curses_form_new(dfui_info_get_name(dfui_form_get_info(f)));
	AURA_MALLOC(cfu, curses_form_userdata);
	cfu->f = f;
	cf->userdata = cfu;
	cf->cleanup = 1;

	set_help(f, cf);

	/* Calculate offsets for nice positioning of labels and buttons. */

	/*
	 * Determine the widths of the widest field and the widest
	 * button, and the total widths of all fields and all buttons.
	 */

	max_label_width = 0;
	total_label_width = 0;
	max_button_width = 0;
	total_button_width = 0;

	for (fi = dfui_form_field_get_first(f); fi != NULL;
	     fi = dfui_field_get_next(fi)) {
		len = MIN(60, strlen(dfui_info_get_name(dfui_field_get_info(fi))));
		if (len > max_label_width)
			max_label_width = len;
		total_label_width += (len + 2);
	}
	for (a = dfui_form_action_get_first(f); a != NULL;
	     a = dfui_action_get_next(a)) {
		len = strlen(dfui_info_get_name(dfui_action_get_info(a)));
		if (len > max_button_width)
			max_button_width = len;
		total_button_width += (len + 6);
	}

	if (total_label_width > (xmax - 2))
		total_label_width = (xmax - 2);		/* XXX scroll/wrap? */

	/* Take the short description and turn it into a set of labels. */

	if ((min_width_str = dfui_form_property_get(f, "minimum_width")) != NULL)
		min_width = atoi(min_width_str);

	desc_width = 40;
	desc_width = MAX(desc_width, min_width);
	if (is_menu) {
		desc_width = MAX(desc_width, max_button_width);
	} else {
		desc_width = MAX(desc_width, total_button_width);
	}
	desc_width = MAX(desc_width, max_label_width);  /* XXX + max_field_width */
	desc_width = MIN(desc_width, xmax - 4); /* -2 for borders, -2 for spaces */

	dfui_debug("min width: %d\n", min_width);
	dfui_debug("button width: %d\n", total_button_width);
	dfui_debug("label width: %d\n", total_label_width);
	dfui_debug("resulting width: %d\n", desc_width);
	dfui_debug("form width: %d\n", cf->width);

	cf->height = curses_form_descriptive_labels_add(cf,
	    dfui_info_get_short_desc(dfui_form_get_info(f)),
	    1, cf->height + 1, desc_width);

	dfui_debug("form width now: %d\n", cf->width);

	if (!is_menu)
		cf->height++;

	/*
	 * Add one label and one textbox (or other control) to a
	 * curses_form for each field in the dfui_form.  Each set of
	 * labels and controls is added one row below the previous set.
	 */
	for (fi = dfui_form_field_get_first(f); fi != NULL;
	     fi = dfui_field_get_next(fi)) {
		label = curses_form_widget_add(cf, 1,
		    cf->height, max_label_width, CURSES_LABEL,
		    dfui_info_get_name(dfui_field_get_info(fi)), 0, 0);

		cd = dfui_dataset_celldata_find(dfui_form_dataset_get_first(f),
		    dfui_field_get_id(fi));

		value = dfui_celldata_get_value(cd);

		if (dfui_field_property_is(fi, "control", "checkbox")) {
			xbox = curses_form_widget_add(cf,
			    max_label_width + 3,
			    cf->height, 4, CURSES_CHECKBOX, "", 0, 0);
			xbox->amount = (value[0] == 'Y' ? 1 : 0);
		} else {
			xbox = curses_form_widget_add(cf,
			    max_label_width + 3,
			    cf->height, 20, CURSES_TEXTBOX, value, 256, 0);
		}
		curses_widget_tooltip_set(xbox,
		    dfui_info_get_short_desc(dfui_field_get_info(fi)));
		xbox->user_id = 1;
		xbox->userdata = fi;

		if (dfui_field_property_is(fi, "editable", "false"))
			xbox->editable = 0;
		if (dfui_field_property_is(fi, "obscured", "true"))
			xbox->obscured = 1;

		if (dfui_field_option_get_first(fi) != NULL) {
			curses_widget_set_click_cb(xbox, cb_click_select_option);
		}

		cf->height++;
	}

	if (dfui_form_field_get_first(f) != NULL)
		cf->height++;

	create_buttons(f, cf, is_menu);

	cf->height++;

	curses_form_finalize(cf);

	return(cf);
}
// -------------------------------------------------------------------
// dialog for purchasing buildings in town
// create buttons for purchasing buildings.
// -------------------------------------------------------------------
void t_buy_building_window::create_buttons( t_window* background )
{
	t_button_info button_info[k_max_buttons];
	t_town_type   town_type = m_town->get_type();
	t_help_block const& help = get_help_block( "town_hall" );

	int i;

	for (i = 0; i < k_max_buttons; i++)
	{
		button_info[i].id = -1;
		button_info[i].state = k_button_hidden;
	}

	set_button_state( button_info, m_town, k_common_buttons, ELEMENTS_OF( k_common_buttons ));
	set_button_state( button_info, m_town, k_button_maps[town_type].map, 
	                  k_button_maps[town_type].count );

	t_bitmap_layer const* layer;
	t_button*			  button;
	t_bitmap_layer const* frame = m_interface->find( "frame" );
	t_screen_point        frame_origin = frame->get_rect().top_left();
	t_bitmap_layer const* thumbnail = m_interface->find( "thumbnail" );
	t_screen_point        thumbnail_origin = thumbnail->get_rect().top_left() - frame_origin;
	t_bitmap_layer const* x_mark = m_interface->find( "cannot build" );
	t_bitmap_layer const* bars[6];
	t_window*             frame_window;
	t_window*             window;
	t_town_building       building;

	m_thumbnails = g_building_thumbnails[town_type]->get();

	bars[k_button_disabled - 1]		 = m_interface->find( "gray bar" );
	bars[k_button_built - 1]		 = m_interface->find( "gold bar" );
	bars[k_button_cannot_build - 1]	 = m_interface->find( "red bar" );
	bars[k_button_cannot_afford - 1] = bars[k_button_cannot_build - 1];
	bars[k_button_not_owner - 1]     = bars[k_button_cannot_build - 1];
	bars[k_button_ok - 1]			 = m_interface->find( "green bar" );

	// find row rectangles
	t_bitmap_layer const* rows[5];
	int                   row_counts[5];
	int                   row_spacing[5];
	int                   row_start[5];

	for (i = 0; i < 5; i++)
	{
		row_counts[i] = 0;
		rows[i] = m_interface->find( format_string( "row %i", i + 1 ) );
	}

	// count # of buttons in each row
	for (i = 0; i < 20; i++)
		if (button_info[i].state != k_button_hidden)
			row_counts[i / 4]++;

	// compute row spacing
    int             width_diff;
	for (i = 0; i < 5; i++)
	{
        // Diff. between row frame and sum of individual building frames.
        width_diff = (rows[i]->get_width() - k_building_columns * frame->get_width());

		row_spacing[i] = width_diff / (k_building_columns - 1) + frame->get_width();
		row_start[i] =  (rows[i]->get_width() - frame->get_width() 
			             - row_spacing[i] * (row_counts[i] - 1)) / 2;
	}             

	// create the buttons
	t_screen_point  point;
	int             row;
	t_window*       bar;
	t_text_window*  text_window;
	t_screen_rect   rect;
	t_screen_rect   text_rect = m_interface->find("building_text")->get_rect();

	//t_screen_point  thumbnail_offset;

	for (i = 0; i < k_max_buttons; i++)
	{
		if (button_info[i].state == k_button_hidden)
			continue;

		building = t_town_building( button_info[i].id  );

		t_building_traits const& traits = get_traits( town_type, building );

		row = i / k_building_columns;
		point = rows[row]->get_rect().top_left();
		point.x += row_start[row] + (i % k_building_columns ) * row_spacing[row];
		button = new t_button( point, background );
		
        rect = frame->get_rect() - frame->get_rect().top_left();
	    frame_window = new t_window ( rect, k_completely_transparent, button );
		window = new t_bitmap_layer_window( frame, -frame->get_rect().top_left(), frame_window );

		// add thumbnail
		layer = m_thumbnails->find( traits.keyword );
		window = new t_bitmap_layer_window( layer, thumbnail_origin, frame_window );

		// if cannot build, add X mark
		switch (button_info[i].state)
		{
			case k_button_disabled:
			case k_button_cannot_build:
			case k_button_cannot_afford:
				window = new t_bitmap_layer_window( x_mark, -frame_origin, frame_window );
				break;
		}
		
		// add appropriate bar
		t_bitmap_layer const* bar_layer = bars[button_info[i].state - 1];
		bar = new t_bitmap_layer_window( bar_layer, -frame_origin, frame_window );
		
		// add name to bar
		text_window = new t_text_window( get_font( text_rect.height() / 2 ), text_rect - bar_layer->get_rect().top_left(),
			                             bar, traits.name, t_pixel_24(0, 0, 0) );
		text_window->set_center_horizontal();
		text_window->set_center_vertical();
		//text_window->set_drop_shadow( true );

		switch (button_info[i].state)
		{
            case k_button_built:
	            set_help( button, help, "gold_bar" );
                break;

			case k_button_disabled:
	            set_help( button, help, "gray_bar" );
                break;

			case k_button_cannot_build:
	            set_help( button, help, "red_bar_x" );
                break;

			case k_button_cannot_afford:
	            set_help( button, help, "red_bar_$" );
				break;

			case k_button_not_owner:
				set_help( button, help, "red_bar_owner" );
				break;

            default :
	            set_help( button, help, "green_bar" );
				break;
		}
		
		// set image and handler
	    frame_window->set_size_from_children();
		button->set_released_image( frame_window );
		if (button_info[i].state == k_button_disabled)
        {
		    button->set_click_handler( add_2nd_argument(
			    bound_handler( *this, &t_buy_building_window::disabled_building_click ), button_info[i].id ));
        }
        else
        {
		    button->set_click_handler( add_2nd_argument(
			    bound_handler( *this, &t_buy_building_window::building_click ), button_info[i].id ));
        }
		button->set_right_click_handler( add_2nd_argument(
			bound_handler( *this, &t_buy_building_window::describe_building ), button_info[i].id ));
	}
}
// Pass in ratio... (for purchases)
void t_dialog_marketplace::init_dialog( t_window* parent, t_adventure_frame* frame, std::string const& name_text, std::string const& intro_text, 
                int market_efficiency_ratio )
{

	t_bitmap_layer const*   layer;
	//t_window *              window;
	t_window *              background_window;
	t_screen_point          origin(0,0);
	t_screen_point          point(0,0);
	t_screen_rect           rect;
	t_bitmap_group_ptr      material_bitmaps_ptr = k_large_material_bitmaps.get();
    int                     i;
	t_help_block const&     material_help = get_help_block( "material_display" );
	t_help_block const&		help = get_help_block( "marketplace" );

	m_player_ptr = &frame->get_map()->get_player();
	m_player_funds = m_player_ptr->get_funds()[k_gold];
	m_bitmaps_ptr = k_marketplace_bitmaps.get();
    m_market_efficiency_ratio = market_efficiency_ratio;

	layer = m_bitmaps_ptr->find( "background" );
	background_window = new t_bitmap_layer_window( layer, origin, this );

	layer = m_bitmaps_ptr->find( "frame" );
   	rect = layer->get_rect();
	m_player_frame = new t_bitmap_layer_window( layer, -rect.top_left(), this );
	m_player_frame->set_visible( false );
	m_player_frame->update_size();

	layer = m_bitmaps_ptr->find( "frame" );
   	rect = layer->get_rect();
	m_market_frame = new t_bitmap_layer_window( layer, -rect.top_left(), this );
	m_market_frame->set_visible( false );
	m_market_frame->update_size();

    // Find wood frame (first item) - get diff for frame.
	t_screen_point  frame_diff(0,0);

    point = m_bitmaps_ptr->find( "wood_icon" )->get_rect().top_left();
    frame_diff = (point - rect.top_left());

    /*
    ** Materials:
    */
	std::string     material_icon_text;

	for (i=0; i<k_material_count; i++)
    {
        // Player's material.
		material_icon_text = format_string ( "%s_icon", k_material_keyword[i] );
	    rect = m_bitmaps_ptr->find( material_icon_text )->get_rect();
        m_player_button[i] = create_marketplace_player_button ( rect.top_left(), background_window, i,
                        k_material_keyword[i], help );
	
        m_player_button[i]->set_click_handler( add_2nd_argument( bound_handler( *this, &t_dialog_marketplace::player_material_clicked ), i));
	    m_player_frame_locations.push_back ( rect.top_left() - frame_diff );

        // Market material.
		material_icon_text = format_string ( "%s_icon_2", k_material_keyword[i] );
	    rect = m_bitmaps_ptr->find( material_icon_text )->get_rect();
        m_market_button[i] = create_marketplace_player_button ( rect.top_left(), background_window, i,
                        format_string( "%s_%s", "available", k_material_keyword[i] ), help );
	
        m_market_button[i]->set_click_handler( add_2nd_argument( bound_handler( *this, &t_dialog_marketplace::market_material_clicked ), i));
	    m_market_frame_locations.push_back ( rect.top_left() - frame_diff );
    }

    /*
    ** Create buttons.
    */
	t_button            *button_ptr;
	t_button_handler    button_handler;

	rect = m_bitmaps_ptr->find( "close_button" )->get_rect();
	button_ptr = new t_button( g_ok_button.get(), rect.top_left(), this );
	button_ptr->set_click_handler( bound_handler( *this, &t_dialog_marketplace::close_click ));
	set_help( button_ptr, help, "ok" );

    /*
    ** Add buy button.
    */
	point = m_bitmaps_ptr->find( "sell_button" )->get_rect().top_left() + origin;
	m_buy_button = new t_button( k_buy_button.get(), point, this );
	button_handler = bound_handler( *this, &t_dialog_marketplace::buy_clicked );
	m_buy_button->set_click_handler( button_handler );
	set_help( m_buy_button, help, "purchase" );
	m_buy_button->enable( false );

    // Add max button.
	point = m_bitmaps_ptr->find( "max_button" )->get_rect().top_left() + origin;
	m_max_button = new t_button( g_max_button.get(), point, this );
	button_handler = bound_handler( *this, &t_dialog_marketplace::max_clicked );
	m_max_button->set_click_handler( button_handler );
	set_help( m_max_button, help, "maximum" );
	m_max_button->enable( false );

    /*
    ** Add scrollbar.
    */
	layer = m_bitmaps_ptr->find( "scrollbar" );
	rect  = layer->get_rect();

	m_scrollbar = new t_scrollbar( rect.top_left(), rect.width(), this, 0, 0, false );
	m_scrollbar->set_handler( bound_handler( *this, &t_dialog_marketplace::scrollbar_move));
	m_scrollbar->set_position( 0 );
	m_scrollbar->set_limits( 0, 0 );

    /*
    ** Text windows.
    */
	t_text_window* text_window_ptr;

    // Title.
	rect = m_bitmaps_ptr->find( "title" )->get_rect() + origin;
	text_window_ptr = new t_text_window( get_font( 20 ), rect, this, name_text, t_pixel_24(0,0,0));
	text_window_ptr->set_center_horizontal();
	text_window_ptr->set_drop_shadow( false );

    // Intro text.
	rect = m_bitmaps_ptr->find( "text" )->get_rect() + origin;
	text_window_ptr = new t_text_window( get_font( 20 ), rect, this, intro_text, t_pixel_24(0,0,0));
	text_window_ptr->set_center_horizontal();
	text_window_ptr->set_drop_shadow( false );

	std::string     material_text_box;
    
	for (i=0; i<k_material_count; i++)
    {
        // Player's side.  Kindgom amount.
		material_text_box = format_string ( "kingdom_%s", k_material_keyword[i] );
	    rect = m_bitmaps_ptr->find( material_text_box )->get_rect();
	    m_player_amount_text[i] = new t_text_window( get_font( 16 ), rect, this, "", t_pixel_24(0,0,0));
	    m_player_amount_text[i]->set_center_horizontal();
        
        // Market exchange text.
		material_text_box = format_string ( "%s_exchange", k_material_keyword[i] );
	    rect = m_bitmaps_ptr->find( material_text_box )->get_rect();
	    m_market_exchange_text[i] = new t_text_window( get_font( 16 ), rect, this, "", t_pixel_24(0,0,0));
	    m_market_exchange_text[i]->set_center_horizontal();

    }

    show_player_material_amount();

    // Player quantity text.
	rect = m_bitmaps_ptr->find( "qty_selling" )->get_rect() + origin;
	m_player_quantity_text = new t_text_window( get_font( rect.height() ), rect, this, "", t_pixel_24(0,0,0));
	m_player_quantity_text->set_center_horizontal();
	m_player_quantity_text->set_drop_shadow( false );

    // Market quantity text.
	rect = m_bitmaps_ptr->find( "exchange_rate" )->get_rect() + origin;
	m_market_quantity_text = new t_text_window( get_font( rect.height() ), rect, this, "", t_pixel_24(0,0,0));
	m_market_quantity_text->set_center_horizontal();
	m_market_quantity_text->set_drop_shadow( false );

    show_exchange_rates();

    /*
    ** Center the position and display the window.
    */
    t_screen_rect parent_rect = get_parent()->get_client_rect();
    
    rect = m_bitmaps_ptr->get_rect();
    rect += (parent_rect.size() - rect.size()) / 2;
    init( rect );

}
// ---------------------------------------------------------------------------
// Initialize dialog. Continue only if the return value is true
// ---------------------------------------------------------------------------
bool t_dialog_caravan_arrivals::init_dialog( t_town & town, t_creature_array * visiting_army )
{
	t_player & player = m_map.get_player();
	int        player_number = m_map.get_player_number();
	bool       foreigners = (    town.get_owner_number() != player_number 
							  || ( visiting_army && visiting_army->get_owner_number() != player_number ) );
	
	t_keyword_replacer town_replacer;
	town_replacer.add_keyword( "%town", town.get_name() );

	t_caravan_set const & caravans = player.get_caravans();
	t_caravan_set::const_iterator it;

	for ( it = caravans.get_lower_bound_of_destination( &town ); it != caravans.end() && (*it)->get_destination().get() == &town; it++ )
	{
		if ( (*it)->has_arrived() )
			m_caravans.push_back( *it );
	}
	
	if ( m_caravans.empty() )
	{
		ok_dialog( town_replacer( k_no_arrivals ), true );
		return false;
	}


	// Create subwindows
	m_bitmaps = k_bitmaps.get();
	t_help_block const& help = get_help_block( "caravan_arrival" );
	t_help_block const& shared_help = get_help_block( "shared" );

	t_bitmap_layer const * layer;
	t_window *             background;
	t_text_window *		   text_window;
	t_button *             button;

	layer = m_bitmaps->find( "background" );
	background = new t_bitmap_layer_window( layer, t_screen_point(0, 0), this );

	layer = m_bitmaps->find( "text scroll" );
	new t_bitmap_layer_window( layer, t_screen_point(0, 0), background );

	layer = m_bitmaps->find( "title scroll" );
	new t_bitmap_layer_window( layer, t_screen_point(0, 0), background );

	layer = m_bitmaps->find( "title" );
	text_window = new t_text_window( get_font( 20 ), layer->get_rect(), background, town_replacer( k_title ), t_pixel_24(0,0,0) );
	text_window->set_drop_shadow( false );
	text_window->set_justification( k_justify_center );

	layer = m_bitmaps->find( "text" );
	text_window = new t_text_window( get_font( 16 ), layer->get_rect(), background, town_replacer( k_text ), t_pixel_24(0,0,0) );
	text_window->set_drop_shadow( false );
	text_window->set_justification( k_justify_center );

	layer = m_bitmaps->find( "ok_button" );
	button = new t_button( g_ok_button.get(), layer->get_rect().top_left(), background );
	button->set_click_handler( bound_handler( *this, &t_dialog_caravan_arrivals::ok_clicked ) );
  set_help( button, shared_help, "ok" );

	// Create creature windows
	t_creature_array_window::t_layout garrison_layout;
	t_bitmap_layer const * background_layer;
	if ( visiting_army )
	{
		background_layer = m_bitmaps->find( "double_garrison_background" );
		layer = m_bitmaps->find( "double_garrison_rings" );
		garrison_layout = t_creature_array_window::k_top_row;
	}
	else
	{
		background_layer = m_bitmaps->find( "single_garrison_background" );
		layer = m_bitmaps->find( "single_garrison_rings" );
		garrison_layout = t_creature_array_window::k_single_row;
	}

	new t_bitmap_layer_window( background_layer, t_screen_point(0, 0), background );

	m_garrison_window = new t_creature_array_window( layer->get_rect().top_left(), &town, garrison_layout, 0, background );
	
	if ( foreigners )
		setup_foreign_creature_array_window_controls( m_map, m_garrison_window );

	if ( visiting_army )
	{
		t_screen_point visiting_point = layer->get_rect().top_left();
		visiting_point.y += m_garrison_window->get_frame_height();

		m_visiting_window = new t_creature_array_window( visiting_point, visiting_army, t_creature_array_window::k_bottom_row, 0, background );
		m_visiting_window->link_selection( m_garrison_window );
		m_visiting_window->move_before( m_garrison_window );

		layer = m_bitmaps->find( "move_garrison_button" );
		button = new t_button( k_move_garrison_down_button.get(), layer->get_rect().top_left(), background );
		if ( town.get_owner_number() == player_number )
		{
			button->set_click_handler( discard_argument< t_button * >( bound_handler( *this, &t_dialog_caravan_arrivals::move_garrison_clicked ) ) );
		}
		else
		{
			button->enable( false );
		}
   		set_help( button, shared_help, "move_garrison_to_adjacent" );

		layer = m_bitmaps->find( "move_visiting_button" );
		button = new t_button( k_move_up_button.get(), layer->get_rect().top_left(), background );
		if ( visiting_army->get_owner_number() == player_number )
		{
			button->set_click_handler( discard_argument< t_button * >( bound_handler( *this, &t_dialog_caravan_arrivals::move_visiting_clicked ) ) );
		}
		else
		{
			button->enable( false );
		}
   		set_help( button, shared_help, "move_adjacent_to_garrison" );

		if ( foreigners )
			setup_foreign_creature_array_window_controls( m_map, m_visiting_window );
	}

	// Create scrollbar
	if ( m_caravans.size() > k_displayed_caravans )
	{
		layer = m_bitmaps->find( "scrollbar" );
		t_scrollbar * scrollbar = new t_scrollbar( layer->get_rect().top_left(), layer->get_height(), background, 
												   0, m_caravans.size() - k_displayed_caravans );
		scrollbar->set_page_size( k_displayed_caravans);
		scrollbar->set_handler( bound_handler( *this, &t_dialog_caravan_arrivals::scroll ) );
	}

	// Create caravan window(s)
	int visible_caravans = minimum( unsigned int( k_displayed_caravans ), m_caravans.size() );
	int	i;

	layer = m_bitmaps->find( "caravan_1" );
	t_screen_point caravan_1_point = layer->get_rect().top_left();

	background_layer = m_bitmaps->find( "caravan_background" );

	layer = m_bitmaps->find( "move_caravan_to_garrison_button" );
	t_screen_point move_to_garrison_offset = layer->get_rect().top_left() - caravan_1_point;
	
	layer = m_bitmaps->find( "move_caravan_to_visiting_button" );
	t_screen_point move_to_visiting_offset = layer->get_rect().top_left() - caravan_1_point;
	
	layer = m_bitmaps->find( "caravan_rings" );
	t_screen_point caravan_rings_offset = layer->get_rect().top_left() - caravan_1_point;

	for ( i = 0; i < visible_caravans; i++ )
	{
		t_screen_point caravan_point;
		if ( i == 0 )
		{
			caravan_point = caravan_1_point;
		}
		else
		{
			layer = m_bitmaps->find( format_string("caravan_%d", i + 1 ) );
			caravan_point = layer->get_rect().top_left();
		}

		// Background
		t_screen_point diff = caravan_point - caravan_1_point;
		new t_bitmap_layer_window( background_layer, diff, background );

		// Buttons
		button = new t_button( k_move_caravan_to_garrison_button.get(), caravan_point + move_to_garrison_offset, background );
		button->set_click_handler( discard_argument< t_button * >( add_argument( bound_handler( *this, &t_dialog_caravan_arrivals::move_to_garrison_clicked ), i ) ) );
	  	set_help( button, help, "move_caravan_to_garrison" );

		if ( visiting_army )
		{
			button = new t_button( k_move_caravan_to_visiting_button.get(), caravan_point + move_to_visiting_offset, background );
			button->set_click_handler( discard_argument< t_button * >( add_argument( bound_handler( *this, &t_dialog_caravan_arrivals::move_to_visiting_clicked ), i ) ) );
		  	set_help( button, help, "move_caravan_to_visiting" );
		}

		m_visible_caravans[i] = new t_creature_array_window( caravan_point + caravan_rings_offset, 
															 m_caravans[i].get(),
															 t_creature_array_window::k_single_row,
															 0,
															 background );

		m_visible_caravans[i]->link_selection( m_garrison_window );

		if ( foreigners )
			setup_foreign_creature_array_window_controls( m_map, m_visible_caravans[i] );
	}
	
	t_screen_rect rect = m_bitmaps->get_rect();
	rect += (get_parent()->get_client_rect().size() - rect.size()) / 2;
	init( rect );

	return true;
}
Beispiel #12
0
//--------- Begin of function Help::set_help2 --------//
//!
void Help::set_help2(int x1, int y1, int width, int height, char* helpCode) {
    set_help( x1, y1, x1+width-1, y1+height-1, helpCode );
}
Beispiel #13
0
void t_dialog_garrison::init_dialog( t_army* visiting_army, 
									 t_ownable_garrisonable_adv_object * adv_obj, 
									 t_adventure_frame* frame,
									 std::string const& name_text, 
									 std::string const& intro_text )
{
	t_bitmap_layer const*   layer;
	t_window *              window;
	t_screen_point          origin(0,0);
	t_screen_point          point(0,0);
	t_screen_rect           rect;

	m_visiting_army_ptr = visiting_army;
    m_garrison_ptr = adv_obj;
    m_frame = frame;

    // Return if no garrison or visiting army?
	//if ((m_visiting_army_ptr == NULL) && (m_garrison_ptr->empty()))
    //    return;

	m_bitmaps_ptr = k_garrison_bitmaps.get();
	layer = m_bitmaps_ptr->find( "background" );
	window = new t_bitmap_layer_window( layer, origin, this );

    /*
    ** Display the garrison.
    */
    create_garrison_window();

    /*
    ** Text windows.
    */
	t_text_window* text_window_ptr;

    // Title.
	rect = m_bitmaps_ptr->find( "title" )->get_rect() + origin;
	text_window_ptr = new t_text_window( get_font( 20 ), rect, this, name_text, t_pixel_24(0,0,0));
	text_window_ptr->set_center_horizontal();
	text_window_ptr->set_drop_shadow( false );

    // Text.
	rect = m_bitmaps_ptr->find( "text" )->get_rect() + origin;
	text_window_ptr = new t_text_window( get_font( 18 ), rect, this, intro_text, t_pixel_24(0,0,0));
	text_window_ptr->set_center_horizontal();
	text_window_ptr->set_drop_shadow( false );

    /*
    ** Create buttons.
    */
	t_help_block const&		shared_help = get_help_block( "shared" );
	t_button                *button_ptr;
	rect = m_bitmaps_ptr->find( "ok_button" )->get_rect();
	button_ptr = new t_button( g_ok_button.get(), rect.top_left(), this );
	button_ptr->set_click_handler( bound_handler( *this, &t_dialog_garrison::close_click ));
  set_help( button_ptr , shared_help, "ok" );

    /*
    ** Set the position and display the window.
    */
	t_screen_rect parent_rect = get_parent()->get_client_rect();
    
	rect = m_bitmaps_ptr->get_rect();
	rect += (parent_rect.size() - rect.size()) / 2;
	init( rect );
}
// ---------------------------------------------------------------------
// create buttons
// ---------------------------------------------------------------------
void t_campaign_selection_dialog::create_buttons()
{
	int						i;
	t_bitmap_layer const*	layer;
	t_window*				window;
	t_screen_point			point(0,0);
	t_screen_rect			rect;
	t_button*				button;
	t_help_block const&		help = get_help_block( "shared" );
	t_help_block const&		campaign_help = get_help_block( "campaign_selection" );

	// create cancel button
	rect = m_layout->find( "cancel_button" )->get_rect();
	button = new t_button( g_cancel_button.get(), rect.top_left(), this );
	button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::cancel_clicked ) );
	set_help( button, help, "cancel" );

	for( i = 0; i < k_campaign_count; ++i )
	{
		std::string const & keyword = get_keyword( k_campaign_ids[ i ] );
		std::string name = keyword;
		name += "_campaign";
		layer = m_layout->find( name );
		rect = layer->get_rect();
		button = new t_button( rect.top_left(), this );
		set_help( button, campaign_help, keyword );

		switch( k_campaign_ids[ i ] )
		{
		case k_standard_campaign_order:
			button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::order_clicked ) );
//			if( m_enabled[k_standard_campaign_order] )
				layer = g_order_intro.get()->find( "frame 001" ); 
//			else
//				layer = g_order_intro_completed.get()->find( "frame 001" ); 
			break;
		case k_standard_campaign_might:
			button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::might_clicked ) );
//			if( m_enabled[k_standard_campaign_might] )
				layer = g_might_intro.get()->find( "frame 001" ); 
//			else
//				layer = g_might_intro_completed.get()->find( "frame 001" ); 
			break;
		case k_standard_campaign_life:
			button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::life_clicked ) );
//			if( m_enabled[k_standard_campaign_life] )
				layer = g_life_intro.get()->find( "frame 001" ); 
//			else
//				layer = g_life_intro_completed.get()->find( "frame 001" ); 
			break;
		case k_standard_campaign_death:
			button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::death_clicked ) );
//			if( m_enabled[k_standard_campaign_death] )
				layer = g_death_intro.get()->find( "frame 001" ); 
//			else
//				layer = g_death_intro_completed.get()->find( "frame 001" ); 
			break;
		case k_standard_campaign_nature:
			button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::nature_clicked ) );
//			if( m_enabled[k_standard_campaign_nature] )
				layer = g_nature_intro.get()->find( "frame 001" ); 
//			else
//				layer = g_nature_intro_completed.get()->find( "frame 001" ); 
			break;
		case k_standard_campaign_chaos:
			button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::chaos_clicked ) );
//			if( m_enabled[k_standard_campaign_chaos] )
				layer = g_chaos_intro.get()->find( "frame 001" ); 
//			else
//				layer = g_chaos_intro_completed.get()->find( "frame 001" ); 
			break;
		}

		window = new t_bitmap_layer_window( layer, point, button );
		button->set_released_image( window );
	}
}
Beispiel #15
0
master::master(main_model& model)
        : model_{model}
        , begun_connection_{model_.connect_begun([this] {
            //  Disable the top panel so that the user can't muck stuff up.
            property_panel_.setEnabled(false);
            bottom_.set_state(bottom::state::rendering);
        })}
        , engine_state_connection_{model_.connect_engine_state(
                  [this](auto run, auto runs, auto state, auto progress) {
                      bottom_.set_bar_text(util::build_string(
                              "run ",
                              run + 1,
                              " / ",
                              runs,
                              ": ",
                              wayverb::combined::to_string(state)));
                      bottom_.set_progress(progress);
                  })}
        , finished_connection_{model_.connect_finished([this] {
            //  Re-enable the top panel.
            property_panel_.setEnabled(true);
            bottom_.set_state(bottom::state::idle);
        })} {
    set_help("configuration panel",
             "Use the options in this panel to adjust the various settings of "
             "the simulation.");

    const auto aabb = wayverb::core::geo::compute_aabb(
            model_.project.get_scene_data().get_vertices());

    //  Populate the property panel
    property_panel_.addSection(
            "sources",
            {new wrapped_property_component<sources::master>{
                    aabb, *model_.project.persistent.sources()}});
    property_panel_.addSection(
            "receivers",
            {new wrapped_property_component<receivers::master>{
                    model_.capsule_presets,
                    aabb,
                    *model_.project.persistent.receivers()}});
    property_panel_.addSection(
            "materials",
            make_material_options(model_.scene,
                                  model_.material_presets,
                                  *model_.project.persistent.materials()));
    property_panel_.addSection(
            "raytracer",
            {static_cast<PropertyComponent*>(new raytracer::ray_number_property{
                     *model_.project.persistent.raytracer()}),
             static_cast<PropertyComponent*>(
                     new raytracer::img_src_order_property{
                             *model_.project.persistent.raytracer()})});

    property_panel_.addSection(
            "waveguide",
            {new wrapped_property_component<waveguide::master>{
                    *model_.project.persistent.waveguide()}});

    property_panel_.setOpaque(false);

    //  Make components visible
    addAndMakeVisible(property_panel_);
    addAndMakeVisible(bottom_);
}