Exemplo n.º 1
0
void tool_wind_fix_enable(void)
{
	int			n,nsel,type,index,seg_type,group_idx;
	bool		has_fc_seg;
	
		// add-sub-tesselate vertex buttons
		
	has_fc_seg=FALSE;
	nsel=select_count();
	
	for (n=0;n!=nsel;n++) {
		select_get(0,&type,&index);
		if (type==segment_piece) {
			seg_type=map.segments[index].type;
			if ((seg_type==sg_floor) || (seg_type==sg_ceiling)) {
				has_fc_seg=TRUE;
				break;
			}
		}
	}
	
	if (!has_fc_seg) {
		HiliteControl(tool_ctrl[16],255);
		HiliteControl(tool_ctrl[17],255);
		HiliteControl(tool_ctrl[18],255);
	}
	else {
		HiliteControl(tool_ctrl[16],0);
		HiliteControl(tool_ctrl[17],0);
		HiliteControl(tool_ctrl[18],0);
	}
	
		// group combo
		
	group_idx=-1;
	
	if (select_count()==1) {
		select_get(0,&type,&index);
		if ((type==segment_piece) || (type==primitive_piece)) group_idx=map.segments[index].group_idx;
	}
	
	if (group_idx==-1) {
		SetControl32BitValue(group_combo,1);
	}
	else {
		SetControl32BitValue(group_combo,(3+group_idx));
	}
}
Exemplo n.º 2
0
void piece_tesselate(bool mesh)
{
	int				n,sel_count,type,mesh_idx,poly_idx;
	
	map_undo_push();
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type==item_map_mesh) {
			if (mesh) {
				map_mesh_tesselate(&map,mesh_idx);
			}
			else {
				map_mesh_poly_tesselate(&map,mesh_idx,poly_idx);
			}
			view_vbo_mesh_rebuild(mesh_idx);
		}
	}

	select_clear();
	
	main_wind_draw();
}
Exemplo n.º 3
0
void map_texture_palette_put_selected_texture(int txt_idx)
{
	int					n,k,sel_count,type,main_idx,poly_idx;
	map_mesh_type		*mesh;
	map_mesh_poly_type	*poly;

	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
	
		select_get(n,&type,&main_idx,&poly_idx);
		
			// liquids
			
		if (type==item_map_liquid) {
			if (view_get_uv_layer()==uv_layer_normal) {
				map.liquid.liquids[main_idx].txt_idx=txt_idx;
			}
			else {
				map.liquid.liquids[main_idx].lmap_txt_idx=txt_idx;
			}
			continue;
		}
		
			// meshes
			
		if (type!=item_map_mesh) continue;
		
		mesh=&map.mesh.meshes[main_idx];
		
			// only set polygon
			
		if (state.map.select_mode==select_mode_polygon) {
			if (view_get_uv_layer()==uv_layer_normal) {
				mesh->polys[poly_idx].txt_idx=txt_idx;
			}
			else {
				mesh->polys[poly_idx].lmap_txt_idx=txt_idx;
			}
		}
		
			// set all mesh
			
		else {
			
			poly=mesh->polys;
			
			for (k=0;k!=mesh->npoly;k++) {
				if (view_get_uv_layer()==uv_layer_normal) {
					poly->txt_idx=txt_idx;
				}
				else {
					poly->lmap_txt_idx=txt_idx;
				}
				poly++;
			}
		
		}		
	}
}
Exemplo n.º 4
0
void walk_view_cursor(bool rot_ok)
{
    // special check for nodes link changes

    if ((select_count()==1) && (select_has_type(node_piece))) {

        if (main_wind_option_down()) {
            os_set_cut_cursor();
            return;
        }

        if (main_wind_control_down()) {
            os_set_add_cursor();
            return;
        }
    }

    // normal cursors

    if (main_wind_space_down()) {
        os_set_hand_cursor();
        return;
    }
    if ((main_wind_option_down()) && ((!main_wind_control_down()) && (!main_wind_shift_down()))) {
        os_set_forward_cursor();
        return;
    }
    if ((main_wind_command_down()) && (rot_ok)) {
        os_set_rotate_cursor();
        return;
    }

    os_set_arrow_cursor();
}
Exemplo n.º 5
0
void piece_select_more(void)
{
	int					n,t,t2,sel_count,type,mesh_idx,poly_idx;
	d3pnt				*pt1,*pt2;
	map_mesh_type		*mesh;
	map_mesh_poly_type	*poly;

		// select more polygons
		
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
	
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;
		
		mesh=&map.mesh.meshes[mesh_idx];
		poly=&mesh->polys[poly_idx];
		
		for (t=0;t!=poly->ptsz;t++) {
			t2=t+1;
			if (t2==poly->ptsz) t2=0;
			
			pt1=&mesh->vertexes[poly->v[t]];
			pt2=&mesh->vertexes[poly->v[t2]];
			
			piece_select_more_check_edge(pt1,pt2);
		}
	}
	
	main_wind_draw();
}
Exemplo n.º 6
0
void piece_mesh_invert_normals(bool poly_only)
{
	int				n,k,sel_count,type,mesh_idx,poly_idx;
	map_mesh_type	*mesh;
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;
		
			// invert the poly
			
		mesh=&map.mesh.meshes[mesh_idx];
		
		if (poly_only) {
			piece_mesh_poly_invert_normals(&mesh->polys[poly_idx]);
		}
		else {
			for (k=0;k!=mesh->npoly;k++) {
				piece_mesh_poly_invert_normals(&mesh->polys[k]);
			}
		}
	}
	
	main_wind_draw();
}
Exemplo n.º 7
0
void piece_move(int move_x,int move_y,int move_z)
{
	int				n,sel_count,type,mesh_idx,poly_idx;
	d3pnt			mov_pnt;
	
	map_undo_push();
	
	sel_count=select_count();
	
	mov_pnt.x=move_x;
	mov_pnt.y=move_y;
	mov_pnt.z=move_z;
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type==item_map_mesh) {
			if (!map.mesh.meshes[mesh_idx].flag.lock_move) {
				map_mesh_move(&map,mesh_idx,&mov_pnt);
				view_force_grid(mesh_idx,TRUE);
				view_vbo_mesh_rebuild(mesh_idx);
			}
		}
	}
	
	main_wind_draw();
}
Exemplo n.º 8
0
void map_palette_reset(void)
{
	int				sel_type,main_idx,sub_idx;
	
		// clear out non-selection indexes

	state.map.cur_group_idx=-1;
	state.map.cur_movement_idx=-1;
	state.map.cur_movement_move_idx=-1;
	state.map.cur_cinema_idx=-1;
	state.map.cur_cinema_action_idx=-1;

		// if no select, change nothing

	if (select_count()==0) {
		state.map.cur_no_sel_piece_type=-1;
		list_palette_set_level(&map_palette,0);
		map_palette_scroll_into_view(item_map_setting,0);
		return;
	}
	
		// set the type

	select_get(0,&sel_type,&main_idx,&sub_idx);
	state.map.cur_no_sel_piece_type=sel_type;
	
	list_palette_set_level(&map_palette,1);
	
	if ((sel_type!=item_map_mesh) && (sel_type!=item_map_liquid)) map_palette_scroll_into_view(sel_type,main_idx);
}
Exemplo n.º 9
0
int node_link_is_node_link_selected(void)
{
	int			type,main_idx,sub_idx;
	
	if (select_count()!=1) return(-1);
	
	select_get(0,&type,&main_idx,&sub_idx);
	if (type!=item_map_node) return(-1);
	
	return(main_idx);
}
Exemplo n.º 10
0
int main(int argc, char** argv) {
    NDB_INIT(argv[0]);
    ndb_opt_set_usage_funcs(short_usage_sub, usage);
    ndb_load_defaults(NULL,load_default_groups,&argc,&argv);
    int ho_error;
#ifndef DBUG_OFF
    opt_debug= "d:t:O,/tmp/ndb_select_count.trace";
#endif
    if ((ho_error=handle_options(&argc, &argv, my_long_options,
                                 ndb_std_get_one_option)))
        return NDBT_ProgramExit(NDBT_WRONGARGS);
    if (argc < 1) {
        usage();
        return NDBT_ProgramExit(NDBT_WRONGARGS);
    }

    Ndb_cluster_connection con(opt_ndb_connectstring, opt_ndb_nodeid);
    con.set_name("ndb_select_count");
    if(con.connect(12, 5, 1) != 0)
    {
        ndbout << "Unable to connect to management server." << endl;
        return NDBT_ProgramExit(NDBT_FAILED);
    }
    if (con.wait_until_ready(30,0) < 0)
    {
        ndbout << "Cluster nodes not ready in 30 seconds." << endl;
        return NDBT_ProgramExit(NDBT_FAILED);
    }

    Ndb MyNdb(&con, _dbname );
    if(MyNdb.init() != 0) {
        ERR(MyNdb.getNdbError());
        return NDBT_ProgramExit(NDBT_FAILED);
    }

    for(int i = 0; i<argc; i++) {
        // Check if table exists in db
        const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]);
        if(pTab == NULL) {
            ndbout << " Table " << argv[i] << " does not exist!" << endl;
            continue;
        }

        Uint64 rows = 0;
        if (select_count(&MyNdb, pTab, _parallelism, &rows,
                         (NdbOperation::LockMode)_lock) != 0) {
            return NDBT_ProgramExit(NDBT_FAILED);
        }

        ndbout << rows << " records in table " << argv[i] << endl;
    }
    return NDBT_ProgramExit(NDBT_OK);
}
Exemplo n.º 11
0
int texture_palette_get_selected_texture(void)
{
	int				type,main_idx,poly_idx;
	
	if (select_count()!=1) return(-1);
	
	select_get(0,&type,&main_idx,&poly_idx);
	
	if (type==liquid_piece) return(map.liquid.liquids[main_idx].txt_idx);
	if (type==mesh_piece) return(map.mesh.meshes[main_idx].polys[poly_idx].txt_idx);
	
	return(-1);
}
Exemplo n.º 12
0
void piece_flip_uvs(bool flip_u,bool flip_v)
{
	int						n,sel_count,
							type,mesh_idx,poly_idx;

	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;

		map_mesh_flip_poly_uv(&map,mesh_idx,poly_idx,flip_u,flip_v);
		view_vbo_mesh_rebuild(mesh_idx);
	}
}
Exemplo n.º 13
0
void piece_rotate_uvs(void)
{
	int						n,sel_count,
							type,mesh_idx,poly_idx;

	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;

		map_mesh_rotate_poly_uv(&map,mesh_idx,poly_idx,90);
		view_vbo_mesh_rebuild(mesh_idx);
	}
}
Exemplo n.º 14
0
void texture_palette_put_selected_texture(int txt_idx)
{
	int					n,k,sel_count,type,main_idx,poly_idx;
	map_mesh_type		*mesh;
	map_mesh_poly_type	*poly;
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
	
		select_get(n,&type,&main_idx,&poly_idx);
		
			// liquids
			
		if (type==liquid_piece) {
			map.liquid.liquids[main_idx].txt_idx=txt_idx;
			continue;
		}
		
			// meshes
			
		if (type!=mesh_piece) continue;
		
		mesh=&map.mesh.meshes[main_idx];
		
			// only set polygon
			
		if (drag_mode==drag_mode_polygon) {
			mesh->polys[poly_idx].txt_idx=txt_idx;
		}
		
			// set all mesh
			
		else {
			
			poly=mesh->polys;
			
			for (k=0;k!=mesh->npoly;k++) {
				poly->txt_idx=txt_idx;
				poly++;
			}
		
		}		
	}
}
Exemplo n.º 15
0
void piece_force_grid(void)
{
	int				n,sel_count,type,mesh_idx,poly_idx;
	
	map_undo_push();
		
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type==item_map_mesh) {
			view_force_grid(mesh_idx,FALSE);
			view_vbo_mesh_rebuild(mesh_idx);
		}
	}
	
	main_wind_draw();
}
Exemplo n.º 16
0
void piece_mesh_select_all_poly(void)
{
	int				n,k,sel_count,type,mesh_idx,poly_idx;
	map_mesh_type	*mesh;
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;
		
		mesh=&map.mesh.meshes[mesh_idx];
		
		for (k=0;k!=mesh->npoly;k++) {
			if (!select_check(item_map_mesh,mesh_idx,k)) select_add(item_map_mesh,mesh_idx,k);
		}
	}
}
Exemplo n.º 17
0
void piece_flip(bool flip_x,bool flip_y,bool flip_z)
{
	int				n,sel_count,type,mesh_idx,poly_idx;
	
	map_undo_push();
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type==item_map_mesh) {
			map_mesh_flip(&map,mesh_idx,flip_x,flip_y,flip_z);
			view_vbo_mesh_rebuild(mesh_idx);
		}
	}
	
	main_wind_draw();
}
Exemplo n.º 18
0
void piece_poly_hole(void)
{
	int				n,sel_count,type,mesh_idx,poly_idx;
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type==item_map_mesh) {
			map_mesh_poly_punch_hole(&map,mesh_idx,poly_idx,NULL,FALSE,normal_mode_in);
			view_vbo_mesh_rebuild(mesh_idx);
		}
	}
	
	select_clear();
	
	main_wind_draw();
}
Exemplo n.º 19
0
   std::string select_random( Query& q, const std::string& table, const std::string& column, const std::string& channel )
   {
      std::string sql = select( table, column, channel );
      int max = q.get_count( select_count( table, column, channel ) );

      boost::mt19937 rng( time( NULL ) ) ;
      boost::uniform_int<> uni(1, max);
      boost::variate_generator<boost::mt19937&, boost::uniform_int<> >
         die(rng, uni);

      sql += " AND id=" + boost::lexical_cast<std::string>( die() ) + ";";

      std::cout << sql << std::endl;
      q.free_result();

      std::string res = q.get_string( sql );
      q.free_result();
      return res;
   }
