~ubuntu-branches/ubuntu/natty/plee-the-bear/natty

« back to all changes in this revision

Viewing changes to bear-factory/model-editor/src/bf/code/action_list_frame.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 - Model 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
56
56
 */
57
57
void bf::action_list_frame::set_model_frame( model_frame* f )
58
58
{
59
 
  m_model_frame = f;
60
 
  fill();
 
59
  if ( f != m_model_frame )
 
60
    {
 
61
      m_model_frame = f;
 
62
      fill();
 
63
    }
61
64
} // action_list_frame::set_model_frame()
62
65
 
63
66
/*----------------------------------------------------------------------------*/
85
88
 */
86
89
void bf::action_list_frame::create_member_controls()
87
90
{
88
 
  m_action_list = new wxListBox( this, IDC_ACTION_LIST );
 
91
  m_action_list = new wxListBox(this, IDC_ACTION_LIST);
89
92
  m_new_action_button = new wxButton(this, wxID_NEW);
90
 
  m_new_action_button->SetLabel(wxT(""));
 
93
  m_new_action_button->SetLabel(wxEmptyString);
91
94
} // action_list_frame::create_member_controls()
92
95
 
93
96
/*----------------------------------------------------------------------------*/
104
107
  s_sizer->Add( m_new_action_button, 0, wxEXPAND | wxALL, 0 );
105
108
  s_sizer->Add( new wxButton(this, wxID_DELETE), 0, wxEXPAND | wxALL, 0 );
106
109
  s_sizer->Add( new wxButton(this, wxID_PROPERTIES), 0, wxEXPAND | wxALL, 0 );
107
 
  
 
110
 
108
111
  sizer->Add( m_action_list, 1, wxEXPAND );
109
112
  sizer->Add( s_sizer, 0, wxEXPAND );
110
 
  
 
113
 
111
114
  SetSizer(sizer);
112
115
} // action_list_frame::create_sizer_controls()
113
116
 
126
129
 */
127
130
void bf::action_list_frame::fill()
128
131
{
129
 
  clear();
130
 
 
131
 
  if ( m_model_frame != NULL )
132
 
    if ( !m_model_frame->empty() )
133
 
      {
134
 
        const gui_model& mdl = m_model_frame->get_model();
135
 
        
136
 
        model::const_action_iterator it;
137
 
        const model::const_action_iterator end_it = mdl.action_end();
138
 
 
139
 
        for ( it = mdl.action_begin(); it != end_it; ++it)
140
 
          m_action_list->Append( std_to_wx_string( it->get_name() ) );
141
 
        
142
 
        if ( mdl.has_active_action() ) 
143
 
          select_action(mdl.get_active_action().get_name());
144
 
      }
 
132
  if ( m_model_frame == NULL )
 
133
    clear();
 
134
  else
 
135
    {
 
136
      const gui_model& mdl = m_model_frame->get_model();
 
137
      wxArrayString arr;
 
138
      model::const_action_iterator it;
 
139
      const model::const_action_iterator end_it = mdl.action_end();
 
140
 
 
141
      for ( it = mdl.action_begin(); it != end_it; ++it)
 
142
        arr.Add( std_to_wx_string( it->get_name() ) );
 
143
 
 
144
      arr.Sort();
 
145
      m_action_list->Set(arr);
 
146
 
 
147
      if ( mdl.has_active_action() )
 
148
        select_action(mdl.get_active_action().get_name());
 
149
    }
145
150
} // action_list_frame::fill()
146
151
 
147
152
/*----------------------------------------------------------------------------*/
149
154
 * \brief Answer to a click on a action menu entry.
150
155
 * \param event This event occured.
151
156
 */
152
 
void bf::action_list_frame::on_new_action(wxCommandEvent& event)
 
157
void bf::action_list_frame::on_new_action( wxCommandEvent& WXUNUSED(event) )
153
158
{
154
159
  if (m_model_frame != NULL)
155
160
    {
165
170
                ( dlg.get_action_name(), dlg.get_action_duration(),
166
171
                  dlg.get_sound(),
167
172
                  dlg.get_auto_next() ) ) );
168
 
          
 
173
 
169
174
          m_model_frame->set_active_action(dlg.get_action_name());
170
175
          fill();
171
176
        }
177
182
 * \brief Answer to a click on the button "delete".
178
183
 * \param event This event occured.
179
184
 */
180
 
void bf::action_list_frame::on_delete(wxCommandEvent& event)
 
