示例#1
0
/***********************************
 camera_set_coord

 Set camera coordinate

 Input:
 - X
 - Y
 Output:
 ***********************************/
static int l_camera_set_coord(lua_State* p_pLuaState)
{
	int l_X;
	l_X = luaL_checknumber(p_pLuaState, -2);
	int l_Y;
	l_Y = luaL_checknumber(p_pLuaState, -1);

	sdl_force_virtual_x(l_X);
	sdl_force_virtual_y(l_Y);

	return 0; // number of results
}
示例#2
0
/************************************************
Select the screen to be rendered
************************************************/
void screen_set_screen(int screen)
{
	if(screen != current_screen) {
		/* Save current virtual coordinates */
		virtual_x[current_screen] = sdl_get_virtual_x();
		virtual_y[current_screen] = sdl_get_virtual_y();
		virtual_z[current_screen] = sdl_get_virtual_z();

		/* Restore previous virtual coordinate */
		if( virtual_x[screen] != INT_MAX ) {
			sdl_force_virtual_x(virtual_x[screen]);
			sdl_force_virtual_y(virtual_y[screen]);
			sdl_force_virtual_z(virtual_z[screen]);
		}

		current_screen = screen;
		context_reset_all_position();
		screen_compose();
	}
}
示例#3
0
/**********************************
Compose the character select screen
**********************************/
item_t * scr_play_compose(context_t * ctx)
{
	int bg_red = 0;
	int bg_blue = 0;
	int bg_green = 0;
	char * map_filename;
	int layer_index = 0;
	char * old_sfx = NULL;

	option = option_get();

	if(item_list) {
		item_list_free(item_list);
		item_list = NULL;
	}

	if(ctx->map == NULL ) {
		if(context_update_from_file(ctx) == RET_NOK) {
			return NULL;
		}
	}

	if(init) {
		/* Register this character to receive server notifications */
		network_request_start(ctx,ctx->id);
		ui_play_init();
		init = false;
	}

	sdl_free_keycb();
	sdl_free_mousecb();
	sdl_add_mousecb(MOUSE_WHEEL_UP,cb_zoom);
	sdl_add_mousecb(MOUSE_WHEEL_DOWN,cb_unzoom);

	change_map = ctx->change_map;

	if( change_map == true ) {
		map_filename = strconcat( MAP_TABLE,"/",ctx->map,NULL);
		network_send_req_file(ctx,map_filename);
		free(map_filename);
		if(default_layer) {
			map_layer_delete(default_layer);
		}
		default_layer = map_layer_new(ctx->map,DEFAULT_LAYER,NULL);
	}

	if( default_layer && default_layer->active ) { // Make sure map data are available
		for(layer_index = 0; layer_index < MAX_LAYER; layer_index++) {
			compose_map_set(ctx,layer_index);
			compose_map_scenery(ctx,layer_index);
			compose_item(ctx,layer_index);
			compose_sprite(ctx,layer_index);
			compose_type(ctx,layer_index);
		}
		compose_map_button(ctx);
		compose_select(ctx);

		ui_play_compose(ctx,item_list);

		// force virtual coordinate on map change
		if( change_map == true ) {
			sdl_force_virtual_x(map_t2p_x(ctx->pos_tx,ctx->pos_ty,default_layer) + default_layer->col_width[ctx->pos_tx%default_layer->col_num]/2 + default_layer->row_width[ctx->pos_ty%default_layer->row_num]/2 );
			sdl_force_virtual_y(map_t2p_y(ctx->pos_tx,ctx->pos_ty,default_layer) + default_layer->col_height[ctx->pos_tx%default_layer->col_num]/2 + default_layer->row_height[ctx->pos_ty%default_layer->row_num]/2 );
		}
		// set virtual coordinate on the same map
		else {
			sdl_set_virtual_x(map_t2p_x(ctx->pos_tx,ctx->pos_ty,default_layer) + default_layer->col_width[ctx->pos_tx%default_layer->col_num]/2 + default_layer->row_width[ctx->pos_ty%default_layer->row_num]/2 );
			sdl_set_virtual_y(map_t2p_y(ctx->pos_tx,ctx->pos_ty,default_layer) + default_layer->col_height[ctx->pos_tx%default_layer->col_num]/2 + default_layer->row_height[ctx->pos_ty%default_layer->row_num]/2 );
		}
	}

	entry_read_int(MAP_TABLE,ctx->map,&bg_red,MAP_KEY_BG_RED,NULL);
	entry_read_int(MAP_TABLE,ctx->map,&bg_blue,MAP_KEY_BG_BLUE,NULL);
	entry_read_int(MAP_TABLE,ctx->map,&bg_green,MAP_KEY_BG_GREEN,NULL);
	SDL_SetRenderDrawColor(ctx->render, bg_red, bg_blue, bg_green, 255);

	old_sfx = sfx;
	sfx = NULL;

	entry_read_string(MAP_TABLE,ctx->map,&sfx,MAP_SFX,NULL);

	if(old_sfx)  {
		if( sfx ) {
			if( strcmp(old_sfx,sfx) ) {
				sfx_stop(ctx,old_sfx);
			}
		} else  { // sfx == NULL
			sfx_stop(ctx,old_sfx);
		}
		free(old_sfx);
	}

	if( sfx && sfx[0]!=0 ) {
		sfx_play(ctx,sfx,NO_RESTART);
	}

	return item_list;
}