126 lines
4.4 KiB
C
126 lines
4.4 KiB
C
#include "engine.h"
|
|
|
|
void view_unit (int race, int unit, int x, int y) {
|
|
int u, v, width, height;
|
|
|
|
u = 0;
|
|
v = (unit - race * 18) * BASE_SIZE;
|
|
width = BASE_SIZE;
|
|
height = BASE_SIZE;
|
|
|
|
switch (race) {
|
|
case orc: render_sprite (orcs, x, y, u, v, width, height); break;
|
|
case human: render_sprite (humans, x, y, u, v, width, height); break;
|
|
case elf: render_sprite (elves, x, y, u, v, width, height); break;
|
|
default: break;
|
|
}
|
|
}
|
|
|
|
void view_menu (int menu, int align, int x, int y) {
|
|
int item, width, height, aligned_x, aligned_y, u, v;
|
|
|
|
if (menu_show [menu] == 0) {
|
|
return;
|
|
}
|
|
|
|
width = (int) strlen (menu_text [menu] [0]);
|
|
height = menu_items [menu];
|
|
aligned_x = (align == 0) ? x : ((render_width () - ICON_SIZE * width) / 2);
|
|
aligned_y = (align == 0) ? y : ((render_height () - ICON_SIZE * height) / 2);
|
|
|
|
for (item = 0; item < menu_items [menu]; ++item) {
|
|
u = (menu_icon [menu] [item] / 10) * ICON_SIZE;
|
|
v = (menu_icon [menu] [item] % 10) * ICON_SIZE;
|
|
|
|
render_sprite (ui, aligned_x, aligned_y + item * ICON_SIZE, u, v, ICON_SIZE, ICON_SIZE);
|
|
render_string (menu_text [menu] [item], aligned_x + ICON_SIZE, aligned_y + item * ICON_SIZE);
|
|
}
|
|
}
|
|
|
|
void view_hud (int alpha, int width, int height, int x, int y) {
|
|
int i, j, u, v;
|
|
|
|
u = width % ICON_SIZE;
|
|
v = height % ICON_SIZE;
|
|
|
|
width /= ICON_SIZE;
|
|
height /= ICON_SIZE;
|
|
|
|
if (alpha == 0) {
|
|
for (i = 0; i < width - 1; ++i) {
|
|
for (j = 0; j < height - 1; ++j) {
|
|
render_sprite (neonui, x + i * ICON_SIZE + ICON_SIZE / 2, y + j * ICON_SIZE + ICON_SIZE / 2, 0, 0, ICON_SIZE, ICON_SIZE);
|
|
}
|
|
render_sprite (neonui, x + i * ICON_SIZE + ICON_SIZE / 2, y + height * ICON_SIZE + ICON_SIZE / 2, 0, 0, u, ICON_SIZE);
|
|
}
|
|
render_sprite (neonui, x + width * ICON_SIZE + ICON_SIZE / 2, y + height * ICON_SIZE + ICON_SIZE / 2, 0, 0, ICON_SIZE, v);
|
|
}
|
|
|
|
for (i = 1; i < width; ++i) {
|
|
render_sprite (neonui, x + i * ICON_SIZE, y, 560, 0, ICON_SIZE, ICON_SIZE);
|
|
render_sprite (neonui, x + i * ICON_SIZE, y + ICON_SIZE * (height - 1) + v, 560, 0, ICON_SIZE, ICON_SIZE);
|
|
}
|
|
|
|
for (i = 1; i < height - 1; ++i) {
|
|
render_sprite (neonui, x, y + i * ICON_SIZE, 256, 128, ICON_SIZE, ICON_SIZE);
|
|
render_sprite (neonui, x + ICON_SIZE * (width - 1) + u, y + i * ICON_SIZE + v, 256, 128, ICON_SIZE, ICON_SIZE);
|
|
}
|
|
|
|
render_sprite (neonui, x, y, 288, 0, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
|
render_sprite (neonui, x + ICON_SIZE * (width - 3) + u, y, 384, 0, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
|
render_sprite (neonui, x, y + ICON_SIZE * (height - 3) + v, 288, 96, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
|
render_sprite (neonui, x + ICON_SIZE * (width - 3) + u, y + ICON_SIZE * (height - 3) + v, 384, 96, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
|
}
|
|
|
|
void view_neon_menu (int menu, int align, int x, int y) {
|
|
int item, aligned_x, aligned_y, i, j;
|
|
|
|
if (menu_show [menu] == 0) {
|
|
return;
|
|
}
|
|
|
|
i = (int) strlen (menu_text [menu] [0]) + 4;
|
|
j = menu_items [menu] + 4;
|
|
|
|
aligned_x = (align == 0) ? x : ((render_width () - ICON_SIZE * i) / 2);
|
|
aligned_y = (align == 0) ? y : ((render_height () - ICON_SIZE * j) / 2);
|
|
|
|
view_hud (menu_alpha [menu], i * ICON_SIZE, j * ICON_SIZE, aligned_x, aligned_y);
|
|
|
|
aligned_x += 2 * ICON_SIZE;
|
|
aligned_y += 2 * ICON_SIZE;
|
|
|
|
for (item = 0; item < menu_items [menu]; ++item) {
|
|
i = (menu_icon [menu] [item] / 10) * ICON_SIZE;
|
|
j = (menu_icon [menu] [item] % 10) * ICON_SIZE;
|
|
|
|
render_sprite (ui, aligned_x, aligned_y + item * ICON_SIZE, i, j, ICON_SIZE, ICON_SIZE);
|
|
|
|
render_string (menu_text [menu] [item], aligned_x + ICON_SIZE, aligned_y + item * ICON_SIZE);
|
|
}
|
|
}
|
|
|
|
void view_map (void) {
|
|
int x, y;
|
|
|
|
for (x = 0; x < CHAD_WORLD_WIDTH; ++x) {
|
|
if (x * BASE_SIZE * render_zoom > render_width () - SIDE_SIZE) break;
|
|
|
|
for (y = 0; y < CHAD_WORLD_HEIGHT; ++y) {
|
|
render_sprite (ashlands, (int) (x * BASE_SIZE * render_zoom), (int) (y * BASE_SIZE * render_zoom), 0, chad_world [0] [x] [y] * BASE_SIZE, BASE_SIZE, BASE_SIZE);
|
|
}
|
|
}
|
|
}
|
|
|
|
void view_base_1 (int index, int x, int y) {
|
|
render_sprite (base_1, x, y, 0, index * 7 * BASE_SIZE, 10 * BASE_SIZE, 7 * BASE_SIZE);
|
|
}
|
|
|
|
void view_base_2 (int index, int x, int y) {
|
|
render_sprite (base_2, x, y, 0, index * 10 * BASE_SIZE, 15 * BASE_SIZE, 10 * BASE_SIZE);
|
|
}
|
|
|
|
void view_side_hud (void) {
|
|
return;
|
|
}
|