2023-12-21 14:20:00 -05:00
|
|
|
#include "engine.h"
|
|
|
|
|
|
|
|
void view_unit (int race, int unit, int x, int y) {
|
|
|
|
int u = 0;
|
|
|
|
int v = (unit - race * 18) * BASE_SIZE;
|
|
|
|
int width = BASE_SIZE;
|
|
|
|
int 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;
|
|
|
|
}
|
2023-12-20 00:07:54 -05:00
|
|
|
}
|
|
|
|
|
2023-12-21 14:20:00 -05:00
|
|
|
void view_menu (int menu, int align, int x, int y) {
|
2023-12-21 16:59:45 -05:00
|
|
|
int width = (int) strlen (menu_text [menu] [0]);
|
|
|
|
int height = menu_items [menu];
|
|
|
|
int aligned_x = (align == 0) ? x : ((render_width () - ICON_SIZE * width) / 2);
|
|
|
|
int aligned_y = (align == 0) ? y : ((render_height () - ICON_SIZE * height) / 2);
|
2023-12-21 14:20:00 -05:00
|
|
|
|
|
|
|
int item;
|
|
|
|
|
|
|
|
if (menu_show [menu] == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-12-21 16:59:45 -05:00
|
|
|
for (item = 0; item < menu_items [menu]; ++item) {
|
|
|
|
int u = (menu_icon [menu] [item] / 10) * ICON_SIZE;
|
|
|
|
int 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_neon_menu (int menu, int align, int x, int y) {
|
|
|
|
int item;
|
|
|
|
|
|
|
|
int width = (int) strlen (menu_text [menu] [0]) + 4;
|
|
|
|
int height = menu_items [menu] + 4;
|
|
|
|
|
|
|
|
int aligned_x = (align == 0) ? x : ((render_width () - ICON_SIZE * width) / 2);
|
|
|
|
int aligned_y = (align == 0) ? y : ((render_height () - ICON_SIZE * height) / 2);
|
|
|
|
|
|
|
|
int offset_x = ICON_SIZE * (width - 3);
|
|
|
|
int offset_y = ICON_SIZE * (height - 3);
|
|
|
|
|
|
|
|
for (int p = 0; p < width - 1; ++p) {
|
|
|
|
for (int q = 0; q < height - 1; ++q) {
|
|
|
|
render_sprite (neonui, aligned_x + p * ICON_SIZE + ICON_SIZE / 2, aligned_y + q * ICON_SIZE + ICON_SIZE / 2, 0, 0, ICON_SIZE, ICON_SIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int n = 1; n < width - 1; ++n) {
|
|
|
|
render_sprite (neonui, aligned_x + n * ICON_SIZE, aligned_y, 560, 0, ICON_SIZE, ICON_SIZE);
|
|
|
|
render_sprite (neonui, aligned_x + n * ICON_SIZE, aligned_y + ICON_SIZE * (height - 1), 560, 0, ICON_SIZE, ICON_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int n = 1; n < height - 1; ++n) {
|
|
|
|
render_sprite (neonui, aligned_x, aligned_y + n * ICON_SIZE, 256, 128, ICON_SIZE, ICON_SIZE);
|
|
|
|
render_sprite (neonui, aligned_x + ICON_SIZE * (width - 1), aligned_y + n * ICON_SIZE, 256, 128, ICON_SIZE, ICON_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
render_sprite (neonui, aligned_x, aligned_y, 288, 0, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
|
|
|
render_sprite (neonui, aligned_x + offset_x, aligned_y, 384, 0, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
|
|
|
render_sprite (neonui, aligned_x, aligned_y + offset_y, 288, 96, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
|
|
|
render_sprite (neonui, aligned_x + offset_x, aligned_y + offset_y, 384, 96, 3 * ICON_SIZE, 3 * ICON_SIZE);
|
|
|
|
|
|
|
|
aligned_x += 2 * ICON_SIZE;
|
|
|
|
aligned_y += 2 * ICON_SIZE;
|
2023-12-20 00:07:54 -05:00
|
|
|
|
2023-12-21 14:20:00 -05:00
|
|
|
for (item = 0; item < menu_items [menu]; ++item) {
|
2023-12-21 16:59:45 -05:00
|
|
|
int u = (menu_icon [menu] [item] / 10) * ICON_SIZE;
|
|
|
|
int v = (menu_icon [menu] [item] % 10) * ICON_SIZE;
|
2023-12-20 00:07:54 -05:00
|
|
|
|
2023-12-21 14:20:00 -05:00
|
|
|
render_sprite (ui, aligned_x, aligned_y + item * ICON_SIZE, u, v, ICON_SIZE, ICON_SIZE);
|
2023-12-21 16:59:45 -05:00
|
|
|
|
2023-12-21 14:20:00 -05:00
|
|
|
render_string (menu_text [menu] [item], aligned_x + ICON_SIZE, aligned_y + item * ICON_SIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void view_map (void) {
|
2023-12-20 00:07:54 -05:00
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (x = 0; x < CHAD_WORLD_WIDTH; ++x) {
|
|
|
|
for (y = 0; y < CHAD_WORLD_HEIGHT; ++y) {
|
2023-12-21 14:20:00 -05:00
|
|
|
int index = chad_world [0] [x] [y];
|
|
|
|
int catch = (y * y + x + x / (y + 1) + y / (x + 1)) % chad_block_change [index];
|
2023-12-20 00:07:54 -05:00
|
|
|
|
2023-12-21 14:20:00 -05:00
|
|
|
render_sprite (ashlands, x * BASE_SIZE, y * BASE_SIZE, catch * BASE_SIZE, index * BASE_SIZE, BASE_SIZE, BASE_SIZE);
|
2023-12-20 00:07:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|