예제 #1
0
void PostProcessingConfigDiag::Event_Slider(wxCommandEvent& ev)
{
  UserEventData* config_option = (UserEventData*)ev.GetEventUserData();
  ConfigGrouping* config = m_config_map[config_option->GetData()];

  const auto& option_data = m_post_processor->GetOption(config->GetOption());

  size_t vector_size = 0;
  if (option_data.m_type ==
      PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_INTEGER)
    vector_size = option_data.m_integer_values.size();
  else
    vector_size = option_data.m_float_values.size();

  for (size_t i = 0; i < vector_size; ++i)
  {
    // Got to do this garbage again.
    // Convert current step in to the real range value
    int current_step = config->GetSliderValue(i);
    std::string string_value;
    if (option_data.m_type ==
        PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_INTEGER)
    {
      s32 value =
          option_data.m_integer_step_values[i] * current_step + option_data.m_integer_min_values[i];
      m_post_processor->SetOptioni(config->GetOption(), i, value);
      string_value = std::to_string(value);
    }
    else
    {
      float value =
          option_data.m_float_step_values[i] * current_step + option_data.m_float_min_values[i];
      m_post_processor->SetOptionf(config->GetOption(), i, value);
      string_value = std::to_string(value);
    }
    // Update the text box to include the new value
    config->SetSliderText(i, string_value);
  }
  ev.Skip();
}
void PostProcessingConfigDiag::Event_Slider_Finish(wxScrollEvent &ev)
{
	UserEventData* config_option = (UserEventData*)ev.GetEventUserData();
	ConfigGrouping* config = m_config_map[config_option->GetData()];

	const auto& option_data = m_post_processor->GetOption(config->GetOption());
	if (!option_data.m_resolve_at_compilation)
	{
		// Just handle options that must be resolved at compilation time
		ev.Skip();
		return;
	}

	size_t vector_size = 0;
	if (option_data.m_type == PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_INTEGER)
		vector_size = option_data.m_integer_values.size();
	else
		vector_size = option_data.m_float_values.size();

	for (size_t i = 0; i < vector_size; ++i)
	{
		// Got to do this garbage again.
		// Convert current step in to the real range value
		int current_step = config->GetSliderValue(i);
		std::string string_value;
		if (option_data.m_type == PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_INTEGER)
		{
			s32 value = option_data.m_integer_step_values[i] * current_step + option_data.m_integer_min_values[i];
			m_post_processor->SetOptioni(config->GetOption(), i, value);
		}
		else
		{
			float value = option_data.m_float_step_values[i] * current_step + option_data.m_float_min_values[i];
			m_post_processor->SetOptionf(config->GetOption(), i, value);
		}
	}
	ev.Skip();
}