~ubuntu-branches/ubuntu/trusty/plee-the-bear/trusty-proposed

« back to all changes in this revision

Viewing changes to bear-factory/level-editor/src/bf/history/code/action_set_item_id.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien Jorge, Julien Jorge
  • Date: 2010-11-17 20:13:34 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101117201334-o4dp7uq437to7oxb
Tags: 0.5.1-1
[ Julien Jorge ]
* New upstream release (Closes: #565062, #546514).
* Add armhf architecture (Closes: #604689).
* Remove patches integrated upstream: rpath-editors.diff, rpath-game.diff,
  editors-menu-section.diff.
* Bump the Standard-Version, no changes.
* Update my email address.
* Set build dependency of libclaw to 1.6.0.
* Add the missing ${misc:Depends} in debian/control.
* List gettext translations in bear-factory.install and plee-the-bear.install.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    Bear Engine - Level editor
3
3
 
4
 
    Copyright (C) 2005-2009 Julien Jorge, Sebastien Angibaud
 
4
    Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
5
5
 
6
6
    This program is free software; you can redistribute it and/or modify it
7
7
    under the terms of the GNU General Public License as published by the
29
29
#include "bf/history/action_set_item_id.hpp"
30
30
 
31
31
#include "bf/item_instance.hpp"
 
32
#include "bf/layer.hpp"
 
33
#include "bf/gui_level.hpp"
 
34
#include "bf/wx_facilities.hpp"
32
35
 
33
36
#include <wx/intl.h>
34
37
#include <claw/assert.hpp>
 
38
#include <limits>
35
39
 
36
40
/*----------------------------------------------------------------------------*/
 
41
/**
 
42
 * \brief Constructor.
 
43
 * \param item The item for which the identifier changes.
 
44
 * \param id The new identifier.
 
45
 */
37
46
bf::action_set_item_id::action_set_item_id
38
47
( item_instance* item, const std::string& id )
39
 
  : m_item(item), m_id(id)
 
48
  : m_item(item), m_id(id),
 
49
    m_layer_index(std::numeric_limits<unsigned int>::max())
40
50
{
41
51
  CLAW_PRECOND( item != NULL );
42
52
} // action_set_item_id::action_set_item_id()
46
56
{
47
57
  CLAW_PRECOND( m_item != NULL );
48
58
 
 
59
  if (m_layer_index >= lvl.layers_count())
 
60
    m_layer_index = lvl.get_layer_by_item(*m_item);
 
61
 
 
62
  std::map<std::string,std::string> id_map;
 
63
 
49
64
  const std::string old( m_item->get_id() );
 
65
  id_map[old] = m_id;
50
66
 
51
67
  m_item->set_id( m_id );
52
68
 
 
69
  layer::item_iterator it;
 
70
  const layer::item_iterator ite = lvl.get_layer(m_layer_index).item_end();
 
71
 
 
72
  for ( it = lvl.get_layer(m_layer_index).item_begin(); it != ite; ++it )
 
73
    it->rename_item_reference_fields(id_map);
 
74
 
53
75
  m_id = old;
54
76
} // action_set_item_id::execute()
55
77
 
71
93
/*----------------------------------------------------------------------------*/
72
94
wxString bf::action_set_item_id::get_description() const
73
95
{
 
96
  if ( m_id.empty() )
 
97
    return _("Remove item identifier");
 
98
  else
 
99
    return
 
100
      wxString::Format
 
101
      ( _("Set item identifier to %s"), std_to_wx_string(m_id).c_str() );
 
102
} // action_set_item_id::get_description()
 
103
 
 
104
/*----------------------------------------------------------------------------*/
 
105
/**
 
106
 * \brief Get a generic description of the action.
 
107
 */
 
108
wxString bf::action_set_item_id::get_action_description()
 
109
{
74
110
  return _("Set item identifier");
75
 
} // action_set_item_id::get_description()
 
111
} // action_set_item_id::get_action_description()