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

Last change on this file since 128 was 124, checked in by Sam Hocevar, 15 years ago
  • Get rid of ugly tabs and trailing spaces everywhere.
File size: 1.6 KB
RevLine 
[56]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
[2]12#include "macs.hpp"
13#include "status.hpp"
14#include "dprint.hpp"
15
16status_manager *stat_man=NULL;
17
18class text_status_node
19{
[124]20  public :
[2]21  char *name;
22  text_status_node *next;
23  visual_object *show;
24  int last_update;
[124]25  text_status_node(char const *Name, visual_object *Show, text_status_node *Next)
26  { name=strcpy((char *)jmalloc(strlen(Name)+1,"status name"),Name);
[2]27    show=Show;
[124]28    next=Next;
[2]29    last_update=0;
30  }
31  ~text_status_node() { jfree(name); if (show) delete show; }
[124]32} ;
[2]33
34
35
36text_status_manager::text_status_manager()
[124]37{
38  first=NULL;
39  level=0;
[2]40}
41
[39]42void text_status_manager::push(char const *name, visual_object *show)
[2]43{
44  level++;
[124]45  first=new text_status_node(name,show,first);
[2]46}
47
48void text_status_manager::update(int percentage)
49{
[124]50//    return;
[2]51  if (level==1 && percentage-first->last_update>4)
52  {
[124]53      char s[256], len;
[2]54    first->last_update=percentage;
55    sprintf(s,"\r%s [",first->name);
56    len = strlen(s);
57    int t=percentage*40/100;
58    int i=0;
59    for (;i<t;i++)
60      s[len+i] = '.';
61    for (;i<40;i++)
[124]62        s[len+i] = ' ';
[2]63    s[len+i++] = ']';
64    s[len+i] = 0;
65    dprintf("%s",s);
66  }
67}
68
69void text_status_manager::pop()
[124]70{
[2]71  CONDITION(first,"No status's to pop!");
72  if (level==1) dprintf("\n");
73  level--;
74  text_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.