source: abuse/trunk/src/imlib/status.cpp @ 524

Last change on this file since 524 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.6 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 "common.h"
16
17#include "status.h"
18#include "dprint.h"
19
20status_manager *stat_man=NULL;
21
22class text_status_node
23{
24  public :
25  char *name;
26  text_status_node *next;
27  visual_object *show;
28  int last_update;
29  text_status_node(char const *Name, visual_object *Show, text_status_node *Next)
30  { name = strdup(Name);
31    show = Show;
32    next = Next;
33    last_update = 0;
34  }
35  ~text_status_node() { free(name); if (show) delete show; }
36} ;
37
38
39
40text_status_manager::text_status_manager()
41{
42  first=NULL;
43  level=0;
44}
45
46void text_status_manager::push(char const *name, visual_object *show)
47{
48  level++;
49  first=new text_status_node(name,show,first);
50}
51
52void text_status_manager::update(int percentage)
53{
54//    return;
55  if (level==1 && percentage-first->last_update>4)
56  {
57      char s[256], len;
58    first->last_update=percentage;
59    sprintf(s,"\r%s [",first->name);
60    len = strlen(s);
61    int t=percentage*40/100;
62    int i=0;
63    for (; i<t; i++)
64      s[len+i] = '.';
65    for (; i<40; i++)
66        s[len+i] = ' ';
67    s[len+i++] = ']';
68    s[len+i] = 0;
69    dprintf("%s",s);
70  }
71}
72
73void text_status_manager::pop()
74{
75  CONDITION(first,"No status's to pop!");
76  if (level==1) dprintf("\n");
77  level--;
78  text_status_node *p=first; first=first->next;
79  delete p;
80}
81
82
83
84
85
Note: See TracBrowser for help on using the repository browser.