source: golgotha/src/i4/test/fli_test/fli_test.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.0 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "main/main.hh"
10#include "app/app.hh"
11#include "loaders/fli_load.hh"
12#include "window/window.hh"
13#include "image/image.hh"
14#include "file/file.hh"
15
16
17class anim_window : public i4_window_class
18{
19  w32 frame_on,
20    tframes;
21  i4_image_class **im;
22public:
23  I4_EVENT_HANDLER_NAME("anim_window");
24
25  anim_window(i4_image_class **im,
26              w32 tframes)
27    : i4_window_class(400,400),
28      tframes(tframes),
29      im(im)
30  {
31    frame_on=0;
32  }
33
34  void draw(i4_draw_context_class &context)
35  {
36    im[frame_on]->put_image(local_image,0,0,context);
37    frame_on++;
38    if (frame_on>=tframes)
39      frame_on=0;
40    request_redraw();
41  }
42
43  virtual void show_self(w32 indent) { ; }
44};
45
46class test_app : public i4_application_class
47{
48public:
49  I4_EVENT_HANDLER_NAME("anim_window");
50
51  virtual w32 max_memory() const { return 6000*1024; }
52
53  void init()
54  {
55    i4_application_class::init();
56
57    i4_file_class *fp=i4_file_man.open(i4gets("fli_file"));
58    if (fp)
59    {
60      w32 tframes;
61      i4_image_class **im=i4_load_fli(fp,tframes);
62      if (!im)
63        i4_error("didn't load");
64
65      anim_window *a=new anim_window(im,tframes);
66      i4_parent_window_class *w=wm->add_mp_window(wm,50,50,
67                                                  im[0]->width(),
68                                                  im[0]->height(),i4gets("window_title"));
69      w->add_child(0,0,a);
70      delete fp;
71    }   
72  }
73
74};
75
76void i4_main(w32 argc, i4_const_str *argv)
77{
78  test_app app;
79  app.run();
80}
Note: See TracBrowser for help on using the repository browser.