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

Last change on this file since 112 was 56, checked in by Sam Hocevar, 12 years ago
  • Add licensing terms to most C / C++ files (Ref #5).
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 "macs.hpp"
13#include "status.hpp"
14#include "dprint.hpp"
15
16class status_node;
17
18class StatusManager
19{
20  status_node *first;
21  StatusManager() { first=NULL; }
22  virtual void push(char *name, visual_object *show);
23  virtual void update(int percentage);
24  virtual void pop();
25} ;
26
27extern StatusManager *stat_man;
28
29
30
31StatusManager *stat_man=NULL;
32
33class status_node
34{
35  public :
36  char *name;
37  status_node *next;
38  visual_object *show;
39  time_marker last_update;
40  status_node(char *Name, visual_object *Show, status_node *Next)
41  { name=strcpy((char *)jmalloc(strlen(Name)+1,"status name"),Name);
42    show=Show;
43    next=Next;
44  }
45  ~status_node() { jfree(name); if (show) delete show; }
46}
47
48
49
50
51void StatusManager::push(char *name, visual_object *show)
52{
53  first=new status_node(name,show,first); 
54}
55
56void StatusManager::update(int percentage)
57{
58  dprintf("\r%s [\n");
59  int t=percentage/5;
60  for (int i=0;i<t;i++)
61    dprintf(".");
62  for (i=t+1;i<20;i++)
63    dprintf(" ");
64  dprintf("]");
65}
66
67void StatusManager::pop()
68{
69  CONDITION(first,"No status's to pop!");
70  status_node *p=first; first=first->next;
71  delete p;
72}
73
74
75
76
77
Note: See TracBrowser for help on using the repository browser.