2 -----BEGIN PGP SIGNED MESSAGE-----
5 m m mm mmm .----------. .---------------------. mmm mm m m
6 8 8 88 888 | .--------` | .------------------` 888 88 8 8
7 8 8 88 888 | ```````|`V```````| |``||``|`````| 888 88 8 8
8 8 8 88 888 `------ | | [] | |``````|| | [] | 888 88 8 8
9 8 8 88 888 |`````` | | | ````|```` | | 888 88 8 8
10 ` ` `` ``` ``````````````> |````````````| |`` ``` `` ` `
12 L A B O R A T O R I E S
14 This file is part of Hacker Radio Rec.
16 Hacker Radio Rec is free software: you can redistribute it and/or
17 modify it under the terms of the GNU General Public License as
18 published by the Free Software Foundation, either version 3 of
19 the License or (at your option) any later version.
21 Hacker Radio Rec is distributed in the hope that it will be
22 useful, but WITHOUT ANY WARRANTY; without even the implied
23 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 See the GNU General Public License for more details.
26 Copyright (C) 2009, Thea DeSilva
27 You can find a copy of GNU General Public License in COPYING
31 SDL_Surface
*sub
, *left
, *right
;
32 SDL_Rect sub_rec
, dst_rec
;
39 float globl_time
= 0.0f
;
41 const color_t sub_bg
= { 0x3f, 0x3f, 0x3f };
43 track_t tracks
[TRACKS
];
47 (Sint32)(((float)vert->param.d1 / 256.0f) * (float)((TRACKS*TRACK_SIZE+4)-main_obj->param.h))
49 double m(double x
,double y
) {
51 return ((a
=x
/y
)-(Sint32
)a
)*y
;
56 Sint32
clip_rect(SDL_Rect
*bound
, SDL_Rect
*in
) {
60 if(bound
->y
> in
->y
) {
65 if((bound
->y
+bound
->h
) < (in
->y
+in
->h
)){
66 h
-= ( (in
->y
+in
->h
) - (bound
->y
+bound
->h
));
73 /* sub_update_block {{{ */
74 void sub_update_block(Sint32 x1
, Sint32 y1
, Sint32 x2
, Sint32 y2
) {
75 SDL_Rect bounding
, dst
;
77 dst
.x
= x1
+ main_obj
->param
.x
;
79 dst
.w
= bounding
.w
= (x2
-x1
) + 1;
81 bounding
.h
= (y2
-y1
) +1;
83 dst
.y
= y1
+ main_obj
->param
.y
- Y
;
87 if(clip_rect(&dst_rec
, &dst
)!=0) {
88 bounding
.y
+= (dst
.y
- unclipped_y
);
91 SDL_BlitSurface(sub
, &bounding
, gui_screen
, &dst
);
92 SDL_UpdateRect(gui_screen
, dst
.x
,dst
.y
,dst
.w
,dst
.h
);
99 void sub_update(struct object_t
*obj
) {
100 sub_update_block(obj
->param
.x
, obj
->param
.y
,
101 obj
->param
.x
+obj
->param
.w
,obj
->param
.y
+obj
->param
.h
);
105 void norm_update(struct object_t
*obj
) {
106 // printf("norm update\n");
111 Sint32
proc_main(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
112 struct object_t
*walker
;
115 Sint32 store_gui_mouse_x
, store_gui_mouse_y
;
120 if((sub
= SDL_CreateRGBSurface(SDL_SWSURFACE
,obj
->param
.w
, (TRACK_SIZE
*TRACKS
+4),24,
121 gui_screen
->format
->Rmask
, gui_screen
->format
->Gmask
,
122 gui_screen
->format
->Bmask
, gui_screen
->format
->Amask
))<=0) {
126 printf("sub: 0x%x\n", sub
);
127 sub_rec
.w
= obj
->param
.w
;
131 dst_rec
.w
= obj
->param
.w
;
132 dst_rec
.h
= obj
->param
.h
;
133 dst_rec
.x
= obj
->param
.x
;
134 dst_rec
.y
= obj
->param
.y
;
135 walker
= sub_grp
->objs
;
137 walker
->in_focus
= 0;
138 walker
->clicked
= FALSE
;
139 if((walker
= (struct object_t
*)walker
->node
.next
)==sub_grp
->objs
) break;
141 broadcast_group(sub_grp
, MSG_START
, 0);
142 MESSAGE_OBJECT(obj
, MSG_USER
);
146 walker
= sub_grp
->objs
;
148 if(walker
->in_focus
== 1) {
149 walker
->in_focus
= 0;
150 MESSAGE_OBJECT(walker
, MSG_OUTFOCUS
);
152 if((walker
= (struct object_t
*)walker
->node
.next
) == sub_grp
->objs
) break;
160 SDL_FillRect( sub
, &sub_rec
, SDL_MapRGB(gui_screen
->format
, sub_bg
.r
, sub_bg
.g
, sub_bg
.b
));
161 sub_rec
.h
= obj
->param
.h
;
163 walker
= sub_grp
->objs
;
165 if(walker
->param
.proc
== proc_shadow_box
)
166 MESSAGE_OBJECT(walker
, MSG_DRAW
);
167 if((walker
=(struct object_t
*)walker
->node
.next
) == sub_grp
->objs
) break;
169 walker
= sub_grp
->objs
;
171 if(walker
->param
.proc
!= proc_shadow_box
)
172 MESSAGE_OBJECT(walker
, MSG_DRAW
);
173 if((walker
=(struct object_t
*)walker
->node
.next
) == sub_grp
->objs
) break;
176 // broadcast_group(sub_grp, MSG_DRAW,0);
182 SDL_BlitSurface(sub
, &sub_rec
, gui_screen
, &dst_rec
);
187 walker
= sub_grp
->objs
;
189 if(gui_mouse_x
>= (walker
->param
.x
+ obj
->param
.x
) &&
190 gui_mouse_x
<= (walker
->param
.x
+ obj
->param
.x
+ walker
->param
.w
) &&
191 gui_mouse_y
>= (walker
->param
.y
+ obj
->param
.y
- Y
) &&
192 gui_mouse_y
<= (walker
->param
.y
+ obj
->param
.y
+ walker
->param
.h
- Y
)) {
194 if(walker
->in_focus
== 0) {
195 walker
->in_focus
= 1;
196 MESSAGE_OBJECT(walker
, MSG_INFOCUS
);
198 obj_x
= gui_mouse_x
- obj
->param
.x
- walker
->param
.x
;
199 obj_y
= gui_mouse_y
- obj
->param
.y
- walker
->param
.y
+ Y
;
200 MESSAGE_OBJECT(walker
, MSG_MOUSEMOVE
);
204 if(walker
->in_focus
== 1) {
205 walker
->in_focus
= 0;
206 MESSAGE_OBJECT(walker
, MSG_OUTFOCUS
);
209 if( (walker
= (struct object_t
*)walker
->node
.next
) == sub_grp
->objs
) break;
220 walker
= sub_grp
->objs
;
221 store_gui_mouse_x
= gui_mouse_x
;
222 store_gui_mouse_y
= gui_mouse_y
;
224 if(store_gui_mouse_x
>= (walker
->param
.x
+ obj
->param
.x
) &&
225 store_gui_mouse_x
<= (walker
->param
.x
+ obj
->param
.x
+ walker
->param
.w
) &&
226 store_gui_mouse_y
>= (walker
->param
.y
+ obj
->param
.y
- Y
) &&
227 store_gui_mouse_y
<= (walker
->param
.y
+ obj
->param
.y
+ walker
->param
.h
- Y
)) {
231 walker
->clicked
== TRUE
;
233 if(msg
== MSG_UNCLICK
&& walker
->clicked
== TRUE
) {
234 MESSAGE_OBJECT(walker
, MSG_PRESS
);
235 walker
->clicked
= FALSE
;
237 walker
->param
.proc(msg
,walker
, data
);
240 if( (walker
= (struct object_t
*)walker
->node
.next
) == sub_grp
->objs
) break;
250 Sint32
proc_wave(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
252 struct object_t
*old_obj
;
254 Sint32 up_left
, up_right
;
256 double old_pos
, old_pos2
, q
;
257 Sint32 x
, px
, begin
, end
;
260 menu_wave_grp
->pos_x
= gui_mouse_x
- 6;
261 menu_wave_grp
->pos_y
= gui_mouse_y
- 6;
263 group_loop(menu_wave_grp
);
266 MESSAGE_OBJECT(time_bar
, MSG_DRAW
);
269 for(i
= 0;i
<TRACKS
;i
++) {
270 MESSAGE_OBJECT(tracks
[i
].wave
, MSG_DRAW
);
271 sub_update(tracks
[i
].wave
);
276 broadcast_group(time_bar_grp
, MSG_DRAW
,0);
281 (obj_x
> (obj
->param
.w
-20)))
284 hline(obj_x
+obj
->param
.x
-5, obj
->param
.y
+obj_y
,
285 obj_x
+obj
->param
.x
+5, &globl_fg
, &globl_bg
, XOR
);
286 vline(obj_x
+obj
->param
.x
, obj
->param
.y
,
287 obj_y
+obj
->param
.y
+obj
->param
.h
, &globl_fg
, &globl_bg
, XOR
);
290 up_left
= obj_x
-(5+abs(obj
->param
.d1
-obj_x
));
291 up_right
=obj_x
+(5+abs(obj
->param
.d1
-obj_x
));
294 if(up_right
>obj
->param
.w
)
295 up_right
= obj
->param
.w
;
298 sub_update_block( obj
->param
.x
+up_left
, obj
->param
.y
,
299 obj
->param
.x
+up_right
, obj
->param
.y
+obj
->param
.h
);
300 vline(obj_x
+obj
->param
.x
, obj
->param
.y
,
301 obj_y
+obj
->param
.y
+obj
->param
.h
, &globl_fg
, &globl_bg
, XOR
);
302 hline(obj_x
+obj
->param
.x
-5, obj
->param
.y
+obj_y
,
303 obj_x
+obj
->param
.x
+5, &globl_fg
, &globl_bg
, XOR
);
304 obj
->param
.d1
= obj_x
;
309 #define IS_IN_TIMEBAR \
310 if(obj_y >= ((obj->param.h/2) - (time_bar->param.h/2)) &&\
311 obj_y <= ((obj->param.h/2) + (time_bar->param.h/2)))
315 time_bar
->param
.proc(MSG_KEYDOWN
, time_bar
, data
);
321 (obj_x
>= (obj
->param
.w
-20))) {
325 i
= obj
->param
.w
- 20;
326 fill_box(obj
->param
.x
+i
, obj
->param
.y
, obj
->param
.x
+20+i
, obj
->param
.y
+obj
->param
.h
,
327 &globl_fg
, &globl_bg
, XOR
);
328 sub_update_block(obj
->param
.x
+i
, obj
->param
.y
, obj
->param
.x
+20+i
,obj
->param
.y
+obj
->param
.h
);
329 while(wait_on_mouse()!=MOUSE_UP
);
330 fill_box(obj
->param
.x
+i
, obj
->param
.y
, obj
->param
.x
+20+i
, obj
->param
.y
+obj
->param
.h
,
331 &globl_fg
, &globl_bg
, XOR
);
332 sub_update_block(obj
->param
.x
+i
, obj
->param
.y
, obj
->param
.x
+20+i
,obj
->param
.y
+obj
->param
.h
);
333 mover(i
==0 ? CMD_PAGELEFT
:CMD_PAGERIGHT
);
337 MESSAGE_OBJECT(time_bar
, MSG_CLICK
);
341 (((((float)obj_x-20)/(time_bar->param.w/5))/zoom)+globl_time)
342 old_obj
= tracks
[cursor
.track
].wave
;
343 tracks
[cursor
.track
].cue
->param
.flags
|= FADE
;
344 MESSAGE_OBJECT(tracks
[cursor
.track
].cue
, MSG_DRAW
);
345 cursor
.track
= obj
->param
.d2
;
346 tracks
[cursor
.track
].cue
->param
.flags
&= (~0^FADE
);
347 MESSAGE_OBJECT(tracks
[cursor
.track
].cue
, MSG_DRAW
);
353 MESSAGE_OBJECT(obj
, MSG_DRAW
);
354 MESSAGE_OBJECT(old_obj
, MSG_DRAW
);
356 (((((float)(obj_x+px)-20)/(time_bar->param.w/5))/zoom)+globl_time)
357 old_pos
= cursor
.pos
;
359 px
= gui_mouse_x
- x
;
362 cursor
.end
= old_pos
;
365 cursor
.pos
= old_pos
;
368 MESSAGE_OBJECT(obj
, MSG_DRAW
);
370 if(wait_on_mouse() == MOUSE_UP
) break;
378 if((obj
->param
.y
+ obj
->param
.h
) < Y
||
379 (obj
->param
.y
> (Y
+ main_obj
->param
.h
))) {
380 tracks
[obj
->param
.d2
].dirty
= 1;
384 if(obj
->in_focus
== 0)
385 color
= SDL_MapRGB(sub
->format
, (float)globl_bg
.r
*0.84f
, (float)globl_bg
.g
*0.84f
, (float)globl_bg
.b
*0.84f
);
387 color
= SDL_MapRGB(sub
->format
, globl_bg
.r
, globl_bg
.g
, globl_bg
.b
);
389 dst
.x
= obj
->param
.x
+20;
390 dst
.y
= obj
->param
.y
;
391 dst
.w
= obj
->param
.w
-40;
392 dst
.h
= obj
->param
.h
;
394 SDL_FillRect(sub
, &dst
, color
);
396 if(obj
->param
.d2
== cursor
.track
) {
398 ((obj->param.x+20) + (( X - globl_time) * zoom * (float)time_bar->param.w/5.0f))
400 begin
= POS(cursor
.pos
);
401 end
= POS(cursor
.end
);
403 if(end
> (obj
->param
.x
+ 20) &&
404 begin
< ((obj
->param
.x
+ obj
->param
.w
) - 20)) {
407 dst
.y
= obj
->param
.y
;
409 dst
.h
= obj
->param
.h
;
411 if(dst
.x
<= (obj
->param
.x
+20)) {
412 dst
.w
-= (obj
->param
.x
+ 20) - dst
.x
;
413 dst
.x
= obj
->param
.x
+20;
416 if((dst
.x
+ dst
.w
) >= ((obj
->param
.x
+ obj
->param
.w
) - 20)) {
417 dst
.w
-= (dst
.x
+dst
.w
) - ((obj
->param
.x
+ obj
->param
.w
) - 20);
420 SDL_FillRect(sub
, &dst
, SDL_MapRGB(sub
->format
, 0xee, 0xee, 0xe2));
422 if(X >= obj->param.x+20 && \
423 X <= (obj->param.x+obj->param.w)-20) \
424 vline(X, obj->param.y, obj->param.y+obj->param.h, \
425 obj->param.fg, obj->param.bg, NO_HASH);
434 src
.x
= 0; src
.y
= 0;
435 dst
.w
= src
.w
=20; dst
.h
= src
.h
= 169;
436 dst
.x
= obj
->param
.x
;
437 dst
.y
= obj
->param
.y
;
438 SDL_BlitSurface(left
, &src
, sub
, &dst
);
439 dst
.x
= obj
->param
.x
+obj
->param
.w
-20;
440 SDL_BlitSurface(right
, &src
, sub
, &dst
);
442 src
.x
= time_bar
->param
.x
; src
.y
= time_bar
->param
.y
;
443 src
.w
= time_bar
->param
.w
; src
.h
= time_bar
->param
.h
;
444 dst
.x
= obj
->param
.x
+20; dst
.y
=obj
->param
.y
+( (obj
->param
.h
/2) - (time_bar
->param
.h
/2));
445 dst
.w
= time_bar
->param
.w
; dst
.h
= time_bar
->param
.h
;
446 SDL_BlitSurface(time_bar_bmp
, &src
, sub
, &dst
);
447 tracks
[obj
->param
.d2
].dirty
= 0;
452 MESSAGE_OBJECT(obj
, MSG_DRAW
);
460 /* floats give us rounding problems when it comes to
461 * day-scale times, no foolin' huh */
464 Sint32
do_line(struct object_t
*obj
, double scale
, char s
) {
469 double store
, store2
;
473 (double)obj->param.x+(div*(double)i) - \
474 m( ((globl_time/scale)*div), div )
476 div
= ((((double)obj
->param
.w
*zoom
)/5.0f
)*scale
);
480 if(div
>(obj
->param
.w
*4)) return;
481 store
= (div
/ ((double)obj
->param
.w
/5.0f
));
490 current_scale
= CHUNKS
;
493 current_scale
= SECONDS
;
496 current_scale
= MINUTES
;
499 current_scale
= HOURS
;
502 current_scale
= DAYS
;
506 store2
= obj
->param
.bg
->r
-obj
->param
.fg
->r
;
507 color
.r
= obj
->param
.bg
->r
- (Sint32
)(store2
* store
);
510 store2
= obj
->param
.bg
->g
-obj
->param
.fg
->g
;
511 color
.g
= obj
->param
.bg
->g
- (Sint32
)(store2
* store
);
513 store2
= obj
->param
.bg
->b
-obj
->param
.fg
->b
;
514 color
.b
= obj
->param
.bg
->b
- (Sint32
)(store2
* store
);
517 j
= (obj
->param
.w
/ div
)+2;
520 if(SPACER
> obj
->param
.x
+1 &&
521 SPACER
< (obj
->param
.x
+obj
->param
.w
))
522 vline(SPACER
, obj
->param
.y
+1, (obj
->param
.y
+obj
->param
.h
-9),
523 &color
, obj
->param
.bg
, NO_HASH
);
524 if((SPACER
+((Sint32
)div
>>1)) > obj
->param
.x
+1 &&
525 (SPACER
+((Sint32
)div
>>1)) < (obj
->param
.x
+obj
->param
.w
))
526 vline(SPACER
+((Sint32
)div
>>1), obj
->param
.y
+5, (obj
->param
.y
+obj
->param
.h
)-5,
527 &color
, obj
->param
.bg
, NO_HASH
);
528 if((SPACER
+((Sint32
)div
>>2)) > obj
->param
.x
+1 &&
529 (SPACER
+((Sint32
)div
>>2)) < (obj
->param
.x
+obj
->param
.w
))
530 vline(SPACER
+((Sint32
)div
>>2), obj
->param
.y
+10, (obj
->param
.y
+obj
->param
.h
)-10,
531 &color
, obj
->param
.bg
, NO_HASH
);
532 if(((SPACER
+((Sint32
)div
>>2))+((Sint32
)div
>>1)) > obj
->param
.x
+1 &&
533 ((SPACER
+((Sint32
)div
>>2))+((Sint32
)div
>>1)) < (obj
->param
.x
+obj
->param
.w
))
534 vline(SPACER
+((Sint32
)div
>>2)+((Sint32
)div
>>1), obj
->param
.y
+10, (obj
->param
.y
+obj
->param
.h
)-10,
535 &color
, obj
->param
.bg
, NO_HASH
);
538 snprintf(buf
, MAX_CHARS
, "%d%c",(Sint32
)(globl_time
/scale
)+i
,s
);
539 clip
= strlen(buf
)*8;
545 if(SPACER
-CENTER_OF_STRING(buf
) > obj
->param
.x
+8 &&
546 SPACER
-CENTER_OF_STRING(buf
) < obj
->param
.x
+ obj
->param
.w
-clip
) {
547 k
= (Sint32
)(globl_time
/scale
)+i
;
548 snprintf(buf
, MAX_CHARS
, "%d%c",k
,s
);
549 draw_text( SPACER
- CENTER_OF_STRING(buf
), obj
->param
.y
+obj
->param
.h
-9, buf
,
550 &color
,obj
->param
.bg
, NO_HASH
, 0);
556 /* proc_time_bar {{{ */
557 Sint32
proc_time_bar(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
560 double store
, store2
;
561 Sint32 x
, px
, lpx
, cur_x
;
569 obj
->param
.d1
= SDL_MapRGB(gui_screen
->format
,
570 obj
->param
.bg
->r
, obj
->param
.bg
->g
, obj
->param
.bg
->b
);
571 obj
->param
.dp1
=(void *)malloc(sizeof(SDL_Rect
));
572 dst
= (SDL_Rect
*)obj
->param
.dp1
;
573 dst
->x
= obj
->param
.x
;
574 dst
->y
= obj
->param
.y
;
575 dst
->w
= obj
->param
.w
;
576 dst
->h
= obj
->param
.h
;
581 globl_time
-= 1.0f
/ (((double)obj
->param
.w
*zoom
)/5.0f
);
582 if(globl_time
< 0.0f
)
584 MESSAGE_OBJECT(obj
, MSG_DRAW
);
587 globl_time
+= 1.0f
/ (((double)obj
->param
.w
*zoom
)/5.0f
);
588 MESSAGE_OBJECT(obj
, MSG_DRAW
);
591 globl_time
-= 5.0f
/zoom
;
592 if(globl_time
< 0.0f
)
594 MESSAGE_OBJECT(obj
, MSG_DRAW
);
597 globl_time
+= 5.0f
/zoom
;
598 MESSAGE_OBJECT(obj
, MSG_DRAW
);
609 MESSAGE_OBJECT(obj
, MSG_DRAW
);
611 if(wait_on_mouse()==MOUSE_UP
) break;
613 k
= SDL_GetModState();
619 if((k
& KMOD_SHIFT
) !=0) {
622 #define OBJ_X (main_obj->param.x + tracks[0].wave->param.x + 20)
623 scaler
= (double)(cur_x
- OBJ_X
);
625 if(((double)(cur_x
- OBJ_X
) / scaler
)>0.0f
)
626 zoom
= store2
*((double)(cur_x
- OBJ_X
) / scaler
) ;
629 globl_time
=store
- (double)px
/ (((double)obj
->param
.w
*zoom
)/5);
631 store
= globl_time
= 0;
640 SDL_FillRect(time_bar_bmp
, obj
->param
.dp1
, obj
->param
.d1
);
642 if(zoom
<= 0.0000009f
) {
643 draw_text(obj
->param
.x
+ (obj
->param
.w
/2) - CENTER_OF_STRING(TOO_LONG
),
644 obj
->param
.y
+ (obj
->param
.h
/2) - 4, TOO_LONG
, obj
->param
.fg
, obj
->param
.bg
, NO_HASH
,0);
648 do_line(obj
, 1.0f
/512.0f
, '~');
649 do_line(obj
, 1.0f
, 's');
650 do_line(obj
, 60.0f
,'m');
651 do_line(obj
, 3600.0f
,'h');
652 do_line(obj
, 3600.0f
*24.0f
,'d');
655 hline(obj
->param
.x
, obj
->param
.y
+(obj
->param
.h
/2), obj
->param
.x
+obj
->param
.w
,
656 obj
->param
.fg
, obj
->param
.bg
, NO_HASH
);
659 SDL_UpdateRect(time_bar_bmp
, 0,0,0,0);
663 intern_update
= sub_update
;
664 for(i
= 0;i
<TRACKS
;i
++)
665 if(tracks
[i
].empty
== 0)
666 MESSAGE_OBJECT(tracks
[i
].wave
, MSG_DRAW
);
674 Sint32
proc_back(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
675 const color_t color
= { 100,100,100 };
678 if(msg
== MSG_DRAW
) {
679 /* this draws the background image
680 * if you want you can fill this with all
681 * sort of fancy stuff, only gets called
682 * once- practically free. I like this
684 p
= (unsigned char *)gui_screen
->pixels
;
685 for(q
= 0;q
<(gui_screen
->h
*gui_screen
->pitch
);q
++)
686 *p
++ = ((q
%gui_screen
->pitch
)>>6)^((q
/gui_screen
->pitch
)>>2);
693 Sint32
proc_progress_bar(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
700 bmp
= IMG_ReadXPMFromArray(obj
->param
.dp1
);
701 obj
->param
.dp1
= bmp
;
702 bmp
= IMG_ReadXPMFromArray(obj
->param
.dp2
);
703 obj
->param
.dp2
= bmp
;
705 obj
->param
.d2
= PROGRESS_BAR_DETER
;
708 src
.x
= 0; src
.y
= 0;
709 src
.w
= dst
.w
= obj
->param
.w
; src
.h
= dst
.w
= obj
->param
.h
;
710 dst
.x
= obj
->param
.x
; dst
.y
= obj
->param
.y
;
711 SDL_BlitSurface(obj
->param
.dp1
, &src
, gui_screen
, &dst
);
713 if(obj
->param
.d2
== PROGRESS_BAR_DETER
) {
714 if(obj
->param
.d1
== 0) {
718 per
= (float)obj
->param
.d1
/ 100.0f
;
720 src
.w
= (Sint32
)(per
* (float)obj
->param
.w
); dst
.w
= src
.w
;
721 SDL_BlitSurface(obj
->param
.dp2
, &src
, gui_screen
, &dst
);
722 snprintf(buf
, MAX_CHARS
,"%d%%", obj
->param
.d1
);
723 draw_text(obj
->param
.x
+(obj
->param
.w
/2)- CENTER_OF_STRING(buf
),
724 obj
->param
.y
+(obj
->param
.h
/2)-4,
725 buf
, obj
->param
.bg
, obj
->param
.bg
, NO_HASH
, 0);
727 per
= (float)(obj
->param
.d1
%100) / 100.0f
;
728 src
.x
= (Sint32
)(per
* (float)(obj
->param
.w
-20));
729 if((obj
->param
.d1
%200) >= 100)
730 src
.x
= (obj
->param
.w
- 20) - src
.x
;
733 dst
.x
= src
.x
+ obj
->param
.x
;
734 SDL_BlitSurface(obj
->param
.dp2
, &src
, gui_screen
, &dst
);
743 char message_bar_null
= 0;
745 Sint32
proc_message_bar(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
749 obj
->param
.dp2
= &message_bar_null
;
750 dst
= obj
->param
.dp1
= (void *)malloc(sizeof(SDL_Rect
));
751 dst
->x
= obj
->param
.x
;
752 dst
->y
= obj
->param
.y
;
753 dst
->w
= obj
->param
.w
;
754 dst
->h
= obj
->param
.h
;
755 obj
->param
.d1
= SDL_MapRGB(gui_screen
->format
, obj
->param
.bg
->r
,
760 SDL_FillRect(gui_screen
, (SDL_Rect
*)obj
->param
.dp1
, obj
->param
.d1
);
761 draw_text(obj
->param
.x
+ (obj
->param
.w
/2) - CENTER_OF_STRING(obj
->param
.dp2
), obj
->param
.y
+(obj
->param
.h
/2)-4,
762 obj
->param
.dp2
, obj
->param
.fg
, obj
->param
.bg
, NO_HASH
, 0);
771 Sint32
proc_memory_bar(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
775 char buf2
[MAX_CHARS
];
778 dst
= obj
->param
.dp1
= (void *)malloc(sizeof(SDL_Rect
));
779 dst
->x
= obj
->param
.x
;
780 dst
->y
= obj
->param
.y
;
781 dst
->w
= obj
->param
.w
;
782 dst
->h
= obj
->param
.h
;
783 obj
->param
.d1
= SDL_MapRGB( gui_screen
->format
,
784 obj
->param
.bg
->r
, obj
->param
.bg
->g
, obj
->param
.bg
->b
);
787 dst
= (SDL_Rect
*)obj
->param
.dp1
;
788 SDL_FillRect( gui_screen
, dst
, obj
->param
.d1
);
789 if(getrusage(RUSAGE_SELF
, &r
)<0) break;
790 /* XXX how do we get drss?! */
791 snprintf(buf
, MAX_CHARS
, "%d", r
.ru_idrss
);
792 snprintf(buf2
, MAX_CHARS
, "%d", r
.ru_inblock
+r
.ru_oublock
);
796 printf("%d %d %10ld %d %d %d %d\n"
797 "%d %d %d %d %d %d %d\n",
814 draw_text(obj
->param
.x
+((obj
->param
.w
/2)-CENTER_OF_STRING(buf
)),
816 buf
, obj
->param
.fg
, obj
->param
.bg
, NO_HASH
, 0);
818 draw_text(obj
->param
.x
+((obj
->param
.w
/2)-CENTER_OF_STRING(buf2
)),
819 (obj
->param
.y
+obj
->param
.h
)-9,
820 buf2
, obj
->param
.fg
, obj
->param
.bg
, NO_HASH
, 0);
828 Sint32
proc_end_splash(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
838 Sint32
proc_start_splash(Sint32 msg
, struct object_t
*obj
, Sint32 data
) {
839 if(msg
== MSG_AFTERDRAW
)
840 group_loop(splash_grp
);
844 Thank you for your attention
845 -----BEGIN PGP SIGNATURE-----
846 Version: GnuPG v1.4.9 (OpenBSD)
848 iEYEARECAAYFAkrsgxAACgkQMNO4A6bnBrOELQCfRW5C+6jwebv/z7V91Xf99p8S
849 5owAn0Opk8nCp3Iq4slrqeGO8GjjSuxq
851 -----END PGP SIGNATURE-----