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

Last change on this file since 481 was 481, checked in by Sam Hocevar, 11 years ago

Fuck the history, I'm renaming all .hpp files to .h for my own sanity.

File size: 1.4 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12#include <string.h>
13
14#include "macs.h"
15#include "status.h"
16#include "dprint.h"
17
18class status_node;
19
20class StatusManager
21{
22  status_node *first;
23  StatusManager() { first=NULL; }
24  virtual void push(char *name, visual_object *show);
25  virtual void update(int percentage);
26  virtual void pop();
27} ;
28
29extern StatusManager *stat_man;
30
31
32
33StatusManager *stat_man=NULL;
34
35class status_node
36{
37  public :
38  char *name;
39  status_node *next;
40  visual_object *show;
41  time_marker last_update;
42  status_node(char *Name, visual_object *Show, status_node *Next)
43  { name = strdup(Name);
44    show = Show;
45    next = Next;
46  }
47  ~status_node() { free(name); if (show) delete show; }
48}
49
50
51
52
53void StatusManager::push(char *name, visual_object *show)
54{
55  first=new status_node(name,show,first);
56}
57
58void StatusManager::update(int percentage)
59{
60  dprintf("\r%s [\n");
61  int t=percentage/5;
62  for (int i=0;i<t;i++)
63    dprintf(".");
64  for (i=t+1;i<20;i++)
65    dprintf(" ");
66  dprintf("]");
67}
68
69void StatusManager::pop()
70{
71  CONDITION(first,"No status's to pop!");
72  status_node *p=first; first=first->next;
73  delete p;
74}
75
76
77
78
79
Note: See TracBrowser for help on using the repository browser.