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