コード例 #1
0
	void FirmwarePackage::upload( Camera& cam, util::progress::IReportProgress& progress, DeviceTypeDesc overrideDeviceType )
	{
		auto type_pid = overrideDeviceType.product_id ? overrideDeviceType.product_id : cam.product_id();
		auto it = device_types_.find( type_pid );
		if( it == device_types_.end() )
		{
			throw std::runtime_error( "Device type not found in package" );
		}

		progress.report_group_format( "Upgrade to version %d", version() );
		progress.report_group_format( "DeviceType = %s [0x%04X]", it->second.desc.description.c_str(), it->second.desc.product_id );

		auto upload_groups = it->second.upload_groups;

		auto group_progress = util::progress::MapItemProgress( progress, upload_groups.size() );

		for( auto upload_group : upload_groups )
		{
			group_progress.report_group( upload_group.name );

			if( !check_group_update_required( cam, upload_group ) )
			{
				group_progress.report_step( "Skipping, up to date" );
				group_progress.report_item();
				continue;
			}

			upload_group.port->upload( cam, upload_group.items, group_progress );

			group_progress.report_item();
		}
	}
コード例 #2
0
ファイル: ooptmenu.cpp プロジェクト: 112212/7k2
int OptionMenu::detect()
{
	if( !active_flag )
		return 0;

	int bx = (VGA_WIDTH - PAGE_WIDTH) / 2;
	int by = (VGA_HEIGHT - PAGE_HEIGHT) / 2;

	Config &tempConfig = config;

//	int i;
	int retFlag1 = 1;

	if( se_vol_slide.detect() == 1)
	{
		tempConfig.sound_effect_flag = se_vol_slide.view_recno > 0;
		if( se_vol_slide.view_recno > 0)
			tempConfig.sound_effect_volume = slide_to_percent_volume(se_vol_slide.view_recno);
		else
			tempConfig.sound_effect_volume = 1;		// never set sound_effect_volume = 0
		audio.set_wav_volume(tempConfig.sound_effect_volume);

		// change music volume, sound effect volume may change music volume
		if( tempConfig.music_flag )
		{
			music.change_volume( tempConfig.wav_music_volume);
		}
	}
//	else if( music_vol_slide.detect() == 1)
//	{
//		tempConfig.music_flag = music_vol_slide.view_recno > 0;
//		tempConfig.wav_music_volume = slide_to_percent_volume(music_vol_slide.view_recno);
//		if( tempConfig.music_flag )
//		{
//			music.change_volume( tempConfig.wav_music_volume );
//		}
//	}
	else if( music_group.detect() >= 0 )
	{
		tempConfig.music_flag = music_group[music_group()].custom_para.value;
	}
	else if( frame_speed_slide.detect() == 1)
	{
		tempConfig.frame_speed = frame_speed_slide.view_recno <= 30 ? frame_speed_slide.view_recno : 99;
	}
	else if( scroll_speed_slide.detect() == 1)
	{
		tempConfig.scroll_speed = scroll_speed_slide.view_recno;
	}
	else
		retFlag1 = 0;

	int retFlag2 = 0;
//	for( i = 0; i < MAX_RACE; ++i )
//	{
//		if( race_button[i].detect() )
//		{
//			if( config.music_flag )
//			{
//				music.play( race_button[i].custom_para.value + 1,
//					sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 );
//			}
//			else
//			{
//				// stop any music playing
//				music.stop();
//			}
//			retFlag2 = 1;
//		}
//	}

	int retFlag3 = 1;
	if( help_group.detect() >= 0)
	{
		tempConfig.help_mode = help_group[help_group()].custom_para.value;
		//refresh_flag |= IGOPTION_HELP;
		update_flag |= IGOPTION_HELP;
	}
	else if( news_group.detect() >= 0)
	{
		tempConfig.disp_news_flag = news_group[news_group()].custom_para.value;
		//refresh_flag |= IGOPTION_HELP;
		update_flag |= IGOPTION_HELP;
	}
	else if( report_group.detect() >= 0)
	{
		tempConfig.opaque_report = report_group[report_group()].custom_para.value;
		//refresh_flag |= IGOPTION_REPORT;
		update_flag |= IGOPTION_REPORT;
	}
	else if( show_icon_group.detect() >= 0)
	{
		tempConfig.show_all_unit_icon = show_icon_group[show_icon_group()].custom_para.value;
		//refresh_flag |= IGOPTION_SHOW_ICON;
		update_flag |= IGOPTION_SHOW_ICON;
	}
	else if( show_path_group.detect() >= 0)
	{
		tempConfig.show_unit_path = show_path_group[show_path_group()].custom_para.value;
		//refresh_flag |= IGOPTION_DRAW_PATH;
		update_flag |= IGOPTION_DRAW_PATH;
	}
	else if( inside_info_group.detect() >= 0)
	{
		tempConfig.disp_extend_info = inside_info_group[inside_info_group()].custom_para.value;
		update_flag |= IGOPTION_INSIDE_INFO;
	}
	else if( scroll_method_group.detect() >= 0)
	{
		tempConfig.scroll_method = scroll_method_group[scroll_method_group()].custom_para.value;
		update_flag |= IGOPTION_SCROLL_METHOD;
	}
	else if( start_button.detect(KEY_RETURN) )
	{
		// detect return button

		if( &config != &tempConfig)
			config = tempConfig;

		exit(1);

		if( update_flag )
		{
			// save config
			Config fileConfig;
			if( !fileConfig.load("config.dat") )
				fileConfig.init();
			fileConfig.change_preference(tempConfig);
			fileConfig.save("config.dat");
		}

	}
	else if( cancel_button.detect(KEY_ESC) )
	{
		config = old_config;

		exit(0);
	}
	else
		retFlag3 = 0;

	return retFlag1 || retFlag2 || retFlag3;
}