source: abuse/branches/pd/macabuse/imlib/status.c @ 161

Last change on this file since 161 was 49, checked in by Sam Hocevar, 15 years ago
  • Imported original public domain release, for future reference.
  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1#include "macs.hpp"
2#include "status.hpp"
3#include "dprint.hpp"
4
5status_manager *stat_man=NULL;
6
7class text_status_node
8{
9  public : 
10  char *name;
11  text_status_node *next;
12  visual_object *show;
13  int last_update;
14  text_status_node(char *Name, visual_object *Show, text_status_node *Next)
15  { name=strcpy((char *)jmalloc(strlen(Name)+1,"status name"),Name);
16    show=Show;
17    next=Next;
18    last_update=0;
19  }
20  ~text_status_node() { jfree(name); if (show) delete show; }
21} ;
22
23
24
25text_status_manager::text_status_manager()
26{
27  first=NULL;
28  level=0;
29}
30
31void text_status_manager::push(char *name, visual_object *show)
32{
33  level++;
34  first=new text_status_node(name,show,first); 
35}
36
37void text_status_manager::update(int percentage)
38{
39        return;
40  if (level==1 && percentage-first->last_update>4)
41  {
42        char s[256], len;
43    first->last_update=percentage;
44    sprintf(s,"\r%s [",first->name);
45    len = strlen(s);
46    int t=percentage*40/100;
47    int i=0;
48    for (;i<t;i++)
49      s[len+i] = '.';
50    for (;i<40;i++)
51        s[len+i] = ' ';
52    s[len+i++] = ']';
53    s[len+i] = 0;
54    dprintf("%s",s);
55  }
56}
57
58void text_status_manager::pop()
59
60  CONDITION(first,"No status's to pop!");
61  if (level==1) dprintf("\n");
62  level--;
63  text_status_node *p=first; first=first->next;
64  delete p;
65}
66
67
68
69
70
Note: See TracBrowser for help on using the repository browser.