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

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

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

File size: 1.7 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
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[555]11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
[56]14
[131]15#include <string.h>
16
[512]17#include "common.h"
18
[481]19#include "status.h"
20#include "dprint.h"
[2]21
22status_manager *stat_man=NULL;
23
24class text_status_node
25{
[124]26  public :
[2]27  char *name;
28  text_status_node *next;
29  visual_object *show;
30  int last_update;
[124]31  text_status_node(char const *Name, visual_object *Show, text_status_node *Next)
[131]32  { name = strdup(Name);
33    show = Show;
34    next = Next;
35    last_update = 0;
[2]36  }
[129]37  ~text_status_node() { free(name); if (show) delete show; }
[124]38} ;
[2]39
40
41
42text_status_manager::text_status_manager()
[124]43{
44  first=NULL;
45  level=0;
[2]46}
47
[39]48void text_status_manager::push(char const *name, visual_object *show)
[2]49{
50  level++;
[124]51  first=new text_status_node(name,show,first);
[2]52}
53
54void text_status_manager::update(int percentage)
55{
[124]56//    return;
[2]57  if (level==1 && percentage-first->last_update>4)
58  {
[124]59      char s[256], len;
[2]60    first->last_update=percentage;
61    sprintf(s,"\r%s [",first->name);
62    len = strlen(s);
63    int t=percentage*40/100;
64    int i=0;
[494]65    for (; i<t; i++)
[2]66      s[len+i] = '.';
[494]67    for (; i<40; i++)
[124]68        s[len+i] = ' ';
[2]69    s[len+i++] = ']';
70    s[len+i] = 0;
71    dprintf("%s",s);
72  }
73}
74
75void text_status_manager::pop()
[124]76{
[2]77  CONDITION(first,"No status's to pop!");
78  if (level==1) dprintf("\n");
79  level--;
80  text_status_node *p=first; first=first->next;
81  delete p;
82}
83
84
85
86
87
Note: See TracBrowser for help on using the repository browser.