/********************************** Show tiles types **********************************/ static void compose_type(context_t * ctx,int layer_index) { int x = 0; int y = 0; item_t * item; char * type; static TTF_Font * font = NULL; int w; int h; char layer_name[SMALL_BUF]; if( option->show_tile_type == false) { return; } sprintf(layer_name,"%s%d",MAP_KEY_LAYER,layer_index); if( entry_exist(MAP_TABLE, ctx->map, layer_name,MAP_KEY_TYPE,NULL) == false ) { return; } font = font_get(ctx,ITEM_FONT, ITEM_FONT_SIZE); for( x=0; x<default_layer->map_w; x++) { for( y=0; y<default_layer->map_h; y++) { if(entry_read_list_index(MAP_TABLE,ctx->map,&type,x + y * default_layer->map_w,layer_name,MAP_KEY_TYPE,NULL) == RET_NOK ) { continue; } if( type[0] == 0 ) { continue; } item = item_list_add(&item_list); item_set_string(item,type); item_set_font(item,font); sdl_get_string_size(item->font,item->string,&w,&h); item_set_anim_shape(item,map_t2p_x(x,y,default_layer),map_t2p_y(x,y,default_layer),w,h); } } }
/********************************** Set sdl_item item for mouse button callback **********************************/ static void compose_map_button(context_t * ctx) { int x = 0; int y = 0; item_t * item; anim_t * anim = NULL; if ( option && option->cursor_over_tile ) { anim = imageDB_get_anim(ctx,option->cursor_over_tile); } for( y=0 ; y < default_layer->map_h ; y++ ) { for ( x=0 ; x < default_layer->map_w ; x++ ) { item = item_list_add(&item_list); item_set_anim_shape(item,map_t2p_x(x,y,default_layer),map_t2p_y(x,y,default_layer),default_layer->tile_width,default_layer->tile_height); item_set_user(item,x,y); item_set_click_left(item,cb_select_map,item,NULL); item_set_click_right(item,cb_redo_map,item,NULL); item_set_over(item,cb_over,item,NULL); item_set_anim_over(item,anim,0); } } }
/****************************************************** create a list of item for the currently selected screen ******************************************************/ static void compose_scr(context_t * context) { static TTF_Font * font = NULL; option_t * option = option_get(); SDL_SetRenderDrawColor(context->render, 0, 0, 0, 255); switch(current_screen) { case SCREEN_SELECT: item_list = scr_select_compose(context); break; case SCREEN_PLAY: item_list = scr_play_compose(context); break; } if( option->show_fps ) { font = font_get(context,ITEM_FONT, ITEM_FONT_SIZE); frame_rate = item_list_add(&item_list); item_set_font(frame_rate,font); item_set_anim_shape(frame_rate,50,50,20,20); item_set_overlay(frame_rate,1); } }