-
Notifications
You must be signed in to change notification settings - Fork 2
/
MBUI.m
142 lines (112 loc) · 2.43 KB
/
MBUI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#import "MBtypes.h"
#import "MBUI.h"
#import "MButil.h"
#import "MBGame.h"
#import "MBAqua.h"
static int playing;
static const char *dialog_strings[DIALOG_MAX + 1];
static const char *menu_strings[DIALOG_MAX + 1];
static int interval = 200;
@implementation MBUI
- (void)UI_restart_timer
{
[aqua aqua_start_timer:interval];
}
- (void)UI_kill_timer
{
[aqua aqua_stop_timer];
}
- (void)UI_pause_game
{
if ([aqua aqua_timer_active])
playing = 1;
[self UI_kill_timer];
}
- (void)UI_resume_game
{
if (playing && ![aqua aqua_timer_active])
[self UI_restart_timer];
playing = 0;
}
- (void)UI_make_main_window:(int)size
{
[aqua aqua_make_main_window:size];
}
- (void)UI_popup_dialog:(int)dialog
{
[aqua aqua_popup_dialog:dialog];
}
- (void)UI_set_cursor:(MBMCursor *)cursor
{
[aqua aqua_set_cursor:cursor];
}
- (void)UI_clear
{
[aqua aqua_clear_window];
}
- (void)UI_refresh
{
[aqua aqua_refresh_window];
}
- (void)UI_draw:(MBPicture *)pict :(int)x :(int)y
{
[aqua aqua_draw_image:pict :x :y];
}
- (void)UI_draw_line:(int)x1 :(int)y1 :(int)x2 :(int)y2
{
[aqua aqua_draw_line:x1 :y1 :x2 :y2];
}
- (void)UI_draw_str:(const char *)str :(int)x :(int)y
{
[aqua aqua_draw_string:str :x :y];
}
- (void)UI_set_pausebutton:(int)action
{
[aqua aqua_set_pausebutton:action];
}
- (void)UI_load_picture_indexed:(const char *)name :(int)index :(int)trans :(MBPicture **)pictp
{
char *newname;
newname = malloc(strlen(name) + 4);
sprintf(newname, "%s_%d", name, index);
[self UI_load_picture:newname :trans :pictp];
free(newname);
}
- (void)UI_load_picture:(const char *)name :(int)trans :(MBPicture **)pictp
{
[aqua aqua_load_picture:name :trans :pictp];
}
- (int)UI_picture_width:(MBPicture *)pict
{
return [aqua aqua_picture_width:pict];
}
- (int)UI_picture_height:(MBPicture *)pict
{
return [aqua aqua_picture_height:pict];
}
- (void)UI_load_cursor:(const char *)name :(int)masked :(MBMCursor **)cursorp
{
[aqua aqua_load_cursor:name :masked :cursorp];
}
- (void)UI_audio_play:(const char *)name
{
[aqua aqua_audio_play:name];
}
- (int)UI_intersect:(int)x1 :(int)y1 :(int)w1 :(int)h1 :(int)x2 :(int)y2 :(int)w2 :(int)h2
{
return ((abs(x2 - x1 + (w2 - w1) / 2) < (w1 + w2) / 2) &&
(abs(y2 - y1 + (h2 - h1) / 2) < (h1 + h2) / 2));
}
- (const char *)UI_dialog_string:(int)index
{
return dialog_strings[index];
}
- (const char *)UI_menu_string:(int)index
{
return menu_strings[index];
}
- (void)UI_set_interval:(int)ti
{
interval = ti;
}
@end