~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/editor/object_selector.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-02-28 19:44:25 UTC
  • mfrom: (4.1.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080228194425-e8ilohlijv02kgcf
Tags: 0.7.2-2
* Fix FTBFS with gcc-4.3 by adding the missing include in
  src/input/evdev_device.cpp (Closes: #462238):
   + debian/patches/20_fix_FTBFS_with_gcc-4.3.
* Rename former patch so that the filename reflects the order in which
  the patches are applied:
   - debian/patches/data_dir.patch
   + debian/patches/10_fix_data_directory.
* Bump Standards-Version from 3.7.2 to 3.7.3, no changes needed.
* Add a dh_desktop call in the arch-dep part of debian/rules.
* Adjust the “missing-dep-for-interpreter guile” override since lintian
  now lists an alternative for that dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  $Id: object_selector.cxx,v 1.37 2003/03/30 13:12:35 grumbel Exp $
2
 
//
3
 
//  Pingus - A free Lemmings clone
4
 
//  Copyright (C) 1999 Ingo Ruhnke <grumbel@gmx.de>
5
 
//
6
 
//  This program is free software; you can redistribute it and/or
7
 
//  modify it under the terms of the GNU General Public License
8
 
//  as published by the Free Software Foundation; either version 2
9
 
//  of the License, or (at your option) any later version.
10
 
//
11
 
//  This program is distributed in the hope that it will be useful,
12
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
//  GNU General Public License for more details.
15
 
//
16
 
//  You should have received a copy of the GNU General Public License
17
 
//  along with this program; if not, write to the Free Software
18
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
 
 
20
 
#include <ClanLib/Core/IOData/directory_scanner.h>
21
 
#include <ClanLib/Core/Resources/resource_manager.h>
22
 
#include <ClanLib/Core/System/system.h>
23
 
#include <ClanLib/Display/Display/display.h>
24
 
#include <ClanLib/Display/Font/font.h>
25
 
#include <ClanLib/Display/Input/inputbuffer.h>
26
 
#include <ClanLib/Display/Input/mouse.h>
27
 
#include "../console.hxx"
28
 
#include "../globals.hxx"
29
 
#include "../loading.hxx"
30
 
#include "../my_gettext.hxx"
31
 
#include "../path_manager.hxx"
32
 
#include "../pingus_resource.hxx"
33
 
#include "../string_converter.hxx"
34
 
#include "../system.hxx"
35
 
#include "object_selector.hxx"
36
 
#include "object_manager.hxx"
37
 
#include "string_reader.hxx"
38
 
#include "thumb_cache.hxx"
39
 
#include "weather_obj.hxx"
40
 
#include "../prefab.hxx"
41
 
 
42
 
#include "../worldobjsdata/entrance_data.hxx"
43
 
#include "../worldobjsdata/exit_data.hxx"
44
 
#include "../worldobjsdata/groundpiece_data.hxx"
45
 
#include "../worldobjsdata/hotspot_data.hxx"
46
 
#include "../worldobjsdata/liquid_data.hxx"
47
 
#include "../worldobjsdata/solid_color_background_data.hxx"
48
 
#include "../worldobjsdata/starfield_background_data.hxx"
49
 
#include "../worldobjsdata/surface_background_data.hxx"
50
 
#include "../worldobjsdata/thunderstorm_background_data.hxx"
51
 
 
52
 
#include "../editorobjs/bumper_obj.hxx"
53
 
#include "../editorobjs/conveyor_belt_obj.hxx"
54
 
#include "../editorobjs/exit_obj.hxx"
55
 
#include "../editorobjs/fake_exit_obj.hxx"
56
 
#include "../editorobjs/guillotine_obj.hxx"
57
 
#include "../editorobjs/groundpiece_obj.hxx"
58
 
#include "../editorobjs/hammer_obj.hxx"
59
 
#include "../editorobjs/hotspot_obj.hxx"
60
 
#include "../editorobjs/ice_block_obj.hxx"
61
 
#include "../editorobjs/info_box_obj.hxx"
62
 
#include "../editorobjs/laser_exit_obj.hxx"
63
 
#include "../editorobjs/smasher_obj.hxx"
64
 
#include "../editorobjs/spike_obj.hxx"
65
 
#include "../editorobjs/switch_door_obj.hxx"
66
 
#include "../editorobjs/teleporter_obj.hxx"
67
 
 
68
 
using namespace EditorObjs;
69
 
using namespace WorldObjsData;
70
 
 
71
 
namespace EditorNS {
72
 
 
73
 
ObjectSelector::ObjectSelector ()
74
 
{
75
 
  last_object = "GroundPieces/";
76
 
  font = PingusResource::load_font("Fonts/courier_small", "fonts");
77
 
  //data_loaded = false;
78
 
}
79
 
 
80
 
ObjectSelector::~ObjectSelector ()
81
 
{
82
 
}
83
 
  
84
 
/** FIXME: Ugly interface, the arguments should not be the offset, but
85
 
    instead the absolute position */
86
 
void
87
 
ObjectSelector::get_obj (ObjectManager* arg_obj_mgr,
88
 
                         int x_off, int y_off)
89
 
{
90
 
  // FIXME: Sick coordinate handling...
91
 
  x_offset = x_off;
92
 
  y_offset = y_off;
93
 
 
94
 
  obj_mgr = arg_obj_mgr;
95
 
  pos = Vector (CL_Mouse::get_x () - x_offset,
96
 
                CL_Mouse::get_y () - y_offset, 
97
 
                0.0f);
98
 
 
99
 
  select_obj_type();
100
 
}
101
 
 
102
 
void
103
 
ObjectSelector::get_trap ()
104
 
{
105
 
  CL_Display::clear_display();
106
 
  font->print_left(20, 20, _("1 - guillotine"));
107
 
  font->print_left(20, 50, _("2 - hammer"));
108
 
  font->print_left(20, 80, _("3 - spike"));
109
 
  font->print_left(20,110, _("4 - laser_exit"));
110
 
  font->print_left(20,140, _("5 - fake_exit"));
111
 
  font->print_left(20,170, _("6 - smasher"));
112
 
  font->print_left(20,200, _("7 - bumper"));
113
 
  Display::flip_display();
114
 
 
115
 
  while (true) 
116
 
    {
117
 
      switch (read_key()) 
118
 
        {
119
 
        case CL_KEY_1:
120
 
          obj_mgr->add(GuillotineObj::create(pos));
121
 
          return;
122
 
        case CL_KEY_2:
123
 
          obj_mgr->add(HammerObj::create(pos));
124
 
          return;
125
 
        case CL_KEY_3:
126
 
          obj_mgr->add(SpikeObj::create(pos));
127
 
          return;
128
 
        case CL_KEY_4:
129
 
          obj_mgr->add(LaserExitObj::create(pos));
130
 
          return;
131
 
        case CL_KEY_5:
132
 
          obj_mgr->add(FakeExitObj::create(pos));
133
 
          return;
134
 
        case CL_KEY_6:
135
 
          obj_mgr->add(SmasherObj::create(pos));
136
 
          return;
137
 
        case CL_KEY_7:
138
 
          obj_mgr->add(BumperObj::create(pos));
139
 
          return;
140
 
        case CL_KEY_ESCAPE:
141
 
          // do nothing
142
 
          return;
143
 
        }
144
 
    }
145
 
}
146
 
 
147
 
void
148
 
ObjectSelector::get_groundpiece (const Groundtype::GPType& gptype)
149
 
{
150
 
  GroundpieceData data;
151
 
  std::string datafile = std::string("groundpieces-") + Groundtype::type_to_string (gptype);
152
 
 
153
 
  data.pos = pos;
154
 
 
155
 
  std::string str = select_surface(datafile);
156
 
 
157
 
  if (!str.empty())
158
 
    {
159
 
      data.desc = ResDescriptor(str, datafile, ResDescriptor::RD_RESOURCE);
160
 
      data.gptype = gptype;
161
 
 
162
 
      obj_mgr->add(new EditorObjs::GroundpieceObj(data));
163
 
    }
164
 
}
165
 
 
166
 
void
167
 
ObjectSelector::get_hotspot (const std::string& filename)
168
 
{
169
 
  HotspotData data;
170
 
  data.pos = pos;
171
 
  std::string str = select_surface(filename);
172
 
 
173
 
  if (!str.empty())
174
 
    {
175
 
      data.desc = ResDescriptor(str, filename, ResDescriptor::RD_RESOURCE);
176
 
      data.speed = -1;
177
 
    }
178
 
  
179
 
  data.insert_EditorObjs(obj_mgr);
180
 
}
181
 
 
182
 
void
183
 
ObjectSelector::get_worldobj ()
184
 
{
185
 
  CL_Display::clear_display();
186
 
  font->print_left(20,  20, _("Select a WorldObj"));
187
 
  font->print_left(20,  50, _("1 - teleporter"));
188
 
  font->print_left(20,  70, _("2 - switch and door"));
189
 
  font->print_left(20,  90, _("3 - ConveyorBelt"));
190
 
  font->print_left(20, 110, _("4 - IceBlock"));
191
 
  font->print_left(20, 130, _("5 - InfoBox"));
192
 
  //font->print_left(20, 110, _("5 - Liquid"));
193
 
  Display::flip_display();
194
 
 
195
 
  while (true) 
196
 
    {
197
 
      switch (read_key()) 
198
 
        {
199
 
        case CL_KEY_1:
200
 
          obj_mgr->add(TeleporterObj::create(pos));
201
 
          return;
202
 
          
203
 
        case CL_KEY_2:
204
 
          obj_mgr->add(SwitchDoorObj::create(pos));
205
 
          return;
206
 
          
207
 
        case CL_KEY_3:
208
 
          obj_mgr->add(ConveyorBeltObj::create(pos));
209
 
          return;
210
 
          
211
 
        case CL_KEY_4:
212
 
          obj_mgr->add(IceBlockObj::create(pos));
213
 
          return;
214
 
          
215
 
        case CL_KEY_5:
216
 
          obj_mgr->add(InfoBoxObj::create(pos));
217
 
          return;
218
 
          
219
 
        case CL_KEY_ESCAPE:
220
 
          return;
221
 
        }
222
 
    }
223
 
}
224
 
 
225
 
void
226
 
ObjectSelector::get_weather ()
227
 
{
228
 
  std::string type;
229
 
  bool done = false;
230
 
 
231
 
  CL_Display::clear_display();
232
 
  font->print_left(20, 20, _("Select a weather"));
233
 
  font->print_left(20, 50, _("1 - snow"));
234
 
  font->print_left(20, 70, _("2 - rain"));
235
 
  Display::flip_display();
236
 
 
237
 
  while (!done) 
238
 
    {
239
 
      switch (read_key()) 
240
 
        {
241
 
        case CL_KEY_1:
242
 
          type = "snow-generator";
243
 
          done = true;
244
 
          break;
245
 
        case CL_KEY_2:
246
 
          type = "rain-generator";
247
 
          done = true;
248
 
          break;
249
 
        }
250
 
    }
251
 
  
252
 
  std::cout << "Weather objects currently not implemented" << std::endl;
253
 
 
254
 
  obj_mgr->add(new WeatherObj(type));
255
 
}
256
 
 
257
 
void
258
 
ObjectSelector::get_entrance ()
259
 
{
260
 
  EntranceData entrance;
261
 
  bool have_name = false;
262
 
  entrance.pos = pos;
263
 
 
264
 
  CL_Display::clear_display();
265
 
  font->print_left(20, 20, _("Select an entrance"));
266
 
  font->print_left(20, 50, _("1 - generic"));
267
 
  font->print_left(20, 70, _("2 - woodthing"));
268
 
  font->print_left(20, 90, _("3 - cloud"));
269
 
  font->print_left(20, 120, _("h - entrance surface (hotspot)"));
270
 
  Display::flip_display();
271
 
 
272
 
  while (!have_name) 
273
 
    {
274
 
      switch (read_key()) 
275
 
        {
276
 
 
277
 
        case CL_KEY_1:
278
 
          entrance.type = "generic";
279
 
          have_name = true;
280
 
          break;
281
 
 
282
 
        case CL_KEY_2:
283
 
          entrance.type = "woodthing";
284
 
          have_name = true;
285
 
          break;
286
 
 
287
 
        case CL_KEY_3:
288
 
          entrance.type = "cloud";
289
 
          have_name = true;
290
 
          break;
291
 
 
292
 
        case CL_KEY_4:
293
 
        case CL_KEY_H:
294
 
          get_hotspot("entrances");
295
 
          break;
296
 
 
297
 
        default:
298
 
          if (verbose) std::cout << "Unknown keypressed" << std::endl;
299
 
          break;
300
 
        }
301
 
    }
302
 
  
303
 
  entrance.insert_EditorObjs (obj_mgr);
304
 
}
305
 
 
306
 
void
307
 
ObjectSelector::get_exit ()
308
 
{
309
 
  std::string str;
310
 
  ExitData data;
311
 
  data.pos = pos;
312
 
  
313
 
  str = select_surface("exits");
314
 
  
315
 
  last_object = str;
316
 
 
317
 
  if (str.empty())
318
 
    return;
319
 
  
320
 
  data.desc = ResDescriptor(str, "exits", ResDescriptor::RD_RESOURCE);
321
 
  
322
 
  data.insert_EditorObjs (obj_mgr);
323
 
}
324
 
 
325
 
void
326
 
ObjectSelector::get_liquid ()
327
 
{
328
 
  std::cout << "ObjectSelector::get_liquid() not implemented" << std::endl;
329
 
  LiquidData data;
330
 
 
331
 
  data.pos = pos;
332
 
  data.old_width_handling = false;
333
 
  data.width = 5;
334
 
  data.desc = ResDescriptor("Liquid/slime", "liquids", ResDescriptor::RD_RESOURCE);
335
 
 
336
 
  data.insert_EditorObjs (obj_mgr);
337
 
}
338
 
 
339
 
void
340
 
ObjectSelector::get_from_file ()
341
 
{
342
 
  CL_Display::clear_display();
343
 
  font->print_left(20, 20, _("What object type do you want?"));
344
 
  font->print_left(20, 50, _("h - Hotspot"));
345
 
  font->print_left(20, 70, _("g - Groundpiece (ground) [not implemented]")); 
346
 
  Display::flip_display();
347
 
 
348
 
  while (true) 
349
 
    {
350
 
      switch (read_key()) 
351
 
        {
352
 
        case CL_KEY_H:
353
 
          {
354
 
            System::Directory dir = System::opendir (System::get_statdir () + "images/");
355
 
            std::list<std::string> strs;
356
 
 
357
 
            for (System::DirectoryIter i = dir.begin (); i != dir.end (); ++i)
358
 
              {
359
 
                if (i->type == System::DirectoryEntry::DE_FILE)
360
 
                  {
361
 
                    //std::cout << "Directory entry: " << System::get_statdir() + "images/" + i->name << std::endl;
362
 
                    strs.push_back (System::get_statdir() + "images/" + i->name);
363
 
                  }
364
 
              }
365
 
 
366
 
            StringReader reader("Input the image name:",
367
 
                                System::get_statdir () + "images/");
368
 
            reader.set_strings(&strs);
369
 
            std::string file = reader.read_string();
370
 
            HotspotData data;
371
 
            data.pos = pos;
372
 
            // FIXME: Ugly hack, since ClanLib appends './'
373
 
            data.desc = ResDescriptor ("../../../../../../../../../../../" + file, 
374
 
                                       "", ResDescriptor::RD_FILE);
375
 
            data.insert_EditorObjs(obj_mgr);
376
 
            return;
377
 
          }
378
 
          break;
379
 
 
380
 
        case CL_KEY_G:
381
 
          console << "ObjectSelector: Inserting groundpieces is not implemented" << std::endl;
382
 
          return;
383
 
 
384
 
        case CL_KEY_ESCAPE:
385
 
          return;
386
 
        }
387
 
    }
388
 
}
389
 
 
390
 
void
391
 
ObjectSelector::select_obj_type ()
392
 
{
393
 
  CL_Display::clear_display();
394
 
  font->print_left(20, 20, _("Which object do you want?"));
395
 
  font->print_left(20, 70, _("g - Groundpiece (ground)"));
396
 
  font->print_left(20, 90, _("s - Groundpiece (solid)"));
397
 
  font->print_left(20,110, _("b - Groundpiece (bridge)"));
398
 
  font->print_left(20,130, _("n - Groundpiece (transparent)"));
399
 
  font->print_left(20,150, _("r - Groundpiece (remove)"));
400
 
  font->print_left(20,170, _("h - Hotspot"));
401
 
  font->print_left(20,190, _("e - Entrance"));
402
 
  font->print_left(20,210, _("x - Exit"));
403
 
  font->print_left(20,230, _("l - Liquid"));
404
 
  font->print_left(20,250, _("w - Weather"));
405
 
  font->print_left(20,270, _("t - Traps"));
406
 
  font->print_left(20,290, _("o - WorldObject"));
407
 
  font->print_left(20,310, _("z - Background"));
408
 
  font->print_left(20,330, _("p - Prefab (ObjectGroup)"));
409
 
  font->print_left(20,350, _("f - something from file (~/.pingus/images/)"));
410
 
  Display::flip_display();
411
 
 
412
 
  while (1) 
413
 
    {
414
 
      switch (read_key()) 
415
 
        {
416
 
        case CL_KEY_T:
417
 
          get_trap();
418
 
          return;
419
 
 
420
 
        case CL_KEY_B:
421
 
          get_groundpiece(Groundtype::GP_BRIDGE);
422
 
          return;
423
 
          
424
 
        case CL_KEY_R:
425
 
          get_groundpiece(Groundtype::GP_REMOVE);
426
 
          return;
427
 
          
428
 
        case CL_KEY_S:
429
 
          get_groundpiece(Groundtype::GP_SOLID);
430
 
          return;
431
 
 
432
 
        case CL_KEY_G:
433
 
          get_groundpiece(Groundtype::GP_GROUND);
434
 
          return;
435
 
 
436
 
        case CL_KEY_N:
437
 
          get_groundpiece(Groundtype::GP_TRANSPARENT);
438
 
          return;
439
 
 
440
 
        case CL_KEY_H:
441
 
          get_hotspot("hotspots");
442
 
          return;
443
 
                  
444
 
        case CL_KEY_E:
445
 
          get_entrance();
446
 
          return;
447
 
 
448
 
        case CL_KEY_X:
449
 
          get_exit();
450
 
          return;
451
 
 
452
 
        case CL_KEY_L:
453
 
          std::cout << "ObjectSelector: Liquid not implemented" << std::endl;
454
 
          get_liquid();
455
 
          return;
456
 
 
457
 
        case CL_KEY_W:
458
 
          get_weather();
459
 
          return;
460
 
          
461
 
        case CL_KEY_P:
462
 
          get_prefab();
463
 
          return;
464
 
 
465
 
        case CL_KEY_O:
466
 
          get_worldobj();
467
 
          return;
468
 
 
469
 
        case CL_KEY_Z:
470
 
          get_background();
471
 
          return;
472
 
                  
473
 
        case CL_KEY_F:
474
 
          get_from_file();
475
 
          return;
476
 
 
477
 
        case CL_KEY_ESCAPE:
478
 
          return;
479
 
        }
480
 
    }
481
 
}
482
 
 
483
 
 
484
 
void
485
 
ObjectSelector::get_prefab ()
486
 
{
487
 
  CL_DirectoryScanner dir;
488
 
  std::vector<std::string> dir_lst;
489
 
  if (dir.scan(path_manager.complete ("prefabs/"), "*.xml"))
490
 
    {
491
 
      while (dir.next ()) {
492
 
        std::string filename = dir.get_name ();
493
 
        dir_lst.push_back (filename.substr(0, filename.length()-4));
494
 
      }
495
 
    }
496
 
 
497
 
  CL_Display::clear_display();
498
 
  font->print_left(20, 20, _("Which prefab do you want?"));
499
 
 
500
 
  for (std::vector<std::string>::size_type i = 0; i < dir_lst.size (); ++i)
501
 
    {
502
 
      font->print_left(20, 60 + i * 30, to_string(i + 1) + " - " + dir_lst[i]); 
503
 
    }
504
 
 
505
 
  Display::flip_display();
506
 
  
507
 
  int item = -1;
508
 
  while (item == -1) 
509
 
    {
510
 
      switch (read_key()) 
511
 
        {
512
 
        case CL_KEY_1:
513
 
          item = 1;
514
 
          break;
515
 
        case CL_KEY_2:
516
 
          item = 2;
517
 
          break;
518
 
        case CL_KEY_3:
519
 
          item = 3;
520
 
          break;
521
 
        case CL_KEY_4:
522
 
          item = 4;
523
 
          break;
524
 
        case CL_KEY_5:
525
 
          item = 5;
526
 
          break;
527
 
        case CL_KEY_6:
528
 
          item = 6;
529
 
          break;
530
 
        case CL_KEY_7:
531
 
          item = 7;
532
 
          break;
533
 
        case CL_KEY_8:
534
 
          item = 8;
535
 
          break;
536
 
        case CL_KEY_9:
537
 
          item = 9;
538
 
          break;
539
 
          
540
 
        case CL_KEY_ESCAPE: 
541
 
          return;
542
 
        }
543
 
    }
544
 
 
545
 
  if ((item-1) < static_cast<int>(dir_lst.size()))
546
 
    {
547
 
      std::cout << "ObjectSelector: Inserting prefab: " << dir_lst[item-1] << std::endl;
548
 
      Prefab* prefab = Prefab::create(dir_lst[item-1]);
549
 
      prefab->get_data()->insert_EditorObjs(obj_mgr);
550
 
      delete prefab;
551
 
    }
552
 
  else
553
 
    {
554
 
      std::cout << "ObjectSelector: invalid prefab selected" << std::endl;
555
 
    }
556
 
}
557
 
 
558
 
void
559
 
ObjectSelector::get_background ()
560
 
{
561
 
  CL_Display::clear_display();
562
 
  font->print_left(20, 20, _("Which object do you want?"));
563
 
  font->print_left(20, 50, _("1 - Surface Background"));
564
 
  font->print_left(20, 70, _("2 - Solid Color Background"));
565
 
  font->print_left(20, 90, _("3 - Starfield Background"));
566
 
  font->print_left(20,110, _("4 - Thunderstorm Background"));
567
 
  Display::flip_display();
568
 
 
569
 
  while (1) 
570
 
    {
571
 
      switch (read_key()) 
572
 
        {
573
 
        case CL_KEY_1:
574
 
          {
575
 
            SurfaceBackgroundData data;
576
 
            data.desc.datafile = "textures";
577
 
            data.desc.res_name = select_surface("textures");
578
 
 
579
 
            if (!data.desc.res_name.empty())
580
 
              {
581
 
                data.insert_EditorObjs(obj_mgr);
582
 
              }
583
 
            return;
584
 
          }
585
 
          return;
586
 
        case CL_KEY_2:
587
 
          SolidColorBackgroundData().insert_EditorObjs(obj_mgr);
588
 
          return;
589
 
        case CL_KEY_3:
590
 
          StarfieldBackgroundData().insert_EditorObjs(obj_mgr);
591
 
          return;
592
 
        case CL_KEY_4:
593
 
          ThunderstormBackgroundData ().insert_EditorObjs(obj_mgr);
594
 
          return;
595
 
        }
596
 
    }
597
 
}
598
 
 
599
 
std::string
600
 
ObjectSelector::select_surface (std::vector<surface_obj>& sur_list)
601
 
{
602
 
  std::cout << "ObjectSelector: Selecting surface out of: " << sur_list.size () << std::endl;
603
 
  SurfaceSelector sur_selector(&sur_list);
604
 
 
605
 
  return sur_selector.select();
606
 
}
607
 
 
608
 
std::string
609
 
ObjectSelector::select_surface (const std::string & resource_file)
610
 
{
611
 
  std::string str;
612
 
  bool datafile_loaded;
613
 
  CL_ResourceManager* res = PingusResource::get(resource_file);
614
 
  GroundpieceData data;
615
 
 
616
 
  datafile_loaded = data_loaded[resource_file];
617
 
  
618
 
  data.pos = pos;
619
 
  
620
 
  std::list<std::string>* liste = res->get_resources_of_type("surface");
621
 
  surface_obj sur_obj;
622
 
  std::vector<surface_obj> sur_list;
623
 
  int j = 0;
624
 
 
625
 
  for(std::list<std::string>::iterator i = liste->begin(); i != liste->end(); ++i)
626
 
    {
627
 
      // FIXME: This should be moved to ThumbCache
628
 
      ++j;
629
 
      sur_obj.name = *i;
630
 
      sur_obj.datafile = resource_file;
631
 
      sur_obj.thumbnail = ThumbCache::load (*i, resource_file);
632
 
 
633
 
      sur_list.push_back(sur_obj);
634
 
 
635
 
      if (!datafile_loaded && (j % 25) == 0)
636
 
        {
637
 
          loading_screen.draw_progress(i->c_str(), (float)j / liste->size());
638
 
        }
639
 
    }
640
 
  // Showing the mousecursor again, since loading_screen hides it
641
 
  Display::show_cursor();
642
 
  data_loaded[resource_file] = true;
643
 
  //data_loaded = false;
644
 
  return select_surface(sur_list);
645
 
}
646
 
 
647
 
int
648
 
ObjectSelector::read_key ()
649
 
{
650
 
  CL_InputBuffer keys;
651
 
  CL_Key key;
652
 
 
653
 
  keys.clear();
654
 
 
655
 
  while (true) 
656
 
    { 
657
 
      CL_System::keep_alive();
658
 
      
659
 
      if (keys.peek_key().state != CL_Key::NoKey) 
660
 
        {
661
 
          key = keys.get_key();
662
 
          //std::cout << "key: " << key.ascii << std::endl;
663
 
          return key.id;
664
 
        }
665
 
    }
666
 
}
667
 
 
668
 
std::string
669
 
ObjectSelector::read_string (const std::string & description, const std::string & def_str)
670
 
{
671
 
  StringReader reader(description, def_str);
672
 
  reader.set_strings(PingusResource::get("global")->get_resources_of_type("surface"));
673
 
  return reader.read_string();
674
 
}
675
 
 
676
 
} // namespace EditorNS
677
 
 
678
 
/* EOF */