예제 #1
0
/**
 * \brief Convert the value of a field in a string.
 * \param item The item in which the value is taken.
 * \param f The field for which we want the value.
 */
wxString bf::item_field_edit::convert_value_to_text
( const item_instance& item, const type_field& f ) const
{
  if ( !item.has_value(f) )
    return std_to_wx_string( item.get_class().get_default_value(f.get_name()) );
  else
    {
      call_by_field_type<value_to_text_converter, wxString> call;
      return call(f, f.get_name(), item);
    }
} // item_field_edit::convert_value_to_text()
예제 #2
0
/**
 * \brief Write an xml node "field".
 * \param item The item instance to write.
 * \param f The field to save.
 * \param os The stream in which we write.
 */
void bf::xml::item_instance_field_node::write
( const item_instance& item, const type_field& f, std::ostream& os ) const
{
  os << "<field name='" << f.get_name() << "'>\n";
  save_field( item, f, os );
  os << "</field>\n";
} // item_instance_field_node::write()
예제 #3
0
/**
 * \brief Toggle the value of a boolean field.
 * \param f The type of the field we are editing.
 */
void bf::item_field_edit::toggle_boolean_field_value( const type_field& f )
{
  CLAW_PRECOND(!f.is_list());
  CLAW_PRECOND(f.get_field_type() == type_field::boolean_field_type);

  bool_type v;
  if ( !get_common_value(f, v) )
    v.set_value(true);
  else
    v.set_value(!v.get_value());

  set_field_value_event<bool_type> event
    ( f.get_name(), v,
      set_field_value_event<bool_type>::set_field_value_event_type, GetId() );
  event.SetEventObject(this);

  if( ProcessEvent(event) )
    update_values();
} // item_field_edit::toggle_boolean_field_value()
예제 #4
0
/**
 * \brief Show the adequate dialog for editing a given string field.
 * \param f The type of the field we are editing.
 */
void bf::item_field_edit::show_string_property_dialog( const type_field& f )
{
  switch ( f.get_range_type() )
    {
    case type_field::field_range_free:
      show_property_dialog< free_edit<string_type> >(f, _("string"));
      break;
    case type_field::field_range_set:
      show_property_dialog< set_edit<string_type> >(f, _("string"));
      break;
    default:
      {
        CLAW_ASSERT(false, "range type is not valid.");
      }
    }
} // item_field_edit::show_string_property_dialog()
예제 #5
0
/**
 * \brief Show the adequate dialog for editing a given item reference field.
 * \param f The type of the field we are editing.
 */
void
bf::item_field_edit::show_item_reference_property_dialog( const type_field& f )
{
  wxArrayString values;

  request_item_id_event event
    ( f, values, request_item_id_event::request_item_id_event_type, GetId() );
  event.SetEventObject(this);

  if ( ProcessEvent(event) )
    {
      values.Sort();

      if ( f.is_list() )
        edit_field< item_reference_edit, std::list<item_reference_type> >
          (f, _("Item"), values);
      else
        edit_field<item_reference_edit, item_reference_type>
          (f, _("List of items"), values);
    }
} // item_field_edit::show_item_reference_property_dialog()
예제 #6
0
/**
 * \brief Load the value of a field.
 * \param item The item in which we set the field.
 * \param f The field to load.
 * \param node The node to parse.
 */
