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

Last change on this file since 534 was 524, checked in by Sam Hocevar, 12 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
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
[56]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
[131]13#include <string.h>
14
[512]15#include "common.h"
16
[481]17#include "status.h"
18#include "dprint.h"
[2]19
20status_manager *stat_man=NULL;
21
22class text_status_node
23{
[124]24  public :
[2]25  char *name;
26  text_status_node *next;
27  visual_object *show;
28  int last_update;
[124]29  text_status_node(char const *Name, visual_object *Show, text_status_node *Next)
[131]30  { name = strdup(Name);
31    show = Show;
32    next = Next;
33    last_update = 0;
[2]34  }
[129]35  ~text_status_node() { free(name); if (show) delete show; }
[124]36} ;
[2]37
38
39
40text_status_manager::text_status_manager()
[124]41{
42  first=NULL;
43  level=0;
[2]44}
45
[39]46void text_status_manager::push(char const *name, visual_object *show)
[2]47{
48  level++;
[124]49  first=new text_status_node(name,show,first);
[2]50}
51
52void text_status_manager::update(int percentage)
53{
[124]54//    return;
[2]55  if (level==1 && percentage-first->last_update>4)
56  {
[124]57      char s[256], len;
[2]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;
[494]63    for (; i<t; i++)
[2]64      s[len+i] = '.';
[494]65    for (; i<40; i++)
[124]66        s[len+i] = ' ';
[2]67    s[len+i++] = ']';
68    s[len+i] = 0;
69    dprintf("%s",s);
70  }
71}
72
73void text_status_manager::pop()
[124]74{
[2]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.