1 | #include "macstat.hpp" |
---|
2 | #include "dprint.hpp" |
---|
3 | |
---|
4 | extern Rect *gRect; |
---|
5 | |
---|
6 | #define ABUSE_STAT_ID 134 |
---|
7 | #define ABUSE_BARPAT1_ID 128 |
---|
8 | #define ABUSE_BARPAT2_ID 129 |
---|
9 | #define ABUSE_BARPAT3_ID 130 |
---|
10 | #define ABUSE_BARPATBG_ID 131 |
---|
11 | |
---|
12 | class mac_status_node |
---|
13 | { |
---|
14 | public : |
---|
15 | char *name; |
---|
16 | mac_status_node *next; |
---|
17 | visual_object *show; |
---|
18 | int last_update; |
---|
19 | mac_status_node(char *Name, visual_object *Show, mac_status_node *Next) |
---|
20 | { |
---|
21 | name=strcpy((char *)jmalloc(strlen(Name)+1,"status name"),Name); |
---|
22 | show=Show; |
---|
23 | next=Next; |
---|
24 | last_update=0; |
---|
25 | } |
---|
26 | ~mac_status_node() { jfree(name); if (show) delete show; } |
---|
27 | } ; |
---|
28 | |
---|
29 | mac_status_manager::mac_status_manager() |
---|
30 | { |
---|
31 | first=NULL; |
---|
32 | level=0; |
---|
33 | } |
---|
34 | |
---|
35 | void mac_status_manager::push(char *name, visual_object *show) |
---|
36 | { |
---|
37 | // return; |
---|
38 | |
---|
39 | Rect r; |
---|
40 | |
---|
41 | level++; |
---|
42 | first=new mac_status_node(name,show,first); |
---|
43 | if (level==1) |
---|
44 | { |
---|
45 | PicHandle thePicture; |
---|
46 | Rect picFrame,r; |
---|
47 | int picWX,picWY; |
---|
48 | PixPatHandle patbg; |
---|
49 | |
---|
50 | thePicture = GetPicture(ABUSE_STAT_ID); |
---|
51 | picFrame = (**thePicture).picFrame; |
---|
52 | picWX = (picFrame.right - picFrame.left); |
---|
53 | picWY = (picFrame.bottom - picFrame.top); |
---|
54 | |
---|
55 | #if 1 |
---|
56 | r.left = (gRect->left+gRect->right)/2 - picWX/2; |
---|
57 | r.right = (gRect->left+gRect->right)/2 + picWX/2; |
---|
58 | r.top = (gRect->top+gRect->bottom)/2 - picWY/2; |
---|
59 | r.bottom = (gRect->top+gRect->bottom)/2 + picWY/2; |
---|
60 | #else |
---|
61 | r = *gRect; |
---|
62 | #endif |
---|
63 | |
---|
64 | win = (CWindowPtr)NewCWindow(nil, &r, "\p", TRUE, 2, (WindowPtr)-1L, FALSE, 0); |
---|
65 | |
---|
66 | GetGWorld(&saveWorld, &saveDevice); |
---|
67 | SetGWorld((GWorldPtr)win,saveDevice); |
---|
68 | |
---|
69 | pat1 = GetPixPat(ABUSE_BARPAT1_ID); |
---|
70 | pat2 = GetPixPat(ABUSE_BARPAT2_ID); |
---|
71 | pat3 = GetPixPat(ABUSE_BARPAT3_ID); |
---|
72 | patbg = GetPixPat(ABUSE_BARPATBG_ID); |
---|
73 | |
---|
74 | FillCRect(&r,patbg); |
---|
75 | #if 1 |
---|
76 | r = picFrame; |
---|
77 | #else |
---|
78 | r.left = (gRect->left+gRect->right)/2 - picWX/2; |
---|
79 | r.right = (gRect->left+gRect->right)/2 + picWX/2; |
---|
80 | r.top = (gRect->top+gRect->bottom)/2 - picWY/2; |
---|
81 | r.bottom = (gRect->top+gRect->bottom)/2 + picWY/2; |
---|
82 | #endif |
---|
83 | DrawPicture(thePicture, &r); |
---|
84 | |
---|
85 | ReleaseResource((Handle)thePicture); |
---|
86 | ReleaseResource((Handle)patbg); |
---|
87 | } |
---|
88 | |
---|
89 | if (level == 1 || level == 2) |
---|
90 | { |
---|
91 | #if 1 |
---|
92 | r.left = 296 + level*5 - 6 + level; |
---|
93 | r.right = 296 + level*5; |
---|
94 | r.top = 205; |
---|
95 | r.bottom = 205 + 162; |
---|
96 | #else |
---|
97 | r.left = ((gRect->right - gRect->left)/2) + 127 + level*5 - 6 + level; |
---|
98 | r.right = ((gRect->right - gRect->left)/2) + 127 + level*5; |
---|
99 | r.top = ((gRect->bottom - gRect->top)/2) + 5; |
---|
100 | r.bottom = ((gRect->bottom - gRect->top)/2) + 5 + 162; |
---|
101 | #endif |
---|
102 | FillCRect(&r,pat1); |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | void mac_status_manager::update(int percentage) |
---|
107 | { |
---|
108 | // return; |
---|
109 | |
---|
110 | Rect r; |
---|
111 | |
---|
112 | #if 1 |
---|
113 | r.left = 296 + level*5 - 6 + level; |
---|
114 | r.right = 296 + level*5; |
---|
115 | r.top = 205 + 162 - percentage*162/100; |
---|
116 | r.bottom = 205 + 162; |
---|
117 | #else |
---|
118 | r.left = ((gRect->right - gRect->left)/2) + 127 + level*5 - 6 + level; |
---|
119 | r.right = ((gRect->right - gRect->left)/2) + 127 + level*5; |
---|
120 | r.top = ((gRect->bottom - gRect->top)/2) + 5 + 162 - percentage*162/100; |
---|
121 | r.bottom = ((gRect->bottom - gRect->top)/2) + 5 + 162; |
---|
122 | #endif |
---|
123 | if (level == 1) |
---|
124 | FillCRect(&r,pat2); |
---|
125 | else if (level == 2) |
---|
126 | FillCRect(&r,pat3); |
---|
127 | } |
---|
128 | |
---|
129 | void mac_status_manager::pop() |
---|
130 | { |
---|
131 | // return; |
---|
132 | |
---|
133 | level--; |
---|
134 | mac_status_node *p=first; |
---|
135 | first=first->next; |
---|
136 | delete p; |
---|
137 | |
---|
138 | if (level==0) |
---|
139 | { |
---|
140 | CloseWindow((WindowPtr)win); |
---|
141 | SetGWorld(saveWorld, saveDevice); |
---|
142 | ReleaseResource((Handle)pat1); |
---|
143 | ReleaseResource((Handle)pat2); |
---|
144 | ReleaseResource((Handle)pat3); |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | |
---|