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

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

core: Get rid of mostly useless headers, move endianness handling to
common.h (and rewrite functions so that they do not need the SDL headers)
and move a few functions out of sdlport's video.cpp. These functions
were in the original video.cpp (which reappears) and shouldn't be part
of the SDL port.

File size: 1.4 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com or
8 *  Jonathan Clark.
9 */
10
11#include "config.h"
12
13#include <string.h>
14
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.