void bf::xml::item_instance_field_node::load_field
( item_instance& item, const type_field& f, const wxXmlNode* node ) const
{
  if ( f.is_list() )
    switch ( f.get_field_type() )
      {
      case type_field::integer_field_type:
        load_value_list<integer_type>( item, f.get_name(), node );
        break;
      case type_field::u_integer_field_type:
        load_value_list<u_integer_type>( item, f.get_name(), node );
        break;
      case type_field::real_field_type:
        load_value_list<real_type>( item, f.get_name(), node );
        break;
      case type_field::boolean_field_type:
        load_value_list<bool_type>( item, f.get_name(), node );
        break;
      case type_field::string_field_type:
        load_value_list<string_type>( item, f.get_name(), node );
        break;
      case type_field::sprite_field_type:
        load_value_list<sprite>( item, f.get_name(), node );
        break;
      case type_field::animation_field_type:
        load_value_list<any_animation>( item, f.get_name(), node );
        break;
      case type_field::item_reference_field_type:
        load_value_list<item_reference_type>( item, f.get_name(), node );
        break;
      case type_field::font_field_type:
        load_value_list<font>( item, f.get_name(), node );
        break;
      case type_field::sample_field_type:
        load_value_list<sample>( item, f.get_name(), node );
        break;
      case type_field::color_field_type:
        load_value_list<color>( item, f.get_name(), node );
        break;
      case type_field::easing_field_type:
        load_value_list<easing_type>( item, f.get_name(), node );
        break;
      }
  else
    switch ( f.get_field_type() )
      {
      case type_field::integer_field_type:
        load_value<integer_type>( item, f.get_name(), node );
        break;
      case type_field::u_integer_field_type:
        load_value<u_integer_type>( item, f.get_name(), node );
        break;
      case type_field::real_field_type:
        load_value<real_type>( item, f.get_name(), node );
        break;
      case type_field::boolean_field_type:
        load_value<bool_type>( item, f.get_name(), node );
        break;
      case type_field::string_field_type:
        load_value<string_type>( item, f.get_name(), node );
        break;
      case type_field::sprite_field_type:
        load_value<sprite>( item, f.get_name(), node );
        break;
      case type_field::animation_field_type:
        load_value<any_animation>( item, f.get_name(), node );
        break;
      case type_field::item_reference_field_type:
        load_value<item_reference_type>( item, f.get_name(), node );
        break;
      case type_field::font_field_type:
        load_value<font>( item, f.get_name(), node );
        break;
      case type_field::sample_field_type:
        load_value<sample>( item, f.get_name(), node );
        break; 
      case type_field::color_field_type:
        load_value<color>( item, f.get_name(), node );
        break;
      case type_field::easing_field_type:
        load_value<easing_type>( item, f.get_name(), node );
        break;
      }
} // item_instance_field_node::load_field()
예제 #7
0
/**
 * \brief Save the value of a field.
 * \param item The item in which we take the field.
 * \param f The field to save.
 * \param os The stream in which we write.
 */
void bf::xml::item_instance_field_node::save_field
( const item_instance& item, const type_field& f, std::ostream& os ) const
{
  if ( f.is_list() )
    switch ( f.get_field_type() )
      {
      case type_field::integer_field_type:
        save_value_list<integer_type>( os, f.get_name(), item, "integer" );
        break;
      case type_field::u_integer_field_type:
        save_value_list<u_integer_type>( os, f.get_name(), item, "u_integer" );
        break;
      case type_field::real_field_type:
        save_value_list<real_type>( os, f.get_name(), item, "real" );
        break;
      case type_field::boolean_field_type:
        save_value_list<bool_type>( os, f.get_name(), item, "bool" );
        break;
      case type_field::string_field_type:
        save_value_list<string_type>( os, f.get_name(), item, "string" );
        break;
      case type_field::sprite_field_type:
        save_value_list<sprite>( os, f.get_name(), item );
        break;
      case type_field::animation_field_type:
        save_value_list<any_animation>( os, f.get_name(), item );
        break;
      case type_field::item_reference_field_type:
        save_value_list<item_reference_type>
          ( os, f.get_name(), item, "item_reference" );
        break;
      case type_field::font_field_type:
        save_value_list<font>( os, f.get_name(), item );
        break;
      case type_field::sample_field_type:
        save_value_list<sample>( os, f.get_name(), item );
        break;
      case type_field::color_field_type:
        save_value_list<color>( os, f.get_name(), item );
        break;
      case type_field::easing_field_type:
        save_value_list<easing_type>( os, f.get_name(), item );
        break;
      }
  else
    switch ( f.get_field_type() )
      {
      case type_field::integer_field_type:
        save_value<integer_type>( os, f.get_name(), item, "integer" );
        break;
      case type_field::u_integer_field_type:
        save_value<u_integer_type>( os, f.get_name(), item, "u_integer" );
        break;
      case type_field::real_field_type:
        save_value<real_type>( os, f.get_name(), item, "real" );
        break;
      case type_field::boolean_field_type:
        save_value<bool_type>( os, f.get_name(), item, "bool" );
        break;
      case type_field::string_field_type:
        save_value<string_type>( os, f.get_name(), item, "string" );
        break;
      case type_field::sprite_field_type:
        save_value<sprite>( os, f.get_name(), item );
        break;
      case type_field::animation_field_type:
        save_value<any_animation>( os, f.get_name(), item );
        break;
      case type_field::item_reference_field_type:
        save_value<item_reference_type>
          ( os, f.get_name(), item, "item_reference" );
        break;
      case type_field::font_field_type:
        save_value<font>( os, f.get_name(), item );
        break;
      case type_field::sample_field_type:
        save_value<sample>( os, f.get_name(), item );
        break;
      case type_field::color_field_type:
        save_value<color>( os, f.get_name(), item );
        break;
      case type_field::easing_field_type:
        save_value<easing_type>( os, f.get_name(), item );
        break;
      }
} // item_instance_field_node::save_field()