185
void bf::action_list_frame::on_delete( wxCommandEvent& WXUNUSED(event) )
181
186
{
182
187
  if (m_model_frame != NULL)
183
188
    if ( !m_model_frame->empty() )
184
189
      {
185
190
        m_model_frame->clear_mark_selection();
186
 
        
187
 
        int index = m_action_list->GetSelection();        
 
191
 
 
192
        int index = m_action_list->GetSelection();
188
193
        std::string name;
189
194
        if ( m_model_frame->get_model().has_active_action() )
190
 
          name = m_model_frame->get_model().get_active_action().get_name(); 
 
195
          name = m_model_frame->get_model().get_active_action().get_name();
191
196
 
192
197
        m_model_frame->reset_active_action();
193
198
        m_model_frame->do_action
194
199
          ( new action_remove_action( name ) );
195
 
        
 
200
 
196
201
        fill();
197
 
        
198
 
        if ( ! m_model_frame->empty() )
 
202
 
 
203
        if ( !m_model_frame->empty() )
199
204
          {
200
 
            if ( index < (int)m_action_list->GetCount() ) 
 
205
            if ( index < (int)m_action_list->GetCount() )
201
206
              m_model_frame->set_active_action
202
207
                (wx_to_std_string(m_action_list->GetString(index)));
203
 
            else 
 
208
            else
204
209
              m_model_frame->set_active_action
205
210
                (wx_to_std_string(m_action_list->GetString(index-1)));
206
211
          }
207
 
        
 
212
 
208
213
         if ( m_model_frame->get_model().has_active_action() )
209
214
           select_action
210
215
             (m_model_frame->get_model().get_active_action().get_name());
216
221
 * \brief Answer to a click on the button "Properties".
217
222
 * \param event This event occured.
218
223
 */
219
 
void bf::action_list_frame::on_show_properties(wxCommandEvent& event)
 
224
void bf::action_list_frame::on_show_properties
 
225
( wxCommandEvent& WXUNUSED(event) )
220
226
{
221
227
  int index = m_action_list->GetSelection();
222
228
 
227
233
      dlg.fill_from( m_model_frame->get_model().get_action(a) );
228
234
 
229
235
      if ( dlg.ShowModal() == wxID_OK )
230
 
        m_model_frame->do_action
231
 
          ( new action_modify_action
232
 
            (& m_model_frame->get_model().get_action(a),
233
 
             dlg.get_action_name(), dlg.get_action_duration(),
234
 
             dlg.get_sound(),
235
 
             dlg.get_auto_next() ) );
236
 
      
237
 
      m_model_frame->set_active_action(dlg.get_action_name());
238
 
      fill();
 
236
        {
 
237
          m_model_frame->do_action
 
238
            ( new action_modify_action
 
239
              (& m_model_frame->get_model().get_action(a),
 
240
               dlg.get_action_name(), dlg.get_action_duration(),
 
241
               dlg.get_sound(),
 
242
               dlg.get_auto_next() ) );
 
243
 
 
244
          m_model_frame->set_active_action(dlg.get_action_name());
 
245
          fill();
 
246
        }
239
247
    }
240
248
} // model_list_frame::on_show_properties()
241
249
 
244
252
 * \brief Inform all windows about the selected action.
245
253
 * \param event This event occured.
246
254
 */
247
 
void bf::action_list_frame::on_select_action(wxCommandEvent& event)
 
255
void bf::action_list_frame::on_select_action( wxCommandEvent& event )
248
256
{
249
257
  if ( event.IsSelection() )
250
 
    {
251
 
      if ( m_model_frame != NULL )
252
 
        {
253
 
          m_model_frame->set_active_action
254
 
            (wx_to_std_string(m_action_list->GetStringSelection()));
255
 
 
256
 
          fill();
257
 
        }
258
 
    }
 
258
    if ( m_model_frame != NULL )
 
259
      {
 
260
        m_model_frame->set_active_action
 
261
          (wx_to_std_string(m_action_list->GetStringSelection()));
 
262
      }
259
263
} // action_list_frame::on_select_action()
260
264
 
261
265
/*----------------------------------------------------------------------------*/
263
267
 * \brief Procedure called when closing the window.
264
268
 * \param event This event occured.
265
269
 */
266
 
void bf::action_list_frame::on_close(wxCloseEvent& event)
 
270
void bf::action_list_frame::on_close( wxCloseEvent& event )
267
271
{
268
272
  if ( event.CanVeto() )
269
273
    {
281
285
  EVT_BUTTON( wxID_PROPERTIES, bf::action_list_frame::on_show_properties )
282
286
  EVT_LISTBOX_DCLICK( bf::action_list_frame::IDC_ACTION_LIST,
283
287
                      bf::action_list_frame::on_show_properties )
284
 
  EVT_LISTBOX( bf::action_list_frame::IDC_ACTION_LIST,
285
 
               bf::action_list_frame::on_select_action )
286
288
  EVT_CLOSE( bf::action_list_frame::on_close )
287
289
END_EVENT_TABLE()