Exemplo n.º 20
0
void piece_rotate(d3ang *ang)
{
	int				n,sel_count,type,mesh_idx,poly_idx;
	d3pnt			center_pnt;
	
	map_undo_push();
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;
		
		map_mesh_calculate_center(&map,mesh_idx,&center_pnt);
		map_mesh_rotate(&map,mesh_idx,&center_pnt,ang);
		view_vbo_mesh_rebuild(mesh_idx);
	}
	
	main_wind_draw();
}
Exemplo n.º 21
0
void piece_single_uvs(bool poly_only)
{
	int						n,sel_count,
							type,mesh_idx,poly_idx;

	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;
		
		if (poly_only) {
			map_mesh_poly_single_uv(&map,mesh_idx,poly_idx);
		}
		else {
			map_mesh_single_uv(&map,mesh_idx);
		}
		view_vbo_mesh_rebuild(mesh_idx);
	}
}
Exemplo n.º 22
0
void piece_mesh_recalc_normals(bool poly_only)
{
	int				n,sel_count,type,mesh_idx,poly_idx;
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;
		
		if (poly_only) {
			map_recalc_normals_mesh_poly(&map,&map.mesh.meshes[mesh_idx],poly_idx,normal_mode_none,FALSE);
		}
		else {
			map_recalc_normals_mesh(&map,&map.mesh.meshes[mesh_idx],normal_mode_none,FALSE);
		}
	}
	
	main_wind_draw();
}
Exemplo n.º 23
0
void piece_mesh_set_normals_in_out(bool out)
{
	int					n,sel_count,normal_mode,
						type,mesh_idx,poly_idx;
	map_mesh_type		*mesh;

	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;
		
			// recalc the normals
			
		mesh=&map.mesh.meshes[mesh_idx];

		normal_mode=out?normal_mode_out:normal_mode_in;
		map_recalc_normals_mesh(&map,&map.mesh.meshes[mesh_idx],normal_mode,FALSE);
	}
}
Exemplo n.º 24
0
int map_texture_palette_get_selected_texture(void)
{
	int					type,main_idx,poly_idx;
	
	if (select_count()!=1) return(-1);
	
	select_get(0,&type,&main_idx,&poly_idx);
	
	if (type==item_map_liquid) {
		if (view_get_uv_layer()==uv_layer_normal) return(map.liquid.liquids[main_idx].txt_idx);
		return(map.liquid.liquids[main_idx].lmap_txt_idx);
	}
	
	if (type==item_map_mesh) {
		if (view_get_uv_layer()==uv_layer_normal) return(map.mesh.meshes[main_idx].polys[poly_idx].txt_idx);
		return(map.mesh.meshes[main_idx].polys[poly_idx].lmap_txt_idx);
	}
	
	return(-1);
}
Exemplo n.º 25
0
void piece_reset_uvs(bool poly_only)
{
	int						n,sel_count,
							type,mesh_idx,poly_idx;

	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&mesh_idx,&poly_idx);
		if (type!=item_map_mesh) continue;
		if (map.mesh.meshes[mesh_idx].flag.lock_uv) continue;
		
		if (poly_only) {
			map_mesh_reset_poly_uv(&map,mesh_idx,poly_idx);
		}
		else {
			map_mesh_reset_uv(&map,mesh_idx);
		}

		view_vbo_mesh_rebuild(mesh_idx);
	}
}
Exemplo n.º 26
0
void map_palette_fill_level_1(void)
{
	int					sel_type,main_idx,sub_idx;

		// special check for non-selection property lists
	
	switch (state.map.cur_no_sel_piece_type) {

		case item_map_setting:
			map_palette_fill_map();
			return;

		case item_map_camera:
			map_palette_fill_camera();
			return;

		case item_map_light_media:
			map_palette_fill_light_media();
			return;

		case item_map_sky_weather:
			map_palette_fill_sky_weather();
			return;

		case item_map_group:
			map_palette_fill_group(state.map.cur_group_idx);
			return;
	
		case item_map_movement:
			map_palette_fill_movement(state.map.cur_movement_idx);
			return;

		case item_map_cinema:
			map_palette_fill_cinema(state.map.cur_cinema_idx);
			return;
	}

		// check selection

	main_idx=-1;
	
	if (select_count()!=0)  select_get(0,&sel_type,&main_idx,&sub_idx);
	if (main_idx==-1) return;

		// selection properties

	switch (sel_type) {

		case item_map_mesh:
			if (state.map.select_mode!=select_mode_polygon) sub_idx=-1;
			map_palette_fill_mesh(main_idx,sub_idx);
			break;

		case item_map_liquid:
			map_palette_fill_liquid(main_idx);
			break;

		case item_map_spot:
			map_palette_fill_spot(main_idx);
			break;

		case item_map_node:
			map_palette_fill_node(main_idx);
			break;

		case item_map_light:
			map_palette_fill_light(main_idx);
			break;

		case item_map_sound:
			map_palette_fill_sound(main_idx);
			break;

		case item_map_particle:
			map_palette_fill_particle(main_idx);
			break;

		case item_map_scenery:
			map_palette_fill_scenery(main_idx);
			break;

	}
}
Exemplo n.º 27
0
void map_palette_click_level_1(bool double_click)
{
	int					sel_type,main_idx,sub_idx;
	
		// special check for non-selection property lists
		// and check state changes

	switch (state.map.cur_no_sel_piece_type) {

		case item_map_group:
			map_palette_click_group(double_click);
			return;

		case item_map_movement:
			map_palette_click_movement(double_click);
			return;

		case item_map_cinema:
			map_palette_click_cinema(double_click);
			return;
	}

		// get the selection

	main_idx=-1;
	
	if (select_count()!=0) select_get(0,&sel_type,&main_idx,&sub_idx);

		// no selection, map properties

	if (main_idx==-1) {

		switch (state.map.cur_no_sel_piece_type) {
			
			case item_map_setting:
				map_palette_click_map(double_click);
				break;

			case item_map_camera:
				map_palette_click_camera(double_click);
				break;

			case item_map_light_media:
				map_palette_click_light_media(double_click);
				break;

			case item_map_sky_weather:
				map_palette_click_sky_weather(double_click);
				break;

		}

		return;
	}

		// selection properties

	switch (sel_type) {

		case item_map_mesh:
			if (state.map.select_mode!=select_mode_polygon) sub_idx=-1;
			map_palette_click_mesh(main_idx,sub_idx,double_click);
			break;

		case item_map_liquid:
			map_palette_click_liquid(main_idx,double_click);
			break;

		case item_map_spot:
			map_palette_click_spot(main_idx,double_click);
			break;

		case item_map_node:
			map_palette_click_node(main_idx,double_click);
			break;

		case item_map_light:
			map_palette_click_light(main_idx,double_click);
			break;

		case item_map_sound:
			map_palette_click_sound(main_idx,double_click);
			break;

		case item_map_particle:
			map_palette_click_particle(main_idx,double_click);
			break;

		case item_map_scenery:
			map_palette_click_scenery(main_idx,double_click);
			break;

	}
}
Exemplo n.º 28
0
void Syncer::worker(time_t curr_time)
{
    auto clone_db = make_db_clone(utils::str::to_string(std::this_thread::get_id()));
    try {
        clone_db->open();
    } catch (const DatabaseException &exc) {
        this->update(std::make_exception_ptr(exc));
        return;
    }

    bool running = true;
    QString buffer;
    while (running)
    {
        QString path;
        try
        {
            path = storage->get_next();
            Track track(path);

            QString hash = track.get_hash();
            auto where = utils::sql::prepare_where<std::string>(cfg::db::row::hash, utils::sql::chars::equal, utils::str::make_dquote_s(hash).toStdString());
            auto hash_count = clone_db->select_count(cfg::db::table::files, cfg::db::row::id, where);
            if (hash_count > 0) {
                clone_db->renew_value(cfg::db::table::files, cfg::db::row::timestamp, std::to_string(curr_time), where);
                this->update({path.toStdString(), std::move(track)});
                continue;
            }

            buffer = (track.get_genre().size() > 0)? track.get_genre() : cfg::db::row::unknown;
            size_t genre_id = clone_db->get_id(cfg::db::table::genres, cfg::db::row::name, buffer.toStdString());

            buffer = (track.get_author().size() > 0)? track.get_author() : cfg::db::row::unknown;
            size_t author_id = clone_db->get_id(cfg::db::table::authors, cfg::db::row::name, buffer.toStdString());

            buffer = (track.get_album().size() > 0)? track.get_album() : cfg::db::row::unknown;
            size_t album_id = clone_db->get_id(cfg::db::table::albums, cfg::db::row::name, buffer.toStdString());

            buffer = (track.get_type().size() > 0)? track.get_type() : cfg::db::row::unknown;
            size_t type_id = clone_db->get_id(cfg::db::table::formats, cfg::db::row::name, buffer.toStdString());

            auto query = insert_track(track, genre_id, author_id, album_id, type_id, curr_time);
            clone_db->execute(query.toStdString());

            this->update({path.toStdString(), std::move(track)});
        }
        catch (const FileStorage::Container::Terminated &exc)
        {
            this->update(std::make_exception_ptr(exc));
            running = false;
        }
        catch (const DatabaseException &exc)
        {
            this->update(std::make_exception_ptr(exc));
            //running = false;
        }
        catch (...)
        {
            this->update(std::current_exception());
        }
    }
}
Exemplo n.º 29
0
void piece_key(char ch)
{
	int					n,sel_count,type,main_idx,sub_idx,mv;
	d3pnt				move_pnt;
	editor_view_type	*view;
	
		// special check for delete key
		
	if ((ch==D3_KEY_BACKSPACE) || (ch==D3_KEY_DELETE)) {
		piece_delete();
		map_palette_reset();
		main_wind_draw();
		main_wind_menu_update();
		return;
	}
	
		// nudge works with grid
	
	mv=view_get_grid();
	if (os_key_shift_down()) mv*=move_key_shift_multiply;
	
		// nudge keys movement

	view=view_get_current_view();
	move_pnt.x=move_pnt.y=move_pnt.z=0;
		
	switch (ch) {
	
		case D3_KEY_LEFT:
			view_mouse_get_scroll_horizontal_axis(view,&move_pnt,-mv);
			break;
			
		case D3_KEY_RIGHT:
			view_mouse_get_scroll_horizontal_axis(view,&move_pnt,+mv);
			break;
			
		case D3_KEY_UP:
			view_mouse_get_scroll_vertical_axis(view,&move_pnt,-mv);
			break;
			
		case D3_KEY_DOWN:
			view_mouse_get_scroll_vertical_axis(view,&move_pnt,mv);
			break;
			
	}
	
	if ((move_pnt.x==0) && (move_pnt.y==0) && (move_pnt.z==0)) return;
	
		// move selection
	
	sel_count=select_count();
	
	for (n=0;n!=sel_count;n++) {
		select_get(n,&type,&main_idx,&sub_idx);

		switch (type) {
		
			case item_map_mesh:
				if (map.mesh.meshes[main_idx].flag.lock_move) break;
				map_mesh_move(&map,main_idx,&move_pnt);
				if ((state.map.auto_texture) && (!map.mesh.meshes[main_idx].flag.lock_uv)) map_mesh_reset_uv(&map,main_idx);
				view_vbo_mesh_rebuild(main_idx);
				break;
				
			case item_map_liquid:
				map_liquid_move(&map,main_idx,&move_pnt);
				if ((state.map.auto_texture) && (!map.liquid.liquids[main_idx].flag.lock_uv)) map_liquid_reset_uv(&map,main_idx);
				break;
				
			case item_map_node:
				map.nodes[main_idx].pnt.x+=move_pnt.x;
				map.nodes[main_idx].pnt.y+=move_pnt.y;
				map.nodes[main_idx].pnt.z+=move_pnt.z;
				break;
				
			case item_map_spot:
				map.spots[main_idx].pnt.x+=move_pnt.x;
				map.spots[main_idx].pnt.y+=move_pnt.y;
				map.spots[main_idx].pnt.z+=move_pnt.z;
				break;
				
			case item_map_scenery:
				map.sceneries[main_idx].pnt.x+=move_pnt.x;
				map.sceneries[main_idx].pnt.y+=move_pnt.y;
				map.sceneries[main_idx].pnt.z+=move_pnt.z;
				break;
				
			case item_map_light:
				map.lights[main_idx].pnt.x+=move_pnt.x;
				map.lights[main_idx].pnt.y+=move_pnt.y;
				map.lights[main_idx].pnt.z+=move_pnt.z;
				break;
				
			case item_map_sound:
				map.sounds[main_idx].pnt.x+=move_pnt.x;
				map.sounds[main_idx].pnt.y+=move_pnt.y;
				map.sounds[main_idx].pnt.z+=move_pnt.z;
				break;
				
			case item_map_particle:
				map.particles[main_idx].pnt.x+=move_pnt.x;
				map.particles[main_idx].pnt.y+=move_pnt.y;
				map.particles[main_idx].pnt.z+=move_pnt.z;
				break;
				
		}
	}
	
	main_wind_draw();
}
Exemplo n.º 30
0
void walk_view_draw_select(d3pnt *cpt,bool draw_area)
{
	int						n,sel_count,
							type,main_idx,sub_idx;
	unsigned char			draw_mesh_once[max_mesh];
	
	sel_count=select_count();
	if (sel_count==0) return;
	
		// only draw mesh selections once
		// as there could be multiple polygon selections
		// for a single mesh
		
	memset(draw_mesh_once,0x0,max_mesh);
	
		// draw the selection of meshes, liquids,
		// and other pieces, drawing the selected
		// polygons later
		
	for (n=(sel_count-1);n>=0;n--) {
	
		select_get(n,&type,&main_idx,&sub_idx);
		
			// draw selection
			
		switch (type) {
		
			case mesh_piece:
				if (draw_mesh_once[main_idx]==0x0) {
					draw_mesh_once[main_idx]=0x1;
					walk_view_draw_select_mesh(main_idx);
				}
				break;
				
			case liquid_piece:
				walk_view_draw_select_liquid(main_idx);
				break;
				
			case node_piece:
				walk_view_draw_select_sprite(&map.nodes[main_idx].pnt);
				break;
				
			case spot_piece:
				if (!walk_view_model_draw_select(&map.spots[main_idx].pnt,&map.spots[main_idx].ang,map.spots[main_idx].display_model)) {
					walk_view_draw_select_sprite(&map.spots[main_idx].pnt);
				}
				break;
				
			case scenery_piece:
				if (!walk_view_model_draw_select(&map.sceneries[main_idx].pnt,&map.sceneries[main_idx].ang,map.sceneries[main_idx].model_name)) {
					walk_view_draw_select_sprite(&map.sceneries[main_idx].pnt);
				}
				break;
				
			case light_piece:
				walk_view_draw_select_sprite(&map.lights[main_idx].pnt);
				break;
				
			case sound_piece:
				walk_view_draw_select_sprite(&map.sounds[main_idx].pnt);
				break;
				
			case particle_piece:
				walk_view_draw_select_sprite(&map.particles[main_idx].pnt);
				break;
				
			case area_piece:
				if (draw_area) walk_view_draw_select_area(main_idx);
				break;
		}
	}
	
		// draw selected polygons
		// draw afterwards so mesh highlighting doesn't
		// effect selection
		
	if (drag_mode==drag_mode_polygon) {
	
		for (n=(sel_count-1);n>=0;n--) {
		
			select_get(n,&type,&main_idx,&sub_idx);
			if (type!=mesh_piece) continue;
			
			walk_view_draw_select_mesh_poly(main_idx,sub_idx);
		}
		
	}
	
		// finish with selecte mesh vertexes
		
	if (drag_mode==drag_mode_vertex) {

		memset(draw_mesh_once,0x0,max_mesh);
			
		for (n=(sel_count-1);n>=0;n--) {
		
			select_get(n,&type,&main_idx,&sub_idx);
			if (type!=mesh_piece) continue;
			
			if (draw_mesh_once[main_idx]==0x0) {
				draw_mesh_once[main_idx]=0x1;
				walk_view_draw_select_mesh_vertex(main_idx);
			}
		}
	}
}