コード例 #1
0
ファイル: draw_card.cpp プロジェクト: davewx7/Wizard-Tactics
rect draw_card(const_card_ptr c, int x, int y)
{
	const rect area(x, y, 108, 120);
	graphics::blit_texture(graphics::texture::get("card.png"), x, y);

	const std::string* monster = c->monster_id();
	if(monster) {
		const_unit_avatar_ptr a = get_avatar(*monster);
		if(a) {
			a->draw(x + 40, y + 70);
		}
	}

	const std::string* land = c->land_id();
	if(land) {
		const_terrain_ptr t = terrain::get(*land);
		if(t) {
			graphics::texture tex(graphics::texture::get(t->texture()));
			graphics::blit_texture(tex, x + 40 - tex.width()/2, y + 65 - tex.height()/2);
			if(!t->overlay_texture().empty()) {
				graphics::blit_texture(graphics::texture::get(t->overlay_texture()), x - 45, y - 35);
			}
		}
	}


	int cost_pos = x + 82;
	int cost_pos_y = y + 8;
	for(int n = resource::num_resources()-1; n != -1; --n) {
		char buf[128];
		sprintf(buf, "magic-icon-%c", resource::resource_id(n));

		const_gui_section_ptr section = gui_section::get(buf);

		for(int m = 0; m != c->cost(n); ++m) {
			section->blit(cost_pos, cost_pos_y, 16, 16);
			cost_pos -= 16;
			if(cost_pos < x) {
				cost_pos = x + 72;
				cost_pos_y += 16;
			}
		}
	}

	graphics::blit_texture(font::render_text(c->name(), graphics::color_white(), 12), x + 8, cost_pos_y + 18);

	return area;
}
コード例 #2
0
static void
set_avatar (GrlData *data,
            GrlKeyID key)
{
  gint length, i;
  GrlRelatedKeys *relkeys;
  gchar *avatar_url;

  length = grl_data_length (data, key);

  for (i = 0; i < length; i++) {
    relkeys = grl_data_get_related_keys (data, key, i);
    avatar_url = get_avatar (grl_related_keys_get_string (relkeys, key));
    if (avatar_url) {
      grl_related_keys_set_string (relkeys, key, avatar_url);
      g_free (avatar_url);
    }
  }
}
コード例 #3
0
ファイル: acc.cpp プロジェクト: baffles/sh05
int main(int argc, char **argv)
{
  //CURL *curl_handle;
  FILE *rfptmp;
  BITMAP *buffer;
  char request[512], rfpname[256];
  
  int len, num_posts, i;
  char *title, *xml;
  typedef struct _pl_
  {
    int id;
    char *poster;
    int posterid;
    char *postdate;
    char *post;
    BITMAP *avatar;
  } postlist;
  postlist *posts;
  
  if(argc != 2)
  {
    printf("Usage: %s [a.cc username]\n", argv[0]);
    return -1;
  }
  sprintf(request, "http://www.bafsoft.net/acc_cache/user.php?usr=%s&cmd=rfp", argv[1]);
  sprintf(rfpname, "temp/%s.rfp", argv[1]);
  printf("%s\n", request);
  
  /*temp = fopen(rfpname, "wb");
  curl_global_init(CURL_GLOBAL_ALL);
  curl_handle = curl_easy_init();
  curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
  curl_easy_setopt(curl_handle, CURLOPT_HEADER, 0);
  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, fwrite);
  curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)temp);
	curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
	curl_easy_setopt(curl_handle, CURLOPT_URL, request);
  curl_easy_perform(curl_handle);
  //curl_easy_cleanup(curl_handle);
  fclose(temp);*/
	curl.download(request, rfpname);
  
  /** printf("%d%s", strlen($rfp['title']), $rfp['title']);
  printf("%d%s", strlen($rfp['xml']), $rfp['xml']);
  printf("%d ", $rfp['pcount']);
  for($i = 0; $i < $rfp['pcount']; $i++)
  {
    printf("%d%s", strlen($rfp['posts'][$i]['poster']), $rfp['posts'][$i]['poster']);
    printf("%d ", $rfp['posts'][$i]['posterid']);
    printf("%d%s", strlen($rfp['posts'][$i]['postdate']), $rfp['posts'][$i]['postdate']);
    printf("%d %s ", strlen($rfp['posts'][$i]['post']), $rfp['posts'][$i]['post']);
  }**/ /// typedef struct { int id; char *poster, int posterid; char *postdate; char *post; } postlist;
  
  printf("Lets go to allegro...\n");
  allegro_init();
  install_keyboard();
  set_color_depth(32);
  set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1024, 768, 0, 0);
  buffer = create_bitmap(1024, 768);
  
  rfptmp = fopen(rfpname, "rb");
  
  fscanf(rfptmp, "%d", &len);
  title = (char *)malloc(len + 1);
  fread(title, len, 1, rfptmp); title[len] = 0;
  
  fscanf(rfptmp, "%d", &len);
  xml = (char *)malloc(len + 1);
  fread(xml, len, 1, rfptmp); xml[len] = 0;
  
  fscanf(rfptmp, "%d ", &num_posts);
  posts = (postlist *)malloc(sizeof(postlist) * num_posts);
  for(i = 0; i < num_posts; ++i)
  {
    posts[i].id = i;
    fscanf(rfptmp, "%d", &len);
    posts[i].poster = (char *)malloc(len + 1);
    fread(posts[i].poster, len, 1, rfptmp); posts[i].poster[len] = 0;
    fscanf(rfptmp, "%d ", &posts[i].posterid);
    fscanf(rfptmp, "%d", &len);
    posts[i].postdate = (char *)malloc(len + 1);
    fread(posts[i].postdate, len, 1, rfptmp); posts[i].postdate[len] = 0;
    fscanf(rfptmp, "%d ", &len);
    posts[i].post = (char *)malloc(len + 1);
    fread(posts[i].post, len, 1, rfptmp); posts[i].post[len] = 0;
    printf("Avatar %d\n", i);
    posts[i].avatar = get_avatar(posts[i].posterid);
    
    //printf("DOWNLOADING AVATARS... (%d/%d) %d%% done\r", i + 1, num_posts, (int)(((float)(i + 1) / (float)num_posts) * 100));
    clear_bitmap(buffer);
    textprintf_ex(buffer, font, 50, 50, makecol(255,255,255), -1, "Downloading Avatars....");
    textprintf_ex(buffer, font, 70, 70, makecol(255,255,255), -1, "(%d/%d) %d%%", i + 1, num_posts, (int)(((float)(i + 1) / (float)num_posts) * 100));
    /// 668 -> 868
    rect(buffer, 412, 100, 612, 150, makecol(255,255,255));
    rectfill(buffer, 413, 101, 412 + (2 * (int)(((float)(i + 1) / (float)num_posts) * 100)), 149, makecol(0,0,255));
    blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
  }
	//curl_easy_perform(curl_handle);
  //curl_easy_cleanup(curl_handle);
  clear_bitmap(screen);
  
  //set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0);
  //printf("Topic: %s  XML URL: %s  Number of Posts: %d\n", title, xml, num_posts);
  //for(i = 0; i < (num_posts < 9 ? num_posts : 9); ++i)
  for(i = 0; i < (num_posts < (SCREEN_W / 96) ? num_posts : (SCREEN_W / 96)); ++i)
  {
    //printf("Post %d  Posted by: %s [%d]  %s\n============================================================================\n%s\n============================================================================\n", i, posts[i].poster, posts[i].posterid, posts[i].postdate, posts[i].post);
    /// 96 height for each
    printf("\n%d", i);
    blit(posts[i].avatar, screen, 0, 0, 8, (i * 96) + 14, 80, 80);
    textprintf_ex(screen, font, 8, (i * 96) + 2, makecol(255,255,255), -1, "%s [%d]", posts[i].poster, posts[i].posterid);
    
    ///textprintf_ex(screen, font, 100, (i * 96) + 2 + text_height(font), makecol(255,255,255), -1, "%s", posts[i].post);
    do_wrapped_text(screen, font, 100, ((i * 96) + 2) + text_height(font), SCREEN_W - 102, (94 - text_height(font)) / text_height(font), makecol(255,255,255), -1, posts[i].post);
  }
  
  while(!keypressed())
    ;
  
  for(i = 0; i < num_posts; ++i)
  {
    free(posts[i].poster);
    free(posts[i].postdate);
    free(posts[i].post);
    //destroy_bitmap(posts[i].avatar);
  }
  free(posts);
  clean_avatars();

  return 0;
}