/* Display bootlist menu with selection */ void gui_show_menu(struct gui_t *gui, kx_menu *menu) { if (!gui) return; int i,j; int slotheight = LYT_MNI_HEIGHT; int slots = gui->height/slotheight -1; kx_menu_level *ml; // struct boot that is in fist slot static int firstslot=0; int cur_no; ml = menu->current; /* active menu level */ cur_no = ml->current_no; /* active menu item index */ /* FIXME: shouldn't be done here */ if (1 == ml->count) { /* Only system menu in list */ draw_background(gui, "No boot devices found.\nR: Reboot S: Rescan"); } else { draw_background(gui, "KEXECBOOT"); } if(cur_no < firstslot) firstslot = cur_no; if(cur_no > firstslot + slots -1) firstslot = cur_no - (slots -1); for(i=1, j=firstslot; i <= slots && j< ml->count; i++, j++) { draw_slot(gui, ml->list[j], i, slotheight, j == cur_no); } fb_render(gui->fb); }
void draw_screen(void) { draw_view(); draw_turn(); draw_stat(); draw_slot(); wrefresh(scroll_w); /* move the cursor */ }
void acceptboard(void) { struct ship *sp; int n; int crew[3]; int men = 0; char c; crew[0] = mc->crew1; crew[1] = mc->crew2; crew[2] = mc->crew3; for (n = 0; n < NBP; n++) { if (mf->OBP[n].turnsent) men += mf->OBP[n].mensent; } for (n = 0; n < NBP; n++) { if (mf->DBP[n].turnsent) men += mf->DBP[n].mensent; } if (men) { crew[0] = men/100 ? 0 : crew[0] != 0; crew[1] = (men%100)/10 ? 0 : crew[1] != 0; crew[2] = men%10 ? 0 : crew[2] != 0; } else { crew[0] = crew[0] != 0; crew[1] = crew[1] != 0; crew[2] = crew[2] != 0; } foreachship(sp) { if (sp == ms || sp->file->dir == 0 || range(ms, sp) > 1) continue; if (ms->nationality == capship(sp)->nationality) continue; if (meleeing(ms, sp) && crew[2]) { c = sgetch("How many more to board the %s (%c%c)? ", sp, 1); parties(crew, sp, 0, c); } else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) { c = sgetch("Crew sections to board the %s (%c%c) (3 max) ?", sp, 1); parties(crew, sp, 0, c); } } if (crew[2]) { c = sgetch("How many sections to repel boarders? ", NULL, 1); parties(crew, ms, 1, c); } blockalarm(); draw_slot(); unblockalarm(); }
repair() { char c; register char *repairs; register struct shipspecs *ptr = mc; register int count; #define FIX(x, m) (m - ptr->x > count \ ? (ptr->x += count, count = 0) : (count -= m - ptr->x, ptr->x = m)) if (repaired || loaded || fired || changed || turned()) { Signal("No hands free to repair", (struct ship *)0); return; } c = sgetch("Repair (hull, guns, rigging)? ", (struct ship *)0, 1); switch (c) { case 'h': repairs = &mf->RH; break; case 'g': repairs = &mf->RG; break; case 'r': repairs = &mf->RR; break; default: Signal("Avast heaving!", (struct ship *)0); return; } if (++*repairs >= 3) { count = 2; switch (c) { case 'h': { int max = ptr->guns/4; if (ptr->hull < max) { FIX(hull, max); Write(W_HULL, ms, 0, ptr->hull, 0, 0, 0); } break; } case 'g': if (ptr->gunL < ptr->gunR) { int max = ptr->guns/5 - ptr->carL; if (ptr->gunL < max) { FIX(gunL, max); Write(W_GUNL, ms, 0, ptr->gunL, ptr->carL, 0, 0); } } else { int max = ptr->guns/5 - ptr->carR; if (ptr->gunR < max) { FIX(gunR, max); Write(W_GUNR, ms, 0, ptr->gunR, ptr->carR, 0, 0); } } break; case 'r': #define X 2 if (ptr->rig4 >= 0 && ptr->rig4 < X) { FIX(rig4, X); Write(W_RIG4, ms, 0, ptr->rig4, 0, 0, 0); } if (count && ptr->rig3 < X) { FIX(rig3, X); Write(W_RIG3, ms, 0, ptr->rig3, 0, 0, 0); } if (count && ptr->rig2 < X) { FIX(rig2, X); Write(W_RIG2, ms, 0, ptr->rig2, 0, 0, 0); } if (count && ptr->rig1 < X) { FIX(rig1, X); Write(W_RIG1, ms, 0, ptr->rig1, 0, 0, 0); } break; } if (count == 2) { Signal("Repairs completed.", (struct ship *)0); *repairs = 2; } else { *repairs = 0; blockalarm(); draw_stat(); unblockalarm(); } } blockalarm(); draw_slot(); unblockalarm(); repaired = 1; }