source: abuse/trunk/src/status.cpp @ 2

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