Last change
on this file since 57 was
56,
checked in by Sam Hocevar, 14 years ago
|
- Add licensing terms to most C / C++ files (Ref #5).
|
File size:
1.6 KB
|
Line | |
---|
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 | |
---|
12 | #include "macs.hpp" |
---|
13 | #include "status.hpp" |
---|
14 | #include "dprint.hpp" |
---|
15 | |
---|
16 | status_manager *stat_man=NULL; |
---|
17 | |
---|
18 | class text_status_node |
---|
19 | { |
---|
20 | public : |
---|
21 | char *name; |
---|
22 | text_status_node *next; |
---|
23 | visual_object *show; |
---|
24 | int last_update; |
---|
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); |
---|
27 | show=Show; |
---|
28 | next=Next; |
---|
29 | last_update=0; |
---|
30 | } |
---|
31 | ~text_status_node() { jfree(name); if (show) delete show; } |
---|
32 | } ; |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | text_status_manager::text_status_manager() |
---|
37 | { |
---|
38 | first=NULL; |
---|
39 | level=0; |
---|
40 | } |
---|
41 | |
---|
42 | void text_status_manager::push(char const *name, visual_object *show) |
---|
43 | { |
---|
44 | level++; |
---|
45 | first=new text_status_node(name,show,first); |
---|
46 | } |
---|
47 | |
---|
48 | void text_status_manager::update(int percentage) |
---|
49 | { |
---|
50 | // return; |
---|
51 | if (level==1 && percentage-first->last_update>4) |
---|
52 | { |
---|
53 | char s[256], len; |
---|
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++) |
---|
62 | s[len+i] = ' '; |
---|
63 | s[len+i++] = ']'; |
---|
64 | s[len+i] = 0; |
---|
65 | dprintf("%s",s); |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | void text_status_manager::pop() |
---|
70 | { |
---|
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.