17 ui
.unit
= ui
.house
= ui
.builder
= ui
.stat
= ui
.btn
= -1;
21 ui
.hover_top
= overNothingMajor
;
22 ui
.hover
= overNothingMinor
;
32 ui
.game_speed
= 25;//PASS_DEL;
39 static Uint32 wait
= 0;
40 static Uint32 fps
= 0;
42 Uint32 tick
= SDL_GetTicks();
43 Uint32 pass
= tick
- wait
;
46 ui
.fps
= ui
.fps_counter
;
53 void update_hintbox() {
60 ui
.hint
= ui
.hover_id
;
66 ui
.hint
= ui
.hover_id
;
76 if (ui
.builder
!= -1) {
93 /* Given X and Y mouse position, determine various UI-related states... */
94 SDL_Rect game_map
= { 0, 0, LOG_WIDTH
- PANE_WIDTH
, LOG_HEIGHT
};
96 SDL_Rect ui_pane
= { LOG_WIDTH
- PANE_WIDTH
- 10, 0, PANE_WIDTH
+ 10, LOG_HEIGHT
};
98 SDL_Rect top_pane
= { 0, 0, LOG_WIDTH
, 16 };
100 ui
.hover
= overNothingMinor
;
103 if (SDL_InBounds(ui
.x
, ui
.y
, &ui_pane
)) {
105 ui
.hover_top
= overPane
;
109 } else if (SDL_InBounds(ui
.x
, ui
.y
, &top_pane
)) {
111 ui
.hover_top
= overNothingMajor
;
115 ui
.hover_top
= overMap
;
124 void track_mouse_map() {
126 Uint32 unit_i
, house_i
;
128 ui
.hover_xcollide
= 0;
129 ui
.hover
= overNothingMinor
;
131 if (ui
.builder
!= -1) {
132 house_p
*h
= &bhouses
[ui
.builder
];
134 int lx
= ui
.x
+ ui
.vx
;
135 int ly
= ui
.y
+ ui
.vy
;
137 int cx
= -(TILE_W
* h
->w
/ 2) + (TILE_W
/2);
138 int cy
= -(TILE_H
* h
->h
/ 2) + (TILE_H
/2);
143 ui
.hover_tx
= (lx
/ TILE_W
);
144 ui
.hover_ty
= (ly
/ TILE_H
);
146 ui
.hover_xcollide
= xcollide(ui
.hover_tx
, ui
.hover_ty
, h
->w
, h
->h
);
151 ui
.hover_tx
= (ui
.x
+ ui
.vx
) / TILE_W
;
152 ui
.hover_ty
= (ui
.y
+ ui
.vy
) / TILE_H
;
154 unit_i
= find_unit(ui
.x
, ui
.y
);
157 ui
.hover_id
= unit_i
;
159 house_i
= find_house(ui
.x
, ui
.y
);
161 ui
.hover
= overHouse
;
162 ui
.hover_id
= house_i
;
167 void track_mouse_ui() {
171 /* One of the build buttons */
172 if (ui
.house
== -1 && ui
.unit
== -1) {
174 LOG_WIDTH
- PANE_WIDTH
,
175 150, /* minimap_height ? */
180 for (i
= 0; i
< HMENU_ITEMS
; i
++) {
182 house_p
*m
= &bhouses
[i
];
184 if (SDL_InBounds(ui
.x
, ui
.y
, &button
)) {
186 ui
.hover
= overBuildButton
;
193 if (button
.x
>= LOG_WIDTH
- 10) {
194 button
.x
= LOG_WIDTH
- PANE_WIDTH
;
200 /* One of the stat/skill buttons */
203 LOG_WIDTH
- PANE_WIDTH
+ BOX_PADDING
+ BOX_PADDING
,
204 150 + BOX_PADDING
+ BOX_PADDING
+ 1,
209 for (i
= 0; i
< MAX_STAT
; i
++) {
211 if (SDL_InBounds(ui
.x
, ui
.y
, &button
)) {
212 ui
.hover
= overUnitStat
;
217 button
.y
-= 14 * MAX_STAT
;
220 for (i
= 0; i
< MAX_STAT
; i
++) {
222 if (SDL_InBounds(ui
.x
, ui
.y
, &button
)) {
223 ui
.hover
= overUnitSkill
;