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

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

imlib: use vec2i for image::size and unroll all necessary changes
everywhere else in the code.

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