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

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

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

File size: 1.5 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, by
8 *  Jonathan Clark, or by Sam Hocevar.
9 */
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <string.h>
16
17#include "status.h"
18#include "dprint.h"
19
20class status_node;
21
22class StatusManager
23{
24  status_node *first;
25  StatusManager() { first=NULL; }
26  virtual void push(char *name, visual_object *show);
27  virtual void update(int percentage);
28  virtual void pop();
29} ;
30
31extern StatusManager *stat_man;
32
33
34
35StatusManager *stat_man=NULL;
36
37class status_node
38{
39  public :
40  char *name;
41  status_node *next;
42  visual_object *show;
43  time_marker last_update;
44  status_node(char *Name, visual_object *Show, status_node *Next)
45  { name = strdup(Name);
46    show = Show;
47    next = Next;
48  }
49  ~status_node() { free(name); if (show) delete show; }
50}
51
52
53
54
55void StatusManager::push(char *name, visual_object *show)
56{
57  first=new status_node(name,show,first);
58}
59
60void StatusManager::update(int percentage)
61{
62  dprintf("\r%s [\n");
63  int t=percentage/5;
64  for (int i=0; i<t; i++)
65    dprintf(".");
66  for (i=t+1; i<20; i++)
67    dprintf(" ");
68  dprintf("]");
69}
70
71void StatusManager::pop()
72{
73  CONDITION(first,"No status's to pop!");
74  status_node *p=first; first=first->next;
75  delete p;
76}
77
78
79
80
81
Note: See TracBrowser for help on using the repository browser.