Exemplo n.º 1
0
void spicker::scroll_event(int newx, image *screen) {
	last_sel = newx;
	int xa, ya, xo, yo;
	xo = x + 2;
	yo = y + 2;
	if (vert) {
		xa = 0;
		ya = item_height();
	} else {
		xa = item_width();
		ya = 0;
	}
	draw_background(screen);

	for (int i = newx; i < newx + vis(); i++) {
		if (i < t) {
			if (m)
				draw_item(screen, xo, yo, i, get_select(i));
			else
				draw_item(screen, xo, yo, i, i == cur_sel);
		}
		xo += xa;
		yo += ya;
	}
}
Exemplo n.º 2
0
void draw_menu() {
	int m_y, m_x, item = 0;
	for (m_y = 0; m_y < 3; m_y++) {
		for (m_x = 0; m_x < 3; m_x++) {
			osd_inv((m_y == menu_y) && (m_x == menu_x));
			draw_item(menu_item[item], 5 + m_x * 10, m_y+2, ALIGN_MIDDLE);
			item++;
		}
	}
	
	osd_inv(0); draw_item(ptrfile, 16, 6, ALIGN_MIDDLE);

	osd_inv(0);	osd_gotoxy(0,7); osd_puts(TXT_MENU_HALP);
}
Exemplo n.º 3
0
Arquivo: ggg.cpp Projeto: koo5/lemon-2
    void draw_item(json_object *o)
    {
	stringstream dummy;
	if(json_object_is_type(o, json_type_boolean))
	{
	    json_object_get_boolean(o)?draw_text("1"):draw_text("0");
	    one_down();
	}
	if(json_object_is_type(o, json_type_double))
	{
	    dummy << json_object_get_double(o);
	    draw_text(dummy.str().c_str());
	    one_down();
	}
	if(json_object_is_type(o, json_type_int))
	{
	    dummy << json_object_get_int(o);
	    draw_text(dummy.str().c_str());
	    one_down();
	}
	if(json_object_is_type(o, json_type_object))
	{
	    one_right();
	    json_object_object_foreach(o, key,val)
	    {
		draw_text(key);
		one_down();
		draw_item(val);
		one_down();
	    }
	    one_left();
	}
Exemplo n.º 4
0
void
Menu::draw(DrawingContext& context)
{
  if (!items[active_item]->help.empty())
  {
    int text_width  = (int) Resources::normal_font->get_text_width(items[active_item]->help);
    int text_height = (int) Resources::normal_font->get_text_height(items[active_item]->help);

    Rectf text_rect(pos.x - text_width/2 - 8,
                   SCREEN_HEIGHT - 48 - text_height/2 - 4,
                   pos.x + text_width/2 + 8,
                   SCREEN_HEIGHT - 48 + text_height/2 + 4);

    context.draw_filled_rect(Rectf(text_rect.p1 - Vector(4,4),
                                   text_rect.p2 + Vector(4,4)),
                             Color(0.2f, 0.3f, 0.4f, 0.8f),
                             16.0f,
                             LAYER_GUI-10);

    context.draw_filled_rect(text_rect,
                             Color(0.6f, 0.7f, 0.8f, 0.5f),
                             16.0f,
                             LAYER_GUI-10);

    context.draw_text(Resources::normal_font, items[active_item]->help,
                      Vector(pos.x, SCREEN_HEIGHT - 48 - text_height/2),
                      ALIGN_CENTER, LAYER_GUI);
  }

  for(unsigned int i = 0; i < items.size(); ++i)
  {
    draw_item(context, i);
  }
}
Exemplo n.º 5
0
void
Menu::draw(DrawingContext& context)
{
  if (!items[active_item]->help.empty())
  {
    int text_width  = static_cast<int>(Resources::normal_font->get_text_width(items[active_item]->help));
    int text_height = static_cast<int>(Resources::normal_font->get_text_height(items[active_item]->help));

    Rectf text_rect(pos.x - static_cast<float>(text_width) / 2.0f - 8.0f,
                    static_cast<float>(SCREEN_HEIGHT) - 48.0f - static_cast<float>(text_height) / 2.0f - 4.0f,
                    pos.x + static_cast<float>(text_width) / 2.0f + 8.0f,
                    static_cast<float>(SCREEN_HEIGHT) - 48.0f + static_cast<float>(text_height) / 2.0f + 4.0f);

    context.color().draw_filled_rect(Rectf(text_rect.p1 - Vector(4,4),
                                             text_rect.p2 + Vector(4,4)),
                                       Color(0.2f, 0.3f, 0.4f, 0.8f),
                                       16.0f,
                                       LAYER_GUI-10);

    context.color().draw_filled_rect(text_rect,
                                       Color(0.6f, 0.7f, 0.8f, 0.5f),
                                       16.0f,
                                       LAYER_GUI-10);

    context.color().draw_text(Resources::normal_font, items[active_item]->help,
                              Vector(pos.x, static_cast<float>(SCREEN_HEIGHT) - 48.0f - static_cast<float>(text_height) / 2.0f),
                              ALIGN_CENTER, LAYER_GUI);
  }

  for(unsigned int i = 0; i < items.size(); ++i)
  {
    draw_item(context, i);
  }
}
Exemplo n.º 6
0
BOOL CALLBACK file_view_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
	switch(msg){
	case WM_INITDIALOG:
		{
			resize_fileview(hwnd);
			SetDlgItemTextW(hwnd,IDC_HOTLIST,(WCHAR*)"\x3D\x27"); //0x273D asterisk
			SetDlgItemTextW(hwnd,IDC_HISTORY,(WCHAR*)"\xBC\x25"); //0x25BC downarrow
		}
		break;
	case WM_DRAWITEM:
		{
			DRAWITEMSTRUCT *di=(DRAWITEMSTRUCT*)lparam;
			if(di!=0 && di->CtlType==ODT_LISTVIEW){
				draw_item(di,0);
				return TRUE;
			}
		}
		break;
	case WM_SIZE:
		resize_fileview(hwnd);
		break;
	}
	return 0;
}
Exemplo n.º 7
0
Arquivo: ui.c Projeto: JBarrada/fancy
void draw_menu(MENU *menu) {
	int i;

	uint32_t height = menu->vpad;
	uint32_t width=0, text_width;
	for (i=0; i<10; i++) {
		if (menu->items[i].active) {
			height += menu->vpad + menu->items[i].size.height;
			text_width = get_str_width_big(menu->items[i].header_text.text1);
			if ((text_width + (2*menu->hpad)) > width) {
				width = text_width + (2*menu->hpad);
			} 
		}
	}
	
	uint32_t absolute_x = menu->pos.x + (WIDTH_W/2) - (width/2);
	uint32_t absolute_y = menu->pos.y + (HEIGHT_W/2) - (height/2);
	rectangle_filled(absolute_x, absolute_y, width, height, menu->bg);
	
	if (menu->header.active)
		absolute_y += draw_item(&menu->header, absolute_x, absolute_y);
	
	absolute_x += menu->hpad;
	absolute_y += menu->vpad;
	for (i=0; i<10; i++) {
		if (menu->items[i].active)
			absolute_y += menu->vpad + draw_menuitem(&menu->items[i], absolute_x, absolute_y);
	}
}
Exemplo n.º 8
0
void draw_plant(
    GLuint position_buffer, GLuint normal_buffer, GLuint uv_buffer,
    GLuint position_loc, GLuint normal_loc, GLuint uv_loc)
{
    draw_item(
        position_buffer, normal_buffer, uv_buffer,
        position_loc, normal_loc, uv_loc, 24);
}
Exemplo n.º 9
0
void draw_cube(
    GLuint position_buffer, GLuint normal_buffer, GLuint uv_buffer,
    GLuint position_loc, GLuint normal_loc, GLuint uv_loc)
{
    draw_item(
        position_buffer, normal_buffer, uv_buffer,
        position_loc, normal_loc, uv_loc, 36);
}
Exemplo n.º 10
0
static void render_screen(int page, int *maxindex)
{
    DIR dir;
    FILINFO file;
    
    __Clear_Screen(0);
    draw_menubar("Run", "Refresh", "", "About");
    
    f_opendir(&dir, "/");
    if (!seek_dir(page, &dir, &file))
    {
        debugf("Directory seek failed");
        return;
    }
    
    int i;
    for (i = 0; i < ICONS_ON_SCREEN; )
    {
        if (f_readdir(&dir, &file) != 0 || file.fname[0] == 0)
            break;
        
        if (is_a_script(file.fname))
        {
            uint32_t icon_buf[32];
            const uint32_t *icon = default_icon;
            int icon_size = 0;
            char name[20] = {0};
            
            if (get_program_metadata(file.fname, icon_buf, &icon_size, name, sizeof(name)))
            {
                if (icon_size != 0)
                {
                    icon = icon_buf;
                }
            }
            
            if (icon == default_icon)
                icon_size = DEFAULT_ICON_HEIGHT;
            
            if (name[0] == 0)
                memcpy(name, file.fname, 13);
            
            draw_item(i, icon, icon_size, name, "");
            i++;
        }
    }
    
    if (f_readdir(&dir, &file) == 0 && file.fname[0] != 0)
        i++;
    
    *maxindex = i;
    
    if (*maxindex == 0)
    {
        draw_text("Please copy some .AMX files to the USB drive :)", 200, 100, 0xFFFF, 0, true);
    }
}
Exemplo n.º 11
0
Arquivo: ui.c Projeto: JBarrada/fancy
void draw_list(LIST *list, uint32_t a_x, uint32_t a_y) {
	int i;
	
	list->size.height = list->vpad + get_item_displacement(&list->header);
	for (i=0; i<6; i++) 
		list->size.height += get_item_displacement(&list->items[i]) + ((list->items[i].active)?list->vpad:0);
	
	uint32_t absolute_x = a_x + list->pos.x;
	uint32_t absolute_y = a_y + list->pos.y;
	rectangle_filled(absolute_x, absolute_y, list->size.width, list->size.height, list->bg);
	
	if (list->header.active)
		absolute_y += draw_item(&list->header, absolute_x, absolute_y);
	
	absolute_x += list->hpad;
	absolute_y += list->vpad;
	for (i=0; i<6; i++) {
		if (list->items[i].active)
			absolute_y += list->vpad + draw_item(&list->items[i], absolute_x, absolute_y);
	}
}
Exemplo n.º 12
0
//draws a NUM_MIX_SLOTSx1 grid of items+grid
static int draw_production_pipe(window_info *win, int x, int y, int recipe_num){
	int i,ofs,valid;
	Uint8 str[80];
	item *the_list;

	//if recipe_num is negative we draw the current manufacture_list, else a recipe
	if (recipe_num<0) {
		the_list=manufacture_list;
		ofs=MIX_SLOT_OFFSET;
		valid=1;
	} else {
		the_list=recipes_store[recipe_num].items;
		ofs=0;
		valid=recipes_store[recipe_num].status;
	}

	glEnable(GL_TEXTURE_2D);
	//ok, now let's draw the mixed objects
	for(i=ofs;i<NUM_MIX_SLOTS+ofs;i++) {
		glColor3f(1.0f,1.0f,1.0f);
		if(the_list[i].quantity > 0){
			int x_start,y_start;
			int use_large = (mouse_over_pipe_pos == i-ofs) && enlarge_text();
			int y_offset = SLOT_SIZE - ((use_large) ?win->default_font_len_y :win->small_font_len_y);

			//get the x and y
			x_start=x+SLOT_SIZE*(i%NUM_MIX_SLOTS)+1;
			y_start=y;

			draw_item(the_list[i].image_id,x_start,y_start,SLOT_SIZE);
			safe_snprintf((char *)str, sizeof(str), "%i", the_list[i].quantity);

			if (use_large)
				draw_string_shadowed_zoomed(x_start, y_start+y_offset, (unsigned char*)str, 1, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, win->current_scale);
			else
				draw_string_small_shadowed_zoomed(x_start, y_start+y_offset, (unsigned char*)str, 1, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, win->current_scale);

			if (!valid)
				gray_out(x_start,y_start,SLOT_SIZE);
		}
	}
	glDisable(GL_TEXTURE_2D);

	//draw the grid, in red if selected
	if (recipe_num==cur_recipe) glColor3f(1.0f,0.0f,0.0f);
	else glColor3f(0.77f,0.57f,0.39f);
	rendergrid(NUM_MIX_SLOTS,1,x, y, SLOT_SIZE, SLOT_SIZE);

	glEnable(GL_TEXTURE_2D);
	return 1;
}
static HRESULT draw_background(uxgtk_theme_t *theme, cairo_t *cr, int part_id, int state_id,
                               int width, int height)
{
    header_theme_t *header_theme = impl_from_uxgtk_theme_t(theme);

    switch (part_id)
    {
        case HP_HEADERITEM:
            return draw_item(header_theme, cr, state_id, width, height);
    }

    FIXME("Unsupported header part %d.\n", part_id);
    return E_NOTIMPL;
}
Exemplo n.º 14
0
void w_plugins::draw_items(SDL_Surface* s) const 
{
	Plugins::iterator i = m_plugins.begin();
	int16 x = rect.x + get_theme_space(LIST_WIDGET, L_SPACE);
	int16 y = rect.y + get_theme_space(LIST_WIDGET, T_SPACE);
	uint16 width = rect.w - get_theme_space(LIST_WIDGET, L_SPACE) - get_theme_space(LIST_WIDGET, R_SPACE);
	
	for (size_t n = 0; n < top_item; ++n)
	{
		++i;
	}
	
	for (size_t n = top_item; n < top_item + MIN(shown_items, num_items); ++n, ++i, y = y + item_height())
		draw_item(i, s, x, y, width, n == selection && active);
}
Exemplo n.º 15
0
void handle_exposure_event(lstate *state)
{
	GR_EVENT_EXPOSURE *event = &state->event.exposure;
	litem *i = state->litems;

	if(event->wid == state->main_window) return;

	while(i) {
		if(event->wid == i->wid) {
			draw_item(state, i);
			return;
		}
		i = i->next;
	}

	GrError("Got exposure event for unknown window %d\n", event->wid);
}
Exemplo n.º 16
0
//draws a 6x1 grid of items+grid
int draw_production_pipe(int x, int y, int recipe_num){
	int i,ofs,valid;
	Uint8 str[80];
	item *the_list;

	//if recipe_num is negative we draw the current manufacture_list, else a recipe	
	if (recipe_num<0) {
		the_list=manufacture_list;
		ofs=36;
		valid=1;
	} else {
		the_list=recipes[recipe_num];
		ofs=0;
		valid=recipe_status[recipe_num];
	}

	glEnable(GL_TEXTURE_2D);
	//ok, now let's draw the mixed objects
	for(i=ofs;i<6+ofs;i++) {
		glColor3f(1.0f,1.0f,1.0f);
		if(the_list[i].quantity > 0){
			int x_start,y_start;

			//get the x and y
			x_start=x+33*(i%6)+1;
			y_start=y;

			draw_item(the_list[i].image_id,x_start,y_start,33);
			safe_snprintf((char *)str, sizeof(str), "%i", the_list[i].quantity);
			draw_string_small_shadowed(x_start,y_start+17,str,1,1.0f,1.0f,1.0f,0.0f,0.0f,0.0f);

			if (!valid)
				gray_out(x_start,y_start,33);
		}
	}
	glDisable(GL_TEXTURE_2D);
	
	//draw the grid, in red if selected
	if (recipe_num==cur_recipe) glColor3f(1.0f,0.0f,0.0f);
	else glColor3f(0.77f,0.57f,0.39f);
	rendergrid(6,1,x, y, 33, 33);

	glEnable(GL_TEXTURE_2D);
	return 1;
}
Exemplo n.º 17
0
void svg_renderer::update_cache_item (const renderable_item *item, const render_cache_id &cache_id, const QTransform &transform,
                                      renderer_config &cfg, int total_x, int total_y)
{
  int block_size = rendered_items_cache::block_pixel_size ();
  SkBitmap bitmap;
  bitmap.setConfig (SkBitmap::kARGB_8888_Config, block_size * total_x, block_size * total_y);
  bitmap.allocPixels ();
  SkBitmapDevice device (bitmap);
  SkCanvas canvas (&device);
  canvas.drawColor (SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode);

  QRectF local_rect = cache_id.pixel_rect (transform);
  QTransform last_inverted = transform.inverted ();
  QPointF last_pos_local = last_inverted.map (QPointF (0, 0));
  QPointF cur_pos_local = last_inverted.map (QPointF (local_rect.x (), local_rect.y ()));
  QPointF diff = -cur_pos_local + last_pos_local;

  QTransform pixmap_transform = QTransform (transform).translate (diff.x (), diff.y ());
  renderer_state state (QRect (0, 0, block_size * total_x, block_size * total_y), pixmap_transform);
  draw_item (item, canvas, state, cfg);

  if (m_queue->is_interrupted ())
    return;

  if (total_x == total_y && total_x == 1)
    m_cache->add_bitmap (cache_id, bitmap, cfg.use_new_cache ());
  else
    {
      for (int i = 0; i < total_x; i++)
        for (int j = 0; j < total_y; j++)
          {
            render_cache_id cur_id (cache_id.x () + i, cache_id.y () + j, cache_id.object_type ());
            SkBitmap bitmap_part;
            DEBUG_ASSERT (bitmap.extractSubset (&bitmap_part, SkIRect::MakeXYWH (i * block_size, j * block_size, block_size, block_size)));
            m_cache->add_bitmap (cur_id, bitmap_part, cfg.use_new_cache ());
          }
    }

}
Exemplo n.º 18
0
/* Draw the current menu. */
void
Menu::draw()
{
  int menu_height = get_height();
  int menu_width  = get_width();

  /* Draw a transparent background */
#ifndef RES320X240
  fillrect(pos_x - menu_width/2,
           pos_y - 24*item.size()/2 - 10,
           menu_width,menu_height + 20,
           150,180,200,125);
#else
  fillrect(pos_x - menu_width/4,
           pos_y - 24*item.size()/2 - 10,
           menu_width,menu_height + 20,
           150,180,200,125);
#endif

  for(unsigned int i = 0; i < item.size(); ++i)
  {
    draw_item(i, menu_width, menu_height);
  }
}
Exemplo n.º 19
0
static void draw_node(node_t *node, void *arg)
{
	int i, *cnt = (int *) arg;

	if (cnt) {
		if (*cnt) {
			int n;
			NEXT_ROW;
			for (n = 1; n < cols; n += 2)
				mvaddch(row, n, ACS_HLINE);
			move(row, 28);
			addch(ACS_VLINE);
			move(row, 54);
			addch(ACS_VLINE);
		}
		(*cnt)++;
	}

	attrset(A_BOLD);
	NEXT_ROW; 
	if (c_nosource)
		putl("%s", node->n_name);
	else
		putl("%s (%s)", node->n_name,
			node->n_from ? node->n_from : "local");

	move(row, 30);
	putl("     Rate         #   %%        Rate         #   %%");
	attroff(A_BOLD);

	move(row, 28);
	addch(ACS_VLINE);
	move(row, 54);
	addch(ACS_VLINE);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_LIST) | layout[LAYOUT_LIST].attr);

	for (i = 0; i < node->n_nitems; i++)
		draw_item(node, &node->n_items[i]);

	if (!c_nototal) {
		int rx_maj_prec, tx_maj_prec, rx_min_prec, tx_min_prec;
		double rx_maj, tx_maj, rx_min, tx_min;
		char *rx_maj_u, *tx_maj_u, *rx_min_u, *tx_min_u;
		
		rx_maj = cancel_down(node->n_rx_maj_total, U_BYTES, &rx_maj_u, &rx_maj_prec);
		tx_maj = cancel_down(node->n_tx_maj_total, U_BYTES, &tx_maj_u, &tx_maj_prec);

		rx_min = cancel_down(node->n_rx_min_total, U_NUMBER, &rx_min_u, &rx_min_prec);
		tx_min = cancel_down(node->n_tx_min_total, U_NUMBER, &tx_min_u, &tx_min_prec);

		NEXT_ROW;
		putl("  %-26s %8.*f%s %8.*f%s     %8.*f%s %8.*f%s    ", "Total",
		    rx_maj_prec, rx_maj, rx_maj_u, rx_min_prec, rx_min, rx_min_u,
		    tx_maj_prec, tx_maj, tx_maj_u, tx_min_prec, tx_min, tx_min_u);

		move(row, 28);
		addch(ACS_VLINE);
		move(row, 54);
		addch(ACS_VLINE);
	}

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr);
}
Exemplo n.º 20
0
void editor_palette<Item>::draw_contents()
{
	toolkit_.set_mouseover_overlay(gui_);

	std::shared_ptr<gui::button> palette_menu_button = gui_.find_menu_button("menu-editor-terrain");
	if (palette_menu_button) {

		t_string& name = groups_[active_group_index()].name;
		std::string& icon = groups_[active_group_index()].icon;

		palette_menu_button->set_tooltip_string(name);
		palette_menu_button->set_overlay(icon);
	}

	unsigned int y = palette_y_;
	unsigned int x = palette_x_;
	int starting = items_start_;
	int ending = std::min<int>(starting + nitems_, num_items());

	std::shared_ptr<gui::button> upscroll_button = gui_.find_action_button("upscroll-button-editor");
	if (upscroll_button)
		upscroll_button->enable(starting != 0);
	std::shared_ptr<gui::button> downscroll_button = gui_.find_action_button("downscroll-button-editor");
	if (downscroll_button)
		downscroll_button->enable(ending != num_items());


	int counter = starting;
	for (int i = 0, size = num_visible_items(); i < size ; ++i) {
		//TODO check if the conditions still hold for the counter variable
		//for (unsigned int counter = starting; counter < ending; counter++)

		gui::tristate_button& tile = buttons_[i];

		tile.hide(true);

		if (i >= ending) continue;

		const std::string item_id = active_group()[counter];
		//typedef std::map<std::string, Item> item_map_wurscht;
		typename item_map::iterator item = item_map_.find(item_id);

		surface item_image(nullptr);
		std::stringstream tooltip_text;
		draw_item((*item).second, item_image, tooltip_text);

		bool is_core = non_core_items_.find(get_id((*item).second)) == non_core_items_.end();
		if (!is_core) {
			tooltip_text << " "
					<< font::span_color(font::BAD_COLOR)
			<< _("(non-core)") << "\n"
			<< _("Will not work in game without extra care.")
			<< "</span>";
		}

		const int counter_from_zero = counter - starting;
		SDL_Rect dstrect;
		dstrect.x = x + (counter_from_zero % item_width_) * item_space_;
		dstrect.y = y;
		dstrect.w = item_size_ + 2;
		dstrect.h = item_size_ + 2;

		tile.set_location(dstrect);
		tile.set_tooltip_string(tooltip_text.str());
		tile.set_item_image(item_image);
		tile.set_item_id(item_id);

//		if (get_id((*item).second) == selected_bg_item_
//				&& get_id((*item).second) == selected_fg_item_) {
//			tile.set_pressed(gui::tristate_button::BOTH);
//		} else if (get_id((*item).second) == selected_bg_item_) {
//			tile.set_pressed(gui::tristate_button::RIGHT);
//		} else if (get_id((*item).second) == selected_fg_item_) {
//			tile.set_pressed(gui::tristate_button::LEFT);
//		} else {
//			tile.set_pressed(gui::tristate_button::NONE);
//		}

		if (is_selected_bg_item(get_id(item->second))
				&& is_selected_fg_item(get_id(item->second))) {
			tile.set_pressed(gui::tristate_button::BOTH);
		} else if (is_selected_bg_item(get_id(item->second))) {
			tile.set_pressed(gui::tristate_button::RIGHT);
		} else if (is_selected_fg_item(get_id(item->second))) {
			tile.set_pressed(gui::tristate_button::LEFT);
		} else {
			tile.set_pressed(gui::tristate_button::NONE);
		}

		tile.set_dirty(true);
		tile.hide(false);
		tile.draw();

		// Adjust location
		if (counter_from_zero % item_width_ == item_width_ - 1)
			y += item_space_;
		++counter;
	}
}
Exemplo n.º 21
0
static int	display_manufacture_handler(window_info *win)
{
	Uint8 str[80];
	int i;

	// keep the main and recipe windows opacity in sync
	if (recipe_win >= 0)
	{
		static int last_recipes_opaque = -1, last_main_opaque = -1;
		if (win->opaque != last_main_opaque)
			last_recipes_opaque = last_main_opaque = windows_list.window[recipe_win].opaque = win->opaque;
		else if (windows_list.window[recipe_win].opaque != last_recipes_opaque)
			last_recipes_opaque = last_main_opaque = win->opaque = windows_list.window[recipe_win].opaque;
	}

	glColor3f(0.77f,0.57f,0.39f);
	glEnable(GL_TEXTURE_2D);

	glColor3f(1.0f,1.0f,1.0f);
	//ok, now let's draw the objects...
	for(i=35;i>=0;i--){
		if(manufacture_list[i].quantity > 0) {
			int x_start,y_start;
			int use_large = (mouse_over_main_pos == i) && enlarge_text();

			//get the x and y
			x_start=SLOT_SIZE*(i%GRID_COLS)+1;
			y_start=SLOT_SIZE*(i/GRID_COLS);

			draw_item(manufacture_list[i].image_id,x_start,y_start,SLOT_SIZE);

			safe_snprintf((char *)str, sizeof(str), "%i",manufacture_list[i].quantity);
			y_start += (i&1) ? 2 : SLOT_SIZE - ((use_large) ?win->default_font_len_y :win->small_font_len_y);
			if (use_large)
				draw_string_shadowed_zoomed(x_start, y_start, (unsigned char*)str, 1, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, win->current_scale);
			else
				draw_string_small_shadowed_zoomed(x_start, y_start, (unsigned char*)str, 1, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, win->current_scale);
		}
	}

	//ok, now let's draw the mixed objects
	draw_production_pipe(win, pipeline_x,manufacture_menu_y_len-recipe_y_offset, -1);

	//now, draw the inventory text, if any.
	if (last_items_string_id != inventory_item_string_id)
	{
		put_small_text_in_box_zoomed((unsigned char*)inventory_item_string, strlen(inventory_item_string), win->len_x-2*win->small_font_len_x, items_string, win->current_scale);
		last_items_string_id = inventory_item_string_id;
	}
	draw_string_small_zoomed(win->small_font_len_x,manufacture_menu_y_len-text_y_offset,(unsigned char *)items_string,4, win->current_scale);

	// Render the grid *after* the images. It seems impossible to code
	// it such that images are rendered exactly within the boxes on all
	// cards
	glDisable(GL_TEXTURE_2D);
	glColor3f(0.77f,0.57f,0.39f);

	//draw the grid
	rendergrid(GRID_COLS, GRID_ROWS, 0, 0, SLOT_SIZE, SLOT_SIZE);

	//Draw recipe control buttons
	draw_recipe_controls(win);
	glEnable(GL_TEXTURE_2D);

	mouse_over_main_pos = -1;
	mouse_over_pipe_pos = -1;

#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
	return 1;
}
Exemplo n.º 22
0
int	display_manufacture_handler(window_info *win)
{
	Uint8 str[80];
	int i;

	//dirty hack for opacity
	//if manufacture_win is opaque then recipe_win should be and viceversa
	if (recipes_shown) win->opaque=windows_list.window[recipe_win].opaque;
	else windows_list.window[recipe_win].opaque=win->opaque;	

	glColor3f(0.77f,0.57f,0.39f);
	glEnable(GL_TEXTURE_2D);

	glColor3f(1.0f,1.0f,1.0f);
	//ok, now let's draw the objects...
	for(i=35;i>=0;i--){
		if(manufacture_list[i].quantity > 0) {
			int x_start,y_start;

			//get the x and y
			x_start=33*(i%12)+1;
			y_start=33*(i/12);

			draw_item(manufacture_list[i].image_id,x_start,y_start,33);
			
			safe_snprintf((char *)str, sizeof(str), "%i",manufacture_list[i].quantity);
			draw_string_small_shadowed(x_start, (i&1)?(y_start+17):(y_start+7), (unsigned char*)str, 1,1.0f,1.0f,1.0f, 0.0f, 0.0f, 0.0f);
		}
	}

	//ok, now let's draw the mixed objects
	draw_production_pipe(2,manufacture_menu_y_len-37, -1);

	//now, draw the inventory text, if any.
	if (last_items_string_id != inventory_item_string_id)
	{		
		put_small_text_in_box((unsigned char*)inventory_item_string, strlen(inventory_item_string), win->len_x-8, items_string);
		last_items_string_id = inventory_item_string_id;
	}
	draw_string_small(4,manufacture_menu_y_len-85,(unsigned char *)items_string,4);

	// Render the grid *after* the images. It seems impossible to code
	// it such that images are rendered exactly within the boxes on all 
	// cards
	glDisable(GL_TEXTURE_2D);
	glColor3f(0.77f,0.57f,0.39f);
	
	//draw the grid
	rendergrid(12,3,0,0,33,33);
	
	//Draw the bottom grid - NOT NEEDED, DONE IN draw_production_pipe
	//rendergrid(6,1,0, manufacture_menu_y_len-37, 33, 33);

	//Draw recipe control buttons
	draw_recipe_controls();
	glEnable(GL_TEXTURE_2D);

#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
	return 1;
}
Exemplo n.º 23
0
	// Draw the item list window
	//
	int List_Window::draw(window_info *win)
	{
		Vars::lists()->check_and_timed_save(false);

		// if resizing wait until we stop
		if (win->resized)
			resizing = true;
		// once we stop, snap the window size to fix nicely
		else if (resizing)
		{
			calc_num_show_names(win->len_y);
			resizing = false;
			resize_window (win->window_id, get_size_x(), get_size_y());
		}

		// check if we need to change the number of grid rows shown
		int new_num_grid_rows = min_grid_rows();
		if (Vars::lists()->valid_active_list())
			new_num_grid_rows = std::max(static_cast<size_t>(new_num_grid_rows), (Vars::lists()->get_list().get_num_items() +5) / 6);
		if (num_grid_rows != new_num_grid_rows)
		{
			num_grid_rows = new_num_grid_rows;
			resized_name_panel(win);
		}

		glEnable(GL_TEXTURE_2D);

		// draw the images
		if (Vars::lists()->valid_active_list())
		{
			glColor3f(1.0f,1.0f,1.0f);
			for(size_t i=0; i<Vars::lists()->get_list().get_num_items() && i<static_cast<size_t>(6*num_grid_rows); i++)
			{
				int x_start, y_start;
				x_start = get_grid_size() * (i%6) + 1;
				y_start = get_grid_size() * (i/6);
				draw_item(Vars::lists()->get_list().get_image_id(i), x_start, y_start, get_grid_size());
			}
		}

		size_t help_lines_shown = 0;

		// Display any name search text
		if (strlen(filter))
		{
			if (SDL_GetTicks() > (last_key_time+5000))
			{
				filter[0] = '\0';
				last_key_time = 0;
			}
			else
			{
				std::string tmp = std::string(item_list_find_str) + std::string("[") + std::string(filter) + std::string("]");
				show_help(tmp.c_str(), 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown++));
			}
		}

		// draw mouse over window help text
		if (show_help_text)
		{
			if (!resizing)
				for (size_t i=0; i<help_str.size(); ++i)
					show_help(help_str[i], 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown++));
			help_str.clear();
		}

		glDisable(GL_TEXTURE_2D);

		// draw the item grid
		glColor3f(0.77f,0.57f,0.39f);
		rendergrid(6, num_grid_rows, 0, 0, get_grid_size(), get_grid_size());

		// if an object is selected, draw a green grid around it
		if (Vars::lists()->valid_active_list() && (quantities.selected == ITEM_EDIT_QUANT) && (selected_item_number < Vars::lists()->get_list().get_num_items()))
		{
			int x_start = selected_item_number%6 * get_grid_size();
			int y_start = static_cast<int>(selected_item_number/6) * get_grid_size();
			if ((SDL_GetTicks() - il_pickup_fail_time) < 250)
				glColor3f(0.8f,0.2f,0.2f);
			else
				glColor3f(0.0f, 1.0f, 0.3f);
			rendergrid(1, 1, x_start, y_start, get_grid_size(), get_grid_size());
			rendergrid(1, 1, x_start-1, y_start-1, get_grid_size()+2, get_grid_size()+2);
		}

		glEnable(GL_TEXTURE_2D);

		// draw the quantities over everything else so they always show
		if (Vars::lists()->valid_active_list())
		{
			glColor3f(1.0f,1.0f,1.0f);
			char str[80];
			for(size_t i=0; i<Vars::lists()->get_list().get_num_items() && i<static_cast<size_t>(6*num_grid_rows); i++)
			{
				int x_start, y_start, y_end;
				x_start = get_grid_size() * (i%6) + 1;
				y_start = get_grid_size() * (i/6);
				y_end = y_start + get_grid_size() - 1;
				safe_snprintf(str, sizeof(str), "%i", Vars::lists()->get_list().get_quantity(i));
				draw_string_small_shadowed(x_start, (i&1)?(y_end-15):(y_end-27), (unsigned char*)str, 1,1.0f,1.0f,1.0f, 0.0f, 0.0f, 0.0f);
			}
		}

		// Drawn the new list button (+) with highlight when mouse over
		if (mouse_over_add_button)
			glColor3f(0.99f,0.77f,0.55f);
		else
			glColor3f(0.77f,0.57f,0.39f);
		draw_string_zoomed(add_button_x, add_button_y, (unsigned const char*)"+", 1, 2.0);

		// draw the item list names
		glColor3f(1.0f,1.0f,1.0f);
		int pos_y = get_grid_size()*num_grid_rows + get_list_gap();
		int num_shown = 0;
		const int top_entry = vscrollbar_get_pos (win_id, names_scroll_id);
		const std::vector<List> lists = Vars::lists()->get_lists();
		const int hl_width = static_cast<int>(win->len_x-ELW_BOX_SIZE-3);
		const int hl_height = static_cast<int>(names_list_height + get_list_gap());
		const size_t disp_chars = static_cast<size_t>((win->len_x-ELW_BOX_SIZE-2*get_list_gap()) / SMALL_FONT_X_LEN);
		for (size_t i = top_entry; i<lists.size() && num_shown<num_show_names_list; ++i)
		{
			if (i==Vars::lists()->get_active())
				draw_highlight(1, static_cast<int>(pos_y-get_list_gap()/2), hl_width, hl_height, 1);
			else if (i==name_under_mouse)
				draw_highlight(1, static_cast<int>(pos_y-get_list_gap()/2), hl_width, hl_height, 0);
			glColor3f(1.0f,1.0f,1.0f);
			if (lists[i].get_name().size() > disp_chars)
			{
				std::string todisp = lists[i].get_name().substr(0,disp_chars);
				draw_string_small(get_list_gap(), pos_y, reinterpret_cast<const unsigned char*>(todisp.c_str()), 1);
				if (i==name_under_mouse)
					show_help(lists[i].get_name().c_str(), 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown));
			}
			else
				draw_string_small(get_list_gap(), pos_y, reinterpret_cast<const unsigned char*>(lists[i].get_name().c_str()), 1);
			pos_y += static_cast<int>(names_list_height + get_list_gap());
			num_shown++;
		}

		if (clicked && (name_under_mouse < lists.size()))
		{
			do_click_sound();
			Vars::lists()->set_active(name_under_mouse);
		}

		if (clicked && mouse_over_add_button)
		{
			do_click_sound();
			new_or_rename_list(true);
		}
		name_under_mouse = static_cast<size_t>(-1);
		mouse_over_add_button = clicked = false;

#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
		return 1;
	}